浏览代码

Merge branch 'master' of http://192.168.1.41:3000/maixinrong/Calculation

TonyKang 5 年之前
父节点
当前提交
50b7186ca4

+ 2 - 2
app/const/sms_alitemplate.js

@@ -17,9 +17,9 @@ const smsTemplate = {
     mmcz: 'SMS_192825318', // 账号:${account},密码重置为:${password}
     ledger_check: 'SMS_192825164', // 项目:${project},标段:${number},台帐需要您审批,请登录系统处理。
     ledger_result: 'SMS_192830156', // 项目:${project},标段:${number},台帐审批${status},请登录系统处理。
-    stage_check: 'SMS_192820179', // 项目:${project},标段:${number},第${qi}期,需要您审批。
+    stage_check: 'SMS_193244645', // 项目:${project},标段:${number},第${qi}期,需要您审批。在线审批https://scn.ink/${code}
     stage_result: 'SMS_192835176', // 项目:${project},标段:${number},第${qi}期,审批${status}。
-    change_check: 'SMS_192820171', // 项目:${project},标段:${number},变更:${biangeng},需要您审批。
+    change_check: 'SMS_193239611', // 项目:${project},标段:${number},变更:${biangeng},需要您审批。在线审批https://scn.ink/${code}
     change_result: 'SMS_192830143', // 项目:${project},标段:${number},变更:${biangeng},审批${status}。
     revise_check: 'SMS_193145529', // 项目:${project},标段:${number},台帐修订需要您审批,请登录系统处理。
     revise_result: 'SMS_193140537', // 项目:${project},标段:${number},台帐修订审批${status},请登录系统处理。

+ 15 - 3
app/controller/stage_controller.js

@@ -654,8 +654,8 @@ module.exports = app => {
                 if (data.updateType === 'update') {
                     const create_time = Date.parse(new Date()) / 1000;
                     const fileName = path.join('public/upload', this.ctx.tender.id.toString(), 'im', 'calcImg_' + create_time + '.png');
-                    const base64Data = data.img.replace(/^data:image\/\w+;base64,/, "");
-                    const dataBuffer = new Buffer(base64Data, 'base64');
+                    const base64Data = data.img.replace(/^data:image\/\w+;base64,/, '');
+                    const dataBuffer = new Buffer.from(base64Data, 'base64');
                     await this.ctx.helper.saveBufferFile(dataBuffer, path.join(this.app.baseDir, 'app', fileName));
                     data.calc_img = fileName;
                     data.calc_img_org = JSON.stringify(data.imgInfo);
@@ -1571,9 +1571,21 @@ module.exports = app => {
          */
         async manager(ctx) {
             try {
+
+                await this._getStageAuditViewData(ctx);
                 const renderData = await this._getDefaultRenderData(ctx);
                 // 获取已完成期审批列表
-                const auditList = await ctx.service.stageAudit.getAllDataByCondition({ tid: ctx.tender.id });
+                const lastStage = await ctx.service.stage.getLastestStage(ctx.tender.id);
+                const auditList = [];
+                if (lastStage && lastStage.status === auditConst.status.checked) {
+                    renderData.lastStageUser = await ctx.service.projectAccount.getDataById(lastStage.user_id);
+                    for (let i = lastStage.times; i > 0; i--) {
+                        const timeAuditList = await ctx.service.stageAudit.getAuditors(lastStage.id, i, 'desc');
+                        auditList.push(timeAuditList);
+                    }
+                }
+                renderData.lastStage = lastStage;
+                renderData.lastAuditList = auditList;
                 await this.layout('stage/manager.ejs', renderData, 'stage/manager_modal.ejs');
             } catch (err) {
                 this.log(err);

+ 6 - 7
app/extend/helper.js

@@ -992,13 +992,12 @@ module.exports = {
      * @returns {*}
      */
     async urlToShort(url) {
-        // const apiUrl = 'http://zhzdjg.com/api/shorturl';
-        // const data = {
-        //     url: encodeURI(url),
-        // };
-        // const result = await this.sendRequest(apiUrl, data, 'get');
-        // return result && result.code === 200 && result.url ? result.url : url;
-        return url;
+        const apiUrl = 'http://scn.ink/api/shorturl';
+        const data = {
+            url: encodeURI(url),
+        };
+        const result = await this.sendRequest(apiUrl, data, 'get');
+        return result && result.code === 200 && result.url ? result.url : url;
     },
 
     /**

+ 2 - 1
app/lib/sms.js

@@ -133,7 +133,7 @@ class SMS {
     // }
 
     /**
-     * 关键字转换
+     * 关键字转换,并限制20个字以内
      *
      * @param {String} content - 内容
      * @return {Object} - 解析结果
@@ -142,6 +142,7 @@ class SMS {
         let str = content.replace(/【/g, '(');
         str = str.replace(/】/g, ')');
         str = str.replace(/工程款/g, '***');
+        str = str.length > 20 ? str.substring(0, 17) + '...' : str;
         return str;
     }
 }

+ 4 - 2
app/lib/stage_im.js

@@ -609,8 +609,10 @@ class StageIm {
         }
         for (const im of nodeImData) {
             this._calculateBwBillsIm(im);
-            im.drawing_code = this.ctx.helper._.uniq(im.drawing_code).join(mergeChar);
-            im.position = this.ctx.helper._.uniq(im.position).join(mergeChar);
+            im.drawing_code = im.drawing_code instanceof Array
+                ? this.ctx.helper._.uniq(im.drawing_code).join(mergeChar) : im.drawing_code;
+            im.position = im.position instanceof Array
+                ? this.ctx.helper._.uniq(im.position).join(mergeChar): im.position;
             im.id = this.ImData.length + 1;
             this.ImData.push(im);
         }

+ 20 - 0
app/public/js/global.js

@@ -149,6 +149,11 @@ const postData = function (url, data, successCallback, errorCallBack, showWaitin
                 if (successCallback) {
                     successCallback(result.data);
                 }
+            } else if (result.err === 2) {
+                toastr.error('error: ' + result.msg);
+                setTimeout(function () {
+                    window.location.href = '/login';
+                },1000);
             } else {
                 toastr.error('error: ' + result.msg);
                 if (errorCallBack) {
@@ -194,6 +199,11 @@ const postDataCompress = function (url, data, successCallback, errorCallBack, ht
                 if (successCallback) {
                     successCallback(result.data);
                 }
+            } else if (result.err === 2) {
+                toastr.error('error: ' + result.msg);
+                setTimeout(function () {
+                    window.location.href = '/login';
+                },1000);
             } else {
                 toastr.error('error: ' + result.msg);
                 if (errorCallBack) {
@@ -248,6 +258,11 @@ const postDataWithFile = function (url, formData, successCallback, errorCallBack
                 if (successCallback) {
                     successCallback(result.data);
                 }
+            } else if (result.err === 2) {
+                toastr.error('error: ' + result.msg);
+                setTimeout(function () {
+                    window.location.href = '/login';
+                },1000);
             } else {
                 toastr.error('error: ' + result.msg);
                 if (errorCallBack) {
@@ -288,6 +303,11 @@ const postDataWithFileProgress = function (url, formData, successCallback, error
                 if (successCallback) {
                     successCallback(result.data);
                 }
+            } else if (result.err === 2) {
+                toastr.error('error: ' + result.msg);
+                setTimeout(function () {
+                    window.location.href = '/login';
+                },1000);
             } else {
                 toastr.error('error: ' + result.msg);
                 if (errorCallBack) {

+ 70 - 26
app/public/js/stage.js

@@ -2022,7 +2022,7 @@ $(document).ready(() => {
             this._initModifyDetail();
             this._initLocateRela();
             // 草图相关
-            this._initImageRela();
+            // this._initImageRela();
             this.reBuildImData();
         }
         _initImTypeSetRela() {
@@ -2334,6 +2334,7 @@ $(document).ready(() => {
         }
         _initModifyDetail() {
             const self = this;
+            let updateImageData;
             // 编辑
             $('#edit-detail').click(function () {
                 $(this).hide();
@@ -2341,6 +2342,7 @@ $(document).ready(() => {
                 $('#cancel-detail').show();
                 $('#detail-show').hide();
                 $('#detail-edit').show();
+                makeImageItem();
             });
             // 保存
             $('#save-detail').click(() => {
@@ -2390,14 +2392,21 @@ $(document).ready(() => {
                     stageIm.loadUpdateDetailData(result);
                     self.reLoadDetailData();
                 });
+                if (updateImageData) {
+                    postData(window.location.pathname + '/detail/merge-img', updateImageData, function (result) {
+                        stageIm.loadUpdateDetailData(result);
+                        updateImageData = '';
+                        self.reLoadDetailData();
+                    });
+                }
             });
             // 取消
             $('#cancel-detail').click(() => {
                 self.reLoadDetailData();
             });
-        }
-        _initImageRela() {
-            const self = this;
+        // }
+        // _initImageRela() {
+        //     const self = this;
             function setdraggrable(){
                 $( ".img-item" ).draggable({ containment: "parent" },{stop: function( event, ui ) {
                     }}).resizable({ containment: "parent" },{ handles: 'n, e, s, w, ne, se, sw, nw' },{ maxWidth: parseFloat($('#imgwidth').val())},{maxHeight: parseFloat($('#imgheight').val())},{
@@ -2443,7 +2452,24 @@ $(document).ready(() => {
                 $(this).parent().remove();
             };
             // 加载草图组成
-            $('#edit-img').on('show.bs.modal', function () {
+            // $('#edit-img').on('show.bs.modal', function () {
+            //     const data = SpreadJsObj.getSelectObject(self.spread.getActiveSheet());
+            //     const items = data.calc_img_org ? JSON.parse(data.calc_img_org) : [];
+            //     const html = [];
+            //     for (const item of items) {
+            //         const itemStyle = 'top:' + item.top + ';' + 'left:' + item.left + ';' + 'width:' + item.width + ';' + 'height:' + item.height + ';';
+            //         html.push('<div class="img-item" style="' + itemStyle + '">');
+            //         html.push('<div class="img-bar">');
+            //         html.push('<a href="javascript: void(0);" class="text-danger" title="删除"><i class="fa fa-remove" style="font-size: 24px"></i></a>');
+            //         html.push('</div>');
+            //         html.push('<div class="focus" style="width:100%; height:100%"><img src="', item.src, '" id="draggable" style="width:100%; height:100%"></div>');
+            //         html.push('</div>');
+            //     }
+            //     $('.img-view').html(html.join(''));
+            //     $('.img-bar').click(removeImageItem);
+            //     setdraggrable();
+            // });
+            function makeImageItem () {
                 const data = SpreadJsObj.getSelectObject(self.spread.getActiveSheet());
                 const items = data.calc_img_org ? JSON.parse(data.calc_img_org) : [];
                 const html = [];
@@ -2459,7 +2485,7 @@ $(document).ready(() => {
                 $('.img-view').html(html.join(''));
                 $('.img-bar').click(removeImageItem);
                 setdraggrable();
-            });
+            };
             // 上传图片
             $('#upload-img').click(function () {
                 $('#upload-img-file').trigger('click');
@@ -2540,27 +2566,45 @@ $(document).ready(() => {
                     }
                     updateData.img = canvas.toDataURL('image/png');
                     updateData.imgInfo = itemInfo;
-                    postData(window.location.pathname + '/detail/merge-img', updateData, function (result) {
-                        stageIm.loadUpdateDetailData(result);
-                        data.calc_img = result.calc_img;
-                        data.calc_img_org = result.calc_img_org;
-                        const calcImgSrc = data && data.calc_img ? '/' + data.calc_img : '';
-                        $('#show-calc-img').attr('src', calcImgSrc);
-                        $('#calc-img').attr('src', calcImgSrc);
-                        $('#view-calc-img').attr('src', calcImgSrc);
-                        $('#edit-img').modal('hide');
-                    });
+
+                    updateImageData = updateData;
+                    $('#calc-img').attr('src', updateData.img);
+                    $('#view-calc-img').attr('src', updateData.img);
+                    $('#show-calc-img').attr('src', updateData.img);
+                    $('#edit-img').modal('hide');
+                    // updateImageData = updateData;
+                    // $('#edit-img').modal('hide');
+                    // postData(window.location.pathname + '/detail/merge-img', updateData, function (result) {
+                    //     stageIm.loadUpdateDetailData(result);
+                    //     data.calc_img = result.calc_img;
+                    //     data.calc_img_org = result.calc_img_org;
+                    //     const calcImgSrc = data && data.calc_img ? '/' + data.calc_img : '';
+                    //     $('#show-calc-img').attr('src', calcImgSrc);
+                    //     $('#calc-img').attr('src', calcImgSrc);
+                    //     $('#view-calc-img').attr('src', calcImgSrc);
+                    //     $('#edit-img').modal('hide');
+                    // });
                 } else if (data.calc_img) {
-                    postData(window.location.pathname + '/detail/merge-img', {updateType: 'clear', lid: data.lid, pid: data.pid, uuid: data.uuid}, function (result) {
-                        stageIm.loadUpdateDetailData(result);
-                        data.calc_img = result.calc_img;
-                        data.calc_img_org = result.calc_img_org;
-                        const calcImgSrc = data && data.calc_img ? '/' + data.calc_img : '';
-                        $('#show-calc-img').attr('src', calcImgSrc);
-                        $('#calc-img').attr('src', calcImgSrc);
-                        $('#view-calc-img').attr('src', calcImgSrc);
-                        $('#edit-img').modal('hide');
-                    });
+                    updateImageData = {updateType: 'clear', lid: data.lid, pid: data.pid, uuid: data.uuid};
+                    $('#show-calc-img').attr('src', '');
+                    $('#calc-img').attr('src', '');
+                    $('#view-calc-img').attr('src', '');
+                    $('#edit-img').modal('hide');
+                    // postData(window.location.pathname + '/detail/merge-img', {updateType: 'clear', lid: data.lid, pid: data.pid, uuid: data.uuid}, function (result) {
+                    //     stageIm.loadUpdateDetailData(result);
+                    //     data.calc_img = result.calc_img;
+                    //     data.calc_img_org = result.calc_img_org;
+                    //     const calcImgSrc = data && data.calc_img ? '/' + data.calc_img : '';
+                    //     $('#show-calc-img').attr('src', calcImgSrc);
+                    //     $('#calc-img').attr('src', calcImgSrc);
+                    //     $('#view-calc-img').attr('src', calcImgSrc);
+                    //     $('#edit-img').modal('hide');
+                    // });
+                } else {
+                    $('#show-calc-img').attr('src', '');
+                    $('#calc-img').attr('src', '');
+                    $('#view-calc-img').attr('src', '');
+                    $('#edit-img').modal('hide');
                 }
             });
         }

+ 6 - 4
app/public/js/stage_im.js

@@ -9,7 +9,7 @@
  */
 
 const stageIm = (function () {
-    const imFields = ['uuid', 'doc_code', 'peg', 'bw', 'xm', 'drawing_code', 'calc_memo', 'calc_img', 'position', 'jldy'];
+    const imFields = ['uuid', 'doc_code', 'peg', 'bw', 'xm', 'drawing_code', 'calc_memo', 'calc_img', 'calc_img_org', 'position', 'jldy'];
     const splitChar = '-';
     const mergeChar = ';';
     let stage, imType, decimal, details, changes, ImData, pre;
@@ -559,8 +559,10 @@ const stageIm = (function () {
             }
             for (const im of nodeImData) {
                 calculateBwBillsIm(im);
-                im.drawing_code = _.uniq(im.drawing_code).join(mergeChar);
-                im.position = _.uniq(im.position).join(mergeChar);
+                im.drawing_code = im.drawing_code instanceof Array
+                    ? _.uniq(im.drawing_code).join(mergeChar) : im.drawing_code;
+                im.position = im.position instanceof Array
+                    ?_.uniq(im.position).join(mergeChar) : im.position;
                 ImData.push(im);
             }
         }
@@ -889,4 +891,4 @@ const stageIm = (function () {
             return ImData;
         },
     }
-})();
+})();

+ 5 - 0
app/public/js/wap/global.js

@@ -32,6 +32,11 @@ const postData = function (url, data, successCallback, errorCallBack, showWaitin
                 if (successCallback) {
                     successCallback(result.data);
                 }
+            } else if (result.err === 2) {
+                toastr.error('error: ' + result.msg);
+                setTimeout(function () {
+                    window.location.href = '/wap/login';
+                },1000);
             } else {
                 toastr.error('error: ' + result.msg);
                 if (errorCallBack) {

+ 24 - 16
app/service/change.js

@@ -384,8 +384,9 @@ module.exports = app => {
                             // }
                             const sms = new SMS(this.ctx);
                             const code = await sms.contentChange(changeInfo.code);
+                            const shenpiUrl = await this.ctx.helper.urlToShort('http://' + this.ctx.request.header.host + '/wap/tender/' + changeInfo.tid + '/change/' + changeInfo.cid + '/info#shenpi');
                             await this.ctx.helper.sendAliSms(auditInfo[0], smsTypeConst.const.BG,
-                                smsTypeConst.judge.approval.toString(), SmsAliConst.template.change_check, { biangeng: code });
+                                smsTypeConst.judge.approval.toString(), SmsAliConst.template.change_check, { biangeng: code, code: shenpiUrl });
                         }
                     }
                     await this.transaction.insert(this.ctx.service.changeAudit.tableName, insertCA);
@@ -546,7 +547,7 @@ module.exports = app => {
                     const sms = new SMS(this.ctx);
                     const code = await sms.contentChange(changeData.code);
                     await this.ctx.helper.sendAliSms(users, smsTypeConst.const.BG,
-                        smsTypeConst.judge.approval.toString(), SmsAliConst.template.change_result, { biangeng: code, status: SmsAliConst.status.success });
+                        smsTypeConst.judge.result.toString(), SmsAliConst.template.change_result, { biangeng: code, status: SmsAliConst.status.success });
                 } else {
                     // 设置下一个审批人为审批状态
                     const nextAudit_update = {
@@ -570,8 +571,9 @@ module.exports = app => {
                     //         sms.send(smsUser.auth_mobile, content);
                     //     }
                     // }
+                    const shenpiUrl = await this.ctx.helper.urlToShort('http://' + this.ctx.request.header.host + '/wap/tender/' + changeData.tid + '/change/' + changeData.cid + '/info#shenpi');
                     await this.ctx.helper.sendAliSms(nextAuditData.uid, smsTypeConst.const.BG,
-                        smsTypeConst.judge.approval.toString(), SmsAliConst.template.change_check, { biangeng: code });
+                        smsTypeConst.judge.approval.toString(), SmsAliConst.template.change_check, { biangeng: code, code: shenpiUrl });
                 }
                 change_update.total_price = total_price;
                 const options = {
@@ -719,7 +721,7 @@ module.exports = app => {
                 const sms = new SMS(this.ctx);
                 const code = await sms.contentChange(changeData.code);
                 await this.ctx.helper.sendAliSms(users, smsTypeConst.const.BG,
-                    smsTypeConst.judge.approval.toString(), SmsAliConst.template.change_result, { biangeng: code, status: SmsAliConst.status.back });
+                    smsTypeConst.judge.result.toString(), SmsAliConst.template.change_result, { biangeng: code, status: SmsAliConst.status.back });
             } catch (error) {
                 await this.transaction.rollback();
                 result = false;
@@ -845,8 +847,9 @@ module.exports = app => {
                 // }
                 const sms = new SMS(this.ctx);
                 const code = await sms.contentChange(changeData.code);
+                const shenpiUrl = await this.ctx.helper.urlToShort('http://' + this.ctx.request.header.host + '/wap/tender/' + changeData.tid + '/change/' + changeData.cid + '/info#shenpi');
                 await this.ctx.helper.sendAliSms(lastauditInfo.uid, smsTypeConst.const.BG,
-                    smsTypeConst.judge.approval.toString(), SmsAliConst.template.change_check, { biangeng: code });
+                    smsTypeConst.judge.approval.toString(), SmsAliConst.template.change_check, { biangeng: code, code: shenpiUrl });
             } catch (error) {
                 await this.transaction.rollback();
                 result = false;
@@ -1063,17 +1066,22 @@ module.exports = app => {
                 result = true;
 
                 // 添加短信通知-需要审批提醒功能
-                const smsUser = await this.ctx.service.projectAccount.getDataById(auditInfo.uid);
-                if (smsUser.auth_mobile !== '' && smsUser.auth_mobile !== undefined && smsUser.sms_type !== '' && smsUser.sms_type !== null) {
-                    const smsType = JSON.parse(smsUser.sms_type);
-                    if (smsType[smsTypeConst.const.BG] !== undefined && smsType[smsTypeConst.const.BG].indexOf(smsTypeConst.judge.approval.toString()) !== -1) {
-                        const sms = new SMS(this.ctx);
-                        const code = await sms.contentChange(changeInfo.code);
-                        const result = await this.ctx.helper.urlToShort('http://' + this.ctx.request.header.host + '/wap/tender/' + changeInfo.tid + '/change/' + changeInfo.cid + '/info#shenpi');
-                        const content = '【纵横计量支付】' + code + '变更需要您审批。' + result;
-                        sms.send(smsUser.auth_mobile, content);
-                    }
-                }
+                // const smsUser = await this.ctx.service.projectAccount.getDataById(auditInfo.uid);
+                // if (smsUser.auth_mobile !== '' && smsUser.auth_mobile !== undefined && smsUser.sms_type !== '' && smsUser.sms_type !== null) {
+                //     const smsType = JSON.parse(smsUser.sms_type);
+                //     if (smsType[smsTypeConst.const.BG] !== undefined && smsType[smsTypeConst.const.BG].indexOf(smsTypeConst.judge.approval.toString()) !== -1) {
+                //         const sms = new SMS(this.ctx);
+                //         const code = await sms.contentChange(changeInfo.code);
+                //         const result = await this.ctx.helper.urlToShort('http://' + this.ctx.request.header.host + '/wap/tender/' + changeInfo.tid + '/change/' + changeInfo.cid + '/info#shenpi');
+                //         const content = '【纵横计量支付】' + code + '变更需要您审批。' + result;
+                //         sms.send(smsUser.auth_mobile, content);
+                //     }
+                // }
+                const sms = new SMS(this.ctx);
+                const code = await sms.contentChange(changeInfo.code);
+                const shenpiUrl = await this.ctx.helper.urlToShort('http://' + this.ctx.request.header.host + '/wap/tender/' + changeInfo.tid + '/change/' + changeInfo.cid + '/info#shenpi');
+                await this.ctx.helper.sendAliSms(auditInfo.uid, smsTypeConst.const.BG,
+                    smsTypeConst.judge.approval.toString(), SmsAliConst.template.change_check, { biangeng: code, code: shenpiUrl });
             } catch (error) {
                 await this.transaction.rollback();
                 result = false;

+ 1 - 1
app/service/report_memory.js

@@ -337,7 +337,7 @@ module.exports = app => {
             for (const node of this.billsTree.nodes) {
                 if (node.b_code) {
                     const leafXmj = this.billsTree.getLeafXmjParent(node);
-                    node.leaf_xmj_id = leafXmj.id;
+                    node.leaf_xmj_id = leafXmj ? leafXmj.id : -1;
                 }
             }
         }

+ 11 - 6
app/service/stage_audit.js

@@ -48,12 +48,13 @@ module.exports = app => {
          *
          * @param {Number} stageId - 期id
          * @param {Number} times - 第几次审批
+         * @param {Number} order_sort - 列表排序方式
          * @returns {Promise<*>}
          */
-        async getAuditors(stageId, times = 1) {
+        async getAuditors(stageId, times = 1, order_sort = 'asc') {
             const sql = 'SELECT la.`aid`, pa.`name`, pa.`company`, pa.`role`, pa.`mobile`, pa.`telephone`, la.`times`, la.`order`, la.`status`, la.`opinion`, la.`begin_time`, la.`end_time`, g.`sort` ' +
                 'FROM ?? AS la, ?? AS pa, (SELECT `aid`,(@i:=@i+1) as `sort` FROM ??, (select @i:=0) as it WHERE `sid` = ? AND `times` = ? GROUP BY `aid`) as g ' +
-                'WHERE la.`sid` = ? and la.`times` = ? and la.`aid` = pa.`id` and g.`aid` = la.`aid` order by la.`order`';
+                'WHERE la.`sid` = ? and la.`times` = ? and la.`aid` = pa.`id` and g.`aid` = la.`aid` order by la.`order` ' + order_sort;
             const sqlParam = [this.tableName, this.ctx.service.projectAccount.tableName, this.tableName, stageId, times, stageId, times];
             const result = await this.db.query(sql, sqlParam);
             const sql2 = 'SELECT COUNT(a.`aid`) as num FROM (SELECT `aid` FROM ?? WHERE `sid` = ? AND `times` = ? GROUP BY `aid`) as a';
@@ -261,8 +262,9 @@ module.exports = app => {
                 //     }
                 // }
                 const stageInfo = await this.ctx.service.stage.getDataById(audit.sid);
+                const shenpiUrl = await this.ctx.helper.urlToShort('http://' + this.ctx.request.header.host + '/wap/tender/' + this.ctx.tender.id + '/stage/' + stageInfo.order);
                 await this.ctx.helper.sendAliSms(audit.aid, smsTypeConst.const.JL,
-                    smsTypeConst.judge.approval.toString(), SmsAliConst.template.stage_check, { qi: stageInfo.order });
+                    smsTypeConst.judge.approval.toString(), SmsAliConst.template.stage_check, { qi: stageInfo.order, code: shenpiUrl });
 
                 // todo 更新标段tender状态 ?
                 await transaction.commit();
@@ -333,8 +335,9 @@ module.exports = app => {
                     //     }
                     // }
                     const stageInfo = await this.ctx.service.stage.getDataById(nextAudit.sid);
+                    const shenpiUrl = await this.ctx.helper.urlToShort('http://' + this.ctx.request.header.host + '/wap/tender/' + this.ctx.tender.id + '/stage/' + stageInfo.order);
                     await this.ctx.helper.sendAliSms(nextAudit.aid, smsTypeConst.const.JL,
-                        smsTypeConst.judge.approval.toString(), SmsAliConst.template.stage_check, { qi: stageInfo.order });
+                        smsTypeConst.judge.approval.toString(), SmsAliConst.template.stage_check, { qi: stageInfo.order, code: shenpiUrl });
                 } else {
                     // 本期结束
                     // 生成截止本期数据 final数据
@@ -574,8 +577,9 @@ module.exports = app => {
                 //     }
                 // }
                 const stageInfo = await this.ctx.service.stage.getDataById(audit.sid);
+                const shenpiUrl = await this.ctx.helper.urlToShort('http://' + this.ctx.request.header.host + '/wap/tender/' + this.ctx.tender.id + '/stage/' + stageInfo.order);
                 await this.ctx.helper.sendAliSms(preAuditor.aid, smsTypeConst.const.JL,
-                    smsTypeConst.judge.approval.toString(), SmsAliConst.template.stage_check, { qi: stageInfo.order });
+                    smsTypeConst.judge.approval.toString(), SmsAliConst.template.stage_check, { qi: stageInfo.order, code: shenpiUrl });
 
                 await transaction.commit();
             } catch (err) {
@@ -794,8 +798,9 @@ module.exports = app => {
                 //     }
                 // }
                 const stageInfo = await this.ctx.service.stage.getDataById(audit.sid);
+                const shenpiUrl = await this.ctx.helper.urlToShort('http://' + this.ctx.request.header.host + '/wap/tender/' + this.ctx.tender.id + '/stage/' + stageInfo.order);
                 await this.ctx.helper.sendAliSms(audit.aid, smsTypeConst.const.JL,
-                    smsTypeConst.judge.approval.toString(), SmsAliConst.template.stage_check, { qi: stageInfo.order });
+                    smsTypeConst.judge.approval.toString(), SmsAliConst.template.stage_check, { qi: stageInfo.order, code: shenpiUrl });
                 await transaction.commit();
             } catch (err) {
                 await transaction.rollback();

+ 60 - 187
app/view/stage/manager.ejs

@@ -4,203 +4,76 @@
         <div class="title-main d-flex">
             <% include ./stage_sub_mini_menu.ejs %>
             <div>
-                第5
+                第<%- ctx.stage.order %>
             </div>
         </div>
     </div>
     <div class="content-wrap">
         <div class="sjs-height-0">
             <div class="c-body">
-                <!--第5期-->
-                <table class="table table-bordered">
-                    <thead>
-                    <tr><th>第5期</th></tr>
-                    </thead>
-                    <tr>
-                        <td>
-                            <table class="table table-bordered table-hover">
-                                <thead>
-                                <tr><th colspan="5">2#<a href="#del" data-toggle="modal" class="btn btn-sm btn-light pull-right text-danger">删除本次审批</a><a href="#pass" data-toggle="modal" class="btn btn-sm btn-warning pull-right mr-2">设置终审审批</a></th></tr>
-                                </thead>
-                                <tbody>
-                                <tr>
-                                    <th width="10%">审批流程</th>
-                                    <th width="25%">审批人</th>
-                                    <th width="15%">审批状态</th>
-                                    <th>审批意见</th>
-                                </tr>
-                                <tr>
-                                    <td>终审</td>
-                                    <td>孙鸿福(总工程师)<p class="text-muted m-0">XXX公司</p></td>
-                                    <td><span class="text-success">审批通过</span><p class="text-muted m-0">2019-08-02</p></td>
-                                    <td></td>
-                                </tr>
-                                <tr>
-                                    <td>3审</td>
-                                    <td>王泰鸿(副工程师)<p class="text-muted m-0">XXX公司</p></td>
-                                    <td><span class="text-success">审批通过</span><p class="text-muted m-0">2019-08-01</p></td>
-                                    <td>审批意见内容在这显示</td>
-                                </tr>
-                                <tr>
-                                    <td>2审</td>
-                                    <td>张立轩(工程师)<p class="text-muted m-0">XXX公司</p></td>
-                                    <td><span class="text-success">审批通过</span><p class="text-muted m-0">2019-07-30</p></td>
-                                    <td>审批意见内容在这显示</td>
-                                </tr>
-                                <tr>
-                                    <td>1审</td>
-                                    <td>吕烨华(监理)<p class="text-muted m-0">XXX公司</p></td>
-                                    <td><span class="text-success">审批通过</span><p class="text-muted m-0">2019-07-28</p></td>
-                                    <td>审批意见内容在这显示</td>
-                                </tr>
-                                <tr>
-                                    <td>原报</td>
-                                    <td>池元化<p class="text-muted m-0">XXX公司</p></td>
-                                    <td><span class="">上报</span><p class="text-muted m-0">2019-07-27</p></td>
-                                    <td>审批意见内容在这显示</td>
-                                </tr>
-                                </tbody>
-                            </table>
-                            <table class="table table-bordered table-hover">
-                                <thead>
-                                <tr><th colspan="5">1#</th></tr>
-                                </thead>
-                                <tbody>
-                                <tr>
-                                    <th width="10%">审批流程</th>
-                                    <th width="25%">审批人</th>
-                                    <th width="15%">审批状态</th>
-                                    <th>审批意见</th>
-                                </tr>
-                                <tr>
-                                    <td>2审</td>
-                                    <td>张立轩(工程师)<p class="text-muted m-0">XXX公司</p></td>
-                                    <td><span class="text-danger">退回原报</span><p class="text-muted m-0">2019-07-26</p></td>
-                                    <td>审批意见内容在这显示</td>
-                                </tr>
-                                <tr>
-                                    <td>1审</td>
-                                    <td>吕烨华(监理)<p class="text-muted m-0">XXX公司</p></td>
-                                    <td><span class="text-success">审批通过</span><p class="text-muted m-0">2019-07-25</p></td>
-                                    <td>审批意见内容在这显示</td>
-                                </tr>
-                                <tr>
-                                    <td>原报</td>
-                                    <td>池元化<p class="text-muted m-0">XXX公司</p></td>
-                                    <td><span class="">上报</span><p class="text-muted m-0">2019-07-24</p></td>
-                                    <td>审批意见内容在这显示</td>
-                                </tr>
-                                </tbody>
-                            </table>
-                        </td>
-                    </tr>
-                </table>
-                <!--第5期 为上报-->
-                <table class="table table-bordered">
-                    <thead>
-                    <tr><th>第5期</th></tr>
-                    </thead>
-                    <tr><td class="text-center text-muted">未上报</td></tr>
-                </table>
-                <!--第4期-->
-                <table class="table table-bordered">
-                    <thead>
-                    <tr><th>第4期</th></tr>
-                    </thead>
-                    <tr><td class="text-center text-muted">需处理前一期后,再进行管理</td></tr>
-                </table>
-                <!--第3期-->
-                <table class="table table-bordered">
-                    <thead>
-                    <tr><th>第3期</th></tr>
-                    </thead>
-                    <tr><td class="text-center text-muted">需处理前一期后,再进行管理</td></tr>
-                </table>
-                <!--第2期-->
-                <table class="table table-bordered">
-                    <thead>
-                    <tr><th>第2期</th></tr>
-                    </thead>
-                    <tr><td class="text-center text-muted">需处理前一期后,再进行管理</td></tr>
-                </table>
-                <!--第1期-->
-                <table class="table table-bordered">
-                    <thead>
-                    <tr><th>第1期</th></tr>
-                    </thead>
-                    <tr><td class="text-center text-muted">需处理前一期后,再进行管理</td></tr>
-                </table>
+                <% if (lastStage) { %>
+                <% for (let i = lastStage.order; i > 0; i--) { %>
+                    <% if (i === lastStage.order && lastStage.status === auditConst.status.checked) { %>
+                    <table class="table table-bordered">
+                        <thead>
+                        <tr><th>第<%- lastStage.order %>期</th></tr>
+                        </thead>
+                        <tr>
+                            <td>
+                                <% for (const la in lastAuditList) { %>
+                                <table class="table table-bordered table-hover">
+                                    <thead>
+                                    <tr><th colspan="5"><%- lastAuditList[la][0].times %>#
+                                            <% if (parseInt(la) === 0) { %><a href="#del" data-toggle="modal" class="btn btn-sm btn-light pull-right text-danger">删除本次审批</a><a href="#pass" data-toggle="modal" class="btn btn-sm btn-warning pull-right mr-2">设置终审审批</a><% } %>
+                                        </th></tr>
+                                    </thead>
+                                    <tbody>
+                                    <tr>
+                                        <th width="10%">审批流程</th>
+                                        <th width="25%">审批人</th>
+                                        <th width="15%">审批状态</th>
+                                        <th>审批意见</th>
+                                    </tr>
+                                    <% for (const audit of lastAuditList[la]) { %>
+                                    <tr>
+                                        <td><% if (audit.max_sort === audit.sort) { %>终<% } else { %><%- audit.sort %><% } %>审</td>
+                                        <td><%- audit.name %><% if (audit.role) { %>(<%- audit.role %>)<% } %><p class="text-muted m-0"><%- audit.company %></p></td>
+                                        <td>
+                                            <% if (audit.status === auditConst.status.checkNo) { %>
+                                            <span class="text-danger">退回原报</span>
+                                            <% } else { %>
+                                            <span class="<%- auditConst.auditStringClass[audit.status] %>"><% if (audit.status !== auditConst.status.uncheck) { %><%- auditConst.auditProgress[audit.status] %><% } %></span>
+                                            <% } %>
+                                            <p class="text-muted m-0"><% if (audit.status !== auditConst.status.uncheck) { %><%- audit.end_time.toLocaleDateString() %><% } %></p></td>
+                                        <td><%- audit.opinion %></td>
+                                    </tr>
+                                    <% } %>
+                                    <tr>
+                                        <td>原报</td>
+                                        <td><%- lastStageUser.name %><% if (lastStageUser.role) { %>(<%- lastStageUser.role %>)<% } %><p class="text-muted m-0"><%- lastStageUser.company %></p></td>
+                                        <td><span>上报</span><p class="text-muted m-0"><%- lastAuditList[la][lastAuditList[la].length - 1].begin_time.toLocaleDateString() %></p></td>
+                                        <td></td>
+                                    </tr>
+                                    </tbody>
+                                </table>
+                                <% } %>
+                            </td>
+                        </tr>
+                    </table>
+                    <% } else { %>
+                    <table class="table table-bordered">
+                        <thead>
+                        <tr><th>第<%- i %>期</th></tr>
+                        </thead>
+                        <tr><td class="text-center text-muted"><% if (i === lastStage.order && lastStage.status !== auditConst.status.checked) { %><%- auditConst.statusString[lastStage.status] %><% } else { %>需处理前一期后,再进行管理<% } %></td></tr>
+                    </table>
+                    <% } %>
+                <% } %>
+                <% } %>
             </div>
         </div>
     </div>
 </div>
-<script type="text/javascript" src="/public/js/ztree/jquery.ztree.core.js"></script>
-<script type="text/javascript" src="/public/js/ztree/jquery.ztree.excheck.js"></script>
-<script type="text/javascript">
-    <!--
-    var setting = {
-        view: {
-            selectedMulti: false
-        },
-        data: {
-            simpleData: {
-                enable: true
-            }
-        },
-        callback: {
-            onCheck: onCheck
-        }
-    };
-
-    var zNodes =[
-        { id:1, pId:0, name:"通用报表", open:true},
-        { id:11, pId:1, name:"XXX表 1-1"},
-        { id:122, pId:11, name:"报表 1-2-2"},
-        { id:123, pId:11, name:"报表 1-2-3"},
-        { id:12, pId:1, name:"YYY表", open:true},
-        { id:124, pId:12, name:"报表 1-2-1"},
-        { id:125, pId:12, name:"报表 1-2-2"},
-        { id:126, pId:12, name:"报表 1-2-3"},
-        { id:2, pId:0, name:"定制报表", open:true},
-        { id:21, pId:2, name:"AA报表 2-1"},
-        { id:221, pId:21, name:"报表 2-2-1"},
-        { id:222, pId:21, name:"报表 2-2-2"},
-        { id:223, pId:21, name:"报表 2-2-3"},
-        { id:22, pId:2, name:"BB报表 2-2", open:true},
-        { id:224, pId:22, name:"报表 2-2-1"},
-        { id:225, pId:22, name:"报表 2-2-2"},
-        { id:226, pId:22, name:"报表 2-2-3"}
-    ];
-
-    var clearFlag = false;
-    function onCheck(e, treeId, treeNode) {
-        count();
-        if (clearFlag) {
-            clearCheckedOldNodes();
-        }
-    }
-    function clearCheckedOldNodes() {
-        var zTree = $.fn.zTree.getZTreeObj("treeDemo2"),
-            nodes = zTree.getChangeCheckedNodes();
-        for (var i=0, l=nodes.length; i<l; i++) {
-            nodes[i].checkedOld = nodes[i].checked;
-        }
-    }
-    function count() {
-        var zTree = $.fn.zTree.getZTreeObj("treeDemo2"),
-            checkCount = zTree.getCheckedNodes(true).length;
-        $("#checkCount2").text(checkCount);
-
-    }
-    function createTree() {
-        $.fn.zTree.init($("#treeDemo2"), setting, zNodes);
-        count();
-    }
-    $(document).ready(function(){
-        createTree();
-    });
-    //-->
-</script>
 <script type="text/javascript">
     autoFlashHeight();
 </script>

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

@@ -37,3 +37,4 @@
         </div>
     </div>
 </div>
+<% include ./audit_modal.ejs %>