@quansitech/antd-admin 1.1.4 → 1.1.6

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.
@@ -98,7 +98,7 @@ export default function (props) {
98
98
  return;
99
99
  }
100
100
  var value = values[values.length - 1];
101
- (_props$fieldProps2 = props.fieldProps) === null || _props$fieldProps2 === void 0 || _props$fieldProps2.onChange(props.dataIndex, value);
101
+ (_props$fieldProps2 = props.fieldProps) === null || _props$fieldProps2 === void 0 || _props$fieldProps2.onChange(value);
102
102
  };
103
103
  return /*#__PURE__*/React.createElement("div", {
104
104
  className: props.className
@@ -74,6 +74,19 @@ export default function (props) {
74
74
  return _ref2.apply(this, arguments);
75
75
  };
76
76
  }();
77
+ useEffect(function () {
78
+ var _props$fieldProps;
79
+ if (loading) {
80
+ return;
81
+ }
82
+ var values = fileList.map(function (file) {
83
+ if (file.status === 'done') {
84
+ file.url = file.response.url || file.response.file_url;
85
+ }
86
+ return file;
87
+ });
88
+ (_props$fieldProps = props.fieldProps) === null || _props$fieldProps === void 0 || _props$fieldProps.onChange(values);
89
+ }, [fileList]);
77
90
  useEffect(function () {
78
91
  var extraRenderValue = [];
79
92
  if (formContext && formContext.extraRenderValues) {
@@ -87,6 +100,10 @@ export default function (props) {
87
100
  });
88
101
  extraRenderValue = (_tableContext$extraRe = (_tableContext$extraRe2 = tableContext.extraRenderValues[index]) === null || _tableContext$extraRe2 === void 0 ? void 0 : _tableContext$extraRe2[props.fieldProps.dataIndex]) !== null && _tableContext$extraRe !== void 0 ? _tableContext$extraRe : [];
89
102
  }
103
+ if (!extraRenderValue.length) {
104
+ setLoading(false);
105
+ return;
106
+ }
90
107
  setFileList(extraRenderValue.map(function (item) {
91
108
  return {
92
109
  uid: item.id,
@@ -102,16 +119,6 @@ export default function (props) {
102
119
  }));
103
120
  setLoading(false);
104
121
  }, []);
105
- useEffect(function () {
106
- var _props$fieldProps;
107
- var values = fileList.map(function (file) {
108
- if (file.status === 'done') {
109
- file.url = file.response.url || file.response.file_url;
110
- }
111
- return file;
112
- });
113
- (_props$fieldProps = props.fieldProps) === null || _props$fieldProps === void 0 || _props$fieldProps.onChange(values);
114
- }, [fileList]);
115
122
  var uploadButton = /*#__PURE__*/React.createElement(Tooltip, {
116
123
  title: fileList.length >= (((_props$fieldProps2 = props.fieldProps) === null || _props$fieldProps2 === void 0 ? void 0 : _props$fieldProps2.maxCount) || 1) ? '最多只能上传' + (((_props$fieldProps3 = props.fieldProps) === null || _props$fieldProps3 === void 0 ? void 0 : _props$fieldProps3.maxCount) || 1) + '个文件' : ''
117
124
  }, /*#__PURE__*/React.createElement(Button, {
@@ -1,11 +1,10 @@
1
1
  import React from "react";
2
2
  import { ColumnReadonlyProps } from "./types";
3
- import { Rules } from "@rc-component/async-validator/lib/interface";
4
3
  declare const _default: (props: ColumnReadonlyProps & {
5
4
  actions?: {
6
5
  type: string;
7
6
  title: string;
8
- showRules?: Rules;
7
+ showCondition?: Condition;
9
8
  badge?: any;
10
9
  }[];
11
10
  }) => React.JSX.Element;
@@ -5,72 +5,39 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
5
5
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
6
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
7
7
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
8
- function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
9
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
10
- function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
11
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
12
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
13
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
14
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
15
- function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
16
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
17
- import React, { useEffect, useState } from "react";
8
+ import React, { useMemo } from "react";
18
9
  import container from "../../../lib/container";
19
10
  import { Badge, Flex } from "antd";
20
- import { asyncFilter, handleRules } from "../../../lib/helpers";
11
+ import { handleCondition } from "../../../lib/helpers";
21
12
  import { upperFirst } from "es-toolkit";
22
13
  export default (function (props) {
23
14
  var actions = props.fieldProps.actions;
24
15
  var record = props.record;
25
- var _useState = useState([]),
26
- _useState2 = _slicedToArray(_useState, 2),
27
- Components = _useState2[0],
28
- setComponents = _useState2[1];
29
- useEffect(function () {
30
- if (actions) {
31
- asyncFilter(actions, /*#__PURE__*/function () {
32
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(Component) {
33
- return _regeneratorRuntime().wrap(function _callee$(_context) {
34
- while (1) switch (_context.prev = _context.next) {
35
- case 0:
36
- if (Component.showRules) {
37
- _context.next = 2;
38
- break;
39
- }
40
- return _context.abrupt("return", true);
41
- case 2:
42
- _context.next = 4;
43
- return handleRules(Component.showRules, record);
44
- case 4:
45
- return _context.abrupt("return", _context.sent);
46
- case 5:
47
- case "end":
48
- return _context.stop();
49
- }
50
- }, _callee);
51
- }));
52
- return function (_x) {
53
- return _ref.apply(this, arguments);
54
- };
55
- }()).then(function (Components) {
56
- return setComponents(Components.map(function (a) {
57
- var badge = a.badge;
58
- var matches = (badge + '').match(/^__(\w+)__$/);
59
- if (matches) {
60
- badge = record[matches[1]];
61
- }
62
- var c = "Column.Readonly.Action.".concat(upperFirst(a.type));
63
- return {
64
- props: _objectSpread(_objectSpread({}, a), {}, {
65
- record: record,
66
- badge: badge
67
- }),
68
- component: container.get(c)
69
- };
70
- }));
71
- });
16
+ var Components = useMemo(function () {
17
+ if (!(actions !== null && actions !== void 0 && actions.length)) {
18
+ return [];
72
19
  }
73
- }, []);
20
+ return actions.filter(function (Component) {
21
+ if (!Component.showCondition) {
22
+ return true;
23
+ }
24
+ return handleCondition(Component.showCondition, record);
25
+ }).map(function (a) {
26
+ var badge = a.badge;
27
+ var matches = (badge + '').match(/^__(\w+)__$/);
28
+ if (matches) {
29
+ badge = record[matches[1]];
30
+ }
31
+ var c = "Column.Readonly.Action.".concat(upperFirst(a.type));
32
+ return {
33
+ props: _objectSpread(_objectSpread({}, a), {}, {
34
+ record: record,
35
+ badge: badge
36
+ }),
37
+ component: container.get(c)
38
+ };
39
+ });
40
+ }, [actions, record]);
74
41
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Flex, {
75
42
  wrap: true
76
43
  }, Components.map(function (Component) {
@@ -46,7 +46,7 @@ export default function (props) {
46
46
  };
47
47
  }));
48
48
  setLoading(false);
49
- }, []);
49
+ }, [props.record]);
50
50
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Spin, {
51
51
  spinning: loading
52
52
  }, /*#__PURE__*/React.createElement(Upload, {
@@ -14,7 +14,6 @@ export default class Ueditor extends Component<ColumnProps & {
14
14
  }, any> {
15
15
  modalContext: ModalContextProps;
16
16
  editor: any;
17
- catching: boolean;
18
17
  containerRef: HTMLElement | null;
19
18
  state: {
20
19
  loading: boolean;
@@ -31,7 +31,6 @@ var Ueditor = /*#__PURE__*/function (_Component) {
31
31
  _this = _super.call.apply(_super, [this].concat(args));
32
32
  _defineProperty(_assertThisInitialized(_this), "modalContext", {});
33
33
  _defineProperty(_assertThisInitialized(_this), "editor", null);
34
- _defineProperty(_assertThisInitialized(_this), "catching", false);
35
34
  _defineProperty(_assertThisInitialized(_this), "containerRef", null);
36
35
  _defineProperty(_assertThisInitialized(_this), "state", {
37
36
  loading: true,
@@ -61,6 +60,7 @@ var Ueditor = /*#__PURE__*/function (_Component) {
61
60
  var that = _this2;
62
61
  window.UE.plugins['forceCatchRemoteImg'] = function () {
63
62
  if (this.options.forcecatchremote) {
63
+ // @ts-ignore
64
64
  this.addListener("afterpaste", function (t, a) {
65
65
  var load_src = that.props.fieldProps.ueditorPath + '/img/load.gif';
66
66
  var domUtils = window.UE.dom.domUtils;
@@ -95,16 +95,22 @@ var Ueditor = /*#__PURE__*/function (_Component) {
95
95
  }
96
96
  }
97
97
  if (catchGo) {
98
- var _that$props$form;
98
+ var _that$editor, _that$props$form;
99
99
  // $('.submit').trigger('startHandlePostData', '正在抓取图片');
100
- that.catching = true;
100
+ that.setState({
101
+ loading: true
102
+ });
103
+ that.props.fieldProps.onChange('[抓取图片中]' + ((_that$editor = that.editor) === null || _that$editor === void 0 ? void 0 : _that$editor.getContent().replace(/^\[抓取图片中]/, '')));
101
104
  that.props.dataIndex && ((_that$props$form = that.props.form) === null || _that$props$form === void 0 ? void 0 : _that$props$form.validateFields([that.props.dataIndex]));
102
105
  }
103
106
  });
104
107
  this.addListener("catchremotesuccess", function () {
105
- var _that$props$form2;
106
- that.catching = false;
108
+ var _that$editor2, _that$props$form2;
109
+ that.props.fieldProps.onChange((_that$editor2 = that.editor) === null || _that$editor2 === void 0 ? void 0 : _that$editor2.getContent().replace(/^\[抓取图片中]/, ''));
107
110
  that.props.dataIndex && ((_that$props$form2 = that.props.form) === null || _that$props$form2 === void 0 ? void 0 : _that$props$form2.validateFields([that.props.dataIndex]));
111
+ that.setState({
112
+ loading: false
113
+ });
108
114
  // $('.submit').trigger('endHandlePostData');
109
115
  });
110
116
  }
@@ -230,14 +236,16 @@ var Ueditor = /*#__PURE__*/function (_Component) {
230
236
  return {
231
237
  bindEvents: {
232
238
  'afterInsertRichText': function afterInsertRichText(e, html) {
233
- var _that$props$form3;
239
+ var _that$editor3, _that$props$form3;
234
240
  me.execCommand('cleardoc');
235
241
  filter.call(me, html);
236
242
  me.document.body.innerHTML = "<section>".concat(html, "</section>");
237
243
  me.fireEvent('catchremoteimage');
238
- that.catching = true;
244
+ that.setState({
245
+ loading: true
246
+ });
247
+ that.props.fieldProps.onChange('[抓取图片中]' + ((_that$editor3 = that.editor) === null || _that$editor3 === void 0 ? void 0 : _that$editor3.getContent().replace(/^\[抓取图片中]/, '')));
239
248
  that.props.dataIndex && ((_that$props$form3 = that.props.form) === null || _that$props$form3 === void 0 ? void 0 : _that$props$form3.validateFields([that.props.dataIndex]));
240
- // $('.submit').trigger('startHandlePostData', '正在抓取图片');
241
249
  }
242
250
  },
243
251
  commands: {}
@@ -289,7 +297,7 @@ var Ueditor = /*#__PURE__*/function (_Component) {
289
297
  }
290
298
  }, /*#__PURE__*/React.createElement(Spin, {
291
299
  spinning: _this3.state.loading
292
- }, /*#__PURE__*/React.createElement("div", {
300
+ }, /*#__PURE__*/React.createElement("textarea", {
293
301
  id: _this3.state.containerId,
294
302
  style: {
295
303
  width: _this3.state.width
@@ -47,10 +47,25 @@ export default function (_ref) {
47
47
  _useState2 = _slicedToArray(_useState, 2),
48
48
  openKeys = _useState2[0],
49
49
  setOpenKeys = _useState2[1];
50
- var _useState3 = useState(),
51
- _useState4 = _slicedToArray(_useState3, 2),
52
- route = _useState4[0],
53
- setRoute = _useState4[1];
50
+ var route = useMemo(function () {
51
+ var _layoutProps$menuList;
52
+ return {
53
+ key: '/',
54
+ routes: (_layoutProps$menuList = layoutProps.menuList) === null || _layoutProps$menuList === void 0 ? void 0 : _layoutProps$menuList.map(function (menu) {
55
+ var _menu$children;
56
+ return {
57
+ name: menu.name,
58
+ key: menu.key,
59
+ children: (_menu$children = menu.children) === null || _menu$children === void 0 ? void 0 : _menu$children.map(function (child) {
60
+ return {
61
+ name: child.name,
62
+ key: child.key
63
+ };
64
+ })
65
+ };
66
+ })
67
+ };
68
+ }, [layoutProps.menuList]);
54
69
  useEffect(function () {
55
70
  function findKeyPath(key, list) {
56
71
  for (var i = 0; i < list.length; i++) {
@@ -91,25 +106,6 @@ export default function (_ref) {
91
106
  }
92
107
  }, [pageProps.layoutProps]);
93
108
  useEffect(function () {
94
- var _layoutProps$menuList;
95
- var r = {
96
- key: '/',
97
- routes: (_layoutProps$menuList = layoutProps.menuList) === null || _layoutProps$menuList === void 0 ? void 0 : _layoutProps$menuList.map(function (menu) {
98
- var _menu$children;
99
- return {
100
- name: menu.name,
101
- key: menu.key,
102
- children: (_menu$children = menu.children) === null || _menu$children === void 0 ? void 0 : _menu$children.map(function (child) {
103
- return {
104
- name: child.name,
105
- key: child.key
106
- };
107
- })
108
- };
109
- })
110
- };
111
- setRoute(r);
112
-
113
109
  // 设置内容高度
114
110
  function onResize() {
115
111
  if (contentRef.current) {
@@ -165,7 +161,7 @@ export default function (_ref) {
165
161
  }, proContext.dark ? /*#__PURE__*/React.createElement(MoonOutlined, null) : /*#__PURE__*/React.createElement(SunOutlined, null))));
166
162
  };
167
163
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ProLayout, {
168
- title: siteTitle,
164
+ title: layoutProps.title,
169
165
  loading: layoutContext.props.loading,
170
166
  layout: "mix",
171
167
  actionsRender: actionsRender,
@@ -174,7 +170,7 @@ export default function (_ref) {
174
170
  logo: layoutContext.props.logo,
175
171
  headerContentRender: headerContentRender,
176
172
  pageTitleRender: function pageTitleRender(p) {
177
- return "".concat(pageTitle, " | ").concat(siteTitle, " \u540E\u53F0\u7BA1\u7406");
173
+ return "".concat(pageTitle, " | ").concat(layoutProps.title, " \u540E\u53F0\u7BA1\u7406");
178
174
  },
179
175
  footerRender: function footerRender() {
180
176
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Space, null, /*#__PURE__*/React.createElement("a", {
@@ -27,6 +27,7 @@ function ChildApp(props) {
27
27
  return /*#__PURE__*/React.createElement(React.Fragment, null, props.enableNewLayout ? /*#__PURE__*/React.createElement(New, props) : /*#__PURE__*/React.createElement(Blank, props));
28
28
  }
29
29
  export default function (props) {
30
+ var _pageProps$layoutProp, _pageProps$layoutProp2, _pageProps$layoutProp3, _pageProps$layoutProp4, _pageProps$layoutProp5, _pageProps$layoutProp6, _pageProps$layoutProp7;
30
31
  var _useState = useState(false),
31
32
  _useState2 = _slicedToArray(_useState, 2),
32
33
  darkMode = _useState2[0],
@@ -35,35 +36,8 @@ export default function (props) {
35
36
  _useState4 = _slicedToArray(_useState3, 2),
36
37
  enableNewLayout = _useState4[0],
37
38
  setEnableNewLayout = _useState4[1];
38
- var _useState5 = useState(''),
39
- _useState6 = _slicedToArray(_useState5, 2),
40
- pageTitle = _useState6[0],
41
- setPageTitle = _useState6[1];
42
- var _useState7 = useState(''),
43
- _useState8 = _slicedToArray(_useState7, 2),
44
- siteTitle = _useState8[0],
45
- setSiteTitle = _useState8[1];
46
39
  var pageProps = usePage().props;
47
- var _useState9 = useState({
48
- title: '',
49
- metaTitle: '',
50
- topMenuActiveKey: '',
51
- menuActiveKey: '',
52
- loading: false,
53
- topMenu: [],
54
- menuList: [],
55
- logo: '',
56
- userMenu: []
57
- }),
58
- _useState10 = _slicedToArray(_useState9, 2),
59
- layoutProps = _useState10[0],
60
- setLayoutProps = _useState10[1];
61
- var assignProps = function assignProps(newProps) {
62
- setLayoutProps(Object.assign(layoutProps, newProps));
63
- };
64
- useEffect(function () {
65
- var _pageProps$layoutProp, _pageProps$layoutProp2, _pageProps$layoutProp3, _pageProps$layoutProp4, _pageProps$layoutProp5, _pageProps$layoutProp6, _pageProps$layoutProp7;
66
- setLayoutProps({
40
+ var _useState5 = useState({
67
41
  title: ((_pageProps$layoutProp = pageProps.layoutProps) === null || _pageProps$layoutProp === void 0 ? void 0 : _pageProps$layoutProp.title) || '',
68
42
  metaTitle: '',
69
43
  topMenuActiveKey: (_pageProps$layoutProp2 = pageProps.layoutProps) === null || _pageProps$layoutProp2 === void 0 ? void 0 : _pageProps$layoutProp2.topMenuActiveKey,
@@ -73,17 +47,28 @@ export default function (props) {
73
47
  menuList: (_pageProps$layoutProp5 = pageProps.layoutProps) === null || _pageProps$layoutProp5 === void 0 ? void 0 : _pageProps$layoutProp5.menuList,
74
48
  logo: (_pageProps$layoutProp6 = pageProps.layoutProps) === null || _pageProps$layoutProp6 === void 0 ? void 0 : _pageProps$layoutProp6.logo,
75
49
  userMenu: (_pageProps$layoutProp7 = pageProps.layoutProps) === null || _pageProps$layoutProp7 === void 0 ? void 0 : _pageProps$layoutProp7.userMenu
76
- });
50
+ }),
51
+ _useState6 = _slicedToArray(_useState5, 2),
52
+ layoutProps = _useState6[0],
53
+ setLayoutProps = _useState6[1];
54
+ var assignProps = function assignProps(newProps) {
55
+ setLayoutProps(Object.assign(layoutProps, newProps));
56
+ };
57
+ useEffect(function () {
58
+ var _pageProps$layoutProp8;
59
+ console.log('props=>', pageProps);
60
+ if ((_pageProps$layoutProp8 = pageProps.layoutProps) !== null && _pageProps$layoutProp8 !== void 0 && _pageProps$layoutProp8.enableNewLayout) {
61
+ setEnableNewLayout(true);
62
+ }
77
63
  var listener = function listener(e) {
78
- var _e$detail$page$props$, _e$detail$page$props$2, _e$detail$page$props$3, _e$detail$page$props$4;
79
- // @ts-ignore
80
- setPageTitle(((_e$detail$page$props$ = e.detail.page.props.layoutProps) === null || _e$detail$page$props$ === void 0 ? void 0 : _e$detail$page$props$.metaTitle) || '');
81
- // @ts-ignore
82
- ((_e$detail$page$props$2 = e.detail.page.props.layoutProps) === null || _e$detail$page$props$2 === void 0 ? void 0 : _e$detail$page$props$2.title) && setSiteTitle(((_e$detail$page$props$3 = e.detail.page.props.layoutProps) === null || _e$detail$page$props$3 === void 0 ? void 0 : _e$detail$page$props$3.title) + '');
83
-
84
- // @ts-ignore
85
- if ((_e$detail$page$props$4 = e.detail.page.props.layoutProps) !== null && _e$detail$page$props$4 !== void 0 && _e$detail$page$props$4.enableNewLayout) {
86
- setEnableNewLayout(true);
64
+ var layoutProps = e.detail.page.props.layoutProps;
65
+ assignProps({
66
+ metaTitle: (layoutProps === null || layoutProps === void 0 ? void 0 : layoutProps.metaTitle) || ''
67
+ });
68
+ if (layoutProps !== null && layoutProps !== void 0 && layoutProps.title) {
69
+ assignProps({
70
+ title: layoutProps === null || layoutProps === void 0 ? void 0 : layoutProps.title
71
+ });
87
72
  }
88
73
  };
89
74
  document.addEventListener('inertia:navigate', listener);
@@ -92,7 +77,7 @@ export default function (props) {
92
77
  };
93
78
  }, []);
94
79
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Head, {
95
- title: pageTitle + ' | ' + siteTitle + ' 后台管理'
80
+ title: layoutProps.metaTitle + ' | ' + layoutProps.title + ' 后台管理'
96
81
  }), /*#__PURE__*/React.createElement(LayoutContext.Provider, {
97
82
  value: {
98
83
  assignProps: assignProps,
@@ -103,8 +88,7 @@ export default function (props) {
103
88
  dark: darkMode
104
89
  }, /*#__PURE__*/React.createElement(AntdApp, null, /*#__PURE__*/React.createElement(ChildApp, _extends({}, props, {
105
90
  setDarkMode: setDarkMode,
106
- pageTitle: pageTitle,
107
- siteTitle: siteTitle,
91
+ pageTitle: layoutProps.metaTitle,
108
92
  enableNewLayout: enableNewLayout
109
93
  }))))));
110
94
  }
@@ -18,8 +18,7 @@ export default function (props) {
18
18
  var tableContext = useContext(TableContext);
19
19
  var onClick = /*#__PURE__*/function () {
20
20
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
21
- var _tableContext$actionR;
22
- var rowKey, data, _props$selectedRows, _loop, _ret, key;
21
+ var rowKey, data, _props$selectedRows, _loop, _ret, key, _tableContext$actionR;
23
22
  return _regeneratorRuntime().wrap(function _callee$(_context2) {
24
23
  while (1) switch (_context2.prev = _context2.next) {
25
24
  case 0:
@@ -32,7 +31,7 @@ export default function (props) {
32
31
  return _context2.abrupt("return");
33
32
  case 4:
34
33
  if (!props.request) {
35
- _context2.next = 26;
34
+ _context2.next = 28;
36
35
  break;
37
36
  }
38
37
  setLoading(true);
@@ -100,28 +99,28 @@ export default function (props) {
100
99
  data: data
101
100
  });
102
101
  case 22:
103
- _context2.prev = 22;
102
+ _context2.next = 24;
103
+ return (_tableContext$actionR = tableContext.actionRef) === null || _tableContext$actionR === void 0 ? void 0 : _tableContext$actionR.reload();
104
+ case 24:
105
+ _context2.prev = 24;
104
106
  setLoading(false);
105
- return _context2.finish(22);
106
- case 25:
107
+ return _context2.finish(24);
108
+ case 27:
107
109
  return _context2.abrupt("return");
108
- case 26:
110
+ case 28:
109
111
  if (!props.modal) {
110
- _context2.next = 30;
112
+ _context2.next = 32;
111
113
  break;
112
114
  }
113
- _context2.next = 29;
115
+ _context2.next = 31;
114
116
  return modalShow(props.modal);
115
- case 29:
117
+ case 31:
116
118
  return _context2.abrupt("return");
117
- case 30:
118
- _context2.next = 32;
119
- return (_tableContext$actionR = tableContext.actionRef) === null || _tableContext$actionR === void 0 ? void 0 : _tableContext$actionR.reload();
120
119
  case 32:
121
120
  case "end":
122
121
  return _context2.stop();
123
122
  }
124
- }, _callee, null, [[19,, 22, 25]]);
123
+ }, _callee, null, [[19,, 24, 27]]);
125
124
  }));
126
125
  return function onClick() {
127
126
  return _ref.apply(this, arguments);
@@ -6,5 +6,6 @@ export default function (props: TableActionProps & {
6
6
  saveRequest: {
7
7
  url: string;
8
8
  method: string;
9
+ data?: Record<string, any>;
9
10
  };
10
11
  }): React.JSX.Element;
@@ -35,32 +35,78 @@ export default function (props) {
35
35
  setLoading = _useState2[1];
36
36
  var onSaveClick = /*#__PURE__*/function () {
37
37
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
38
- var _tableContext$actionR3;
39
- return _regeneratorRuntime().wrap(function _callee$(_context) {
40
- while (1) switch (_context.prev = _context.next) {
38
+ var data, _loop, dataKey, _tableContext$actionR3;
39
+ return _regeneratorRuntime().wrap(function _callee$(_context2) {
40
+ while (1) switch (_context2.prev = _context2.next) {
41
41
  case 0:
42
42
  setLoading(true);
43
- _context.prev = 1;
44
- _context.next = 4;
43
+ data = tableContext.getEditedValues();
44
+ if (!props.saveRequest.data) {
45
+ _context2.next = 13;
46
+ break;
47
+ }
48
+ data = {};
49
+ _loop = /*#__PURE__*/_regeneratorRuntime().mark(function _loop(dataKey) {
50
+ var match;
51
+ return _regeneratorRuntime().wrap(function _loop$(_context) {
52
+ while (1) switch (_context.prev = _context.next) {
53
+ case 0:
54
+ data[dataKey] = [];
55
+ match = props.saveRequest.data[dataKey].match(/^__(\w+)__$/);
56
+ if (match) {
57
+ _context.next = 4;
58
+ break;
59
+ }
60
+ return _context.abrupt("return", 1);
61
+ case 4:
62
+ tableContext.getEditedValues().forEach(function (item) {
63
+ data[dataKey].push(item[match[1]]);
64
+ });
65
+ case 5:
66
+ case "end":
67
+ return _context.stop();
68
+ }
69
+ }, _loop);
70
+ });
71
+ _context2.t0 = _regeneratorRuntime().keys(props.saveRequest.data);
72
+ case 6:
73
+ if ((_context2.t1 = _context2.t0()).done) {
74
+ _context2.next = 13;
75
+ break;
76
+ }
77
+ dataKey = _context2.t1.value;
78
+ return _context2.delegateYield(_loop(dataKey), "t2", 9);
79
+ case 9:
80
+ if (!_context2.t2) {
81
+ _context2.next = 11;
82
+ break;
83
+ }
84
+ return _context2.abrupt("continue", 6);
85
+ case 11:
86
+ _context2.next = 6;
87
+ break;
88
+ case 13:
89
+ _context2.prev = 13;
90
+ _context2.next = 16;
45
91
  return http({
46
92
  method: props.saveRequest.method,
47
93
  url: props.saveRequest.url,
48
- data: tableContext.getEditedValues()
94
+ data: data
49
95
  });
50
- case 4:
51
- _context.next = 6;
96
+ case 16:
97
+ _context2.next = 18;
52
98
  return (_tableContext$actionR3 = tableContext.actionRef) === null || _tableContext$actionR3 === void 0 ? void 0 : _tableContext$actionR3.reload();
53
- case 6:
54
- _context.prev = 6;
99
+ case 18:
100
+ _context2.prev = 18;
55
101
  setLoading(false);
56
- return _context.finish(6);
57
- case 9:
102
+ return _context2.finish(18);
103
+ case 21:
58
104
  onCancelClick();
59
- case 10:
105
+ case 22:
60
106
  case "end":
61
- return _context.stop();
107
+ return _context2.stop();
62
108
  }
63
- }, _callee, null, [[1,, 6, 9]]);
109
+ }, _callee, null, [[13,, 18, 21]]);
64
110
  }));
65
111
  return function onSaveClick() {
66
112
  return _ref.apply(this, arguments);
@@ -81,6 +81,45 @@ export default function (props) {
81
81
  return _ref.apply(this, arguments);
82
82
  };
83
83
  }();
84
+ var columns = useMemo(function () {
85
+ var _cloneDeep;
86
+ return (_cloneDeep = cloneDeep(props.columns)) === null || _cloneDeep === void 0 ? void 0 : _cloneDeep.map(function (c) {
87
+ var _props$defaultSearchV;
88
+ c.key = c.dataIndex;
89
+ if (((_props$defaultSearchV = props.defaultSearchValue) === null || _props$defaultSearchV === void 0 ? void 0 : _props$defaultSearchV[c.dataIndex]) !== undefined) {
90
+ c.initialValue = props.defaultSearchValue[c.dataIndex];
91
+ }
92
+ commonHandler(c);
93
+ if (container.schemaHandler[c.valueType]) {
94
+ return container.schemaHandler[c.valueType](c);
95
+ }
96
+ return c;
97
+ });
98
+ }, [props.columns]);
99
+ var postData = function postData(data) {
100
+ if (!isArray(data)) {
101
+ return data;
102
+ }
103
+ columns.map(function (column) {
104
+ switch (column.valueType) {
105
+ case 'dateTime':
106
+ data = data.map(function (row) {
107
+ var v = row[column.dataIndex];
108
+ if (parseInt(v) == v && v < 4102444800) {
109
+ row[column.dataIndex] *= 1000;
110
+ }
111
+ return row;
112
+ });
113
+ break;
114
+ }
115
+ });
116
+ return data.map(function (row) {
117
+ if (typeof row[props.rowKey] === 'undefined') {
118
+ row[props.rowKey] = uniqueId('row_');
119
+ }
120
+ return row;
121
+ });
122
+ };
84
123
  var formRef = useRef();
85
124
  var actionRef = useRef();
86
125
  var _useState = useState(function () {
@@ -101,11 +140,12 @@ export default function (props) {
101
140
  _useState8 = _slicedToArray(_useState7, 2),
102
141
  loading = _useState8[0],
103
142
  setLoading = _useState8[1];
104
- var _useState9 = useState(),
143
+ // @ts-ignore
144
+ var _useState9 = useState(props.pagination),
105
145
  _useState10 = _slicedToArray(_useState9, 2),
106
146
  pagination = _useState10[0],
107
147
  setPagination = _useState10[1];
108
- var _useState11 = useState([]),
148
+ var _useState11 = useState(postData(props.dataSource)),
109
149
  _useState12 = _slicedToArray(_useState11, 2),
110
150
  dataSource = _useState12[0],
111
151
  setDataSource = _useState12[1];
@@ -113,31 +153,12 @@ export default function (props) {
113
153
  _useState14 = _slicedToArray(_useState13, 2),
114
154
  sticky = _useState14[0],
115
155
  setSticky = _useState14[1];
116
- var _useState15 = useState([]),
156
+ var _useState15 = useState(props.extraRenderValues),
117
157
  _useState16 = _slicedToArray(_useState15, 2),
118
158
  extraRenderValues = _useState16[0],
119
159
  setExtraRenderValues = _useState16[1];
120
- var columns = useMemo(function () {
121
- var _cloneDeep;
122
- return (_cloneDeep = cloneDeep(props.columns)) === null || _cloneDeep === void 0 ? void 0 : _cloneDeep.map(function (c) {
123
- var _props$defaultSearchV;
124
- c.key = c.dataIndex;
125
- if (((_props$defaultSearchV = props.defaultSearchValue) === null || _props$defaultSearchV === void 0 ? void 0 : _props$defaultSearchV[c.dataIndex]) !== undefined) {
126
- c.initialValue = props.defaultSearchValue[c.dataIndex];
127
- }
128
- commonHandler(c);
129
- if (container.schemaHandler[c.valueType]) {
130
- return container.schemaHandler[c.valueType](c);
131
- }
132
- return c;
133
- });
134
- }, [props.columns]);
135
160
  var modalContext = useContext(ModalContext);
136
161
  useEffect(function () {
137
- // @ts-ignore
138
- setPagination(props.pagination || false);
139
- setDataSource(postData(props.dataSource));
140
- setExtraRenderValues(props.extraRenderValues);
141
162
  setLoading(false);
142
163
  if (!modalContext.inModal) {
143
164
  var _document$querySelect;
@@ -146,30 +167,6 @@ export default function (props) {
146
167
  });
147
168
  }
148
169
  }, []);
149
- var postData = function postData(data) {
150
- if (!isArray(data)) {
151
- return data;
152
- }
153
- columns.map(function (column) {
154
- switch (column.valueType) {
155
- case 'dateTime':
156
- data = data.map(function (row) {
157
- var v = row[column.dataIndex];
158
- if (parseInt(v) == v && v < 4102444800) {
159
- row[column.dataIndex] *= 1000;
160
- }
161
- return row;
162
- });
163
- break;
164
- }
165
- });
166
- return data.map(function (row) {
167
- if (typeof row[props.rowKey] === 'undefined') {
168
- row[props.rowKey] = uniqueId('row_');
169
- }
170
- return row;
171
- });
172
- };
173
170
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(TableContext.Provider, {
174
171
  value: {
175
172
  getTableProps: function getTableProps() {
@@ -2,7 +2,7 @@ import React from "react";
2
2
  import { ActionType } from "@ant-design/pro-components";
3
3
  import { TableProps } from "./Table";
4
4
  import { FormInstance } from "antd/lib/form";
5
- type TableContextValue = {
5
+ export type TableContextValue = {
6
6
  getTableProps: () => TableProps;
7
7
  getEditedValues: () => Record<string, any>[];
8
8
  editableKeys: React.Key[];
@@ -15,4 +15,3 @@ type TableContextValue = {
15
15
  dataSource: any[];
16
16
  };
17
17
  export declare const TableContext: React.Context<TableContextValue>;
18
- export {};
@@ -1,12 +1,8 @@
1
1
  import { VisitOptions } from "@inertiajs/core/types/types";
2
- import { Rules } from "@rc-component/async-validator/lib/interface";
3
2
  import { ModalFuncProps } from "antd";
4
3
  export declare function replaceUrl(url: string, params: any): string;
5
4
  export declare function replaceParams(params: Record<string, any>, data: Record<string, any>): Record<string, any>;
6
5
  export declare function routerNavigateTo(url: string, config?: VisitOptions): void;
7
- export declare function handleRules(dataRules: Rules, data: any): Promise<unknown>;
8
- export declare function asyncFilter(arr: any[], predicate: (item: any) => PromiseLike<any>): Promise<any[]>;
9
- export declare function filterObjectKeys(obj: Record<string, any>, keysToKeep: string[]): Record<string, any>;
10
6
  export declare function createScript(url: string): Promise<unknown>;
11
7
  export declare function modalShow(options: ModalOptions): Promise<{
12
8
  destroy: () => void;
@@ -14,3 +10,4 @@ export declare function modalShow(options: ModalOptions): Promise<{
14
10
  }>;
15
11
  export declare function upperFirst(str: string): string;
16
12
  export declare function getProValueTypeMap(): any;
13
+ export declare function handleCondition(condition: Condition, data: any): any;
@@ -8,7 +8,6 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
8
8
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
9
9
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
10
10
  import { router } from "@inertiajs/react";
11
- import Schema from '@rc-component/async-validator';
12
11
  import http from "./http";
13
12
  import container from "./container";
14
13
  import React, { Suspense } from "react";
@@ -38,53 +37,6 @@ export function replaceParams(params, data) {
38
37
  export function routerNavigateTo(url, config) {
39
38
  return router.visit(url, _objectSpread({}, config));
40
39
  }
41
- export function handleRules(dataRules, data) {
42
- return new Promise(function (resolve) {
43
- var validator = new Schema(dataRules);
44
- validator.validate(data, function (errors, fields) {
45
- if (errors) {
46
- resolve(false);
47
- return;
48
- }
49
- resolve(true);
50
- });
51
- });
52
- }
53
- export function asyncFilter(_x, _x2) {
54
- return _asyncFilter.apply(this, arguments);
55
- }
56
- function _asyncFilter() {
57
- _asyncFilter = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(arr, predicate) {
58
- return _regeneratorRuntime().wrap(function _callee$(_context) {
59
- while (1) switch (_context.prev = _context.next) {
60
- case 0:
61
- _context.next = 2;
62
- return Promise.all(arr.map(predicate)).then(function (results) {
63
- return arr.filter(function (_v, index) {
64
- return results[index];
65
- });
66
- });
67
- case 2:
68
- return _context.abrupt("return", _context.sent);
69
- case 3:
70
- case "end":
71
- return _context.stop();
72
- }
73
- }, _callee);
74
- }));
75
- return _asyncFilter.apply(this, arguments);
76
- }
77
- export function filterObjectKeys(obj, keysToKeep) {
78
- if (_typeof(obj) !== 'object' || !obj) {
79
- return obj;
80
- }
81
- return Object.keys(obj).filter(function (key) {
82
- return !keysToKeep.includes(key);
83
- }).reduce(function (newObj, key) {
84
- newObj[key] = obj[key];
85
- return newObj;
86
- }, {});
87
- }
88
40
  export function createScript(url) {
89
41
  var scriptTags = window.document.querySelectorAll('script');
90
42
  var len = scriptTags.length;
@@ -104,21 +56,21 @@ export function createScript(url) {
104
56
  document.body.appendChild(node);
105
57
  });
106
58
  }
107
- export function modalShow(_x3) {
59
+ export function modalShow(_x) {
108
60
  return _modalShow.apply(this, arguments);
109
61
  }
110
62
  function _modalShow() {
111
- _modalShow = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(options) {
63
+ _modalShow = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(options) {
112
64
  var props, res, Component, _afterClose, modal;
113
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
114
- while (1) switch (_context2.prev = _context2.next) {
65
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
66
+ while (1) switch (_context.prev = _context.next) {
115
67
  case 0:
116
68
  props = options.content.props;
117
69
  if (!options.content.url) {
118
- _context2.next = 8;
70
+ _context.next = 8;
119
71
  break;
120
72
  }
121
- _context2.next = 4;
73
+ _context.next = 4;
122
74
  return http({
123
75
  method: 'get',
124
76
  url: options.content.url,
@@ -127,9 +79,9 @@ function _modalShow() {
127
79
  }
128
80
  });
129
81
  case 4:
130
- res = _context2.sent;
82
+ res = _context.sent;
131
83
  if (!(typeof res.data === 'string')) {
132
- _context2.next = 7;
84
+ _context.next = 7;
133
85
  break;
134
86
  }
135
87
  throw new Error('modal response is not vail');
@@ -137,7 +89,7 @@ function _modalShow() {
137
89
  props = res.data;
138
90
  case 8:
139
91
  if (props) {
140
- _context2.next = 10;
92
+ _context.next = 10;
141
93
  break;
142
94
  }
143
95
  throw new Error('modal props is empty');
@@ -165,15 +117,15 @@ function _modalShow() {
165
117
  _afterClose && _afterClose();
166
118
  }
167
119
  }));
168
- return _context2.abrupt("return", {
120
+ return _context.abrupt("return", {
169
121
  destroy: modal.destroy,
170
122
  update: modal.update
171
123
  });
172
124
  case 14:
173
125
  case "end":
174
- return _context2.stop();
126
+ return _context.stop();
175
127
  }
176
- }, _callee2);
128
+ }, _callee);
177
129
  }));
178
130
  return _modalShow.apply(this, arguments);
179
131
  }
@@ -205,4 +157,32 @@ export function getProValueTypeMap() {
205
157
  };
206
158
  return map;
207
159
  }, {});
160
+ }
161
+ export function handleCondition(condition, data) {
162
+ switch (condition.operator) {
163
+ case 'eq':
164
+ case '=':
165
+ return data[condition.field] == condition.value;
166
+ case 'neq':
167
+ case '!=':
168
+ case '<>':
169
+ return data[condition.field] != condition.value;
170
+ case 'gt':
171
+ case '>':
172
+ return data[condition.field] > condition.value;
173
+ case 'gte':
174
+ case '>=':
175
+ return data[condition.field] >= condition.value;
176
+ case 'lt':
177
+ case '<':
178
+ return data[condition.field] < condition.value;
179
+ case 'elt':
180
+ case '<=':
181
+ return data[condition.field] <= condition.value;
182
+ case 'in':
183
+ return data[condition.field] && condition.value.includes(data[condition.field]);
184
+ case 'not in':
185
+ return data[condition.field] && !condition.value.includes(data[condition.field]);
186
+ }
187
+ return false;
208
188
  }
package/dist/lib/http.js CHANGED
@@ -13,6 +13,7 @@ http.interceptors.request.use(function (config) {
13
13
  config.headers['X-Requested-With'] = 'XMLHttpRequest';
14
14
  return config;
15
15
  });
16
+ var timer;
16
17
  http.interceptors.response.use(function (response) {
17
18
  var _response$config$fetc;
18
19
  var checkInfo = function checkInfo(data) {
@@ -37,8 +38,12 @@ http.interceptors.response.use(function (response) {
37
38
  }
38
39
  var showInfo = checkInfo(response.data);
39
40
  if (response.data.url) {
40
- setTimeout(function () {
41
+ if (timer) {
42
+ clearTimeout(timer);
43
+ }
44
+ timer = setTimeout(function () {
41
45
  routerNavigateTo(response.data.url);
46
+ timer = null;
42
47
  }, showInfo ? 2000 : 0);
43
48
  }
44
49
  if (response.data.status == 0) {
@@ -8,6 +8,7 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
8
8
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
9
9
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
10
10
  import http from "./http";
11
+ import { handleCondition } from "./helpers";
11
12
  var uploadValidator = function uploadValidator(_, value) {
12
13
  return new Promise(function (resolve, reject) {
13
14
  if (!value) {
@@ -100,21 +101,49 @@ export var schemaHandler = {
100
101
  };
101
102
  return schema;
102
103
  },
104
+ dependency: function dependency(schema) {
105
+ var _columns = schema.columns,
106
+ valueType = schema.valueType;
107
+ return {
108
+ valueType: valueType,
109
+ name: [schema.showCondition.field],
110
+ columns: function columns(fields) {
111
+ return handleCondition(schema.showCondition, fields) ? _columns : [];
112
+ }
113
+ };
114
+ },
103
115
  ueditor: function ueditor(schema) {
104
116
  if (!schema.formItemProps) {
105
117
  schema.formItemProps = {};
106
118
  }
107
- if (!schema.fieldProps.rules) {
108
- schema.fieldProps.rules = [];
119
+ if (!schema.formItemProps.rules) {
120
+ schema.formItemProps.rules = [];
109
121
  }
110
- // schema.formItemProps.rules.push({
111
- // validator: async (rule: any, value: any) => {
112
- // if (this.catching) {
113
- // throw new Error('正在抓取图片')
114
- // }
115
- // return true
116
- // }
117
- // })
122
+ schema.formItemProps.rules.push({
123
+ validator: function () {
124
+ var _validator = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(rule, value) {
125
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
126
+ while (1) switch (_context.prev = _context.next) {
127
+ case 0:
128
+ if (!(value.slice(0, 7) === '[抓取图片中]')) {
129
+ _context.next = 2;
130
+ break;
131
+ }
132
+ throw new Error('请等待图片抓取完成');
133
+ case 2:
134
+ return _context.abrupt("return", true);
135
+ case 3:
136
+ case "end":
137
+ return _context.stop();
138
+ }
139
+ }, _callee);
140
+ }));
141
+ function validator(_x, _x2) {
142
+ return _validator.apply(this, arguments);
143
+ }
144
+ return validator;
145
+ }()
146
+ });
118
147
  return _objectSpread({}, schema);
119
148
  },
120
149
  select: function select(schema) {
@@ -123,18 +152,18 @@ export var schemaHandler = {
123
152
  if ((_schema$fieldProps = schema.fieldProps) !== null && _schema$fieldProps !== void 0 && _schema$fieldProps.searchUrl) {
124
153
  return _objectSpread(_objectSpread({}, schema), {}, {
125
154
  request: function () {
126
- var _request = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(params) {
155
+ var _request = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(params) {
127
156
  var res;
128
- return _regeneratorRuntime().wrap(function _callee$(_context) {
129
- while (1) switch (_context.prev = _context.next) {
157
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
158
+ while (1) switch (_context2.prev = _context2.next) {
130
159
  case 0:
131
- _context.next = 2;
160
+ _context2.next = 2;
132
161
  return http(schema.fieldProps.searchUrl, {
133
162
  params: params
134
163
  });
135
164
  case 2:
136
- res = _context.sent;
137
- return _context.abrupt("return", res.data.map(function (item) {
165
+ res = _context2.sent;
166
+ return _context2.abrupt("return", res.data.map(function (item) {
138
167
  return {
139
168
  label: item.label || item.value,
140
169
  value: item.value
@@ -142,11 +171,11 @@ export var schemaHandler = {
142
171
  }));
143
172
  case 4:
144
173
  case "end":
145
- return _context.stop();
174
+ return _context2.stop();
146
175
  }
147
- }, _callee);
176
+ }, _callee2);
148
177
  }));
149
- function request(_x) {
178
+ function request(_x3) {
150
179
  return _request.apply(this, arguments);
151
180
  }
152
181
  return request;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quansitech/antd-admin",
3
- "version": "1.1.4",
3
+ "version": "1.1.6",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"