ls-pro-common 3.0.61 → 3.0.63
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.css +215 -111
- package/dist/common.js +1 -1
- package/dist/common.min.css +215 -111
- package/dist/common.min.js +1 -1
- package/es/components/InputMultiLine.d.ts +20 -14
- package/es/components/InputMultiLine.js +80 -64
- package/es/components/InputTable.d.ts +40 -38
- package/es/components/InputTable.js +43 -20
- package/es/components/TagCheck.d.ts +2 -0
- package/es/components/TagCheck.js +7 -5
- package/es/components/antd-custom.less +2 -2
- package/es/components/common.less +80 -81
- package/lib/components/InputMultiLine.d.ts +20 -14
- package/lib/components/InputMultiLine.js +80 -64
- package/lib/components/InputTable.d.ts +40 -38
- package/lib/components/InputTable.js +43 -20
- package/lib/components/TagCheck.d.ts +2 -0
- package/lib/components/TagCheck.js +7 -5
- package/lib/components/antd-custom.less +2 -2
- package/lib/components/common.less +80 -81
- package/package.json +3 -3
|
@@ -3,20 +3,23 @@ import type { InputProps } from 'antd';
|
|
|
3
3
|
import type { TextAreaProps } from 'antd/lib/input';
|
|
4
4
|
import type { ProFormItemProps } from 'ls-pro-form';
|
|
5
5
|
export declare type InputMultiLineProps = ProFormItemProps<InputProps> & {
|
|
6
|
-
|
|
7
|
-
name
|
|
8
|
-
|
|
6
|
+
/** @name 表单项name, 跟 form.item 的 name一致 */
|
|
7
|
+
name?: string;
|
|
8
|
+
/** @name 表单值 */
|
|
9
9
|
defaultValue?: string;
|
|
10
|
-
|
|
10
|
+
/** @name 弹框宽度,默认为400 */
|
|
11
11
|
popWidth?: string;
|
|
12
|
-
|
|
13
|
-
placement?:
|
|
14
|
-
|
|
12
|
+
/** @name 弹框位置,默认为bottom */
|
|
13
|
+
placement?: 'bottom' | 'top' | 'bottomLeft' | 'bottomRight' | 'topLeft' | 'topRight';
|
|
14
|
+
/** @name 多行文本框行数 */
|
|
15
15
|
rows?: number;
|
|
16
16
|
/** @name 最大输入行数 */
|
|
17
17
|
maxRows?: number;
|
|
18
18
|
getPopupContainer?: (triggerNode: any) => HTMLElement;
|
|
19
19
|
textAreaProps?: TextAreaProps;
|
|
20
|
+
onChange?: (e: any) => void;
|
|
21
|
+
value?: string;
|
|
22
|
+
textareaPlaceholder?: string;
|
|
20
23
|
};
|
|
21
24
|
declare const InputMultiLine: React.ForwardRefExoticComponent<{
|
|
22
25
|
fieldProps?: (import("ls-pro-form/lib/interface").FieldProps & InputProps) | undefined;
|
|
@@ -28,19 +31,22 @@ declare const InputMultiLine: React.ForwardRefExoticComponent<{
|
|
|
28
31
|
proFieldProps?: import("ls-pro-utils").ProFieldProps | undefined;
|
|
29
32
|
footerRender?: import("ls-pro-form").LightFilterFooterRender | undefined;
|
|
30
33
|
} & Omit<import("ls-pro-form/lib/components/FormItem").ProFormItemProps, "valueType"> & import("ls-pro-form/lib/interface").ExtendsProps & {
|
|
31
|
-
|
|
32
|
-
name
|
|
33
|
-
|
|
34
|
+
/** @name 表单项name, 跟 form.item 的 name一致 */
|
|
35
|
+
name?: string | undefined;
|
|
36
|
+
/** @name 表单值 */
|
|
34
37
|
defaultValue?: string | undefined;
|
|
35
|
-
|
|
38
|
+
/** @name 弹框宽度,默认为400 */
|
|
36
39
|
popWidth?: string | undefined;
|
|
37
|
-
|
|
38
|
-
placement?:
|
|
39
|
-
|
|
40
|
+
/** @name 弹框位置,默认为bottom */
|
|
41
|
+
placement?: "top" | "bottom" | "topLeft" | "topRight" | "bottomLeft" | "bottomRight" | undefined;
|
|
42
|
+
/** @name 多行文本框行数 */
|
|
40
43
|
rows?: number | undefined;
|
|
41
44
|
/** @name 最大输入行数 */
|
|
42
45
|
maxRows?: number | undefined;
|
|
43
46
|
getPopupContainer?: ((triggerNode: any) => HTMLElement) | undefined;
|
|
44
47
|
textAreaProps?: TextAreaProps | undefined;
|
|
48
|
+
onChange?: ((e: any) => void) | undefined;
|
|
49
|
+
value?: string | undefined;
|
|
50
|
+
textareaPlaceholder?: string | undefined;
|
|
45
51
|
} & React.RefAttributes<unknown>>;
|
|
46
52
|
export default InputMultiLine;
|
|
@@ -3,30 +3,31 @@ import _Popover from "antd/es/popover";
|
|
|
3
3
|
import "antd/es/input/style";
|
|
4
4
|
import _Input from "antd/es/input";
|
|
5
5
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
6
|
-
import
|
|
6
|
+
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
|
-
var _excluded = ["name", "rows", "maxRows", "placement", "popWidth", "fieldProps", "defaultValue", "allowClear", "getPopupContainer", "textAreaProps"];
|
|
9
|
+
var _excluded = ["name", "rows", "maxRows", "placement", "popWidth", "fieldProps", "defaultValue", "allowClear", "getPopupContainer", "textAreaProps", "value", "label", "textareaPlaceholder", "onChange"];
|
|
10
10
|
import React, { useRef, useState, useEffect, useContext, useMemo, 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) {
|
|
14
|
-
//@ts-ignore
|
|
15
|
-
var _useContext = useContext(ProFormContext),
|
|
16
|
-
formRef = _useContext.formRef;
|
|
17
14
|
var _useState = useState(''),
|
|
18
15
|
_useState2 = _slicedToArray(_useState, 2),
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
lineText = _useState2[0],
|
|
17
|
+
setLineText = _useState2[1];
|
|
21
18
|
var _useState3 = useState(''),
|
|
22
19
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
innerValue = _useState4[0],
|
|
21
|
+
setInnerValue = _useState4[1];
|
|
25
22
|
var _useState5 = useState(false),
|
|
26
23
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
27
24
|
visible = _useState6[0],
|
|
28
25
|
setVisible = _useState6[1];
|
|
29
|
-
var inputRef = useRef();
|
|
26
|
+
var inputRef = useRef(null);
|
|
27
|
+
var textareaRef = useRef(null);
|
|
28
|
+
//@ts-ignore
|
|
29
|
+
var _useContext = useContext(ProFormContext),
|
|
30
|
+
formRef = _useContext.formRef;
|
|
30
31
|
useImperativeHandle(ref, function () {
|
|
31
32
|
return inputRef.current;
|
|
32
33
|
});
|
|
@@ -34,11 +35,11 @@ var InputMultiLine = /*#__PURE__*/React.forwardRef(function (prop, ref) {
|
|
|
34
35
|
_prop$rows = prop.rows,
|
|
35
36
|
rows = _prop$rows === void 0 ? 12 : _prop$rows,
|
|
36
37
|
_prop$maxRows = prop.maxRows,
|
|
37
|
-
maxRows = _prop$maxRows === void 0 ?
|
|
38
|
+
maxRows = _prop$maxRows === void 0 ? 5000 : _prop$maxRows,
|
|
38
39
|
_prop$placement = prop.placement,
|
|
39
|
-
placement = _prop$placement === void 0 ? '
|
|
40
|
+
placement = _prop$placement === void 0 ? 'bottomRight' : _prop$placement,
|
|
40
41
|
_prop$popWidth = prop.popWidth,
|
|
41
|
-
popWidth = _prop$popWidth === void 0 ? '
|
|
42
|
+
popWidth = _prop$popWidth === void 0 ? '250px' : _prop$popWidth,
|
|
42
43
|
fieldProps = prop.fieldProps,
|
|
43
44
|
defaultValue = prop.defaultValue,
|
|
44
45
|
_prop$allowClear = prop.allowClear,
|
|
@@ -48,92 +49,107 @@ var InputMultiLine = /*#__PURE__*/React.forwardRef(function (prop, ref) {
|
|
|
48
49
|
return triggerNode.parentNode.parentNode.parentNode.parentNode;
|
|
49
50
|
} : _prop$getPopupContain,
|
|
50
51
|
textAreaProps = prop.textAreaProps,
|
|
52
|
+
value = prop.value,
|
|
53
|
+
label = prop.label,
|
|
54
|
+
_prop$textareaPlaceho = prop.textareaPlaceholder,
|
|
55
|
+
textareaPlaceholder = _prop$textareaPlaceho === void 0 ? '请输入' : _prop$textareaPlaceho,
|
|
56
|
+
_onChange = prop.onChange,
|
|
51
57
|
rest = _objectWithoutProperties(prop, _excluded);
|
|
58
|
+
var setValue = function setValue(val) {
|
|
59
|
+
setInnerValue(val);
|
|
60
|
+
if (label && name && (formRef === null || formRef === void 0 ? void 0 : formRef.current)) {
|
|
61
|
+
formRef === null || formRef === void 0 ? void 0 : formRef.current.setFieldsValue(_defineProperty({}, name, val));
|
|
62
|
+
}
|
|
63
|
+
};
|
|
52
64
|
// 设置初始值
|
|
53
65
|
useEffect(function () {
|
|
54
|
-
if (defaultValue)
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
var _formRef$current, _formRef$current$getF;
|
|
58
|
-
var formValue = formRef === null || formRef === void 0 ? void 0 : (_formRef$current = formRef.current) === null || _formRef$current === void 0 ? void 0 : (_formRef$current$getF = _formRef$current.getFieldValue) === null || _formRef$current$getF === void 0 ? void 0 : _formRef$current$getF.call(_formRef$current, name);
|
|
59
|
-
setText(formValue);
|
|
60
|
-
}
|
|
66
|
+
if (!defaultValue) return;
|
|
67
|
+
_onChange === null || _onChange === void 0 ? void 0 : _onChange(defaultValue);
|
|
68
|
+
setValue(defaultValue);
|
|
61
69
|
}, []);
|
|
62
|
-
// 显示多行输入时,赋值给多行文本框
|
|
63
|
-
useEffect(function () {
|
|
64
|
-
if (!visible) return;
|
|
65
|
-
var line = (text || '').split(',').join('\n');
|
|
66
|
-
setLineText(line);
|
|
67
|
-
}, [visible, text]);
|
|
68
|
-
// 输入框值变化时,赋值给表单项
|
|
69
|
-
useEffect(function () {
|
|
70
|
-
var _formRef$current2, _formRef$current2$get, _formRef$current3, _formRef$current3$set;
|
|
71
|
-
var formValue = (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)) || {};
|
|
72
|
-
formValue[name] = text;
|
|
73
|
-
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, _objectSpread({}, formValue));
|
|
74
|
-
}, [text]);
|
|
75
70
|
var lineInput = function lineInput(e) {
|
|
76
71
|
var line = (e.target.value || '').split('\n').filter(function (o, i) {
|
|
77
|
-
return i <= (maxRows < 1 ?
|
|
72
|
+
return i <= (maxRows < 1 ? 10000 : maxRows);
|
|
78
73
|
}).join('\n');
|
|
79
|
-
var txt = line.split('\n').join(',');
|
|
80
74
|
setLineText(line);
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
setText(e.target.value);
|
|
85
|
-
};
|
|
86
|
-
var clearValue = function clearValue(e) {
|
|
87
|
-
if (!e.target.value) {
|
|
88
|
-
setText('');
|
|
89
|
-
setLineText('');
|
|
90
|
-
}
|
|
75
|
+
var val = line.split('\n').join(',');
|
|
76
|
+
_onChange === null || _onChange === void 0 ? void 0 : _onChange(val);
|
|
77
|
+
setValue(val);
|
|
91
78
|
};
|
|
92
79
|
var PopoverDom = useMemo(function () {
|
|
93
80
|
return /*#__PURE__*/React.createElement(_Popover, {
|
|
81
|
+
getPopupContainer: getPopupContainer,
|
|
82
|
+
trigger: "click",
|
|
83
|
+
placement: placement,
|
|
84
|
+
visible: rest.disabled || (fieldProps === null || fieldProps === void 0 ? void 0 : fieldProps.disabled) ? false : visible,
|
|
85
|
+
onVisibleChange: function onVisibleChange(flag) {
|
|
86
|
+
setVisible(flag);
|
|
87
|
+
if (flag) {
|
|
88
|
+
var _textareaRef$current;
|
|
89
|
+
setLineText((value || innerValue || '').split(',').join('\n'));
|
|
90
|
+
(_textareaRef$current = textareaRef.current) === null || _textareaRef$current === void 0 ? void 0 : _textareaRef$current.focus();
|
|
91
|
+
} else {
|
|
92
|
+
// 关闭时清除左右空格及空行
|
|
93
|
+
var line = (lineText || '').split('\n').map(function (o) {
|
|
94
|
+
return o.trim();
|
|
95
|
+
}).filter(function (o, i) {
|
|
96
|
+
return i <= (maxRows < 1 ? 10000 : maxRows) && o;
|
|
97
|
+
}).join('\n');
|
|
98
|
+
var val = line.split('\n').join(',');
|
|
99
|
+
_onChange === null || _onChange === void 0 ? void 0 : _onChange(val);
|
|
100
|
+
setValue(val);
|
|
101
|
+
}
|
|
102
|
+
},
|
|
94
103
|
content: /*#__PURE__*/React.createElement("div", {
|
|
95
104
|
style: {
|
|
96
105
|
width: popWidth
|
|
97
106
|
}
|
|
98
107
|
}, /*#__PURE__*/React.createElement(_Input.TextArea, _extends({
|
|
99
|
-
placeholder:
|
|
108
|
+
placeholder: textareaPlaceholder
|
|
100
109
|
}, textAreaProps, {
|
|
101
110
|
rows: rows,
|
|
102
111
|
value: lineText,
|
|
103
112
|
onInput: lineInput,
|
|
113
|
+
autoFocus: true,
|
|
114
|
+
ref: textareaRef,
|
|
104
115
|
onKeyPress: function onKeyPress(e) {
|
|
105
|
-
|
|
116
|
+
// 阻止表单自动提交
|
|
117
|
+
if (e.key === 'Enter') {
|
|
118
|
+
e.stopPropagation();
|
|
119
|
+
}
|
|
106
120
|
}
|
|
107
|
-
})))
|
|
108
|
-
trigger: "click",
|
|
109
|
-
visible: rest.disabled || (fieldProps === null || fieldProps === void 0 ? void 0 : fieldProps.disabled) ? false : visible,
|
|
110
|
-
onVisibleChange: setVisible,
|
|
111
|
-
getPopupContainer: getPopupContainer
|
|
121
|
+
})))
|
|
112
122
|
}, /*#__PURE__*/React.createElement(UnorderedListOutlined, {
|
|
113
123
|
onClick: function onClick(e) {
|
|
124
|
+
if (rest.readonly || rest.disabled) return;
|
|
114
125
|
setVisible(true);
|
|
115
126
|
}
|
|
116
127
|
}));
|
|
117
128
|
}, [visible, popWidth, lineText, rest]);
|
|
118
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null,
|
|
119
|
-
name: name
|
|
129
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, label && name ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ProFormText, _extends({
|
|
130
|
+
name: name,
|
|
131
|
+
label: label
|
|
120
132
|
}, rest), /*#__PURE__*/React.createElement(_Input, _extends({
|
|
121
133
|
suffix: PopoverDom,
|
|
122
|
-
placeholder:
|
|
134
|
+
placeholder: (fieldProps === null || fieldProps === void 0 ? void 0 : fieldProps.placeholder) || '请输入',
|
|
135
|
+
allowClear: allowClear
|
|
123
136
|
}, fieldProps, {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
137
|
+
ref: inputRef,
|
|
138
|
+
value: innerValue,
|
|
139
|
+
onChange: function onChange(e) {
|
|
140
|
+
_onChange === null || _onChange === void 0 ? void 0 : _onChange(e.target.value);
|
|
141
|
+
setValue(e.target.value);
|
|
142
|
+
}
|
|
143
|
+
})))) : /*#__PURE__*/React.createElement(_Input, _extends({
|
|
129
144
|
suffix: PopoverDom,
|
|
130
145
|
placeholder: "\u8BF7\u8F93\u5165",
|
|
131
146
|
allowClear: allowClear
|
|
132
147
|
}, fieldProps, {
|
|
133
|
-
onChange:
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
ref: inputRef
|
|
148
|
+
onChange: function onChange(e) {
|
|
149
|
+
_onChange === null || _onChange === void 0 ? void 0 : _onChange(e.target.value);
|
|
150
|
+
},
|
|
151
|
+
ref: inputRef,
|
|
152
|
+
value: value
|
|
137
153
|
})));
|
|
138
154
|
});
|
|
139
155
|
export default InputMultiLine;
|
|
@@ -3,48 +3,49 @@ import type { InputProps } from 'antd';
|
|
|
3
3
|
import type { ProFormItemProps } from 'ls-pro-form';
|
|
4
4
|
import { TooltipPlacement } from 'antd/lib/tooltip';
|
|
5
5
|
export declare type InputTableProps = ProFormItemProps<InputProps> & {
|
|
6
|
-
|
|
6
|
+
/** @name 弹框选择表格列配置 */
|
|
7
7
|
columns: any[];
|
|
8
|
-
|
|
8
|
+
/** @name 调用后端API地址 */
|
|
9
9
|
url: string;
|
|
10
|
-
|
|
10
|
+
/** @name 弹框表格高度,默认400 */
|
|
11
11
|
tableHeight?: number;
|
|
12
|
-
|
|
12
|
+
/** @name 弹框表格宽度,默认650 */
|
|
13
13
|
tableWidth?: number;
|
|
14
|
-
|
|
14
|
+
/** @name 是否支持多选 */
|
|
15
15
|
multiple?: boolean;
|
|
16
|
-
|
|
16
|
+
/** @name 表单项name, 跟 form.item 的 name一致 */
|
|
17
17
|
name: string;
|
|
18
|
-
|
|
18
|
+
/** @name 返回的值字段,表格中valueField配置的字段时返回给name */
|
|
19
19
|
valueField: string;
|
|
20
|
-
|
|
20
|
+
/** @name 返回输入框显示的字段,textField字段值返回给textName */
|
|
21
21
|
textField?: string;
|
|
22
|
-
|
|
22
|
+
/** @name 用于接收textField返回的值 */
|
|
23
23
|
textName?: string;
|
|
24
24
|
/** @name 表格的其它配置 */
|
|
25
25
|
tableConfig?: any;
|
|
26
|
-
|
|
26
|
+
/** @name 表单label宽度,默认70 */
|
|
27
27
|
labelWidth?: number;
|
|
28
|
-
|
|
28
|
+
/** @name 是否2.0接口 */
|
|
29
29
|
isV2?: boolean;
|
|
30
|
-
|
|
30
|
+
/** @name 是否支持跨页选择 */
|
|
31
31
|
keepSelect?: boolean;
|
|
32
|
-
|
|
32
|
+
/** @name 回车事件查询关键字 */
|
|
33
33
|
searchField?: string;
|
|
34
|
-
|
|
34
|
+
/** @name 填充其它表单项目配置 */
|
|
35
35
|
fillMap?: Record<string, string>;
|
|
36
|
-
|
|
36
|
+
/** @name 输入后检查数据的触发方式,默认为entry回车触发 */
|
|
37
37
|
triggerCheck?: 'entry' | 'blur';
|
|
38
|
-
|
|
38
|
+
/** @name 每次展示面板时都加载数据,接合 tableConfig里的 manualRequest 一起使用 */
|
|
39
39
|
loadOnShow?: boolean;
|
|
40
40
|
placement?: TooltipPlacement;
|
|
41
41
|
arrowPointAtCenter?: boolean;
|
|
42
|
+
method?: 'GET' | 'POST';
|
|
42
43
|
rowKey?: any;
|
|
43
|
-
|
|
44
|
+
/** @name 选择行事件 */
|
|
44
45
|
onSelectChange?: (item: any, formRef?: any) => void;
|
|
45
|
-
|
|
46
|
+
/** @name 加载之前事件,param为查询条件对象,可以通过此方法调整 */
|
|
46
47
|
beforeLoad?: (param: any) => void;
|
|
47
|
-
|
|
48
|
+
/** @name 加载之后事件,row为接口返回数据,可以通过此方法调整 */
|
|
48
49
|
afterLoad?: (rows: any[]) => void;
|
|
49
50
|
getPopupContainer?: (triggerNode: any) => HTMLElement;
|
|
50
51
|
};
|
|
@@ -58,48 +59,49 @@ declare const InputTable: React.ForwardRefExoticComponent<{
|
|
|
58
59
|
proFieldProps?: import("ls-pro-utils").ProFieldProps | undefined;
|
|
59
60
|
footerRender?: import("ls-pro-form").LightFilterFooterRender | undefined;
|
|
60
61
|
} & Omit<import("ls-pro-form/lib/components/FormItem").ProFormItemProps, "valueType"> & import("ls-pro-form/lib/interface").ExtendsProps & {
|
|
61
|
-
|
|
62
|
+
/** @name 弹框选择表格列配置 */
|
|
62
63
|
columns: any[];
|
|
63
|
-
|
|
64
|
+
/** @name 调用后端API地址 */
|
|
64
65
|
url: string;
|
|
65
|
-
|
|
66
|
+
/** @name 弹框表格高度,默认400 */
|
|
66
67
|
tableHeight?: number | undefined;
|
|
67
|
-
|
|
68
|
+
/** @name 弹框表格宽度,默认650 */
|
|
68
69
|
tableWidth?: number | undefined;
|
|
69
|
-
|
|
70
|
+
/** @name 是否支持多选 */
|
|
70
71
|
multiple?: boolean | undefined;
|
|
71
|
-
|
|
72
|
+
/** @name 表单项name, 跟 form.item 的 name一致 */
|
|
72
73
|
name: string;
|
|
73
|
-
|
|
74
|
+
/** @name 返回的值字段,表格中valueField配置的字段时返回给name */
|
|
74
75
|
valueField: string;
|
|
75
|
-
|
|
76
|
+
/** @name 返回输入框显示的字段,textField字段值返回给textName */
|
|
76
77
|
textField?: string | undefined;
|
|
77
|
-
|
|
78
|
+
/** @name 用于接收textField返回的值 */
|
|
78
79
|
textName?: string | undefined;
|
|
79
80
|
/** @name 表格的其它配置 */
|
|
80
81
|
tableConfig?: any;
|
|
81
|
-
|
|
82
|
+
/** @name 表单label宽度,默认70 */
|
|
82
83
|
labelWidth?: number | undefined;
|
|
83
|
-
|
|
84
|
+
/** @name 是否2.0接口 */
|
|
84
85
|
isV2?: boolean | undefined;
|
|
85
|
-
|
|
86
|
+
/** @name 是否支持跨页选择 */
|
|
86
87
|
keepSelect?: boolean | undefined;
|
|
87
|
-
|
|
88
|
+
/** @name 回车事件查询关键字 */
|
|
88
89
|
searchField?: string | undefined;
|
|
89
|
-
|
|
90
|
+
/** @name 填充其它表单项目配置 */
|
|
90
91
|
fillMap?: Record<string, string> | undefined;
|
|
91
|
-
|
|
92
|
+
/** @name 输入后检查数据的触发方式,默认为entry回车触发 */
|
|
92
93
|
triggerCheck?: "entry" | "blur" | undefined;
|
|
93
|
-
|
|
94
|
+
/** @name 每次展示面板时都加载数据,接合 tableConfig里的 manualRequest 一起使用 */
|
|
94
95
|
loadOnShow?: boolean | undefined;
|
|
95
96
|
placement?: TooltipPlacement | undefined;
|
|
96
97
|
arrowPointAtCenter?: boolean | undefined;
|
|
98
|
+
method?: "POST" | "GET" | undefined;
|
|
97
99
|
rowKey?: any;
|
|
98
|
-
|
|
100
|
+
/** @name 选择行事件 */
|
|
99
101
|
onSelectChange?: ((item: any, formRef?: any) => void) | undefined;
|
|
100
|
-
|
|
102
|
+
/** @name 加载之前事件,param为查询条件对象,可以通过此方法调整 */
|
|
101
103
|
beforeLoad?: ((param: any) => void) | undefined;
|
|
102
|
-
|
|
104
|
+
/** @name 加载之后事件,row为接口返回数据,可以通过此方法调整 */
|
|
103
105
|
afterLoad?: ((rows: any[]) => void) | undefined;
|
|
104
106
|
getPopupContainer?: ((triggerNode: any) => HTMLElement) | undefined;
|
|
105
107
|
} & React.RefAttributes<unknown>>;
|
|
@@ -11,14 +11,14 @@ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
|
11
11
|
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
12
12
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
13
13
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
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"],
|
|
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"],
|
|
15
15
|
_excluded2 = ["current", "pageSize"];
|
|
16
16
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
17
17
|
import React, { useRef, useState, useEffect, useContext, useMemo, useImperativeHandle } from 'react';
|
|
18
18
|
import ProTable from 'ls-pro-table';
|
|
19
19
|
import { ProFormText, ProFormContext } from 'ls-pro-form';
|
|
20
20
|
import { MoreOutlined } from '@ant-design/icons';
|
|
21
|
-
import { httpGet } from '../http';
|
|
21
|
+
import { httpGet, httpPost } from '../http';
|
|
22
22
|
import { isDev, showWarn } from '../utils';
|
|
23
23
|
var InputTable = /*#__PURE__*/React.forwardRef(function (prop, ref) {
|
|
24
24
|
//@ts-ignore
|
|
@@ -66,7 +66,7 @@ var InputTable = /*#__PURE__*/React.forwardRef(function (prop, ref) {
|
|
|
66
66
|
_prop$allowClear = prop.allowClear,
|
|
67
67
|
allowClear = _prop$allowClear === void 0 ? true : _prop$allowClear,
|
|
68
68
|
_prop$keepSelect = prop.keepSelect,
|
|
69
|
-
keepSelect = _prop$keepSelect === void 0 ?
|
|
69
|
+
keepSelect = _prop$keepSelect === void 0 ? true : _prop$keepSelect,
|
|
70
70
|
fieldProps = prop.fieldProps,
|
|
71
71
|
searchField = prop.searchField,
|
|
72
72
|
fillMap = prop.fillMap,
|
|
@@ -83,6 +83,8 @@ var InputTable = /*#__PURE__*/React.forwardRef(function (prop, ref) {
|
|
|
83
83
|
_prop$arrowPointAtCen = prop.arrowPointAtCenter,
|
|
84
84
|
arrowPointAtCenter = _prop$arrowPointAtCen === void 0 ? true : _prop$arrowPointAtCen,
|
|
85
85
|
rowKey = prop.rowKey,
|
|
86
|
+
_prop$method = prop.method,
|
|
87
|
+
method = _prop$method === void 0 ? 'GET' : _prop$method,
|
|
86
88
|
rest = _objectWithoutProperties(prop, _excluded);
|
|
87
89
|
if (!valueField && isDev) {
|
|
88
90
|
console.error('valueField 属性必须设置');
|
|
@@ -132,7 +134,6 @@ var InputTable = /*#__PURE__*/React.forwardRef(function (prop, ref) {
|
|
|
132
134
|
data.page = current;
|
|
133
135
|
data.pageSize = pageSize;
|
|
134
136
|
}
|
|
135
|
-
;
|
|
136
137
|
if (Object.keys(rest).length && !isV2) {
|
|
137
138
|
data.where = rest;
|
|
138
139
|
} else {
|
|
@@ -145,11 +146,22 @@ var InputTable = /*#__PURE__*/React.forwardRef(function (prop, ref) {
|
|
|
145
146
|
if (beforeLoad) {
|
|
146
147
|
beforeLoad(data);
|
|
147
148
|
}
|
|
148
|
-
|
|
149
|
-
|
|
149
|
+
if (!(method !== 'GET')) {
|
|
150
|
+
_context.next = 12;
|
|
151
|
+
break;
|
|
152
|
+
}
|
|
153
|
+
_context.next = 9;
|
|
154
|
+
return httpPost(url, data);
|
|
155
|
+
case 9:
|
|
156
|
+
result = _context.sent;
|
|
157
|
+
_context.next = 15;
|
|
158
|
+
break;
|
|
159
|
+
case 12:
|
|
160
|
+
_context.next = 14;
|
|
150
161
|
return httpGet(url, data);
|
|
151
|
-
case
|
|
162
|
+
case 14:
|
|
152
163
|
result = _context.sent;
|
|
164
|
+
case 15:
|
|
153
165
|
rows = result.rows || [];
|
|
154
166
|
if (afterLoad) {
|
|
155
167
|
afterLoad(rows);
|
|
@@ -161,7 +173,7 @@ var InputTable = /*#__PURE__*/React.forwardRef(function (prop, ref) {
|
|
|
161
173
|
arr = val.split(',');
|
|
162
174
|
pageSelectedRows = rows.filter(function (row) {
|
|
163
175
|
return arr.includes(row[valueField]);
|
|
164
|
-
}); // 过滤 selectRowRef.current 中已存在的行
|
|
176
|
+
}); // 过滤 selectRowRef.current 中已存在的行
|
|
165
177
|
pageSelectedRows = pageSelectedRows.filter(function (row) {
|
|
166
178
|
return !selectRowRef.current.some(function (o) {
|
|
167
179
|
return o[valueField] === row[valueField];
|
|
@@ -179,7 +191,7 @@ var InputTable = /*#__PURE__*/React.forwardRef(function (prop, ref) {
|
|
|
179
191
|
total: Number(result.total || 0),
|
|
180
192
|
success: true
|
|
181
193
|
});
|
|
182
|
-
case
|
|
194
|
+
case 19:
|
|
183
195
|
case "end":
|
|
184
196
|
return _context.stop();
|
|
185
197
|
}
|
|
@@ -272,6 +284,11 @@ var InputTable = /*#__PURE__*/React.forwardRef(function (prop, ref) {
|
|
|
272
284
|
}
|
|
273
285
|
onSelectChange === null || onSelectChange === void 0 ? void 0 : onSelectChange(row, formRef);
|
|
274
286
|
};
|
|
287
|
+
var handleClear = function handleClear() {
|
|
288
|
+
var _tableRef$current2, _tableRef$current2$cl;
|
|
289
|
+
selectRowRef.current = [];
|
|
290
|
+
(_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);
|
|
291
|
+
};
|
|
275
292
|
// 可输入时,回车或失去焦点调接口查询数据
|
|
276
293
|
var onQuery = function onQuery(e) {
|
|
277
294
|
if (rest.disabled || (fieldProps === null || fieldProps === void 0 ? void 0 : fieldProps.disabled) || readonly) return;
|
|
@@ -343,35 +360,39 @@ var InputTable = /*#__PURE__*/React.forwardRef(function (prop, ref) {
|
|
|
343
360
|
};
|
|
344
361
|
useEffect(function () {
|
|
345
362
|
if (!text && multiple) {
|
|
346
|
-
var _tableRef$
|
|
363
|
+
var _tableRef$current3, _tableRef$current3$cl;
|
|
347
364
|
selectRowRef.current = [];
|
|
348
|
-
(_tableRef$
|
|
365
|
+
(_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);
|
|
349
366
|
}
|
|
350
367
|
}, [text, multiple]);
|
|
351
368
|
useEffect(function () {
|
|
352
369
|
if (visible && loadOnShow) {
|
|
353
|
-
var _tableRef$
|
|
354
|
-
(_tableRef$
|
|
370
|
+
var _tableRef$current4, _tableRef$current4$re;
|
|
371
|
+
(_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);
|
|
355
372
|
}
|
|
356
373
|
}, [visible, loadOnShow]);
|
|
374
|
+
useEffect(function () {
|
|
375
|
+
// if (!visible || !multiple || !text) return;
|
|
376
|
+
// const list = tableRef.current?.getDatasource();
|
|
377
|
+
// if (list?.length > 0 && selectRowRef.current.length === 0) {
|
|
378
|
+
// }
|
|
379
|
+
}, [visible, text]);
|
|
357
380
|
var tableDom = /*#__PURE__*/React.createElement(ProTable, _extends({
|
|
358
381
|
className: "ls-input-table",
|
|
359
382
|
columns: columns,
|
|
360
383
|
request: loadData,
|
|
361
384
|
manualRequest: false,
|
|
362
385
|
actionRef: tableRef,
|
|
386
|
+
cellSelectable: false,
|
|
363
387
|
search: {
|
|
364
|
-
labelWidth: labelWidth
|
|
365
|
-
|
|
388
|
+
labelWidth: labelWidth,
|
|
389
|
+
btnInline: true
|
|
366
390
|
},
|
|
367
391
|
options: {
|
|
368
392
|
density: false,
|
|
369
393
|
reload: false,
|
|
370
394
|
setting: false
|
|
371
395
|
},
|
|
372
|
-
form: {
|
|
373
|
-
btnInline: true
|
|
374
|
-
},
|
|
375
396
|
height: 'full',
|
|
376
397
|
rowKey: tableKey,
|
|
377
398
|
onRow: function onRow(record) {
|
|
@@ -391,7 +412,7 @@ var InputTable = /*#__PURE__*/React.forwardRef(function (prop, ref) {
|
|
|
391
412
|
}
|
|
392
413
|
}, "\u786E\u8BA4")] : [];
|
|
393
414
|
},
|
|
394
|
-
headerTitle: multiple ? null :
|
|
415
|
+
headerTitle: multiple ? null : '双击选中当前行数据',
|
|
395
416
|
cardProps: {
|
|
396
417
|
bodyStyle: {
|
|
397
418
|
padding: 0
|
|
@@ -406,7 +427,9 @@ var InputTable = /*#__PURE__*/React.forwardRef(function (prop, ref) {
|
|
|
406
427
|
selectRowRef.current = rows;
|
|
407
428
|
setSelectedKeys(keys);
|
|
408
429
|
}
|
|
409
|
-
} : false
|
|
430
|
+
} : false,
|
|
431
|
+
showClear: true,
|
|
432
|
+
selectedTagField: textField || valueField
|
|
410
433
|
}));
|
|
411
434
|
// 处理有值时,可清空
|
|
412
435
|
useEffect(function () {
|
|
@@ -16,25 +16,27 @@ var TagCheck = function TagCheck(props) {
|
|
|
16
16
|
tagStyle = props.tagStyle,
|
|
17
17
|
options = props.options,
|
|
18
18
|
_props$multiple = props.multiple,
|
|
19
|
-
multiple = _props$multiple === void 0 ? true : _props$multiple
|
|
19
|
+
multiple = _props$multiple === void 0 ? true : _props$multiple,
|
|
20
|
+
_props$disabled = props.disabled,
|
|
21
|
+
disabled = _props$disabled === void 0 ? false : _props$disabled,
|
|
22
|
+
_props$readonly = props.readonly,
|
|
23
|
+
readonly = _props$readonly === void 0 ? false : _props$readonly;
|
|
20
24
|
var _useState = useState(toArray(props.value)),
|
|
21
25
|
_useState2 = _slicedToArray(_useState, 2),
|
|
22
26
|
innerValue = _useState2[0],
|
|
23
27
|
setInnerValue = _useState2[1];
|
|
24
28
|
useEffect(function () {
|
|
25
|
-
if (!('value' in props)) return;
|
|
26
29
|
setInnerValue(toArray(props.value));
|
|
27
30
|
}, [props.value]);
|
|
28
31
|
return /*#__PURE__*/React.createElement("div", {
|
|
29
32
|
style: style,
|
|
30
33
|
className: classNames('tag-check', className)
|
|
31
|
-
}, multiple && options.length > 0 && /*#__PURE__*/React.createElement(_Tag.CheckableTag, {
|
|
34
|
+
}, multiple && options.length > 0 && !disabled && !readonly && /*#__PURE__*/React.createElement(_Tag.CheckableTag, {
|
|
32
35
|
checked: innerValue.length === options.length,
|
|
33
36
|
onChange: function onChange(checked) {
|
|
34
37
|
var val = checked ? options.map(function (o) {
|
|
35
38
|
return o.value;
|
|
36
39
|
}) : [];
|
|
37
|
-
setInnerValue(val);
|
|
38
40
|
_onChange === null || _onChange === void 0 ? void 0 : _onChange(val.length ? val : undefined, 'all', checked);
|
|
39
41
|
}
|
|
40
42
|
}, "\u5168\u90E8"), options && options.map(function (item) {
|
|
@@ -46,6 +48,7 @@ var TagCheck = function TagCheck(props) {
|
|
|
46
48
|
return item.value == o;
|
|
47
49
|
}).length > 0,
|
|
48
50
|
onChange: function onChange(checked) {
|
|
51
|
+
if (readonly || disabled) return;
|
|
49
52
|
var val = [];
|
|
50
53
|
if (checked) {
|
|
51
54
|
val = multiple ? [].concat(_toConsumableArray(innerValue), [item.value]) : [item.value];
|
|
@@ -54,7 +57,6 @@ var TagCheck = function TagCheck(props) {
|
|
|
54
57
|
return o != item.value;
|
|
55
58
|
});
|
|
56
59
|
}
|
|
57
|
-
setInnerValue(val);
|
|
58
60
|
_onChange === null || _onChange === void 0 ? void 0 : _onChange(val.length ? multiple ? val : val[0] : undefined, item, checked);
|
|
59
61
|
}
|
|
60
62
|
}, item.label);
|
|
@@ -152,13 +152,13 @@
|
|
|
152
152
|
|
|
153
153
|
.ant-btn-dangerous {
|
|
154
154
|
color: #f5222d;
|
|
155
|
-
background-color: #
|
|
155
|
+
background-color: #fff1f0;
|
|
156
156
|
border-color: transparent;
|
|
157
157
|
|
|
158
158
|
&:hover,
|
|
159
159
|
&:focus {
|
|
160
160
|
color: #f5222d;
|
|
161
|
-
background-color: #
|
|
161
|
+
background-color: #ffccc7;
|
|
162
162
|
border-color: transparent;
|
|
163
163
|
}
|
|
164
164
|
|