Ver código fonte

fix: 优化列配置逻辑,替换可选符

lanjianrong 3 meses atrás
pai
commit
4f11b1deb8
1 arquivos alterados com 11 adições e 11 exclusões
  1. 11 11
      app/public/js/contract_detail.js

+ 11 - 11
app/public/js/contract_detail.js

@@ -57,7 +57,7 @@ $(document).ready(function() {
                 return !permission_edit || data.c_code;
             },
             calc: function (data) {
-                return !permission_edit || data?.children?.length > 0;
+                return !permission_edit || (data && data.children && data.children.length > 0);
             },
         },
     }
@@ -78,12 +78,12 @@ $(document).ready(function() {
       calc2: {title: '计算2', colSpan: '1', rowSpan: '2', field: 'calc2', hAlign: 2, width: 120, type: 'Number', readOnly: 'readOnly.calc'},
     }
     // 根据 colSet 组装最终显示的列配置
-    colSet.forEach(col => {
-      const colInfo = colMap?.[col.field];
-      if (colInfo && col.show) {
-        contractSpreadSetting.cols.push({...colInfo, title: col?.alias || col.name});
-      }
-    });
+        colSet.forEach(col => {
+            const colInfo = colMap && colMap[col.field];
+            if (colInfo && col.show) {
+                contractSpreadSetting.cols.push(Object.assign({}, colInfo, { title: (col && col.alias) || col.name }));
+            }
+        });
 
 
     const contractSpread = SpreadJsObj.createNewSpread($('#contract-spread')[0]);
@@ -415,7 +415,7 @@ $(document).ready(function() {
         },
         setContract: function (sheet) {
             const node = SpreadJsObj.getSelectObject(sheet);
-            
+
             if (node && node.c_code) {
                 $('#htdetail-table').show();
                 $('#htpay-table').show();
@@ -597,7 +597,7 @@ $(document).ready(function() {
                 const col = info.sheet.zh_setting.cols[info.col];
                 const sortData = info.sheet.zh_dataType === 'tree' ? info.sheet.zh_tree.nodes : info.sheet.zh_data;
                 const node = sortData[info.row];
-                
+
                 const data = {
                     id: node.id,
                 };
@@ -615,8 +615,8 @@ $(document).ready(function() {
                     data[col.field] = null;
                 }
                 // 更新至服务器
-                
-                postData(window.location.pathname + '/update', {postType: node?.c_code ? 'update-contract' : 'update', postData: data}, function (result) {
+
+                postData(window.location.pathname + '/update', {postType: (node && node.c_code) ? 'update-contract' : 'update', postData: data}, function (result) {
                     const refreshNode = contractTree.loadPostData(result);
                     contractTreeSpreadObj.refreshTree(info.sheet, refreshNode);
                 });