@zhubangyun/lowcode-core 5.7.301 → 5.8.290

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.
@@ -1,4 +1,5 @@
1
1
  import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
2
+ import _Typography from "antd/es/typography";
2
3
  import _notification from "antd/es/notification";
3
4
  import _Modal from "antd/es/modal";
4
5
  import _message from "antd/es/message";
@@ -6,6 +7,7 @@ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
6
7
  import _regeneratorRuntime from "@babel/runtime/regenerator";
7
8
  import axios from "axios";
8
9
  import { onFulfilled, onRejected } from "./index";
10
+ import { transformerId } from "../data";
9
11
  export var BaseRestApi = /*#__PURE__*/function () {
10
12
  function BaseRestApi(uri, options) {
11
13
  this.uri = void 0;
@@ -116,7 +118,7 @@ export var BaseRestApi = /*#__PURE__*/function () {
116
118
  return (_this$handleRequestCo3 = this.handleRequestConfig) === null || _this$handleRequestCo3 === void 0 ? void 0 : _this$handleRequestCo3.call(this, config);
117
119
  case 3:
118
120
  _context3.next = 5;
119
- return this.request.post("", data, config);
121
+ return this.request.post("save", data, config);
120
122
  case 5:
121
123
  res = _context3.sent;
122
124
  if (res.success) {
@@ -286,67 +288,134 @@ export var BaseRestApi = /*#__PURE__*/function () {
286
288
  }
287
289
  return deleteById;
288
290
  }();
289
- _proto.showError = /*#__PURE__*/function () {
290
- var _showError = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(type, msg) {
291
- var _JSON$parse, _type, message;
291
+ _proto["delete"] = /*#__PURE__*/function () {
292
+ var _delete2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(data, options) {
293
+ var _this$handleRequestCo7;
294
+ var config, arrayData, idValue, res, _options$onError6, _options$onSuccess6;
292
295
  return _regeneratorRuntime.wrap(function _callee7$(_context7) {
293
296
  while (1) switch (_context7.prev = _context7.next) {
294
297
  case 0:
295
- _context7.prev = 0;
296
- if (!msg) {
297
- _context7.next = 16;
298
- break;
299
- }
300
- _JSON$parse = JSON.parse(msg), _type = _JSON$parse.type, message = _JSON$parse.message;
301
- if (!(_type == "message")) {
302
- _context7.next = 8;
303
- break;
298
+ config = {};
299
+ _context7.next = 3;
300
+ return (_this$handleRequestCo7 = this.handleRequestConfig) === null || _this$handleRequestCo7 === void 0 ? void 0 : _this$handleRequestCo7.call(this, config);
301
+ case 3:
302
+ arrayData = [];
303
+ idValue = transformerId(data);
304
+ if (!Array.isArray(idValue)) {
305
+ arrayData.push(idValue);
306
+ } else {
307
+ arrayData = idValue;
304
308
  }
305
- _message.error({
306
- type: "error",
307
- content: message
309
+ arrayData = arrayData.filter(function (item) {
310
+ return !!item;
308
311
  });
309
- return _context7.abrupt("return");
310
- case 8:
311
- if (!(_type == "modal")) {
312
- _context7.next = 13;
312
+ if (!(arrayData.length == 0)) {
313
+ _context7.next = 9;
313
314
  break;
314
315
  }
315
- _Modal.error({
316
- content: message
317
- });
318
- return _context7.abrupt("return");
319
- case 13:
320
- if (!(_type == "notification")) {
321
- _context7.next = 16;
316
+ throw new Error("删除对象不可为空!");
317
+ case 9:
318
+ _context7.next = 11;
319
+ return this.request.post("remove", arrayData, config);
320
+ case 11:
321
+ res = _context7.sent;
322
+ if (res.success) {
323
+ _context7.next = 18;
322
324
  break;
323
325
  }
324
- _notification.error({
325
- message: message
326
- });
327
- return _context7.abrupt("return");
326
+ this.showError("\u5220\u9664\u5931\u8D25!", res.message).then();
327
+ _context7.next = 16;
328
+ return options === null || options === void 0 ? void 0 : (_options$onError6 = options.onError) === null || _options$onError6 === void 0 ? void 0 : _options$onError6.call(options, res);
328
329
  case 16:
329
330
  _context7.next = 20;
330
331
  break;
331
332
  case 18:
332
- _context7.prev = 18;
333
- _context7.t0 = _context7["catch"](0);
333
+ _context7.next = 20;
334
+ return options === null || options === void 0 ? void 0 : (_options$onSuccess6 = options.onSuccess) === null || _options$onSuccess6 === void 0 ? void 0 : _options$onSuccess6.call(options, res);
334
335
  case 20:
335
- console.error("{" + this.title + "}" + type + (msg || ""));
336
- _message === null || _message === void 0 ? void 0 : _message.error("{" + this.title + "}" + type + (msg || "")).then();
337
- case 22:
336
+ return _context7.abrupt("return", res);
337
+ case 21:
338
338
  case "end":
339
339
  return _context7.stop();
340
340
  }
341
- }, _callee7, this, [[0, 18]]);
341
+ }, _callee7, this);
342
+ }));
343
+ function _delete(_x13, _x14) {
344
+ return _delete2.apply(this, arguments);
345
+ }
346
+ return _delete;
347
+ }();
348
+ _proto.showError = /*#__PURE__*/function () {
349
+ var _showError = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(type, msg) {
350
+ var props;
351
+ return _regeneratorRuntime.wrap(function _callee8$(_context8) {
352
+ while (1) switch (_context8.prev = _context8.next) {
353
+ case 0:
354
+ _context8.prev = 0;
355
+ if (!msg) {
356
+ _context8.next = 18;
357
+ break;
358
+ }
359
+ props = JSON.parse(msg);
360
+ props.content = props.message;
361
+ if (!props.title) {
362
+ props.title = "" + this.title + type;
363
+ }
364
+ if (!(props.type == "message")) {
365
+ _context8.next = 10;
366
+ break;
367
+ }
368
+ _message.error(props);
369
+ return _context8.abrupt("return");
370
+ case 10:
371
+ if (!(props.type == "modal")) {
372
+ _context8.next = 15;
373
+ break;
374
+ }
375
+ _Modal.error(props);
376
+ return _context8.abrupt("return");
377
+ case 15:
378
+ if (!(props.type == "notification")) {
379
+ _context8.next = 18;
380
+ break;
381
+ }
382
+ _notification.error(props);
383
+ return _context8.abrupt("return");
384
+ case 18:
385
+ _context8.next = 24;
386
+ break;
387
+ case 20:
388
+ _context8.prev = 20;
389
+ _context8.t0 = _context8["catch"](0);
390
+ console.error("" + this.title + type + (msg || ""));
391
+ _Modal.error({
392
+ title: "" + this.title + type,
393
+ centered: true,
394
+ content: /*#__PURE__*/React.createElement(_Typography.Text, {
395
+ type: "danger"
396
+ }, msg || "")
397
+ });
398
+ case 24:
399
+ case "end":
400
+ return _context8.stop();
401
+ }
402
+ }, _callee8, this, [[0, 20]]);
342
403
  }));
343
- function showError(_x13, _x14) {
404
+ function showError(_x15, _x16) {
344
405
  return _showError.apply(this, arguments);
345
406
  }
346
407
  return showError;
347
408
  }();
348
409
  return BaseRestApi;
349
410
  }();
411
+ function getStringId(item) {
412
+ if (typeof (item === null || item === void 0 ? void 0 : item.id) === "string") {
413
+ return item.id;
414
+ } else if (typeof item === "string") {
415
+ return item;
416
+ }
417
+ return null;
418
+ }
350
419
  export var RestApi = /*#__PURE__*/function (_BaseRestApi2) {
351
420
  function RestApi(uri, options) {
352
421
  return _BaseRestApi2.call(this, uri, options) || this;
@@ -354,16 +423,16 @@ export var RestApi = /*#__PURE__*/function (_BaseRestApi2) {
354
423
  _inheritsLoose(RestApi, _BaseRestApi2);
355
424
  var _proto2 = RestApi.prototype;
356
425
  _proto2.handleRequestConfig = /*#__PURE__*/function () {
357
- var _handleRequestConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(config) {
358
- return _regeneratorRuntime.wrap(function _callee8$(_context8) {
359
- while (1) switch (_context8.prev = _context8.next) {
426
+ var _handleRequestConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9(config) {
427
+ return _regeneratorRuntime.wrap(function _callee9$(_context9) {
428
+ while (1) switch (_context9.prev = _context9.next) {
360
429
  case 0:
361
430
  case "end":
362
- return _context8.stop();
431
+ return _context9.stop();
363
432
  }
364
- }, _callee8);
433
+ }, _callee9);
365
434
  }));
366
- function handleRequestConfig(_x15) {
435
+ function handleRequestConfig(_x17) {
367
436
  return _handleRequestConfig.apply(this, arguments);
368
437
  }
369
438
  return handleRequestConfig;
@@ -5,3 +5,4 @@ export declare function handleFormSchema(schema: any): Promise<void>;
5
5
  * @param callback 返回true 继续往下遍历
6
6
  */
7
7
  export declare function forEachFormSchema(schema: any, callback: (child: any, index: number, children: any[]) => boolean): void;
8
+ export declare function getAdminFormSchema(id: string): Promise<any>;