@quansitech/antd-admin 1.1.45 → 1.1.46

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.
@@ -31,6 +31,43 @@ var uploadValidator = function uploadValidator(_, value) {
31
31
  resolve(true);
32
32
  });
33
33
  };
34
+ var handleUploadRules = function handleUploadRules(rules) {
35
+ var rRule = rules.find(function (rule) {
36
+ return rule.required;
37
+ });
38
+ if (rRule) {
39
+ rules.push({
40
+ validator: function () {
41
+ var _validator = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(_, value) {
42
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
43
+ while (1) switch (_context.prev = _context.next) {
44
+ case 0:
45
+ if (!(value === '0' || value === 0)) {
46
+ _context.next = 2;
47
+ break;
48
+ }
49
+ throw new Error(rRule.message);
50
+ case 2:
51
+ return _context.abrupt("return", true);
52
+ case 3:
53
+ case "end":
54
+ return _context.stop();
55
+ }
56
+ }, _callee);
57
+ }));
58
+ function validator(_x, _x2) {
59
+ return _validator.apply(this, arguments);
60
+ }
61
+ return validator;
62
+ }()
63
+ });
64
+ }
65
+ rules.push({
66
+ validator: uploadValidator
67
+ });
68
+ console.log(rules);
69
+ return rules;
70
+ };
34
71
  export var commonHandler = function commonHandler(schema) {
35
72
  var _schema$formItemProps;
36
73
  schema.valueType = lowerFirst(schema.valueType);
@@ -52,22 +89,22 @@ export var commonHandler = function commonHandler(schema) {
52
89
  if (!((_schema$formItemProps = schema.formItemProps) !== null && _schema$formItemProps !== void 0 && _schema$formItemProps.rules)) {
53
90
  deepSet(schema, 'formItemProps.rules', []);
54
91
  }
55
- schema.fieldProps.withValidator = function (_validator) {
92
+ schema.fieldProps.withValidator = function (_validator2) {
56
93
  schema.formItemProps.rules.push({
57
94
  validator: function validator(rules, value) {
58
- return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
59
- return _regeneratorRuntime().wrap(function _callee$(_context) {
60
- while (1) switch (_context.prev = _context.next) {
95
+ return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
96
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
97
+ while (1) switch (_context2.prev = _context2.next) {
61
98
  case 0:
62
- _context.next = 2;
63
- return _validator(value);
99
+ _context2.next = 2;
100
+ return _validator2(value);
64
101
  case 2:
65
- return _context.abrupt("return", true);
102
+ return _context2.abrupt("return", true);
66
103
  case 3:
67
104
  case "end":
68
- return _context.stop();
105
+ return _context2.stop();
69
106
  }
70
- }, _callee);
107
+ }, _callee2);
71
108
  }))();
72
109
  }
73
110
  });
@@ -107,15 +144,13 @@ export var schemaHandler = {
107
144
  },
108
145
  // 上传
109
146
  image: function image(schema) {
110
- schema.formItemProps.rules.push({
111
- validator: uploadValidator
112
- });
147
+ var _schema$formItemProps2;
148
+ schema.formItemProps.rules = handleUploadRules((_schema$formItemProps2 = schema.formItemProps) === null || _schema$formItemProps2 === void 0 ? void 0 : _schema$formItemProps2.rules);
113
149
  return _objectSpread({}, schema);
114
150
  },
115
151
  file: function file(schema) {
116
- schema.formItemProps.rules.push({
117
- validator: uploadValidator
118
- });
152
+ var _schema$formItemProps3;
153
+ schema.formItemProps.rules = handleUploadRules((_schema$formItemProps3 = schema.formItemProps) === null || _schema$formItemProps3 === void 0 ? void 0 : _schema$formItemProps3.rules);
119
154
  return _objectSpread({}, schema);
120
155
  },
121
156
  action: function action(schema) {
@@ -155,31 +190,31 @@ export var schemaHandler = {
155
190
  }
156
191
  schema.formItemProps.rules.push({
157
192
  validator: function () {
158
- var _validator2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(rule, value) {
159
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
160
- while (1) switch (_context2.prev = _context2.next) {
193
+ var _validator3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(rule, value) {
194
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
195
+ while (1) switch (_context3.prev = _context3.next) {
161
196
  case 0:
162
197
  if (value) {
163
- _context2.next = 2;
198
+ _context3.next = 2;
164
199
  break;
165
200
  }
166
- return _context2.abrupt("return", true);
201
+ return _context3.abrupt("return", true);
167
202
  case 2:
168
203
  if (!(value.slice(0, 7) === '[抓取图片中]')) {
169
- _context2.next = 4;
204
+ _context3.next = 4;
170
205
  break;
171
206
  }
172
207
  throw new Error('请等待图片抓取完成');
173
208
  case 4:
174
- return _context2.abrupt("return", true);
209
+ return _context3.abrupt("return", true);
175
210
  case 5:
176
211
  case "end":
177
- return _context2.stop();
212
+ return _context3.stop();
178
213
  }
179
- }, _callee2);
214
+ }, _callee3);
180
215
  }));
181
- function validator(_x, _x2) {
182
- return _validator2.apply(this, arguments);
216
+ function validator(_x3, _x4) {
217
+ return _validator3.apply(this, arguments);
183
218
  }
184
219
  return validator;
185
220
  }()
@@ -192,18 +227,18 @@ export var schemaHandler = {
192
227
  if ((_schema$fieldProps = schema.fieldProps) !== null && _schema$fieldProps !== void 0 && _schema$fieldProps.searchUrl) {
193
228
  return _objectSpread(_objectSpread({}, schema), {}, {
194
229
  request: function () {
195
- var _request = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(params) {
230
+ var _request = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(params) {
196
231
  var res;
197
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
198
- while (1) switch (_context3.prev = _context3.next) {
232
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
233
+ while (1) switch (_context4.prev = _context4.next) {
199
234
  case 0:
200
- _context3.next = 2;
235
+ _context4.next = 2;
201
236
  return http(schema.fieldProps.searchUrl, {
202
237
  params: params
203
238
  });
204
239
  case 2:
205
- res = _context3.sent;
206
- return _context3.abrupt("return", res.data.map(function (item) {
240
+ res = _context4.sent;
241
+ return _context4.abrupt("return", res.data.map(function (item) {
207
242
  return {
208
243
  label: item.label || item.value,
209
244
  value: item.value
@@ -211,11 +246,11 @@ export var schemaHandler = {
211
246
  }));
212
247
  case 4:
213
248
  case "end":
214
- return _context3.stop();
249
+ return _context4.stop();
215
250
  }
216
- }, _callee3);
251
+ }, _callee4);
217
252
  }));
218
- function request(_x3) {
253
+ function request(_x5) {
219
254
  return _request.apply(this, arguments);
220
255
  }
221
256
  return request;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quansitech/antd-admin",
3
- "version": "1.1.45",
3
+ "version": "1.1.46",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"