laiguoran 4 роки тому
батько
коміт
7b54ecc3da
2 змінених файлів з 14 додано та 16 видалено
  1. 4 16
      app/controller/change_controller.js
  2. 10 0
      app/service/change_audit_list.js

+ 4 - 16
app/controller/change_controller.js

@@ -545,10 +545,7 @@ module.exports = app => {
                 // 根据auditStatus获取审批人列表
                 const auditList = await ctx.service.changeAudit.getListByStatus(change, auditStatus);
                 // 获取已选清单
-                let changeList = await ctx.service.changeAuditList.getAllDataByCondition({
-                    where: { cid: change.cid },
-                    orders: [['lid', 'desc'], ['id', 'asc']],
-                });
+                let changeList = await ctx.service.changeAuditList.getList(change.cid);
 
                 // 获取用户人验证手机号
                 const pa = await ctx.service.projectAccount.getDataById(ctx.session.sessionUser.accountId);
@@ -734,18 +731,12 @@ module.exports = app => {
                     case 'paste':
                         await ctx.service.changeAuditList.saveDatas(data.updateData);
                         // 取所有工料表
-                        responseData.data = await ctx.service.changeAuditList.getAllDataByCondition({
-                            where: { cid: ctx.change.cid },
-                            orders: [['lid', 'desc'], ['id', 'asc']],
-                        });
+                        responseData.data = await ctx.service.changeAuditList.getList(ctx.change.cid);
                         break;
                     case 'ledger_list':
                         await ctx.service.changeAuditList.saveLedgerListDatas(data.updateData);
                         // 取所有工料表
-                        responseData.data = await ctx.service.changeAuditList.getAllDataByCondition({
-                            where: { cid: ctx.change.cid },
-                            orders: [['lid', 'desc'], ['id', 'asc']],
-                        });
+                        responseData.data = await ctx.service.changeAuditList.getList(ctx.change.cid);
                         break;
                     case 'info':
                         await ctx.service.change.saveInfo(data.updateData);
@@ -754,10 +745,7 @@ module.exports = app => {
                         break;
                     case 'paste_amount_rows':
                         await ctx.service.changeAuditList.saveDatas(data.updateData);
-                        let changeList = await ctx.service.changeAuditList.getAllDataByCondition({
-                            where: { cid: ctx.change.cid },
-                            orders: [['lid', 'desc'], ['id', 'asc']],
-                        });
+                        let changeList = await ctx.service.changeAuditList.getList(ctx.change.cid);
                         const auditList2 = await ctx.service.changeAudit.getListGroupByTimes(ctx.change.cid, ctx.change.times);
                         changeList = JSON.parse(JSON.stringify(changeList.sort())).sort().sort();
                         for (const cl of changeList) {

+ 10 - 0
app/service/change_audit_list.js

@@ -24,6 +24,16 @@ module.exports = app => {
         }
 
         /**
+         * 取出变更令清单列表,并按台账清单在前,空白清单在后排序
+         * @return {void}
+         */
+        async getList(cid) {
+            const sql = 'SELECT * FROM ?? WHERE `cid` = ? ORDER BY `lid` = 0, `id` asc';
+            const sqlParam = [this.tableName, cid];
+            return await this.db.query(sql, sqlParam);
+        }
+
+        /**
          * 添加空白变更清单
          * @return {void}
          */