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