ls-pro-common 3.0.89 → 3.0.91
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/InputMultiLine.js +15 -25
- package/es/components/InputTable.d.ts +1 -1
- package/es/components/InputTable.js +127 -166
- package/es/http/index.js +13 -8
- package/lib/components/InputMultiLine.js +15 -25
- package/lib/components/InputTable.d.ts +1 -1
- package/lib/components/InputTable.js +127 -166
- package/lib/http/index.js +13 -8
- package/package.json +1 -1
|
@@ -7,7 +7,7 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
|
7
7
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
8
8
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
9
9
|
var _excluded = ["name", "rows", "maxRows", "placement", "popWidth", "fieldProps", "defaultValue", "allowClear", "getPopupContainer", "textAreaProps", "value", "label", "textareaPlaceholder", "onChange"];
|
|
10
|
-
import React, { useRef, useState, useEffect, useContext,
|
|
10
|
+
import React, { useRef, useState, useEffect, useContext, useImperativeHandle } from 'react';
|
|
11
11
|
import { ProFormText, ProFormContext } from 'ls-pro-form';
|
|
12
12
|
import { UnorderedListOutlined } from '@ant-design/icons';
|
|
13
13
|
var InputMultiLine = /*#__PURE__*/React.forwardRef(function (prop, ref) {
|
|
@@ -76,13 +76,13 @@ var InputMultiLine = /*#__PURE__*/React.forwardRef(function (prop, ref) {
|
|
|
76
76
|
_onChange === null || _onChange === void 0 ? void 0 : _onChange(val);
|
|
77
77
|
setValue(val);
|
|
78
78
|
};
|
|
79
|
-
var
|
|
80
|
-
|
|
79
|
+
var InputDom = /*#__PURE__*/React.createElement(_Input, _extends({
|
|
80
|
+
suffix: /*#__PURE__*/React.createElement(_Popover, {
|
|
81
81
|
getPopupContainer: getPopupContainer,
|
|
82
82
|
trigger: "click",
|
|
83
83
|
placement: placement,
|
|
84
|
-
|
|
85
|
-
|
|
84
|
+
open: rest.disabled || (fieldProps === null || fieldProps === void 0 ? void 0 : fieldProps.disabled) ? false : visible,
|
|
85
|
+
onOpenChange: function onOpenChange(flag) {
|
|
86
86
|
setVisible(flag);
|
|
87
87
|
if (flag) {
|
|
88
88
|
var _textareaRef$current;
|
|
@@ -128,32 +128,22 @@ var InputMultiLine = /*#__PURE__*/React.forwardRef(function (prop, ref) {
|
|
|
128
128
|
if (rest.readonly || rest.disabled) return;
|
|
129
129
|
setVisible(true);
|
|
130
130
|
}
|
|
131
|
-
}))
|
|
132
|
-
}, [visible, popWidth, lineText, value, name, label, rest]);
|
|
133
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, label && name ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ProFormText, _extends({
|
|
134
|
-
name: name,
|
|
135
|
-
label: label
|
|
136
|
-
}, rest), /*#__PURE__*/React.createElement(_Input, _extends({
|
|
137
|
-
suffix: PopoverDom,
|
|
131
|
+
})),
|
|
138
132
|
placeholder: (fieldProps === null || fieldProps === void 0 ? void 0 : fieldProps.placeholder) || '请输入',
|
|
139
133
|
allowClear: allowClear
|
|
140
134
|
}, fieldProps, {
|
|
141
135
|
ref: inputRef,
|
|
142
|
-
value: innerValue,
|
|
136
|
+
value: label && name ? innerValue : value,
|
|
143
137
|
onChange: function onChange(e) {
|
|
144
138
|
_onChange === null || _onChange === void 0 ? void 0 : _onChange(e.target.value);
|
|
145
|
-
|
|
139
|
+
if (label && name) {
|
|
140
|
+
setValue(e.target.value);
|
|
141
|
+
}
|
|
146
142
|
}
|
|
147
|
-
}))
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
},
|
|
152
|
-
onChange: function onChange(e) {
|
|
153
|
-
_onChange === null || _onChange === void 0 ? void 0 : _onChange(e.target.value);
|
|
154
|
-
},
|
|
155
|
-
ref: inputRef,
|
|
156
|
-
value: value
|
|
157
|
-
})));
|
|
143
|
+
}));
|
|
144
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, label && name ? /*#__PURE__*/React.createElement(ProFormText, _extends({
|
|
145
|
+
name: name,
|
|
146
|
+
label: label
|
|
147
|
+
}, rest), InputDom) : InputDom);
|
|
158
148
|
});
|
|
159
149
|
export default InputMultiLine;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { InputProps } from 'antd';
|
|
3
3
|
import type { ProFormItemProps } from 'ls-pro-form';
|
|
4
|
-
import { TooltipPlacement } from 'antd/
|
|
4
|
+
import type { TooltipPlacement } from 'antd/es/tooltip';
|
|
5
5
|
export declare type InputTableProps = ProFormItemProps<InputProps> & {
|
|
6
6
|
/** @name 弹框选择表格列配置 */
|
|
7
7
|
columns: any[];
|
|
@@ -7,9 +7,9 @@ import "antd/es/button/style";
|
|
|
7
7
|
import _Button from "antd/es/button";
|
|
8
8
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
9
9
|
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
10
|
-
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
11
10
|
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
12
11
|
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"];
|
|
@@ -40,7 +40,9 @@ var InputTable = /*#__PURE__*/React.forwardRef(function (prop, ref) {
|
|
|
40
40
|
setText = _useState6[1];
|
|
41
41
|
var inputRef = useRef();
|
|
42
42
|
useImperativeHandle(ref, function () {
|
|
43
|
-
return inputRef.current
|
|
43
|
+
return _objectSpread(_objectSpread({}, inputRef.current), {}, {
|
|
44
|
+
clear: handleClear
|
|
45
|
+
});
|
|
44
46
|
});
|
|
45
47
|
var columns = prop.columns,
|
|
46
48
|
url = prop.url,
|
|
@@ -101,7 +103,7 @@ var InputTable = /*#__PURE__*/React.forwardRef(function (prop, ref) {
|
|
|
101
103
|
var tableKey = (tableConfig === null || tableConfig === void 0 ? void 0 : tableConfig.rowKey) || valueField || 'id';
|
|
102
104
|
//显示输入框绑定的name,如果不设置textName,设置为$name__text
|
|
103
105
|
var textNameProp = useMemo(function () {
|
|
104
|
-
return textName
|
|
106
|
+
return textName ? textName : name + '__text';
|
|
105
107
|
}, [textName, name]);
|
|
106
108
|
// 输入框回车时,调用查询参数字段
|
|
107
109
|
var searchKey = useMemo(function () {
|
|
@@ -124,11 +126,11 @@ var InputTable = /*#__PURE__*/React.forwardRef(function (prop, ref) {
|
|
|
124
126
|
}, [columns, searchField, valueField, textField]);
|
|
125
127
|
var loadData = /*#__PURE__*/function () {
|
|
126
128
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(param) {
|
|
127
|
-
var current, pageSize,
|
|
129
|
+
var current, pageSize, restParams, data, _tableRef$current, _tableRef$current$cle, result, rows, formValue, val, _selectRowRef$current, arr, pageSelectedRows;
|
|
128
130
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
129
131
|
while (1) switch (_context.prev = _context.next) {
|
|
130
132
|
case 0:
|
|
131
|
-
current = param.current, pageSize = param.pageSize,
|
|
133
|
+
current = param.current, pageSize = param.pageSize, restParams = _objectWithoutProperties(param, _excluded2);
|
|
132
134
|
data = {};
|
|
133
135
|
if (isV2) {
|
|
134
136
|
data['page.pn'] = current;
|
|
@@ -137,10 +139,10 @@ var InputTable = /*#__PURE__*/React.forwardRef(function (prop, ref) {
|
|
|
137
139
|
data.page = current;
|
|
138
140
|
data.pageSize = pageSize;
|
|
139
141
|
}
|
|
140
|
-
if (Object.keys(
|
|
141
|
-
data.where =
|
|
142
|
+
if (Object.keys(restParams).length && !isV2) {
|
|
143
|
+
data.where = restParams;
|
|
142
144
|
} else {
|
|
143
|
-
data = _objectSpread(_objectSpread({}, data),
|
|
145
|
+
data = _objectSpread(_objectSpread({}, data), restParams);
|
|
144
146
|
}
|
|
145
147
|
if (!keepSelect) {
|
|
146
148
|
selectRowRef.current = [];
|
|
@@ -165,16 +167,15 @@ var InputTable = /*#__PURE__*/React.forwardRef(function (prop, ref) {
|
|
|
165
167
|
case 14:
|
|
166
168
|
result = _context.sent;
|
|
167
169
|
case 15:
|
|
168
|
-
rows = result.rows || []
|
|
170
|
+
rows = (result.rows || []).filter(function (o) {
|
|
171
|
+
return o;
|
|
172
|
+
});
|
|
169
173
|
if (afterLoad) {
|
|
170
174
|
afterLoad(rows);
|
|
171
175
|
}
|
|
172
176
|
// 多选时,找出当前页的默认选中项
|
|
173
177
|
if (multiple) {
|
|
174
|
-
formValue = (
|
|
175
|
-
if (rowKey) {
|
|
176
|
-
formValue = formValue[rowKey] || {};
|
|
177
|
-
}
|
|
178
|
+
formValue = getFormValue();
|
|
178
179
|
val = formValue[name] || (record === null || record === void 0 ? void 0 : record[name]);
|
|
179
180
|
if (val) {
|
|
180
181
|
arr = val.split(',');
|
|
@@ -208,52 +209,78 @@ var InputTable = /*#__PURE__*/React.forwardRef(function (prop, ref) {
|
|
|
208
209
|
return _ref.apply(this, arguments);
|
|
209
210
|
};
|
|
210
211
|
}();
|
|
211
|
-
|
|
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
|
+
// 初始化数据,主要设置名称
|
|
212
230
|
useEffect(function () {
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
} catch (_unused) {}
|
|
225
|
-
} else {
|
|
226
|
-
var _formRef$current3, _formRef$current3$get, _formRef$current4, _formRef$current4$get;
|
|
227
|
-
txt = formRef === null || formRef === void 0 ? void 0 : (_formRef$current3 = formRef.current) === null || _formRef$current3 === void 0 ? void 0 : (_formRef$current3$get = _formRef$current3.getFieldValue) === null || _formRef$current3$get === void 0 ? void 0 : _formRef$current3$get.call(_formRef$current3, textNameProp);
|
|
228
|
-
val = formRef === null || formRef === void 0 ? void 0 : (_formRef$current4 = formRef.current) === null || _formRef$current4 === void 0 ? void 0 : (_formRef$current4$get = _formRef$current4.getFieldValue) === null || _formRef$current4$get === void 0 ? void 0 : _formRef$current4$get.call(_formRef$current4, name);
|
|
229
|
-
}
|
|
230
|
-
if (txt) {
|
|
231
|
-
setText(txt);
|
|
232
|
-
} else if (val) {
|
|
233
|
-
setText(val);
|
|
234
|
-
if (rowKey) {
|
|
235
|
-
var _formRef$current5, _formRef$current5$set;
|
|
236
|
-
formRef === null || formRef === void 0 ? void 0 : (_formRef$current5 = formRef.current) === null || _formRef$current5 === void 0 ? void 0 : (_formRef$current5$set = _formRef$current5.setFieldsValue) === null || _formRef$current5$set === void 0 ? void 0 : _formRef$current5$set.call(_formRef$current5, _defineProperty({}, rowKey, _objectSpread(_objectSpread({}, row), {}, _defineProperty({}, textNameProp, val))));
|
|
237
|
-
} else {
|
|
238
|
-
var _formRef$current6, _formRef$current6$set;
|
|
239
|
-
formRef === null || formRef === void 0 ? void 0 : (_formRef$current6 = formRef.current) === null || _formRef$current6 === void 0 ? void 0 : (_formRef$current6$set = _formRef$current6.setFieldsValue) === null || _formRef$current6$set === void 0 ? void 0 : _formRef$current6$set.call(_formRef$current6, _defineProperty({}, textNameProp, val));
|
|
240
|
-
}
|
|
231
|
+
var _formValue$textNamePr, _formValue$name;
|
|
232
|
+
var formValue = getFormValue();
|
|
233
|
+
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];
|
|
234
|
+
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];
|
|
235
|
+
setText(txt !== null && txt !== void 0 ? txt : val);
|
|
236
|
+
if (val && !txt) {
|
|
237
|
+
formValue[textNameProp] = val;
|
|
238
|
+
setFormValue(formValue);
|
|
239
|
+
// 多值选择或选择的初始值不在第一页时显示有问题
|
|
240
|
+
if (textField !== valueField) {
|
|
241
|
+
initName(val);
|
|
241
242
|
}
|
|
242
|
-
|
|
243
|
-
}, 0);
|
|
243
|
+
}
|
|
244
244
|
}, [rowKey]);
|
|
245
|
+
var initName = function initName(val) {
|
|
246
|
+
var _columns$find;
|
|
247
|
+
if (!val) return;
|
|
248
|
+
var fieldName = ((_columns$find = columns.find(function (o) {
|
|
249
|
+
return o.dataIndex === valueField;
|
|
250
|
+
})) === null || _columns$find === void 0 ? void 0 : _columns$find.searchField) || valueField;
|
|
251
|
+
var param = {
|
|
252
|
+
current: 1,
|
|
253
|
+
pageSize: 10
|
|
254
|
+
};
|
|
255
|
+
if (Array.isArray(val)) val = val.join(',');
|
|
256
|
+
if (val.toString().includes(',')) {
|
|
257
|
+
fieldName += '_in';
|
|
258
|
+
}
|
|
259
|
+
param[fieldName] = val;
|
|
260
|
+
loadData(param).then(function (result) {
|
|
261
|
+
var rows = (result.data || []).filter(function (o) {
|
|
262
|
+
return o;
|
|
263
|
+
});
|
|
264
|
+
var txt = rows.map(function (o) {
|
|
265
|
+
return o[textField];
|
|
266
|
+
}).join(',') || val;
|
|
267
|
+
var formValue = getFormValue();
|
|
268
|
+
formValue[textNameProp] = txt;
|
|
269
|
+
setText(txt);
|
|
270
|
+
setFormValue(formValue);
|
|
271
|
+
});
|
|
272
|
+
};
|
|
245
273
|
// 处理返回数据
|
|
246
274
|
var handleValue = function handleValue(row) {
|
|
247
|
-
var _formRef$current7, _formRef$current7$get, _rest$onChange2;
|
|
248
275
|
var close = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
249
|
-
var formValue = (
|
|
250
|
-
if (
|
|
251
|
-
formValue = formValue[rowKey] || {};
|
|
252
|
-
}
|
|
253
|
-
if (!formValue) return;
|
|
276
|
+
var formValue = getFormValue();
|
|
277
|
+
if (!formValue || !row) return;
|
|
254
278
|
var txt;
|
|
255
279
|
//支持多选
|
|
256
280
|
if (Array.isArray(row)) {
|
|
281
|
+
row = row.filter(function (o) {
|
|
282
|
+
return o;
|
|
283
|
+
});
|
|
257
284
|
//返回值
|
|
258
285
|
formValue[name] = row.map(function (o) {
|
|
259
286
|
return o[valueField];
|
|
@@ -284,23 +311,22 @@ var InputTable = /*#__PURE__*/React.forwardRef(function (prop, ref) {
|
|
|
284
311
|
}
|
|
285
312
|
formValue[textNameProp] = txt;
|
|
286
313
|
setText(txt);
|
|
287
|
-
(
|
|
314
|
+
setFormValue(formValue);
|
|
315
|
+
onSelectChange === null || onSelectChange === void 0 ? void 0 : onSelectChange(row, formRef);
|
|
288
316
|
if (close) {
|
|
289
317
|
setVisible(false);
|
|
290
318
|
}
|
|
291
|
-
if (rowKey) {
|
|
292
|
-
var _formRef$current8, _formRef$current8$set;
|
|
293
|
-
formRef === null || formRef === void 0 ? void 0 : (_formRef$current8 = formRef.current) === null || _formRef$current8 === void 0 ? void 0 : (_formRef$current8$set = _formRef$current8.setFieldsValue) === null || _formRef$current8$set === void 0 ? void 0 : _formRef$current8$set.call(_formRef$current8, _defineProperty({}, rowKey, formValue));
|
|
294
|
-
} else {
|
|
295
|
-
var _formRef$current9, _formRef$current9$set;
|
|
296
|
-
formRef === null || formRef === void 0 ? void 0 : (_formRef$current9 = formRef.current) === null || _formRef$current9 === void 0 ? void 0 : (_formRef$current9$set = _formRef$current9.setFieldsValue) === null || _formRef$current9$set === void 0 ? void 0 : _formRef$current9$set.call(_formRef$current9, _objectSpread({}, formValue));
|
|
297
|
-
}
|
|
298
|
-
onSelectChange === null || onSelectChange === void 0 ? void 0 : onSelectChange(row, formRef);
|
|
299
319
|
};
|
|
300
320
|
var handleClear = function handleClear() {
|
|
301
321
|
var _tableRef$current2, _tableRef$current2$cl;
|
|
302
322
|
selectRowRef.current = [];
|
|
323
|
+
setSelectedKeys([]);
|
|
303
324
|
(_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);
|
|
325
|
+
setText('');
|
|
326
|
+
var formValue = getFormValue();
|
|
327
|
+
formValue[name] = undefined;
|
|
328
|
+
formValue[textNameProp] = undefined;
|
|
329
|
+
setFormValue(formValue);
|
|
304
330
|
};
|
|
305
331
|
// 可输入时,回车或失去焦点调接口查询数据
|
|
306
332
|
var onQuery = function onQuery(e) {
|
|
@@ -329,47 +355,21 @@ var InputTable = /*#__PURE__*/React.forwardRef(function (prop, ref) {
|
|
|
329
355
|
};
|
|
330
356
|
//直接输入不回车,value 和 text 为同一个值
|
|
331
357
|
var onInput = function onInput(e) {
|
|
332
|
-
var
|
|
333
|
-
var formValue = (formRef === null || formRef === void 0 ? void 0 : (_formRef$current10 = formRef.current) === null || _formRef$current10 === void 0 ? void 0 : (_formRef$current10$ge = _formRef$current10.getFieldsValue) === null || _formRef$current10$ge === void 0 ? void 0 : _formRef$current10$ge.call(_formRef$current10)) || {};
|
|
334
|
-
if (rowKey) {
|
|
335
|
-
formValue = formValue[rowKey] || {};
|
|
336
|
-
}
|
|
358
|
+
var formValue = getFormValue();
|
|
337
359
|
var val = e.target.value;
|
|
338
360
|
formValue[name] = val;
|
|
339
361
|
formValue[textNameProp] = val;
|
|
340
362
|
setText(val);
|
|
341
|
-
(
|
|
342
|
-
if (rowKey) {
|
|
343
|
-
var _formRef$current11, _formRef$current11$se;
|
|
344
|
-
formRef === null || formRef === void 0 ? void 0 : (_formRef$current11 = formRef.current) === null || _formRef$current11 === void 0 ? void 0 : (_formRef$current11$se = _formRef$current11.setFieldsValue) === null || _formRef$current11$se === void 0 ? void 0 : _formRef$current11$se.call(_formRef$current11, _defineProperty({}, rowKey, formValue));
|
|
345
|
-
} else {
|
|
346
|
-
var _formRef$current12, _formRef$current12$se;
|
|
347
|
-
formRef === null || formRef === void 0 ? void 0 : (_formRef$current12 = formRef.current) === null || _formRef$current12 === void 0 ? void 0 : (_formRef$current12$se = _formRef$current12.setFieldsValue) === null || _formRef$current12$se === void 0 ? void 0 : _formRef$current12$se.call(_formRef$current12, _objectSpread({}, formValue));
|
|
348
|
-
}
|
|
363
|
+
setFormValue(formValue);
|
|
349
364
|
};
|
|
350
365
|
// 当表单重置或点clear时,处理值
|
|
351
366
|
var clearValue = function clearValue(e) {
|
|
352
367
|
if (!e.target.value) {
|
|
353
|
-
|
|
354
|
-
setText('');
|
|
355
|
-
(_rest$onChange4 = rest.onChange) === null || _rest$onChange4 === void 0 ? void 0 : _rest$onChange4.call(rest, '');
|
|
356
|
-
var formValue = (formRef === null || formRef === void 0 ? void 0 : (_formRef$current13 = formRef.current) === null || _formRef$current13 === void 0 ? void 0 : (_formRef$current13$ge = _formRef$current13.getFieldsValue) === null || _formRef$current13$ge === void 0 ? void 0 : _formRef$current13$ge.call(_formRef$current13)) || {};
|
|
357
|
-
if (rowKey) {
|
|
358
|
-
formValue = formValue[rowKey] || {};
|
|
359
|
-
}
|
|
360
|
-
formValue[name] = '';
|
|
361
|
-
formValue[textNameProp] = '';
|
|
362
|
-
if (rowKey) {
|
|
363
|
-
var _formRef$current14, _formRef$current14$se;
|
|
364
|
-
formRef === null || formRef === void 0 ? void 0 : (_formRef$current14 = formRef.current) === null || _formRef$current14 === void 0 ? void 0 : (_formRef$current14$se = _formRef$current14.setFieldsValue) === null || _formRef$current14$se === void 0 ? void 0 : _formRef$current14$se.call(_formRef$current14, _defineProperty({}, rowKey, formValue));
|
|
365
|
-
} else {
|
|
366
|
-
var _formRef$current15, _formRef$current15$se;
|
|
367
|
-
formRef === null || formRef === void 0 ? void 0 : (_formRef$current15 = formRef.current) === null || _formRef$current15 === void 0 ? void 0 : (_formRef$current15$se = _formRef$current15.setFieldsValue) === null || _formRef$current15$se === void 0 ? void 0 : _formRef$current15$se.call(_formRef$current15, _objectSpread({}, formValue));
|
|
368
|
-
}
|
|
368
|
+
handleClear();
|
|
369
369
|
if (onSelectChange) {
|
|
370
370
|
try {
|
|
371
371
|
onSelectChange(null, formRef);
|
|
372
|
-
} catch (
|
|
372
|
+
} catch (error) {}
|
|
373
373
|
}
|
|
374
374
|
}
|
|
375
375
|
};
|
|
@@ -407,11 +407,11 @@ var InputTable = /*#__PURE__*/React.forwardRef(function (prop, ref) {
|
|
|
407
407
|
},
|
|
408
408
|
height: 'full',
|
|
409
409
|
rowKey: tableKey,
|
|
410
|
-
onRow: function onRow(
|
|
410
|
+
onRow: function onRow(rowData) {
|
|
411
411
|
return {
|
|
412
412
|
onDoubleClick: function onDoubleClick() {
|
|
413
413
|
if (!multiple) {
|
|
414
|
-
handleValue(
|
|
414
|
+
handleValue(rowData);
|
|
415
415
|
}
|
|
416
416
|
}
|
|
417
417
|
};
|
|
@@ -435,8 +435,12 @@ var InputTable = /*#__PURE__*/React.forwardRef(function (prop, ref) {
|
|
|
435
435
|
selectedRowKeys: selectedKeys,
|
|
436
436
|
preserveSelectedRowKeys: keepSelect,
|
|
437
437
|
onChange: function onChange(keys, rows) {
|
|
438
|
-
selectRowRef.current = rows || []
|
|
439
|
-
|
|
438
|
+
selectRowRef.current = (rows || []).filter(function (o) {
|
|
439
|
+
return o;
|
|
440
|
+
});
|
|
441
|
+
setSelectedKeys(selectRowRef.current.map(function (o) {
|
|
442
|
+
return o[tableKey];
|
|
443
|
+
}));
|
|
440
444
|
if (changeOnSelect) {
|
|
441
445
|
handleValue(selectRowRef.current, false);
|
|
442
446
|
}
|
|
@@ -447,28 +451,7 @@ var InputTable = /*#__PURE__*/React.forwardRef(function (prop, ref) {
|
|
|
447
451
|
showClear: true,
|
|
448
452
|
selectedTagField: textField || valueField
|
|
449
453
|
}));
|
|
450
|
-
|
|
451
|
-
useEffect(function () {
|
|
452
|
-
if (rest.disabled || (fieldProps === null || fieldProps === void 0 ? void 0 : fieldProps.disabled)) return;
|
|
453
|
-
try {
|
|
454
|
-
var el = inputRef.current.input.parentNode;
|
|
455
|
-
if (!el) return;
|
|
456
|
-
if (text) {
|
|
457
|
-
el.classList.add('ant-input-has-value');
|
|
458
|
-
} else {
|
|
459
|
-
el.classList.remove('ant-input-has-value');
|
|
460
|
-
}
|
|
461
|
-
} catch (e) {}
|
|
462
|
-
}, [text, rest, fieldProps]);
|
|
463
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
464
|
-
style: {
|
|
465
|
-
display: 'none'
|
|
466
|
-
}
|
|
467
|
-
}, /*#__PURE__*/React.createElement(ProFormText, {
|
|
468
|
-
name: name
|
|
469
|
-
})), rest.label ? /*#__PURE__*/React.createElement(ProFormText, _extends({
|
|
470
|
-
name: textNameProp
|
|
471
|
-
}, rest), /*#__PURE__*/React.createElement(_Input, _extends({
|
|
454
|
+
var InputDom = /*#__PURE__*/React.createElement(_Input, _extends({
|
|
472
455
|
suffix: /*#__PURE__*/React.createElement(_Popover, {
|
|
473
456
|
content: /*#__PURE__*/React.createElement("div", {
|
|
474
457
|
style: {
|
|
@@ -485,13 +468,13 @@ var InputTable = /*#__PURE__*/React.forwardRef(function (prop, ref) {
|
|
|
485
468
|
overlayStyle: {
|
|
486
469
|
width: 'max-content'
|
|
487
470
|
},
|
|
488
|
-
|
|
489
|
-
|
|
471
|
+
open: rest.disabled || (fieldProps === null || fieldProps === void 0 ? void 0 : fieldProps.disabled) ? false : visible,
|
|
472
|
+
onOpenChange: setVisible,
|
|
490
473
|
getPopupContainer: getPopupContainer,
|
|
491
474
|
placement: placement,
|
|
492
475
|
arrowPointAtCenter: arrowPointAtCenter
|
|
493
476
|
}, /*#__PURE__*/React.createElement(MoreOutlined, {
|
|
494
|
-
onClick: function onClick(
|
|
477
|
+
onClick: function onClick() {
|
|
495
478
|
if (rest.disabled || (fieldProps === null || fieldProps === void 0 ? void 0 : fieldProps.disabled)) return;
|
|
496
479
|
setVisible(true);
|
|
497
480
|
}
|
|
@@ -516,54 +499,32 @@ var InputTable = /*#__PURE__*/React.forwardRef(function (prop, ref) {
|
|
|
516
499
|
readOnly: readonly,
|
|
517
500
|
allowClear: allowClear,
|
|
518
501
|
ref: inputRef
|
|
519
|
-
},
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
},
|
|
533
|
-
overlayStyle: {
|
|
534
|
-
width: 'max-content'
|
|
535
|
-
},
|
|
536
|
-
visible: rest.disabled || (fieldProps === null || fieldProps === void 0 ? void 0 : fieldProps.disabled) ? false : visible,
|
|
537
|
-
onVisibleChange: setVisible,
|
|
538
|
-
getPopupContainer: getPopupContainer,
|
|
539
|
-
placement: placement,
|
|
540
|
-
arrowPointAtCenter: arrowPointAtCenter
|
|
541
|
-
}, /*#__PURE__*/React.createElement(MoreOutlined, {
|
|
542
|
-
onClick: function onClick(e) {
|
|
543
|
-
if (rest.disabled || (fieldProps === null || fieldProps === void 0 ? void 0 : fieldProps.disabled)) return;
|
|
544
|
-
setVisible(true);
|
|
545
|
-
}
|
|
546
|
-
})),
|
|
547
|
-
onClick: function onClick() {
|
|
548
|
-
if (!readonly) return;
|
|
549
|
-
setVisible(true);
|
|
550
|
-
},
|
|
551
|
-
onInput: onInput,
|
|
552
|
-
onPressEnter: function onPressEnter(e) {
|
|
553
|
-
if (triggerCheck === 'entry') {
|
|
554
|
-
onQuery(e);
|
|
555
|
-
}
|
|
556
|
-
},
|
|
557
|
-
onBlur: function onBlur(e) {
|
|
558
|
-
if (triggerCheck === 'blur') {
|
|
559
|
-
onQuery(e);
|
|
502
|
+
}, rest.label ? {} : {
|
|
503
|
+
value: text
|
|
504
|
+
}, fieldProps));
|
|
505
|
+
// 处理有值时,可清空
|
|
506
|
+
useEffect(function () {
|
|
507
|
+
if (rest.disabled || (fieldProps === null || fieldProps === void 0 ? void 0 : fieldProps.disabled)) return;
|
|
508
|
+
try {
|
|
509
|
+
var el = inputRef.current.input.parentNode;
|
|
510
|
+
if (!el) return;
|
|
511
|
+
if (text) {
|
|
512
|
+
el.classList.add('ant-input-has-value');
|
|
513
|
+
} else {
|
|
514
|
+
el.classList.remove('ant-input-has-value');
|
|
560
515
|
}
|
|
561
|
-
}
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
},
|
|
516
|
+
} catch (e) {}
|
|
517
|
+
}, [text, rest, fieldProps]);
|
|
518
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
519
|
+
style: {
|
|
520
|
+
display: 'none'
|
|
521
|
+
}
|
|
522
|
+
}, /*#__PURE__*/React.createElement(ProFormText, {
|
|
523
|
+
name: name
|
|
524
|
+
})), /*#__PURE__*/React.createElement(ProFormText, _extends({
|
|
525
|
+
name: textNameProp
|
|
526
|
+
}, rest, {
|
|
527
|
+
noStyle: !rest.label
|
|
528
|
+
}), InputDom));
|
|
568
529
|
});
|
|
569
530
|
export default InputTable;
|
package/es/http/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
1
2
|
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
2
3
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
3
4
|
import { extend } from 'umi-request';
|
|
@@ -15,6 +16,7 @@ var httpStatus = {
|
|
|
15
16
|
};
|
|
16
17
|
/** 请求拦截器,统一添加token */
|
|
17
18
|
request.interceptors.request.use(function (url, options) {
|
|
19
|
+
var _options$params;
|
|
18
20
|
var token = getCookie('token');
|
|
19
21
|
options.headers = options.headers || {};
|
|
20
22
|
// 处理 token
|
|
@@ -47,12 +49,14 @@ request.interceptors.request.use(function (url, options) {
|
|
|
47
49
|
}
|
|
48
50
|
|
|
49
51
|
url = url.replace('&noToken=1', '').replace('noToken=1', '');
|
|
52
|
+
var resCode = getUrlQuery('resCode', url) || getUrlQuery('resCode') || getUrlQuery('resourceId') || getResourceProps('resourceId');
|
|
50
53
|
var param = {
|
|
51
|
-
resCode: getUrlQuery('resCode', url) || getUrlQuery('resCode') || getUrlQuery('resourceId') || getResourceProps('resourceId'),
|
|
52
54
|
_t1: Date.now()
|
|
53
55
|
};
|
|
54
|
-
|
|
55
|
-
|
|
56
|
+
// 当没有明文参数resCode的时候,添加resCode参数为资源Id
|
|
57
|
+
//@ts-ignore
|
|
58
|
+
if (resCode && !((_options$params = options.params) === null || _options$params === void 0 ? void 0 : _options$params.resCode)) {
|
|
59
|
+
param.resCode = resCode;
|
|
56
60
|
}
|
|
57
61
|
url = setUrlQuery(url, param);
|
|
58
62
|
return {
|
|
@@ -204,7 +208,9 @@ function ajax(url) {
|
|
|
204
208
|
timeout: timeout,
|
|
205
209
|
requestType: isJson ? 'json' : 'form'
|
|
206
210
|
}).finally(function () {
|
|
207
|
-
|
|
211
|
+
if (loadText) {
|
|
212
|
+
exitLoading();
|
|
213
|
+
}
|
|
208
214
|
});
|
|
209
215
|
}
|
|
210
216
|
}
|
|
@@ -322,12 +328,11 @@ function _fetchOptions() {
|
|
|
322
328
|
_yield$httpGet$rows = _yield$httpGet.rows;
|
|
323
329
|
rows = _yield$httpGet$rows === void 0 ? [] : _yield$httpGet$rows;
|
|
324
330
|
data = (rows || []).map(function (o) {
|
|
325
|
-
return {
|
|
331
|
+
return _objectSpread(_objectSpread({}, o), {}, {
|
|
326
332
|
value: o[valueField],
|
|
327
333
|
text: o[labelField],
|
|
328
|
-
label: (showValue ? o[valueField] + '→' : '') + o[labelField]
|
|
329
|
-
|
|
330
|
-
};
|
|
334
|
+
label: (showValue ? o[valueField] + '→' : '') + o[labelField]
|
|
335
|
+
});
|
|
331
336
|
});
|
|
332
337
|
return _context2.abrupt("return", data);
|
|
333
338
|
case 10:
|
|
@@ -7,7 +7,7 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
|
7
7
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
8
8
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
9
9
|
var _excluded = ["name", "rows", "maxRows", "placement", "popWidth", "fieldProps", "defaultValue", "allowClear", "getPopupContainer", "textAreaProps", "value", "label", "textareaPlaceholder", "onChange"];
|
|
10
|
-
import React, { useRef, useState, useEffect, useContext,
|
|
10
|
+
import React, { useRef, useState, useEffect, useContext, useImperativeHandle } from 'react';
|
|
11
11
|
import { ProFormText, ProFormContext } from 'ls-pro-form';
|
|
12
12
|
import { UnorderedListOutlined } from '@ant-design/icons';
|
|
13
13
|
var InputMultiLine = /*#__PURE__*/React.forwardRef(function (prop, ref) {
|
|
@@ -76,13 +76,13 @@ var InputMultiLine = /*#__PURE__*/React.forwardRef(function (prop, ref) {
|
|
|
76
76
|
_onChange === null || _onChange === void 0 ? void 0 : _onChange(val);
|
|
77
77
|
setValue(val);
|
|
78
78
|
};
|
|
79
|
-
var
|
|
80
|
-
|
|
79
|
+
var InputDom = /*#__PURE__*/React.createElement(_Input, _extends({
|
|
80
|
+
suffix: /*#__PURE__*/React.createElement(_Popover, {
|
|
81
81
|
getPopupContainer: getPopupContainer,
|
|
82
82
|
trigger: "click",
|
|
83
83
|
placement: placement,
|
|
84
|
-
|
|
85
|
-
|
|
84
|
+
open: rest.disabled || (fieldProps === null || fieldProps === void 0 ? void 0 : fieldProps.disabled) ? false : visible,
|
|
85
|
+
onOpenChange: function onOpenChange(flag) {
|
|
86
86
|
setVisible(flag);
|
|
87
87
|
if (flag) {
|
|
88
88
|
var _textareaRef$current;
|
|
@@ -128,32 +128,22 @@ var InputMultiLine = /*#__PURE__*/React.forwardRef(function (prop, ref) {
|
|
|
128
128
|
if (rest.readonly || rest.disabled) return;
|
|
129
129
|
setVisible(true);
|
|
130
130
|
}
|
|
131
|
-
}))
|
|
132
|
-
}, [visible, popWidth, lineText, value, name, label, rest]);
|
|
133
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, label && name ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ProFormText, _extends({
|
|
134
|
-
name: name,
|
|
135
|
-
label: label
|
|
136
|
-
}, rest), /*#__PURE__*/React.createElement(_Input, _extends({
|
|
137
|
-
suffix: PopoverDom,
|
|
131
|
+
})),
|
|
138
132
|
placeholder: (fieldProps === null || fieldProps === void 0 ? void 0 : fieldProps.placeholder) || '请输入',
|
|
139
133
|
allowClear: allowClear
|
|
140
134
|
}, fieldProps, {
|
|
141
135
|
ref: inputRef,
|
|
142
|
-
value: innerValue,
|
|
136
|
+
value: label && name ? innerValue : value,
|
|
143
137
|
onChange: function onChange(e) {
|
|
144
138
|
_onChange === null || _onChange === void 0 ? void 0 : _onChange(e.target.value);
|
|
145
|
-
|
|
139
|
+
if (label && name) {
|
|
140
|
+
setValue(e.target.value);
|
|
141
|
+
}
|
|
146
142
|
}
|
|
147
|
-
}))
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
},
|
|
152
|
-
onChange: function onChange(e) {
|
|
153
|
-
_onChange === null || _onChange === void 0 ? void 0 : _onChange(e.target.value);
|
|
154
|
-
},
|
|
155
|
-
ref: inputRef,
|
|
156
|
-
value: value
|
|
157
|
-
})));
|
|
143
|
+
}));
|
|
144
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, label && name ? /*#__PURE__*/React.createElement(ProFormText, _extends({
|
|
145
|
+
name: name,
|
|
146
|
+
label: label
|
|
147
|
+
}, rest), InputDom) : InputDom);
|
|
158
148
|
});
|
|
159
149
|
export default InputMultiLine;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { InputProps } from 'antd';
|
|
3
3
|
import type { ProFormItemProps } from 'ls-pro-form';
|
|
4
|
-
import { TooltipPlacement } from 'antd/
|
|
4
|
+
import type { TooltipPlacement } from 'antd/es/tooltip';
|
|
5
5
|
export declare type InputTableProps = ProFormItemProps<InputProps> & {
|
|
6
6
|
/** @name 弹框选择表格列配置 */
|
|
7
7
|
columns: any[];
|