|
@@ -16,7 +16,7 @@ const path = require('path');
|
|
|
const commonQueryColumns = [
|
|
|
'id', 'project_id', 'name', 'status', 'category', 'ledger_times', 'ledger_status', 'measure_type', 'user_id', 'valuation', 'create_time',
|
|
|
'total_price', 'deal_tp', 'copy_id', 's2b_gxby_check', 's2b_gxby_limit', 's2b_dagl_check', 's2b_dagl_limit', 'has_rela', 'his_id', 'rpt_show_level',
|
|
|
- 'build_status', 'settle_order',
|
|
|
+ 'build_status', 'settle_order', 'spid',
|
|
|
];
|
|
|
|
|
|
module.exports = app => {
|
|
@@ -92,7 +92,7 @@ module.exports = app => {
|
|
|
let sqlParam = [];
|
|
|
if (listStatus === 'manage') {
|
|
|
// 管理页面只取属于自己创建的标段
|
|
|
- sql = 'SELECT t.`id`, t.`project_id`, t.`name`, t.`status`, t.`category`, t.`ledger_times`, t.`ledger_status`, t.`measure_type`, t.`user_id`, t.`create_time`, t.`total_price`, t.`deal_tp`,' +
|
|
|
+ sql = 'SELECT t.`id`, t.`project_id`, t.`name`, t.`status`, t.`category`, t.`ledger_times`, t.`ledger_status`, t.`measure_type`, t.`user_id`, t.`create_time`, t.`total_price`, t.`deal_tp`, t.`spid`,' +
|
|
|
' pa.`name` As `user_name`, pa.`role` As `user_role`, pa.`company` As `user_company` ' +
|
|
|
' FROM ?? As t ' +
|
|
|
' Left Join ?? As pa ' +
|
|
@@ -101,7 +101,7 @@ module.exports = app => {
|
|
|
sqlParam = [this.tableName, this.ctx.service.projectAccount.tableName, session.sessionProject.id, session.sessionUser.accountId];
|
|
|
} else if (getAll === 1 || (permission !== null && permission.tender !== undefined && permission.tender.indexOf('2') !== -1)) {
|
|
|
// 具有查看所有标段权限的用户查阅标段
|
|
|
- sql = 'SELECT t.`id`, t.`project_id`, t.`name`, t.`status`, t.`category`, t.`ledger_times`, t.`ledger_status`, t.`measure_type`, t.`user_id`, t.`create_time`, t.`total_price`, t.`deal_tp`,' +
|
|
|
+ sql = 'SELECT t.`id`, t.`project_id`, t.`name`, t.`status`, t.`category`, t.`ledger_times`, t.`ledger_status`, t.`measure_type`, t.`user_id`, t.`create_time`, t.`total_price`, t.`deal_tp`, t.`spid`,' +
|
|
|
' pa.`name` As `user_name`, pa.`role` As `user_role`, pa.`company` As `user_company` ' +
|
|
|
' FROM ?? As t ' +
|
|
|
' Left Join ?? As pa ' +
|
|
@@ -271,6 +271,7 @@ module.exports = app => {
|
|
|
create_time: new Date(),
|
|
|
category: JSON.stringify(data.category),
|
|
|
valuation: data.valuation,
|
|
|
+ spid: data.spid,
|
|
|
};
|
|
|
const operate = await this.transaction.insert(this.tableName, insertData);
|
|
|
|
|
@@ -279,6 +280,7 @@ module.exports = app => {
|
|
|
throw '新增标段数据失败';
|
|
|
}
|
|
|
await this.ctx.service.tenderCache.insertTenderCache(this.transaction, operate.insertId, sessionUser.accountId);
|
|
|
+ if (data.spid) await ctx.service.subProject.addRelaTender(this.transaction, data.spid, operate.insertId);
|
|
|
|
|
|
|
|
|
// 获取合同支付模板 并添加到标段
|
|
@@ -320,6 +322,7 @@ module.exports = app => {
|
|
|
*/
|
|
|
async save(postData, id = 0) {
|
|
|
id = parseInt(id);
|
|
|
+ const tender = await this.getDataById(id);
|
|
|
|
|
|
const rowData = {
|
|
|
id,
|
|
@@ -327,8 +330,20 @@ module.exports = app => {
|
|
|
type: postData.type,
|
|
|
category: JSON.stringify(postData.category),
|
|
|
};
|
|
|
- const result = await this.db.update(this.tableName, rowData);
|
|
|
- return result.affectedRows > 0;
|
|
|
+ const conn = await this.db.beginTransaction();
|
|
|
+ try {
|
|
|
+ if (tender.spid !== postData.spid) {
|
|
|
+ if (postData.spid) await this.ctx.service.subProject.addRelaTender(conn, postData.spid, id);
|
|
|
+ if (tender.spid) await this.ctx.service.subProject.removeRelaTender(conn, postData.spid, id);
|
|
|
+ }
|
|
|
+ rowData.spid = postData.spid || '';
|
|
|
+ const result = await conn.update(this.tableName, rowData);
|
|
|
+ await conn.commit();
|
|
|
+ return result.affectedRows > 0;
|
|
|
+ } catch(err) {
|
|
|
+ await conn.rollback();
|
|
|
+ throw err;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|