Browse Source

Merge branch 'dev' of http://192.168.1.41:3000/maixinrong/Calculation into dev

TonyKang 3 years ago
parent
commit
c178bfbbad

+ 50 - 1
app/controller/report_archive_controller.js

@@ -13,11 +13,38 @@ const measureType = require('../const/tender').measureType;
 const fsUtil = require('../public/js/fsUtil');
 const auditConst = require('../const/audit');
 const signConst = require('../const/sign');
+const shenpiConst = require('../const/shenpi');
+const accountGroup = require('../const/account_group').group;
 
 module.exports = app => {
     class ReportArchiveController extends app.BaseController {
 
+        /**
+         * 获取审批界面所需的 原报、审批人数据等
+         * @param ctx
+         * @return {Promise<void>}
+         * @private
+         */
+        async _getStageAuditViewData(ctx) {
+            if (!ctx.stage) return;
+            const times = ctx.stage.status === auditConst.stage.status.checkNo ? ctx.stage.times - 1 : ctx.stage.times;
+
+            ctx.stage.user = await ctx.service.projectAccount.getAccountInfoById(ctx.stage.user_id);
+            ctx.stage.auditHistory = [];
+            if (times >= 1) {
+                for (let i = 1; i <= times; i++) {
+                    ctx.stage.auditHistory.push(await ctx.service.stageAudit.getAuditors(ctx.stage.id, i));
+                }
+            }
+            // 获取审批流程中左边列表
+            ctx.stage.auditors2 = await ctx.service.stageAudit.getAuditGroupByListWithOwner(ctx.stage.id, times);
+            if (ctx.stage.status === auditConst.stage.status.uncheck || ctx.stage.status === auditConst.stage.status.checkNo) {
+                ctx.stage.auditorList = await ctx.service.stageAudit.getAuditors(ctx.stage.id, ctx.stage.times);
+            }
+        }
+
         async index(ctx) {
+            await this._getStageAuditViewData(ctx);
             const tender = ctx.tender;
             const stage = ctx.stage;
             let stage_id = -1;
@@ -73,6 +100,19 @@ module.exports = app => {
             if (custTreeNodes.length > 0) {
                 rpt_tpl_items = custTreeNodes[0].rpt_tpl_items;
             }
+
+            // 获取用户权限
+            const accountInfo = await this.ctx.service.projectAccount.getDataById(this.ctx.session.sessionUser.accountId);
+            // 获取所有项目参与者
+            const accountList = await ctx.service.projectAccount.getAllDataByCondition({
+                where: { project_id: ctx.session.sessionProject.id, enable: 1 },
+                columns: ['id', 'name', 'company', 'role', 'enable', 'is_admin', 'account_group', 'mobile'],
+            });
+            const newAccountGroup = accountGroup.map((item, idx) => {
+                const groupList = accountList.filter(item => item.account_group === idx);
+                return { groupName: item, groupList };
+            });
+
             //
             const renderData = {
                 tender: tender.data,
@@ -94,8 +134,17 @@ module.exports = app => {
                 archiveEncryptionList,
                 can_netcasign: false,
                 ossPath: signConst.path.oss,
+                shenpiConst,
+                preUrl: '/tender/' + ctx.tender.id + '/measure/stage/' + ctx.params.order,
+                authMobile: accountInfo.auth_mobile,
+                accountGroup: newAccountGroup,
+                accountList,
             };
-            await this.layout('report/index_archive.ejs', renderData);
+            if (stage_id === -1) {
+                await this.layout('report/index_archive.ejs', renderData);
+            } else {
+                await this.layout('report/index_archive.ejs', renderData, 'stage/audit_modal.ejs');
+            }
         }
 
         async getReportArchive(ctx) {

+ 11 - 7
app/lib/sum_load.js

@@ -100,7 +100,7 @@ class loadGclBaseTree {
             node.quantity = this.ctx.helper.round(node.quantity, p.value);
 
             if (!node.unit_price) {
-                const db = dealBills.find(x => { return x.b_code === node.b_code && x.name === node.name && x.unit === node.unit });
+                const db = dealBills.find(x => { return x.code === node.b_code && x.name === node.name && x.unit === node.unit });
                 if (!db) return;
                 node.unit_price = db.unit_price;
             }
@@ -133,9 +133,10 @@ class loadLedgerGclTree extends loadGclBaseTree {
             create.push({
                 id: i.id, tender_id: i.tender_id, ledger_id: i.ledger_id, ledger_pid: i.ledger_pid,
                 level: i.level, order: i.order, full_path: i.full_path, is_leaf: !i.children || i.children.length === 0,
-                b_code: i.b_code, name: i.name, unit: i.unit,
+                b_code: i.b_code, name: i.name, unit: i.unit, unit_price: i.unit_price || 0,
                 sgfh_qty: i.sgfh_qty, sjcl_qty: i.sjcl_qty, qtcl_qty: i.qtcl_qty, quantity: i.quantity,
-            })
+                sgfh_tp: i.sgfh_tp || 0, sjcl_tp: i.sjcl_tp || 0, qtcl_tp: i.qtcl_tp || 0, total_price: i.total_price || 0,
+            });
         }
         return {update, create};
     }
@@ -207,7 +208,9 @@ class updateReviseGclTree extends loadGclBaseTree {
                     });
                 } else if (bn.sjcl_qty !== bn.org_sjcl_qty || bn.qtcl_qty !== bn.org_qtcl_qty || bn.sgfh_qty !== bn.org_sgfh_qty) {
                     result.update.push({
-                        id: bn.id, ledger_id: bn.ledger_id, sgfh_qty: bn.sgfh_qty, sjcl_qty: bn.sjcl_qty, qtcl_qty: bn.qtcl_qty, quantity: bn.quantity
+                        id: bn.id, ledger_id: bn.ledger_id, unit_price: bn.unit_price || 0,
+                        sgfh_qty: bn.sgfh_qty, sjcl_qty: bn.sjcl_qty, qtcl_qty: bn.qtcl_qty, quantity: bn.quantity,
+                        sgfh_tp: bn.sgfh_tp || 0, sjcl_tp: bn.sjcl_tp || 0, qtcl_tp: bn.qtcl_tp || 0, total_price: bn.total_price || 0,
                     })
                 }
             }
@@ -216,8 +219,9 @@ class updateReviseGclTree extends loadGclBaseTree {
             result.create.push({
                 id: i.id, tender_id: i.tender_id, ledger_id: i.ledger_id, ledger_pid: i.ledger_pid,
                 level: i.level, order: i.order, full_path: i.full_path, is_leaf: !i.children || i.children.length === 0,
-                b_code: i.b_code, name: i.name, unit: i.unit,
+                b_code: i.b_code, name: i.name, unit: i.unit, unit_price: i.unit_price || 0,
                 sgfh_qty: i.sgfh_qty, sjcl_qty: i.sjcl_qty, qtcl_qty: i.qtcl_qty, quantity: i.quantity,
+                sgfh_tp: i.sgfh_tp || 0, sjcl_tp: i.sjcl_tp || 0, qtcl_tp: i.qtcl_tp || 0, total_price: i.total_price || 0,
             })
         }
         return result;
@@ -355,7 +359,7 @@ class sumLoad {
                 this.recusiveLoadGatherGcl(top, null);
             }
         }
-        const dealBills = await this.ctx.service.dealBills.getAllDataByCondition({ tid: this.ctx.tender.id });
+        const dealBills = await this.ctx.service.dealBills.getAllDataByCondition({ where: { tender_id: this.ctx.tender.id } });
         this.loadTree.calculateAll(dealBills);
         return this.loadTree;
     }
@@ -385,7 +389,7 @@ class sumLoad {
                 this.recusiveLoadGatherGcl(top, null);
             }
         }
-        const dealBills = await this.ctx.service.dealBills.getAllDataByCondition({ tid: this.ctx.tender.id });
+        const dealBills = await this.ctx.service.dealBills.getAllDataByCondition({ where: { tender_id: this.ctx.tender.id } });
         this.loadTree.calculateAll(dealBills);
         return this.loadTree;
     }

BIN
app/public/files/template/ledger/导入分项清单EXCEL格式.xlsx


+ 3 - 0
app/public/js/revise.js

@@ -99,6 +99,9 @@ $(document).ready(() => {
         relaSpread: billsSpread,
         storeKey: 'revise-slm-' + window.location.pathname.split('/')[2] + '-' + window.location.pathname.split('/')[4],
         id: 'revise-slm',
+        afterLocated:  function () {
+            posSpreadObj.loadCurPosData();
+        },
         afterShow: function () {
             billsSpread.refresh();
             if (posSpread) posSpread.refresh();

+ 19 - 0
app/public/js/shares/cs_tools.js

@@ -986,6 +986,25 @@ const showSelectTab = function(select, spread, afterShow) {
             const spread = SpreadJsObj.createNewSpread($('#' + resultId)[0]);
             const sheet = spread.getActiveSheet();
             SpreadJsObj.initSheet(sheet, setting.spreadSetting);
+            spread.getActiveSheet().bind(spreadNS.Events.CellDoubleClick, function (e, info) {
+                if (!setting.relaSpread) return;
+
+                const sheet = info.sheet;
+                const data = sheet.zh_data;
+                if (!data) { return }
+
+                const curBills = data[info.row];
+                if (!curBills) { return }
+
+                if (curBills.ledger_id) {
+                    SpreadJsObj.locateTreeNode(setting.relaSpread.getActiveSheet(), curBills.ledger_id, true);
+                    if (setting.afterLocated) {
+                        setting.afterLocated();
+                    }
+                } else {
+                    toastr.warning('找不到该清单');
+                }
+            });
 
             const loadMissData = function (data, his = false) {
                 const sourceTree = setting.relaSpread.getActiveSheet().zh_tree;

+ 3 - 0
app/public/js/stage.js

@@ -837,6 +837,9 @@ $(document).ready(() => {
         relaSpread: slSpread,
         storeKey: 'stage-slm-' + stage.id,
         id: 'stage-slm',
+        afterLocated:  function () {
+            stagePosSpreadObj.loadCurPosData();
+        },
         afterShow: function () {
             slSpread.refresh();
             if (spSpread) spSpread.refresh();

+ 23 - 13
app/public/report/js/rpt_archive.js

@@ -109,9 +109,19 @@ let rptArchiveObj = {
                     me.currentArchivePdfPath = null;
                     if (aItem.items && aItem.items.length > 0) {
                         // me.currentArchiveUuid = aItem.items[0].uuid;
-                        me.currentArchiveUuid = aItem.items[aItem.items.length - 1].uuid;
                         // me.currentArchiveDateStr = aItem.items[0].updateDate_time;
-                        me.currentArchiveDateStr = '#' + (aItem.items.length) + ' ' + aItem.items[aItem.items.length - 1].updateDate_time;
+                        const newItems = _.orderBy(aItem.items, ['updateDate_time'], ['desc']);
+                        me.currentArchiveUuid = newItems[0].uuid;
+                        me.currentArchiveDateStr = '#' + (_.findIndex(aItem.items, { updateDate_time: newItems[0].updateDate_time})+1) + ' ' + newItems[0].updateDate_time;
+                        if (can_netcasign) {
+                            for (const [i,item] of aItem.items.entries()) {
+                                if (_.find(signLogList, { uuid: item.uuid })) {
+                                    me.currentArchiveUuid = item.uuid;
+                                    me.currentArchiveDateStr = '#' + (i+1) + ' ' + item.updateDate_time;
+                                    break;
+                                }
+                            }
+                        }
                     }
                     break;
                 }
@@ -164,15 +174,15 @@ let rptArchiveObj = {
                         $('#show-removesign-modal-btn').hide();
                     }
                     postData('/tender/'+ TENDER_ID +'/signReport/post', {type: 'pdfIsExist', uuid: me.currentArchiveUuid}, function (result) {
-                        me.currentArchivePdfPath = result ? oss_path + '/sign/'+ me.currentArchiveUuid +'.PDF' + (uSignLogList.length !== 0 ? '?' + uSignLogList[uSignLogList.length-1].versionid : '') : oss_path + '/'+ me.currentArchiveUuid +'.PDF';
+                        me.currentArchivePdfPath = result ? oss_path + '/sign/'+ me.currentArchiveUuid +'.PDF' + (uSignLogList.length !== 0 ? '?' + uSignLogList[uSignLogList.length-1].versionid : '') : oss_path + '/'+ me.currentArchiveUuid +'.PDF?' + new Date(me.currentArchiveDateStr.slice(3).replace(/-/g, '/')).getTime();
                         $('#iframe_made').html('<iframe src="/archive/pdf/show?file=' + me.currentArchivePdfPath + '" height="750px" width="100%" style="border: none;"></iframe>');
                     }, function () {
-                        me.currentArchivePdfPath = oss_path + '/'+ me.currentArchiveUuid +'.PDF';
-                        $('#iframe_made').html('<iframe src="/archive/pdf/show?file=' + oss_path + '/'+ me.currentArchiveUuid +'.PDF" height="750px" width="100%" style="border: none;"></iframe>');
+                        me.currentArchivePdfPath = oss_path + '/'+ me.currentArchiveUuid +'.PDF?' + new Date(me.currentArchiveDateStr.slice(3).replace(/-/g, '/')).getTime();
+                        $('#iframe_made').html('<iframe src="/archive/pdf/show?file=' + me.currentArchivePdfPath + '" height="750px" width="100%" style="border: none;"></iframe>');
                     })
                 } else {
-                    me.currentArchivePdfPath = oss_path + '/'+ me.currentArchiveUuid +'.PDF';
-                    $('#iframe_made').html('<iframe src="/archive/pdf/show?file=' + oss_path + '/'+ me.currentArchiveUuid +'.PDF" height="750px" width="100%" style="border: none;"></iframe>');
+                    me.currentArchivePdfPath = oss_path + '/'+ me.currentArchiveUuid +'.PDF?' + new Date(me.currentArchiveDateStr.slice(3).replace(/-/g, '/')).getTime();
+                    $('#iframe_made').html('<iframe src="/archive/pdf/show?file=' + me.currentArchivePdfPath + '" height="750px" width="100%" style="border: none;"></iframe>');
                 }
                 // let uuIdUrl =  "/getArchivedFileByUUID/" + me.currentArchiveUuid + "/" + stringUtil.replaceAll(me.currentNode.name, "#", "_");
                 // console.log(uuIdUrl);
@@ -192,18 +202,18 @@ let rptArchiveObj = {
         if(can_netcasign) {
             postData('/tender/'+ TENDER_ID +'/signReport/post', {type: 'pdfIsExist', uuid: me.currentArchiveUuid}, function (result) {
                 const uSignLogList = _.filter(signLogList, { uuid: me.currentArchiveUuid });
-                me.currentArchivePdfPath = result ? oss_path + '/sign/'+ me.currentArchiveUuid +'.PDF' + (uSignLogList.length !== 0 ? '?' + uSignLogList[uSignLogList.length-1].versionid : '') : oss_path + '/'+ me.currentArchiveUuid +'.PDF';
+                me.currentArchivePdfPath = result ? oss_path + '/sign/'+ me.currentArchiveUuid +'.PDF' + (uSignLogList.length !== 0 ? '?' + uSignLogList[uSignLogList.length-1].versionid : '') : oss_path + '/'+ me.currentArchiveUuid +'.PDF?' + new Date(me.currentArchiveDateStr.slice(3).replace(/-/g, '/')).getTime();
                 $('#iframe_made').html('<iframe src="/archive/pdf/show?file=' + me.currentArchivePdfPath + '" height="750px" width="100%" style="border: none;"></iframe>');
                 me._buildeArchiveDateSelect();
             }, function () {
-                me.currentArchivePdfPath = oss_path + '/'+ me.currentArchiveUuid +'.PDF';
-                $('#iframe_made').html('<iframe src="/archive/pdf/show?file=' + oss_path + '/'+ me.currentArchiveUuid +'.PDF" height="750px" width="100%" style="border: none;"></iframe>');
+                me.currentArchivePdfPath = oss_path + '/'+ me.currentArchiveUuid +'.PDF?' + new Date(me.currentArchiveDateStr.slice(3).replace(/-/g, '/')).getTime();
+                $('#iframe_made').html('<iframe src="/archive/pdf/show?file=' + me.currentArchivePdfPath + '" height="750px" width="100%" style="border: none;"></iframe>');
                 me._buildeArchiveDateSelect();
             });
             me._updateSignHtmlAndFrame();
         } else {
-            me.currentArchivePdfPath = oss_path + '/'+ me.currentArchiveUuid +'.PDF';
-            $('#iframe_made').html('<iframe src="/archive/pdf/show?file=' + oss_path + '/'+ me.currentArchiveUuid +'.PDF" height="750px" width="100%" style="border: none;"></iframe>');
+            me.currentArchivePdfPath = oss_path + '/'+ me.currentArchiveUuid +'.PDF?' + new Date(me.currentArchiveDateStr.slice(3).replace(/-/g, '/')).getTime();
+            $('#iframe_made').html('<iframe src="/archive/pdf/show?file=' + me.currentArchivePdfPath + '" height="750px" width="100%" style="border: none;"></iframe>');
             me._buildeArchiveDateSelect();
         }
     },
@@ -250,7 +260,7 @@ let rptArchiveObj = {
         }
         $('#page-list').html(pagetr);
         if (needFrame) {
-            me.currentArchivePdfPath = uSignLogList.length > 0 ? oss_path + '/sign/'+ me.currentArchiveUuid +'.PDF' : oss_path + '/'+ me.currentArchiveUuid +'.PDF';
+            me.currentArchivePdfPath = uSignLogList.length > 0 ? oss_path + '/sign/'+ me.currentArchiveUuid +'.PDF' : oss_path + '/'+ me.currentArchiveUuid +'.PDF?' + new Date(me.currentArchiveDateStr.slice(3).replace(/-/g, '/')).getTime();
             $('#iframe_made').html('<iframe src="/archive/pdf/show?file=' + me.currentArchivePdfPath + (uSignLogList.length !== 0 ? '?' + uSignLogList[uSignLogList.length-1].versionid : '') + '" height="750px" width="100%" style="border: none;"></iframe>');
         }
         $('#dateStr').html(me.currentArchiveDateStr);

+ 0 - 1
app/service/deal_bills.js

@@ -66,7 +66,6 @@ module.exports = app => {
                         }
                     } else {
                         const code = this.ctx.helper._.trim(row[iCode]);
-                        console.log(code);
                         if (this.ctx.helper.validBillsCode(code)) {
                             const data = {
                                 deal_id: bills.length + 1,

+ 1 - 1
app/view/report/index.ejs

@@ -262,7 +262,7 @@
     });
 </script>
 <script>
-    const tenders = JSON.parse('<%- JSON.stringify(tenderList) %>');
+    const tenders = JSON.parse(unescape('<%- escape(JSON.stringify(tenderList)) %>'));
     let ARCHIVE_LIST = JSON.parse('<%- JSON.stringify(archiveList) %>');
     let LAST_AUDITOR = JSON.parse('<%- JSON.stringify(lastAuditor) %>');
     const category = JSON.parse('<%- JSON.stringify(categoryData) %>');

+ 2 - 0
config/config.default.js

@@ -19,6 +19,8 @@ module.exports = appInfo => {
             password: 'Zh@)!(3850Calc',
             // 数据库名
             database: 'calculation',
+            // 设置mysql连接字符集
+            charset: 'utf8mb4',
         },
         // 是否加载到 app 上,默认开启
         app: true,