ls-pro-common 1.1.1 → 1.1.3
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 +66 -3
- package/dist/common.js +1 -1
- package/dist/common.js.LICENSE.txt +14 -3
- package/dist/common.min.css +66 -3
- package/dist/common.min.js +1 -1
- package/dist/common.min.js.LICENSE.txt +14 -3
- package/es/components/AreaCascader.js +35 -48
- package/es/components/AreaCascaderPanel.js +55 -85
- package/es/components/DescritionCard.js +14 -19
- package/es/components/DtlLayout.js +25 -38
- package/es/components/IconSelector.js +27 -50
- package/es/components/ImageSelector.js +89 -139
- package/es/components/InputMultiLine.js +33 -45
- package/es/components/InputTable.js +118 -160
- package/es/components/Loading.js +3 -6
- package/es/components/Permission.d.ts +6 -0
- package/es/components/Permission.js +10 -0
- package/es/components/common.less +63 -0
- package/es/hooks/useDtl/index.d.ts +2 -2
- package/es/hooks/useDtl/index.js +685 -950
- package/es/hooks/usePermission/index.js +0 -9
- package/es/hooks/useSingle/index.d.ts +3 -3
- package/es/hooks/useSingle/index.js +431 -603
- package/es/http/index.js +116 -154
- package/es/index.d.ts +4 -2
- package/es/index.js +2 -2
- package/es/service/BaseService.js +121 -195
- package/es/utils/index.d.ts +9 -22
- package/es/utils/index.js +63 -181
- package/lib/components/404.js +1 -6
- package/lib/components/AreaCascader.js +37 -63
- package/lib/components/AreaCascaderPanel.js +57 -105
- package/lib/components/DescritionCard.js +16 -33
- package/lib/components/DtlLayout.js +27 -49
- package/lib/components/IconSelector.js +29 -64
- package/lib/components/ImageSelector.js +91 -162
- package/lib/components/InputMultiLine.js +35 -61
- package/lib/components/InputTable.js +120 -185
- package/lib/components/Loading.js +4 -16
- package/lib/components/Permission.d.ts +6 -0
- package/lib/components/Permission.js +18 -0
- package/lib/components/common.less +63 -0
- package/lib/hooks/useDtl/index.d.ts +2 -2
- package/lib/hooks/useDtl/index.js +686 -966
- package/lib/hooks/usePermission/index.js +0 -12
- package/lib/hooks/useSingle/index.d.ts +3 -3
- package/lib/hooks/useSingle/index.js +432 -618
- package/lib/http/index.js +114 -163
- package/lib/index.d.ts +4 -2
- package/lib/index.js +9 -21
- package/lib/service/BaseService.js +121 -201
- package/lib/utils/index.d.ts +9 -22
- package/lib/utils/index.js +85 -290
- package/package.json +2 -2
|
@@ -16,27 +16,22 @@ import { useMemo, useState, useContext, useEffect, useRef } from 'react';
|
|
|
16
16
|
import { ProFormText, ProFormContext } from 'ls-pro-form';
|
|
17
17
|
import { PlusOutlined, SearchOutlined } from '@ant-design/icons';
|
|
18
18
|
var iconList = ['icon-Menu1', 'icon-Menu2', 'icon-Menu3', 'icon-Menu4', 'icon-Menu5', 'icon-Menu6', 'icon-Menu7', 'icon-Menu8', 'icon-Menu9', 'icon-Menu10', 'icon-Menu11', 'icon-Menu12', 'icon-Menu13', 'icon-Menu14', 'icon-Menu15', 'icon-Menu16', 'icon-Menu17', 'icon-Menu18', 'icon-Menu19', 'icon-Menu20', 'icon-Menu21', 'icon-Menu22', 'icon-Menu23', 'icon-Menu24', 'icon-Menu25', 'icon-Menu26', 'icon-Menu27', 'icon-Menu28', 'icon-Menu29', 'icon-Menu30', 'icon-Menu31', 'icon-Menu32', 'icon-Menu33', 'icon-Menu34', 'icon-Menu35', 'icon-Menu36', 'icon-Menu37', 'icon-Menu38', 'icon-Menu39', 'icon-Menu40', 'icon-Menu41', 'icon-Menu42', 'icon-Menu43', 'icon-Menu44', 'icon-Menu45', 'icon-Menu46', 'icon-Menu47'];
|
|
19
|
-
|
|
20
19
|
function IconSelector(prop) {
|
|
21
20
|
//@ts-ignore?
|
|
22
21
|
var _useContext = useContext(ProFormContext),
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
formRef = _useContext.formRef;
|
|
25
23
|
var _useState = useState(false),
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
24
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
25
|
+
visible = _useState2[0],
|
|
26
|
+
setVisible = _useState2[1];
|
|
30
27
|
var _useState3 = useState(''),
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
28
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
29
|
+
icon = _useState4[0],
|
|
30
|
+
setIcon = _useState4[1];
|
|
35
31
|
var _useState5 = useState(''),
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
32
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
33
|
+
searchKey = _useState6[0],
|
|
34
|
+
setSearchKey = _useState6[1];
|
|
40
35
|
var inputRef = useRef();
|
|
41
36
|
var list = useMemo(function () {
|
|
42
37
|
if (!searchKey) return [].concat(iconList);
|
|
@@ -44,27 +39,23 @@ function IconSelector(prop) {
|
|
|
44
39
|
return o.includes(searchKey);
|
|
45
40
|
});
|
|
46
41
|
}, [searchKey]);
|
|
47
|
-
|
|
48
42
|
var _prop$readonly = prop.readonly,
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
43
|
+
readonly = _prop$readonly === void 0 ? true : _prop$readonly,
|
|
44
|
+
_prop$allowClear = prop.allowClear,
|
|
45
|
+
allowClear = _prop$allowClear === void 0 ? true : _prop$allowClear,
|
|
46
|
+
_prop$title = prop.title,
|
|
47
|
+
title = _prop$title === void 0 ? "选择图标" : _prop$title,
|
|
48
|
+
_prop$modalWidth = prop.modalWidth,
|
|
49
|
+
modalWidth = _prop$modalWidth === void 0 ? '630px' : _prop$modalWidth,
|
|
50
|
+
name = prop.name,
|
|
51
|
+
_prop$isInput = prop.isInput,
|
|
52
|
+
isInput = _prop$isInput === void 0 ? true : _prop$isInput,
|
|
53
|
+
modalProps = prop.modalProps,
|
|
54
|
+
defaultValue = prop.defaultValue,
|
|
55
|
+
rest = _objectWithoutProperties(prop, _excluded);
|
|
63
56
|
useEffect(function () {
|
|
64
57
|
var _formRef$current;
|
|
65
|
-
|
|
66
58
|
var val = (_formRef$current = formRef.current) === null || _formRef$current === void 0 ? void 0 : _formRef$current.getFieldsValue();
|
|
67
|
-
|
|
68
59
|
if (val && val[name]) {
|
|
69
60
|
setIcon(val[name]);
|
|
70
61
|
}
|
|
@@ -76,14 +67,11 @@ function IconSelector(prop) {
|
|
|
76
67
|
}, [defaultValue]);
|
|
77
68
|
useEffect(function () {
|
|
78
69
|
var _rest$fieldProps;
|
|
79
|
-
|
|
80
70
|
if ((rest === null || rest === void 0 ? void 0 : rest.disabled) || (rest === null || rest === void 0 ? void 0 : (_rest$fieldProps = rest.fieldProps) === null || _rest$fieldProps === void 0 ? void 0 : _rest$fieldProps.disabled)) return;
|
|
81
|
-
|
|
82
71
|
try {
|
|
83
72
|
if (!inputRef.current) return;
|
|
84
73
|
var el = inputRef.current.input.parentNode;
|
|
85
74
|
if (!el) return;
|
|
86
|
-
|
|
87
75
|
if (icon) {
|
|
88
76
|
el.classList.add('ant-input-has-value');
|
|
89
77
|
} else {
|
|
@@ -91,25 +79,20 @@ function IconSelector(prop) {
|
|
|
91
79
|
}
|
|
92
80
|
} catch (e) {}
|
|
93
81
|
}, [icon]);
|
|
94
|
-
|
|
95
82
|
var showSelector = function showSelector(flag) {
|
|
96
83
|
var _rest$fieldProps2;
|
|
97
|
-
|
|
98
84
|
if ((rest === null || rest === void 0 ? void 0 : rest.disabled) || (rest === null || rest === void 0 ? void 0 : (_rest$fieldProps2 = rest.fieldProps) === null || _rest$fieldProps2 === void 0 ? void 0 : _rest$fieldProps2.disabled)) return;
|
|
99
85
|
setVisible(flag);
|
|
100
86
|
};
|
|
101
|
-
|
|
102
87
|
var clearValue = function clearValue(e) {
|
|
103
88
|
if (!e || !e.target.value) {
|
|
104
89
|
var _formRef$current2;
|
|
105
|
-
|
|
106
90
|
setIcon('');
|
|
107
91
|
var formValue = formRef === null || formRef === void 0 ? void 0 : (_formRef$current2 = formRef.current) === null || _formRef$current2 === void 0 ? void 0 : _formRef$current2.getFieldsValue();
|
|
108
92
|
formValue[name] = '';
|
|
109
93
|
formRef.current.setFieldsValue(_objectSpread({}, formValue));
|
|
110
94
|
}
|
|
111
95
|
};
|
|
112
|
-
|
|
113
96
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ProFormText, _extends({
|
|
114
97
|
name: name
|
|
115
98
|
}, rest), isInput ? /*#__PURE__*/React.createElement(_Input, _extends({
|
|
@@ -175,10 +158,8 @@ function IconSelector(prop) {
|
|
|
175
158
|
footer: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(_Button, {
|
|
176
159
|
onClick: function onClick() {
|
|
177
160
|
var formVal = formRef.current.getFieldsValue();
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
161
|
+
var val = _objectSpread({}, formVal);
|
|
162
|
+
//@ts-ignore
|
|
182
163
|
val[name] = '';
|
|
183
164
|
formRef.current.setFieldsValue(val);
|
|
184
165
|
setIcon('');
|
|
@@ -208,12 +189,9 @@ function IconSelector(prop) {
|
|
|
208
189
|
console.log('选择图标组件未设置name属性');
|
|
209
190
|
return;
|
|
210
191
|
}
|
|
211
|
-
|
|
212
192
|
var formVal = formRef.current.getFieldsValue();
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
193
|
+
var val = _objectSpread({}, formVal);
|
|
194
|
+
//@ts-ignore
|
|
217
195
|
val[name] = o;
|
|
218
196
|
formRef.current.setFieldsValue(val);
|
|
219
197
|
setIcon(o);
|
|
@@ -241,5 +219,4 @@ function IconSelector(prop) {
|
|
|
241
219
|
}, o));
|
|
242
220
|
}))));
|
|
243
221
|
}
|
|
244
|
-
|
|
245
222
|
export default IconSelector;
|
|
@@ -12,12 +12,12 @@ import "antd/es/input/style";
|
|
|
12
12
|
import _Input from "antd/es/input";
|
|
13
13
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
14
14
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
15
|
-
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
16
15
|
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
17
16
|
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
18
17
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
19
18
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
20
19
|
var _excluded = ["type", "uploadable", "readonly", "allowClear", "title", "modalWidth", "name", "maxSize", "modalProps", "code", "isInput", "desc", "imageClass"];
|
|
20
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
21
21
|
import React from "react";
|
|
22
22
|
import { useMemo, useState, useEffect, useContext, useRef } from 'react';
|
|
23
23
|
import { ProFormText, ProFormContext } from 'ls-pro-form';
|
|
@@ -25,225 +25,182 @@ import { PlusOutlined, UploadOutlined, SearchOutlined, CloseOutlined } from '@an
|
|
|
25
25
|
import { httpGet } from '../http';
|
|
26
26
|
import { getCache, showError, showWarn, showSuccess } from '../utils';
|
|
27
27
|
var fileCenter = getCache('ossPath') || '/petrel/petrel-file-center-api/lesoon/oss/file/';
|
|
28
|
-
|
|
29
28
|
function ImageSelector(prop) {
|
|
30
29
|
var _rest$fieldProps3;
|
|
31
|
-
|
|
32
30
|
//@ts-ignore?
|
|
33
31
|
var _useContext = useContext(ProFormContext),
|
|
34
|
-
|
|
35
|
-
|
|
32
|
+
formRef = _useContext.formRef;
|
|
36
33
|
var _useState = useState(false),
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
34
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
35
|
+
visible = _useState2[0],
|
|
36
|
+
setVisible = _useState2[1];
|
|
41
37
|
var _useState3 = useState(''),
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
38
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
39
|
+
imgUrl = _useState4[0],
|
|
40
|
+
setImgUrl = _useState4[1];
|
|
46
41
|
var _useState5 = useState([]),
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
42
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
43
|
+
list = _useState6[0],
|
|
44
|
+
setList = _useState6[1];
|
|
51
45
|
var _useState7 = useState(''),
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
46
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
47
|
+
searchKey = _useState8[0],
|
|
48
|
+
setSearchKey = _useState8[1];
|
|
56
49
|
var _useState9 = useState(''),
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
50
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
51
|
+
nextMarker = _useState10[0],
|
|
52
|
+
setNextMarker = _useState10[1];
|
|
61
53
|
var inputRef = useRef();
|
|
62
|
-
|
|
63
54
|
var type = prop.type,
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
55
|
+
_prop$uploadable = prop.uploadable,
|
|
56
|
+
uploadable = _prop$uploadable === void 0 ? true : _prop$uploadable,
|
|
57
|
+
_prop$readonly = prop.readonly,
|
|
58
|
+
readonly = _prop$readonly === void 0 ? true : _prop$readonly,
|
|
59
|
+
_prop$allowClear = prop.allowClear,
|
|
60
|
+
allowClear = _prop$allowClear === void 0 ? true : _prop$allowClear,
|
|
61
|
+
_prop$title = prop.title,
|
|
62
|
+
title = _prop$title === void 0 ? "选择图标" : _prop$title,
|
|
63
|
+
_prop$modalWidth = prop.modalWidth,
|
|
64
|
+
modalWidth = _prop$modalWidth === void 0 ? '600px' : _prop$modalWidth,
|
|
65
|
+
name = prop.name,
|
|
66
|
+
_prop$maxSize = prop.maxSize,
|
|
67
|
+
maxSize = _prop$maxSize === void 0 ? 5 : _prop$maxSize,
|
|
68
|
+
modalProps = prop.modalProps,
|
|
69
|
+
_prop$code = prop.code,
|
|
70
|
+
code = _prop$code === void 0 ? 'RETAIL' : _prop$code,
|
|
71
|
+
_prop$isInput = prop.isInput,
|
|
72
|
+
isInput = _prop$isInput === void 0 ? true : _prop$isInput,
|
|
73
|
+
_prop$desc = prop.desc,
|
|
74
|
+
desc = _prop$desc === void 0 ? '支持 png | jpg | gif 格式图片' : _prop$desc,
|
|
75
|
+
_prop$imageClass = prop.imageClass,
|
|
76
|
+
imageClass = _prop$imageClass === void 0 ? '' : _prop$imageClass,
|
|
77
|
+
rest = _objectWithoutProperties(prop, _excluded);
|
|
78
|
+
// 上传地址
|
|
89
79
|
var uploadImgApi = useMemo(function () {
|
|
90
80
|
return fileCenter + 'upload/' + code + '?catalogName=' + type;
|
|
91
|
-
}, [code, type]);
|
|
92
|
-
|
|
81
|
+
}, [code, type]);
|
|
82
|
+
// 分页加载列表地址
|
|
93
83
|
var pageImgApi = useMemo(function () {
|
|
94
84
|
return fileCenter + 'page/' + code;
|
|
95
|
-
}, [code]);
|
|
96
|
-
|
|
85
|
+
}, [code]);
|
|
86
|
+
// 展示地址
|
|
97
87
|
var showImgApi = useMemo(function () {
|
|
98
88
|
return fileCenter + 'show/' + code;
|
|
99
89
|
}, [code]);
|
|
100
|
-
|
|
101
90
|
var loadData = /*#__PURE__*/function () {
|
|
102
91
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(keys) {
|
|
103
92
|
var _result$data, _result$data2;
|
|
104
|
-
|
|
105
93
|
var url, param, result, rows;
|
|
106
94
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
107
|
-
while (1) {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
return
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
setList([].concat(_toConsumableArray(list), _toConsumableArray(rows)));
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
setNextMarker((_result$data2 = result.data) === null || _result$data2 === void 0 ? void 0 : _result$data2.nextMarker);
|
|
145
|
-
|
|
146
|
-
case 11:
|
|
147
|
-
case "end":
|
|
148
|
-
return _context.stop();
|
|
149
|
-
}
|
|
95
|
+
while (1) switch (_context.prev = _context.next) {
|
|
96
|
+
case 0:
|
|
97
|
+
url = pageImgApi;
|
|
98
|
+
param = {
|
|
99
|
+
prefix: type,
|
|
100
|
+
maxKeys: 16
|
|
101
|
+
};
|
|
102
|
+
if (keys) {
|
|
103
|
+
param.prefix = param.prefix + '/' + keys;
|
|
104
|
+
}
|
|
105
|
+
if (nextMarker) {
|
|
106
|
+
param.nextMarker = nextMarker;
|
|
107
|
+
}
|
|
108
|
+
_context.next = 6;
|
|
109
|
+
return httpGet(url, param, false);
|
|
110
|
+
case 6:
|
|
111
|
+
result = _context.sent;
|
|
112
|
+
rows = (((_result$data = result.data) === null || _result$data === void 0 ? void 0 : _result$data.objectList) || []).filter(function (o) {
|
|
113
|
+
return o.dir == false && (!nextMarker || !list.find(function (e) {
|
|
114
|
+
return e.path === o.path;
|
|
115
|
+
}));
|
|
116
|
+
});
|
|
117
|
+
rows.forEach(function (row) {
|
|
118
|
+
row.url = showImgApi + '?fileName=' + row.path;
|
|
119
|
+
});
|
|
120
|
+
if (!nextMarker) {
|
|
121
|
+
setList(rows);
|
|
122
|
+
} else {
|
|
123
|
+
setList([].concat(_toConsumableArray(list), _toConsumableArray(rows)));
|
|
124
|
+
}
|
|
125
|
+
setNextMarker((_result$data2 = result.data) === null || _result$data2 === void 0 ? void 0 : _result$data2.nextMarker);
|
|
126
|
+
case 11:
|
|
127
|
+
case "end":
|
|
128
|
+
return _context.stop();
|
|
150
129
|
}
|
|
151
130
|
}, _callee);
|
|
152
131
|
}));
|
|
153
|
-
|
|
154
132
|
return function loadData(_x) {
|
|
155
133
|
return _ref.apply(this, arguments);
|
|
156
134
|
};
|
|
157
135
|
}();
|
|
158
|
-
|
|
159
136
|
useEffect(function () {
|
|
160
137
|
if (!visible) {
|
|
161
138
|
setNextMarker('');
|
|
162
139
|
setSearchKey('');
|
|
163
140
|
return;
|
|
164
141
|
}
|
|
165
|
-
|
|
166
142
|
loadData(searchKey);
|
|
167
143
|
}, [visible, searchKey]);
|
|
168
144
|
useEffect(function () {
|
|
169
145
|
var val = formRef.current.getFieldsValue();
|
|
170
|
-
|
|
171
146
|
if (val && val[name]) {
|
|
172
147
|
setImgUrl(val[name]);
|
|
173
148
|
}
|
|
174
|
-
}, []);
|
|
175
|
-
|
|
149
|
+
}, []);
|
|
150
|
+
// 验证上传文件大小
|
|
176
151
|
var beforeUpload = function beforeUpload(file) {
|
|
177
152
|
var sizeLimit = file.size / 1024 / 1024 >= maxSize;
|
|
178
|
-
|
|
179
153
|
if (sizeLimit) {
|
|
180
154
|
showError("\u4E0A\u4F20\u7684\u6587\u4EF6\u4E0D\u80FD\u5927\u4E8E".concat(maxSize, "M"));
|
|
181
155
|
}
|
|
182
|
-
|
|
183
156
|
return !sizeLimit;
|
|
184
|
-
};
|
|
185
|
-
|
|
186
|
-
|
|
157
|
+
};
|
|
158
|
+
// 上传图片
|
|
187
159
|
var onUpload = function onUpload(info) {
|
|
188
160
|
var isDirect = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
189
|
-
|
|
190
161
|
if (info.file.status === 'done') {
|
|
191
162
|
var _result$flag;
|
|
192
|
-
|
|
193
163
|
var result = info.file.response;
|
|
194
|
-
|
|
195
164
|
if ((result === null || result === void 0 ? void 0 : (_result$flag = result.flag) === null || _result$flag === void 0 ? void 0 : _result$flag.retCode) === '0') {
|
|
196
|
-
showSuccess(result.flag.retMsg);
|
|
197
|
-
|
|
165
|
+
showSuccess(result.flag.retMsg);
|
|
166
|
+
// 直接上传
|
|
198
167
|
if (isDirect) {
|
|
199
168
|
var _result$rows$;
|
|
200
|
-
|
|
201
169
|
var img = showImgApi + '?fileName=' + (result === null || result === void 0 ? void 0 : (_result$rows$ = result.rows[0]) === null || _result$rows$ === void 0 ? void 0 : _result$rows$.newFileId);
|
|
202
170
|
setImgUrl(img);
|
|
203
171
|
var formVal = formRef.current.getFieldsValue();
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
172
|
+
var val = _objectSpread({}, formVal);
|
|
173
|
+
//@ts-ignore
|
|
208
174
|
val[name] = img;
|
|
209
175
|
formRef.current.setFieldsValue(val);
|
|
210
176
|
}
|
|
211
177
|
} else {
|
|
212
178
|
var _result$flag2;
|
|
213
|
-
|
|
214
179
|
showError((result === null || result === void 0 ? void 0 : (_result$flag2 = result.flag) === null || _result$flag2 === void 0 ? void 0 : _result$flag2.retMsg) || '上传图片失败,请联系管理员');
|
|
215
180
|
}
|
|
216
181
|
} else if (info.file.status === 'error') {
|
|
217
182
|
showError('上传数据失败,请联系管理员');
|
|
218
183
|
}
|
|
219
|
-
|
|
220
184
|
if (!isDirect && !info.fileList.filter(function (o) {
|
|
221
185
|
return o.status === 'uploading';
|
|
222
186
|
}).length) {
|
|
223
187
|
loadData(searchKey);
|
|
224
188
|
}
|
|
225
189
|
};
|
|
226
|
-
|
|
227
190
|
var showSelect = function showSelect() {
|
|
228
191
|
var _rest$fieldProps;
|
|
229
|
-
|
|
230
192
|
if ((rest === null || rest === void 0 ? void 0 : rest.disabled) || (rest === null || rest === void 0 ? void 0 : (_rest$fieldProps = rest.fieldProps) === null || _rest$fieldProps === void 0 ? void 0 : _rest$fieldProps.disabled)) {
|
|
231
193
|
return;
|
|
232
194
|
}
|
|
233
|
-
|
|
234
195
|
setVisible(true);
|
|
235
196
|
};
|
|
236
|
-
|
|
237
197
|
useEffect(function () {
|
|
238
198
|
var _rest$fieldProps2;
|
|
239
|
-
|
|
240
199
|
if ((rest === null || rest === void 0 ? void 0 : rest.disabled) || (rest === null || rest === void 0 ? void 0 : (_rest$fieldProps2 = rest.fieldProps) === null || _rest$fieldProps2 === void 0 ? void 0 : _rest$fieldProps2.disabled)) return;
|
|
241
|
-
|
|
242
200
|
try {
|
|
243
201
|
if (!inputRef.current) return;
|
|
244
202
|
var el = inputRef.current.input.parentNode;
|
|
245
203
|
if (!el) return;
|
|
246
|
-
|
|
247
204
|
if (imgUrl) {
|
|
248
205
|
el.classList.add('ant-input-has-value');
|
|
249
206
|
} else {
|
|
@@ -251,18 +208,15 @@ function ImageSelector(prop) {
|
|
|
251
208
|
}
|
|
252
209
|
} catch (e) {}
|
|
253
210
|
}, [imgUrl]);
|
|
254
|
-
|
|
255
211
|
var clearValue = function clearValue(e) {
|
|
256
212
|
if (!e || !e.target.value) {
|
|
257
213
|
var _formRef$current;
|
|
258
|
-
|
|
259
214
|
setImgUrl('');
|
|
260
215
|
var formValue = formRef === null || formRef === void 0 ? void 0 : (_formRef$current = formRef.current) === null || _formRef$current === void 0 ? void 0 : _formRef$current.getFieldsValue();
|
|
261
216
|
formValue[name] = '';
|
|
262
217
|
formRef.current.setFieldsValue(_objectSpread({}, formValue));
|
|
263
218
|
}
|
|
264
219
|
};
|
|
265
|
-
|
|
266
220
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ProFormText, _extends({
|
|
267
221
|
name: name
|
|
268
222
|
}, rest), isInput ? /*#__PURE__*/React.createElement(_Input, _extends({
|
|
@@ -401,12 +355,9 @@ function ImageSelector(prop) {
|
|
|
401
355
|
showWarn('选择图标组件未设置name属性');
|
|
402
356
|
return;
|
|
403
357
|
}
|
|
404
|
-
|
|
405
358
|
var formVal = formRef.current.getFieldsValue();
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
359
|
+
var val = _objectSpread({}, formVal);
|
|
360
|
+
//@ts-ignore
|
|
410
361
|
val[name] = o.url;
|
|
411
362
|
formRef.current.setFieldsValue(val);
|
|
412
363
|
setImgUrl(o.url);
|
|
@@ -435,5 +386,4 @@ function ImageSelector(prop) {
|
|
|
435
386
|
image: _Empty.PRESENTED_IMAGE_SIMPLE
|
|
436
387
|
}))));
|
|
437
388
|
}
|
|
438
|
-
|
|
439
389
|
export default ImageSelector;
|
|
@@ -13,74 +13,65 @@ import { UnorderedListOutlined } from '@ant-design/icons';
|
|
|
13
13
|
var InputMultiLine = /*#__PURE__*/React.forwardRef(function (prop, ref) {
|
|
14
14
|
//@ts-ignore
|
|
15
15
|
var _useContext = useContext(ProFormContext),
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
formRef = _useContext.formRef;
|
|
18
17
|
var _useState = useState(''),
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
19
|
+
text = _useState2[0],
|
|
20
|
+
setText = _useState2[1];
|
|
23
21
|
var _useState3 = useState(''),
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
23
|
+
lineText = _useState4[0],
|
|
24
|
+
setLineText = _useState4[1];
|
|
28
25
|
var _useState5 = useState(false),
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
26
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
27
|
+
visible = _useState6[0],
|
|
28
|
+
setVisible = _useState6[1];
|
|
33
29
|
var inputRef = useRef();
|
|
34
30
|
useImperativeHandle(ref, function () {
|
|
35
31
|
return inputRef.current;
|
|
36
32
|
});
|
|
37
|
-
|
|
38
33
|
var name = prop.name,
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
34
|
+
_prop$rows = prop.rows,
|
|
35
|
+
rows = _prop$rows === void 0 ? 12 : _prop$rows,
|
|
36
|
+
_prop$maxRows = prop.maxRows,
|
|
37
|
+
maxRows = _prop$maxRows === void 0 ? 20 : _prop$maxRows,
|
|
38
|
+
_prop$placement = prop.placement,
|
|
39
|
+
placement = _prop$placement === void 0 ? 'bottom' : _prop$placement,
|
|
40
|
+
_prop$popWidth = prop.popWidth,
|
|
41
|
+
popWidth = _prop$popWidth === void 0 ? '400px' : _prop$popWidth,
|
|
42
|
+
fieldProps = prop.fieldProps,
|
|
43
|
+
defaultValue = prop.defaultValue,
|
|
44
|
+
_prop$allowClear = prop.allowClear,
|
|
45
|
+
allowClear = _prop$allowClear === void 0 ? true : _prop$allowClear,
|
|
46
|
+
_prop$getPopupContain = prop.getPopupContainer,
|
|
47
|
+
getPopupContainer = _prop$getPopupContain === void 0 ? function (triggerNode) {
|
|
48
|
+
return triggerNode.parentNode.parentNode.parentNode.parentNode;
|
|
49
|
+
} : _prop$getPopupContain,
|
|
50
|
+
textAreaProps = prop.textAreaProps,
|
|
51
|
+
rest = _objectWithoutProperties(prop, _excluded);
|
|
52
|
+
// 设置初始值
|
|
59
53
|
useEffect(function () {
|
|
60
54
|
if (defaultValue) {
|
|
61
55
|
setText(defaultValue);
|
|
62
56
|
} else if (name) {
|
|
63
57
|
var _formRef$current;
|
|
64
|
-
|
|
65
58
|
var formValue = formRef === null || formRef === void 0 ? void 0 : (_formRef$current = formRef.current) === null || _formRef$current === void 0 ? void 0 : _formRef$current.getFieldsValue();
|
|
66
59
|
setText(formValue[name]);
|
|
67
60
|
}
|
|
68
|
-
}, []);
|
|
69
|
-
|
|
61
|
+
}, []);
|
|
62
|
+
// 显示多行输入时,赋值给多行文本框
|
|
70
63
|
useEffect(function () {
|
|
71
64
|
if (!visible) return;
|
|
72
65
|
var line = (text || '').split(',').join('\n');
|
|
73
66
|
setLineText(line);
|
|
74
|
-
}, [visible, text]);
|
|
75
|
-
|
|
67
|
+
}, [visible, text]);
|
|
68
|
+
// 输入框值变化时,赋值给表单项
|
|
76
69
|
useEffect(function () {
|
|
77
70
|
var _formRef$current2, _formRef$current3;
|
|
78
|
-
|
|
79
71
|
var formValue = formRef === null || formRef === void 0 ? void 0 : (_formRef$current2 = formRef.current) === null || _formRef$current2 === void 0 ? void 0 : _formRef$current2.getFieldsValue();
|
|
80
72
|
formValue[name] = text;
|
|
81
73
|
(_formRef$current3 = formRef.current) === null || _formRef$current3 === void 0 ? void 0 : _formRef$current3.setFieldsValue(_objectSpread({}, formValue));
|
|
82
74
|
}, [text]);
|
|
83
|
-
|
|
84
75
|
var lineInput = function lineInput(e) {
|
|
85
76
|
var line = (e.target.value || '').split('\n').filter(function (o, i) {
|
|
86
77
|
return i <= (maxRows < 1 ? 1000 : maxRows);
|
|
@@ -89,18 +80,15 @@ var InputMultiLine = /*#__PURE__*/React.forwardRef(function (prop, ref) {
|
|
|
89
80
|
setLineText(line);
|
|
90
81
|
setText(txt);
|
|
91
82
|
};
|
|
92
|
-
|
|
93
83
|
var textInput = function textInput(e) {
|
|
94
84
|
setText(e.target.value);
|
|
95
85
|
};
|
|
96
|
-
|
|
97
86
|
var clearValue = function clearValue(e) {
|
|
98
87
|
if (!e.target.value) {
|
|
99
88
|
setText('');
|
|
100
89
|
setLineText('');
|
|
101
90
|
}
|
|
102
91
|
};
|
|
103
|
-
|
|
104
92
|
var PopoverDom = useMemo(function () {
|
|
105
93
|
return /*#__PURE__*/React.createElement(_Popover, {
|
|
106
94
|
content: /*#__PURE__*/React.createElement("div", {
|