@guo514360255/antd-lib 1.4.32 → 1.4.34
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/CustomFormModal/index.js +83 -48
- package/dist/FormItem/index.js +5 -4
- package/dist/compontent.d.ts +1 -0
- package/package.json +1 -1
|
@@ -90,51 +90,86 @@ var CustomFormModal = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
90
90
|
useImperativeHandle(ref, function () {
|
|
91
91
|
return {
|
|
92
92
|
open: function open(values) {
|
|
93
|
-
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
93
|
+
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
94
94
|
var _formRef$current, data, newData;
|
|
95
|
-
return _regeneratorRuntime().wrap(function
|
|
96
|
-
while (1) switch (
|
|
95
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
96
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
97
97
|
case 0:
|
|
98
98
|
setOpen(true);
|
|
99
99
|
if (!(values !== null && values !== void 0 && values.id && detailRequest)) {
|
|
100
|
-
|
|
100
|
+
_context2.next = 27;
|
|
101
101
|
break;
|
|
102
102
|
}
|
|
103
103
|
setDetailLoading(true);
|
|
104
|
-
|
|
105
|
-
|
|
104
|
+
_context2.prev = 3;
|
|
105
|
+
_context2.next = 6;
|
|
106
106
|
return detailRequest(values.id);
|
|
107
107
|
case 6:
|
|
108
|
-
data =
|
|
108
|
+
data = _context2.sent;
|
|
109
109
|
columns === null || columns === void 0 || columns.forEach(function (item) {
|
|
110
110
|
if (item.formKey) {
|
|
111
111
|
data["".concat(item.dataIndex).concat(formKey)] = data[item.dataIndex];
|
|
112
112
|
}
|
|
113
113
|
});
|
|
114
|
-
|
|
114
|
+
if (!handleModalData) {
|
|
115
|
+
_context2.next = 14;
|
|
116
|
+
break;
|
|
117
|
+
}
|
|
118
|
+
_context2.next = 11;
|
|
119
|
+
return handleModalData(data || {});
|
|
120
|
+
case 11:
|
|
121
|
+
_context2.t0 = _context2.sent;
|
|
122
|
+
_context2.next = 15;
|
|
123
|
+
break;
|
|
124
|
+
case 14:
|
|
125
|
+
_context2.t0 = data || {};
|
|
126
|
+
case 15:
|
|
127
|
+
newData = _context2.t0;
|
|
115
128
|
setFieldValues(newData);
|
|
116
129
|
(_formRef$current = formRef.current) === null || _formRef$current === void 0 || _formRef$current.setFieldsValue(newData || {});
|
|
117
|
-
return
|
|
118
|
-
case
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
console.warn(
|
|
122
|
-
case
|
|
123
|
-
|
|
130
|
+
return _context2.abrupt("return");
|
|
131
|
+
case 21:
|
|
132
|
+
_context2.prev = 21;
|
|
133
|
+
_context2.t1 = _context2["catch"](3);
|
|
134
|
+
console.warn(_context2.t1);
|
|
135
|
+
case 24:
|
|
136
|
+
_context2.prev = 24;
|
|
124
137
|
setDetailLoading(false);
|
|
125
|
-
return
|
|
126
|
-
case
|
|
127
|
-
setTimeout(function () {
|
|
138
|
+
return _context2.finish(24);
|
|
139
|
+
case 27:
|
|
140
|
+
setTimeout( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
128
141
|
var _formRef$current2;
|
|
129
|
-
var newData
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
142
|
+
var newData;
|
|
143
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
144
|
+
while (1) switch (_context.prev = _context.next) {
|
|
145
|
+
case 0:
|
|
146
|
+
if (!handleModalData) {
|
|
147
|
+
_context.next = 6;
|
|
148
|
+
break;
|
|
149
|
+
}
|
|
150
|
+
_context.next = 3;
|
|
151
|
+
return handleModalData(values || {});
|
|
152
|
+
case 3:
|
|
153
|
+
_context.t0 = _context.sent;
|
|
154
|
+
_context.next = 7;
|
|
155
|
+
break;
|
|
156
|
+
case 6:
|
|
157
|
+
_context.t0 = values || {};
|
|
158
|
+
case 7:
|
|
159
|
+
newData = _context.t0;
|
|
160
|
+
setFieldValues(newData);
|
|
161
|
+
(_formRef$current2 = formRef.current) === null || _formRef$current2 === void 0 || _formRef$current2.setFieldsValue(newData || {});
|
|
162
|
+
case 10:
|
|
163
|
+
case "end":
|
|
164
|
+
return _context.stop();
|
|
165
|
+
}
|
|
166
|
+
}, _callee);
|
|
167
|
+
})), 0);
|
|
168
|
+
case 28:
|
|
134
169
|
case "end":
|
|
135
|
-
return
|
|
170
|
+
return _context2.stop();
|
|
136
171
|
}
|
|
137
|
-
},
|
|
172
|
+
}, _callee2, null, [[3, 21, 24, 27]]);
|
|
138
173
|
}))();
|
|
139
174
|
},
|
|
140
175
|
getFormRef: function getFormRef() {
|
|
@@ -143,17 +178,17 @@ var CustomFormModal = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
143
178
|
};
|
|
144
179
|
});
|
|
145
180
|
var submitEvent = /*#__PURE__*/function () {
|
|
146
|
-
var
|
|
181
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
147
182
|
var _formRef$current3, _formRef$current4, _tableActionRef$curre, formData, data, result, _key2;
|
|
148
|
-
return _regeneratorRuntime().wrap(function
|
|
149
|
-
while (1) switch (
|
|
183
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
184
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
150
185
|
case 0:
|
|
151
186
|
setLoading(true);
|
|
152
|
-
|
|
153
|
-
|
|
187
|
+
_context3.prev = 1;
|
|
188
|
+
_context3.next = 4;
|
|
154
189
|
return (_formRef$current3 = formRef.current) === null || _formRef$current3 === void 0 ? void 0 : _formRef$current3.validateFields();
|
|
155
190
|
case 4:
|
|
156
|
-
formData =
|
|
191
|
+
formData = _context3.sent;
|
|
157
192
|
data = _objectSpread(_objectSpread({}, formValues), formData);
|
|
158
193
|
result = {};
|
|
159
194
|
for (_key2 in data) {
|
|
@@ -167,24 +202,24 @@ var CustomFormModal = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
167
202
|
result = handleData(result);
|
|
168
203
|
}
|
|
169
204
|
if (!formValues.id) {
|
|
170
|
-
|
|
205
|
+
_context3.next = 15;
|
|
171
206
|
break;
|
|
172
207
|
}
|
|
173
208
|
if (!updateRequest) {
|
|
174
|
-
|
|
209
|
+
_context3.next = 13;
|
|
175
210
|
break;
|
|
176
211
|
}
|
|
177
|
-
|
|
212
|
+
_context3.next = 13;
|
|
178
213
|
return updateRequest(result);
|
|
179
214
|
case 13:
|
|
180
|
-
|
|
215
|
+
_context3.next = 18;
|
|
181
216
|
break;
|
|
182
217
|
case 15:
|
|
183
218
|
if (!saveRequest) {
|
|
184
|
-
|
|
219
|
+
_context3.next = 18;
|
|
185
220
|
break;
|
|
186
221
|
}
|
|
187
|
-
|
|
222
|
+
_context3.next = 18;
|
|
188
223
|
return saveRequest(result);
|
|
189
224
|
case 18:
|
|
190
225
|
setOpen(false);
|
|
@@ -194,22 +229,22 @@ var CustomFormModal = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
194
229
|
}
|
|
195
230
|
messageApi.success('提交成功');
|
|
196
231
|
tableActionRef === null || tableActionRef === void 0 || (_tableActionRef$curre = tableActionRef.current) === null || _tableActionRef$curre === void 0 || _tableActionRef$curre.reload();
|
|
197
|
-
|
|
232
|
+
_context3.next = 28;
|
|
198
233
|
break;
|
|
199
234
|
case 25:
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
console.log(
|
|
235
|
+
_context3.prev = 25;
|
|
236
|
+
_context3.t0 = _context3["catch"](1);
|
|
237
|
+
console.log(_context3.t0, 'submit request error');
|
|
203
238
|
case 28:
|
|
204
239
|
setLoading(false);
|
|
205
240
|
case 29:
|
|
206
241
|
case "end":
|
|
207
|
-
return
|
|
242
|
+
return _context3.stop();
|
|
208
243
|
}
|
|
209
|
-
},
|
|
244
|
+
}, _callee3, null, [[1, 25]]);
|
|
210
245
|
}));
|
|
211
246
|
return function submitEvent() {
|
|
212
|
-
return
|
|
247
|
+
return _ref2.apply(this, arguments);
|
|
213
248
|
};
|
|
214
249
|
}();
|
|
215
250
|
var close = function close() {
|
|
@@ -272,10 +307,10 @@ var CustomFormModal = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
272
307
|
return item.type === 'list' ? /*#__PURE__*/React.createElement(Form.List, {
|
|
273
308
|
name: item.dataIndex,
|
|
274
309
|
key: item.dataIndex
|
|
275
|
-
}, function (fields,
|
|
276
|
-
var add =
|
|
277
|
-
remove =
|
|
278
|
-
var errors =
|
|
310
|
+
}, function (fields, _ref3, _ref4) {
|
|
311
|
+
var add = _ref3.add,
|
|
312
|
+
remove = _ref3.remove;
|
|
313
|
+
var errors = _ref4.errors;
|
|
279
314
|
return /*#__PURE__*/React.createElement(React.Fragment, null, fields.map(function (field, key) {
|
|
280
315
|
return /*#__PURE__*/React.createElement(Form.Item, {
|
|
281
316
|
label: key === 0 ? "".concat(item.title) : '',
|
package/dist/FormItem/index.js
CHANGED
|
@@ -7,7 +7,7 @@ var _excluded = ["value", "onChange"];
|
|
|
7
7
|
* @Description:
|
|
8
8
|
*/
|
|
9
9
|
import { valueEnumTransform } from "../utils/util";
|
|
10
|
-
import { Checkbox, Input, InputNumber, Radio, Select, TreeSelect } from 'antd';
|
|
10
|
+
import { Checkbox, ColorPicker, Input, InputNumber, Radio, Select, TreeSelect } from 'antd';
|
|
11
11
|
import React from 'react';
|
|
12
12
|
var FormItem = function FormItem(_ref) {
|
|
13
13
|
var value = _ref.value,
|
|
@@ -20,14 +20,15 @@ var FormItem = function FormItem(_ref) {
|
|
|
20
20
|
inputNumber: InputNumber,
|
|
21
21
|
treeSelect: TreeSelect,
|
|
22
22
|
textArea: Input.TextArea,
|
|
23
|
-
checkbox: Checkbox.Group
|
|
23
|
+
checkbox: Checkbox.Group,
|
|
24
|
+
color: ColorPicker
|
|
24
25
|
};
|
|
25
26
|
var placeholder = rest.defaultPlaceholder || ['input', 'inputNumber', 'textArea'].includes(rest.type) ? '请输入' : '请选择';
|
|
26
27
|
var FieldComponent = comField[rest.type || 'input'];
|
|
27
28
|
return /*#__PURE__*/React.createElement(FieldComponent, _extends({
|
|
28
29
|
value: value,
|
|
29
30
|
onChange: function onChange(e) {
|
|
30
|
-
return _onChange === null || _onChange === void 0 ? void 0 : _onChange(['treeSelect', 'select', 'checkbox'].includes(rest.type) ? e : !rest.type || ['input', 'inputNumber'].includes(rest.type) ? e : e.target.value);
|
|
31
|
+
return _onChange === null || _onChange === void 0 ? void 0 : _onChange(['treeSelect', 'select', 'checkbox', 'color'].includes(rest.type) ? e : !rest.type || ['input', 'inputNumber'].includes(rest.type) ? e : e.target.value);
|
|
31
32
|
}
|
|
32
33
|
}, ['radio', 'checkbox', 'inputNumber'].includes(rest.type) ? {} : {
|
|
33
34
|
allowClear: true
|
|
@@ -36,7 +37,7 @@ var FormItem = function FormItem(_ref) {
|
|
|
36
37
|
optionFilterProp: 'label'
|
|
37
38
|
} : {}, {
|
|
38
39
|
style: {
|
|
39
|
-
width: '100%'
|
|
40
|
+
width: ['color'].includes(rest.type) ? '' : '100%'
|
|
40
41
|
}
|
|
41
42
|
}, ['radio', 'select'].includes(rest.type) ? {
|
|
42
43
|
options: valueEnumTransform(rest.valueEnum, value)
|
package/dist/compontent.d.ts
CHANGED