瀏覽代碼

修复切换清空bug

ellisran 10 月之前
父節點
當前提交
f5b32f7d9c
共有 3 個文件被更改,包括 21 次插入23 次删除
  1. 1 1
      app/controller/change_controller.js
  2. 1 4
      app/public/js/change_information_set.js
  3. 19 18
      app/service/change.js

+ 1 - 1
app/controller/change_controller.js

@@ -685,7 +685,7 @@ module.exports = app => {
                         await ctx.service.change.saveInfo(data.updateData);
                         break;
                     case 'order_by':
-                        const result = await ctx.service.change.saveOrderBy(data.updateData, data.newLedgerList);
+                        const result = await ctx.service.change.saveOrderBy(data.updateData);
                         responseData.data = result;
                         break;
                     case 'order_site':

+ 1 - 4
app/public/js/change_information_set.js

@@ -1009,9 +1009,7 @@ $(document).ready(() => {
         // 按台账去重新排序changeList,空白清单居后
         if (!changeOrder) {
             const sycList = _.difference(changeList, newChangeList);
-            console.log(sycList);
             changeList = newChangeList.concat(sycList);
-            console.log(changeList);
             // order如果不同,则修改并提交
             const updateOrderList = [];
             for (let i = 0; i < changeList.length; i++) {
@@ -1992,9 +1990,8 @@ $(document).ready(() => {
     $('.dropdown-menu input[name="paixu"]').on('click', function () {
         const newChangeOrder = parseInt($(this).val());
         if (newChangeOrder !== changeOrder) {
-            const newLedgerList = changeOrder ? remakeChangeSpread(0) : [];
             // 更新至服务器
-            postData(window.location.pathname + '/save', { type:'order_by', updateData: newChangeOrder, newLedgerList }, function (result) {
+            postData(window.location.pathname + '/save', { type:'order_by', updateData: newChangeOrder }, function (result) {
                 if (newChangeOrder === 0) {
                     $('#bpaixu').text('清单排序:清单编号');
                     $('#upAndMoveBtn').attr('style', 'display: none !important');

+ 19 - 18
app/service/change.js

@@ -840,34 +840,35 @@ module.exports = app => {
          * @param {int} order_by - 表单提交的数据
          * @return {void}
          */
-        async saveOrderBy(order_by, newLedgerList = []) {
+        async saveOrderBy(order_by) {
             const transaction = await this.db.beginTransaction();
             let result = [];
             try {
                 const postData = { order_by };
-                let changeList = await this.ctx.service.changeAuditList.getList(this.ctx.change.cid);
-                if (order_by) {
-                    let i = 1;
-                    const updateArray = [];
-                    for (const cl of changeList) {
-                        updateArray.push({
-                            id: cl.id,
-                            order: i,
-                        });
-                        cl.order = i;
-                        i++;
-                    }
-                    if (updateArray.length > 0) await transaction.updateRows(this.ctx.service.changeAuditList.tableName, updateArray);
-                } else {
-                    await this.ctx.service.changeAuditList.saveLedgerListDatas(newLedgerList, null, order_by);
-                    changeList = await this.ctx.service.changeAuditList.getList(this.ctx.change.cid, order_by);
-                }
+                // let changeList = await this.ctx.service.changeAuditList.getList(this.ctx.change.cid);
+                // if (order_by) {
+                //     let i = 1;
+                //     const updateArray = [];
+                //     for (const cl of changeList) {
+                //         updateArray.push({
+                //             id: cl.id,
+                //             order: i,
+                //         });
+                //         cl.order = i;
+                //         i++;
+                //     }
+                //     if (updateArray.length > 0) await transaction.updateRows(this.ctx.service.changeAuditList.tableName, updateArray);
+                // } else {
+                //     // await this.ctx.service.changeAuditList.saveLedgerListDatas(newLedgerList, null, order_by);
+                //     changeList = await this.ctx.service.changeAuditList.getList(this.ctx.change.cid);
+                // }
                 const options = {
                     where: {
                         cid: this.ctx.change.cid,
                     },
                 };
                 await transaction.update(this.tableName, postData, options);
+                const changeList = await this.ctx.service.changeAuditList.getList(this.ctx.change.cid, order_by);
                 await transaction.commit();
                 result = { changeList,
                     usedList: await this.ctx.service.stageChange.getAllFinalUsedData(this.ctx.tender.id, this.ctx.change.cid) };