ls-pro-common 3.1.16 → 3.1.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -70,62 +70,89 @@ function useDtl(dtlParam) {
70
70
  if (!auditStatus || !statusField) return false;
71
71
  return Number(masterObject[statusField] || 0) >= auditStatus;
72
72
  }, [auditStatus, statusField, masterObject]);
73
+ /** @name 处理before函数 */
74
+ var handleBefore = /*#__PURE__*/function () {
75
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(beforeFn, arg, isDtl) {
76
+ var data;
77
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
78
+ while (1) switch (_context.prev = _context.next) {
79
+ case 0:
80
+ if (beforeFn) {
81
+ _context.next = 2;
82
+ break;
83
+ }
84
+ return _context.abrupt("return", arg);
85
+ case 2:
86
+ _context.next = 4;
87
+ return beforeFn(arg, isDtl);
88
+ case 4:
89
+ data = _context.sent;
90
+ if (!(data === true || data === undefined)) {
91
+ _context.next = 7;
92
+ break;
93
+ }
94
+ return _context.abrupt("return", arg);
95
+ case 7:
96
+ return _context.abrupt("return", data);
97
+ case 8:
98
+ case "end":
99
+ return _context.stop();
100
+ }
101
+ }, _callee);
102
+ }));
103
+ return function handleBefore(_x, _x2, _x3) {
104
+ return _ref.apply(this, arguments);
105
+ };
106
+ }();
73
107
  /** @name 保存主表 */
74
108
  var onSaveMst = /*#__PURE__*/function () {
75
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(values) {
109
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(values) {
76
110
  var _result$flag;
77
- var data, result;
78
- return _regeneratorRuntime.wrap(function _callee$(_context) {
79
- while (1) switch (_context.prev = _context.next) {
111
+ var obj, data, result;
112
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
113
+ while (1) switch (_context2.prev = _context2.next) {
80
114
  case 0:
81
115
  if (!isAudit()) {
82
- _context.next = 3;
116
+ _context2.next = 3;
83
117
  break;
84
118
  }
85
119
  showWarn('当前单据已审核,不能保存');
86
- return _context.abrupt("return", false);
120
+ return _context2.abrupt("return", false);
87
121
  case 3:
88
- data = _objectSpread(_objectSpread({}, masterObject), values);
89
- _context.t0 = beforeSave;
90
- if (!_context.t0) {
91
- _context.next = 10;
92
- break;
93
- }
94
- _context.next = 8;
95
- return beforeSave(data, false);
96
- case 8:
97
- _context.t1 = _context.sent;
98
- _context.t0 = _context.t1 === false;
99
- case 10:
100
- if (!_context.t0) {
101
- _context.next = 12;
122
+ obj = _objectSpread(_objectSpread({}, masterObject), values);
123
+ _context2.next = 6;
124
+ return handleBefore(beforeSave, obj, false);
125
+ case 6:
126
+ data = _context2.sent;
127
+ if (!(data === false)) {
128
+ _context2.next = 9;
102
129
  break;
103
130
  }
104
- return _context.abrupt("return", false);
105
- case 12:
106
- _context.next = 14;
131
+ return _context2.abrupt("return", false);
132
+ case 9:
133
+ _context2.next = 11;
107
134
  return mstService.save(data);
108
- case 14:
109
- result = _context.sent;
110
- _context.t2 = afterSave;
111
- if (!_context.t2) {
112
- _context.next = 21;
135
+ case 11:
136
+ result = _context2.sent;
137
+ _context2.t0 = afterSave;
138
+ if (!_context2.t0) {
139
+ _context2.next = 18;
113
140
  break;
114
141
  }
115
- _context.next = 19;
142
+ _context2.next = 16;
116
143
  return afterSave(result, data, false);
117
- case 19:
118
- _context.t3 = _context.sent;
119
- _context.t2 = _context.t3 === false;
120
- case 21:
121
- if (!_context.t2) {
122
- _context.next = 23;
144
+ case 16:
145
+ _context2.t1 = _context2.sent;
146
+ _context2.t0 = _context2.t1 === false;
147
+ case 18:
148
+ if (!_context2.t0) {
149
+ _context2.next = 20;
123
150
  break;
124
151
  }
125
- return _context.abrupt("return", false);
126
- case 23:
152
+ return _context2.abrupt("return", false);
153
+ case 20:
127
154
  if (!((result === null || result === void 0 ? void 0 : (_result$flag = result.flag) === null || _result$flag === void 0 ? void 0 : _result$flag.retCode) === '0')) {
128
- _context.next = 30;
155
+ _context2.next = 27;
129
156
  break;
130
157
  }
131
158
  showSuccess(result.flag.retMsg || '操作成功');
@@ -137,22 +164,22 @@ function useDtl(dtlParam) {
137
164
  masterObject.id = result.id;
138
165
  }
139
166
  setEditItem({});
140
- return _context.abrupt("return", true);
141
- case 30:
142
- return _context.abrupt("return", false);
143
- case 31:
167
+ return _context2.abrupt("return", true);
168
+ case 27:
169
+ return _context2.abrupt("return", false);
170
+ case 28:
144
171
  case "end":
145
- return _context.stop();
172
+ return _context2.stop();
146
173
  }
147
- }, _callee);
174
+ }, _callee2);
148
175
  }));
149
- return function onSaveMst(_x) {
150
- return _ref.apply(this, arguments);
176
+ return function onSaveMst(_x4) {
177
+ return _ref2.apply(this, arguments);
151
178
  };
152
179
  }();
153
180
  /** @name 主从一起保存 */
154
181
  var onSaveMstDtl = /*#__PURE__*/function () {
155
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
182
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
156
183
  var _formRef$current, _formRef$current$getF, _tableRef$current, _tableRef$current$get, _tableRef$current2, _tableRef$current2$ge, _result$flag2;
157
184
  var isDelete,
158
185
  values,
@@ -160,25 +187,26 @@ function useDtl(dtlParam) {
160
187
  dtlEditData,
161
188
  dtlData,
162
189
  param,
190
+ data,
163
191
  result,
164
- _args2 = arguments;
165
- return _regeneratorRuntime.wrap(function _callee2$(_context2) {
166
- while (1) switch (_context2.prev = _context2.next) {
192
+ _args3 = arguments;
193
+ return _regeneratorRuntime.wrap(function _callee3$(_context3) {
194
+ while (1) switch (_context3.prev = _context3.next) {
167
195
  case 0:
168
- isDelete = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : false;
196
+ isDelete = _args3.length > 0 && _args3[0] !== undefined ? _args3[0] : false;
169
197
  if (!isAudit()) {
170
- _context2.next = 4;
198
+ _context3.next = 4;
171
199
  break;
172
200
  }
173
201
  showWarn('当前单据已审核,不能保存');
174
- return _context2.abrupt("return", false);
202
+ return _context3.abrupt("return", false);
175
203
  case 4:
176
204
  if (dtlParam.dtlName) {
177
- _context2.next = 7;
205
+ _context3.next = 7;
178
206
  break;
179
207
  }
180
208
  showWarn('useDtl未传入dtlName参数,不能主从一起保存');
181
- return _context2.abrupt("return");
209
+ return _context3.abrupt("return");
182
210
  case 7:
183
211
  values = (_formRef$current = formRef.current) === null || _formRef$current === void 0 ? void 0 : (_formRef$current$getF = _formRef$current.getFieldsFormatValue) === null || _formRef$current$getF === void 0 ? void 0 : _formRef$current$getF.call(_formRef$current);
184
212
  mst = _objectSpread(_objectSpread({}, masterObject), values);
@@ -212,256 +240,237 @@ function useDtl(dtlParam) {
212
240
  deleteRows: []
213
241
  };
214
242
  }
215
- _context2.t0 = beforeSave;
216
- if (!_context2.t0) {
217
- _context2.next = 19;
218
- break;
219
- }
220
- _context2.next = 17;
221
- return beforeSave(param, false);
222
- case 17:
223
- _context2.t1 = _context2.sent;
224
- _context2.t0 = _context2.t1 === false;
225
- case 19:
226
- if (!_context2.t0) {
227
- _context2.next = 21;
243
+ _context3.next = 15;
244
+ return handleBefore(beforeSave, param, false);
245
+ case 15:
246
+ data = _context3.sent;
247
+ if (!(data === false)) {
248
+ _context3.next = 18;
228
249
  break;
229
250
  }
230
- return _context2.abrupt("return", false);
231
- case 21:
232
- _context2.next = 23;
233
- return mstService.saveMstDtl(param);
234
- case 23:
235
- result = _context2.sent;
236
- _context2.t2 = afterSave;
237
- if (!_context2.t2) {
238
- _context2.next = 30;
251
+ return _context3.abrupt("return", false);
252
+ case 18:
253
+ _context3.next = 20;
254
+ return mstService.saveMstDtl(data);
255
+ case 20:
256
+ result = _context3.sent;
257
+ _context3.t0 = afterSave;
258
+ if (!_context3.t0) {
259
+ _context3.next = 27;
239
260
  break;
240
261
  }
241
- _context2.next = 28;
242
- return afterSave(result, param, false);
243
- case 28:
244
- _context2.t3 = _context2.sent;
245
- _context2.t2 = _context2.t3 === false;
246
- case 30:
247
- if (!_context2.t2) {
248
- _context2.next = 32;
262
+ _context3.next = 25;
263
+ return afterSave(result, data, false);
264
+ case 25:
265
+ _context3.t1 = _context3.sent;
266
+ _context3.t0 = _context3.t1 === false;
267
+ case 27:
268
+ if (!_context3.t0) {
269
+ _context3.next = 29;
249
270
  break;
250
271
  }
251
- return _context2.abrupt("return", false);
252
- case 32:
272
+ return _context3.abrupt("return", false);
273
+ case 29:
253
274
  if (!((result === null || result === void 0 ? void 0 : (_result$flag2 = result.flag) === null || _result$flag2 === void 0 ? void 0 : _result$flag2.retCode) === '0')) {
254
- _context2.next = 37;
275
+ _context3.next = 34;
255
276
  break;
256
277
  }
257
278
  showSuccess(result.flag.retMsg || '操作成功');
258
279
  Object.assign(masterObject, result.data);
259
280
  setEditItem({});
260
- return _context2.abrupt("return", true);
261
- case 37:
262
- return _context2.abrupt("return", false);
263
- case 38:
281
+ return _context3.abrupt("return", true);
282
+ case 34:
283
+ return _context3.abrupt("return", false);
284
+ case 35:
264
285
  case "end":
265
- return _context2.stop();
286
+ return _context3.stop();
266
287
  }
267
- }, _callee2);
288
+ }, _callee3);
268
289
  }));
269
290
  return function onSaveMstDtl() {
270
- return _ref2.apply(this, arguments);
291
+ return _ref3.apply(this, arguments);
271
292
  };
272
293
  }();
273
294
  /** 删除按钮事件 */
274
295
  var onRemoveMst = /*#__PURE__*/function () {
275
- var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
296
+ var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
276
297
  var _result$flag3;
277
298
  var ids, result;
278
- return _regeneratorRuntime.wrap(function _callee3$(_context3) {
279
- while (1) switch (_context3.prev = _context3.next) {
299
+ return _regeneratorRuntime.wrap(function _callee4$(_context4) {
300
+ while (1) switch (_context4.prev = _context4.next) {
280
301
  case 0:
281
302
  if (!(!masterObject || !masterObject[mstKeyField])) {
282
- _context3.next = 2;
303
+ _context4.next = 2;
283
304
  break;
284
305
  }
285
- return _context3.abrupt("return", false);
306
+ return _context4.abrupt("return", false);
286
307
  case 2:
287
308
  if (!isAudit()) {
288
- _context3.next = 5;
309
+ _context4.next = 5;
289
310
  break;
290
311
  }
291
312
  showWarn('当前单据已审核,不能删除');
292
- return _context3.abrupt("return", false);
313
+ return _context4.abrupt("return", false);
293
314
  case 5:
294
- _context3.next = 7;
315
+ _context4.next = 7;
295
316
  return showConfirm('确认要删除当前数据?');
296
317
  case 7:
297
318
  if (!beforeRemove) {
298
- _context3.next = 13;
319
+ _context4.next = 13;
299
320
  break;
300
321
  }
301
- _context3.next = 10;
322
+ _context4.next = 10;
302
323
  return beforeRemove([masterObject]);
303
324
  case 10:
304
- ids = _context3.sent;
325
+ ids = _context4.sent;
305
326
  if (!(ids === false)) {
306
- _context3.next = 13;
327
+ _context4.next = 13;
307
328
  break;
308
329
  }
309
- return _context3.abrupt("return", false);
330
+ return _context4.abrupt("return", false);
310
331
  case 13:
311
- if (!ids) {
332
+ if (ids === true || ids === undefined) {
312
333
  ids = [masterObject.id || masterObject[mstKeyField]]; //优先取id为主键,除非表中无id
313
334
  }
314
- _context3.next = 16;
335
+ _context4.next = 16;
315
336
  return mstService.remove(ids);
316
337
  case 16:
317
- result = _context3.sent;
318
- _context3.t0 = afterRemove;
319
- if (!_context3.t0) {
320
- _context3.next = 23;
338
+ result = _context4.sent;
339
+ _context4.t0 = afterRemove;
340
+ if (!_context4.t0) {
341
+ _context4.next = 23;
321
342
  break;
322
343
  }
323
- _context3.next = 21;
344
+ _context4.next = 21;
324
345
  return afterRemove(result, masterObject);
325
346
  case 21:
326
- _context3.t1 = _context3.sent;
327
- _context3.t0 = _context3.t1 === false;
347
+ _context4.t1 = _context4.sent;
348
+ _context4.t0 = _context4.t1 === false;
328
349
  case 23:
329
- if (!_context3.t0) {
330
- _context3.next = 25;
350
+ if (!_context4.t0) {
351
+ _context4.next = 25;
331
352
  break;
332
353
  }
333
- return _context3.abrupt("return");
354
+ return _context4.abrupt("return");
334
355
  case 25:
335
356
  if (!((result === null || result === void 0 ? void 0 : (_result$flag3 = result.flag) === null || _result$flag3 === void 0 ? void 0 : _result$flag3.retCode) === '0')) {
336
- _context3.next = 28;
357
+ _context4.next = 28;
337
358
  break;
338
359
  }
339
360
  showSuccess(result.flag.retMsg || '删除成功');
340
- return _context3.abrupt("return", true);
361
+ return _context4.abrupt("return", true);
341
362
  case 28:
342
- return _context3.abrupt("return", false);
363
+ return _context4.abrupt("return", false);
343
364
  case 29:
344
365
  case "end":
345
- return _context3.stop();
366
+ return _context4.stop();
346
367
  }
347
- }, _callee3);
368
+ }, _callee4);
348
369
  }));
349
370
  return function onRemoveMst() {
350
- return _ref3.apply(this, arguments);
371
+ return _ref4.apply(this, arguments);
351
372
  };
352
373
  }();
353
374
  /** 新增按钮事件 */
354
375
  var onAddDtl = /*#__PURE__*/function () {
355
- var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
376
+ var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5() {
356
377
  var item,
357
378
  _formRef$current2,
358
379
  mstVal,
359
380
  mst,
360
- _args4 = arguments;
361
- return _regeneratorRuntime.wrap(function _callee4$(_context4) {
362
- while (1) switch (_context4.prev = _context4.next) {
381
+ data,
382
+ _args5 = arguments;
383
+ return _regeneratorRuntime.wrap(function _callee5$(_context5) {
384
+ while (1) switch (_context5.prev = _context5.next) {
363
385
  case 0:
364
- item = _args4.length > 0 && _args4[0] !== undefined ? _args4[0] : _objectSpread({}, dtlItem);
386
+ item = _args5.length > 0 && _args5[0] !== undefined ? _args5[0] : _objectSpread({}, dtlItem);
365
387
  if (!(!masterObject[mstKeyField] && formRef.current)) {
366
- _context4.next = 16;
388
+ _context5.next = 16;
367
389
  break;
368
390
  }
369
- _context4.prev = 2;
370
- _context4.next = 5;
391
+ _context5.prev = 2;
392
+ _context5.next = 5;
371
393
  return (_formRef$current2 = formRef.current) === null || _formRef$current2 === void 0 ? void 0 : _formRef$current2.validateFields();
372
394
  case 5:
373
395
  mstVal = formRef.current.getFieldsValue();
374
- _context4.next = 8;
396
+ _context5.next = 8;
375
397
  return onSaveMst(mstVal);
376
398
  case 8:
377
- mst = _context4.sent;
399
+ mst = _context5.sent;
378
400
  if (!(mst !== true)) {
379
- _context4.next = 11;
401
+ _context5.next = 11;
380
402
  break;
381
403
  }
382
- return _context4.abrupt("return", false);
404
+ return _context5.abrupt("return", false);
383
405
  case 11:
384
- _context4.next = 16;
406
+ _context5.next = 16;
385
407
  break;
386
408
  case 13:
387
- _context4.prev = 13;
388
- _context4.t0 = _context4["catch"](2);
389
- return _context4.abrupt("return", false);
409
+ _context5.prev = 13;
410
+ _context5.t0 = _context5["catch"](2);
411
+ return _context5.abrupt("return", false);
390
412
  case 16:
391
- _context4.t1 = beforeAdd;
392
- if (!_context4.t1) {
393
- _context4.next = 22;
394
- break;
395
- }
396
- _context4.next = 20;
397
- return beforeAdd(item);
398
- case 20:
399
- _context4.t2 = _context4.sent;
400
- _context4.t1 = _context4.t2 === false;
401
- case 22:
402
- if (!_context4.t1) {
403
- _context4.next = 24;
413
+ _context5.next = 18;
414
+ return handleBefore(beforeAdd, item);
415
+ case 18:
416
+ data = _context5.sent;
417
+ if (!(data === false)) {
418
+ _context5.next = 21;
404
419
  break;
405
420
  }
406
- return _context4.abrupt("return", false);
407
- case 24:
408
- setEditItem(item);
421
+ return _context5.abrupt("return");
422
+ case 21:
423
+ setEditItem(data);
409
424
  setShowEdit(true);
410
- return _context4.abrupt("return", true);
411
- case 27:
425
+ return _context5.abrupt("return", true);
426
+ case 24:
412
427
  case "end":
413
- return _context4.stop();
428
+ return _context5.stop();
414
429
  }
415
- }, _callee4, null, [[2, 13]]);
430
+ }, _callee5, null, [[2, 13]]);
416
431
  }));
417
432
  return function onAddDtl() {
418
- return _ref4.apply(this, arguments);
433
+ return _ref5.apply(this, arguments);
419
434
  };
420
435
  }();
421
436
  /** 编辑按钮事件 */
422
437
  var onEditDtl = /*#__PURE__*/function () {
423
- var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5() {
438
+ var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6() {
424
439
  var item,
425
- _args5 = arguments;
426
- return _regeneratorRuntime.wrap(function _callee5$(_context5) {
427
- while (1) switch (_context5.prev = _context5.next) {
440
+ data,
441
+ _args6 = arguments;
442
+ return _regeneratorRuntime.wrap(function _callee6$(_context6) {
443
+ while (1) switch (_context6.prev = _context6.next) {
428
444
  case 0:
429
- item = _args5.length > 0 && _args5[0] !== undefined ? _args5[0] : _objectSpread({}, selectedRows[0]);
445
+ item = _args6.length > 0 && _args6[0] !== undefined ? _args6[0] : _objectSpread({}, selectedRows[0]);
430
446
  if (selectedRows.length) {
431
- _context5.next = 4;
447
+ _context6.next = 4;
432
448
  break;
433
449
  }
434
450
  showWarn('请先选择需要更改的数据');
435
- return _context5.abrupt("return", false);
451
+ return _context6.abrupt("return", false);
436
452
  case 4:
437
- _context5.t0 = beforeEdit;
438
- if (!_context5.t0) {
439
- _context5.next = 10;
440
- break;
441
- }
442
- _context5.next = 8;
443
- return beforeEdit(item);
444
- case 8:
445
- _context5.t1 = _context5.sent;
446
- _context5.t0 = _context5.t1 === false;
447
- case 10:
448
- if (!_context5.t0) {
449
- _context5.next = 12;
453
+ _context6.next = 6;
454
+ return handleBefore(beforeEdit, item);
455
+ case 6:
456
+ data = _context6.sent;
457
+ if (!(data === false)) {
458
+ _context6.next = 9;
450
459
  break;
451
460
  }
452
- return _context5.abrupt("return", false);
453
- case 12:
454
- setEditItem(item);
461
+ return _context6.abrupt("return", false);
462
+ case 9:
463
+ setEditItem(data);
455
464
  setShowEdit(true);
456
- return _context5.abrupt("return", true);
457
- case 15:
465
+ return _context6.abrupt("return", true);
466
+ case 12:
458
467
  case "end":
459
- return _context5.stop();
468
+ return _context6.stop();
460
469
  }
461
- }, _callee5);
470
+ }, _callee6);
462
471
  }));
463
472
  return function onEditDtl() {
464
- return _ref5.apply(this, arguments);
473
+ return _ref6.apply(this, arguments);
465
474
  };
466
475
  }();
467
476
  /** 删除按钮事件 */
@@ -471,51 +480,51 @@ function useDtl(dtlParam) {
471
480
  showWarn('请选择需要删除的数据');
472
481
  return;
473
482
  }
474
- showConfirm('确认要删除选择的数据?').then( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6() {
483
+ showConfirm('确认要删除选择的数据?').then( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7() {
475
484
  var _result$flag4;
476
485
  var ids, result;
477
- return _regeneratorRuntime.wrap(function _callee6$(_context6) {
478
- while (1) switch (_context6.prev = _context6.next) {
486
+ return _regeneratorRuntime.wrap(function _callee7$(_context7) {
487
+ while (1) switch (_context7.prev = _context7.next) {
479
488
  case 0:
480
489
  if (!beforeRemove) {
481
- _context6.next = 6;
490
+ _context7.next = 6;
482
491
  break;
483
492
  }
484
- _context6.next = 3;
493
+ _context7.next = 3;
485
494
  return beforeRemove(rows);
486
495
  case 3:
487
- ids = _context6.sent;
496
+ ids = _context7.sent;
488
497
  if (!(ids === false)) {
489
- _context6.next = 6;
498
+ _context7.next = 6;
490
499
  break;
491
500
  }
492
- return _context6.abrupt("return");
501
+ return _context7.abrupt("return");
493
502
  case 6:
494
- if (!ids) {
503
+ if (ids === true || ids === undefined) {
495
504
  ids = rows.map(function (o) {
496
505
  return o.id;
497
506
  });
498
507
  }
499
- _context6.next = 9;
508
+ _context7.next = 9;
500
509
  return dtlService.remove(ids);
501
510
  case 9:
502
- result = _context6.sent;
503
- _context6.t0 = afterRemove;
504
- if (!_context6.t0) {
505
- _context6.next = 16;
511
+ result = _context7.sent;
512
+ _context7.t0 = afterRemove;
513
+ if (!_context7.t0) {
514
+ _context7.next = 16;
506
515
  break;
507
516
  }
508
- _context6.next = 14;
517
+ _context7.next = 14;
509
518
  return afterRemove(result, rows);
510
519
  case 14:
511
- _context6.t1 = _context6.sent;
512
- _context6.t0 = _context6.t1 === false;
520
+ _context7.t1 = _context7.sent;
521
+ _context7.t0 = _context7.t1 === false;
513
522
  case 16:
514
- if (!_context6.t0) {
515
- _context6.next = 18;
523
+ if (!_context7.t0) {
524
+ _context7.next = 18;
516
525
  break;
517
526
  }
518
- return _context6.abrupt("return");
527
+ return _context7.abrupt("return");
519
528
  case 18:
520
529
  if ((result === null || result === void 0 ? void 0 : (_result$flag4 = result.flag) === null || _result$flag4 === void 0 ? void 0 : _result$flag4.retCode) === '0') {
521
530
  showSuccess(result.flag.retMsg);
@@ -525,80 +534,73 @@ function useDtl(dtlParam) {
525
534
  }
526
535
  case 19:
527
536
  case "end":
528
- return _context6.stop();
537
+ return _context7.stop();
529
538
  }
530
- }, _callee6);
539
+ }, _callee7);
531
540
  })));
532
541
  };
533
542
  /** 新增,更改对应的保存事件 */
534
543
  var onSaveDtl = /*#__PURE__*/function () {
535
- var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(formData) {
544
+ var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(formData) {
536
545
  var _result$flag5;
537
- var data, result;
538
- return _regeneratorRuntime.wrap(function _callee7$(_context7) {
539
- while (1) switch (_context7.prev = _context7.next) {
546
+ var obj, data, result;
547
+ return _regeneratorRuntime.wrap(function _callee8$(_context8) {
548
+ while (1) switch (_context8.prev = _context8.next) {
540
549
  case 0:
541
- data = _objectSpread(_objectSpread({}, editItem), formData);
542
- if (!data.id) {
543
- data[relationField] = masterObject[mstKeyField];
550
+ obj = _objectSpread(_objectSpread({}, editItem), formData);
551
+ if (!obj.id) {
552
+ obj[relationField] = masterObject[mstKeyField];
544
553
  }
545
- _context7.t0 = beforeSave;
546
- if (!_context7.t0) {
547
- _context7.next = 8;
548
- break;
549
- }
550
- _context7.next = 6;
551
- return beforeSave(data, true);
552
- case 6:
553
- _context7.t1 = _context7.sent;
554
- _context7.t0 = _context7.t1 === false;
555
- case 8:
556
- if (!_context7.t0) {
557
- _context7.next = 10;
554
+ _context8.next = 4;
555
+ return handleBefore(beforeSave, obj, true);
556
+ case 4:
557
+ data = _context8.sent;
558
+ if (!(data === false)) {
559
+ _context8.next = 7;
558
560
  break;
559
561
  }
560
- return _context7.abrupt("return", false);
561
- case 10:
562
- _context7.next = 12;
562
+ return _context8.abrupt("return", false);
563
+ case 7:
564
+ _context8.next = 9;
563
565
  return dtlService.save(data);
564
- case 12:
565
- result = _context7.sent;
566
- _context7.t2 = afterSave;
567
- if (!_context7.t2) {
568
- _context7.next = 19;
566
+ case 9:
567
+ result = _context8.sent;
568
+ _context8.t0 = afterSave;
569
+ if (!_context8.t0) {
570
+ _context8.next = 16;
569
571
  break;
570
572
  }
571
- _context7.next = 17;
573
+ _context8.next = 14;
572
574
  return afterSave(result, data, true);
573
- case 17:
574
- _context7.t3 = _context7.sent;
575
- _context7.t2 = _context7.t3 === false;
576
- case 19:
577
- if (!_context7.t2) {
578
- _context7.next = 21;
575
+ case 14:
576
+ _context8.t1 = _context8.sent;
577
+ _context8.t0 = _context8.t1 === false;
578
+ case 16:
579
+ if (!_context8.t0) {
580
+ _context8.next = 18;
579
581
  break;
580
582
  }
581
- return _context7.abrupt("return", false);
582
- case 21:
583
+ return _context8.abrupt("return", false);
584
+ case 18:
583
585
  if (!((result === null || result === void 0 ? void 0 : (_result$flag5 = result.flag) === null || _result$flag5 === void 0 ? void 0 : _result$flag5.retCode) === '0')) {
584
- _context7.next = 25;
586
+ _context8.next = 22;
585
587
  break;
586
588
  }
587
589
  showSuccess(result.flag.retMsg);
588
590
  if (tableRef.current) {
589
591
  tableRef.current.reload(false);
590
592
  }
591
- return _context7.abrupt("return", true);
592
- case 25:
593
- return _context7.abrupt("return", false);
594
- case 26:
593
+ return _context8.abrupt("return", true);
594
+ case 22:
595
+ return _context8.abrupt("return", false);
596
+ case 23:
595
597
  case "end":
596
- return _context7.stop();
598
+ return _context8.stop();
597
599
  }
598
- }, _callee7);
600
+ }, _callee8);
599
601
  }));
600
- return function onSaveDtl(_x2) {
601
- return _ref7.apply(this, arguments);
602
+ return function onSaveDtl(_x5) {
603
+ return _ref8.apply(this, arguments);
602
604
  };
603
605
  }();
604
606
  var toV2LoadParams = function toV2LoadParams(param) {
@@ -624,18 +626,18 @@ function useDtl(dtlParam) {
624
626
  };
625
627
  /** 加载数据方法 */
626
628
  var onLoadDtl = /*#__PURE__*/function () {
627
- var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(params, sort, filter) {
629
+ var _ref9 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9(params, sort, filter) {
628
630
  var _tableRef$current3, _tableRef$current3$cl;
629
- var current, pageSize, sumProperties, rest, param, key, sortArr, _key, _key2, result;
630
- return _regeneratorRuntime.wrap(function _callee8$(_context8) {
631
- while (1) switch (_context8.prev = _context8.next) {
631
+ var current, pageSize, sumProperties, rest, param, key, sortArr, _key, _key2, where, result;
632
+ return _regeneratorRuntime.wrap(function _callee9$(_context9) {
633
+ while (1) switch (_context9.prev = _context9.next) {
632
634
  case 0:
633
635
  current = params.current, pageSize = params.pageSize, sumProperties = params.sumProperties, rest = _objectWithoutProperties(params, _excluded);
634
636
  if (!(!masterObject || !masterObject[mstKeyField])) {
635
- _context8.next = 3;
637
+ _context9.next = 3;
636
638
  break;
637
639
  }
638
- return _context8.abrupt("return", {
640
+ return _context9.abrupt("return", {
639
641
  data: [],
640
642
  success: true
641
643
  });
@@ -684,69 +686,67 @@ function useDtl(dtlParam) {
684
686
  if (isV2) {
685
687
  toV2LoadParams(param);
686
688
  }
687
- _context8.t0 = beforeLoad;
688
- if (!_context8.t0) {
689
- _context8.next = 22;
690
- break;
691
- }
692
- _context8.next = 20;
693
- return beforeLoad(param);
694
- case 20:
695
- _context8.t1 = _context8.sent;
696
- _context8.t0 = _context8.t1 === false;
697
- case 22:
698
- if (!_context8.t0) {
699
- _context8.next = 24;
689
+ _context9.next = 18;
690
+ return handleBefore(beforeLoad, param, true);
691
+ case 18:
692
+ where = _context9.sent;
693
+ if (!(where === false)) {
694
+ _context9.next = 21;
700
695
  break;
701
696
  }
702
- return _context8.abrupt("return", {
697
+ return _context9.abrupt("return", {
703
698
  data: [],
704
- success: true
699
+ success: false,
700
+ total: 0
705
701
  });
706
- case 24:
707
- if (sumProperties && param.sort) {
708
- delete param.sort;
702
+ case 21:
703
+ // 如果beforeLoad返回true或没有返回值,则使用原来的param
704
+ if (where === true || where === undefined) {
705
+ where = param;
709
706
  }
710
- _context8.next = 27;
711
- return dtlService.load(param);
712
- case 27:
713
- result = _context8.sent;
707
+ if (sumProperties && where.sort) {
708
+ delete where.sort;
709
+ }
710
+ _context9.next = 25;
711
+ return dtlService.load(where);
712
+ case 25:
713
+ result = _context9.sent;
714
714
  result.data = result.rows;
715
715
  result.success = true;
716
716
  if (sumProperties) {
717
717
  result.data = result.footer;
718
718
  }
719
- return _context8.abrupt("return", result);
720
- case 32:
719
+ return _context9.abrupt("return", result);
720
+ case 30:
721
721
  case "end":
722
- return _context8.stop();
722
+ return _context9.stop();
723
723
  }
724
- }, _callee8);
724
+ }, _callee9);
725
725
  }));
726
- return function onLoadDtl(_x3, _x4, _x5) {
727
- return _ref8.apply(this, arguments);
726
+ return function onLoadDtl(_x6, _x7, _x8) {
727
+ return _ref9.apply(this, arguments);
728
728
  };
729
729
  }();
730
730
  var onExportDtl = /*#__PURE__*/function () {
731
- var _ref9 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9(url, param) {
731
+ var _ref10 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10(url, param) {
732
732
  var _param$exportColumns;
733
733
  var searchArr, arr, otherArr, whereArr, where, _result$flag6, _result$flag7, _result$flag8, result, _result$flag9;
734
- return _regeneratorRuntime.wrap(function _callee9$(_context9) {
735
- while (1) switch (_context9.prev = _context9.next) {
734
+ return _regeneratorRuntime.wrap(function _callee10$(_context10) {
735
+ while (1) switch (_context10.prev = _context10.next) {
736
736
  case 0:
737
737
  if ((_param$exportColumns = param.exportColumns) === null || _param$exportColumns === void 0 ? void 0 : _param$exportColumns.length) {
738
- _context9.next = 3;
738
+ _context10.next = 3;
739
739
  break;
740
740
  }
741
741
  showWarn('请选择要导出的列');
742
- return _context9.abrupt("return", false);
742
+ return _context10.abrupt("return", false);
743
743
  case 3:
744
744
  if (param.findUrl) {
745
- _context9.next = 6;
745
+ _context10.next = 6;
746
746
  break;
747
747
  }
748
748
  showWarn('请配置业务接口 bizApi 属性');
749
- return _context9.abrupt("return", false);
749
+ return _context10.abrupt("return", false);
750
750
  case 6:
751
751
  if (param.searchData) {
752
752
  searchArr = (param.searchData || '').split('&');
@@ -787,143 +787,136 @@ function useDtl(dtlParam) {
787
787
  }
788
788
  }
789
789
  }
790
- _context9.prev = 7;
791
- _context9.next = 10;
790
+ _context10.prev = 7;
791
+ _context10.next = 10;
792
792
  return httpPost(url, param);
793
793
  case 10:
794
- result = _context9.sent;
794
+ result = _context10.sent;
795
795
  if (!(result.data && typeof result.data === 'string' && ((_result$flag6 = result.flag) === null || _result$flag6 === void 0 ? void 0 : _result$flag6.retCode) === '0')) {
796
- _context9.next = 14;
796
+ _context10.next = 14;
797
797
  break;
798
798
  }
799
799
  downloadFile(result.data);
800
- return _context9.abrupt("return", true);
800
+ return _context10.abrupt("return", true);
801
801
  case 14:
802
802
  if (!(((_result$flag7 = result.flag) === null || _result$flag7 === void 0 ? void 0 : _result$flag7.retCode) === '0')) {
803
- _context9.next = 19;
803
+ _context10.next = 19;
804
804
  break;
805
805
  }
806
806
  exportProcess(result);
807
807
  // showSuccess(result.flag?.retMsg || '导出成功');
808
- return _context9.abrupt("return", true);
808
+ return _context10.abrupt("return", true);
809
809
  case 19:
810
810
  if (!['9101', '9102', '9103', '9013', '9014', '9110'].includes((result === null || result === void 0 ? void 0 : (_result$flag8 = result.flag) === null || _result$flag8 === void 0 ? void 0 : _result$flag8.retCode) || '0')) {
811
- _context9.next = 23;
811
+ _context10.next = 23;
812
812
  break;
813
813
  }
814
- return _context9.abrupt("return", result);
814
+ return _context10.abrupt("return", result);
815
815
  case 23:
816
816
  showError(((_result$flag9 = result.flag) === null || _result$flag9 === void 0 ? void 0 : _result$flag9.retMsg) || '导出失败,请联系系统管理员');
817
- return _context9.abrupt("return", false);
817
+ return _context10.abrupt("return", false);
818
818
  case 25:
819
- _context9.next = 31;
819
+ _context10.next = 31;
820
820
  break;
821
821
  case 27:
822
- _context9.prev = 27;
823
- _context9.t0 = _context9["catch"](7);
824
- showError(_context9.t0.message);
825
- return _context9.abrupt("return", false);
822
+ _context10.prev = 27;
823
+ _context10.t0 = _context10["catch"](7);
824
+ showError(_context10.t0.message);
825
+ return _context10.abrupt("return", false);
826
826
  case 31:
827
827
  case "end":
828
- return _context9.stop();
828
+ return _context10.stop();
829
829
  }
830
- }, _callee9, null, [[7, 27]]);
830
+ }, _callee10, null, [[7, 27]]);
831
831
  }));
832
- return function onExportDtl(_x6, _x7) {
833
- return _ref9.apply(this, arguments);
832
+ return function onExportDtl(_x9, _x10) {
833
+ return _ref10.apply(this, arguments);
834
834
  };
835
835
  }();
836
836
  /** 审核按钮事件 */
837
837
  var onAudit = /*#__PURE__*/function () {
838
- var _ref10 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10() {
839
- var obj, _result$flag10, result;
840
- return _regeneratorRuntime.wrap(function _callee10$(_context10) {
841
- while (1) switch (_context10.prev = _context10.next) {
838
+ var _ref11 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11() {
839
+ var obj, datas, _result$flag10, result;
840
+ return _regeneratorRuntime.wrap(function _callee11$(_context11) {
841
+ while (1) switch (_context11.prev = _context11.next) {
842
842
  case 0:
843
843
  if (!isAudit()) {
844
- _context10.next = 3;
844
+ _context11.next = 3;
845
845
  break;
846
846
  }
847
847
  showWarn('当前数据已审核,不能再做审核操作!');
848
- return _context10.abrupt("return");
848
+ return _context11.abrupt("return");
849
849
  case 3:
850
850
  obj = _objectSpread({}, masterObject);
851
851
  if (masterObject[mstKeyField]) {
852
- _context10.next = 7;
852
+ _context11.next = 7;
853
853
  break;
854
854
  }
855
855
  showWarn('当前数据未保存,不能审核');
856
- return _context10.abrupt("return");
856
+ return _context11.abrupt("return");
857
857
  case 7:
858
- _context10.prev = 7;
859
- _context10.next = 10;
858
+ _context11.prev = 7;
859
+ _context11.next = 10;
860
860
  return showConfirm('确认要审核此数据?', '审核提示');
861
861
  case 10:
862
- _context10.next = 16;
862
+ _context11.next = 16;
863
863
  break;
864
864
  case 12:
865
- _context10.prev = 12;
866
- _context10.t0 = _context10["catch"](7);
867
- console.log('终止审核', _context10.t0);
868
- return _context10.abrupt("return");
865
+ _context11.prev = 12;
866
+ _context11.t0 = _context11["catch"](7);
867
+ console.log('终止审核', _context11.t0);
868
+ return _context11.abrupt("return");
869
869
  case 16:
870
- _context10.t1 = beforeAudit;
871
- if (!_context10.t1) {
872
- _context10.next = 22;
873
- break;
874
- }
875
- _context10.next = 20;
876
- return beforeAudit(obj);
877
- case 20:
878
- _context10.t2 = _context10.sent;
879
- _context10.t1 = _context10.t2 === false;
880
- case 22:
881
- if (!_context10.t1) {
882
- _context10.next = 24;
870
+ _context11.next = 18;
871
+ return handleBefore(beforeAudit, obj, false);
872
+ case 18:
873
+ datas = _context11.sent;
874
+ if (!(datas === false)) {
875
+ _context11.next = 21;
883
876
  break;
884
877
  }
885
- return _context10.abrupt("return");
878
+ return _context11.abrupt("return");
879
+ case 21:
880
+ _context11.prev = 21;
881
+ _context11.next = 24;
882
+ return mstService.audit(datas);
886
883
  case 24:
887
- _context10.prev = 24;
888
- _context10.next = 27;
889
- return mstService.audit([obj]);
890
- case 27:
891
- result = _context10.sent;
892
- _context10.t3 = afterAudit;
893
- if (!_context10.t3) {
894
- _context10.next = 34;
884
+ result = _context11.sent;
885
+ _context11.t1 = afterAudit;
886
+ if (!_context11.t1) {
887
+ _context11.next = 31;
895
888
  break;
896
889
  }
897
- _context10.next = 32;
898
- return afterAudit(result, [obj]);
899
- case 32:
900
- _context10.t4 = _context10.sent;
901
- _context10.t3 = _context10.t4 === false;
902
- case 34:
903
- if (!_context10.t3) {
904
- _context10.next = 36;
890
+ _context11.next = 29;
891
+ return afterAudit(result, datas);
892
+ case 29:
893
+ _context11.t2 = _context11.sent;
894
+ _context11.t1 = _context11.t2 === false;
895
+ case 31:
896
+ if (!_context11.t1) {
897
+ _context11.next = 33;
905
898
  break;
906
899
  }
907
- return _context10.abrupt("return");
908
- case 36:
900
+ return _context11.abrupt("return");
901
+ case 33:
909
902
  if ((result === null || result === void 0 ? void 0 : (_result$flag10 = result.flag) === null || _result$flag10 === void 0 ? void 0 : _result$flag10.retCode) === '0') {
910
903
  showSuccess(result.flag.retMsg || '审核成功');
911
904
  Object.assign(masterObject, result.data);
912
905
  }
913
- _context10.next = 42;
906
+ _context11.next = 39;
914
907
  break;
908
+ case 36:
909
+ _context11.prev = 36;
910
+ _context11.t3 = _context11["catch"](21);
911
+ console.log('审核异常', _context11.t3);
915
912
  case 39:
916
- _context10.prev = 39;
917
- _context10.t5 = _context10["catch"](24);
918
- console.log('审核异常', _context10.t5);
919
- case 42:
920
913
  case "end":
921
- return _context10.stop();
914
+ return _context11.stop();
922
915
  }
923
- }, _callee10, null, [[7, 12], [24, 39]]);
916
+ }, _callee11, null, [[7, 12], [21, 36]]);
924
917
  }));
925
918
  return function onAudit() {
926
- return _ref10.apply(this, arguments);
919
+ return _ref11.apply(this, arguments);
927
920
  };
928
921
  }();
929
922
  var btnDisabled = function btnDisabled(key) {