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