ls-pro-common 1.0.19 → 1.0.20
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.
- package/dist/common.js +1 -1
- package/dist/common.min.js +1 -1
- package/es/components/InputTable.js +2 -1
- package/es/hooks/useDtl/index.d.ts +5 -4
- package/es/hooks/useDtl/index.js +181 -101
- package/es/hooks/usePermission/index.d.ts +7 -0
- package/es/hooks/usePermission/index.js +38 -0
- package/es/hooks/useSingle/index.d.ts +16 -6
- package/es/hooks/useSingle/index.js +329 -159
- package/es/typing.d.ts +2 -0
- package/lib/components/InputTable.js +2 -1
- package/lib/hooks/useDtl/index.d.ts +5 -4
- package/lib/hooks/useDtl/index.js +180 -100
- package/lib/hooks/usePermission/index.d.ts +7 -0
- package/lib/hooks/usePermission/index.js +47 -0
- package/lib/hooks/useSingle/index.d.ts +16 -6
- package/lib/hooks/useSingle/index.js +329 -158
- package/lib/typing.d.ts +2 -0
- package/package.json +3 -3
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import "antd/es/button/style";
|
|
2
2
|
import _Button from "antd/es/button";
|
|
3
3
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
4
|
-
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
5
4
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
5
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
6
6
|
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
7
7
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
8
8
|
var _excluded = ["current", "pageSize"];
|
|
9
9
|
import React from "react";
|
|
10
|
-
import { useState, useRef } from 'react';
|
|
11
|
-
import { PlusOutlined, EditOutlined, DeleteOutlined, ImportOutlined, ExportOutlined } from '@ant-design/icons';
|
|
10
|
+
import { useState, useRef, useMemo, useCallback } from 'react';
|
|
11
|
+
import { PlusOutlined, EditOutlined, DeleteOutlined, ImportOutlined, ExportOutlined, CheckOutlined } from '@ant-design/icons';
|
|
12
12
|
import { showConfirm, showWarn, showSuccess, showError } from '../../utils';
|
|
13
13
|
import { httpPost } from '../../http';
|
|
14
|
+
import usePermission from '../usePermission';
|
|
14
15
|
/**
|
|
15
16
|
* 单表基本增删改查 hooks
|
|
16
17
|
* @param service 单表服务
|
|
@@ -21,15 +22,25 @@ import { httpPost } from '../../http';
|
|
|
21
22
|
*/
|
|
22
23
|
|
|
23
24
|
function useSingle(inParam) {
|
|
25
|
+
var _usePermission = usePermission(),
|
|
26
|
+
resourceId = _usePermission.resourceId,
|
|
27
|
+
checkRight = _usePermission.checkRight;
|
|
28
|
+
|
|
24
29
|
var service = inParam.service,
|
|
25
30
|
toolConfig = inParam.toolConfig,
|
|
26
31
|
initItem = inParam.initItem,
|
|
32
|
+
statusField = inParam.statusField,
|
|
33
|
+
auditStatus = inParam.auditStatus,
|
|
34
|
+
beforeAudit = inParam.beforeAudit,
|
|
27
35
|
beforeLoad = inParam.beforeLoad,
|
|
28
36
|
beforeRemove = inParam.beforeRemove,
|
|
29
37
|
beforeAdd = inParam.beforeAdd,
|
|
30
38
|
beforeEdit = inParam.beforeEdit,
|
|
39
|
+
beforeSave = inParam.beforeSave,
|
|
31
40
|
afterRemove = inParam.afterRemove,
|
|
32
|
-
afterSave = inParam.afterSave
|
|
41
|
+
afterSave = inParam.afterSave,
|
|
42
|
+
afterAudit = inParam.afterAudit,
|
|
43
|
+
btnStatus = inParam.btnStatus;
|
|
33
44
|
/** @name 选中行数据 */
|
|
34
45
|
|
|
35
46
|
var _useState = useState([]),
|
|
@@ -63,38 +74,42 @@ function useSingle(inParam) {
|
|
|
63
74
|
/** 新增按钮事件 */
|
|
64
75
|
|
|
65
76
|
var onAdd = /*#__PURE__*/function () {
|
|
66
|
-
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
77
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(item) {
|
|
67
78
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
68
79
|
while (1) {
|
|
69
80
|
switch (_context.prev = _context.next) {
|
|
70
81
|
case 0:
|
|
82
|
+
if (!item) {
|
|
83
|
+
item = _objectSpread({}, initItem);
|
|
84
|
+
}
|
|
85
|
+
|
|
71
86
|
_context.t0 = beforeAdd;
|
|
72
87
|
|
|
73
88
|
if (!_context.t0) {
|
|
74
|
-
_context.next =
|
|
89
|
+
_context.next = 7;
|
|
75
90
|
break;
|
|
76
91
|
}
|
|
77
92
|
|
|
78
|
-
_context.next =
|
|
79
|
-
return beforeAdd(
|
|
93
|
+
_context.next = 5;
|
|
94
|
+
return beforeAdd(item);
|
|
80
95
|
|
|
81
|
-
case
|
|
96
|
+
case 5:
|
|
82
97
|
_context.t1 = _context.sent;
|
|
83
98
|
_context.t0 = _context.t1 === false;
|
|
84
99
|
|
|
85
|
-
case
|
|
100
|
+
case 7:
|
|
86
101
|
if (!_context.t0) {
|
|
87
|
-
_context.next =
|
|
102
|
+
_context.next = 9;
|
|
88
103
|
break;
|
|
89
104
|
}
|
|
90
105
|
|
|
91
106
|
return _context.abrupt("return");
|
|
92
107
|
|
|
93
|
-
case
|
|
94
|
-
setEditItem(
|
|
108
|
+
case 9:
|
|
109
|
+
setEditItem(item);
|
|
95
110
|
setShowEdit(true);
|
|
96
111
|
|
|
97
|
-
case
|
|
112
|
+
case 11:
|
|
98
113
|
case "end":
|
|
99
114
|
return _context.stop();
|
|
100
115
|
}
|
|
@@ -102,7 +117,7 @@ function useSingle(inParam) {
|
|
|
102
117
|
}, _callee);
|
|
103
118
|
}));
|
|
104
119
|
|
|
105
|
-
return function onAdd() {
|
|
120
|
+
return function onAdd(_x) {
|
|
106
121
|
return _ref.apply(this, arguments);
|
|
107
122
|
};
|
|
108
123
|
}();
|
|
@@ -110,12 +125,12 @@ function useSingle(inParam) {
|
|
|
110
125
|
|
|
111
126
|
|
|
112
127
|
var onEdit = /*#__PURE__*/function () {
|
|
113
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
128
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(item) {
|
|
114
129
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
115
130
|
while (1) {
|
|
116
131
|
switch (_context2.prev = _context2.next) {
|
|
117
132
|
case 0:
|
|
118
|
-
if (selectedRows.length) {
|
|
133
|
+
if (!(!item && !selectedRows.length)) {
|
|
119
134
|
_context2.next = 3;
|
|
120
135
|
break;
|
|
121
136
|
}
|
|
@@ -124,33 +139,37 @@ function useSingle(inParam) {
|
|
|
124
139
|
return _context2.abrupt("return");
|
|
125
140
|
|
|
126
141
|
case 3:
|
|
142
|
+
if (!item) {
|
|
143
|
+
item = _objectSpread({}, selectedRows[0]);
|
|
144
|
+
}
|
|
145
|
+
|
|
127
146
|
_context2.t0 = beforeEdit;
|
|
128
147
|
|
|
129
148
|
if (!_context2.t0) {
|
|
130
|
-
_context2.next =
|
|
149
|
+
_context2.next = 10;
|
|
131
150
|
break;
|
|
132
151
|
}
|
|
133
152
|
|
|
134
|
-
_context2.next =
|
|
135
|
-
return beforeEdit(
|
|
153
|
+
_context2.next = 8;
|
|
154
|
+
return beforeEdit(item);
|
|
136
155
|
|
|
137
|
-
case
|
|
156
|
+
case 8:
|
|
138
157
|
_context2.t1 = _context2.sent;
|
|
139
158
|
_context2.t0 = _context2.t1 === false;
|
|
140
159
|
|
|
141
|
-
case
|
|
160
|
+
case 10:
|
|
142
161
|
if (!_context2.t0) {
|
|
143
|
-
_context2.next =
|
|
162
|
+
_context2.next = 12;
|
|
144
163
|
break;
|
|
145
164
|
}
|
|
146
165
|
|
|
147
166
|
return _context2.abrupt("return");
|
|
148
167
|
|
|
149
|
-
case
|
|
150
|
-
setEditItem(
|
|
168
|
+
case 12:
|
|
169
|
+
setEditItem(item);
|
|
151
170
|
setShowEdit(true);
|
|
152
171
|
|
|
153
|
-
case
|
|
172
|
+
case 14:
|
|
154
173
|
case "end":
|
|
155
174
|
return _context2.stop();
|
|
156
175
|
}
|
|
@@ -158,67 +177,82 @@ function useSingle(inParam) {
|
|
|
158
177
|
}, _callee2);
|
|
159
178
|
}));
|
|
160
179
|
|
|
161
|
-
return function onEdit() {
|
|
180
|
+
return function onEdit(_x2) {
|
|
162
181
|
return _ref2.apply(this, arguments);
|
|
163
182
|
};
|
|
164
183
|
}();
|
|
165
184
|
/** 删除按钮事件 */
|
|
166
185
|
|
|
167
186
|
|
|
168
|
-
var onRemove = function onRemove() {
|
|
169
|
-
if (!selectedRows.length) {
|
|
187
|
+
var onRemove = function onRemove(row) {
|
|
188
|
+
if (!row || !selectedRows.length) {
|
|
170
189
|
showWarn('请选择需要删除的数据');
|
|
171
190
|
return;
|
|
172
191
|
}
|
|
173
192
|
|
|
174
193
|
showConfirm('确认要删除选择的数据?').then( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
175
|
-
var ids, _result$flag, result;
|
|
194
|
+
var rows, ids, _result$flag, result;
|
|
176
195
|
|
|
177
196
|
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
178
197
|
while (1) {
|
|
179
198
|
switch (_context3.prev = _context3.next) {
|
|
180
199
|
case 0:
|
|
200
|
+
rows = row ? [row] : selectedRows;
|
|
201
|
+
|
|
181
202
|
if (!beforeRemove) {
|
|
182
|
-
_context3.next =
|
|
203
|
+
_context3.next = 7;
|
|
183
204
|
break;
|
|
184
205
|
}
|
|
185
206
|
|
|
186
|
-
_context3.next =
|
|
187
|
-
return beforeRemove(
|
|
207
|
+
_context3.next = 4;
|
|
208
|
+
return beforeRemove(rows);
|
|
188
209
|
|
|
189
|
-
case
|
|
210
|
+
case 4:
|
|
190
211
|
ids = _context3.sent;
|
|
191
212
|
|
|
192
213
|
if (!(ids === false)) {
|
|
193
|
-
_context3.next =
|
|
214
|
+
_context3.next = 7;
|
|
194
215
|
break;
|
|
195
216
|
}
|
|
196
217
|
|
|
197
218
|
return _context3.abrupt("return");
|
|
198
219
|
|
|
199
|
-
case
|
|
220
|
+
case 7:
|
|
200
221
|
if (!ids) {
|
|
201
|
-
ids =
|
|
222
|
+
ids = rows.map(function (o) {
|
|
202
223
|
return o.id;
|
|
203
224
|
});
|
|
204
225
|
}
|
|
205
226
|
|
|
206
|
-
_context3.prev =
|
|
207
|
-
_context3.next =
|
|
227
|
+
_context3.prev = 8;
|
|
228
|
+
_context3.next = 11;
|
|
208
229
|
return service.remove(ids);
|
|
209
230
|
|
|
210
|
-
case
|
|
231
|
+
case 11:
|
|
211
232
|
result = _context3.sent;
|
|
233
|
+
_context3.t0 = afterRemove;
|
|
212
234
|
|
|
213
|
-
if (!
|
|
214
|
-
_context3.next =
|
|
235
|
+
if (!_context3.t0) {
|
|
236
|
+
_context3.next = 18;
|
|
237
|
+
break;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
_context3.next = 16;
|
|
241
|
+
return afterRemove(result, rows);
|
|
242
|
+
|
|
243
|
+
case 16:
|
|
244
|
+
_context3.t1 = _context3.sent;
|
|
245
|
+
_context3.t0 = _context3.t1 === false;
|
|
246
|
+
|
|
247
|
+
case 18:
|
|
248
|
+
if (!_context3.t0) {
|
|
249
|
+
_context3.next = 20;
|
|
215
250
|
break;
|
|
216
251
|
}
|
|
217
252
|
|
|
218
|
-
afterRemove(result, selectedRows);
|
|
219
253
|
return _context3.abrupt("return");
|
|
220
254
|
|
|
221
|
-
case
|
|
255
|
+
case 20:
|
|
222
256
|
if ((result === null || result === void 0 ? void 0 : (_result$flag = result.flag) === null || _result$flag === void 0 ? void 0 : _result$flag.retCode) === '0') {
|
|
223
257
|
showSuccess(result.flag.retMsg);
|
|
224
258
|
|
|
@@ -227,55 +261,168 @@ function useSingle(inParam) {
|
|
|
227
261
|
}
|
|
228
262
|
}
|
|
229
263
|
|
|
230
|
-
_context3.next =
|
|
264
|
+
_context3.next = 26;
|
|
231
265
|
break;
|
|
232
266
|
|
|
233
|
-
case
|
|
234
|
-
_context3.prev =
|
|
235
|
-
_context3.
|
|
236
|
-
console.log(_context3.
|
|
267
|
+
case 23:
|
|
268
|
+
_context3.prev = 23;
|
|
269
|
+
_context3.t2 = _context3["catch"](8);
|
|
270
|
+
console.log(_context3.t2);
|
|
237
271
|
|
|
238
|
-
case
|
|
272
|
+
case 26:
|
|
239
273
|
case "end":
|
|
240
274
|
return _context3.stop();
|
|
241
275
|
}
|
|
242
276
|
}
|
|
243
|
-
}, _callee3, null, [[
|
|
277
|
+
}, _callee3, null, [[8, 23]]);
|
|
244
278
|
})));
|
|
245
279
|
};
|
|
246
|
-
/**
|
|
280
|
+
/** 审核按钮事件 */
|
|
247
281
|
|
|
248
282
|
|
|
249
|
-
var
|
|
250
|
-
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(
|
|
251
|
-
var
|
|
283
|
+
var onAudit = /*#__PURE__*/function () {
|
|
284
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(row) {
|
|
285
|
+
var rows, _result$flag2, result;
|
|
252
286
|
|
|
253
287
|
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
254
288
|
while (1) {
|
|
255
289
|
switch (_context4.prev = _context4.next) {
|
|
290
|
+
case 0:
|
|
291
|
+
if (!(!row || !selectedRows.length)) {
|
|
292
|
+
_context4.next = 3;
|
|
293
|
+
break;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
showWarn('请选择需要审核的数据');
|
|
297
|
+
return _context4.abrupt("return");
|
|
298
|
+
|
|
299
|
+
case 3:
|
|
300
|
+
rows = (row ? [row] : selectedRows).map(function (o) {
|
|
301
|
+
return _objectSpread({}, o);
|
|
302
|
+
});
|
|
303
|
+
_context4.t0 = beforeAudit;
|
|
304
|
+
|
|
305
|
+
if (!_context4.t0) {
|
|
306
|
+
_context4.next = 10;
|
|
307
|
+
break;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
_context4.next = 8;
|
|
311
|
+
return beforeAudit(rows);
|
|
312
|
+
|
|
313
|
+
case 8:
|
|
314
|
+
_context4.t1 = _context4.sent;
|
|
315
|
+
_context4.t0 = _context4.t1 === false;
|
|
316
|
+
|
|
317
|
+
case 10:
|
|
318
|
+
if (!_context4.t0) {
|
|
319
|
+
_context4.next = 12;
|
|
320
|
+
break;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
return _context4.abrupt("return");
|
|
324
|
+
|
|
325
|
+
case 12:
|
|
326
|
+
_context4.prev = 12;
|
|
327
|
+
_context4.next = 15;
|
|
328
|
+
return service.audit(rows);
|
|
329
|
+
|
|
330
|
+
case 15:
|
|
331
|
+
result = _context4.sent;
|
|
332
|
+
|
|
333
|
+
if (!afterAudit) {
|
|
334
|
+
_context4.next = 19;
|
|
335
|
+
break;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
afterAudit(result, rows);
|
|
339
|
+
return _context4.abrupt("return");
|
|
340
|
+
|
|
341
|
+
case 19:
|
|
342
|
+
if ((result === null || result === void 0 ? void 0 : (_result$flag2 = result.flag) === null || _result$flag2 === void 0 ? void 0 : _result$flag2.retCode) === '0') {
|
|
343
|
+
showSuccess(result.flag.retMsg);
|
|
344
|
+
|
|
345
|
+
if (tableRef.current) {
|
|
346
|
+
tableRef.current.reload(false);
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
_context4.next = 25;
|
|
351
|
+
break;
|
|
352
|
+
|
|
353
|
+
case 22:
|
|
354
|
+
_context4.prev = 22;
|
|
355
|
+
_context4.t2 = _context4["catch"](12);
|
|
356
|
+
console.log(_context4.t2);
|
|
357
|
+
|
|
358
|
+
case 25:
|
|
359
|
+
case "end":
|
|
360
|
+
return _context4.stop();
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
}, _callee4, null, [[12, 22]]);
|
|
364
|
+
}));
|
|
365
|
+
|
|
366
|
+
return function onAudit(_x3) {
|
|
367
|
+
return _ref4.apply(this, arguments);
|
|
368
|
+
};
|
|
369
|
+
}();
|
|
370
|
+
/** 新增,更改对应的保存事件 */
|
|
371
|
+
|
|
372
|
+
|
|
373
|
+
var onSave = /*#__PURE__*/function () {
|
|
374
|
+
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(formData) {
|
|
375
|
+
var data, _result$flag3, result;
|
|
376
|
+
|
|
377
|
+
return _regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
378
|
+
while (1) {
|
|
379
|
+
switch (_context5.prev = _context5.next) {
|
|
256
380
|
case 0:
|
|
257
381
|
data = _objectSpread(_objectSpread({}, editItem), formData);
|
|
258
|
-
|
|
259
|
-
|
|
382
|
+
_context5.prev = 1;
|
|
383
|
+
_context5.t0 = beforeSave;
|
|
384
|
+
|
|
385
|
+
if (!_context5.t0) {
|
|
386
|
+
_context5.next = 8;
|
|
387
|
+
break;
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
_context5.next = 6;
|
|
391
|
+
return beforeSave(data);
|
|
392
|
+
|
|
393
|
+
case 6:
|
|
394
|
+
_context5.t1 = _context5.sent;
|
|
395
|
+
_context5.t0 = _context5.t1 === false;
|
|
396
|
+
|
|
397
|
+
case 8:
|
|
398
|
+
if (!_context5.t0) {
|
|
399
|
+
_context5.next = 10;
|
|
400
|
+
break;
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
return _context5.abrupt("return", false);
|
|
404
|
+
|
|
405
|
+
case 10:
|
|
406
|
+
_context5.next = 12;
|
|
260
407
|
return service.save(data);
|
|
261
408
|
|
|
262
|
-
case
|
|
263
|
-
result =
|
|
409
|
+
case 12:
|
|
410
|
+
result = _context5.sent;
|
|
264
411
|
|
|
265
412
|
if (!afterSave) {
|
|
266
|
-
|
|
413
|
+
_context5.next = 17;
|
|
267
414
|
break;
|
|
268
415
|
}
|
|
269
416
|
|
|
270
|
-
|
|
271
|
-
return afterSave(result, data);
|
|
417
|
+
_context5.next = 16;
|
|
418
|
+
return afterSave(result, data, false);
|
|
272
419
|
|
|
273
|
-
case
|
|
274
|
-
return
|
|
420
|
+
case 16:
|
|
421
|
+
return _context5.abrupt("return", _context5.sent);
|
|
275
422
|
|
|
276
|
-
case
|
|
277
|
-
if (!((result === null || result === void 0 ? void 0 : (_result$
|
|
278
|
-
|
|
423
|
+
case 17:
|
|
424
|
+
if (!((result === null || result === void 0 ? void 0 : (_result$flag3 = result.flag) === null || _result$flag3 === void 0 ? void 0 : _result$flag3.retCode) === '0')) {
|
|
425
|
+
_context5.next = 21;
|
|
279
426
|
break;
|
|
280
427
|
}
|
|
281
428
|
|
|
@@ -285,41 +432,41 @@ function useSingle(inParam) {
|
|
|
285
432
|
tableRef.current.reload(false);
|
|
286
433
|
}
|
|
287
434
|
|
|
288
|
-
return
|
|
435
|
+
return _context5.abrupt("return", true);
|
|
289
436
|
|
|
290
|
-
case
|
|
291
|
-
|
|
437
|
+
case 21:
|
|
438
|
+
_context5.next = 26;
|
|
292
439
|
break;
|
|
293
440
|
|
|
294
|
-
case
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
console.log(
|
|
441
|
+
case 23:
|
|
442
|
+
_context5.prev = 23;
|
|
443
|
+
_context5.t2 = _context5["catch"](1);
|
|
444
|
+
console.log(_context5.t2);
|
|
298
445
|
|
|
299
|
-
case
|
|
300
|
-
return
|
|
446
|
+
case 26:
|
|
447
|
+
return _context5.abrupt("return", false);
|
|
301
448
|
|
|
302
|
-
case
|
|
449
|
+
case 27:
|
|
303
450
|
case "end":
|
|
304
|
-
return
|
|
451
|
+
return _context5.stop();
|
|
305
452
|
}
|
|
306
453
|
}
|
|
307
|
-
},
|
|
454
|
+
}, _callee5, null, [[1, 23]]);
|
|
308
455
|
}));
|
|
309
456
|
|
|
310
|
-
return function onSave(
|
|
311
|
-
return
|
|
457
|
+
return function onSave(_x4) {
|
|
458
|
+
return _ref5.apply(this, arguments);
|
|
312
459
|
};
|
|
313
460
|
}();
|
|
314
461
|
/** 加载数据方法 */
|
|
315
462
|
|
|
316
463
|
|
|
317
464
|
var onLoad = /*#__PURE__*/function () {
|
|
318
|
-
var
|
|
465
|
+
var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(params, sort, filter) {
|
|
319
466
|
var current, pageSize, rest, param, key, result;
|
|
320
|
-
return _regeneratorRuntime.wrap(function
|
|
467
|
+
return _regeneratorRuntime.wrap(function _callee6$(_context6) {
|
|
321
468
|
while (1) {
|
|
322
|
-
switch (
|
|
469
|
+
switch (_context6.prev = _context6.next) {
|
|
323
470
|
case 0:
|
|
324
471
|
current = params.current, pageSize = params.pageSize, rest = _objectWithoutProperties(params, _excluded);
|
|
325
472
|
param = {};
|
|
@@ -339,157 +486,179 @@ function useSingle(inParam) {
|
|
|
339
486
|
param.where = rest;
|
|
340
487
|
}
|
|
341
488
|
|
|
342
|
-
|
|
489
|
+
_context6.t0 = beforeLoad;
|
|
343
490
|
|
|
344
|
-
if (!
|
|
345
|
-
|
|
491
|
+
if (!_context6.t0) {
|
|
492
|
+
_context6.next = 11;
|
|
346
493
|
break;
|
|
347
494
|
}
|
|
348
495
|
|
|
349
|
-
|
|
496
|
+
_context6.next = 9;
|
|
350
497
|
return beforeLoad(param);
|
|
351
498
|
|
|
352
499
|
case 9:
|
|
353
|
-
|
|
354
|
-
|
|
500
|
+
_context6.t1 = _context6.sent;
|
|
501
|
+
_context6.t0 = _context6.t1 === false;
|
|
355
502
|
|
|
356
503
|
case 11:
|
|
357
|
-
if (!
|
|
358
|
-
|
|
504
|
+
if (!_context6.t0) {
|
|
505
|
+
_context6.next = 13;
|
|
359
506
|
break;
|
|
360
507
|
}
|
|
361
508
|
|
|
362
|
-
return
|
|
509
|
+
return _context6.abrupt("return", {
|
|
363
510
|
data: [],
|
|
364
511
|
success: false,
|
|
365
512
|
total: 0
|
|
366
513
|
});
|
|
367
514
|
|
|
368
515
|
case 13:
|
|
369
|
-
|
|
516
|
+
_context6.next = 15;
|
|
370
517
|
return service.load(param);
|
|
371
518
|
|
|
372
519
|
case 15:
|
|
373
|
-
result =
|
|
520
|
+
result = _context6.sent;
|
|
374
521
|
result.data = result.rows;
|
|
375
522
|
result.success = true;
|
|
376
|
-
return
|
|
523
|
+
return _context6.abrupt("return", result);
|
|
377
524
|
|
|
378
525
|
case 19:
|
|
379
526
|
case "end":
|
|
380
|
-
return
|
|
527
|
+
return _context6.stop();
|
|
381
528
|
}
|
|
382
529
|
}
|
|
383
|
-
},
|
|
530
|
+
}, _callee6);
|
|
384
531
|
}));
|
|
385
532
|
|
|
386
|
-
return function onLoad(
|
|
387
|
-
return
|
|
533
|
+
return function onLoad(_x5, _x6, _x7) {
|
|
534
|
+
return _ref6.apply(this, arguments);
|
|
388
535
|
};
|
|
389
536
|
}();
|
|
390
537
|
|
|
391
538
|
var onExport = /*#__PURE__*/function () {
|
|
392
|
-
var
|
|
539
|
+
var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(url, param) {
|
|
393
540
|
var _param$exportColumns;
|
|
394
541
|
|
|
395
|
-
var _result$
|
|
542
|
+
var _result$flag4, result, _result$flag5, _result$flag6;
|
|
396
543
|
|
|
397
|
-
return _regeneratorRuntime.wrap(function
|
|
544
|
+
return _regeneratorRuntime.wrap(function _callee7$(_context7) {
|
|
398
545
|
while (1) {
|
|
399
|
-
switch (
|
|
546
|
+
switch (_context7.prev = _context7.next) {
|
|
400
547
|
case 0:
|
|
401
548
|
if ((_param$exportColumns = param.exportColumns) === null || _param$exportColumns === void 0 ? void 0 : _param$exportColumns.length) {
|
|
402
|
-
|
|
549
|
+
_context7.next = 3;
|
|
403
550
|
break;
|
|
404
551
|
}
|
|
405
552
|
|
|
406
553
|
showWarn('请选择要导出的列');
|
|
407
|
-
return
|
|
554
|
+
return _context7.abrupt("return", false);
|
|
408
555
|
|
|
409
556
|
case 3:
|
|
410
557
|
if (param.findUrl) {
|
|
411
|
-
|
|
558
|
+
_context7.next = 6;
|
|
412
559
|
break;
|
|
413
560
|
}
|
|
414
561
|
|
|
415
562
|
showWarn('请配置业务接口 bizApi 属性');
|
|
416
|
-
return
|
|
563
|
+
return _context7.abrupt("return", false);
|
|
417
564
|
|
|
418
565
|
case 6:
|
|
419
|
-
|
|
420
|
-
|
|
566
|
+
_context7.prev = 6;
|
|
567
|
+
_context7.next = 9;
|
|
421
568
|
return httpPost(url, param);
|
|
422
569
|
|
|
423
570
|
case 9:
|
|
424
|
-
result =
|
|
571
|
+
result = _context7.sent;
|
|
425
572
|
|
|
426
|
-
if (!(((_result$
|
|
427
|
-
|
|
573
|
+
if (!(((_result$flag4 = result.flag) === null || _result$flag4 === void 0 ? void 0 : _result$flag4.retCode) === '0')) {
|
|
574
|
+
_context7.next = 15;
|
|
428
575
|
break;
|
|
429
576
|
}
|
|
430
577
|
|
|
431
|
-
showSuccess(((_result$
|
|
432
|
-
return
|
|
578
|
+
showSuccess(((_result$flag5 = result.flag) === null || _result$flag5 === void 0 ? void 0 : _result$flag5.retMsg) || '导出成功');
|
|
579
|
+
return _context7.abrupt("return", true);
|
|
433
580
|
|
|
434
581
|
case 15:
|
|
435
|
-
showError(((_result$
|
|
436
|
-
return
|
|
582
|
+
showError(((_result$flag6 = result.flag) === null || _result$flag6 === void 0 ? void 0 : _result$flag6.retMsg) || '导出失败,请联系系统管理员');
|
|
583
|
+
return _context7.abrupt("return", false);
|
|
437
584
|
|
|
438
585
|
case 17:
|
|
439
|
-
|
|
586
|
+
_context7.next = 24;
|
|
440
587
|
break;
|
|
441
588
|
|
|
442
589
|
case 19:
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
console.log(
|
|
446
|
-
showError(
|
|
447
|
-
return
|
|
590
|
+
_context7.prev = 19;
|
|
591
|
+
_context7.t0 = _context7["catch"](6);
|
|
592
|
+
console.log(_context7.t0);
|
|
593
|
+
showError(_context7.t0.message);
|
|
594
|
+
return _context7.abrupt("return", false);
|
|
448
595
|
|
|
449
596
|
case 24:
|
|
450
597
|
case "end":
|
|
451
|
-
return
|
|
598
|
+
return _context7.stop();
|
|
452
599
|
}
|
|
453
600
|
}
|
|
454
|
-
},
|
|
601
|
+
}, _callee7, null, [[6, 19]]);
|
|
455
602
|
}));
|
|
456
603
|
|
|
457
|
-
return function onExport(
|
|
458
|
-
return
|
|
604
|
+
return function onExport(_x8, _x9) {
|
|
605
|
+
return _ref7.apply(this, arguments);
|
|
459
606
|
};
|
|
460
607
|
}();
|
|
461
608
|
|
|
462
|
-
var
|
|
609
|
+
var btnDisabled = function btnDisabled(key) {
|
|
610
|
+
if (btnStatus && typeof btnStatus(key) === 'boolean') return btnStatus(key);
|
|
611
|
+
|
|
612
|
+
switch (key) {
|
|
613
|
+
case 'edit':
|
|
614
|
+
return selectedRows.length !== 1 || isAudit();
|
|
615
|
+
|
|
616
|
+
case 'remove':
|
|
617
|
+
case 'audit':
|
|
618
|
+
return selectedRows.length === 0 || isAudit();
|
|
619
|
+
|
|
620
|
+
default:
|
|
621
|
+
return false;
|
|
622
|
+
}
|
|
623
|
+
};
|
|
463
624
|
|
|
464
|
-
|
|
465
|
-
|
|
625
|
+
var isAudit = useCallback(function () {
|
|
626
|
+
if (!auditStatus || !statusField) return false;
|
|
627
|
+
if (!selectedRows.length) return false;
|
|
628
|
+
return selectedRows.findIndex(function (o) {
|
|
629
|
+
return Number(o[statusField] || 0) >= auditStatus;
|
|
630
|
+
}) > -1;
|
|
631
|
+
}, [auditStatus, statusField, selectedRows]);
|
|
632
|
+
var tableTools = useMemo(function () {
|
|
633
|
+
return [(toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.add) && checkRight(2) ? /*#__PURE__*/React.createElement(_Button, {
|
|
466
634
|
key: "add",
|
|
467
|
-
onClick:
|
|
635
|
+
onClick: function onClick() {
|
|
636
|
+
return onAdd(null);
|
|
637
|
+
},
|
|
468
638
|
icon: /*#__PURE__*/React.createElement(PlusOutlined, null)
|
|
469
|
-
}, "\u65B0\u589E"))
|
|
470
|
-
}
|
|
471
|
-
|
|
472
|
-
if (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.edit) {
|
|
473
|
-
tableTools.push( /*#__PURE__*/React.createElement(_Button, {
|
|
639
|
+
}, "\u65B0\u589E") : false, (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.edit) && checkRight(4) ? /*#__PURE__*/React.createElement(_Button, {
|
|
474
640
|
key: "edit",
|
|
475
|
-
disabled:
|
|
476
|
-
onClick:
|
|
641
|
+
disabled: btnDisabled('edit'),
|
|
642
|
+
onClick: function onClick() {
|
|
643
|
+
return onEdit(null);
|
|
644
|
+
},
|
|
477
645
|
icon: /*#__PURE__*/React.createElement(EditOutlined, null)
|
|
478
|
-
}, "\u7F16\u8F91"))
|
|
479
|
-
}
|
|
480
|
-
|
|
481
|
-
if (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.remove) {
|
|
482
|
-
tableTools.push( /*#__PURE__*/React.createElement(_Button, {
|
|
646
|
+
}, "\u7F16\u8F91") : false, (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.remove) && (checkRight(8) || checkRight(32)) ? /*#__PURE__*/React.createElement(_Button, {
|
|
483
647
|
key: "remove",
|
|
484
|
-
onClick:
|
|
648
|
+
onClick: function onClick() {
|
|
649
|
+
return onRemove(null);
|
|
650
|
+
},
|
|
485
651
|
danger: true,
|
|
486
|
-
disabled:
|
|
652
|
+
disabled: btnDisabled('remove'),
|
|
487
653
|
icon: /*#__PURE__*/React.createElement(DeleteOutlined, null)
|
|
488
|
-
}, "\u5220\u9664"))
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
654
|
+
}, "\u5220\u9664") : false, (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.audit) && checkRight(64) ? /*#__PURE__*/React.createElement(_Button, {
|
|
655
|
+
key: "audit",
|
|
656
|
+
onClick: function onClick() {
|
|
657
|
+
return onAudit(null);
|
|
658
|
+
},
|
|
659
|
+
disabled: btnDisabled('audit'),
|
|
660
|
+
icon: /*#__PURE__*/React.createElement(CheckOutlined, null)
|
|
661
|
+
}, "\u5BA1\u6838") : false, (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.import) && checkRight(128) ? /*#__PURE__*/React.createElement(_Button, {
|
|
493
662
|
key: "import",
|
|
494
663
|
onClick: function onClick() {
|
|
495
664
|
var _tableRef$current, _tableRef$current$sho;
|
|
@@ -497,11 +666,7 @@ function useSingle(inParam) {
|
|
|
497
666
|
tableRef === null || tableRef === void 0 ? void 0 : (_tableRef$current = tableRef.current) === null || _tableRef$current === void 0 ? void 0 : (_tableRef$current$sho = _tableRef$current.showImport) === null || _tableRef$current$sho === void 0 ? void 0 : _tableRef$current$sho.call(_tableRef$current);
|
|
498
667
|
},
|
|
499
668
|
icon: /*#__PURE__*/React.createElement(ImportOutlined, null)
|
|
500
|
-
}, "\u5BFC\u5165"))
|
|
501
|
-
}
|
|
502
|
-
|
|
503
|
-
if (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.export) {
|
|
504
|
-
tableTools.push( /*#__PURE__*/React.createElement(_Button, {
|
|
669
|
+
}, "\u5BFC\u5165") : false, (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.import) && checkRight(256) ? /*#__PURE__*/React.createElement(_Button, {
|
|
505
670
|
key: "export",
|
|
506
671
|
onClick: function onClick() {
|
|
507
672
|
var _tableRef$current2, _tableRef$current2$sh;
|
|
@@ -509,9 +674,10 @@ function useSingle(inParam) {
|
|
|
509
674
|
tableRef === null || tableRef === void 0 ? void 0 : (_tableRef$current2 = tableRef.current) === null || _tableRef$current2 === void 0 ? void 0 : (_tableRef$current2$sh = _tableRef$current2.showExport) === null || _tableRef$current2$sh === void 0 ? void 0 : _tableRef$current2$sh.call(_tableRef$current2);
|
|
510
675
|
},
|
|
511
676
|
icon: /*#__PURE__*/React.createElement(ExportOutlined, null)
|
|
512
|
-
}, "\u5BFC\u51FA"))
|
|
513
|
-
|
|
514
|
-
|
|
677
|
+
}, "\u5BFC\u51FA") : false].filter(function (o) {
|
|
678
|
+
return o !== false;
|
|
679
|
+
});
|
|
680
|
+
}, [selectedRows]);
|
|
515
681
|
return {
|
|
516
682
|
formRef: formRef,
|
|
517
683
|
editFormRef: editFormRef,
|
|
@@ -528,7 +694,11 @@ function useSingle(inParam) {
|
|
|
528
694
|
onLoad: onLoad,
|
|
529
695
|
onAdd: onAdd,
|
|
530
696
|
onEdit: onEdit,
|
|
531
|
-
onExport: onExport
|
|
697
|
+
onExport: onExport,
|
|
698
|
+
onAudit: onAudit,
|
|
699
|
+
resourceId: resourceId,
|
|
700
|
+
checkRight: checkRight,
|
|
701
|
+
isAudit: isAudit
|
|
532
702
|
};
|
|
533
703
|
}
|
|
534
704
|
|