Browse Source

修复归档审批人列无法显示bug,数据库改成utf8mb4支持emoji

laiguoran 4 years ago
parent
commit
941fcf68b8
3 changed files with 53 additions and 2 deletions
  1. 50 1
      app/controller/report_archive_controller.js
  2. 1 1
      app/view/report/index.ejs
  3. 2 0
      config/config.default.js

+ 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) {

+ 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,