Browse Source

优化双击添加大司空数据功能

ellisran 1 month ago
parent
commit
de4829b835
1 changed files with 32 additions and 1 deletions
  1. 32 1
      app/public/js/change_revise.js

+ 32 - 1
app/public/js/change_revise.js

@@ -3917,8 +3917,38 @@ $(document).ready(() => {
                         return;
                         return;
                     }
                     }
                     const is_bill = dealBills.kind === 4;
                     const is_bill = dealBills.kind === 4;
+                    // 判断dealBills.code以-开头,是则向上判断是否需要拼接code名称
+                    function makeCode(dealBills) {
+                        const originalCode = dealBills.code;
+                        if (!originalCode || originalCode.charAt(0) !== '-') {
+                            return originalCode;
+                        }
+                        const parents = dealSheet.zh_tree.getAllParents(dealBills);
+                        if (!parents || parents.length === 0) {
+                            return originalCode;
+                        }
+                        const kind4Parents = _.filter(parents, { kind: 4 });
+                        if (!kind4Parents || kind4Parents.length === 0) {
+                            return originalCode;
+                        }
+                        const firstParentCode = kind4Parents[0].code;
+                        if (firstParentCode.charAt(0) === '-') {
+                            return originalCode;
+                        }
+                        const codeParts = [];
+                        for (const parent of kind4Parents.reverse()) {
+                            codeParts.push(parent.code);
+                            if (parent.code.charAt(0) !== '-') {
+                                break;
+                            }
+                        }
+                        if (codeParts.length > 0) {
+                            return codeParts.reverse().join('') + originalCode;
+                        }
+                        return originalCode;
+                    }
                     const oneBills = {
                     const oneBills = {
-                        b_code: is_bill ? dealBills.code : null, code: !is_bill ? dealBills.code : null, name: dealBills.name, unit: dealBills.unit,
+                        b_code: is_bill ? makeCode(dealBills) : null, code: !is_bill ? dealBills.code : null, name: dealBills.name, unit: dealBills.unit,
                         unit_price: is_bill ? dealBills.unitPrice : null, quantity: is_bill ? dealBills.quantity : null, total_price: is_bill ? dealBills.totalPrice : null,
                         unit_price: is_bill ? dealBills.unitPrice : null, quantity: is_bill ? dealBills.quantity : null, total_price: is_bill ? dealBills.totalPrice : null,
                         sgfh_qty: is_bill ? dealBills.quantity : null, sgfh_tp: is_bill ? dealBills.totalPrice : null,
                         sgfh_qty: is_bill ? dealBills.quantity : null, sgfh_tp: is_bill ? dealBills.totalPrice : null,
                     };
                     };
@@ -4058,6 +4088,7 @@ $(document).ready(() => {
         }
         }
         postData('/profile/dsk/api', { type: 'project_bills', tid: window.location.pathname.split('/')[2], compilationId: projectInfo.compilationId, treeId }, function (result) {
         postData('/profile/dsk/api', { type: 'project_bills', tid: window.location.pathname.split('/')[2], compilationId: projectInfo.compilationId, treeId }, function (result) {
             const tree = dskProjectBills2Tree.convert(result);
             const tree = dskProjectBills2Tree.convert(result);
+            console.log(tree);
             SpreadJsObj.loadSheetData(dskBills.spread.getActiveSheet(), SpreadJsObj.DataType.Tree, tree);
             SpreadJsObj.loadSheetData(dskBills.spread.getActiveSheet(), SpreadJsObj.DataType.Tree, tree);
         });
         });
     }
     }