|
@@ -40,6 +40,7 @@ module.exports = app => {
|
|
|
continue;
|
|
|
}
|
|
|
l.name = accountInfo.name;
|
|
|
+ l.company = accountInfo.company;
|
|
|
}
|
|
|
if (removeList.length > 0) {
|
|
|
for (const r of removeList) {
|
|
@@ -89,8 +90,53 @@ module.exports = app => {
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
- async delAudit(id) {
|
|
|
- return await this.db.delete(this.tableName, { id });
|
|
|
+ async delAudits(spid, tid, datas) {
|
|
|
+ // return await this.db.delete(this.tableName, { id });
|
|
|
+ // 需要同时移除审批流程里的人
|
|
|
+ const reponseData = {};
|
|
|
+ const transaction = await this.db.beginTransaction();
|
|
|
+ try {
|
|
|
+ await transaction.delete(this.tableName, { id: this._.map(datas, 'id') });
|
|
|
+ const shenpiAudits = await this.ctx.service.shenpiAudit.getAuditList(tid, shenpiConst.sp_other_type.financial, shenpiConst.sp_status.gdspl);
|
|
|
+ const uids = this._.map(datas, 'uid');
|
|
|
+ const removeData = [];
|
|
|
+ for (const sp of shenpiAudits) {
|
|
|
+ if (this._.includes(uids, sp.audit_id)) {
|
|
|
+ removeData.push(sp.id);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (removeData.length > 0) {
|
|
|
+ await transaction.delete(this.ctx.service.shenpiAudit.tableName, { id: removeData });
|
|
|
+ // 重新分配order值
|
|
|
+ const newSpAudits = await transaction.select(this.ctx.service.shenpiAudit.tableName, { where: { tid, sp_type: shenpiConst.sp_other_type.financial, sp_status: shenpiConst.sp_status.gdspl }, orders: [['audit_order', 'asc'], ['id', 'asc']] });
|
|
|
+ // groupby audit_order
|
|
|
+ const newSpAuditsGroup = this._.groupBy(newSpAudits, 'audit_order');
|
|
|
+ const updateData = [];
|
|
|
+ let order = 1;
|
|
|
+ for (const a in newSpAuditsGroup) {
|
|
|
+ const sameOrderAudits = newSpAuditsGroup[a];
|
|
|
+ for (const sa of sameOrderAudits) {
|
|
|
+ if (sa.audit_order !== order) {
|
|
|
+ updateData.push({
|
|
|
+ id: sa.id,
|
|
|
+ audit_order: order,
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ order++;
|
|
|
+ }
|
|
|
+ if (updateData.length > 0) {
|
|
|
+ await transaction.updateRows(this.ctx.service.shenpiAudit.tableName, updateData);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ await transaction.commit();
|
|
|
+ reponseData.permissionList = await this.getList(spid, tid);
|
|
|
+ reponseData.auditGroupList = await this.ctx.service.shenpiAudit.getAuditGroupList(tid, shenpiConst.sp_other_type.financial, shenpiConst.sp_status.gdspl);
|
|
|
+ } catch (error) {
|
|
|
+ console.log(error);
|
|
|
+ await transaction.rollback();
|
|
|
+ }
|
|
|
+ return reponseData;
|
|
|
}
|
|
|
|
|
|
async updatePermission(updateData) {
|
|
@@ -108,11 +154,17 @@ module.exports = app => {
|
|
|
const transaction = await this.db.beginTransaction();
|
|
|
try {
|
|
|
// 判断是否存在并加入到成员表中
|
|
|
+ const fptAudit = await this.getDataByCondition({ spid, tid, uid: data.audit_id });
|
|
|
+ if (!fptAudit) {
|
|
|
+ await transaction.insert(this.tableName, { spid, tid, uid: data.audit_id, create_time: new Date() });
|
|
|
+ }
|
|
|
+ // 判断是否存在并加入到成员表中
|
|
|
const fAudit = await this.ctx.service.financialAudit.getDataByCondition({ spid, uid: data.audit_id });
|
|
|
if (!fAudit) {
|
|
|
await transaction.insert(this.ctx.service.financialAudit.tableName, { spid, uid: data.audit_id, create_time: new Date() });
|
|
|
}
|
|
|
await transaction.commit();
|
|
|
+ reponseData.permissionList = await this.getList(spid, tid);
|
|
|
} catch (error) {
|
|
|
console.log(error);
|
|
|
await transaction.rollback();
|
|
@@ -121,14 +173,14 @@ module.exports = app => {
|
|
|
return reponseData;
|
|
|
}
|
|
|
|
|
|
- async copyAudit2otherTender(spid, data, tid) {
|
|
|
+ async copyShenpi2otherTender(spid, data, tid) {
|
|
|
const reponseData = {};
|
|
|
const info = await this.ctx.service.shenpiAudit.copyAudit2otherTender(data, tid);
|
|
|
if (info) {
|
|
|
const transaction = await this.db.beginTransaction();
|
|
|
try {
|
|
|
- const permissionList = await this.getAllDataByCondition({ where: { spid, tid } });
|
|
|
- const uidList = this._.map(permissionList, 'uid');
|
|
|
+ // const permissionList = await this.getAllDataByCondition({ where: { spid, tid } });
|
|
|
+ const uidList = this._.map(data.auditList, 'audit_id');
|
|
|
const tidList = data.tidList.split(',');
|
|
|
if (tidList.length === 0) {
|
|
|
throw '没有选择要复制的标段';
|
|
@@ -140,7 +192,10 @@ module.exports = app => {
|
|
|
const tenderAudits = await this.getAllDataByCondition({ where: { spid, tid: t } });
|
|
|
const diffList = this._.difference(uidList, this._.map(tenderAudits, 'uid'));
|
|
|
for (const d of diffList) {
|
|
|
- pushData.push({ spid, tid: t, uid: d, create_time: times });
|
|
|
+ pushData.push({
|
|
|
+ spid, tid: t, uid: d,
|
|
|
+ create_time: times,
|
|
|
+ });
|
|
|
}
|
|
|
}
|
|
|
if (pushData.length > 0) await transaction.insert(this.tableName, pushData);
|
|
@@ -154,6 +209,48 @@ module.exports = app => {
|
|
|
}
|
|
|
return reponseData;
|
|
|
}
|
|
|
+
|
|
|
+ async copyAudit2otherTender(spid, data, tid) {
|
|
|
+ const reponseData = {};
|
|
|
+ const transaction = await this.db.beginTransaction();
|
|
|
+ try {
|
|
|
+ const permissionList = await this.getAllDataByCondition({ where: { spid, tid } });
|
|
|
+ const uidList = this._.map(permissionList, 'uid');
|
|
|
+ const tidList = data.tidList.split(',');
|
|
|
+ if (tidList.length === 0) {
|
|
|
+ throw '没有选择要复制的标段';
|
|
|
+ }
|
|
|
+ if (uidList.length > 0) {
|
|
|
+ const pushData = [];
|
|
|
+ const updateData = [];
|
|
|
+ const times = new Date();
|
|
|
+ for (const t of tidList) {
|
|
|
+ const tenderAudits = await this.getAllDataByCondition({ where: { spid, tid: t } });
|
|
|
+ const diffList = this._.difference(uidList, this._.map(tenderAudits, 'uid'));
|
|
|
+ for (const d of diffList) {
|
|
|
+ const p = permissionList.find(item => item.uid === d);
|
|
|
+ pushData.push({ spid, tid: t, uid: p.uid, is_report: p.is_report, create_time: times });
|
|
|
+ }
|
|
|
+ const sameList = this._.intersection(this._.map(tenderAudits, 'uid'), uidList);
|
|
|
+ for (const s of sameList) {
|
|
|
+ const p = permissionList.find(item => item.uid === s);
|
|
|
+ const t = tenderAudits.find(item => item.uid === s);
|
|
|
+ if (p.is_report !== t.is_report) {
|
|
|
+ updateData.push({ id: t.id, is_report: p.is_report });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (pushData.length > 0) await transaction.insert(this.tableName, pushData);
|
|
|
+ if (updateData.length > 0) await transaction.updateRows(this.tableName, updateData);
|
|
|
+ }
|
|
|
+ await transaction.commit();
|
|
|
+ reponseData.otherPermissionList = await this.getList(spid, tidList);
|
|
|
+ } catch (error) {
|
|
|
+ console.log(error);
|
|
|
+ await transaction.rollback();
|
|
|
+ }
|
|
|
+ return reponseData;
|
|
|
+ }
|
|
|
}
|
|
|
return FinancialPayTenderAudit;
|
|
|
};
|