瀏覽代碼

显示设置,签约默认值调整

MaiXinRong 2 年之前
父節點
當前提交
e967e59323
共有 3 個文件被更改,包括 23 次插入6 次删除
  1. 11 0
      app/const/tender_info.js
  2. 1 1
      app/service/tender.js
  3. 11 5
      app/service/tender_info.js

+ 11 - 0
app/const/tender_info.js

@@ -180,9 +180,20 @@ const defaultInfo = {
         },
     },
 };
+const gclDefaultInfo = (function () {
+    const result = JSON.parse(JSON.stringify(defaultInfo));
+    result.display.ledger.deal = true;
+    return result;
+})(defaultInfo);
+const tzDefaultInfo = (function () {
+    const result = JSON.parse(JSON.stringify(defaultInfo));
+    return result;
+})(defaultInfo);
 
 module.exports = {
     parseInfo,
     arrayInfo,
     defaultInfo,
+    gclDefaultInfo,
+    tzDefaultInfo,
 };

+ 1 - 1
app/service/tender.js

@@ -437,7 +437,7 @@ module.exports = app => {
 
         async getCheckTender(tid) {
             const tender = await this.ctx.service.tender.getTender(tid);
-            tender.info = await this.ctx.service.tenderInfo.getTenderInfo(tid);
+            if (tender.measure_type) tender.info = await this.ctx.service.tenderInfo.getTenderInfo(tid);
             return tender;
         }
 

+ 11 - 5
app/service/tender_info.js

@@ -11,10 +11,9 @@
 const infoConst = require('../const/tender_info');
 const parseInfo = infoConst.parseInfo;
 const arrayInfo = infoConst.arrayInfo;
-const defaultInfo = infoConst.defaultInfo;
 const advanceConst = require('../const/audit').advance;
 const auditConst = require('../const/audit');
-
+const measureType = require('../const/tender').measureType;
 
 module.exports = app => {
 
@@ -31,6 +30,11 @@ module.exports = app => {
             this.tableName = 'tender_info';
         }
 
+        async getDefaultInfo (tenderId) {
+            const tender = await this.ctx.service.tender.getTender(tenderId);
+            return tender.measure_type === measureType.tz.value ? infoConst.tzDefaultInfo : infoConst.gclDefaultInfo;
+        }
+
         /**
          * 新增 标段相关信息
          *
@@ -40,6 +44,7 @@ module.exports = app => {
          * @return {Promise<void>}
          */
         async addTenderInfo(tenderId, projectId, transaction) {
+            const defaultInfo = await this.getDefaultInfo(tenderId);
             const info = JSON.parse(JSON.stringify(defaultInfo));
             info.tid = tenderId;
             info.pid = projectId;
@@ -64,11 +69,10 @@ module.exports = app => {
          * @return {Promise<void>}
          */
         async getTenderInfo(tenderId) {
+            const defaultInfo = await this.getDefaultInfo(tenderId);
             let info = await this.getDataByCondition({ tid: tenderId });
             // 兼容不存在info的情况
-            if (!info) {
-                info = await this.addTenderInfo(tenderId, this.ctx.session.sessionProject.id);
-            }
+            if (!info) info = await this.addTenderInfo(tenderId, this.ctx.session.sessionProject.id);
             for (const pi of parseInfo) {
                 info[pi] = !info[pi] || info[pi] === '' ? (pi === 'shenpi' ? JSON.parse(JSON.stringify(defaultInfo[pi])) : defaultInfo[pi]) : JSON.parse(info[pi]);
                 this.ctx.helper._.defaults(info[pi], defaultInfo[pi]);
@@ -88,6 +92,7 @@ module.exports = app => {
          * @return {Promise<void>}
          */
         async getTenderInfoEx(tenderId) {
+            const defaultInfo = await this.getDefaultInfo(tenderId);
             const sql = 'select t2.name, t1.* from zh_tender_info t1 inner join zh_tender t2 on t2.id = t1.tid where t1.tid = ?';
             const sqlParam = [tenderId];
             const list = await this.db.query(sql, sqlParam);
@@ -378,6 +383,7 @@ module.exports = app => {
          * @return {Promise<void>}
          */
         async getTenderShenpiInfo(tenderId) {
+            const defaultInfo = await this.getDefaultInfo(tenderId);
             const info = await this.getDataByCondition({ tid: tenderId });
             // 还没选择模式的标段不应该可以选择审批流程设置
             if (!info) {