ls-pro-common 3.0.96 → 3.0.98

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.
Files changed (58) hide show
  1. package/dist/common.css +63 -0
  2. package/dist/common.js +1 -1
  3. package/dist/common.less +2 -1
  4. package/dist/common.min.css +63 -0
  5. package/dist/common.min.js +1 -1
  6. package/es/components/AreaCascader.js +5 -8
  7. package/es/components/AreaCascaderPanel.js +5 -9
  8. package/es/components/InputTable.js +87 -61
  9. package/es/components/ProButton/index.d.ts +10 -0
  10. package/es/components/ProButton/index.js +40 -0
  11. package/es/components/RecordLog/index.d.ts +16 -0
  12. package/es/components/RecordLog/index.js +114 -0
  13. package/es/components/RecordLog/index.less +71 -0
  14. package/es/hooks/useMdm.d.ts +7 -0
  15. package/es/hooks/useMdm.js +47 -0
  16. package/es/http/index.d.ts +2 -1
  17. package/es/http/index.js +16 -9
  18. package/es/http/mdmRequest.d.ts +184 -0
  19. package/es/http/mdmRequest.js +351 -0
  20. package/es/index.d.ts +6 -2
  21. package/es/index.js +6 -2
  22. package/es/utils/array.d.ts +26 -0
  23. package/es/utils/array.js +74 -0
  24. package/es/utils/format.d.ts +82 -0
  25. package/es/utils/format.js +148 -0
  26. package/es/utils/index.d.ts +19 -125
  27. package/es/utils/index.js +21 -478
  28. package/es/utils/modal.d.ts +43 -0
  29. package/es/utils/modal.js +225 -0
  30. package/es/utils/size.d.ts +9 -0
  31. package/es/utils/size.js +81 -0
  32. package/lib/components/AreaCascader.js +5 -8
  33. package/lib/components/AreaCascaderPanel.js +5 -9
  34. package/lib/components/InputTable.js +87 -61
  35. package/lib/components/ProButton/index.d.ts +10 -0
  36. package/lib/components/ProButton/index.js +40 -0
  37. package/lib/components/RecordLog/index.d.ts +16 -0
  38. package/lib/components/RecordLog/index.js +114 -0
  39. package/lib/components/RecordLog/index.less +71 -0
  40. package/lib/hooks/useMdm.d.ts +7 -0
  41. package/lib/hooks/useMdm.js +47 -0
  42. package/lib/http/index.d.ts +2 -1
  43. package/lib/http/index.js +16 -9
  44. package/lib/http/mdmRequest.d.ts +184 -0
  45. package/lib/http/mdmRequest.js +351 -0
  46. package/lib/index.d.ts +6 -2
  47. package/lib/index.js +6 -2
  48. package/lib/utils/array.d.ts +26 -0
  49. package/lib/utils/array.js +74 -0
  50. package/lib/utils/format.d.ts +82 -0
  51. package/lib/utils/format.js +148 -0
  52. package/lib/utils/index.d.ts +19 -125
  53. package/lib/utils/index.js +21 -478
  54. package/lib/utils/modal.d.ts +43 -0
  55. package/lib/utils/modal.js +225 -0
  56. package/lib/utils/size.d.ts +9 -0
  57. package/lib/utils/size.js +81 -0
  58. package/package.json +4 -2
@@ -0,0 +1,225 @@
1
+ import "antd/es/spin/style";
2
+ import _Spin from "antd/es/spin";
3
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
4
+ import "antd/es/modal/style";
5
+ import _Modal from "antd/es/modal";
6
+ import "antd/es/message/style";
7
+ import _message from "antd/es/message";
8
+ import React from "react";
9
+ import ReactDOM from 'react-dom';
10
+ import { QuestionCircleOutlined } from '@ant-design/icons';
11
+ _message.config({
12
+ maxCount: 1
13
+ });
14
+ /** @name 获取全屏元素 */
15
+ export var getFullScreenElement = function getFullScreenElement() {
16
+ //@ts-ignore
17
+ return document.fullscreenElement ||
18
+ //@ts-ignore
19
+ document.mozFullScreenElement ||
20
+ //@ts-ignore
21
+ document.msFullScreenElement ||
22
+ //@ts-ignore
23
+ document.webkitFullscreenElement || undefined;
24
+ };
25
+ /** @name 显示错误 */
26
+ export var showError = function showError(text) {
27
+ var duration = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 3;
28
+ if (!text) {
29
+ text = '出错了!!';
30
+ }
31
+ _message.error({
32
+ content: text,
33
+ duration: duration,
34
+ getPopupContainer: function getPopupContainer(e) {
35
+ return getFullScreenElement() || document.body;
36
+ },
37
+ onClick: function onClick(e) {
38
+ var _e$target;
39
+ var tag = (_e$target = e.target) === null || _e$target === void 0 ? void 0 : _e$target.tagName.toLowerCase();
40
+ if (tag === 'img' || tag === 'path' || tag === 'svg') {
41
+ try {
42
+ _message.destroy();
43
+ } catch (e) {}
44
+ try {
45
+ var _e$target2, _e$target2$closest;
46
+ var msg = (_e$target2 = e.target) === null || _e$target2 === void 0 ? void 0 : (_e$target2$closest = _e$target2.closest('.ant-message')) === null || _e$target2$closest === void 0 ? void 0 : _e$target2$closest.parentNode;
47
+ if (msg) {
48
+ var _msg$parentNode;
49
+ (_msg$parentNode = msg.parentNode) === null || _msg$parentNode === void 0 ? void 0 : _msg$parentNode.removeChild(msg);
50
+ }
51
+ } catch (e) {}
52
+ }
53
+ }
54
+ });
55
+ };
56
+ /** @name 显示警示 */
57
+ export var showWarn = function showWarn(text) {
58
+ var duration = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 3;
59
+ if (!text) {
60
+ text = '请注意!';
61
+ }
62
+ _message.warn({
63
+ content: text,
64
+ duration: duration,
65
+ getPopupContainer: function getPopupContainer(e) {
66
+ return getFullScreenElement() || document.body;
67
+ },
68
+ onClick: function onClick(e) {
69
+ var _e$target3;
70
+ var tag = (_e$target3 = e.target) === null || _e$target3 === void 0 ? void 0 : _e$target3.tagName.toLowerCase();
71
+ if (tag === 'img' || tag === 'path' || tag === 'svg') {
72
+ try {
73
+ _message.destroy();
74
+ } catch (e) {}
75
+ try {
76
+ var _e$target4, _e$target4$closest;
77
+ var msg = (_e$target4 = e.target) === null || _e$target4 === void 0 ? void 0 : (_e$target4$closest = _e$target4.closest('.ant-message')) === null || _e$target4$closest === void 0 ? void 0 : _e$target4$closest.parentNode;
78
+ if (msg) {
79
+ var _msg$parentNode2;
80
+ (_msg$parentNode2 = msg.parentNode) === null || _msg$parentNode2 === void 0 ? void 0 : _msg$parentNode2.removeChild(msg);
81
+ }
82
+ } catch (e) {}
83
+ }
84
+ }
85
+ });
86
+ };
87
+ /** @name 显示成功 */
88
+ export var showSuccess = function showSuccess(text) {
89
+ var duration = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 3;
90
+ if (!text) {
91
+ text = '操作成功!';
92
+ }
93
+ _message.success({
94
+ content: text,
95
+ duration: duration,
96
+ getPopupContainer: function getPopupContainer(e) {
97
+ return getFullScreenElement() || document.body;
98
+ },
99
+ onClick: function onClick(e) {
100
+ var _e$target5;
101
+ var tag = (_e$target5 = e.target) === null || _e$target5 === void 0 ? void 0 : _e$target5.tagName.toLowerCase();
102
+ if (tag === 'img' || tag === 'path' || tag === 'svg') {
103
+ try {
104
+ _message.destroy();
105
+ } catch (e) {}
106
+ try {
107
+ var _e$target6, _e$target6$closest;
108
+ var msg = (_e$target6 = e.target) === null || _e$target6 === void 0 ? void 0 : (_e$target6$closest = _e$target6.closest('.ant-message')) === null || _e$target6$closest === void 0 ? void 0 : _e$target6$closest.parentNode;
109
+ if (msg) {
110
+ var _msg$parentNode3;
111
+ (_msg$parentNode3 = msg.parentNode) === null || _msg$parentNode3 === void 0 ? void 0 : _msg$parentNode3.removeChild(msg);
112
+ }
113
+ } catch (e) {}
114
+ }
115
+ }
116
+ });
117
+ };
118
+ /**
119
+ * 弹框提示
120
+ *
121
+ * @param text 提示信息
122
+ * @param title 标题,默认 系统提示
123
+ * @param type 类型
124
+ * @param opts 附加参数
125
+ * @returns Promise<Boolean>
126
+ */
127
+ export var showAlert = function showAlert(text) {
128
+ var title = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '系统提示';
129
+ var type = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'error';
130
+ var opts = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
131
+ return new Promise(function (resolve, reject) {
132
+ _Modal[type](_objectSpread({
133
+ content: text,
134
+ title: title,
135
+ getContainer: getFullScreenElement() || document.body,
136
+ onOk: function onOk() {
137
+ resolve(true);
138
+ },
139
+ onCancel: function onCancel() {
140
+ reject(false);
141
+ }
142
+ }, opts));
143
+ });
144
+ };
145
+ /**
146
+ * 请求接口出错
147
+ *
148
+ * @param retMsg 错误原因
149
+ * @param retCode 错误码
150
+ * @param faultCode 故障码
151
+ * @param opts 附加参数
152
+ */
153
+ export var httpError = function httpError(retMsg, retCode, faultCode) {
154
+ var opts = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
155
+ var msg = /*#__PURE__*/React.createElement(React.Fragment, null, "\u9519\u8BEF\u539F\u56E0:", /*#__PURE__*/React.createElement("b", null, retMsg), /*#__PURE__*/React.createElement("br", null), "\u9519\u8BEF\u7801:", /*#__PURE__*/React.createElement("b", null, retCode), /*#__PURE__*/React.createElement("br", null), "\u6545\u969C\u7801:", /*#__PURE__*/React.createElement("b", null, faultCode));
156
+ return showAlert(msg, '请求接口出错', 'error', opts);
157
+ };
158
+ /** 销毁所有弹框 */
159
+ export var exitAlert = function exitAlert() {
160
+ _Modal.destroyAll();
161
+ };
162
+ /** @name 显示确认 */
163
+ export var showConfirm = function showConfirm(text) {
164
+ var title = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '系统提示';
165
+ return new Promise(function (resolve, reject) {
166
+ _Modal.confirm({
167
+ title: title,
168
+ content: text,
169
+ icon: /*#__PURE__*/React.createElement(QuestionCircleOutlined, null),
170
+ okType: 'danger',
171
+ closable: true,
172
+ cancelButtonProps: {
173
+ className: 'ant-btn-gray'
174
+ },
175
+ getContainer: getFullScreenElement() || document.body,
176
+ onOk: function onOk() {
177
+ resolve(true);
178
+ },
179
+ onCancel: function onCancel() {
180
+ reject(false);
181
+ }
182
+ });
183
+ });
184
+ };
185
+ var timeout = false;
186
+ /**
187
+ * Token过期重新登录
188
+ *
189
+ * @returns
190
+ */
191
+ export var reLogin = function reLogin() {
192
+ if (timeout) return;
193
+ timeout = true;
194
+ _Modal.warning({
195
+ title: '登录状态已过期,请重新登录',
196
+ okText: '重新登录',
197
+ maskClosable: false,
198
+ getContainer: getFullScreenElement() || document.body,
199
+ afterClose: function afterClose() {
200
+ timeout = false;
201
+ (window.top || window).location.href = location.pathname === '/' ? '/login' : '/login?redirect=' + encodeURIComponent(location.href);
202
+ }
203
+ });
204
+ };
205
+ /** 显示加载 */
206
+ export var showLoading = function showLoading() {
207
+ var text = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '处理中...';
208
+ var loading = document.getElementById('myloading');
209
+ if (loading) return;
210
+ var loadWrapper = document.createElement('div');
211
+ loadWrapper.setAttribute('id', 'myloading');
212
+ ReactDOM.render( /*#__PURE__*/React.createElement(_Spin, {
213
+ tip: text
214
+ }), loadWrapper);
215
+ var pNode = getFullScreenElement() || document.body;
216
+ pNode.appendChild(loadWrapper);
217
+ };
218
+ /** 退出加载 */
219
+ export var exitLoading = function exitLoading() {
220
+ var loading = document.getElementById('myloading');
221
+ if (loading) {
222
+ var _loading$parentNode;
223
+ (_loading$parentNode = loading.parentNode) === null || _loading$parentNode === void 0 ? void 0 : _loading$parentNode.removeChild(loading);
224
+ }
225
+ };
@@ -0,0 +1,9 @@
1
+ /**
2
+ * 处理普通的尺码横排
3
+ *
4
+ * @param orgSizeHeader 后端返回的原始尺码组表头
5
+ * @param typeWidth 尺码组宽 sizeTypeNo,默认120
6
+ * @param sizeWidth 尺码宽f1~f100, 默认100
7
+ * @returns 返回已处理好的表头[{dataIndex:sizeTypeNo,title:'国标码',width:120,children[...]},{dataIndex:'f1',...}...]
8
+ */
9
+ export declare const handleSizeCols: (orgSizeHeader: any[], typeWidth?: number, sizeWidth?: number) => any[];
@@ -0,0 +1,81 @@
1
+ /**
2
+ * 处理普通的尺码横排
3
+ *
4
+ * @param orgSizeHeader 后端返回的原始尺码组表头
5
+ * @param typeWidth 尺码组宽 sizeTypeNo,默认120
6
+ * @param sizeWidth 尺码宽f1~f100, 默认100
7
+ * @returns 返回已处理好的表头[{dataIndex:sizeTypeNo,title:'国标码',width:120,children[...]},{dataIndex:'f1',...}...]
8
+ */
9
+ export var handleSizeCols = function handleSizeCols(orgSizeHeader) {
10
+ var typeWidth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 120;
11
+ var sizeWidth = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 100;
12
+ // f1~f100 当所有尺码组都为null时,删除不需要的尺码。
13
+ var arr = orgSizeHeader.map(function (o) {
14
+ var _loop = function _loop(key) {
15
+ if (orgSizeHeader.every(function (item) {
16
+ return !item['f' + key];
17
+ })) {
18
+ delete o['f' + key];
19
+ }
20
+ };
21
+ for (var key = 1; key <= 100; key++) {
22
+ _loop(key);
23
+ }
24
+ return o;
25
+ });
26
+ // 多表头时找到最底层的表头
27
+ var findNext = function findNext(item) {
28
+ if (item.children.length) {
29
+ return findNext(item.children[0]);
30
+ }
31
+ return item;
32
+ };
33
+ var headers = []; // 用于保存返回表头
34
+ var header; // 用于保存每个配码的表头信息
35
+ arr.forEach(function (h, i) {
36
+ // 先处理尺码组
37
+ header = {
38
+ dataIndex: 'sizeTypeNo',
39
+ title: h.sizeTypeNo,
40
+ width: typeWidth,
41
+ ellipsis: true
42
+ };
43
+ //当返回多个尺码组时,需要用children支持多表头
44
+ if (arr.length > i + 1) {
45
+ header.children = [];
46
+ }
47
+ // 第一个尺码组,直接添加,第二个之后,加到上一个的children中。
48
+ if (i === 0) {
49
+ headers.push(header);
50
+ } else {
51
+ findNext(headers.find(function (o) {
52
+ return o.dataIndex === 'sizeTypeNo';
53
+ })).children.push(header);
54
+ }
55
+ // 处理 f1~f100
56
+ var _loop2 = function _loop2(k) {
57
+ if (k === 'sizeTypeNo') return "continue";
58
+ header = {
59
+ dataIndex: k,
60
+ title: h[k] || ' ',
61
+ width: sizeWidth,
62
+ ellipsis: true
63
+ };
64
+ if (arr.length > i + 1) {
65
+ header.children = [];
66
+ }
67
+ if (i === 0) {
68
+ headers.push(header);
69
+ } else {
70
+ findNext(headers.find(function (o) {
71
+ return o.dataIndex === k;
72
+ })).children.push(header);
73
+ }
74
+ };
75
+ for (var k in h) {
76
+ var _ret = _loop2(k);
77
+ if (_ret === "continue") continue;
78
+ }
79
+ });
80
+ return headers;
81
+ };
@@ -6,7 +6,7 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
6
6
  import _regeneratorRuntime from "@babel/runtime/regenerator";
7
7
  import React, { useRef, useState, useEffect, useImperativeHandle } from 'react';
8
8
  import { httpGet } from '../http';
9
- import { getCache, setCache, treeEach, isSaasVersion, toGatewayUrl } from '../utils';
9
+ import { getCache, setCache, treeEach } from '../utils';
10
10
  var AreaCascader = /*#__PURE__*/React.forwardRef(function (props, ref) {
11
11
  var _useState = useState([]),
12
12
  _useState2 = _slicedToArray(_useState, 2),
@@ -34,14 +34,11 @@ var AreaCascader = /*#__PURE__*/React.forwardRef(function (props, ref) {
34
34
  return _context.abrupt("return");
35
35
  case 4:
36
36
  api = '/petrel/petrel-location-center-api/sysAdministrativeDivision/allByTree';
37
- if (isSaasVersion()) {
38
- api = toGatewayUrl('/tenant-mdm-api/sysAdministrativeDivision/allByTree');
39
- }
40
- _context.next = 8;
37
+ _context.next = 7;
41
38
  return httpGet(api, {}, false);
42
- case 8:
39
+ case 7:
43
40
  result = _context.sent;
44
- opts = (isSaasVersion() ? result.data : result.rows) || [];
41
+ opts = result.rows || [];
45
42
  treeEach(opts, function (item) {
46
43
  item.label = item.name;
47
44
  item.value = item.id;
@@ -55,7 +52,7 @@ var AreaCascader = /*#__PURE__*/React.forwardRef(function (props, ref) {
55
52
  });
56
53
  setCache('areaOptions', opts, true);
57
54
  setOptions(opts);
58
- case 13:
55
+ case 12:
59
56
  case "end":
60
57
  return _context.stop();
61
58
  }
@@ -9,9 +9,8 @@ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
9
9
  import _regeneratorRuntime from "@babel/runtime/regenerator";
10
10
  import React, { useRef, useState, useEffect, useImperativeHandle } from 'react';
11
11
  import { httpGet } from '../http';
12
- import { getCache, setCache, treeEach, isSaasVersion } from '../utils';
12
+ import { getCache, setCache, treeEach } from '../utils';
13
13
  import './common.less';
14
- import { toGatewayUrl } from 'ls-pro-table';
15
14
  var AreaPicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
16
15
  var propsConfig = _objectSpread({
17
16
  getPopupContainer: function getPopupContainer(triggerNode) {
@@ -94,14 +93,11 @@ var AreaPicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
94
93
  return _context.abrupt("return");
95
94
  case 3:
96
95
  api = '/petrel/petrel-location-center-api/sysAdministrativeDivision/allByTree';
97
- if (isSaasVersion()) {
98
- api = toGatewayUrl('/tenant-mdm-api/sysAdministrativeDivision/allByTree');
99
- }
100
- _context.next = 7;
96
+ _context.next = 6;
101
97
  return httpGet(api, {}, false);
102
- case 7:
98
+ case 6:
103
99
  result = _context.sent;
104
- opts = (isSaasVersion() ? result.data : result.rows) || [];
100
+ opts = result.rows || [];
105
101
  treeEach(opts, function (item) {
106
102
  item.label = item.name;
107
103
  item.value = item.id;
@@ -115,7 +111,7 @@ var AreaPicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
115
111
  setCache('areaOptionsPanel', opts, true);
116
112
  setOptions(opts);
117
113
  setShowData(opts);
118
- case 13:
114
+ case 12:
119
115
  case "end":
120
116
  return _context.stop();
121
117
  }
@@ -5,11 +5,11 @@ import _Popover from "antd/es/popover";
5
5
  import _extends from "@babel/runtime/helpers/esm/extends";
6
6
  import "antd/es/button/style";
7
7
  import _Button from "antd/es/button";
8
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
8
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
9
9
  import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
10
10
  import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
11
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
11
12
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
12
- import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
13
13
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
14
14
  var _excluded = ["columns", "url", "textName", "name", "tableConfig", "tableHeight", "tableWidth", "readonly", "multiple", "valueField", "labelWidth", "textField", "onSelectChange", "beforeLoad", "afterLoad", "isV2", "allowClear", "keepSelect", "fieldProps", "searchField", "fillMap", "loadOnShow", "triggerCheck", "getPopupContainer", "placement", "arrowPointAtCenter", "rowKey", "method", "changeOnSelect", "record"],
15
15
  _excluded2 = ["current", "pageSize"];
@@ -39,11 +39,7 @@ var InputTable = /*#__PURE__*/React.forwardRef(function (prop, ref) {
39
39
  text = _useState6[0],
40
40
  setText = _useState6[1];
41
41
  var inputRef = useRef();
42
- useImperativeHandle(ref, function () {
43
- return _objectSpread(_objectSpread({}, inputRef.current), {}, {
44
- clear: handleClear
45
- });
46
- });
42
+ var initRows = useRef(null); //用于存储初始行数据
47
43
  var columns = prop.columns,
48
44
  url = prop.url,
49
45
  textName = prop.textName,
@@ -124,13 +120,51 @@ var InputTable = /*#__PURE__*/React.forwardRef(function (prop, ref) {
124
120
  if (col) return col.searchField || col.dataIndex;
125
121
  return textField || valueField;
126
122
  }, [columns, searchField, valueField, textField]);
123
+ var getFormValue = function getFormValue() {
124
+ var _formRef$current2, _formRef$current2$get;
125
+ if (rowKey) {
126
+ var _formRef$current, _formRef$current$getF, _formRef$current$getF2;
127
+ return formRef === null || formRef === void 0 ? void 0 : (_formRef$current = formRef.current) === null || _formRef$current === void 0 ? void 0 : (_formRef$current$getF = _formRef$current.getFieldsValue) === null || _formRef$current$getF === void 0 ? void 0 : (_formRef$current$getF2 = _formRef$current$getF.call(_formRef$current)) === null || _formRef$current$getF2 === void 0 ? void 0 : _formRef$current$getF2[rowKey];
128
+ }
129
+ return formRef === null || formRef === void 0 ? void 0 : (_formRef$current2 = formRef.current) === null || _formRef$current2 === void 0 ? void 0 : (_formRef$current2$get = _formRef$current2.getFieldsValue) === null || _formRef$current2$get === void 0 ? void 0 : _formRef$current2$get.call(_formRef$current2);
130
+ };
131
+ var setFormValue = function setFormValue(formValue) {
132
+ if (rowKey) {
133
+ var _formRef$current3, _formRef$current3$set;
134
+ formRef === null || formRef === void 0 ? void 0 : (_formRef$current3 = formRef.current) === null || _formRef$current3 === void 0 ? void 0 : (_formRef$current3$set = _formRef$current3.setFieldsValue) === null || _formRef$current3$set === void 0 ? void 0 : _formRef$current3$set.call(_formRef$current3, _defineProperty({}, rowKey, formValue));
135
+ } else {
136
+ var _formRef$current4, _formRef$current4$set;
137
+ formRef === null || formRef === void 0 ? void 0 : (_formRef$current4 = formRef.current) === null || _formRef$current4 === void 0 ? void 0 : (_formRef$current4$set = _formRef$current4.setFieldsValue) === null || _formRef$current4$set === void 0 ? void 0 : _formRef$current4$set.call(_formRef$current4, formValue);
138
+ }
139
+ };
127
140
  var loadData = /*#__PURE__*/function () {
128
141
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(param) {
129
- var current, pageSize, restParams, data, _tableRef$current, _tableRef$current$cle, result, rows, formValue, val, _selectRowRef$current, arr, pageSelectedRows;
142
+ var current, pageSize, restParams, _selectRowRef$current, _rows, data, _tableRef$current2, _tableRef$current2$cl, result, rows, formValue, val, _selectRowRef$current2, arr, pageSelectedRows;
130
143
  return _regeneratorRuntime.wrap(function _callee$(_context) {
131
144
  while (1) switch (_context.prev = _context.next) {
132
145
  case 0:
133
- current = param.current, pageSize = param.pageSize, restParams = _objectWithoutProperties(param, _excluded2);
146
+ current = param.current, pageSize = param.pageSize, restParams = _objectWithoutProperties(param, _excluded2); //如果精灵框初始有值(用于编辑页面)先把初始值加载到第一页,才能默认选中。
147
+ if (!(visible && multiple && Array.isArray(initRows.current))) {
148
+ _context.next = 9;
149
+ break;
150
+ }
151
+ _rows = initRows.current;
152
+ initRows.current = null;
153
+ (_selectRowRef$current = selectRowRef.current).push.apply(_selectRowRef$current, _toConsumableArray(_rows));
154
+ selectedKeys.push.apply(selectedKeys, _toConsumableArray(_rows.map(function (o) {
155
+ return o[tableKey];
156
+ })));
157
+ setSelectedKeys(Array.from(new Set(selectedKeys)));
158
+ setTimeout(function () {
159
+ var _tableRef$current, _tableRef$current$rel;
160
+ (_tableRef$current = tableRef.current) === null || _tableRef$current === void 0 ? void 0 : (_tableRef$current$rel = _tableRef$current.reload) === null || _tableRef$current$rel === void 0 ? void 0 : _tableRef$current$rel.call(_tableRef$current);
161
+ }, 0);
162
+ return _context.abrupt("return", {
163
+ data: _rows,
164
+ total: _rows.length,
165
+ success: true
166
+ });
167
+ case 9:
134
168
  data = {};
135
169
  if (isV2) {
136
170
  data['page.pn'] = current;
@@ -146,27 +180,27 @@ var InputTable = /*#__PURE__*/React.forwardRef(function (prop, ref) {
146
180
  }
147
181
  if (!keepSelect) {
148
182
  selectRowRef.current = [];
149
- (_tableRef$current = tableRef.current) === null || _tableRef$current === void 0 ? void 0 : (_tableRef$current$cle = _tableRef$current.clearSelected) === null || _tableRef$current$cle === void 0 ? void 0 : _tableRef$current$cle.call(_tableRef$current);
183
+ (_tableRef$current2 = tableRef.current) === null || _tableRef$current2 === void 0 ? void 0 : (_tableRef$current2$cl = _tableRef$current2.clearSelected) === null || _tableRef$current2$cl === void 0 ? void 0 : _tableRef$current2$cl.call(_tableRef$current2);
150
184
  }
151
185
  if (beforeLoad) {
152
186
  beforeLoad(data);
153
187
  }
154
188
  if (!(method !== 'GET')) {
155
- _context.next = 12;
189
+ _context.next = 20;
156
190
  break;
157
191
  }
158
- _context.next = 9;
192
+ _context.next = 17;
159
193
  return httpPost(url, data);
160
- case 9:
194
+ case 17:
161
195
  result = _context.sent;
162
- _context.next = 15;
196
+ _context.next = 23;
163
197
  break;
164
- case 12:
165
- _context.next = 14;
198
+ case 20:
199
+ _context.next = 22;
166
200
  return httpGet(url, data);
167
- case 14:
201
+ case 22:
168
202
  result = _context.sent;
169
- case 15:
203
+ case 23:
170
204
  rows = (result.rows || []).filter(function (o) {
171
205
  return o;
172
206
  });
@@ -187,7 +221,7 @@ var InputTable = /*#__PURE__*/React.forwardRef(function (prop, ref) {
187
221
  return o[valueField] === row[valueField];
188
222
  });
189
223
  });
190
- (_selectRowRef$current = selectRowRef.current).push.apply(_selectRowRef$current, _toConsumableArray(pageSelectedRows));
224
+ (_selectRowRef$current2 = selectRowRef.current).push.apply(_selectRowRef$current2, _toConsumableArray(pageSelectedRows));
191
225
  selectedKeys.push.apply(selectedKeys, _toConsumableArray(pageSelectedRows.map(function (o) {
192
226
  return o[tableKey];
193
227
  })));
@@ -199,7 +233,7 @@ var InputTable = /*#__PURE__*/React.forwardRef(function (prop, ref) {
199
233
  total: Number(result.total || 0),
200
234
  success: true
201
235
  });
202
- case 19:
236
+ case 27:
203
237
  case "end":
204
238
  return _context.stop();
205
239
  }
@@ -209,40 +243,6 @@ var InputTable = /*#__PURE__*/React.forwardRef(function (prop, ref) {
209
243
  return _ref.apply(this, arguments);
210
244
  };
211
245
  }();
212
- var getFormValue = function getFormValue() {
213
- var _formRef$current2, _formRef$current2$get;
214
- if (rowKey) {
215
- var _formRef$current, _formRef$current$getF, _formRef$current$getF2;
216
- return formRef === null || formRef === void 0 ? void 0 : (_formRef$current = formRef.current) === null || _formRef$current === void 0 ? void 0 : (_formRef$current$getF = _formRef$current.getFieldsValue) === null || _formRef$current$getF === void 0 ? void 0 : (_formRef$current$getF2 = _formRef$current$getF.call(_formRef$current)) === null || _formRef$current$getF2 === void 0 ? void 0 : _formRef$current$getF2[rowKey];
217
- }
218
- return formRef === null || formRef === void 0 ? void 0 : (_formRef$current2 = formRef.current) === null || _formRef$current2 === void 0 ? void 0 : (_formRef$current2$get = _formRef$current2.getFieldsValue) === null || _formRef$current2$get === void 0 ? void 0 : _formRef$current2$get.call(_formRef$current2);
219
- };
220
- var setFormValue = function setFormValue(formValue) {
221
- if (rowKey) {
222
- var _formRef$current3, _formRef$current3$set;
223
- formRef === null || formRef === void 0 ? void 0 : (_formRef$current3 = formRef.current) === null || _formRef$current3 === void 0 ? void 0 : (_formRef$current3$set = _formRef$current3.setFieldsValue) === null || _formRef$current3$set === void 0 ? void 0 : _formRef$current3$set.call(_formRef$current3, _defineProperty({}, rowKey, formValue));
224
- } else {
225
- var _formRef$current4, _formRef$current4$set;
226
- formRef === null || formRef === void 0 ? void 0 : (_formRef$current4 = formRef.current) === null || _formRef$current4 === void 0 ? void 0 : (_formRef$current4$set = _formRef$current4.setFieldsValue) === null || _formRef$current4$set === void 0 ? void 0 : _formRef$current4$set.call(_formRef$current4, formValue);
227
- }
228
- };
229
- // 初始化数据,主要设置名称
230
- useEffect(function () {
231
- var _formValue$textNamePr, _formValue$name;
232
- var formValue = getFormValue();
233
- if (!formValue) return;
234
- var txt = (_formValue$textNamePr = formValue === null || formValue === void 0 ? void 0 : formValue[textNameProp]) !== null && _formValue$textNamePr !== void 0 ? _formValue$textNamePr : record === null || record === void 0 ? void 0 : record[textNameProp];
235
- var val = (_formValue$name = formValue === null || formValue === void 0 ? void 0 : formValue[name]) !== null && _formValue$name !== void 0 ? _formValue$name : record === null || record === void 0 ? void 0 : record[name];
236
- setText(txt !== null && txt !== void 0 ? txt : val);
237
- if (val && !txt) {
238
- formValue[textNameProp] = val;
239
- setFormValue(formValue);
240
- // 多值选择或选择的初始值不在第一页时显示有问题
241
- if (textField !== valueField) {
242
- initName(val);
243
- }
244
- }
245
- }, [rowKey]);
246
246
  var initName = function initName(val) {
247
247
  var _columns$find;
248
248
  if (!val) return;
@@ -251,14 +251,18 @@ var InputTable = /*#__PURE__*/React.forwardRef(function (prop, ref) {
251
251
  })) === null || _columns$find === void 0 ? void 0 : _columns$find.searchField) || valueField;
252
252
  var param = {
253
253
  current: 1,
254
- pageSize: 10
254
+ pageSize: 1000
255
255
  };
256
256
  if (Array.isArray(val)) val = val.join(',');
257
257
  if (val.toString().includes(',')) {
258
258
  fieldName += '_in';
259
259
  }
260
+ if (isV2) {
261
+ fieldName = 'search.' + fieldName;
262
+ }
260
263
  param[fieldName] = val;
261
264
  loadData(param).then(function (result) {
265
+ initRows.current = result.data;
262
266
  var rows = (result.data || []).filter(function (o) {
263
267
  return o;
264
268
  });
@@ -272,6 +276,23 @@ var InputTable = /*#__PURE__*/React.forwardRef(function (prop, ref) {
272
276
  setFormValue(formValue);
273
277
  });
274
278
  };
279
+ // 初始化数据,主要设置名称
280
+ useEffect(function () {
281
+ var _formValue$textNamePr, _formValue$name;
282
+ var formValue = getFormValue();
283
+ if (!formValue) return;
284
+ var txt = (_formValue$textNamePr = formValue === null || formValue === void 0 ? void 0 : formValue[textNameProp]) !== null && _formValue$textNamePr !== void 0 ? _formValue$textNamePr : record === null || record === void 0 ? void 0 : record[textNameProp];
285
+ var val = (_formValue$name = formValue === null || formValue === void 0 ? void 0 : formValue[name]) !== null && _formValue$name !== void 0 ? _formValue$name : record === null || record === void 0 ? void 0 : record[name];
286
+ setText(txt !== null && txt !== void 0 ? txt : val);
287
+ if (val && !txt) {
288
+ formValue[textNameProp] = val;
289
+ setFormValue(formValue);
290
+ // 多值选择或选择的初始值不在第一页时显示有问题
291
+ if (textField !== valueField) {
292
+ initName(val);
293
+ }
294
+ }
295
+ }, [rowKey]);
275
296
  // 处理返回数据
276
297
  var handleValue = function handleValue(row) {
277
298
  var close = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
@@ -320,10 +341,10 @@ var InputTable = /*#__PURE__*/React.forwardRef(function (prop, ref) {
320
341
  }
321
342
  };
322
343
  var handleClear = function handleClear() {
323
- var _tableRef$current2, _tableRef$current2$cl;
344
+ var _tableRef$current3, _tableRef$current3$cl;
324
345
  selectRowRef.current = [];
325
346
  setSelectedKeys([]);
326
- (_tableRef$current2 = tableRef.current) === null || _tableRef$current2 === void 0 ? void 0 : (_tableRef$current2$cl = _tableRef$current2.clearSelected) === null || _tableRef$current2$cl === void 0 ? void 0 : _tableRef$current2$cl.call(_tableRef$current2);
347
+ (_tableRef$current3 = tableRef.current) === null || _tableRef$current3 === void 0 ? void 0 : (_tableRef$current3$cl = _tableRef$current3.clearSelected) === null || _tableRef$current3$cl === void 0 ? void 0 : _tableRef$current3$cl.call(_tableRef$current3);
327
348
  setText('');
328
349
  var formValue = getFormValue();
329
350
  if (!formValue) return;
@@ -376,17 +397,22 @@ var InputTable = /*#__PURE__*/React.forwardRef(function (prop, ref) {
376
397
  }
377
398
  }
378
399
  };
400
+ useImperativeHandle(ref, function () {
401
+ return _objectSpread(_objectSpread({}, inputRef.current), {}, {
402
+ clear: handleClear
403
+ });
404
+ });
379
405
  useEffect(function () {
380
406
  if (!text && multiple) {
381
- var _tableRef$current3, _tableRef$current3$cl;
407
+ var _tableRef$current4, _tableRef$current4$cl;
382
408
  selectRowRef.current = [];
383
- (_tableRef$current3 = tableRef.current) === null || _tableRef$current3 === void 0 ? void 0 : (_tableRef$current3$cl = _tableRef$current3.clearSelected) === null || _tableRef$current3$cl === void 0 ? void 0 : _tableRef$current3$cl.call(_tableRef$current3);
409
+ (_tableRef$current4 = tableRef.current) === null || _tableRef$current4 === void 0 ? void 0 : (_tableRef$current4$cl = _tableRef$current4.clearSelected) === null || _tableRef$current4$cl === void 0 ? void 0 : _tableRef$current4$cl.call(_tableRef$current4);
384
410
  }
385
411
  }, [text, multiple]);
386
412
  useEffect(function () {
387
413
  if (visible && loadOnShow) {
388
- var _tableRef$current4, _tableRef$current4$re;
389
- (_tableRef$current4 = tableRef.current) === null || _tableRef$current4 === void 0 ? void 0 : (_tableRef$current4$re = _tableRef$current4.reload) === null || _tableRef$current4$re === void 0 ? void 0 : _tableRef$current4$re.call(_tableRef$current4);
414
+ var _tableRef$current5, _tableRef$current5$re;
415
+ (_tableRef$current5 = tableRef.current) === null || _tableRef$current5 === void 0 ? void 0 : (_tableRef$current5$re = _tableRef$current5.reload) === null || _tableRef$current5$re === void 0 ? void 0 : _tableRef$current5$re.call(_tableRef$current5);
390
416
  }
391
417
  }, [visible, loadOnShow]);
392
418
  var tableDom = /*#__PURE__*/React.createElement(ProTable, _extends({
@@ -0,0 +1,10 @@
1
+ /** @name 防抖按钮 */
2
+ /// <reference types="react" />
3
+ import { type ButtonProps, TooltipProps } from 'antd';
4
+ export interface ProButtonProps extends ButtonProps {
5
+ /** @name 防抖时间,默认为300ms */
6
+ time?: number;
7
+ tip?: JSX.Element | string;
8
+ tipProps?: TooltipProps;
9
+ }
10
+ export default function ProButton(props: ProButtonProps): JSX.Element;