Bläddra i källkod

草图备注相关

MaiXinRong 3 år sedan
förälder
incheckning
adf830cb84
2 ändrade filer med 25 tillägg och 23 borttagningar
  1. 10 8
      app/controller/stage_controller.js
  2. 15 15
      app/public/js/stage.js

+ 10 - 8
app/controller/stage_controller.js

@@ -703,15 +703,17 @@ module.exports = app => {
                 const data = JSON.parse(ctx.request.body.data);
                 const data = JSON.parse(ctx.request.body.data);
 
 
                 if (data.updateType === 'update') {
                 if (data.updateType === 'update') {
-                    const create_time = Date.parse(new Date()) / 1000;
-                    const fileName = path.join('public/upload', this.ctx.tender.id.toString(), 'im', 'calcImg_' + create_time + '.png');
-                    const base64Data = data.img.replace(/^data:image\/\w+;base64,/, '');
-                    const dataBuffer = new Buffer.from(base64Data, 'base64');
-                    await this.ctx.helper.saveBufferFile(dataBuffer, path.join(this.app.baseDir, 'app', fileName));
-                    data.calc_img = fileName;
-                    data.calc_img_org = JSON.stringify(data.imgInfo);
+                    if (data.img) {
+                        const create_time = Date.parse(new Date()) / 1000;
+                        const fileName = path.join('public/upload', this.ctx.tender.id.toString(), 'im', 'calcImg_' + create_time + '.png');
+                        const base64Data = data.img.replace(/^data:image\/\w+;base64,/, '');
+                        const dataBuffer = new Buffer.from(base64Data, 'base64');
+                        await this.ctx.helper.saveBufferFile(dataBuffer, path.join(this.app.baseDir, 'app', fileName));
+                        data.calc_img = fileName;
+                        data.calc_img_org = JSON.stringify(data.imgInfo);
+                        delete data.img;
+                    }
                     delete data.updateType;
                     delete data.updateType;
-                    delete data.img;
                     delete data.imgInfo;
                     delete data.imgInfo;
                 } else if (data.updateType === 'clear') {
                 } else if (data.updateType === 'clear') {
                     data.calc_img = null;
                     data.calc_img = null;

+ 15 - 15
app/public/js/stage.js

@@ -3162,6 +3162,19 @@ $(document).ready(() => {
                 const items = $('.img-item');
                 const items = $('.img-item');
                 const img_remark = $('#text-edit').val();
                 const img_remark = $('#text-edit').val();
                 const data = SpreadJsObj.getSelectObject(self.spread.getActiveSheet());
                 const data = SpreadJsObj.getSelectObject(self.spread.getActiveSheet());
+
+                // 生成上传数据
+                const updateData = {updateType: 'update', lid: data.lid, pid: data.pid, calc_img_remark: img_remark};
+                if (data.uuid) {
+                    updateData.uuid = data.uuid;
+                } else {
+                    updateData.code = data.code;
+                    updateData.name = data.name;
+                    updateData.unit = data.unit;
+                    updateData.unit_price = data.unit_price;
+                    updateData.pid = data.pid;
+                    updateData.pos_name = data.pos_name;
+                }
                 if (items.length > 0) {
                 if (items.length > 0) {
                     const itemInfo = [];
                     const itemInfo = [];
                     for (const item of items) {
                     for (const item of items) {
@@ -3187,22 +3200,9 @@ $(document).ready(() => {
                         const img = $('img', b)[0];
                         const img = $('img', b)[0];
                         ctx.drawImage(img, pos.left, pos.top, img.width, img.height);
                         ctx.drawImage(img, pos.left, pos.top, img.width, img.height);
                     }
                     }
-                    // 生成上传数据
-                    const updateData = {updateType: 'update', lid: data.lid, pid: data.pid};
-                    if (data.uuid) {
-                        updateData.uuid = data.uuid;
-                    } else {
-                        updateData.code = data.code;
-                        updateData.name = data.name;
-                        updateData.unit = data.unit;
-                        updateData.unit_price = data.unit_price;
-                        updateData.pid = data.pid;
-                        updateData.pos_name = data.pos_name;
-                    }
 
 
                     updateData.img = canvas.toDataURL('image/png');
                     updateData.img = canvas.toDataURL('image/png');
                     updateData.imgInfo = itemInfo;
                     updateData.imgInfo = itemInfo;
-                    updateData.calc_img_remark = img_remark;
                     self.updateImageData = updateData;
                     self.updateImageData = updateData;
                     $('#calc-img').attr('src', updateData.img);
                     $('#calc-img').attr('src', updateData.img);
                     $('#view-calc-img').attr('src', updateData.img);
                     $('#view-calc-img').attr('src', updateData.img);
@@ -3223,7 +3223,7 @@ $(document).ready(() => {
                     //     $('#edit-img').modal('hide');
                     //     $('#edit-img').modal('hide');
                     // });
                     // });
                 } else if (data.calc_img) {
                 } else if (data.calc_img) {
-                    self.updateImageData = {updateType: 'clear', lid: data.lid, pid: data.pid, uuid: data.uuid};
+                    self.updateImageData = {updateType: 'clear', lid: data.lid, pid: data.pid, uuid: data.uuid, calc_img_remark: img_remark};
                     $('#show-calc-img').attr('src', '');
                     $('#show-calc-img').attr('src', '');
                     $('#calc-img').attr('src', '');
                     $('#calc-img').attr('src', '');
                     $('#view-calc-img').attr('src', '');
                     $('#view-calc-img').attr('src', '');
@@ -3241,7 +3241,7 @@ $(document).ready(() => {
                     //     $('#edit-img').modal('hide');
                     //     $('#edit-img').modal('hide');
                     // });
                     // });
                 } else {
                 } else {
-                    self.updateImageData = null;
+                    self.updateImageData = updateData;
                     $('#show-calc-img').attr('src', '');
                     $('#show-calc-img').attr('src', '');
                     $('#calc-img').attr('src', '');
                     $('#calc-img').attr('src', '');
                     $('#view-calc-img').attr('src', '');
                     $('#view-calc-img').attr('src', '');