@quansitech/antd-admin 1.1.16 → 1.1.18
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/components/Column/Cascader.js +5 -2
- package/dist/components/Table.js +60 -15
- package/dist/components/Tabs.js +10 -2
- package/dist/components/TabsContext.d.ts +6 -0
- package/dist/components/TabsContext.js +2 -0
- package/dist/lib/helpers.d.ts +2 -0
- package/dist/lib/helpers.js +47 -1
- package/dist/lib/schemaHandler.js +17 -3
- package/package.json +1 -1
|
@@ -31,8 +31,11 @@ export default function (props) {
|
|
|
31
31
|
var option = options[i];
|
|
32
32
|
if (option.value === value) {
|
|
33
33
|
return [option.value];
|
|
34
|
-
}
|
|
35
|
-
|
|
34
|
+
}
|
|
35
|
+
if ((_option$children = option.children) !== null && _option$children !== void 0 && _option$children.length) {
|
|
36
|
+
if (findValue(option.children, value).length) {
|
|
37
|
+
return [option.value].concat(_toConsumableArray(findValue(option.children, value)));
|
|
38
|
+
}
|
|
36
39
|
}
|
|
37
40
|
}
|
|
38
41
|
return [];
|
package/dist/components/Table.js
CHANGED
|
@@ -27,11 +27,15 @@ import http from "../lib/http";
|
|
|
27
27
|
import "./Table.scss";
|
|
28
28
|
import { ModalContext } from "./ModalContext";
|
|
29
29
|
import { commonHandler } from "../lib/schemaHandler";
|
|
30
|
-
import { diffTree } from "../lib/helpers";
|
|
30
|
+
import { diffTree, getValueByPath } from "../lib/helpers";
|
|
31
|
+
import { router } from "@inertiajs/react";
|
|
32
|
+
import qs from 'qs';
|
|
33
|
+
import { TabsContext } from "./TabsContext";
|
|
31
34
|
export default function (props) {
|
|
35
|
+
var searchUrl = props.searchUrl;
|
|
32
36
|
var request = /*#__PURE__*/function () {
|
|
33
37
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(params, sort, filter) {
|
|
34
|
-
var data, res;
|
|
38
|
+
var data, only, res;
|
|
35
39
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
36
40
|
while (1) switch (_context.prev = _context.next) {
|
|
37
41
|
case 0:
|
|
@@ -46,15 +50,42 @@ export default function (props) {
|
|
|
46
50
|
}
|
|
47
51
|
setEditableKeys([]);
|
|
48
52
|
setEditableValues([]);
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
53
|
+
if (modalContext.inModal) {
|
|
54
|
+
_context.next = 10;
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
only = ['dataSource', 'pagination'];
|
|
58
|
+
if (tabsContext.inTabs) {
|
|
59
|
+
only.push('tabs');
|
|
60
|
+
}
|
|
61
|
+
router.get(searchUrl, data, {
|
|
62
|
+
preserveScroll: true,
|
|
63
|
+
preserveState: true,
|
|
64
|
+
only: only,
|
|
65
|
+
onSuccess: function onSuccess(e) {
|
|
66
|
+
var props = e.props;
|
|
67
|
+
if (tabsContext.inTabs) {
|
|
68
|
+
props = getValueByPath(props, tabsContext.propsPath);
|
|
69
|
+
}
|
|
70
|
+
console.log(props);
|
|
71
|
+
setDataSource(postData(props.dataSource));
|
|
72
|
+
setPagination(props.pagination);
|
|
73
|
+
},
|
|
74
|
+
onFinish: function onFinish() {
|
|
75
|
+
setLoading(false);
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
return _context.abrupt("return");
|
|
79
|
+
case 10:
|
|
80
|
+
_context.prev = 10;
|
|
81
|
+
_context.next = 13;
|
|
82
|
+
return http.get(searchUrl, {
|
|
52
83
|
params: data,
|
|
53
84
|
headers: {
|
|
54
85
|
'X-Table-Search': '1'
|
|
55
86
|
}
|
|
56
87
|
});
|
|
57
|
-
case
|
|
88
|
+
case 13:
|
|
58
89
|
res = _context.sent;
|
|
59
90
|
if (res.data.pagination) {
|
|
60
91
|
setPagination(_objectSpread(_objectSpread({}, res.data.pagination), {}, {
|
|
@@ -68,15 +99,15 @@ export default function (props) {
|
|
|
68
99
|
data: res.data.dataSource || [],
|
|
69
100
|
success: true
|
|
70
101
|
});
|
|
71
|
-
case
|
|
72
|
-
_context.prev =
|
|
102
|
+
case 17:
|
|
103
|
+
_context.prev = 17;
|
|
73
104
|
setLoading(false);
|
|
74
|
-
return _context.finish(
|
|
75
|
-
case
|
|
105
|
+
return _context.finish(17);
|
|
106
|
+
case 20:
|
|
76
107
|
case "end":
|
|
77
108
|
return _context.stop();
|
|
78
109
|
}
|
|
79
|
-
}, _callee, null, [[
|
|
110
|
+
}, _callee, null, [[10,, 17, 20]]);
|
|
80
111
|
}));
|
|
81
112
|
return function request(_x, _x2, _x3) {
|
|
82
113
|
return _ref.apply(this, arguments);
|
|
@@ -85,11 +116,7 @@ export default function (props) {
|
|
|
85
116
|
var columns = useMemo(function () {
|
|
86
117
|
var _cloneDeep;
|
|
87
118
|
return (_cloneDeep = cloneDeep(props.columns)) === null || _cloneDeep === void 0 ? void 0 : _cloneDeep.map(function (c) {
|
|
88
|
-
var _props$defaultSearchV;
|
|
89
119
|
c.key = c.dataIndex;
|
|
90
|
-
if (((_props$defaultSearchV = props.defaultSearchValue) === null || _props$defaultSearchV === void 0 ? void 0 : _props$defaultSearchV[c.dataIndex]) !== undefined) {
|
|
91
|
-
c.initialValue = props.defaultSearchValue[c.dataIndex];
|
|
92
|
-
}
|
|
93
120
|
commonHandler(c);
|
|
94
121
|
if (container.schemaHandler[c.valueType]) {
|
|
95
122
|
return container.schemaHandler[c.valueType](c);
|
|
@@ -159,6 +186,7 @@ export default function (props) {
|
|
|
159
186
|
extraRenderValues = _useState16[0],
|
|
160
187
|
setExtraRenderValues = _useState16[1];
|
|
161
188
|
var modalContext = useContext(ModalContext);
|
|
189
|
+
var tabsContext = useContext(TabsContext);
|
|
162
190
|
useEffect(function () {
|
|
163
191
|
setLoading(false);
|
|
164
192
|
if (!modalContext.inModal) {
|
|
@@ -167,6 +195,23 @@ export default function (props) {
|
|
|
167
195
|
offsetHeader: ((_document$querySelect = document.querySelector('.ant-layout-header')) === null || _document$querySelect === void 0 ? void 0 : _document$querySelect.clientHeight) || 56
|
|
168
196
|
});
|
|
169
197
|
}
|
|
198
|
+
|
|
199
|
+
// 搜索
|
|
200
|
+
if (!searchUrl) {
|
|
201
|
+
searchUrl = window.location.href;
|
|
202
|
+
}
|
|
203
|
+
if (props.defaultSearchValue !== undefined) {
|
|
204
|
+
formRef.current.setFieldsValue(props.defaultSearchValue);
|
|
205
|
+
}
|
|
206
|
+
var query = qs.parse(window.location.search.replace(/^\?/, ''));
|
|
207
|
+
if (query && Object.keys(query).length) {
|
|
208
|
+
Object.keys(query).forEach(function (key) {
|
|
209
|
+
if (typeof query[key] === 'string') {
|
|
210
|
+
/^\d+$/.test(query[key]) && (query[key] = parseInt(query[key]));
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
formRef.current.setFieldsValue(query);
|
|
214
|
+
}
|
|
170
215
|
}, []);
|
|
171
216
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(TableContext.Provider, {
|
|
172
217
|
value: {
|
package/dist/components/Tabs.js
CHANGED
|
@@ -7,13 +7,16 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
|
7
7
|
import { Tabs } from "antd";
|
|
8
8
|
import React, { Suspense, useEffect, useMemo, useState } from "react";
|
|
9
9
|
import container from "../lib/container";
|
|
10
|
-
import { routerNavigateTo } from "../lib/helpers";
|
|
10
|
+
import { findValuePath, routerNavigateTo } from "../lib/helpers";
|
|
11
11
|
import { upperFirst } from "es-toolkit";
|
|
12
|
+
import { TabsContext } from "./TabsContext";
|
|
13
|
+
import { usePage } from "@inertiajs/react";
|
|
12
14
|
export default function (props) {
|
|
13
15
|
var _useState = useState(),
|
|
14
16
|
_useState2 = _slicedToArray(_useState, 2),
|
|
15
17
|
activeKey = _useState2[0],
|
|
16
18
|
setActiveKey = _useState2[1];
|
|
19
|
+
var pageProps = usePage().props;
|
|
17
20
|
var items = useMemo(function () {
|
|
18
21
|
return Object.keys(props.tabs).map(function (key) {
|
|
19
22
|
var _t$pane;
|
|
@@ -29,7 +32,12 @@ export default function (props) {
|
|
|
29
32
|
return {
|
|
30
33
|
key: key,
|
|
31
34
|
label: t.title,
|
|
32
|
-
children: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(
|
|
35
|
+
children: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(TabsContext.Provider, {
|
|
36
|
+
value: {
|
|
37
|
+
inTabs: true,
|
|
38
|
+
propsPath: findValuePath(pageProps, t.pane.props)
|
|
39
|
+
}
|
|
40
|
+
}, /*#__PURE__*/React.createElement(Suspense, null, /*#__PURE__*/React.createElement(Component, t.pane.props))))
|
|
33
41
|
};
|
|
34
42
|
});
|
|
35
43
|
}, [props.tabs]);
|
package/dist/lib/helpers.d.ts
CHANGED
|
@@ -14,3 +14,5 @@ export declare function handleCondition(condition: Condition, data: any): any;
|
|
|
14
14
|
export declare function deepSet(obj: any, path: string, value: any): void;
|
|
15
15
|
export declare function filterObjectKeys(obj: Record<string, any>, keysToFilter: string[]): Record<string, any>;
|
|
16
16
|
export declare function diffTree(tree1: any[], tree2: any[], childKey: string): any[];
|
|
17
|
+
export declare function findValuePath(obj: any, target: any, path?: string[]): string[] | null;
|
|
18
|
+
export declare function getValueByPath(obj: any, path: string[]): any;
|
package/dist/lib/helpers.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
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; }
|
|
2
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
2
3
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
3
4
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
4
5
|
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); }
|
|
@@ -101,6 +102,11 @@ function _modalShow() {
|
|
|
101
102
|
}
|
|
102
103
|
throw new Error('modal props is empty');
|
|
103
104
|
case 10:
|
|
105
|
+
if (props.type === 'table') {
|
|
106
|
+
if (typeof props.ajaxRequest === 'undefined') {
|
|
107
|
+
props.ajaxRequest = true;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
104
110
|
Component = container.get('Modal.' + upperFirst(props.type));
|
|
105
111
|
_afterClose = function afterClose() {};
|
|
106
112
|
modal = global.modal.info(_objectSpread(_objectSpread({}, options), {}, {
|
|
@@ -128,7 +134,7 @@ function _modalShow() {
|
|
|
128
134
|
destroy: modal.destroy,
|
|
129
135
|
update: modal.update
|
|
130
136
|
});
|
|
131
|
-
case
|
|
137
|
+
case 15:
|
|
132
138
|
case "end":
|
|
133
139
|
return _context.stop();
|
|
134
140
|
}
|
|
@@ -236,4 +242,44 @@ export function diffTree(tree1, tree2, childKey) {
|
|
|
236
242
|
_loop();
|
|
237
243
|
}
|
|
238
244
|
return res;
|
|
245
|
+
}
|
|
246
|
+
export function findValuePath(obj, target) {
|
|
247
|
+
var path = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
248
|
+
for (var key in obj) {
|
|
249
|
+
if (obj.hasOwnProperty(key)) {
|
|
250
|
+
var currentPath = [].concat(_toConsumableArray(path), [key]);
|
|
251
|
+
if (obj[key] === target) {
|
|
252
|
+
return currentPath;
|
|
253
|
+
} else if (_typeof(obj[key]) === 'object' && obj[key] !== null) {
|
|
254
|
+
var result = findValuePath(obj[key], target, currentPath);
|
|
255
|
+
if (result) {
|
|
256
|
+
return result;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
return null;
|
|
262
|
+
}
|
|
263
|
+
export function getValueByPath(obj, path) {
|
|
264
|
+
if (!Array.isArray(path) || path.length === 0) {
|
|
265
|
+
return undefined; // 如果路径无效,返回 undefined
|
|
266
|
+
}
|
|
267
|
+
var current = obj;
|
|
268
|
+
var _iterator = _createForOfIteratorHelper(path),
|
|
269
|
+
_step;
|
|
270
|
+
try {
|
|
271
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
272
|
+
var key = _step.value;
|
|
273
|
+
if (current && _typeof(current) === 'object' && key in current) {
|
|
274
|
+
current = current[key];
|
|
275
|
+
} else {
|
|
276
|
+
return undefined; // 如果路径中的某个键不存在,返回 undefined
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
} catch (err) {
|
|
280
|
+
_iterator.e(err);
|
|
281
|
+
} finally {
|
|
282
|
+
_iterator.f();
|
|
283
|
+
}
|
|
284
|
+
return current;
|
|
239
285
|
}
|
|
@@ -42,6 +42,14 @@ var uploadTransform = function uploadTransform(value, _name) {
|
|
|
42
42
|
};
|
|
43
43
|
export var commonHandler = function commonHandler(schema) {
|
|
44
44
|
if (schema.valueEnum) {
|
|
45
|
+
var _schema$valueEnum;
|
|
46
|
+
(_schema$valueEnum = schema.valueEnum) === null || _schema$valueEnum === void 0 || _schema$valueEnum.map(function (item) {
|
|
47
|
+
var key = item[0];
|
|
48
|
+
if (typeof key === 'string' && /^\d+$/.test(key)) {
|
|
49
|
+
key = Number(key);
|
|
50
|
+
}
|
|
51
|
+
return [key, item[1]];
|
|
52
|
+
});
|
|
45
53
|
schema.valueEnum = new Map(schema.valueEnum);
|
|
46
54
|
}
|
|
47
55
|
// 有些表单项宽度并不能撑满,这里强制设置宽度
|
|
@@ -139,14 +147,20 @@ export var schemaHandler = {
|
|
|
139
147
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
140
148
|
while (1) switch (_context.prev = _context.next) {
|
|
141
149
|
case 0:
|
|
142
|
-
if (
|
|
150
|
+
if (value) {
|
|
143
151
|
_context.next = 2;
|
|
144
152
|
break;
|
|
145
153
|
}
|
|
146
|
-
|
|
154
|
+
return _context.abrupt("return", true);
|
|
147
155
|
case 2:
|
|
156
|
+
if (!(value.slice(0, 7) === '[抓取图片中]')) {
|
|
157
|
+
_context.next = 4;
|
|
158
|
+
break;
|
|
159
|
+
}
|
|
160
|
+
throw new Error('请等待图片抓取完成');
|
|
161
|
+
case 4:
|
|
148
162
|
return _context.abrupt("return", true);
|
|
149
|
-
case
|
|
163
|
+
case 5:
|
|
150
164
|
case "end":
|
|
151
165
|
return _context.stop();
|
|
152
166
|
}
|