MaiXinRong 4 лет назад
Родитель
Сommit
98ef156d9e
3 измененных файлов с 50 добавлено и 13 удалено
  1. 33 8
      app/public/js/stage.js
  2. 15 4
      app/public/js/stage_im.js
  3. 2 1
      app/view/stage/index.ejs

+ 33 - 8
app/public/js/stage.js

@@ -2500,6 +2500,28 @@ $(document).ready(() => {
         }
         _initModifyDetail() {
             const self = this;
+            // 重置
+            $('#reset-detail').click(function () {
+                const data = SpreadJsObj.getSelectObject(self.spread.getActiveSheet());
+                if (!data.uuid) return;
+                const updateData = {
+                    lid: data.lid, pid: data.pid,
+                    uuid: data.uuid,
+                    custom_define: [],
+                };
+                for (const f of data.custom_define) {
+                    if (stageIm.resetFields.indexOf(f) >= 0) {
+                        updateData[f] = null;
+                    } else {
+                        updateData.custom_define.push(f);
+                    }
+                }
+                updateData.custom_define = updateData.custom_define.join(',');
+                postData(window.location.pathname + '/detail/save', updateData, function (result) {
+                    stageIm.loadUpdateDetailData(result);
+                    self.reLoadDetailData();
+                });
+            });
             // 编辑
             $('#edit-detail').click(function () {
                 $(this).hide();
@@ -2704,11 +2726,7 @@ $(document).ready(() => {
                     if (data.uuid) {
                         updateData.uuid = data.uuid;
                     }
-                    if (data.custom_define.indexOf('calc_img') === -1) {
-                        updateData.custom_define = data.custom_define;
-                        updateData.custom_define.push('calc_img');
-                        updateData.custom_define = updateData.custom_define.join(',');
-                    }
+
                     updateData.img = canvas.toDataURL('image/png');
                     updateData.imgInfo = itemInfo;
                     updateData.calc_img_remark = img_remark;
@@ -2792,7 +2810,14 @@ $(document).ready(() => {
         }
         reLoadDetailData() {
             const data = SpreadJsObj.getSelectObject(this.spread.getActiveSheet());
+            $('#reset-detail').hide();
             if (data) {
+                for (const f of data.custom_define) {
+                    if (stageIm.resetFields.indexOf(f) >= 0) {
+                        $('#reset-detail').show();
+                        break;
+                    }
+                }
                 $('#edit-detail').show();
                 $('#modify-img').show();
             } else {
@@ -3382,7 +3407,7 @@ $(document).ready(() => {
             //     timeout: 60000,
             // })
         }
-    })
+    });
 
     // 监听附件check是否选中
     $('.list-table').on('click', '.check-file', function() {
@@ -3394,13 +3419,13 @@ $(document).ready(() => {
         } else {
             checkBox.prop("checked", false)
         }
-    })
+    });
     $('.check-all-file').click(function() {
         const isCheck = $(this).is(':checked')
         $(this).parents('table').find('.list-table').each(function() {
             $(this).find('input:checkbox').prop("checked", isCheck)
         })
-    })
+    });
 
     // 显示层次
     (function (select, sheet) {

+ 15 - 4
app/public/js/stage_im.js

@@ -9,7 +9,8 @@
  */
 
 const stageIm = (function () {
-    const imFields = ['uuid', 'doc_code', 'peg', 'bw', 'xm', 'drawing_code', 'calc_memo', 'calc_img', 'calc_img_org','calc_img_remark', 'position', 'jldy'];
+    const imFields = ['uuid', 'peg', 'bw', 'xm', 'drawing_code', 'calc_memo', 'position', 'jldy'];
+    const resetFields = ['peg', 'bw', 'xm', 'drawing_code', 'calc_memo', 'position', 'jldy'];
     const splitChar = '-';
     const mergeChar = ';';
     let stage, imType, decimal, details, changes, ImData, pre;
@@ -254,10 +255,19 @@ const stageIm = (function () {
     }
 
     function loadCustomDetail(im, detail) {
+        if (!im.org) {
+            im.org = {};
+            for (const f of resetFields) {
+                im.org[f] = im[f];
+            }
+        }
         im.custom_define = detail.custom_define ? detail.custom_define.split(',') : imFields;
         _.assignInWith(im, detail, function (oV, sV, key) {
-            return (im.custom_define.indexOf(key) > -1 && sV !== undefined && sV !== null) ? sV : oV;
+            return (im.custom_define.indexOf(key) > -1) ? sV : ((resetFields.indexOf(key) > -1) ? im.org[key] : oV);
         });
+        im.uuid = detail.uuid;
+        im.doc_code = detail.doc_code;
+        im.calc_img = detail.calc_img;
         im.calc_img_org = detail.calc_img_org;
         im.calc_img_remark = detail.calc_img_remark;
     }
@@ -867,8 +877,8 @@ const stageIm = (function () {
         for (const d of datas) {
             const detail = _.find(details, {uuid: d.uuid});
             if (detail) {
-                _.assignInWith(detail, d, function (oV, sV, key) {
-                    return imFields.indexOf(key) > -1 && !_.isUndefined(sV) && !_.isNull(sV) ? sV : oV;
+                _.assignInWith(detail, d, function (oV, sV) {
+                    return !_.isUndefined(sV) ? sV : oV;
                 });
                 detail.custom_define = d.custom_define;
             } else {
@@ -988,5 +998,6 @@ const stageIm = (function () {
         getFirstUsed: getFirstUsed,
         getRelaXmj: getRelaXmj,
         getRelaImData: getRelaImData,
+        resetFields,
     }
 })();

+ 2 - 1
app/view/stage/index.ejs

@@ -131,7 +131,8 @@
                             <% if (!stage.readOnly) { %>
                             <legend class="sticky-top bg-white">
                                 <div class="d-flex justify-content-end mb-1">
-                                    <a href="javascript: void(0);" class="btn btn-sm btn-outline-primary" id="edit-detail" style="display: none;">编辑</a>
+                                    <a href="javascript: void(0);" class="btn btn-sm btn-outline-primary" id="reset-detail" style="display: none;">重置</a>
+                                    <a href="javascript: void(0);" class="btn btn-sm btn-outline-primary ml-1" id="edit-detail" style="display: none;">编辑</a>
                                     <a href="javascript: void(0);" class="btn btn-sm btn-outline-success" id="save-detail" style="display: none;">保存</a>
                                     <a href="javascript: void(0);" class="btn btn-sm btn-outline-secondary" id="cancel-detail" style="display: none;">取消</a>
                                 </div>