MaiXinRong 7 месяцев назад
Родитель
Сommit
8cedfe70d7

+ 1 - 0
app/const/page_show.js

@@ -28,6 +28,7 @@ const defaultSetting = {
     bwtz: 0,
     xxjd: 0,
     openMaterial: 1,
+    openIsolatePay: 0,
     stageExtra: 1,
     closeExportPdf: 0,
     closeExportExcel: 0,

+ 75 - 1
app/public/js/phase_pay_detail.js

@@ -40,6 +40,9 @@ $(document).ready(() => {
             },
             isSf: function(data) {
                 return data.pay_type === 'bqsf';
+            },
+            isGatherValid: function(data) {
+                return !data.pay_type && (!data.children || data.children.length === 0);
             }
         }
     };
@@ -385,7 +388,7 @@ $(document).ready(() => {
                 {title: '截止本期金额',  colSpan: '1', rowSpan: '1', field: 'end_tp', hAlign: 2, width: 100, readOnly: true, type: 'Number'},
                 {title: '起扣金额',  colSpan: '1', rowSpan: '1', field: 'start_tp', hAlign: 2, width: 100, type: 'Number'},
                 {title: '付(扣)款限额',  colSpan: '1', rowSpan: '1', field: 'range_tp', hAlign: 2, width: 100, cellType: 'tip', type: 'Number', getTip: payUtils.tips.range_tp},
-                {title: '汇总',  colSpan: '1', rowSpan: '1', field: 'is_yf', hAlign: 2, width: 60, readOnly: true, type: 'checkbox'},
+                {title: '汇总',  colSpan: '1', rowSpan: '1', field: 'is_gather', hAlign: 1, width: 60, cellType: 'signalCheckbox', show: payUtils.check.isGatherValid},
                 {title: '附件', colSpan: '1', rowSpan: '1', field: 'attachment', hAlign: 0, width: 60, readOnly: true, cellType: 'imageBtn', normalImg: '#rela-file-icon', hoverImg: '#rela-file-hover', getValue: 'getValue.attachment'},
                 {title: '本期批注', colSpan: '1', rowSpan: '1', field: 'postil', hAlign: 0, width: 120, formatter: '@', cellType: 'autoTip'},
             ],
@@ -507,6 +510,9 @@ $(document).ready(() => {
                     case 'range_tp':
                         info.cancel = (select.children && select.children.length > 0) || payUtils.check.isYf(select);
                         break;
+                    case 'is_gather':
+                        info.cancel = true;
+                        break;
                 }
 
                 if (col.field === 'tp') {
@@ -602,6 +608,72 @@ $(document).ready(() => {
                 }
                 payEvent.loadExprToInput();
             },
+            buttonClicked: function (e, info) {
+                if (!info.sheet.zh_setting) return;
+
+                const select = SpreadJsObj.getSelectObject(info.sheet);
+                const col = info.sheet.zh_setting.cols[info.col];
+                if (col.field !== 'is_gather') return;
+                if (!payUtils.check.isGatherValid(select)) return;
+                if (info.sheet.isEditing()) info.sheet.endEdit(true);
+
+                const data = {
+                    postType: 'update',
+                    postData: { id: select.id },
+                };
+                data.postData[col.field] = info.sheet.getValue(info.row, info.col) || 0;
+                // 更新至服务器
+                postData('update', data, function (result) {
+                    if (result.reload) payEvent.reloadPays(result.reload);
+                });
+            },
+            deletePress: function (sheet) {
+                if (!sheet.zh_setting) return;
+
+                const sel = sheet.getSelections()[0];
+                if (!sel) return;
+                const col = sheet.zh_setting.cols[sel.col];
+                if (col.readOnly === true) return;
+                if (sel.colCount > 1) toastr.warning('请勿同时删除多列数据');
+
+                const data = { postType: 'update', postData: [] };
+                for (let iRow = sel.row; iRow < sel.row + sel.rowCount; iRow ++) {
+                    const node = sheet.zh_tree.nodes[iRow];
+                    if (node && (!node.pay_type || col.field === 'postil')) {
+                        const updateData = { id: node.id };
+                        switch(col.field) {
+                            case 'tp':
+                                updateData.tp = 0;
+                                updateData.expr = '';
+                                break;
+                            case 'start_tp':
+                                updateData.start_tp = 0;
+                                updateData.start_expr = '';
+                                break;
+                            case 'range_tp':
+                                updateData.range_tp = 0;
+                                updateData.range_expr = '';
+                                break;
+                            case 'is_gather':
+                                updateData.is_gather = 0;
+                                break;
+                            default:
+                                updateData[col.field] = col.type === 'Number' ? 0 : '';
+                        }
+                        data.postData.push(updateData);
+                    }
+                }
+                postData('update', data, function (result) {
+                    if (result.reload) {
+                        payEvent.reloadPays(result.reload);
+                    } else {
+                        const refreshData = payTree.loadPostData(result);
+                        payEvent.refreshTree(refreshData);
+                    }
+                }, function () {
+                    SpreadJsObj.reLoadRowData(sheet, sel.row, sel.rowCount);
+                });
+            },
             baseOpr: function(type) {
                 const self = this;
                 const node = SpreadJsObj.getSelectObject(sheet);
@@ -638,6 +710,8 @@ $(document).ready(() => {
         if (!readOnly) {
             spread.bind(spreadNS.Events.EditStarting, payEvent.editStarting);
             spread.bind(spreadNS.Events.EditEnded, payEvent.editEnded);
+            spread.bind(spreadNS.Events.ButtonClicked, payEvent.buttonClicked);
+            SpreadJsObj.addDeleteBind(spread, payEvent.deletePress);
             $('a[name="base-opr"]').click(function () {
                 payEvent.baseOpr(this.getAttribute('type'));
             });

+ 37 - 0
app/public/js/spreadjs_rela/spreadjs_zh.js

@@ -740,6 +740,13 @@ const SpreadJsObj = {
             sheet.getRange(-1, col, -1, 1).cellType(sheet.extendCellType.checkbox);
             sheet.getRange(-1, col, -1, 1).hAlign(col ? col.hAlign : spreadNS.HorizontalAlign.center);// 空白行不居中问题,checkbox要默认居中
         }
+        if (colSetting.cellType === 'signalCheckbox') {
+            if (!sheet.extendCellType.signalCheckbox) {
+                sheet.extendCellType.signalCheckbox = this.CellType.getSignalCheckboxCellType();
+            }
+            sheet.getRange(-1, col, -1, 1).cellType(sheet.extendCellType.signalCheckbox);
+            sheet.getRange(-1, col, -1, 1).hAlign(col ? col.hAlign : spreadNS.HorizontalAlign.center);// 空白行不居中问题,checkbox要默认居中
+        }
         if (colSetting.cellType === 'unit') {
             if (!sheet.extendCellType.unit) {
                 const comboEdit = colSetting.comboEdit ? colSetting.comboEdit : false;
@@ -2825,6 +2832,36 @@ const SpreadJsObj = {
             };
             return new stackedBarCellType();
         },
+        getSignalCheckboxCellType: function () {
+            const SignalCheckboxCellType = function () {};
+            SignalCheckboxCellType.prototype = new spreadNS.CellTypes.CheckBox();
+            const proto = SignalCheckboxCellType.prototype;
+            proto.showCheckBox = function (sheet, iRow, iCol) {
+                const col = sheet.zh_setting.cols[iCol];
+                if (col.show && Object.prototype.toString.apply(col.show) === "[object Function]") {
+                    const sortData = SpreadJsObj.getSortData(sheet);
+                    const data = sortData ? sortData[iRow] : null;
+                    return data ? col.show(data) : false;
+                } else {
+                    return col.show !== undefined && col.show !== null ? col.show : true ;
+                }
+            };
+            proto.paintValue = function (ctx, value, x, y, w, h, style, options) {
+                if (this.showCheckBox(options.sheet, options.row, options.col)) {
+                    spreadNS.CellTypes.CheckBox.prototype.paintValue.apply(this, arguments);
+                } else {
+                    spreadNS.CellTypes.Base.prototype.paintValue.apply(this, [ctx, '', x, y, w, h, style, options]);
+                }
+            };
+            // proto.paint = function (canvas, value, x, y, w, h, style, options) {
+            //     if (this.showCheckBox(options.sheet, options.row, options.col)) {
+            //         spreadNS.CellTypes.CheckBox.prototype.paintContent.apply(this, [canvas, value, x, y, w, h, style, options]);
+            //     } else {
+            //         spreadNS.CellTypes.Base.prototype.paintContent.apply(this, [canvas, value, x, y, w, h, style, options]);
+            //     }
+            // };
+            return new SignalCheckboxCellType();
+        },
     },
 
     RowHeader: {

+ 2 - 2
app/service/phase_pay_detail.js

@@ -560,14 +560,14 @@ class PhasePayDetail extends TreeService {
     async updateDetail(phasePay, data) {
         const masterId = this.getMasterKey(phasePay);
         if (Array.isArray(data)) {
-            const orgData = this.getDataByCondition({ where: { id: data.map(d => { return d.id; }) } });
+            const orgData = await this.getAllDataByCondition({ where: { id: data.map(d => { return d.id; }) } });
             const updateDatas = [];
             for (const d of data) {
                 const node = orgData.find(x => { return x.id === d.id; });
                 if (!node || masterId !== node[this.setting.mid]) throw '提交数据错误';
                 updateDatas.push(this._filterValidField(node.id, d));
             }
-            await this.db.updateRows(this.tableName, updateDatas);
+            if (updateDatas.length > 0) await this.db.updateRows(this.tableName, updateDatas);
         } else {
             const node = await this.getDataById(data.id);
             if (!node || masterId !== node[this.setting.mid]) throw '提交数据错误';

+ 2 - 0
app/view/tender/tender_sub_menu.ejs

@@ -33,9 +33,11 @@
             </ul>
         </div>
         <div class="nav-box">
+            <% if (ctx.session.sessionProject.page_show.openIsolatePay) { %>
             <ul class="nav-list list-unstyled">
                 <li <% if (ctx.url.indexOf('/tender/' + ctx.tender.id + '/pay') !== -1) { %>class="active"<% } %>><a href="/tender/<%- ctx.tender.id %>/pay" class="h3"><i class="fa fa-pie-chart fa-fw"></i> <span>合同支付</span></a></li>
             </ul>
+            <% } %>
         </div>
         <div class="nav-box">
             <% if (!ctx.session.sessionProject.page_show.openChangeProject && !ctx.session.sessionProject.page_show.openChangeApply && !ctx.session.sessionProject.page_show.openChangePlan) { %>