|
@@ -12,6 +12,7 @@ const moment = require('moment');
|
|
|
const audit = require('../const/audit');
|
|
|
const codeRuleConst = require('../const/code_rule');
|
|
|
const changeConst = require('../const/change');
|
|
|
+const tenderMenu = require('../../config/menu').tenderMenu;
|
|
|
|
|
|
module.exports = app => {
|
|
|
class ChangeController extends app.BaseController {
|
|
@@ -28,19 +29,38 @@ module.exports = app => {
|
|
|
ctx.showTitle = true;
|
|
|
}
|
|
|
|
|
|
- async _filterChanges(ctx, status) {
|
|
|
+ async _filterChanges(ctx, status = 0) {
|
|
|
const tenderId = ctx.params.id;
|
|
|
+ ctx.session.sessionUser.tenderId = tenderId;
|
|
|
const tender = await this.service.tender.getDataById(tenderId);
|
|
|
const tenderList = await this.service.tender.getList();
|
|
|
|
|
|
- const changes = await ctx.service.change.checkingDatas(tender.id, ctx.session.sessionUser.accountId);
|
|
|
+ const page = ctx.page;
|
|
|
+ const changes = await ctx.service.change.getListByStatus(tender.id, status);
|
|
|
+ const total = await ctx.service.change.getCountByStatus(tender.id, status);
|
|
|
+ if (changes !== null) {
|
|
|
+ let i = 0;
|
|
|
+ for(let c of changes) {
|
|
|
+ const changeAudit = await ctx.service.changeAudit.getLastUser(c.cid, c.times);
|
|
|
+ changes[i].changeAudit = changeAudit;
|
|
|
+ i++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 分页相关
|
|
|
+ const pageInfo = {
|
|
|
+ page,
|
|
|
+ total: parseInt(total / app.config.pageSize),
|
|
|
+ queryData: JSON.stringify(ctx.urlInfo.query),
|
|
|
+ };
|
|
|
+
|
|
|
const filter = JSON.parse(JSON.stringify(audit.filter));
|
|
|
filter.count = [];
|
|
|
- filter.count[filter.status.pending] = 4;// await ctx.service.change.pendingDatas(tender.id, ctx.session.sessionUser.accountId);
|
|
|
- filter.count[filter.status.uncheck] = 4;// await ctx.service.change.checkingDatas(tender.id, ctx.session.sessionUser.accountId);
|
|
|
- filter.count[filter.status.checking] = 4;// await ctx.service.change.checkedDatas(tender.id, ctx.session.sessionUser.accountId);
|
|
|
- filter.count[filter.status.checked] = 4;// await ctx.service.change.pendingDatas(tender.id, ctx.session.sessionUser.accountId);
|
|
|
- filter.count[filter.status.checkNo] = 4;//await ctx.service.change.pendingDatas(tender.id, ctx.session.sessionUser.accountId);
|
|
|
+ filter.count[filter.status.pending] = await ctx.service.change.getCountByStatus(tender.id, filter.status.pending);// await ctx.service.change.pendingDatas(tender.id, ctx.session.sessionUser.accountId);
|
|
|
+ filter.count[filter.status.uncheck] = await ctx.service.change.getCountByStatus(tender.id, filter.status.uncheck);// await ctx.service.change.checkingDatas(tender.id, ctx.session.sessionUser.accountId);
|
|
|
+ filter.count[filter.status.checking] = await ctx.service.change.getCountByStatus(tender.id, filter.status.checking);// await ctx.service.change.checkedDatas(tender.id, ctx.session.sessionUser.accountId);
|
|
|
+ filter.count[filter.status.checked] = await ctx.service.change.getCountByStatus(tender.id, filter.status.checked);// await ctx.service.change.pendingDatas(tender.id, ctx.session.sessionUser.accountId);
|
|
|
+ filter.count[filter.status.checkNo] = await ctx.service.change.getCountByStatus(tender.id, filter.status.checkNo);//await ctx.service.change.pendingDatas(tender.id, ctx.session.sessionUser.accountId);
|
|
|
|
|
|
const codeRule = tender.c_rule ? JSON.parse(tender.c_rule) : [];
|
|
|
for (const rule of codeRule) {
|
|
@@ -60,10 +80,13 @@ module.exports = app => {
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
const renderData = {
|
|
|
+ uid: ctx.session.sessionUser.accountId,
|
|
|
moment,
|
|
|
tender,
|
|
|
tenderList,
|
|
|
+ pageInfo,
|
|
|
changes,
|
|
|
filter,
|
|
|
status: status,
|
|
@@ -71,6 +94,8 @@ module.exports = app => {
|
|
|
auditConst: audit.flow,
|
|
|
ruleType: codeRuleConst.ruleType.change,
|
|
|
ruleConst: codeRuleConst.measure,
|
|
|
+ tenderMenu: this.menu.tenderMenu,
|
|
|
+ preUrl: '/tender/' + tenderId,
|
|
|
};
|
|
|
|
|
|
await this.layout('change/index.ejs', renderData, 'change/modal.ejs');
|
|
@@ -84,7 +109,7 @@ module.exports = app => {
|
|
|
*/
|
|
|
async index(ctx) {
|
|
|
try {
|
|
|
- await this._filterChanges(ctx, audit.filter.status.uncheck);
|
|
|
+ await this._filterChanges(ctx);
|
|
|
} catch (err) {
|
|
|
this.log(err);
|
|
|
ctx.redirect('/dashboard');
|
|
@@ -176,7 +201,7 @@ module.exports = app => {
|
|
|
await this._filterChanges(ctx, status);
|
|
|
} catch (err) {
|
|
|
this.logger.error(err);
|
|
|
- ctx.redirect('/change');
|
|
|
+ ctx.redirect('/tender/'+ ctx.params.id +'/change');
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -188,20 +213,29 @@ module.exports = app => {
|
|
|
*/
|
|
|
async info(ctx) {
|
|
|
try {
|
|
|
- const tender = ctx.tenderData;
|
|
|
- const tenderList = ctx.tenderList;
|
|
|
+ const tid = ctx.session.sessionUser.tenderId !== undefined ? ctx.session.sessionUser.tenderId : ctx.params.id;
|
|
|
+ const tender = await this.service.tender.getDataById(tid);
|
|
|
const change = await ctx.service.change.getDataByCondition({cid: ctx.params.cid});
|
|
|
|
|
|
+ // 后台判断当前人查看info状态
|
|
|
+ const auditStatus = await ctx.service.changeAudit.getStatusByChange(change);
|
|
|
+
|
|
|
+ // 获取公司列表
|
|
|
+ const companyList = await ctx.service.changeCompany.getAllDataByCondition({ tid: tid });
|
|
|
+
|
|
|
const renderData = {
|
|
|
+ uid: ctx.session.sessionUser.accountId,
|
|
|
tender,
|
|
|
- tenderList,
|
|
|
change,
|
|
|
changeConst,
|
|
|
+ auditStatus,
|
|
|
+ auditConst: audit.flow,
|
|
|
+ companyList,
|
|
|
};
|
|
|
- await this.layout('change/info.ejs', renderData);
|
|
|
+ await this.layout('change/info.ejs', renderData, 'change/info_modal.ejs');
|
|
|
} catch (err) {
|
|
|
this.log(err);
|
|
|
- ctx.redirect('/change');
|
|
|
+ ctx.redirect('/tender/'+ ctx.params.id +'/change');
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -222,7 +256,7 @@ module.exports = app => {
|
|
|
tenderList,
|
|
|
change,
|
|
|
};
|
|
|
- await this.layout('change/bills.ejs', renderData, 'change/bills_modal.ejs');
|
|
|
+ await this.layout('change/bills.ejs', renderData, 'change/info_modal.ejs');
|
|
|
|
|
|
} catch (err) {
|
|
|
this.log(err);
|
|
@@ -254,6 +288,32 @@ module.exports = app => {
|
|
|
ctx.redirect('/change');
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 变更公司管理
|
|
|
+ * @param ctx
|
|
|
+ * @return {Promise.<void>}
|
|
|
+ */
|
|
|
+ async updateCompany(ctx) {
|
|
|
+ const responseData = {
|
|
|
+ err: 0,
|
|
|
+ msg: '',
|
|
|
+ data: '',
|
|
|
+ };
|
|
|
+ try {
|
|
|
+ const data = JSON.parse(ctx.request.body.data);
|
|
|
+ if (data.tid === undefined || data.uci === undefined || data.uc === undefined || data.ac === undefined) {
|
|
|
+ throw '参数有误';
|
|
|
+ }
|
|
|
+ const [addCompany, selectCompany] = await ctx.service.changeCompany.setCompanyList(data);
|
|
|
+ responseData.data = { add: addCompany, select: selectCompany };
|
|
|
+ } catch (err) {
|
|
|
+ responseData.err = 1;
|
|
|
+ responseData.msg = err;
|
|
|
+ }
|
|
|
+
|
|
|
+ ctx.body = responseData;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
return ChangeController;
|