Browse Source

分类获取标段列表个数bug问题

laiguoran 4 years ago
parent
commit
67726c44d9

+ 2 - 2
app/controller/change_controller.js

@@ -37,7 +37,7 @@ module.exports = app => {
             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 tenderList = await this.service.tender.getList();
 
             const page = ctx.page;
             const changes = await ctx.service.change.getListByStatus(tender.id, status);
@@ -122,7 +122,7 @@ module.exports = app => {
                 uid: ctx.session.sessionUser.accountId,
                 moment,
                 tender,
-                tenderList,
+                // tenderList,
                 pageInfo,
                 changes,
                 filter,

+ 2 - 2
app/controller/setting_controller.js

@@ -393,7 +393,7 @@ module.exports = app => {
                 }
 
                 const categoryData = await ctx.service.category.getAllCategory(projectId);
-                const tenderData = await ctx.service.tender.getList();
+                const tenderData = await ctx.service.tender.getList('', null, 1);
                 const renderData = {
                     projectData,
                     categoryType: settingConst.cType,
@@ -480,7 +480,7 @@ module.exports = app => {
                 await ctx.service.categoryValue.setCategoryValue(data.id, data.updateValue);
 
                 responseData.data.category = await ctx.service.category.getCategory(data.id);
-                responseData.data.tenders = await ctx.service.tender.getList();
+                responseData.data.tenders = await ctx.service.tender.getList('', null, 1);
 
                 ctx.body = responseData;
             } catch (err) {

+ 3 - 3
app/service/category.js

@@ -89,7 +89,7 @@ module.exports = app => {
         async deleteCategory(pid, cid) {
             const category = await this.getDataById(cid);
             if (category.pid !== pid) {
-                throw '提交数据错误'
+                throw '提交数据错误';
             }
             this.transaction = await this.db.beginTransaction();
             try {
@@ -98,7 +98,7 @@ module.exports = app => {
                     await this._upLevelCategory(pid, category.level);
                 }
                 // 删除标段分类数据
-                const tenders = await this.ctx.service.tender.getList();
+                const tenders = await this.ctx.service.tender.getList('', null, 1);
                 for (const t of tenders) {
                     if (t.category && t.category.length > 0) {
                         this._.remove(t.category, function (c) {
@@ -171,4 +171,4 @@ module.exports = app => {
     }
 
     return Category;
-};
+};

+ 2 - 2
app/service/category_value.js

@@ -65,7 +65,7 @@ module.exports = app => {
         }
 
         async setCategoryValue(cid, value) {
-            const tenders = await this.ctx.service.tender.getList();
+            const tenders = await this.ctx.service.tender.getList('', null, 1);
 
             this.transaction = await this.db.beginTransaction();
             try {
@@ -107,4 +107,4 @@ module.exports = app => {
     }
 
     return CategoryValue;
-};
+};

+ 5 - 2
app/service/tender.js

@@ -75,9 +75,12 @@ module.exports = app => {
         /**
          * 获取你所参与的标段的列表
          *
+         * @param {String} listStatus - 取列表状态,如果是管理页要传
+         * @param {String} permission - 根据权限取值
+         * @param {Number} getAll - 是否取所有标段
          * @return {Array} - 返回标段数据
          */
-        async getList(listStatus = '', permission = null) {
+        async getList(listStatus = '', permission = null, getAll = 0) {
             // 获取当前项目信息
             const session = this.ctx.session;
             let sql = '';
@@ -91,7 +94,7 @@ module.exports = app => {
                     '  ON t.`user_id` = pa.`id` ' +
                     '  WHERE t.`project_id` = ? AND t.`user_id` = ? ORDER BY CONVERT(t.`name` USING GBK) ASC';
                 sqlParam = [this.tableName, this.ctx.service.projectAccount.tableName, session.sessionProject.id, session.sessionUser.accountId];
-            } else if (permission !== null && permission.tender !== undefined && permission.tender.indexOf('2') !== -1) {
+            } 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`,' +
                     '    pa.`name` As `user_name`, pa.`role` As `user_role`, pa.`company` As `user_company` ' +