Browse Source

修复bug

laiguoran 4 years ago
parent
commit
862a5bf06b

+ 9 - 1
app/const/tender_info.js

@@ -8,7 +8,7 @@
  * @version
  */
 
-const parseInfo = ['deal_info', 'construction_unit', 'tech_param', 'decimal', 'precision', 'deal_param', 'display', 'pay_account'];
+const parseInfo = ['deal_info', 'construction_unit', 'tech_param', 'decimal', 'precision', 'deal_param', 'display', 'pay_account', 'shenpi'];
 const arrayInfo = ['chapter'];
 const defaultInfo = {
     // 合同信息
@@ -132,6 +132,14 @@ const defaultInfo = {
             phone: '',
         },
     },
+    shenpi: {
+        advance: 1,
+        ledger: 1,
+        revise: 1,
+        stage: 1,
+        change: 1,
+        material: 1,
+    },
 };
 
 module.exports = {

+ 16 - 15
app/controller/tender_controller.js

@@ -752,7 +752,7 @@ module.exports = app => {
                 return { groupName: item, groupList };
             });
             for (const sp of shenpiConst.sp_lc) {
-                sp.status = ctx.tender.info.shenpi ? JSON.parse(ctx.tender.info.shenpi)[sp.code] : shenpiConst.sp_status.sqspr;
+                sp.status = ctx.tender.info.shenpi ? ctx.tender.info.shenpi[sp.code] : shenpiConst.sp_status.sqspr;
                 if (sp.status === shenpiConst.sp_status.gdspl) {
                     sp.auditList = await ctx.service.shenpiAudit.getAuditList(ctx.tender.id, sp.type, sp.status);
                 } else if (sp.status === shenpiConst.sp_status.gdzs) {
@@ -778,20 +778,21 @@ module.exports = app => {
                 if (ctx.session.sessionUser.is_admin === 0) {
                     throw '你没有权限修改审批流程';
                 }
-                let postData = {};
-                if (!ctx.tender.info.shenpi) {
-                    for (const sp of shenpiConst.sp_lc) {
-                        if (sp.code === data.code) {
-                            postData[sp.code] = data.status;
-                        } else {
-                            postData[sp.code] = shenpiConst.sp_status.sqspr;
-                        }
-                    }
-                } else {
-                    postData = JSON.parse(ctx.tender.info.shenpi);
-                    postData[data.code] = data.status;
-                }
-                await ctx.service.tenderInfo.saveTenderInfo(ctx.tender.id, { shenpi: JSON.stringify(postData) });
+                // let postData = {};
+                // if (!ctx.tender.info.shenpi) {
+                //     for (const sp of shenpiConst.sp_lc) {
+                //         if (sp.code === data.code) {
+                //             postData[sp.code] = data.status;
+                //         } else {
+                //             postData[sp.code] = shenpiConst.sp_status.sqspr;
+                //         }
+                //     }
+                // } else {
+                const postData = ctx.tender.info.shenpi;
+                postData[data.code] = data.status;
+                // }
+                // console.log(postData);
+                await ctx.service.tenderInfo.saveTenderInfo(ctx.tender.id, { shenpi: postData });
                 let auditList = [];
                 if (data.status === shenpiConst.sp_status.gdspl) {
                     auditList = await ctx.service.shenpiAudit.getAuditList(ctx.tender.id, shenpiConst.sp_type[data.code], data.status);

+ 2 - 2
app/middleware/material_check.js

@@ -105,8 +105,8 @@ module.exports = options => {
             material.readOnly = !((material.status === status.uncheck || material.status === status.checkNo) && accountId === material.user_id);
             this.material = material;
             // 根据状态判断是否需要更新审批人列表
-            if ((material.status === status.uncheck || material.status === status.checkNo) && this.tender.info.shenpi && JSON.parse(this.tender.info.shenpi).material !== shenpiConst.sp_status.sqspr) {
-                const shenpi_status = JSON.parse(this.tender.info.shenpi).material;
+            if ((material.status === status.uncheck || material.status === status.checkNo) && this.tender.info.shenpi.material !== shenpiConst.sp_status.sqspr) {
+                const shenpi_status = this.tender.info.shenpi.material;
                 // 进一步比较审批流是否与审批流程设置的相同,不同则替换为固定审批流或固定的终审
                 const auditList = yield this.service.materialAudit.getAllDataByCondition({ where: { mid: material.id, times: material.times } });
                 const auditIdList = _.map(auditList, 'aid');

+ 4 - 6
app/view/material/audit_modal.ejs

@@ -8,7 +8,7 @@
             </div>
             <div class="modal-body">
                 <div class="dropdown text-right">
-                    <% if (!ctx.tender.info.shenpi || (ctx.tender.info.shenpi && JSON.parse(ctx.tender.info.shenpi).material !== shenpiConst.sp_status.gdspl)) { %>
+                    <% if (ctx.tender.info.shenpi.material !== shenpiConst.sp_status.gdspl) { %>
                     <button class="btn btn-outline-primary btn-sm dropdown-toggle" type="button"
                         id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true"
                         aria-expanded="false">
@@ -45,10 +45,8 @@
                     <ul class="list-group list-group-flush" id="auditors">
                         <% for (let i = 0, iLen = ctx.material.auditorList.length; i < iLen; i++) { %>
                         <li class="list-group-item" auditorId="<%- ctx.material.auditorList[i].aid %>">
-                            <% if (!ctx.tender.info.shenpi ||
-                                    (ctx.tender.info.shenpi && (JSON.parse(ctx.tender.info.shenpi).material === shenpiConst.sp_status.sqspr
-                                            || (JSON.parse(ctx.tender.info.shenpi).material === shenpiConst.sp_status.gdzs && i+1 !== iLen)
-                                    ))) { %>
+                            <% if (ctx.tender.info.shenpi.material === shenpiConst.sp_status.sqspr ||
+                                    (ctx.tender.info.shenpi.material === shenpiConst.sp_status.gdzs && i+1 !== iLen)) { %>
                             <a href="javascript: void(0)" class="text-danger pull-right">移除</a>
                             <% } %>
                             <span><%- ctx.material.auditorList[i].order %> <%- ctx.material.auditorList[i].name %></span>
@@ -686,7 +684,7 @@
     <script>
         const accountGroup = JSON.parse('<%- JSON.stringify(accountGroup) %>');
         const accountList = JSON.parse('<%- JSON.stringify(accountList) %>');
-        const is_gdzs = <% if (ctx.tender.info.shenpi && JSON.parse(ctx.tender.info.shenpi).material === shenpiConst.sp_status.gdzs) { %>1<% } else { %>0<% } %>;
+        const is_gdzs = <% if (ctx.tender.info.shenpi.material === shenpiConst.sp_status.gdzs) { %>1<% } else { %>0<% } %>;
     </script>
 <% } %>
 <script>const cur_uid = parseInt('<%- ctx.session.sessionUser.accountId %>');</script>

+ 2 - 0
app/view/tender/detail.ejs

@@ -100,7 +100,9 @@
                                 <a href="#bd-set-5" data-toggle="modal" data-target="#bd-set-5" class="btn btn-sm btn-outline-primary">显示设置</a>
                                 <a href="#bd-set-6" data-toggle="modal" data-target="#bd-set-6" class="btn btn-sm btn-outline-primary">章节设置</a>
                                 <a href="#bd-set-7" data-toggle="modal" data-target="#bd-set-7" class="btn btn-sm btn-outline-primary">付款账号</a>
+                                <% if (ctx.session.sessionUser.is_admin) { %>
                                 <a href="/tender/<%- tender.id %>/shenpi" class="btn btn-sm btn-outline-primary">审批流程</a>
+                                <% } %>
                             </div>
                         </div>
                     </div>