ls-pro-common 1.0.8 → 1.0.11
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/hooks/useDtl/index.d.ts +2 -0
- package/es/hooks/useDtl/index.js +75 -2
- package/es/hooks/useSingle/index.d.ts +2 -1
- package/es/hooks/useSingle/index.js +91 -23
- package/es/utils/index.d.ts +1 -22
- package/es/utils/index.js +3 -65
- package/lib/hooks/useDtl/index.d.ts +2 -0
- package/lib/hooks/useDtl/index.js +75 -1
- package/lib/hooks/useSingle/index.d.ts +2 -1
- package/lib/hooks/useSingle/index.js +91 -22
- package/lib/utils/index.d.ts +1 -22
- package/lib/utils/index.js +32 -79
- package/package.json +3 -3
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ActionType } from 'ls-pro-table';
|
|
2
|
+
import type { exportParam } from 'ls-pro-table/lib/components/Export';
|
|
2
3
|
import type { ProFormInstance } from 'ls-pro-form';
|
|
3
4
|
import type { SingleParamType } from '../useSingle';
|
|
4
5
|
export declare type DtlParamType = SingleParamType & {
|
|
@@ -25,5 +26,6 @@ declare function useDtl(dtlParam: DtlParamType): {
|
|
|
25
26
|
onEditDtl: () => Promise<boolean>;
|
|
26
27
|
onSaveMst: (values: any) => Promise<void>;
|
|
27
28
|
onRemoveMst: () => Promise<boolean | undefined>;
|
|
29
|
+
onExportDtl: (url: string, param: exportParam) => Promise<boolean>;
|
|
28
30
|
};
|
|
29
31
|
export default useDtl;
|
package/es/hooks/useDtl/index.js
CHANGED
|
@@ -9,7 +9,8 @@ var _excluded = ["current", "pageSize"];
|
|
|
9
9
|
import React from "react";
|
|
10
10
|
import { useState, useRef } from 'react';
|
|
11
11
|
import { PlusOutlined, EditOutlined, DeleteOutlined, ImportOutlined, ExportOutlined } from '@ant-design/icons';
|
|
12
|
-
import { showConfirm, showWarn, showSuccess } from '../../utils';
|
|
12
|
+
import { showConfirm, showWarn, showError, showSuccess } from '../../utils';
|
|
13
|
+
import { httpPost } from '../../http';
|
|
13
14
|
|
|
14
15
|
function useDtl(dtlParam) {
|
|
15
16
|
var mstService = dtlParam.service,
|
|
@@ -576,6 +577,77 @@ function useDtl(dtlParam) {
|
|
|
576
577
|
};
|
|
577
578
|
}();
|
|
578
579
|
|
|
580
|
+
var onExportDtl = /*#__PURE__*/function () {
|
|
581
|
+
var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(url, param) {
|
|
582
|
+
var _param$exportColumns;
|
|
583
|
+
|
|
584
|
+
var _result$flag5, result, _result$flag6, _result$flag7;
|
|
585
|
+
|
|
586
|
+
return _regeneratorRuntime.wrap(function _callee8$(_context8) {
|
|
587
|
+
while (1) {
|
|
588
|
+
switch (_context8.prev = _context8.next) {
|
|
589
|
+
case 0:
|
|
590
|
+
if ((_param$exportColumns = param.exportColumns) === null || _param$exportColumns === void 0 ? void 0 : _param$exportColumns.length) {
|
|
591
|
+
_context8.next = 3;
|
|
592
|
+
break;
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
showWarn('请选择要导出的列');
|
|
596
|
+
return _context8.abrupt("return", false);
|
|
597
|
+
|
|
598
|
+
case 3:
|
|
599
|
+
if (param.findUrl) {
|
|
600
|
+
_context8.next = 6;
|
|
601
|
+
break;
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
showWarn('请配置业务接口 bizApi 属性');
|
|
605
|
+
return _context8.abrupt("return", false);
|
|
606
|
+
|
|
607
|
+
case 6:
|
|
608
|
+
_context8.prev = 6;
|
|
609
|
+
_context8.next = 9;
|
|
610
|
+
return httpPost(url, param);
|
|
611
|
+
|
|
612
|
+
case 9:
|
|
613
|
+
result = _context8.sent;
|
|
614
|
+
|
|
615
|
+
if (!(((_result$flag5 = result.flag) === null || _result$flag5 === void 0 ? void 0 : _result$flag5.retCode) === '0')) {
|
|
616
|
+
_context8.next = 15;
|
|
617
|
+
break;
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
showSuccess(((_result$flag6 = result.flag) === null || _result$flag6 === void 0 ? void 0 : _result$flag6.retMsg) || '导出成功');
|
|
621
|
+
return _context8.abrupt("return", true);
|
|
622
|
+
|
|
623
|
+
case 15:
|
|
624
|
+
showError(((_result$flag7 = result.flag) === null || _result$flag7 === void 0 ? void 0 : _result$flag7.retMsg) || '导出失败,请联系系统管理员');
|
|
625
|
+
return _context8.abrupt("return", false);
|
|
626
|
+
|
|
627
|
+
case 17:
|
|
628
|
+
_context8.next = 24;
|
|
629
|
+
break;
|
|
630
|
+
|
|
631
|
+
case 19:
|
|
632
|
+
_context8.prev = 19;
|
|
633
|
+
_context8.t0 = _context8["catch"](6);
|
|
634
|
+
console.log(_context8.t0);
|
|
635
|
+
showError(_context8.t0.message);
|
|
636
|
+
return _context8.abrupt("return", false);
|
|
637
|
+
|
|
638
|
+
case 24:
|
|
639
|
+
case "end":
|
|
640
|
+
return _context8.stop();
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
}, _callee8, null, [[6, 19]]);
|
|
644
|
+
}));
|
|
645
|
+
|
|
646
|
+
return function onExportDtl(_x6, _x7) {
|
|
647
|
+
return _ref8.apply(this, arguments);
|
|
648
|
+
};
|
|
649
|
+
}();
|
|
650
|
+
|
|
579
651
|
var tableTools = [];
|
|
580
652
|
|
|
581
653
|
if (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.add) {
|
|
@@ -646,7 +718,8 @@ function useDtl(dtlParam) {
|
|
|
646
718
|
onAddDtl: onAddDtl,
|
|
647
719
|
onEditDtl: onEditDtl,
|
|
648
720
|
onSaveMst: onSaveMst,
|
|
649
|
-
onRemoveMst: onRemoveMst
|
|
721
|
+
onRemoveMst: onRemoveMst,
|
|
722
|
+
onExportDtl: onExportDtl
|
|
650
723
|
};
|
|
651
724
|
}
|
|
652
725
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ActionType } from 'ls-pro-table';
|
|
2
|
+
import type { exportParam } from 'ls-pro-table/lib/components/Export';
|
|
2
3
|
import type { ProFormInstance } from 'ls-pro-form';
|
|
3
4
|
import type { ApiResponse, TableToolbar } from '../../typing';
|
|
4
5
|
export declare type SingleParamType = {
|
|
@@ -36,6 +37,6 @@ declare function useSingle(inParam: SingleParamType): {
|
|
|
36
37
|
onLoad: (params: Record<string, any>, sort: Record<string, any>, filter: Record<string, any>) => Promise<any>;
|
|
37
38
|
onAdd: () => Promise<void>;
|
|
38
39
|
onEdit: () => Promise<void>;
|
|
39
|
-
onExport: (url: string, param:
|
|
40
|
+
onExport: (url: string, param: exportParam) => Promise<boolean>;
|
|
40
41
|
};
|
|
41
42
|
export default useSingle;
|
|
@@ -9,7 +9,8 @@ var _excluded = ["current", "pageSize"];
|
|
|
9
9
|
import React from "react";
|
|
10
10
|
import { useState, useRef } from 'react';
|
|
11
11
|
import { PlusOutlined, EditOutlined, DeleteOutlined, ImportOutlined, ExportOutlined } from '@ant-design/icons';
|
|
12
|
-
import { showConfirm, showWarn, showSuccess } from '../../utils';
|
|
12
|
+
import { showConfirm, showWarn, showSuccess, showError } from '../../utils';
|
|
13
|
+
import { httpPost } from '../../http';
|
|
13
14
|
/**
|
|
14
15
|
* 单表基本增删改查 hooks
|
|
15
16
|
* @param service 单表服务
|
|
@@ -171,9 +172,8 @@ function useSingle(inParam) {
|
|
|
171
172
|
}
|
|
172
173
|
|
|
173
174
|
showConfirm('确认要删除选择的数据?').then( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
174
|
-
var _result$flag;
|
|
175
|
+
var ids, _result$flag, result;
|
|
175
176
|
|
|
176
|
-
var ids, result;
|
|
177
177
|
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
178
178
|
while (1) {
|
|
179
179
|
switch (_context3.prev = _context3.next) {
|
|
@@ -203,21 +203,22 @@ function useSingle(inParam) {
|
|
|
203
203
|
});
|
|
204
204
|
}
|
|
205
205
|
|
|
206
|
-
_context3.
|
|
206
|
+
_context3.prev = 7;
|
|
207
|
+
_context3.next = 10;
|
|
207
208
|
return service.remove(ids);
|
|
208
209
|
|
|
209
|
-
case
|
|
210
|
+
case 10:
|
|
210
211
|
result = _context3.sent;
|
|
211
212
|
|
|
212
213
|
if (!afterRemove) {
|
|
213
|
-
_context3.next =
|
|
214
|
+
_context3.next = 14;
|
|
214
215
|
break;
|
|
215
216
|
}
|
|
216
217
|
|
|
217
218
|
afterRemove(result, selectedRows);
|
|
218
219
|
return _context3.abrupt("return");
|
|
219
220
|
|
|
220
|
-
case
|
|
221
|
+
case 14:
|
|
221
222
|
if ((result === null || result === void 0 ? void 0 : (_result$flag = result.flag) === null || _result$flag === void 0 ? void 0 : _result$flag.retCode) === '0') {
|
|
222
223
|
showSuccess(result.flag.retMsg);
|
|
223
224
|
|
|
@@ -226,12 +227,20 @@ function useSingle(inParam) {
|
|
|
226
227
|
}
|
|
227
228
|
}
|
|
228
229
|
|
|
229
|
-
|
|
230
|
+
_context3.next = 20;
|
|
231
|
+
break;
|
|
232
|
+
|
|
233
|
+
case 17:
|
|
234
|
+
_context3.prev = 17;
|
|
235
|
+
_context3.t0 = _context3["catch"](7);
|
|
236
|
+
console.log(_context3.t0);
|
|
237
|
+
|
|
238
|
+
case 20:
|
|
230
239
|
case "end":
|
|
231
240
|
return _context3.stop();
|
|
232
241
|
}
|
|
233
242
|
}
|
|
234
|
-
}, _callee3);
|
|
243
|
+
}, _callee3, null, [[7, 17]]);
|
|
235
244
|
})));
|
|
236
245
|
};
|
|
237
246
|
/** 新增,更改对应的保存事件 */
|
|
@@ -239,34 +248,34 @@ function useSingle(inParam) {
|
|
|
239
248
|
|
|
240
249
|
var onSave = /*#__PURE__*/function () {
|
|
241
250
|
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(formData) {
|
|
242
|
-
var _result$flag2;
|
|
251
|
+
var data, _result$flag2, result;
|
|
243
252
|
|
|
244
|
-
var data, result;
|
|
245
253
|
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
246
254
|
while (1) {
|
|
247
255
|
switch (_context4.prev = _context4.next) {
|
|
248
256
|
case 0:
|
|
249
257
|
data = _objectSpread(_objectSpread({}, editItem), formData);
|
|
250
|
-
_context4.
|
|
258
|
+
_context4.prev = 1;
|
|
259
|
+
_context4.next = 4;
|
|
251
260
|
return service.save(data);
|
|
252
261
|
|
|
253
|
-
case
|
|
262
|
+
case 4:
|
|
254
263
|
result = _context4.sent;
|
|
255
264
|
|
|
256
265
|
if (!afterSave) {
|
|
257
|
-
_context4.next =
|
|
266
|
+
_context4.next = 9;
|
|
258
267
|
break;
|
|
259
268
|
}
|
|
260
269
|
|
|
261
|
-
_context4.next =
|
|
270
|
+
_context4.next = 8;
|
|
262
271
|
return afterSave(result, data);
|
|
263
272
|
|
|
264
|
-
case
|
|
273
|
+
case 8:
|
|
265
274
|
return _context4.abrupt("return", _context4.sent);
|
|
266
275
|
|
|
267
|
-
case
|
|
276
|
+
case 9:
|
|
268
277
|
if (!((result === null || result === void 0 ? void 0 : (_result$flag2 = result.flag) === null || _result$flag2 === void 0 ? void 0 : _result$flag2.retCode) === '0')) {
|
|
269
|
-
_context4.next =
|
|
278
|
+
_context4.next = 13;
|
|
270
279
|
break;
|
|
271
280
|
}
|
|
272
281
|
|
|
@@ -278,15 +287,24 @@ function useSingle(inParam) {
|
|
|
278
287
|
|
|
279
288
|
return _context4.abrupt("return", true);
|
|
280
289
|
|
|
281
|
-
case
|
|
290
|
+
case 13:
|
|
291
|
+
_context4.next = 18;
|
|
292
|
+
break;
|
|
293
|
+
|
|
294
|
+
case 15:
|
|
295
|
+
_context4.prev = 15;
|
|
296
|
+
_context4.t0 = _context4["catch"](1);
|
|
297
|
+
console.log(_context4.t0);
|
|
298
|
+
|
|
299
|
+
case 18:
|
|
282
300
|
return _context4.abrupt("return", false);
|
|
283
301
|
|
|
284
|
-
case
|
|
302
|
+
case 19:
|
|
285
303
|
case "end":
|
|
286
304
|
return _context4.stop();
|
|
287
305
|
}
|
|
288
306
|
}
|
|
289
|
-
}, _callee4);
|
|
307
|
+
}, _callee4, null, [[1, 15]]);
|
|
290
308
|
}));
|
|
291
309
|
|
|
292
310
|
return function onSave(_x) {
|
|
@@ -372,18 +390,68 @@ function useSingle(inParam) {
|
|
|
372
390
|
|
|
373
391
|
var onExport = /*#__PURE__*/function () {
|
|
374
392
|
var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(url, param) {
|
|
393
|
+
var _param$exportColumns;
|
|
394
|
+
|
|
395
|
+
var _result$flag3, result, _result$flag4, _result$flag5;
|
|
396
|
+
|
|
375
397
|
return _regeneratorRuntime.wrap(function _callee6$(_context6) {
|
|
376
398
|
while (1) {
|
|
377
399
|
switch (_context6.prev = _context6.next) {
|
|
378
400
|
case 0:
|
|
401
|
+
if ((_param$exportColumns = param.exportColumns) === null || _param$exportColumns === void 0 ? void 0 : _param$exportColumns.length) {
|
|
402
|
+
_context6.next = 3;
|
|
403
|
+
break;
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
showWarn('请选择要导出的列');
|
|
407
|
+
return _context6.abrupt("return", false);
|
|
408
|
+
|
|
409
|
+
case 3:
|
|
410
|
+
if (param.findUrl) {
|
|
411
|
+
_context6.next = 6;
|
|
412
|
+
break;
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
showWarn('请配置业务接口 bizApi 属性');
|
|
416
|
+
return _context6.abrupt("return", false);
|
|
417
|
+
|
|
418
|
+
case 6:
|
|
419
|
+
_context6.prev = 6;
|
|
420
|
+
_context6.next = 9;
|
|
421
|
+
return httpPost(url, param);
|
|
422
|
+
|
|
423
|
+
case 9:
|
|
424
|
+
result = _context6.sent;
|
|
425
|
+
|
|
426
|
+
if (!(((_result$flag3 = result.flag) === null || _result$flag3 === void 0 ? void 0 : _result$flag3.retCode) === '0')) {
|
|
427
|
+
_context6.next = 15;
|
|
428
|
+
break;
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
showSuccess(((_result$flag4 = result.flag) === null || _result$flag4 === void 0 ? void 0 : _result$flag4.retMsg) || '导出成功');
|
|
379
432
|
return _context6.abrupt("return", true);
|
|
380
433
|
|
|
381
|
-
case
|
|
434
|
+
case 15:
|
|
435
|
+
showError(((_result$flag5 = result.flag) === null || _result$flag5 === void 0 ? void 0 : _result$flag5.retMsg) || '导出失败,请联系系统管理员');
|
|
436
|
+
return _context6.abrupt("return", false);
|
|
437
|
+
|
|
438
|
+
case 17:
|
|
439
|
+
_context6.next = 24;
|
|
440
|
+
break;
|
|
441
|
+
|
|
442
|
+
case 19:
|
|
443
|
+
_context6.prev = 19;
|
|
444
|
+
_context6.t0 = _context6["catch"](6);
|
|
445
|
+
console.log(_context6.t0);
|
|
446
|
+
showError(_context6.t0.message);
|
|
447
|
+
return _context6.abrupt("return", false);
|
|
448
|
+
|
|
449
|
+
case 24:
|
|
382
450
|
case "end":
|
|
383
451
|
return _context6.stop();
|
|
384
452
|
}
|
|
385
453
|
}
|
|
386
|
-
}, _callee6);
|
|
454
|
+
}, _callee6, null, [[6, 19]]);
|
|
387
455
|
}));
|
|
388
456
|
|
|
389
457
|
return function onExport(_x5, _x6) {
|
package/es/utils/index.d.ts
CHANGED
|
@@ -1,18 +1,4 @@
|
|
|
1
|
-
export
|
|
2
|
-
/**
|
|
3
|
-
* 设置url传参
|
|
4
|
-
* @param {*} url
|
|
5
|
-
* @param {*} keyvals
|
|
6
|
-
* @returns
|
|
7
|
-
*/
|
|
8
|
-
export declare const setUrlQuery: (url: string, keyvals?: Record<string, any>) => string;
|
|
9
|
-
/**
|
|
10
|
-
* 给 url 添加网关
|
|
11
|
-
* @param url 原url,以 / 打头
|
|
12
|
-
* @param defGateway 默认网关 /petrel
|
|
13
|
-
* @returns
|
|
14
|
-
*/
|
|
15
|
-
export declare const toGatewayUrl: (url: string, defGateway?: string) => string;
|
|
1
|
+
export { getUrlQuery, setUrlQuery, dateFormat, toGatewayUrl } from 'ls-pro-table/lib/utils';
|
|
16
2
|
/**
|
|
17
3
|
* 设置文档title
|
|
18
4
|
* @param {*} title
|
|
@@ -49,13 +35,6 @@ export declare const setCache: (key: string, data: any) => void;
|
|
|
49
35
|
* @returns 关键字对应的值
|
|
50
36
|
*/
|
|
51
37
|
export declare const getCache: any;
|
|
52
|
-
/**
|
|
53
|
-
* 简单日期格式化
|
|
54
|
-
* @param {*} dt 传入时间参数,若不传取当前时间
|
|
55
|
-
* @param {*} showTime 是否返回当前时间,默认返回时间
|
|
56
|
-
* @returns xxxx年-xx月-xx日 [xx时:xx分:xx秒]
|
|
57
|
-
*/
|
|
58
|
-
export declare const dateFormat: (dt: Date | undefined | null, showTime?: boolean) => string;
|
|
59
38
|
/** @name 显示错误 */
|
|
60
39
|
export declare const showError: (text: string) => void;
|
|
61
40
|
/** @name 显示警示 */
|
package/es/utils/index.js
CHANGED
|
@@ -6,51 +6,7 @@ import _message from "antd/es/message";
|
|
|
6
6
|
import _typeof from "@babel/runtime/helpers/esm/typeof";
|
|
7
7
|
import React from "react";
|
|
8
8
|
import { QuestionCircleOutlined } from '@ant-design/icons';
|
|
9
|
-
export
|
|
10
|
-
var url = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : location.search.substr(1) || '';
|
|
11
|
-
var reg = new RegExp('(^|[&|?])' + name + '=([^&]*)(&|$)'),
|
|
12
|
-
r = url.match(reg);
|
|
13
|
-
if (r != null) return unescape(decodeURI(r[2]));
|
|
14
|
-
return '';
|
|
15
|
-
};
|
|
16
|
-
/**
|
|
17
|
-
* 设置url传参
|
|
18
|
-
* @param {*} url
|
|
19
|
-
* @param {*} keyvals
|
|
20
|
-
* @returns
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
export var setUrlQuery = function setUrlQuery(url) {
|
|
24
|
-
var keyvals = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
25
|
-
var newUrl = url;
|
|
26
|
-
|
|
27
|
-
for (var name in keyvals) {
|
|
28
|
-
var reg = new RegExp('(^|)' + name + '=([^&]*)(|$)');
|
|
29
|
-
var tmp = name + '=' + keyvals[name];
|
|
30
|
-
|
|
31
|
-
if (newUrl.match(reg) != null) {
|
|
32
|
-
// @ts-ignore
|
|
33
|
-
newUrl = newUrl.replace(eval(reg), tmp);
|
|
34
|
-
} else {
|
|
35
|
-
newUrl = newUrl + (newUrl.match('[\?]') ? '&' : '?') + tmp;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return newUrl;
|
|
40
|
-
};
|
|
41
|
-
/**
|
|
42
|
-
* 给 url 添加网关
|
|
43
|
-
* @param url 原url,以 / 打头
|
|
44
|
-
* @param defGateway 默认网关 /petrel
|
|
45
|
-
* @returns
|
|
46
|
-
*/
|
|
47
|
-
|
|
48
|
-
export var toGatewayUrl = function toGatewayUrl(url) {
|
|
49
|
-
var defGateway = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '/petrel';
|
|
50
|
-
if (url.startsWith('http://') || url.startsWith('https://') || url.startsWith('//')) return url;
|
|
51
|
-
var gateway = getUrlQuery('gateway') || location.origin + defGateway;
|
|
52
|
-
return gateway + url;
|
|
53
|
-
};
|
|
9
|
+
export { getUrlQuery, setUrlQuery, dateFormat, toGatewayUrl } from "ls-pro-table/es/utils";
|
|
54
10
|
/**
|
|
55
11
|
* 设置文档title
|
|
56
12
|
* @param {*} title
|
|
@@ -126,24 +82,6 @@ export var getCache = function getCache(key) {
|
|
|
126
82
|
|
|
127
83
|
return data;
|
|
128
84
|
};
|
|
129
|
-
/**
|
|
130
|
-
* 简单日期格式化
|
|
131
|
-
* @param {*} dt 传入时间参数,若不传取当前时间
|
|
132
|
-
* @param {*} showTime 是否返回当前时间,默认返回时间
|
|
133
|
-
* @returns xxxx年-xx月-xx日 [xx时:xx分:xx秒]
|
|
134
|
-
*/
|
|
135
|
-
|
|
136
|
-
export var dateFormat = function dateFormat(dt) {
|
|
137
|
-
var showTime = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
138
|
-
var ct = dt ? dt : new Date(Date.now());
|
|
139
|
-
var str = ct.getFullYear() + '-' + ('' + (ct.getMonth() + 1)).padStart(2, '0') + '-' + ('' + ct.getDate()).padStart(2, '0');
|
|
140
|
-
|
|
141
|
-
if (showTime) {
|
|
142
|
-
str += ' ' + (ct.getHours() + '').padStart(2, '0') + ':' + (ct.getMinutes() + '').padStart(2, '0') + ":" + (ct.getSeconds() + '').padStart(2, '0');
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
return str;
|
|
146
|
-
};
|
|
147
85
|
/** @name 显示错误 */
|
|
148
86
|
|
|
149
87
|
export var showError = function showError(text) {
|
|
@@ -229,9 +167,9 @@ export var treeEach = function treeEach(list, fn) {
|
|
|
229
167
|
list.forEach(function (item, index) {
|
|
230
168
|
fn(item, index, list); // @ts-ignore
|
|
231
169
|
|
|
232
|
-
if (Array.isArray(
|
|
170
|
+
if (Array.isArray(item[children]) && item[children].length) {
|
|
233
171
|
// @ts-ignore
|
|
234
|
-
treeEach(
|
|
172
|
+
treeEach(item[children], fn, children);
|
|
235
173
|
}
|
|
236
174
|
});
|
|
237
175
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ActionType } from 'ls-pro-table';
|
|
2
|
+
import type { exportParam } from 'ls-pro-table/lib/components/Export';
|
|
2
3
|
import type { ProFormInstance } from 'ls-pro-form';
|
|
3
4
|
import type { SingleParamType } from '../useSingle';
|
|
4
5
|
export declare type DtlParamType = SingleParamType & {
|
|
@@ -25,5 +26,6 @@ declare function useDtl(dtlParam: DtlParamType): {
|
|
|
25
26
|
onEditDtl: () => Promise<boolean>;
|
|
26
27
|
onSaveMst: (values: any) => Promise<void>;
|
|
27
28
|
onRemoveMst: () => Promise<boolean | undefined>;
|
|
29
|
+
onExportDtl: (url: string, param: exportParam) => Promise<boolean>;
|
|
28
30
|
};
|
|
29
31
|
export default useDtl;
|
|
@@ -29,6 +29,8 @@ var _icons = require("@ant-design/icons");
|
|
|
29
29
|
|
|
30
30
|
var _utils = require("../../utils");
|
|
31
31
|
|
|
32
|
+
var _http = require("../../http");
|
|
33
|
+
|
|
32
34
|
var _excluded = ["current", "pageSize"];
|
|
33
35
|
|
|
34
36
|
function useDtl(dtlParam) {
|
|
@@ -596,6 +598,77 @@ function useDtl(dtlParam) {
|
|
|
596
598
|
};
|
|
597
599
|
}();
|
|
598
600
|
|
|
601
|
+
var onExportDtl = /*#__PURE__*/function () {
|
|
602
|
+
var _ref8 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee8(url, param) {
|
|
603
|
+
var _param$exportColumns;
|
|
604
|
+
|
|
605
|
+
var _result$flag5, result, _result$flag6, _result$flag7;
|
|
606
|
+
|
|
607
|
+
return _regenerator.default.wrap(function _callee8$(_context8) {
|
|
608
|
+
while (1) {
|
|
609
|
+
switch (_context8.prev = _context8.next) {
|
|
610
|
+
case 0:
|
|
611
|
+
if ((_param$exportColumns = param.exportColumns) === null || _param$exportColumns === void 0 ? void 0 : _param$exportColumns.length) {
|
|
612
|
+
_context8.next = 3;
|
|
613
|
+
break;
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
(0, _utils.showWarn)('请选择要导出的列');
|
|
617
|
+
return _context8.abrupt("return", false);
|
|
618
|
+
|
|
619
|
+
case 3:
|
|
620
|
+
if (param.findUrl) {
|
|
621
|
+
_context8.next = 6;
|
|
622
|
+
break;
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
(0, _utils.showWarn)('请配置业务接口 bizApi 属性');
|
|
626
|
+
return _context8.abrupt("return", false);
|
|
627
|
+
|
|
628
|
+
case 6:
|
|
629
|
+
_context8.prev = 6;
|
|
630
|
+
_context8.next = 9;
|
|
631
|
+
return (0, _http.httpPost)(url, param);
|
|
632
|
+
|
|
633
|
+
case 9:
|
|
634
|
+
result = _context8.sent;
|
|
635
|
+
|
|
636
|
+
if (!(((_result$flag5 = result.flag) === null || _result$flag5 === void 0 ? void 0 : _result$flag5.retCode) === '0')) {
|
|
637
|
+
_context8.next = 15;
|
|
638
|
+
break;
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
(0, _utils.showSuccess)(((_result$flag6 = result.flag) === null || _result$flag6 === void 0 ? void 0 : _result$flag6.retMsg) || '导出成功');
|
|
642
|
+
return _context8.abrupt("return", true);
|
|
643
|
+
|
|
644
|
+
case 15:
|
|
645
|
+
(0, _utils.showError)(((_result$flag7 = result.flag) === null || _result$flag7 === void 0 ? void 0 : _result$flag7.retMsg) || '导出失败,请联系系统管理员');
|
|
646
|
+
return _context8.abrupt("return", false);
|
|
647
|
+
|
|
648
|
+
case 17:
|
|
649
|
+
_context8.next = 24;
|
|
650
|
+
break;
|
|
651
|
+
|
|
652
|
+
case 19:
|
|
653
|
+
_context8.prev = 19;
|
|
654
|
+
_context8.t0 = _context8["catch"](6);
|
|
655
|
+
console.log(_context8.t0);
|
|
656
|
+
(0, _utils.showError)(_context8.t0.message);
|
|
657
|
+
return _context8.abrupt("return", false);
|
|
658
|
+
|
|
659
|
+
case 24:
|
|
660
|
+
case "end":
|
|
661
|
+
return _context8.stop();
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
}, _callee8, null, [[6, 19]]);
|
|
665
|
+
}));
|
|
666
|
+
|
|
667
|
+
return function onExportDtl(_x6, _x7) {
|
|
668
|
+
return _ref8.apply(this, arguments);
|
|
669
|
+
};
|
|
670
|
+
}();
|
|
671
|
+
|
|
599
672
|
var tableTools = [];
|
|
600
673
|
|
|
601
674
|
if (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.add) {
|
|
@@ -666,7 +739,8 @@ function useDtl(dtlParam) {
|
|
|
666
739
|
onAddDtl: onAddDtl,
|
|
667
740
|
onEditDtl: onEditDtl,
|
|
668
741
|
onSaveMst: onSaveMst,
|
|
669
|
-
onRemoveMst: onRemoveMst
|
|
742
|
+
onRemoveMst: onRemoveMst,
|
|
743
|
+
onExportDtl: onExportDtl
|
|
670
744
|
};
|
|
671
745
|
}
|
|
672
746
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ActionType } from 'ls-pro-table';
|
|
2
|
+
import type { exportParam } from 'ls-pro-table/lib/components/Export';
|
|
2
3
|
import type { ProFormInstance } from 'ls-pro-form';
|
|
3
4
|
import type { ApiResponse, TableToolbar } from '../../typing';
|
|
4
5
|
export declare type SingleParamType = {
|
|
@@ -36,6 +37,6 @@ declare function useSingle(inParam: SingleParamType): {
|
|
|
36
37
|
onLoad: (params: Record<string, any>, sort: Record<string, any>, filter: Record<string, any>) => Promise<any>;
|
|
37
38
|
onAdd: () => Promise<void>;
|
|
38
39
|
onEdit: () => Promise<void>;
|
|
39
|
-
onExport: (url: string, param:
|
|
40
|
+
onExport: (url: string, param: exportParam) => Promise<boolean>;
|
|
40
41
|
};
|
|
41
42
|
export default useSingle;
|