|
|
@@ -6,6 +6,7 @@ const advanceConst = require('../const/advance');
|
|
|
const shenpiConst = require('../const/shenpi');
|
|
|
const stdConst = require('../const/standard');
|
|
|
const _ = require('lodash');
|
|
|
+const PinYinOrder = require('../public/js/PinYinOrder.bundle');
|
|
|
|
|
|
module.exports = app => {
|
|
|
class WeappTenderController extends app.BaseController {
|
|
|
@@ -19,8 +20,24 @@ module.exports = app => {
|
|
|
const accountInfo = ctx.session.sessionUser;
|
|
|
const userPermission = accountInfo !== undefined && accountInfo.permission !== '' ? JSON.parse(accountInfo.permission) : null;
|
|
|
if (userPermission !== null && userPermission.tender !== undefined && userPermission.tender.indexOf('1') !== -1) {
|
|
|
+ const buildStatus = ctx.query.buildStatus;
|
|
|
+ if (buildStatus !== undefined && buildStatus !== '1' && buildStatus !== '2') {
|
|
|
+ throw '标段建设状态参数错误';
|
|
|
+ }
|
|
|
const subProject = await this.ctx.service.subProject.getDataById(projectId);
|
|
|
- const tenderList = await this.ctx.service.tender.getList('', userPermission, ctx.session.sessionUser.is_admin, '', subProject);
|
|
|
+ if (!subProject) throw '项目不存在';
|
|
|
+ if (subProject.project_id !== ctx.session.sessionProject.id) throw '您无权查看该项目';
|
|
|
+ // 与网页端 subProjectCheck 使用相同的个人分类和页面配置。
|
|
|
+ const subProjectPermission = accountInfo.is_admin
|
|
|
+ ? ctx.service.subProjPermission.adminPermission
|
|
|
+ : await ctx.service.subProjPermission.getSubProjectUserPermission(projectId, accountInfo.accountId);
|
|
|
+ if (!subProjectPermission) throw '您无权查看该项目';
|
|
|
+ subProject.page_show = ctx.service.subProject.getPageShow(subProject.page_show);
|
|
|
+ const buildStatusFilter = buildStatus === undefined ? '' : app.mysql.format(' AND t.build_status = ?', [Number(buildStatus)]);
|
|
|
+ const tenderList = await this.ctx.service.tender.getList('', userPermission, accountInfo.is_admin, buildStatusFilter, subProject);
|
|
|
+ // 复用网页的名称比较器,保持默认拼音排序一致。
|
|
|
+ const nameOrder = new PinYinOrder();
|
|
|
+ tenderList.sort((a, b) => nameOrder.compareWord(a.name, b.name));
|
|
|
for (const tender of tenderList) {
|
|
|
// 查询当前审批期以及状态
|
|
|
const stage = await this.ctx.service.stage.getLastestStage(tender.id, true);
|
|
|
@@ -31,6 +48,7 @@ module.exports = app => {
|
|
|
const renderData = {
|
|
|
categoryData,
|
|
|
tenderList,
|
|
|
+ selfCategoryLevel: subProjectPermission.self_category_level || '',
|
|
|
};
|
|
|
ctx.body = { err: 0, msg: '', data: renderData };
|
|
|
} else {
|