Bläddra i källkod

台账模式增加空白清单和签约清单显示

ellisran 6 månader sedan
förälder
incheckning
8a530d7f45
1 ändrade filer med 86 tillägg och 9 borttagningar
  1. 86 9
      app/public/js/change_information.js

+ 86 - 9
app/public/js/change_information.js

@@ -2734,10 +2734,10 @@ $(document).ready(() => {
         cols: [
             {title: '计价', colSpan: '1', rowSpan: '2', field: 'is_valuation', hAlign: 1, width: 50, cellType: 'checkbox', getValue: 'getValue.is_valuation', readOnly: 'readOnly.isValuation'},
             {title: '项目节编号', colSpan: '1', rowSpan: '2', field: 'code', hAlign: 0, width: 120, formatter: '@', readOnly: true, cellType: 'tree' },
-            {title: '清单编号', colSpan: '1', rowSpan: '2', field: 'b_code', hAlign: 0, width: 80, formatter: '@', readOnly: true},
-            {title: '名称', colSpan: '1', rowSpan: '2', field: 'name', hAlign: 0, width: 120, formatter: '@', readOnly: true},
-            {title: '单位', colSpan: '1', rowSpan: '2', field: 'unit', hAlign: 1, width: 60, formatter: '@', readOnly: true},
-            {title: '单价', colSpan: '1', rowSpan: '2', field: 'unit_price', hAlign: 2, width: 60, type: 'Number', getValue: 'getValue.unit_price', readOnly: true},
+            {title: '清单编号', colSpan: '1', rowSpan: '2', field: 'b_code', hAlign: 0, width: 80, formatter: '@', readOnly: 'readOnly.isEdit2'},
+            {title: '名称', colSpan: '1', rowSpan: '2', field: 'name', hAlign: 0, width: 120, formatter: '@', readOnly: 'readOnly.isEdit2'},
+            {title: '单位', colSpan: '1', rowSpan: '2', field: 'unit', hAlign: 1, width: 60, formatter: '@', readOnly: 'readOnly.isEdit2', cellType: 'unit', comboItems: changeUnits, comboEdit: true},
+            {title: '单价', colSpan: '1', rowSpan: '2', field: 'unit_price', hAlign: 2, width: 60, type: 'Number', getValue: 'getValue.unit_price', readOnly: 'readOnly.isEdit2'},
             {title: '变更详情', colSpan: '1', rowSpan: '2', field: 'detail', hAlign: 0, width: 120, formatter: '@', readOnly: 'readOnly.isEdit'},
             {title: '计量上限(%)', colSpan: '1', rowSpan: '2', field: 'delimit', hAlign: 2, width: 60, type: 'Number', readOnly: 'readOnly.isEdit', visible: openChangeState},
             {title: '原设计|数量', colSpan: '2|1', rowSpan: '1|1', field: 'oamount2', hAlign: 2, width: 60, type: 'Number', readOnly: 'readOnly.isSettle', getValue: 'getValue.oamount2'},
@@ -2760,9 +2760,15 @@ $(document).ready(() => {
                     indent: 16,
                     getColor: function (index, data) {
                         if (!data) return;
-                        if (data.clid) {
+                        if (data.lid == 0) {
+                            return '#007bff';
+                        }
+                        if (data.clid && data.gcl_id) {
                             return '#28a745';
                         }
+                        if (data.clid && !data.gcl_id && data.lid != 0) {
+                            return '#ffc107';
+                        }
                         if (data.cid) {
                             return '#dc3545';
                         }
@@ -2842,6 +2848,9 @@ $(document).ready(() => {
             isEdit: function (data) {
                 return !(!readOnly && data.clid);
             },
+            isEdit2: function (data) {
+                return !(!readOnly && data.lid == 0 && data.clid);
+            },
             isValuation: function (data) {
                 return !(!readOnly && data.clid && _.findIndex(changeUsedData, { cbid: data.clid }) !== -1);
             },
@@ -3493,6 +3502,17 @@ $(document).ready(() => {
                     }
                 }
             }
+            if (col.field === 'unit') {
+                select.camount = ZhCalc.round(select.camount, findDecimal(validText)) || 0;
+                select.oamount2 = ZhCalc.round(select.oamount2, findDecimal(validText)) || 0;
+                cInfo.camount = select.camount;
+                cInfo.oamount2 = select.oamount2;
+            }
+            if (col.field === 'b_code') {
+                cInfo.code = validText;
+            } else {
+                cInfo[col.field] = validText;
+            }
             cInfo[col.field] = validText;
             select[col.field] = validText;
             console.log(cInfo);
@@ -3507,7 +3527,11 @@ $(document).ready(() => {
                 ledgerTreeSpreadObj.refreshTree(ledgerSheet, refreshData);
             }, function () {
                 select[col.field] = orgValue;
-                cInfo[col.field] = orgValue;
+                if (col.field === 'b_code') {
+                    cInfo.code = orgValue;
+                } else {
+                    cInfo[col.field] = orgValue;
+                }
                 if(col.field === 'camount') {
                     select.spamount = orgValue;
                     cInfo.spamount = orgValue;
@@ -3615,7 +3639,7 @@ $(document).ready(() => {
                         if (colSetting.field === 'delimit') {
                             const reg = /^(\d{1,2}|100)$/;
                             if (!(_.isNumber(validText) && reg.test(validText))) {
-                                toastr.error('计量单元第' + (hintRow+1) + '行计量上限默认值只能粘贴0-100之间的整数');
+                                toastr.error('清单第' + (hintRow+1) + '行计量上限默认值只能粘贴0-100之间的整数');
                                 bPaste = false;
                                 continue;
                             }
@@ -3624,7 +3648,7 @@ $(document).ready(() => {
                             if (usedInfo && usedInfo.qty) {
                                 const minLimit = Math.ceil(ZhCalc.mul(ZhCalc.div(usedInfo.qty, sortData[curRow].camount), 100));
                                 if (validText < minLimit) {
-                                    toastr.error('计量单元第' + (hintRow+1) + '行计量上限值至少大于等于 ' + minLimit);
+                                    toastr.error('清单第' + (hintRow+1) + '行计量上限值至少大于等于 ' + minLimit);
                                     bPaste = false;
                                     continue;
                                 }
@@ -3632,7 +3656,19 @@ $(document).ready(() => {
                         }
                     }
                     let unitdecimal = validText;
-                    cLData[colSetting.field] = validText;
+                    if (colSetting.field === 'unit') {
+                        //粘贴内容要为下拉列表里所有的单位,不然为空
+                        if (changeUnits.indexOf(validText) === -1) {
+                            unitdecimal = '';
+                        }
+                        cLData.camount = ZhCalc.round(sortData[curRow].camount, findDecimal(unitdecimal)) || 0;
+                        cLData.oamount2 = ZhCalc.round(sortData[curRow].oamount2, findDecimal(unitdecimal)) || 0;
+                    }
+                    if (colSetting.field === 'b_code') {
+                        cLData.code = validText;
+                    } else {
+                        cLData[colSetting.field] = validText;
+                    }
                     sortData[curRow][colSetting.field] = validText;
                     cLData.spamount = ZhCalc.round(sortData[curRow].camount, findDecimal(unitdecimal)) || 0;
                     sortData[curRow].spamount = cLData.spamount;
@@ -5409,6 +5445,7 @@ $(document).ready(() => {
             $('.judge-hide').attr("style","display:none !important");
             $('.judge-show').show();
             const {changeLedgers, changePoss} = makeLedgerAndPosData();
+            console.log(changeLedgers);
             ledgerTree.loadDatas(changeLedgers);
             pos.loadDatas(changePoss);
             treeCalc.calculateAll(ledgerTree);
@@ -5455,6 +5492,46 @@ $(document).ready(() => {
             }
             changeLedgers.push(...parentLedgers);
         }
+        // 找出空白清单和签约清单
+        const otherChangeList = _.filter(changeList, function (item) {
+            return item.gcl_id === '';
+        });
+        if (otherChangeList.length > 0) {
+            // 判断changeLedgers中是否已经存在第一部分
+            let firstChangeLedger = _.find(changeLedgers, { order: 1, level: 1 });
+            let firstOrder = 1;
+            if (firstChangeLedger) {
+                const firstChilds = _.filter(changeLedgers, { ledger_pid: firstChangeLedger.ledger_id });
+                firstOrder =  _.maxBy(firstChilds, 'order').order + 1;
+            }
+            let maxLedgerId = changeLedgers.length > 0 ? _.maxBy(changeLedgers, 'ledger_id').ledger_id + 1 : 1;
+            if (!firstChangeLedger) {
+                const firstLedger = _.find(ledgerList, { order: 1, level: 1 });
+                if (firstLedger) {
+                    changeLedgers.push(firstLedger);
+                    firstChangeLedger = firstLedger;
+                } else {
+                    firstChangeLedger = { id: 'new-tree-ledger-1', ledger_id: 1, ledger_pid: -1, name: '第一部分 建筑安装工程费', unit: '公路公里', unit_price: 0, b_code: null, code: '1', order: 1, level: 1, full_path: '1', is_leaf: 0 };
+                    changeLedgers.push(firstChangeLedger);
+                }
+            }
+            for (const cl of otherChangeList) {
+                const cloneCl = _.cloneDeep(cl);
+                cloneCl.b_code = cloneCl.code;
+                cloneCl.code = null;
+                cloneCl.clid = cl.id;
+                cloneCl.level = 2;
+                cloneCl.order = firstOrder;
+                cloneCl.is_leaf = 1;
+                cloneCl.ledger_pid = firstChangeLedger.ledger_id;
+                cloneCl.ledger_id = maxLedgerId;
+                cloneCl.full_path = firstChangeLedger.full_path + '-' + maxLedgerId;
+                console.log(cloneCl);
+                changeLedgers.push(cloneCl);
+                maxLedgerId++;
+                firstOrder++;
+            }
+        }
         const changePoss = _.filter(posList, function (item) {
             return _.findIndex(changeList, { mx_id: item.id }) !== -1;
         });