Explorar el Código

甲供材料1.0

MaiXinRong hace 5 años
padre
commit
49c8dac4e9

+ 4 - 9
app/controller/stage_extra_controller.js

@@ -48,15 +48,10 @@ module.exports = app => {
                 for (const d of data) {
                     const pd = this.ctx.helper._.find(preData, {uuid: d.uuid});
                     if (pd) {
-                        p.pre_arrive_qty = pd.arrive_qty;
-                        p.pre_arrive_tp = pd.arrive_tp;
-                        p.pre_deduct_qty = pd.deduct_qty;
-                        p.pre_deduct_tp = pd.deduct_tp;
-
-                        p.end_arrive_qty = ctx.helper.add(pd.arrive_qty + p.arrive_qty);
-                        p.end_arrive_tp = ctx.helper.add(pd.arrive_tp + p.arrive_tp);
-                        p.end_deduct_qty = ctx.helper.add(pd.deduct_qty + p.deduct_qty);
-                        p.end_deduct_tp = ctx.helper.add(pd.deduct_tp + p.deduct_tp);
+                        d.pre_arrive_qty = pd.arrive_qty;
+                        d.pre_arrive_tp = pd.arrive_tp;
+                        d.pre_deduct_qty = pd.deduct_qty;
+                        d.pre_deduct_tp = pd.deduct_tp;
                     }
                 }
                 ctx.body = {err: 0, msg: '', data: data};

+ 43 - 10
app/public/js/se_jgcl.js

@@ -65,8 +65,17 @@ $(document).ready(() => {
                 return a.order - b.order;
             });
         }
+        calculateAll() {
+            for (const d of this.data) {
+                d.end_arrive_qty = ZhCalc.add(d.pre_arrive_qty, d.arrive_qty);
+                d.end_arrive_tp = ZhCalc.add(d.pre_arrive_tp, d.arrive_tp);
+                d.end_deduct_qty = ZhCalc.add(d.pre_deduct_qty, d.deduct_qty);
+                d.end_deduct_tp = ZhCalc.add(d.pre_deduct_tp, d.deduct_tp);
+            }
+        }
         loadDatas(datas) {
             this.data = datas;
+            this.calculateAll();
             this.resortData();
         }
         loadUpdateData(updateData) {
@@ -92,6 +101,7 @@ $(document).ready(() => {
                     return updateData.del.indexOf(d.id) >= 0;
                 });
             }
+            this.calculateAll();
             this.resortData();
         }
     }
@@ -156,13 +166,13 @@ $(document).ready(() => {
                 const sels = sheet.getSelections();
                 if (!sels || !sels[0]) return;
                 const hint = {
-                    isOld: {type: 'warning', msg: '该甲供材料为往期数据,不可删除'},
+                    isOld: {type: 'warning', msg: '该甲供材料已计量,不可删除'},
                     invalidDel: {type: 'warning', msg: '该甲供材料不是您新增的,只有原报和新增人可删除'},
                 };
 
                 for (let iRow = sels[0].row, iLen = sels[0].row + sels[0].rowCount; iRow < iLen; iRow++) {
                     const node = sortData[iRow];
-                    if (node.add_sid === stageId) {
+                    if (node.pre_used) {
                         toastMessageUniq(hint.isOld);
                         continue;
                     } else {
@@ -174,7 +184,7 @@ $(document).ready(() => {
                     }
                 }
                 if (datas.length > 0) {
-                    postData(window.location.pathname + '/update', {updateType: 'del', updateData: datas}, function (result) {
+                    postData(window.location.pathname + '/update', {del: datas}, function (result) {
                         jgclObj.loadUpdateData(result);
                         SpreadJsObj.reLoadSheetData(jgclSheet);
                     }, function () {
@@ -213,7 +223,6 @@ $(document).ready(() => {
 
                 postData(window.location.pathname + '/update', data, function (result) {
                     jgclObj.loadUpdateData(result);
-                    //SpreadJsObj.reLoadRowData(info.sheet, info.row);
                     SpreadJsObj.reLoadSheetData(info.sheet);
                 }, function () {
                     SpreadJsObj.reLoadRowData(info.sheet, info.row);
@@ -233,7 +242,7 @@ $(document).ready(() => {
                     case 'name':
                     case 'unit':
                     case 'unit_price':
-                        info.cancel = readOnly && node.add_sid !== stageId;
+                        info.cancel = readOnly || node.pre_used;
                         break;
                 }
             },
@@ -266,7 +275,7 @@ $(document).ready(() => {
                         const colSetting = setting.cols[curCol];
                         const value = trimInvalidChar(pasteData[iRow][iCol]);
 
-                        if (col.field === 'name' && (!value || value === '')) {
+                        if (colSetting.field === 'name' && (!value || value === '')) {
                             toastMessageUniq(hint.name);
                             break;
                         }
@@ -286,6 +295,7 @@ $(document).ready(() => {
                             data.id = node.id;
                             uDatas.push(data);
                         } else {
+                            data.order = curRow + 1;
                             iDatas.push(data);
                         }
                     }
@@ -303,10 +313,32 @@ $(document).ready(() => {
                 }
             },
             upMove: function () {
-
+                const sels = jgclSheet.getSelections(), sortData = jgclSheet.zh_data;
+                const node = sortData[sels[0].row];
+                const preNode = sortData[sels[0].row - 1];
+                const data = [
+                    {id: node.id, order: preNode.order},
+                    {id: preNode.id, order: node.order}
+                ];
+                postData(window.location.pathname + '/update', {update: data}, function (result) {
+                    jgclObj.loadUpdateData(result);
+                    SpreadJsObj.reLoadRowsData(jgclSheet, [sels[0].row, sels[0].row - 1]);
+                    jgclSheet.setSelection(sels[0].row - 1, sels[0].col, sels[0].rowCount, sels[0].colCount);
+                });
             },
             downMove: function () {
-
+                const sels = jgclSheet.getSelections(), sortData = jgclSheet.zh_data;
+                const node = sortData[sels[0].row];
+                const nextNode = sortData[sels[0].row + 1];
+                const data = [
+                    {id: node.id, order: nextNode.order},
+                    {id: nextNode.id, order: node.order}
+                ];
+                postData(window.location.pathname + '/update', {update: data}, function (result) {
+                    jgclObj.loadUpdateData(result);
+                    SpreadJsObj.reLoadRowsData(jgclSheet, [sels[0].row, sels[0].row + 1]);
+                    jgclSheet.setSelection(sels[0].row + 1, sels[0].col, sels[0].rowCount, sels[0].colCount);
+                });
             }
         };
         jgclSheet.bind(spreadNS.Events.EditEnded, jgclOprObj.editEnded);
@@ -338,9 +370,10 @@ $(document).ready(() => {
                         return !readOnly;
                     }
                 },
+                sprDel: '------------',
                 upMove: {
                     name: '上移',
-                    icon: 'fa-remove',
+                    icon: 'fa-arrow-up',
                     callback: function (key, opt) {
                         jgclOprObj.upMove();
                     },
@@ -358,7 +391,7 @@ $(document).ready(() => {
                 },
                 downMove: {
                     name: '下移',
-                    icon: 'fa-remove',
+                    icon: 'fa-arrow-down',
                     callback: function (key, opt) {
                         jgclOprObj.downMove();
                     },

+ 5 - 0
app/service/stage.js

@@ -268,6 +268,11 @@ module.exports = app => {
                 if (!dealResult) {
                     throw '新增期合同支付数据失败';
                 }
+                // 新增期其他台账数据
+                if (preStage) {
+                    const jgclResult = await this.ctx.service.stageJgcl.addInitialStageData(newStage, preStage, transaction);
+                    if (!jgclResult) throw '初始化甲供材料数据失败';
+                }
 
                 await transaction.commit();
                 return newStage;

+ 5 - 0
app/service/stage_audit.js

@@ -212,6 +212,7 @@ module.exports = app => {
                 const yfPay = await this.ctx.service.stagePay.calcAllStagePays(this.ctx.stage, transaction);
                 // 复制一份下一审核人数据
                 await this.ctx.service.stagePay.copyAuditStagePays(this.ctx.stage, this.ctx.stage.times, 1, transaction);
+                await this.ctx.service.stageJgcl.updateHistory(this.ctx.stage, transaction);
                 // 更新期数据
                 const tpData = await this.ctx.service.stageBills.getSumTotalPrice(this.ctx.stage);
                 await transaction.update(this.ctx.service.stage.tableName, {
@@ -265,6 +266,7 @@ module.exports = app => {
                 if (nextAudit) {
                     // 复制一份下一审核人数据
                     await this.ctx.service.stagePay.copyAuditStagePays(this.ctx.stage, this.ctx.stage.times, nextAudit.order, transaction);
+                    await this.ctx.service.stageJgcl.updateHistory(this.ctx.stage, transaction);
                     // 流程至下一审批人
                     await transaction.update(this.tableName, {id: nextAudit.id, status: auditConst.status.checking, begin_time: time});
                     // 同步 期信息
@@ -376,6 +378,7 @@ module.exports = app => {
                 await this.ctx.service.stagePay.calcAllStagePays(this.ctx.stage, transaction);
                 // 复制一份最新数据给原报
                 await this.ctx.service.stagePay.copyAuditStagePays(this.ctx.stage, this.ctx.stage.times + 1, 0, transaction);
+                await this.ctx.service.stageJgcl.updateHistory(this.ctx.stage, transaction);
 
                 // 添加短信通知-审批退回提醒功能
                 const mobile_array = [];
@@ -453,6 +456,7 @@ module.exports = app => {
                 await this.ctx.service.stagePay.calcAllStagePays(this.ctx.stage, transaction);
                 // 复制一份最新数据给下一人
                 await this.ctx.service.stagePay.copyAuditStagePays(this.ctx.stage, this.ctx.stage.times, audit.order + 1, transaction);
+                await this.ctx.service.stageJgcl.updateHistory(this.ctx.stage, transaction);
 
                 // 同步 期信息
                 await transaction.update(this.ctx.service.stage.tableName, {
@@ -660,6 +664,7 @@ module.exports = app => {
                 // 复制一份最新数据给下一人
                 await this.ctx.service.stagePay.copyAuditStagePays(this.ctx.stage, this.ctx.stage.times, audit.order + 1, transaction);
                 await this.ctx.service.stagePay.copyAuditStagePays(this.ctx.stage, this.ctx.stage.times, audit.order + 2, transaction);
+                await this.ctx.service.stageJgcl.updateHistory(this.ctx.stage, transaction);
 
                 // 本期结束
                 // 生成截止本期数据 final数据

+ 1 - 0
app/view/layout/layout.ejs

@@ -68,6 +68,7 @@
     if (toastInfo !== '') {
         toastr[toastInfo.type](toastInfo.message);
     }
+    const userID = <%- ctx.session.sessionUser.accountId %>;
     let user = '<%= ctx.session.sessionUser.name %>';
     <% if (ctx.app.config.is_debug) { %>
     const is_debug = true;

+ 0 - 1
app/view/stage/index.ejs

@@ -544,7 +544,6 @@
     const imType = JSON.parse('<%- JSON.stringify(imType) %>');
     const whiteList = JSON.parse('<%- JSON.stringify(whiteList) %>');
     let attData = JSON.parse('<%- JSON.stringify(attData) %>');
-    const userID = '<%- ctx.session.sessionUser.accountId %>';
     const ckColSetting = 'stage-col-visible-1.0.3-<%- tender.id %>';
 </script>
 <% if (ctx.stage.status === auditConst.status.uncheck && ctx.session.sessionUser.accountId === ctx.stage.user_id) {%>

+ 0 - 1
app/view/stage/pay.ejs

@@ -60,7 +60,6 @@
     const decimal = JSON.parse('<%- JSON.stringify(ctx.tender.info.decimal) %>');
     const whiteList = JSON.parse('<%- JSON.stringify(whiteList) %>');
     const uploadPermission = <%- uploadPermission %>;
-    const userID = <%- ctx.session.sessionUser.accountId %>;
     const preContractTp = <%- (pre.contract_tp || 0) %>;
     const preQcTp = <%- (pre.qc_tp || 0) %>;
     const preGatherTp = <%- (pre.gather_tp || 0) %>;