فهرست منبع

1. 安全计量,审核比较
2. 支付明细,复制粘贴

MaiXinRong 1 هفته پیش
والد
کامیت
427a628cfa

+ 16 - 1
app/controller/safe_controller.js

@@ -190,9 +190,24 @@ module.exports = app => {
         }
         async safeCompare(ctx) {
             try {
+                await this._getStageAuditViewData(ctx);
+                // 流程审批人相关数据
+                const accountList = await ctx.service.projectAccount.getAllSubProjectAccount(ctx.subProject);
+                const unitList = await ctx.service.constructionUnit.getAllDataByCondition({ where: { pid: ctx.session.sessionProject.id } });
+                const accountGroup = unitList.map(item => {
+                    const groupList = accountList.filter(item1 => item1.company === item.name);
+                    return { groupName: item.name, groupList };
+                }).filter(x => { return x.groupList.length > 0; });
+                // 是否已验证手机短信
+                const pa = await ctx.service.projectAccount.getDataById(ctx.session.sessionUser.accountId);
                 const renderData = {
                     jsFiles: this.app.jsFiles.common.concat(this.app.jsFiles.safe.compare),
-                    auditConst,
+                    auditConst: auditConst.common,
+                    accountList,
+                    accountGroup,
+                    shenpiConst,
+                    auditType: auditConst.auditType,
+                    authMobile: pa.auth_mobile,
                 };
                 await this.layout('safe_calc/compare.ejs', renderData);
             } catch (err) {

+ 92 - 0
app/public/js/phase_pay_detail.js

@@ -846,12 +846,104 @@ $(document).ready(() => {
                 SpreadJsObj.loadSheetData(sheet, SpreadJsObj.DataType.Tree, payTree);
                 payEvent.refreshActn();
             },
+            clipboardPasting: function(e, info) {
+                if (!info.sheet.zh_setting) return;
+
+                const pasteData = info.pasteData.html
+                    ? SpreadJsObj.analysisPasteHtml(info.pasteData.html)
+                    : (info.pasteData.text === ''
+                        ? SpreadJsObj.Clipboard.getAnalysisPasteText()
+                        : SpreadJsObj.analysisPasteText(info.pasteData.text));
+
+                const range = info.cellRange;
+                if (range.colCount > 1) {
+                    toastr.error('请勿复制粘贴多列数据');
+                    return;
+                }
+                const col = info.sheet.zh_setting.cols[range.col];
+                const data = { postType: 'update', postData:[] };
+                for (let iRow = range.row; iRow < range.row + range.rowCount; iRow++) {
+                    const node = info.sheet.zh_tree.nodes[iRow];
+                    let valid;
+                    switch (col.field) {
+                        case 'name':
+                            valid = !payUtils.check.isFixed(node);
+                            break;
+                        case 'tp':
+                            valid = !payUtils.check.tpReadOnly(node);
+                            break;
+                        case 'start_tp':
+                            valid = !payUtils.check.startTpReadOnly(node);
+                            break;
+                        case 'range_tp':
+                            valid = !payUtils.check.rangeTpReadOnly(node);
+                            break;
+                        default:
+                            valid = false;
+                    }
+                    if (!valid) {
+                        toastr.error('不可复制粘贴数据');
+                        return;
+                    }
+                    const updateData = { id: node.id };
+                    const validText = col.wordWrap ? pasteData[iRow-range.row][range.col-range.col] : trimInvalidChar(pasteData[iRow-range.row][range.col-range.col]);
+                    switch(col.field) {
+                        case 'tp':
+                            const [tpValid, tpMsg] = payUtils.check.isSf(node)
+                                ? payCalc.checkSfExpr(validText, updateData, node, payTree)
+                                : payCalc.checkExpr(validText, updateData, node, payTree);
+                            if (!tpValid) {
+                                toastr.warning(tpMsg);
+                                SpreadJsObj.reLoadRowData(info.sheet, info.row);
+                                return;
+                            }
+                            break;
+                        case 'start_tp':
+                            const [sValid, sMsg] = payCalc.checkStartExpr(node, validText, updateData);
+                            if (!sValid) {
+                                toastr.warning(sMsg);
+                                SpreadJsObj.reLoadRowData(info.sheet, info.row);
+                                return;
+                            }
+                            break;
+                        case 'range_tp':
+                            const [rValid, rMsg] = payCalc.checkRangeExpr(node, validText, updateData);
+                            if (!rValid) {
+                                toastr.warning(rMsg);
+                                SpreadJsObj.reLoadRowData(info.sheet, info.row);
+                                return;
+                            }
+                            break;
+                        default:
+                            if (col.type === 'Number') {
+                                updateData[col.field] = _.toNumber(validText) || 0;
+                            } else {
+                                updateData[col.field] = validText || '';
+                            }
+                            break;
+                    }
+                    data.postData.push(updateData);
+                }
+                if (data.postData.length === 0) return;
+
+                postData('update', data, function (result) {
+                    if (result.reload) {
+                        payEvent.reloadPays(result.reload);
+                    } else {
+                        const refreshData = payTree.loadPostData(result);
+                        payEvent.refreshTree(refreshData);
+                    }
+                }, function () {
+                    SpreadJsObj.reLoadRowData(info.sheet, info.row);
+                });
+            },
         };
         spread.bind(spreadNS.Events.SelectionChanged, payEvent.selectionChanged);
         if (!readOnly) {
             spread.bind(spreadNS.Events.EditStarting, payEvent.editStarting);
             spread.bind(spreadNS.Events.EditEnded, payEvent.editEnded);
             spread.bind(spreadNS.Events.ButtonClicked, payEvent.buttonClicked);
+            spread.bind(spreadNS.Events.ClipboardPasting, payEvent.clipboardPasting);
             SpreadJsObj.addDeleteBind(spread, payEvent.deletePress);
             $('a[name="base-opr"]').click(function () {
                 payEvent.baseOpr(this.getAttribute('type'));

+ 9 - 9
app/public/js/safe_bills_compare.js

@@ -57,11 +57,11 @@ $(document).ready(function() {
                 this.spreadSetting.cols.push(col);
             }
             for (const role of roles) {
-                this.spreadSetting.fieldSufs.push(role.order);
+                this.spreadSetting.fieldSufs.push(role.active_order);
                 for (const ec of this.spreadSetting.extraCols) {
                     const col = JSON.parse(JSON.stringify(ec));
                     col.title = _.replace(col.title, '%s', role.name);
-                    col.field = _.replace(col.field, '{%d}', role.order);
+                    col.field = _.replace(col.field, '{%d}', role.active_order);
                     this.spreadSetting.cols.push(col);
                 }
             }
@@ -74,7 +74,7 @@ $(document).ready(function() {
             const findHis = function (role, history) {
                 let his = null;
                 for (const h of history) {
-                    if (h.times < role.times || (h.times === role.times && h.order <= role.order)) {
+                    if (h.audit_times < role.audit_times || (h.audit_times === role.audit_times && h.active_order <= role.active_order)) {
                         his = h;
                     } else {
                         break;
@@ -84,16 +84,16 @@ $(document).ready(function() {
             };
             for (const d of datas) {
                 if (!d.tree_is_leaf) continue;
-                d.cur_his.sort((x, y) => { return x.times === y.times ? x.order - y.order : x.times - y.times; });
+                d.cur_his.sort((x, y) => { return x.audit_times === y.audit_times ? x.active_order - y.active_order : x.audit_times - y.audit_times; });
                 for (const r of roles) {
                     if (r.latest) {
-                        d[`qty_${r.order}`] = d.cur_qty;
-                        d[`tp_${r.order}`] = d.cur_tp;
+                        d[`qty_${r.active_order}`] = d.cur_qty;
+                        d[`tp_${r.active_order}`] = d.cur_tp;
                     } else {
                         const rHis = findHis(r, d.cur_his);
                         if (rHis) {
-                            d[`qty_${r.order}`] = rHis.qty;
-                            d[`tp_${r.order}`] = rHis.tp;
+                            d[`qty_${r.active_order}`] = rHis.qty;
+                            d[`tp_${r.active_order}`] = rHis.tp;
                         }
                     }
                 }
@@ -103,7 +103,7 @@ $(document).ready(function() {
             this.initSpread(roles);
             this.analysisCompareData(datas, roles);
             this.tree.loadDatas(datas);
-            this.tree.setting.calcFields = roles.map(x => { return `tp_${x.order}`});
+            this.tree.setting.calcFields = roles.map(x => { return `tp_${x.audit_order}`});
             treeCalc.calculateAll(this.tree);
             SpreadJsObj.loadSheetData(this.sheet, SpreadJsObj.DataType.Tree, this.tree);
             SpreadJsObj.loadTopAndSelect(this.sheet, this.ckBillsSpread);

+ 24 - 6
app/service/safe_stage_audit.js

@@ -73,7 +73,7 @@ module.exports = app => {
                 for (const g of group) {
                     const his = {
                         auditYear: '', auditDate: '', auditTime: '', audit_time: null,
-                        audit_type: g[0].audit_type, audit_order: g[0].audit_order,
+                        audit_type: g[0].audit_type, audit_order: g[0].audit_order, audit_times: g[0].audit_times, active_order: g[0].active_order,
                         auditors: g
                     };
                     his.is_final = his.audit_order === max_order;
@@ -114,6 +114,22 @@ module.exports = app => {
             const sqlParam = [tenderId];
             return this.db.query(sql, sqlParam);
         }
+        // 获取审核比较 可查看的列表,它用不可修改
+        async getViewFlow(safeStage) {
+            const result = [];
+            if (safeStage.audit_status === auditConst.common.status.uncheck) return result;
+
+            const group = await this.getAuditorHistory(safeStage.id, safeStage.curTimes);
+            const latestGroup = group[group.length - 1];
+            latestGroup.forEach(x => {
+                if (x.audit_status === auditConst.common.status.checked) result.push(x);
+                if (x.audit_status === auditConst.common.status.checking && !safeStage.readOnly) {
+                    x.latest = true;
+                    result.push(x);
+                }
+            });
+            return result;
+        }
         // ***** 查询审批人相关
 
         // ***** 修改审批人相关
@@ -202,13 +218,13 @@ module.exports = app => {
             return true;
         }
         // 拷贝上一期审批流程
-        async copyPreAuditors(transaction, prePhasePay, newPhasePay) {
-            const auditors = prePhasePay ? await this.getUniqAuditors(prePhasePay) : [];
+        async copyPreAuditors(transaction, preSafeStage, newSafeStage) {
+            const auditors = preSafeStage ? await this.getUniqAuditors(preSafeStage) : [];
             const newAuditors = [];
             // 添加原报
             const user = await this.ctx.service.projectAccount.getDataById(this.ctx.session.sessionUser.accountId);
             newAuditors.push({
-                tid: newPhasePay.tid, stage_id: newPhasePay.id,
+                tid: newSafeStage.tid, stage_id: newSafeStage.id,
                 audit_id: this.ctx.session.sessionUser.accountId,
                 audit_times: 1, audit_order: 0, audit_type: auditConst.auditType.key.common,
                 active_order: 0, audit_status: auditConst.safeStage.status.uncheck,
@@ -218,7 +234,7 @@ module.exports = app => {
             for (const a of auditors) {
                 if (a.audit_order === 0) continue;
                 newAuditors.push({
-                    tid: newPhasePay.tid, stage_id: newPhasePay.id,
+                    tid: newSafeStage.tid, stage_id: newSafeStage.id,
                     audit_id: a.audit_id,
                     audit_times: 1, audit_order: a.audit_order, audit_type: a.audit_type,
                     active_order: a.audit_order, audit_status: auditConst.safeStage.status.uncheck,
@@ -497,7 +513,7 @@ module.exports = app => {
                     // await this.ctx.service.specMsg.addSafeStageMsg(transaction, this.ctx.session.sessionProject.id, safeStage, pushOperate.safeStage.flow);
                 } else {
                     // 同步 期信息
-                    await transaction.update(this.ctx.service.safeStage.tableName, { id: safeStage.id, audit_status: auditConst.safeStage.status.checking, ...paySum });
+                    await transaction.update(this.ctx.service.safeStage.tableName, { id: safeStage.id, audit_status: auditConst.safeStage.status.checking, ...billsSum });
                 }
                 await transaction.commit();
             } catch (err) {
@@ -994,6 +1010,8 @@ module.exports = app => {
                     id: safeStage.id, audit_times: safeStage.audit_times - 1, audit_status: auditConst.safeStage.status.checking,
                 });
                 // todo 修改安全生产费数据
+                await this._cacheAuditData(transaction, safeStage,
+                    { audit_id: selfAuditor.audit_id, audit_times: selfAuditor.audit_times, audit_order: selfAuditor.audit_order, active_order: selfAuditor.active_order + 1});
                 // await this.ctx.service.safeStageBills.initPhaseDataByAuditCancel(transaction, safeStage, selfAuditor.audit_times, selfAuditor.active_order, selfAuditor.audit_times, selfAuditor.active_order + 1);
                 // await transaction.update(this.ctx.service.safeStageBills.tableName,
                 //     { audit_times: selfAuditor.audit_times, audit_sort: selfAuditor.active_order + 2, master_id: `${safeStage.id}-${selfAuditor.audit_times}-${selfAuditor.active_order + 2}` },

+ 2 - 0
app/service/safe_stage_bills.js

@@ -514,6 +514,8 @@ module.exports = app => {
                 if (l.cur_read_qty !== l.cur_qty || l.cur_read_tp !== l.cur_tp) {
                     const data = { id: l.id, cur_read_qty: l.cur_qty, cur_read_tp: l.cur_tp };
                     const his = l.cur_his ? JSON.parse(l.cur_his) : [];
+                    const fi = his.find(x => { return x.audit_times === auditInfo.audit_times && x.active_order === auditInfo.active_order; });
+                    if (fi >= 0) his.splice(fi, 1);
                     his.push({ ...auditInfo, qty: l.cur_qty, tp: l.cur_tp, up: l.unit_price });
                     data.cur_his = JSON.stringify(his);
                     data.cur_read_qty = l.cur_qty;

+ 3 - 3
app/view/safe_calc/sub_menu_list.ejs

@@ -1,5 +1,5 @@
 <nav-menu title="返回" url="/sp/<%- ctx.subProject.id %>/safe/tender/<%- ctx.tender.id  %>/stage" tclass="text-primary" ml="1" icon="fa-chevron-left"></nav-menu>
-<nav-menu title="安全生产费" url="/sp/<%- ctx.subProject.id %>/safe/tender/<%- ctx.tender.id %>/safe/<%= ctx.safeStage.stage_order %>/bills" ml="3" active="<%= ctx.url.indexOf('bills') %>"></nav-menu>
-<nav-menu title="审核比较" url="/sp/<%- ctx.subProject.id %>/safe/tender/<%- ctx.tender.id %>/safe/<%= ctx.safeStage.stage_order %>/compare" ml="3" active="<%= ctx.url.indexOf('compare') %>"></nav-menu>
-<nav-menu title="输出报表" url="/sp/<%- ctx.subProject.id %>/safe/tender/<%- ctx.tender.id %>/safe/<%= ctx.safeStage.stage_order %>/report" ml="3" active="<%= ctx.url.indexOf('report') %>"></nav-menu>
+<nav-menu title="安全生产费" url="/sp/<%- ctx.subProject.id %>/safe/tender/<%- ctx.tender.id %>/stage/<%= ctx.safeStage.stage_order %>/bills" ml="3" active="<%= ctx.url.indexOf('bills') %>"></nav-menu>
+<nav-menu title="审核比较" url="/sp/<%- ctx.subProject.id %>/safe/tender/<%- ctx.tender.id %>/stage/<%= ctx.safeStage.stage_order %>/compare" ml="3" active="<%= ctx.url.indexOf('compare') %>"></nav-menu>
+<nav-menu title="输出报表" url="/sp/<%- ctx.subProject.id %>/safe/tender/<%- ctx.tender.id %>/stage/<%= ctx.safeStage.stage_order %>/report" ml="3" active="<%= ctx.url.indexOf('report') %>"></nav-menu>
 <% include ./audit_btn.ejs %>