Browse Source

合同支付,复制粘贴遗漏

MaiXinRong 6 years ago
parent
commit
8b50b0ffbf
3 changed files with 20 additions and 9 deletions
  1. 5 1
      app/controller/stage_controller.js
  2. 8 6
      app/public/js/stage_pay.js
  3. 7 2
      app/service/stage_pay.js

+ 5 - 1
app/controller/stage_controller.js

@@ -473,7 +473,11 @@ module.exports = app => {
                             responseData.data = await ctx.service.stagePay.getStagePays(ctx.stage);
                             await payCalculator.calculateAll(responseData.data);
                         } else {
-                            responseData.data = await ctx.service.stagePay.getStagePay(ctx.stage, responseData.data.id);
+                            if (data.updateData instanceof Array) {
+                                responseData.data = await ctx.service.stagePay.getStagePay(ctx.stage, this.app._.map(responseData.data, 'id'));
+                            } else {
+                                responseData.data = await ctx.service.stagePay.getStagePay(ctx.stage, responseData.data.id);
+                            }
                         }
                         break;
                     case 'stage':

+ 8 - 6
app/public/js/stage_pay.js

@@ -16,12 +16,14 @@ function getStageId() {
     return window.location.pathname.split('/')[5];
 }
 
-function loadUpdateDealPays(newPay) {
+function loadUpdateDealPays(newPay, fields) {
     const newPays = newPay instanceof Array ? newPay : [newPay];
     for (const np of newPays) {
         const op = _.find(dealPay, {id: np.id});
         for (const prop in np) {
-            op[prop] = np[prop];
+            if (!fields || fields.indexOf(prop) >= 0) {
+                op[prop] = np[prop];
+            }
         }
     }
 }
@@ -278,7 +280,7 @@ $(document).ready(() => {
                 }
                 // 更新至服务器
                 postData(window.location.pathname + '/save', data, function (result) {
-                    loadUpdateDealPays(result);
+                    loadUpdateDealPays(result, col.field === 'name' ? ['name'] : null);
                     SpreadJsObj.reLoadSheetData(paySpread.getActiveSheet());
                 });
             }
@@ -368,7 +370,7 @@ $(document).ready(() => {
                         data.updateData = data.updateData[0];
                     }
                     postData(window.location.pathname + '/save', data, function (result) {
-                        loadUpdateDealPays(result);
+                        loadUpdateDealPays(result, col.field === 'name' ? ['name'] : null);
                         SpreadJsObj.reLoadSheetData(paySpread.getActiveSheet());
                     })
                 }
@@ -382,7 +384,7 @@ $(document).ready(() => {
                     return;
                 }
                 if (info.cellRange.colCount > 1) {
-                    toast('请勿同时删除多列数据', 'warning');
+                    toast('请勿同时复制粘贴多列数据', 'warning');
                 }
 
                 const sortData = info.sheet.zh_data;
@@ -415,7 +417,7 @@ $(document).ready(() => {
                     }
                     if (data.updateData.length > 0) {
                         postData(window.location.pathname + '/save', data, function (result) {
-                            loadUpdateDealPays(result);
+                            loadUpdateDealPays(result, col.field === 'name' ? ['name'] : null);
                             SpreadJsObj.reLoadSheetData(paySpread.getActiveSheet());
                         }, function () {
                             SpreadJsObj.reLoadSheetData(paySpread.getActiveSheet());

+ 7 - 2
app/service/stage_pay.js

@@ -34,12 +34,17 @@ module.exports = app => {
          * @returns {Promise<*>}
          */
         async getAuditorStagePay(pid, sid, times, order) {
+            const pidSql = pid instanceof Array ? ' And SP.`pid` in (' + pid.join(',') + ')' : 'And SP.`pid` = ' + pid;
             const sql = 'SELECT SP.*, P.`csorder`, P.`cstimes`, P.`csaorder`, P.`order`, P.uid, P.name, P.minus, P.ptype, P.sprice, P.sexpr, P.rprice, P.rexpr, P.is_yf, P.dl_type, P.dl_count, P.dl_tp_type, P.dl_tp ' +
                 '  FROM ?? As SP, ?? As P ' +
-                '  WHERE SP.`sid` = ? AND SP.`stimes` = ? AND SP.`sorder` = ? AND SP.`pid` = P.`id` AND SP.`pid` = ? AND P.`valid`' +
+                '  WHERE SP.`sid` = ? AND SP.`stimes` = ? AND SP.`sorder` = ? AND SP.`pid` = P.`id` AND P.`valid`' + pidSql +
                 '  ORDER BY P.`order`';
             const sqlParam = [this.tableName, this.ctx.service.pay.tableName, sid, times, order, pid];
-            return await this.db.queryOne(sql, sqlParam);
+            if (pid instanceof Array) {
+                return await this.db.query(sql, sqlParam);
+            } else {
+                return await this.db.queryOne(sql, sqlParam);
+            }
         }
 
         /**