ls-pro-common 1.0.7 → 1.0.10

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.
@@ -3,3 +3,27 @@
3
3
  Licensed under the MIT License (MIT), see
4
4
  http://jedwatson.github.io/classnames
5
5
  */
6
+
7
+ /*! *****************************************************************************
8
+ Copyright (c) Microsoft Corporation.
9
+
10
+ Permission to use, copy, modify, and/or distribute this software for any
11
+ purpose with or without fee is hereby granted.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
14
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
15
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
16
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
17
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
18
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19
+ PERFORMANCE OF THIS SOFTWARE.
20
+ ***************************************************************************** */
21
+
22
+ /** @license React v16.13.1
23
+ * react-is.production.min.js
24
+ *
25
+ * Copyright (c) Facebook, Inc. and its affiliates.
26
+ *
27
+ * This source code is licensed under the MIT license found in the
28
+ * LICENSE file in the root directory of this source tree.
29
+ */
@@ -0,0 +1,18 @@
1
+ /// <reference types="react" />
2
+ import type { InputProps } from 'antd';
3
+ import type { ProFormItemProps } from 'ls-pro-form';
4
+ export declare type InputTableProps = ProFormItemProps<InputProps> & {
5
+ columns: any[];
6
+ url: string;
7
+ tableHeight?: number;
8
+ tableWidth?: number;
9
+ multiple?: boolean;
10
+ name: string;
11
+ valueField: string;
12
+ textField?: string;
13
+ textName?: string;
14
+ tableConfig?: any;
15
+ onSelectChange?: (item: any) => void;
16
+ };
17
+ declare function InputTable(prop: InputTableProps): JSX.Element;
18
+ export default InputTable;
@@ -0,0 +1,225 @@
1
+ import "antd/es/input/style";
2
+ import _Input from "antd/es/input";
3
+ import "antd/es/popover/style";
4
+ import _Popover from "antd/es/popover";
5
+ import _extends from "@babel/runtime/helpers/esm/extends";
6
+ import "antd/es/button/style";
7
+ import _Button from "antd/es/button";
8
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
9
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
10
+ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
11
+ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
12
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
13
+ var _excluded = ["columns", "url", "textName", "name", "tableConfig", "tableHeight", "tableWidth", "readonly", "multiple", "valueField", "textField", "onSelectChange"],
14
+ _excluded2 = ["current", "pageSize"];
15
+ import React from "react";
16
+ import { useRef, useState, useEffect, useContext } from 'react';
17
+ import ProTable from 'ls-pro-table';
18
+ import { ProFormText, ProFormContext } from 'ls-pro-form';
19
+ import { MoreOutlined } from '@ant-design/icons';
20
+ import { httpGet } from '../http';
21
+
22
+ function InputTable(prop) {
23
+ //@ts-ignore
24
+ var _useContext = useContext(ProFormContext),
25
+ formRef = _useContext.formRef;
26
+
27
+ var tableRef = useRef();
28
+
29
+ var _useState = useState(false),
30
+ _useState2 = _slicedToArray(_useState, 2),
31
+ visible = _useState2[0],
32
+ setVisible = _useState2[1];
33
+
34
+ var _useState3 = useState([]),
35
+ _useState4 = _slicedToArray(_useState3, 2),
36
+ selectedRows = _useState4[0],
37
+ setSelectedRows = _useState4[1];
38
+
39
+ var _useState5 = useState(''),
40
+ _useState6 = _slicedToArray(_useState5, 2),
41
+ text = _useState6[0],
42
+ setText = _useState6[1];
43
+
44
+ var columns = prop.columns,
45
+ url = prop.url,
46
+ textName = prop.textName,
47
+ name = prop.name,
48
+ tableConfig = prop.tableConfig,
49
+ _prop$tableHeight = prop.tableHeight,
50
+ tableHeight = _prop$tableHeight === void 0 ? 400 : _prop$tableHeight,
51
+ _prop$tableWidth = prop.tableWidth,
52
+ tableWidth = _prop$tableWidth === void 0 ? 650 : _prop$tableWidth,
53
+ _prop$readonly = prop.readonly,
54
+ readonly = _prop$readonly === void 0 ? true : _prop$readonly,
55
+ multiple = prop.multiple,
56
+ valueField = prop.valueField,
57
+ textField = prop.textField,
58
+ onSelectChange = prop.onSelectChange,
59
+ rest = _objectWithoutProperties(prop, _excluded);
60
+
61
+ var textNameProp = textName || name + '__text';
62
+
63
+ var loadData = /*#__PURE__*/function () {
64
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(param) {
65
+ var current, pageSize, rest, data, result;
66
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
67
+ while (1) {
68
+ switch (_context.prev = _context.next) {
69
+ case 0:
70
+ current = param.current, pageSize = param.pageSize, rest = _objectWithoutProperties(param, _excluded2);
71
+ data = {
72
+ page: current,
73
+ pageSize: pageSize
74
+ };
75
+
76
+ if (Object.keys(rest).length) {
77
+ data.where = rest;
78
+ }
79
+
80
+ _context.next = 5;
81
+ return httpGet(url, data);
82
+
83
+ case 5:
84
+ result = _context.sent;
85
+ return _context.abrupt("return", {
86
+ data: result.rows || [],
87
+ total: result.total || 0,
88
+ success: true
89
+ });
90
+
91
+ case 7:
92
+ case "end":
93
+ return _context.stop();
94
+ }
95
+ }
96
+ }, _callee);
97
+ }));
98
+
99
+ return function loadData(_x) {
100
+ return _ref.apply(this, arguments);
101
+ };
102
+ }();
103
+
104
+ useEffect(function () {
105
+ var _formRef$current;
106
+
107
+ var formValue = formRef === null || formRef === void 0 ? void 0 : (_formRef$current = formRef.current) === null || _formRef$current === void 0 ? void 0 : _formRef$current.getFieldsValue();
108
+ var txt = formValue[textField || valueField];
109
+
110
+ if (txt) {
111
+ setText(txt);
112
+ }
113
+ }, []);
114
+ var tableDom = /*#__PURE__*/React.createElement(ProTable, _extends({
115
+ columns: columns,
116
+ request: loadData,
117
+ rowKey: valueField,
118
+ manualRequest: false,
119
+ actionRef: tableRef,
120
+ search: {
121
+ labelWidth: 70
122
+ },
123
+ options: {
124
+ density: false,
125
+ reload: false,
126
+ setting: false
127
+ },
128
+ form: {
129
+ submitter: {
130
+ resetButtonProps: false
131
+ }
132
+ },
133
+ height: 'full',
134
+ rowSelection: {
135
+ type: multiple ? 'checkbox' : 'radio',
136
+ onChange: function onChange(keys, rows) {
137
+ setSelectedRows(rows);
138
+ }
139
+ },
140
+ tableAlertRender: false,
141
+ onRow: function onRow(record) {
142
+ return {
143
+ onDoubleClick: function onDoubleClick() {
144
+ var _formRef$current2, _formRef$current3;
145
+
146
+ var formValue = formRef === null || formRef === void 0 ? void 0 : (_formRef$current2 = formRef.current) === null || _formRef$current2 === void 0 ? void 0 : _formRef$current2.getFieldsValue();
147
+ formValue[name] = record[valueField];
148
+ setText(record[textField || valueField]); // 如果需要接收名称(指定了名称属性名),则反回名称
149
+
150
+ if (textName) {
151
+ formValue[textNameProp] = record[textField || valueField];
152
+ }
153
+
154
+ (_formRef$current3 = formRef.current) === null || _formRef$current3 === void 0 ? void 0 : _formRef$current3.setFieldsValue(_objectSpread({}, formValue));
155
+ setVisible(false);
156
+ onSelectChange === null || onSelectChange === void 0 ? void 0 : onSelectChange(record);
157
+ }
158
+ };
159
+ },
160
+ toolBarRender: function toolBarRender() {
161
+ return [/*#__PURE__*/React.createElement(_Button, {
162
+ onClick: function onClick() {
163
+ if (selectedRows.length) {
164
+ var _formRef$current4, _formRef$current5;
165
+
166
+ var formValue = formRef === null || formRef === void 0 ? void 0 : (_formRef$current4 = formRef.current) === null || _formRef$current4 === void 0 ? void 0 : _formRef$current4.getFieldsValue();
167
+ formValue[name] = selectedRows.map(function (o) {
168
+ return o[valueField];
169
+ }).join(',');
170
+ var txt = selectedRows.map(function (o) {
171
+ return o[textField || valueField];
172
+ }).join(',');
173
+ setText(txt); // 如果需要接收名称,则反回名称
174
+
175
+ if (textName) {
176
+ formValue[textNameProp] = txt;
177
+ }
178
+
179
+ (_formRef$current5 = formRef.current) === null || _formRef$current5 === void 0 ? void 0 : _formRef$current5.setFieldsValue(_objectSpread({}, formValue));
180
+ }
181
+
182
+ setVisible(false);
183
+ }
184
+ }, "\u786E\u8BA4")];
185
+ },
186
+ headerTitle: "\u53CC\u51FB\u8FD4\u56DE\u5F53\u524D\u884C\u6570\u636E"
187
+ }, tableConfig));
188
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
189
+ style: {
190
+ display: 'none'
191
+ }
192
+ }, /*#__PURE__*/React.createElement(ProFormText, {
193
+ name: name
194
+ })), /*#__PURE__*/React.createElement(ProFormText, _extends({
195
+ name: textNameProp
196
+ }, rest), /*#__PURE__*/React.createElement(_Input, {
197
+ suffix: /*#__PURE__*/React.createElement(_Popover, {
198
+ content: /*#__PURE__*/React.createElement("div", {
199
+ style: {
200
+ width: tableWidth + 'px',
201
+ height: tableHeight + 'px',
202
+ maxHeight: '95vh',
203
+ overflow: 'auto'
204
+ }
205
+ }, tableDom),
206
+ trigger: "click",
207
+ visible: visible,
208
+ onVisibleChange: setVisible
209
+ }, /*#__PURE__*/React.createElement(MoreOutlined, null)),
210
+ onClick: function onClick() {
211
+ return setVisible(true);
212
+ },
213
+ onInput: function onInput(e) {
214
+ var _formRef$current6;
215
+
216
+ var formValue = formRef === null || formRef === void 0 ? void 0 : (_formRef$current6 = formRef.current) === null || _formRef$current6 === void 0 ? void 0 : _formRef$current6.getFieldsValue();
217
+ formValue[name] = e.target.value;
218
+ formRef.current.setFieldsValue(_objectSpread({}, formValue));
219
+ },
220
+ readOnly: readonly,
221
+ value: text
222
+ })));
223
+ }
224
+
225
+ export default InputTable;
@@ -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;
@@ -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) {
@@ -608,6 +680,11 @@ function useDtl(dtlParam) {
608
680
  if (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.import) {
609
681
  tableTools.push( /*#__PURE__*/React.createElement(_Button, {
610
682
  key: "import",
683
+ onClick: function onClick() {
684
+ var _tableRef$current, _tableRef$current$sho;
685
+
686
+ 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);
687
+ },
611
688
  icon: /*#__PURE__*/React.createElement(ImportOutlined, null)
612
689
  }, "\u5BFC\u5165"));
613
690
  }
@@ -615,6 +692,11 @@ function useDtl(dtlParam) {
615
692
  if (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.export) {
616
693
  tableTools.push( /*#__PURE__*/React.createElement(_Button, {
617
694
  key: "export",
695
+ onClick: function onClick() {
696
+ var _tableRef$current2, _tableRef$current2$sh;
697
+
698
+ 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);
699
+ },
618
700
  icon: /*#__PURE__*/React.createElement(ExportOutlined, null)
619
701
  }, "\u5BFC\u51FA"));
620
702
  }
@@ -636,7 +718,8 @@ function useDtl(dtlParam) {
636
718
  onAddDtl: onAddDtl,
637
719
  onEditDtl: onEditDtl,
638
720
  onSaveMst: onSaveMst,
639
- onRemoveMst: onRemoveMst
721
+ onRemoveMst: onRemoveMst,
722
+ onExportDtl: onExportDtl
640
723
  };
641
724
  }
642
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,5 +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>;
40
+ onExport: (url: string, param: exportParam) => Promise<boolean>;
39
41
  };
40
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.next = 9;
206
+ _context3.prev = 7;
207
+ _context3.next = 10;
207
208
  return service.remove(ids);
208
209
 
209
- case 9:
210
+ case 10:
210
211
  result = _context3.sent;
211
212
 
212
213
  if (!afterRemove) {
213
- _context3.next = 13;
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 13:
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
- case 14:
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.next = 3;
258
+ _context4.prev = 1;
259
+ _context4.next = 4;
251
260
  return service.save(data);
252
261
 
253
- case 3:
262
+ case 4:
254
263
  result = _context4.sent;
255
264
 
256
265
  if (!afterSave) {
257
- _context4.next = 8;
266
+ _context4.next = 9;
258
267
  break;
259
268
  }
260
269
 
261
- _context4.next = 7;
270
+ _context4.next = 8;
262
271
  return afterSave(result, data);
263
272
 
264
- case 7:
273
+ case 8:
265
274
  return _context4.abrupt("return", _context4.sent);
266
275
 
267
- case 8:
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 = 12;
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 12:
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 13:
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) {
@@ -370,6 +388,77 @@ function useSingle(inParam) {
370
388
  };
371
389
  }();
372
390
 
391
+ var onExport = /*#__PURE__*/function () {
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
+
397
+ return _regeneratorRuntime.wrap(function _callee6$(_context6) {
398
+ while (1) {
399
+ switch (_context6.prev = _context6.next) {
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) || '导出成功');
432
+ return _context6.abrupt("return", true);
433
+
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:
450
+ case "end":
451
+ return _context6.stop();
452
+ }
453
+ }
454
+ }, _callee6, null, [[6, 19]]);
455
+ }));
456
+
457
+ return function onExport(_x5, _x6) {
458
+ return _ref6.apply(this, arguments);
459
+ };
460
+ }();
461
+
373
462
  var tableTools = [];
374
463
 
375
464
  if (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.add) {
@@ -402,6 +491,11 @@ function useSingle(inParam) {
402
491
  if (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.import) {
403
492
  tableTools.push( /*#__PURE__*/React.createElement(_Button, {
404
493
  key: "import",
494
+ onClick: function onClick() {
495
+ var _tableRef$current, _tableRef$current$sho;
496
+
497
+ 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
+ },
405
499
  icon: /*#__PURE__*/React.createElement(ImportOutlined, null)
406
500
  }, "\u5BFC\u5165"));
407
501
  }
@@ -409,6 +503,11 @@ function useSingle(inParam) {
409
503
  if (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.export) {
410
504
  tableTools.push( /*#__PURE__*/React.createElement(_Button, {
411
505
  key: "export",
506
+ onClick: function onClick() {
507
+ var _tableRef$current2, _tableRef$current2$sh;
508
+
509
+ 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
+ },
412
511
  icon: /*#__PURE__*/React.createElement(ExportOutlined, null)
413
512
  }, "\u5BFC\u51FA"));
414
513
  }
@@ -428,7 +527,8 @@ function useSingle(inParam) {
428
527
  onSave: onSave,
429
528
  onLoad: onLoad,
430
529
  onAdd: onAdd,
431
- onEdit: onEdit
530
+ onEdit: onEdit,
531
+ onExport: onExport
432
532
  };
433
533
  }
434
534
 
package/es/http/index.js CHANGED
@@ -2,7 +2,7 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
2
2
  import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
3
3
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
4
4
  import { extend } from 'umi-request';
5
- import { getCache, getUrlQuery, showError } from '../utils'; //默认超时时间为1分钟
5
+ import { getCache, getUrlQuery, showError, toGatewayUrl } from '../utils'; //默认超时时间为1分钟
6
6
 
7
7
  var request = extend({
8
8
  timeout: 60000
@@ -23,7 +23,7 @@ request.interceptors.request.use(function (url, options) {
23
23
  }
24
24
 
25
25
  return {
26
- url: url,
26
+ url: toGatewayUrl(url),
27
27
  options: opts
28
28
  };
29
29
  });