ls-pro-common 1.1.0 → 1.1.2
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 +138 -1
- package/dist/common.js +1 -1
- package/dist/common.js.LICENSE.txt +5 -3
- package/dist/common.min.css +138 -1
- package/dist/common.min.js +1 -1
- package/dist/common.min.js.LICENSE.txt +5 -3
- package/es/components/AreaCascader.js +35 -48
- package/es/components/AreaCascaderPanel.d.ts +5 -0
- package/es/components/AreaCascaderPanel.js +230 -0
- 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.d.ts +2 -0
- package/es/components/InputTable.js +118 -160
- package/es/components/Loading.js +3 -6
- package/es/components/common.less +158 -1
- package/es/hooks/useDtl/index.d.ts +2 -0
- package/es/hooks/useDtl/index.js +676 -941
- package/es/hooks/usePermission/index.js +0 -9
- package/es/hooks/useSingle/index.d.ts +2 -0
- package/es/hooks/useSingle/index.js +440 -599
- package/es/http/index.js +113 -149
- package/es/index.d.ts +2 -1
- package/es/index.js +2 -2
- package/es/service/BaseService.js +121 -195
- package/es/utils/index.js +12 -111
- package/lib/components/404.js +1 -6
- package/lib/components/AreaCascader.js +37 -63
- package/lib/components/AreaCascaderPanel.d.ts +5 -0
- package/lib/components/AreaCascaderPanel.js +239 -0
- 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.d.ts +2 -0
- package/lib/components/InputTable.js +120 -185
- package/lib/components/Loading.js +4 -16
- package/lib/components/common.less +158 -1
- package/lib/hooks/useDtl/index.d.ts +2 -0
- package/lib/hooks/useDtl/index.js +677 -957
- package/lib/hooks/usePermission/index.js +0 -12
- package/lib/hooks/useSingle/index.d.ts +2 -0
- package/lib/hooks/useSingle/index.js +441 -614
- package/lib/http/index.js +111 -158
- package/lib/index.d.ts +2 -1
- package/lib/index.js +9 -20
- package/lib/service/BaseService.js +121 -201
- package/lib/utils/index.js +13 -209
- package/package.json +2 -2
|
@@ -1,67 +1,44 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
|
|
6
|
-
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
7
5
|
Object.defineProperty(exports, "__esModule", {
|
|
8
6
|
value: true
|
|
9
7
|
});
|
|
10
8
|
exports.default = void 0;
|
|
11
|
-
|
|
12
9
|
require("antd/es/modal/style");
|
|
13
|
-
|
|
14
10
|
var _modal = _interopRequireDefault(require("antd/es/modal"));
|
|
15
|
-
|
|
16
11
|
require("antd/es/card/style");
|
|
17
|
-
|
|
18
12
|
var _card = _interopRequireDefault(require("antd/es/card"));
|
|
19
|
-
|
|
20
13
|
require("antd/es/button/style");
|
|
21
|
-
|
|
22
14
|
var _button = _interopRequireDefault(require("antd/es/button"));
|
|
23
|
-
|
|
24
15
|
require("antd/es/input/style");
|
|
25
|
-
|
|
26
16
|
var _input = _interopRequireDefault(require("antd/es/input"));
|
|
27
|
-
|
|
28
17
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
29
|
-
|
|
30
18
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
31
|
-
|
|
32
19
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
33
|
-
|
|
34
20
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
35
|
-
|
|
36
21
|
var _react = _interopRequireWildcard(require("react"));
|
|
37
|
-
|
|
38
22
|
var _lsProForm = require("ls-pro-form");
|
|
39
|
-
|
|
40
23
|
var _icons = require("@ant-design/icons");
|
|
41
|
-
|
|
42
24
|
var _excluded = ["readonly", "allowClear", "title", "modalWidth", "name", "isInput", "modalProps", "defaultValue"];
|
|
43
25
|
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'];
|
|
44
|
-
|
|
45
26
|
function IconSelector(prop) {
|
|
46
27
|
//@ts-ignore?
|
|
47
28
|
var _useContext = (0, _react.useContext)(_lsProForm.ProFormContext),
|
|
48
|
-
|
|
49
|
-
|
|
29
|
+
formRef = _useContext.formRef;
|
|
50
30
|
var _useState = (0, _react.useState)(false),
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
31
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
32
|
+
visible = _useState2[0],
|
|
33
|
+
setVisible = _useState2[1];
|
|
55
34
|
var _useState3 = (0, _react.useState)(''),
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
35
|
+
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
|
|
36
|
+
icon = _useState4[0],
|
|
37
|
+
setIcon = _useState4[1];
|
|
60
38
|
var _useState5 = (0, _react.useState)(''),
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
39
|
+
_useState6 = (0, _slicedToArray2.default)(_useState5, 2),
|
|
40
|
+
searchKey = _useState6[0],
|
|
41
|
+
setSearchKey = _useState6[1];
|
|
65
42
|
var inputRef = (0, _react.useRef)();
|
|
66
43
|
var list = (0, _react.useMemo)(function () {
|
|
67
44
|
if (!searchKey) return [].concat(iconList);
|
|
@@ -70,24 +47,22 @@ function IconSelector(prop) {
|
|
|
70
47
|
});
|
|
71
48
|
}, [searchKey]);
|
|
72
49
|
var _prop$readonly = prop.readonly,
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
50
|
+
readonly = _prop$readonly === void 0 ? true : _prop$readonly,
|
|
51
|
+
_prop$allowClear = prop.allowClear,
|
|
52
|
+
allowClear = _prop$allowClear === void 0 ? true : _prop$allowClear,
|
|
53
|
+
_prop$title = prop.title,
|
|
54
|
+
title = _prop$title === void 0 ? "选择图标" : _prop$title,
|
|
55
|
+
_prop$modalWidth = prop.modalWidth,
|
|
56
|
+
modalWidth = _prop$modalWidth === void 0 ? '630px' : _prop$modalWidth,
|
|
57
|
+
name = prop.name,
|
|
58
|
+
_prop$isInput = prop.isInput,
|
|
59
|
+
isInput = _prop$isInput === void 0 ? true : _prop$isInput,
|
|
60
|
+
modalProps = prop.modalProps,
|
|
61
|
+
defaultValue = prop.defaultValue,
|
|
62
|
+
rest = (0, _objectWithoutProperties2.default)(prop, _excluded);
|
|
86
63
|
(0, _react.useEffect)(function () {
|
|
87
64
|
var _formRef$current;
|
|
88
|
-
|
|
89
65
|
var val = (_formRef$current = formRef.current) === null || _formRef$current === void 0 ? void 0 : _formRef$current.getFieldsValue();
|
|
90
|
-
|
|
91
66
|
if (val && val[name]) {
|
|
92
67
|
setIcon(val[name]);
|
|
93
68
|
}
|
|
@@ -99,14 +74,11 @@ function IconSelector(prop) {
|
|
|
99
74
|
}, [defaultValue]);
|
|
100
75
|
(0, _react.useEffect)(function () {
|
|
101
76
|
var _rest$fieldProps;
|
|
102
|
-
|
|
103
77
|
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;
|
|
104
|
-
|
|
105
78
|
try {
|
|
106
79
|
if (!inputRef.current) return;
|
|
107
80
|
var el = inputRef.current.input.parentNode;
|
|
108
81
|
if (!el) return;
|
|
109
|
-
|
|
110
82
|
if (icon) {
|
|
111
83
|
el.classList.add('ant-input-has-value');
|
|
112
84
|
} else {
|
|
@@ -114,25 +86,20 @@ function IconSelector(prop) {
|
|
|
114
86
|
}
|
|
115
87
|
} catch (e) {}
|
|
116
88
|
}, [icon]);
|
|
117
|
-
|
|
118
89
|
var showSelector = function showSelector(flag) {
|
|
119
90
|
var _rest$fieldProps2;
|
|
120
|
-
|
|
121
91
|
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;
|
|
122
92
|
setVisible(flag);
|
|
123
93
|
};
|
|
124
|
-
|
|
125
94
|
var clearValue = function clearValue(e) {
|
|
126
95
|
if (!e || !e.target.value) {
|
|
127
96
|
var _formRef$current2;
|
|
128
|
-
|
|
129
97
|
setIcon('');
|
|
130
98
|
var formValue = formRef === null || formRef === void 0 ? void 0 : (_formRef$current2 = formRef.current) === null || _formRef$current2 === void 0 ? void 0 : _formRef$current2.getFieldsValue();
|
|
131
99
|
formValue[name] = '';
|
|
132
100
|
formRef.current.setFieldsValue((0, _objectSpread2.default)({}, formValue));
|
|
133
101
|
}
|
|
134
102
|
};
|
|
135
|
-
|
|
136
103
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_lsProForm.ProFormText, (0, _extends2.default)({
|
|
137
104
|
name: name
|
|
138
105
|
}, rest), isInput ? /*#__PURE__*/_react.default.createElement(_input.default, (0, _extends2.default)({
|
|
@@ -198,8 +165,8 @@ function IconSelector(prop) {
|
|
|
198
165
|
footer: /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_button.default, {
|
|
199
166
|
onClick: function onClick() {
|
|
200
167
|
var formVal = formRef.current.getFieldsValue();
|
|
201
|
-
var val = (0, _objectSpread2.default)({}, formVal);
|
|
202
|
-
|
|
168
|
+
var val = (0, _objectSpread2.default)({}, formVal);
|
|
169
|
+
//@ts-ignore
|
|
203
170
|
val[name] = '';
|
|
204
171
|
formRef.current.setFieldsValue(val);
|
|
205
172
|
setIcon('');
|
|
@@ -229,10 +196,9 @@ function IconSelector(prop) {
|
|
|
229
196
|
console.log('选择图标组件未设置name属性');
|
|
230
197
|
return;
|
|
231
198
|
}
|
|
232
|
-
|
|
233
199
|
var formVal = formRef.current.getFieldsValue();
|
|
234
|
-
var val = (0, _objectSpread2.default)({}, formVal);
|
|
235
|
-
|
|
200
|
+
var val = (0, _objectSpread2.default)({}, formVal);
|
|
201
|
+
//@ts-ignore
|
|
236
202
|
val[name] = o;
|
|
237
203
|
formRef.current.setFieldsValue(val);
|
|
238
204
|
setIcon(o);
|
|
@@ -260,6 +226,5 @@ function IconSelector(prop) {
|
|
|
260
226
|
}, o));
|
|
261
227
|
}))));
|
|
262
228
|
}
|
|
263
|
-
|
|
264
229
|
var _default = IconSelector;
|
|
265
230
|
exports.default = _default;
|
|
@@ -1,279 +1,213 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
|
|
6
|
-
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
7
5
|
Object.defineProperty(exports, "__esModule", {
|
|
8
6
|
value: true
|
|
9
7
|
});
|
|
10
8
|
exports.default = void 0;
|
|
11
|
-
|
|
9
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
12
10
|
require("antd/es/modal/style");
|
|
13
|
-
|
|
14
11
|
var _modal = _interopRequireDefault(require("antd/es/modal"));
|
|
15
|
-
|
|
16
12
|
require("antd/es/empty/style");
|
|
17
|
-
|
|
18
13
|
var _empty = _interopRequireDefault(require("antd/es/empty"));
|
|
19
|
-
|
|
20
14
|
require("antd/es/card/style");
|
|
21
|
-
|
|
22
15
|
var _card = _interopRequireDefault(require("antd/es/card"));
|
|
23
|
-
|
|
24
16
|
require("antd/es/button/style");
|
|
25
|
-
|
|
26
17
|
var _button = _interopRequireDefault(require("antd/es/button"));
|
|
27
|
-
|
|
28
18
|
require("antd/es/upload/style");
|
|
29
|
-
|
|
30
19
|
var _upload = _interopRequireDefault(require("antd/es/upload"));
|
|
31
|
-
|
|
32
20
|
require("antd/es/input/style");
|
|
33
|
-
|
|
34
21
|
var _input = _interopRequireDefault(require("antd/es/input"));
|
|
35
|
-
|
|
36
22
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
37
|
-
|
|
38
23
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
39
|
-
|
|
40
|
-
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
41
|
-
|
|
42
24
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
43
|
-
|
|
44
25
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
45
|
-
|
|
46
26
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
47
|
-
|
|
48
27
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
49
|
-
|
|
50
28
|
var _react = _interopRequireWildcard(require("react"));
|
|
51
|
-
|
|
52
29
|
var _lsProForm = require("ls-pro-form");
|
|
53
|
-
|
|
54
30
|
var _icons = require("@ant-design/icons");
|
|
55
|
-
|
|
56
31
|
var _http = require("../http");
|
|
57
|
-
|
|
58
32
|
var _utils = require("../utils");
|
|
59
|
-
|
|
60
33
|
var _excluded = ["type", "uploadable", "readonly", "allowClear", "title", "modalWidth", "name", "maxSize", "modalProps", "code", "isInput", "desc", "imageClass"];
|
|
61
34
|
var fileCenter = (0, _utils.getCache)('ossPath') || '/petrel/petrel-file-center-api/lesoon/oss/file/';
|
|
62
|
-
|
|
63
35
|
function ImageSelector(prop) {
|
|
64
36
|
var _rest$fieldProps3;
|
|
65
|
-
|
|
66
37
|
//@ts-ignore?
|
|
67
38
|
var _useContext = (0, _react.useContext)(_lsProForm.ProFormContext),
|
|
68
|
-
|
|
69
|
-
|
|
39
|
+
formRef = _useContext.formRef;
|
|
70
40
|
var _useState = (0, _react.useState)(false),
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
41
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
42
|
+
visible = _useState2[0],
|
|
43
|
+
setVisible = _useState2[1];
|
|
75
44
|
var _useState3 = (0, _react.useState)(''),
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
45
|
+
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
|
|
46
|
+
imgUrl = _useState4[0],
|
|
47
|
+
setImgUrl = _useState4[1];
|
|
80
48
|
var _useState5 = (0, _react.useState)([]),
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
49
|
+
_useState6 = (0, _slicedToArray2.default)(_useState5, 2),
|
|
50
|
+
list = _useState6[0],
|
|
51
|
+
setList = _useState6[1];
|
|
85
52
|
var _useState7 = (0, _react.useState)(''),
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
53
|
+
_useState8 = (0, _slicedToArray2.default)(_useState7, 2),
|
|
54
|
+
searchKey = _useState8[0],
|
|
55
|
+
setSearchKey = _useState8[1];
|
|
90
56
|
var _useState9 = (0, _react.useState)(''),
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
57
|
+
_useState10 = (0, _slicedToArray2.default)(_useState9, 2),
|
|
58
|
+
nextMarker = _useState10[0],
|
|
59
|
+
setNextMarker = _useState10[1];
|
|
95
60
|
var inputRef = (0, _react.useRef)();
|
|
96
61
|
var type = prop.type,
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
62
|
+
_prop$uploadable = prop.uploadable,
|
|
63
|
+
uploadable = _prop$uploadable === void 0 ? true : _prop$uploadable,
|
|
64
|
+
_prop$readonly = prop.readonly,
|
|
65
|
+
readonly = _prop$readonly === void 0 ? true : _prop$readonly,
|
|
66
|
+
_prop$allowClear = prop.allowClear,
|
|
67
|
+
allowClear = _prop$allowClear === void 0 ? true : _prop$allowClear,
|
|
68
|
+
_prop$title = prop.title,
|
|
69
|
+
title = _prop$title === void 0 ? "选择图标" : _prop$title,
|
|
70
|
+
_prop$modalWidth = prop.modalWidth,
|
|
71
|
+
modalWidth = _prop$modalWidth === void 0 ? '600px' : _prop$modalWidth,
|
|
72
|
+
name = prop.name,
|
|
73
|
+
_prop$maxSize = prop.maxSize,
|
|
74
|
+
maxSize = _prop$maxSize === void 0 ? 5 : _prop$maxSize,
|
|
75
|
+
modalProps = prop.modalProps,
|
|
76
|
+
_prop$code = prop.code,
|
|
77
|
+
code = _prop$code === void 0 ? 'RETAIL' : _prop$code,
|
|
78
|
+
_prop$isInput = prop.isInput,
|
|
79
|
+
isInput = _prop$isInput === void 0 ? true : _prop$isInput,
|
|
80
|
+
_prop$desc = prop.desc,
|
|
81
|
+
desc = _prop$desc === void 0 ? '支持 png | jpg | gif 格式图片' : _prop$desc,
|
|
82
|
+
_prop$imageClass = prop.imageClass,
|
|
83
|
+
imageClass = _prop$imageClass === void 0 ? '' : _prop$imageClass,
|
|
84
|
+
rest = (0, _objectWithoutProperties2.default)(prop, _excluded);
|
|
85
|
+
// 上传地址
|
|
121
86
|
var uploadImgApi = (0, _react.useMemo)(function () {
|
|
122
87
|
return fileCenter + 'upload/' + code + '?catalogName=' + type;
|
|
123
|
-
}, [code, type]);
|
|
124
|
-
|
|
88
|
+
}, [code, type]);
|
|
89
|
+
// 分页加载列表地址
|
|
125
90
|
var pageImgApi = (0, _react.useMemo)(function () {
|
|
126
91
|
return fileCenter + 'page/' + code;
|
|
127
|
-
}, [code]);
|
|
128
|
-
|
|
92
|
+
}, [code]);
|
|
93
|
+
// 展示地址
|
|
129
94
|
var showImgApi = (0, _react.useMemo)(function () {
|
|
130
95
|
return fileCenter + 'show/' + code;
|
|
131
96
|
}, [code]);
|
|
132
|
-
|
|
133
97
|
var loadData = /*#__PURE__*/function () {
|
|
134
98
|
var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(keys) {
|
|
135
99
|
var _result$data, _result$data2;
|
|
136
|
-
|
|
137
100
|
var url, param, result, rows;
|
|
138
101
|
return _regenerator.default.wrap(function _callee$(_context) {
|
|
139
|
-
while (1) {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
return (
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
setList([].concat((0, _toConsumableArray2.default)(list), (0, _toConsumableArray2.default)(rows)));
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
setNextMarker((_result$data2 = result.data) === null || _result$data2 === void 0 ? void 0 : _result$data2.nextMarker);
|
|
177
|
-
|
|
178
|
-
case 11:
|
|
179
|
-
case "end":
|
|
180
|
-
return _context.stop();
|
|
181
|
-
}
|
|
102
|
+
while (1) switch (_context.prev = _context.next) {
|
|
103
|
+
case 0:
|
|
104
|
+
url = pageImgApi;
|
|
105
|
+
param = {
|
|
106
|
+
prefix: type,
|
|
107
|
+
maxKeys: 16
|
|
108
|
+
};
|
|
109
|
+
if (keys) {
|
|
110
|
+
param.prefix = param.prefix + '/' + keys;
|
|
111
|
+
}
|
|
112
|
+
if (nextMarker) {
|
|
113
|
+
param.nextMarker = nextMarker;
|
|
114
|
+
}
|
|
115
|
+
_context.next = 6;
|
|
116
|
+
return (0, _http.httpGet)(url, param, false);
|
|
117
|
+
case 6:
|
|
118
|
+
result = _context.sent;
|
|
119
|
+
rows = (((_result$data = result.data) === null || _result$data === void 0 ? void 0 : _result$data.objectList) || []).filter(function (o) {
|
|
120
|
+
return o.dir == false && (!nextMarker || !list.find(function (e) {
|
|
121
|
+
return e.path === o.path;
|
|
122
|
+
}));
|
|
123
|
+
});
|
|
124
|
+
rows.forEach(function (row) {
|
|
125
|
+
row.url = showImgApi + '?fileName=' + row.path;
|
|
126
|
+
});
|
|
127
|
+
if (!nextMarker) {
|
|
128
|
+
setList(rows);
|
|
129
|
+
} else {
|
|
130
|
+
setList([].concat((0, _toConsumableArray2.default)(list), (0, _toConsumableArray2.default)(rows)));
|
|
131
|
+
}
|
|
132
|
+
setNextMarker((_result$data2 = result.data) === null || _result$data2 === void 0 ? void 0 : _result$data2.nextMarker);
|
|
133
|
+
case 11:
|
|
134
|
+
case "end":
|
|
135
|
+
return _context.stop();
|
|
182
136
|
}
|
|
183
137
|
}, _callee);
|
|
184
138
|
}));
|
|
185
|
-
|
|
186
139
|
return function loadData(_x) {
|
|
187
140
|
return _ref.apply(this, arguments);
|
|
188
141
|
};
|
|
189
142
|
}();
|
|
190
|
-
|
|
191
143
|
(0, _react.useEffect)(function () {
|
|
192
144
|
if (!visible) {
|
|
193
145
|
setNextMarker('');
|
|
194
146
|
setSearchKey('');
|
|
195
147
|
return;
|
|
196
148
|
}
|
|
197
|
-
|
|
198
149
|
loadData(searchKey);
|
|
199
150
|
}, [visible, searchKey]);
|
|
200
151
|
(0, _react.useEffect)(function () {
|
|
201
152
|
var val = formRef.current.getFieldsValue();
|
|
202
|
-
|
|
203
153
|
if (val && val[name]) {
|
|
204
154
|
setImgUrl(val[name]);
|
|
205
155
|
}
|
|
206
|
-
}, []);
|
|
207
|
-
|
|
156
|
+
}, []);
|
|
157
|
+
// 验证上传文件大小
|
|
208
158
|
var beforeUpload = function beforeUpload(file) {
|
|
209
159
|
var sizeLimit = file.size / 1024 / 1024 >= maxSize;
|
|
210
|
-
|
|
211
160
|
if (sizeLimit) {
|
|
212
161
|
(0, _utils.showError)("\u4E0A\u4F20\u7684\u6587\u4EF6\u4E0D\u80FD\u5927\u4E8E".concat(maxSize, "M"));
|
|
213
162
|
}
|
|
214
|
-
|
|
215
163
|
return !sizeLimit;
|
|
216
|
-
};
|
|
217
|
-
|
|
218
|
-
|
|
164
|
+
};
|
|
165
|
+
// 上传图片
|
|
219
166
|
var onUpload = function onUpload(info) {
|
|
220
167
|
var isDirect = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
221
|
-
|
|
222
168
|
if (info.file.status === 'done') {
|
|
223
169
|
var _result$flag;
|
|
224
|
-
|
|
225
170
|
var result = info.file.response;
|
|
226
|
-
|
|
227
171
|
if ((result === null || result === void 0 ? void 0 : (_result$flag = result.flag) === null || _result$flag === void 0 ? void 0 : _result$flag.retCode) === '0') {
|
|
228
|
-
(0, _utils.showSuccess)(result.flag.retMsg);
|
|
229
|
-
|
|
172
|
+
(0, _utils.showSuccess)(result.flag.retMsg);
|
|
173
|
+
// 直接上传
|
|
230
174
|
if (isDirect) {
|
|
231
175
|
var _result$rows$;
|
|
232
|
-
|
|
233
176
|
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);
|
|
234
177
|
setImgUrl(img);
|
|
235
178
|
var formVal = formRef.current.getFieldsValue();
|
|
236
|
-
var val = (0, _objectSpread2.default)({}, formVal);
|
|
237
|
-
|
|
179
|
+
var val = (0, _objectSpread2.default)({}, formVal);
|
|
180
|
+
//@ts-ignore
|
|
238
181
|
val[name] = img;
|
|
239
182
|
formRef.current.setFieldsValue(val);
|
|
240
183
|
}
|
|
241
184
|
} else {
|
|
242
185
|
var _result$flag2;
|
|
243
|
-
|
|
244
186
|
(0, _utils.showError)((result === null || result === void 0 ? void 0 : (_result$flag2 = result.flag) === null || _result$flag2 === void 0 ? void 0 : _result$flag2.retMsg) || '上传图片失败,请联系管理员');
|
|
245
187
|
}
|
|
246
188
|
} else if (info.file.status === 'error') {
|
|
247
189
|
(0, _utils.showError)('上传数据失败,请联系管理员');
|
|
248
190
|
}
|
|
249
|
-
|
|
250
191
|
if (!isDirect && !info.fileList.filter(function (o) {
|
|
251
192
|
return o.status === 'uploading';
|
|
252
193
|
}).length) {
|
|
253
194
|
loadData(searchKey);
|
|
254
195
|
}
|
|
255
196
|
};
|
|
256
|
-
|
|
257
197
|
var showSelect = function showSelect() {
|
|
258
198
|
var _rest$fieldProps;
|
|
259
|
-
|
|
260
199
|
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)) {
|
|
261
200
|
return;
|
|
262
201
|
}
|
|
263
|
-
|
|
264
202
|
setVisible(true);
|
|
265
203
|
};
|
|
266
|
-
|
|
267
204
|
(0, _react.useEffect)(function () {
|
|
268
205
|
var _rest$fieldProps2;
|
|
269
|
-
|
|
270
206
|
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;
|
|
271
|
-
|
|
272
207
|
try {
|
|
273
208
|
if (!inputRef.current) return;
|
|
274
209
|
var el = inputRef.current.input.parentNode;
|
|
275
210
|
if (!el) return;
|
|
276
|
-
|
|
277
211
|
if (imgUrl) {
|
|
278
212
|
el.classList.add('ant-input-has-value');
|
|
279
213
|
} else {
|
|
@@ -281,18 +215,15 @@ function ImageSelector(prop) {
|
|
|
281
215
|
}
|
|
282
216
|
} catch (e) {}
|
|
283
217
|
}, [imgUrl]);
|
|
284
|
-
|
|
285
218
|
var clearValue = function clearValue(e) {
|
|
286
219
|
if (!e || !e.target.value) {
|
|
287
220
|
var _formRef$current;
|
|
288
|
-
|
|
289
221
|
setImgUrl('');
|
|
290
222
|
var formValue = formRef === null || formRef === void 0 ? void 0 : (_formRef$current = formRef.current) === null || _formRef$current === void 0 ? void 0 : _formRef$current.getFieldsValue();
|
|
291
223
|
formValue[name] = '';
|
|
292
224
|
formRef.current.setFieldsValue((0, _objectSpread2.default)({}, formValue));
|
|
293
225
|
}
|
|
294
226
|
};
|
|
295
|
-
|
|
296
227
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_lsProForm.ProFormText, (0, _extends2.default)({
|
|
297
228
|
name: name
|
|
298
229
|
}, rest), isInput ? /*#__PURE__*/_react.default.createElement(_input.default, (0, _extends2.default)({
|
|
@@ -431,10 +362,9 @@ function ImageSelector(prop) {
|
|
|
431
362
|
(0, _utils.showWarn)('选择图标组件未设置name属性');
|
|
432
363
|
return;
|
|
433
364
|
}
|
|
434
|
-
|
|
435
365
|
var formVal = formRef.current.getFieldsValue();
|
|
436
|
-
var val = (0, _objectSpread2.default)({}, formVal);
|
|
437
|
-
|
|
366
|
+
var val = (0, _objectSpread2.default)({}, formVal);
|
|
367
|
+
//@ts-ignore
|
|
438
368
|
val[name] = o.url;
|
|
439
369
|
formRef.current.setFieldsValue(val);
|
|
440
370
|
setImgUrl(o.url);
|
|
@@ -463,6 +393,5 @@ function ImageSelector(prop) {
|
|
|
463
393
|
image: _empty.default.PRESENTED_IMAGE_SIMPLE
|
|
464
394
|
}))));
|
|
465
395
|
}
|
|
466
|
-
|
|
467
396
|
var _default = ImageSelector;
|
|
468
397
|
exports.default = _default;
|