Browse Source

合同支付,新增本期批注

MaiXinRong 3 years ago
parent
commit
46788f40e0

+ 2 - 1
app/controller/stage_controller.js

@@ -951,6 +951,7 @@ module.exports = app => {
 
                 ctx.body = responseData;
             } catch (err) {
+                console.log(err);
                 this.log(err);
                 ctx.body = { err: 1, msg: err.toString(), data: null };
             }
@@ -1401,7 +1402,7 @@ module.exports = app => {
                 ctx.body = { err: 0, msg: '', data: result };
             } catch (err) {
                 this.log(err);
-                ctx.body = this.ajaxErrorBody(err, '加载合同支付数据错误');
+                ctx.body = this.ajaxErrorBody(err, '加载部位台账数据错误');
             }
         }
 

+ 85 - 91
app/public/js/stage_pay.js

@@ -139,7 +139,8 @@ $(document).ready(() => {
                 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: '', hAlign: 0, width: 120, readOnly: true, getValue: 'getValue.state', foreColor: 'red', font: '8px 宋体'},
+            {title: '本期批注', colSpan: '1', rowSpan: '1', field: 'postil', hAlign: 0, width: 120},
+            // {title: '状态', colSpan: '1', rowSpan: '1', field: '', hAlign: 0, width: 120, readOnly: true, getValue: 'getValue.state', foreColor: 'red', font: '8px 宋体'},
         ],
         emptyRows: 0,
         headRows: 1,
@@ -643,49 +644,46 @@ $(document).ready(() => {
                 }
                 // 获取更新信息
                 const data = {
-                    type: (col.field === 'tp' || col.field === 'name') ? 'stage' : 'info',
-                    updateData: {}
+                    type: ['tp', 'name', 'postil'].indexOf(col.field) >= 0 ? 'stage' : 'info',
+                    updateData: { pid: select.pid }
                 };
                 // 获取更新数据
-                if (col.field === 'tp') {
-                    data.updateData.pid = select.pid;
-                    const [valid, msg] = payBase.isSF(select)
-                        ? paySpreadObj._checkSfExpr(validText, data.updateData)
-                        : paySpreadObj._checkExpr(validText, data.updateData);
-                    if (!valid) {
-                        toastr.warning(msg);
-                        SpreadJsObj.reLoadRowData(info.sheet, info.row);
-                        return;
-                    }
-                    // if (payBase.isSF(select)) {
-                    //     data.updateData.expr = data.updateData.tp;
-                    // }
-                } else if (col.field === 'name') {
-                    data.updateData.pid = select.pid;
-                    data.updateData.name = validText;
-                } else {
-                    data.updateData.id = select.pid;
-                    if (col.field === 'sprice') {
-                        const [valid, msg] = paySpreadObj._checkSExpr(select, validText, data.updateData);
-                        if (!valid) {
-                            toastr.warning(msg);
+                switch(col.field) {
+                    case 'tp':
+                        const [tpValid, tpMsg] = payBase.isSF(select)
+                            ? paySpreadObj._checkSfExpr(validText, data.updateData)
+                            : paySpreadObj._checkExpr(validText, data.updateData);
+                        if (!tpValid) {
+                            toastr.warning(tpMsg);
                             SpreadJsObj.reLoadRowData(info.sheet, info.row);
                             return;
                         }
-                    } else if (col.field === 'rprice') {
-                        const [valid, msg] = paySpreadObj._checkRExpr(select, validText, data.updateData);
-                        if (!valid) {
-                            toastr.warning(msg);
+                        // if (payBase.isSF(select)) {
+                        //     data.updateData.expr = data.updateData.tp;
+                        // }
+                        break;
+                    case 'name':
+                        data.updateData.name = validText;
+                        break;
+                    case 'sprice':
+                        const [sValid, sMsg] = paySpreadObj._checkSExpr(select, validText, data.updateData);
+                        if (!sValid) {
+                            toastr.warning(sMsg);
                             SpreadJsObj.reLoadRowData(info.sheet, info.row);
                             return;
                         }
-                    } else {
-                        if (validText) {
-                            data.updateData[col.field] = validText;
-                        } else {
-                            data.updateData[col.field] = null;
+                        break;
+                    case 'rprice':
+                        const [rValid, rMsg] = paySpreadObj._checkRExpr(select, validText, data.updateData);
+                        if (!rValid) {
+                            toastr.warning(rMsg);
+                            SpreadJsObj.reLoadRowData(info.sheet, info.row);
+                            return;
                         }
-                    }
+                        break;
+                    default:
+                        data.updateData[col.field] = validText || '';
+
                 }
                 // 更新至服务器
                 postData(window.location.pathname + '/save', data, function (result) {
@@ -758,32 +756,32 @@ $(document).ready(() => {
                     toast('请勿同时删除多列数据', 'warning');
                 }
 
-                const data = {type: col.field === 'tp' ? 'stage' : 'info', updateData: []};
+                const data = {type: ['tp', 'postil'].indexOf(col.field) >= 0 ? 'stage' : 'info', updateData: []};
                 for (let iRow = sel.row; iRow < sel.row + sel.rowCount; iRow++) {
                     const node = sheet.zh_data[iRow];
-                    if (node && (node.ptype === 1 || node.ptype === 3)) {
-                        const updateData = {};
-                        if (col.field === 'tp') {
-                            updateData.pid = node.pid;
-                            updateData.tp = null;
-                            updateData.expr = null;
-                        } else {
-                            updateData.id = node.pid;
-                            if (col.field === 'sprice') {
-                                const [valid, msg] = paySpreadObj._checkSExpr(node, null, updateData);
-                                if (!valid) {
-                                    toastr.warning(msg);
+                    if (node && (node.ptype === 1 || node.ptype === 3 || col.field === 'postil')) {
+                        const updateData = { pid: node.pid };
+                        switch (col.field) {
+                            case 'tp':
+                                updateData.tp = null;
+                                updateData.expr = null;
+                                break;
+                            case 'sprice':
+                                const [sValid, sMsg] = paySpreadObj._checkSExpr(node, null, updateData);
+                                if (!sValid) {
+                                    toastr.warning(sMsg);
                                     return;
                                 }
-                            } else if (col.field === 'rprice') {
-                                const [valid, msg] = paySpreadObj._checkRExpr(node, null, updateData);
-                                if (!valid) {
-                                    toastr.warning(msg);
+                                break;
+                            case 'rprice':
+                                const [rValid, rMsg] = paySpreadObj._checkRExpr(node, null, updateData);
+                                if (!rValid) {
+                                    toastr.warning(rMsg);
                                     return;
                                 }
-                            } else {
-                                updateData[col.field] = null;
-                            }
+                                break;
+                            default:
+                                updateData[col.field] = col.type === 'Number' ? 0 : '';
                         }
                         data.updateData.push(updateData);
                     }
@@ -813,56 +811,52 @@ $(document).ready(() => {
 
                 const sortData = info.sheet.zh_data;
                 const data = {
-                    type: (col.field === 'tp' || col.field === 'name') ? 'stage' : 'info',
+                    type: ['tp', 'name', 'postil'].indexOf(col.field) >= 0 ? 'stage' : 'info',
                     updateData: []
                 };
 
                 for (let iRow = 0; iRow < info.cellRange.rowCount; iRow++) {
                     const curRow = info.cellRange.row + iRow;
                     const node = sortData[curRow];
-                    if (node && (node.ptype === 1 || node.ptype === 3)) {
+                    if (node && (node.ptype === 1 || node.ptype === 3 || col.field === 'postil')) {
                         const validText = info.sheet.getText(curRow, info.cellRange.col).replace('\n', '');
-                        const updateData = {};
-                        if (col.field === 'tp') {
-                            updateData.pid = node.pid;
-                            const [valid, msg] = payBase.isSF(node)
-                                ? paySpreadObj._checkSfExpr(validText, updateData)
-                                : paySpreadObj._checkExpr(validText, updateData);
-                            if (!valid) {
-                                toastr.warning(msg);
-                                SpreadJsObj.reLoadSheetData(paySpread.getActiveSheet());
-                                return;
-                            }
-                            if (payBase.isSF(node)) {
-                                data.updateData.expr = data.updateData.tp;
-                            }
-                        } else if (col.field === 'name') {
-                            updateData.pid = node.pid;
-                            updateData.name = validText;
-                        } else {
-                            updateData.id = node.pid;
-
-                            if (col.field === 'sprice') {
-                                const [valid, msg] = paySpreadObj._checkSExpr(node, validText, updateData);
-                                if (!valid) {
-                                    toastr.warning(msg);
+                        const updateData = { pid: node.pid };
+                        switch (col.field) {
+                            case 'tp':
+                                const [tpValid, tpMsg] = payBase.isSF(node)
+                                    ? paySpreadObj._checkSfExpr(validText, updateData)
+                                    : paySpreadObj._checkExpr(validText, updateData);
+                                if (!tpValid) {
+                                    toastr.warning(tpMsg);
                                     SpreadJsObj.reLoadSheetData(paySpread.getActiveSheet());
                                     return;
                                 }
-                            } else if (col.field === 'rprice') {
-                                const [valid, msg] = paySpreadObj._checkRExpr(node, validText, updateData);
-                                if (!valid) {
-                                    toastr.warning(msg);
+                                // if (payBase.isSF(node)) {
+                                //     data.updateData.expr = data.updateData.tp;
+                                // }
+                                break;
+                            case 'name':
+                                updateData.name = validText;
+                                break;
+                            case 'sprice':
+                                const [sValid, sMsg] = paySpreadObj._checkSExpr(node, validText, updateData);
+                                if (!sValid) {
+                                    toastr.warning(sMsg);
                                     SpreadJsObj.reLoadSheetData(paySpread.getActiveSheet());
                                     return;
                                 }
-                            } else {
-                                if (validText) {
-                                    updateData[col.field] = validText;
-                                } else {
-                                    updateData[col.field] = null;
+                                break;
+                            case 'rprice':
+                                const [rValid, rMsg] = paySpreadObj._checkRExpr(node, validText, updateData);
+                                if (!rValid) {
+                                    toastr.warning(rMsg);
+                                    SpreadJsObj.reLoadSheetData(paySpread.getActiveSheet());
+                                    return;
                                 }
-                            }
+                                break;
+                            default:
+                                updateData[col.field] = validText || '';
+
                         }
                         data.updateData.push(updateData);
                     }

+ 1 - 1
app/router.js

@@ -218,7 +218,7 @@ module.exports = app => {
 
     // 台账修订页面
     app.get('/tender/:id/revise/:rid/info', sessionAuth, tenderCheck, uncheckTenderCheck, reviseCheck, reviseAuditCheck, 'reviseController.info');
-    app.post('/tender/:id/revise/:rid/auditors', sessionAuth, tenderCheck, uncheckTenderCheck, reviseCheck, 'reviseController.reviseAuditors');
+    app.post('/tender/:id/revise/auditors', sessionAuth, tenderCheck, uncheckTenderCheck, reviseCheck, 'reviseController.reviseAuditors');
     app.post('/tender/:id/revise/:rid/info/load', sessionAuth, tenderCheck, uncheckTenderCheck, reviseCheck, 'reviseController.loadInfoData');
     app.post('/tender/:id/revise/:rid/info/update', sessionAuth, tenderCheck, uncheckTenderCheck, reviseCheck, 'reviseController.update');
     app.post('/tender/:id/revise/:rid/info/upload-excel/:ueType', sessionAuth, tenderCheck, uncheckTenderCheck, reviseCheck, 'reviseController.uploadExcel');

+ 0 - 2
app/service/ledger_revise.js

@@ -194,10 +194,8 @@ module.exports = app => {
             const his_id = await this.ctx.service.ledgerHistory.backupReviseLedgerHistory(revise);
             const transaction = await this.db.beginTransaction();
             try {
-                const [billsHis, posHis] = await this.backupReviseHistoryFile(revise);
                 const result = await transaction.update(this.tableName, {
                     id: revise.id, valid: false, end_time: new Date(),
-                    bills_file: billsHis, pos_file: posHis,
                     his_id,
                 });
                 await transaction.update(this.ctx.service.ledgerHistory.tableName, { id: his_id, valid: 0 });

+ 1 - 1
app/service/revise_audit.js

@@ -231,7 +231,7 @@ module.exports = app => {
             const time = new Date();
 
             // 拷贝备份台账数据
-            const his_id = await this.ctx.service.ledgerRevise.backupReviseLedgerHistory(revise);
+            const his_id = await this.ctx.service.ledgerHistory.backupReviseLedgerHistory(revise);
 
             const transaction = await this.db.beginTransaction();
             try {

+ 1 - 1
app/service/stage_pay.js

@@ -207,6 +207,7 @@ module.exports = app => {
                 if (data.expr !== undefined) { updateData.expr = data.expr }
                 if (data.tp !== undefined) { updateData.tp = data.tp }
                 if (data.pause !== undefined) { updateData.pause = data.pause }
+                if (data.postil !== undefined) updateData.postil = data.postil;
                 updateDatas.push(updateData);
             }
             const result = await this.db.updateRows(this.tableName, updateDatas);
@@ -229,7 +230,6 @@ module.exports = app => {
             const PayCalculator = require('../lib/pay_calc');
             const payCalculator = new PayCalculator(this.ctx, stage, this.ctx.tender.info);
             await payCalculator.calculateAll(stagePays);
-            console.log(stagePays);
             const srUpdate = [], update = [];
             for (const sp of stagePays) {
                 update.push({

+ 1 - 2
db_script/ledger_his.js

@@ -90,8 +90,7 @@ const saveReviseLedgerHis = async function (tender, revise) {
 };
 
 const doCompleteTender = async function(t) {
-    if (t.his_id) return;
-    const revise = await querySql('Select * From zh_stage where tid = ? order By in_time asc', [t.id]);
+    const revise = await querySql('Select * From zh_ledger_revise where tid = ? order By in_time asc', [t.id]);
     if (revise.length > 0) {
         let his_id;
         for (const r of revise) {

+ 4 - 1
sql/update.sql

@@ -261,4 +261,7 @@ ALTER TABLE `zh_tender`
 ADD COLUMN `his_id`  bigint(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT '台账历史数据id' AFTER `s2b_dagl_limit`;
 
 ALTER TABLE `zh_stage`
-ADD COLUMN `his_id`  bigint(20) UNSIGNED NOT NULL COMMENT '历史台账id' AFTER `tp_history`;
+ADD COLUMN `his_id`  bigint(20) UNSIGNED NOT NULL COMMENT '历史台账id' AFTER `tp_history`;
+
+ALTER TABLE `zh_stage_pay`
+ADD COLUMN `postil`  varchar(1000) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '本期批注' AFTER `start_stage_order`;