Просмотр исходного кода

变更令增加新增单价勾选功能

ellisran 2 недель назад
Родитель
Сommit
7e3d97f1c6

+ 1 - 1
app/controller/change_controller.js

@@ -971,7 +971,7 @@ module.exports = app => {
             const ledgerColumn = [
                 'id', 'tender_id', 'ledger_id', 'ledger_pid', 'level', 'order', 'full_path', 'is_leaf',
                 'code', 'b_code', 'name', 'unit', 'unit_price', 'quantity', 'total_price',
-                'sgfh_qty', 'sgfh_expr', 'sgfh_tp', 'memo', 'features', 'drawing_code', 'node_type', 'ex_qty1', 'ex_tp1', 'ccid'];
+                'sgfh_qty', 'sgfh_expr', 'sgfh_tp', 'memo', 'features', 'drawing_code', 'node_type', 'ex_qty1', 'ex_tp1', 'ccid', 'is_new_price'];
             if (tender.info.display.ledger.deal) ledgerColumn.push('deal_qty', 'deal_tp');
             if (tender.info.display.ledger.dgnQty) ledgerColumn.push('dgn_qty1', 'dgn_qty2');
             if (tender.info.display.ledger.clQty) ledgerColumn.push('sjcl_qty', 'qtcl_qty', 'sjcl_expr', 'qtcl_expr', 'sjcl_tp', 'qtcl_tp');

+ 105 - 27
app/public/js/change_information.js

@@ -578,6 +578,7 @@ $(document).ready(() => {
     const changeSpreadSetting = {
         cols: [
             {title: '计价', colSpan: '1', rowSpan: '2', field: 'is_valuation', hAlign: 1, width: 50, cellType: 'checkbox', readOnly: 'readOnly.isValuation'},
+            {title: '新增单价', colSpan: '1', rowSpan: '2', field: 'is_new_price', hAlign: 1, width: 35, cellType: 'checkbox', readOnly: 'readOnly.isNewPrice'},
             {title: '清单编号', colSpan: '1', rowSpan: '2', field: 'code', hAlign: 0, width: 80, formatter: '@', readOnly: 'readOnly.isEdit'},
             {title: '名称', colSpan: '1', rowSpan: '2', field: 'name', hAlign: 0, width: 120, formatter: '@', readOnly: 'readOnly.isEdit'},
             {title: '单位', colSpan: '1', rowSpan: '2', field: 'unit', hAlign: 1, width: 60, formatter: '@', readOnly: 'readOnly.isEdit', cellType: 'unit', comboItems: changeUnits, comboEdit: true},
@@ -699,6 +700,13 @@ $(document).ready(() => {
             },
             isSettle2: function (data) {
                 return !(!readOnly && ((data.id && !checkIsSettle(data)) || (data.children && data.children.length === 1 && !checkIsSettle(data.children[0]))));
+            },
+            isNewPrice: function (data) {
+                if (!data || readOnly) return true;
+                if (!readOnly && data.is_add_list) {
+                    return false;
+                }
+                return true;
             }
         },
     };
@@ -897,6 +905,11 @@ $(document).ready(() => {
             let i = 0;
             // 重算金额和数量汇总
             for (const node of newChangeList) {
+                if (node.gcl_id && _.findIndex(changeLedgerList, { id: node.gcl_id }) !== -1) {
+                    node.is_add_list = 1;
+                    const ledger = _.find(changeLedgerList, { id: node.gcl_id });
+                    node.is_new_price = ledger ? ledger.is_new_price : 0;
+                }
                 if (node.children && node.children.length > 0) {
                     changeSpreadObj.calcOneSum(node);
                     node.order = i + 1;
@@ -1336,7 +1349,7 @@ $(document).ready(() => {
                 return;
             }
             const col = info.sheet.zh_setting.cols[info.col];
-            if (col.field === 'is_valuation') {
+            if (col.field === 'is_valuation' || col.field === 'is_new_price') {
                 return;
             }
             let validText = is_numeric(info.editingText) && _.indexOf(numField, col.field) !== -1 ? parseFloat(info.editingText) : (info.editingText ? trimInvalidChar(info.editingText) : '');
@@ -1588,21 +1601,21 @@ $(document).ready(() => {
         };
         changeSpreadObj.buttonClicked = function(e, info) {
             if (info.sheet.zh_setting) {
-                const select = SpreadJsObj.getSelectObject(info.sheet);
-                if (!select || !select.id) {
-                    changeSpreadObj.reloadRow(info.sheet, info.row);
-                    return;
-                }
-                const cInfo = _.find(changeList, { id: select.id });
-                if (!cInfo) {
-                    toastr.error('数据错误,请刷新页面重试');
-                    changeSpreadObj.reloadRow(info.sheet, info.row);
-                    return;
+                if (info.sheet.isEditing()) {
+                    info.sheet.endEdit(true);
                 }
+                const select = SpreadJsObj.getSelectObject(info.sheet);
                 const col = info.sheet.zh_setting.cols[info.col];
                 if (col.field === 'is_valuation') {
-                    if (info.sheet.isEditing()) {
-                        info.sheet.endEdit(true);
+                    if (!select || !select.id) {
+                        changeSpreadObj.reloadRow(info.sheet, info.row);
+                        return;
+                    }
+                    const cInfo = _.find(changeList, { id: select.id });
+                    if (!cInfo) {
+                        toastr.error('数据错误,请刷新页面重试');
+                        changeSpreadObj.reloadRow(info.sheet, info.row);
+                        return;
                     }
                     if (_.findIndex(changeUsedData, { cbid: select.id }) !== -1) {
                         return;
@@ -1623,6 +1636,32 @@ $(document).ready(() => {
                         cInfo.is_valuation = select.is_valuation;
                         changeSpreadObj.reloadRow(info.sheet, info.row);
                     });
+                } else if (col.field === 'is_new_price') {
+                    // 判断是否为新增清单,是新增清单允许修改此项
+                    if (changeCol.readOnly.isNewPrice(select)) {
+                        changeSpreadObj.reloadRow(info.sheet, info.row);
+                        return;
+                    }
+                    select.is_new_price = info.sheet.getValue(info.row, info.col) ? 0 : 1;
+                    const c = _.find(changeLedgerList, { id: select.gcl_id });
+                    const data = {
+                        id: c.id,
+                        tender_id: c.tender_id,
+                        ledger_id: c.ledger_id,
+                        is_new_price: select.is_new_price,
+                    };
+                    // 单独更新到新增部位
+                    postData(window.location.pathname + '/revise/update', { postType: 'update', postData: data }, function (result) {
+                        c.is_new_price = select.is_new_price;
+                        const ledger = _.find(ledgerList, { id: c.id });
+                        if (ledger) {
+                            ledger.is_new_price = select.is_new_price;
+                        }
+                        changeSpreadObj.reloadRow(info.sheet, info.row);
+                    }, function () {
+                        select.is_new_price = info.sheet.getValue(info.row, info.col) ? 1 : 0;
+                        changeSpreadObj.reloadRow(info.sheet, info.row);
+                    });
                 }
             }
         };
@@ -2763,6 +2802,7 @@ $(document).ready(() => {
     const ledgerSpreadSetting = {
         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: 'is_new_price', hAlign: 1, width: 35, cellType: 'checkbox', readOnly: 'readOnly.isNewPrice'},
             {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: 'readOnly.isEdit2'},
             {title: '名称', colSpan: '1', rowSpan: '2', field: 'name', hAlign: 0, width: 120, formatter: '@', readOnly: 'readOnly.isEdit2'},
@@ -2890,6 +2930,13 @@ $(document).ready(() => {
             },
             isSettle2: function (data) {
                 return !(!readOnly && data.clid && !checkIsSettle(data));
+            },
+            isNewPrice: function (data) {
+                if (!data || readOnly) return true;
+                if (!readOnly && data.is_leaf === 1 && _.findIndex(changeLedgerList, { id: data.id }) !== -1) {
+                    return false;
+                }
+                return true;
             }
         },
     };
@@ -3445,7 +3492,7 @@ $(document).ready(() => {
                 return;
             }
             const col = info.sheet.zh_setting.cols[info.col];
-            if (col.field === 'is_valuation') {
+            if (col.field === 'is_valuation' || col.field === 'is_new_price') {
                 return;
             }
             const sortData = info.sheet.zh_dataType === 'tree' ? info.sheet.zh_tree.nodes : info.sheet.zh_data;
@@ -3736,21 +3783,21 @@ $(document).ready(() => {
         };
         ledgerTreeSpreadObj.buttonClicked = function(e, info) {
             if (info.sheet.zh_setting) {
-                const select = SpreadJsObj.getSelectObject(info.sheet);
-                if (!select || !select.clid) {
-                    SpreadJsObj.reLoadRowData(info.sheet, info.row);
-                    return;
-                }
-                const cInfo = _.find(changeList, { id: select.clid });
-                if (!cInfo) {
-                    toastr.error('数据错误,请刷新页面重试');
-                    SpreadJsObj.reLoadRowData(info.sheet, info.row);
-                    return;
+                if (info.sheet.isEditing()) {
+                    info.sheet.endEdit(true);
                 }
+                const select = SpreadJsObj.getSelectObject(info.sheet);
                 const col = info.sheet.zh_setting.cols[info.col];
                 if (col.field === 'is_valuation') {
-                    if (info.sheet.isEditing()) {
-                        info.sheet.endEdit(true);
+                    if (!select || !select.clid) {
+                        SpreadJsObj.reLoadRowData(info.sheet, info.row);
+                        return;
+                    }
+                    const cInfo = _.find(changeList, { id: select.clid });
+                    if (!cInfo) {
+                        toastr.error('数据错误,请刷新页面重试');
+                        SpreadJsObj.reLoadRowData(info.sheet, info.row);
+                        return;
                     }
                     if (_.findIndex(changeUsedData, { cbid: select.clid }) !== -1) {
                         return;
@@ -3770,6 +3817,37 @@ $(document).ready(() => {
                         cInfo.is_valuation = select.is_valuation;
                         SpreadJsObj.reLoadRowData(info.sheet, info.row);
                     });
+                } else if (col.field === 'is_new_price') {
+                    if (ledgerCol.readOnly.isNewPrice(select)) {
+                        SpreadJsObj.reLoadRowData(info.sheet, info.row);
+                        return;
+                    }
+                    select.is_new_price = info.sheet.getValue(info.row, info.col) ? 0 : 1;
+                    const c = _.find(changeLedgerList, { id: select.id });
+                    const data = {
+                        id: c.id,
+                        tender_id: c.tender_id,
+                        ledger_id: c.ledger_id,
+                        is_new_price: select.is_new_price,
+                    };
+                    // 单独更新到新增部位
+                    postData(window.location.pathname + '/revise/update', { postType: 'update', postData: data }, function (result) {
+                        c.is_new_price = select.is_new_price;
+                        const ledger = _.find(ledgerList, { id: c.id });
+                        if (ledger) {
+                            ledger.is_new_price = select.is_new_price;
+                        }
+                        const loadResult = {
+                            update: [select],
+                        };
+                        const refreshData = ledgerTree.loadPostData(loadResult);
+                        console.log(select, loadResult, refreshData);
+                        ledgerTreeSpreadObj.refreshTree(ledgerSheet, refreshData);
+                    }, function () {
+                        select.is_new_price = info.sheet.getValue(info.row, info.col) ? 1 : 0;
+                        SpreadJsObj.reLoadRowData(info.sheet, info.row);
+                    });
+
                 }
             }
         };
@@ -5514,7 +5592,7 @@ $(document).ready(() => {
         ledgerTree.loadDatas(changeLedgers);
         pos.loadDatas(changePoss);
         treeCalc.calculateAll(ledgerTree);
-        console.log(ledgerTree);
+        console.log(changeLedgers, ledgerTree);
         SpreadJsObj.loadSheetData(ledgerSheet, SpreadJsObj.DataType.Tree, ledgerTree);
         ledgerTree.expandByCustom(() => { return true; });
         SpreadJsObj.refreshTreeRowVisible(ledgerSheet);

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

@@ -122,6 +122,7 @@ $(document).ready(() => {
             }
         }
     };
+    console.log(billsSpreadSetting.cols);
     const posCol = {
         getValue: {
             isChange: function (data) {
@@ -825,6 +826,36 @@ $(document).ready(() => {
                         cInfo.is_valuation = select.is_valuation;
                         SpreadJsObj.reLoadRowData(info.sheet, info.row);
                     });
+                } else if (col.field === 'is_new_price') {
+                    if (info.sheet.isEditing()) {
+                        info.sheet.endEdit(true);
+                    }
+                    if (billsCol.readOnly.isChangeAdd(select)) {
+                        SpreadJsObj.reLoadRowData(info.sheet, info.row);
+                        return;
+                    }
+                    if (select && select.is_leaf === 0) {
+                        SpreadJsObj.reLoadRowData(info.sheet, info.row);
+                        return;
+                    }
+                    const is_new_price = info.sheet.getValue(info.row, info.col) ? 1 : 0;
+                    select.is_new_price = is_new_price;
+                    const data = {
+                        id: select.id,
+                        tender_id: select.tender_id,
+                        ledger_id: select.ledger_id,
+                        is_new_price: is_new_price,
+                    };
+                    postData(window.location.pathname + '/update', {postType: 'update', postData: data}, function (result) {
+                        changeList = result.changeList;
+                        const refreshNode = billsTree.loadPostData(result);
+                        for (const u of refreshNode.update) {
+                            billsTreeSpreadObj.reCalcCamount(u);
+                        }
+                        billsTreeSpreadObj.refreshTree(info.sheet, refreshNode);
+                        billsTreeSpreadObj.refreshPosData();
+                        changeGclData = true;
+                    });
                 }
             }
         },
@@ -836,7 +867,7 @@ $(document).ready(() => {
         editEnded: function (e, info) {
             if (info.sheet.zh_setting) {
                 const col = info.sheet.zh_setting.cols[info.col];
-                if (col.field === 'is_change' || col.field === 'is_valuation') {
+                if (col.field === 'is_change' || col.field === 'is_valuation' || col.field === 'is_new_price') {
                     return;
                 }
                 const sortData = info.sheet.zh_dataType === 'tree' ? info.sheet.zh_tree.nodes : info.sheet.zh_data;

+ 3 - 0
sql/update.sql

@@ -312,6 +312,9 @@ CREATE TABLE `zh_pos_calc_detail`  (
 ALTER TABLE `zh_material_list`
 ADD COLUMN `qty` decimal(30, 8) NULL DEFAULT NULL COMMENT '本期调差数量' AFTER `gather_qty`;
 
+ALTER TABLE `zh_change_ledger`
+ADD COLUMN `is_new_price` tinyint(1) UNSIGNED NOT NULL DEFAULT 0 COMMENT '新增单价' AFTER `ex_tp1`;
+
 ------------------------------------
 -- 表数据
 ------------------------------------