@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.
- package/dist/components/Column/Cascader.js +1 -1
- package/dist/components/Column/File.js +17 -10
- package/dist/components/Column/Readonly/Action.d.ts +1 -2
- package/dist/components/Column/Readonly/Action.js +26 -59
- package/dist/components/Column/Readonly/File.js +1 -1
- package/dist/components/Column/Ueditor.d.ts +0 -1
- package/dist/components/Column/Ueditor.js +17 -9
- package/dist/components/Layout/New.js +21 -25
- package/dist/components/Layout.js +25 -41
- package/dist/components/Table/Action/Button.js +13 -14
- package/dist/components/Table/Action/StartEditable.d.ts +1 -0
- package/dist/components/Table/Action/StartEditable.js +61 -15
- package/dist/components/Table.js +43 -46
- package/dist/components/TableContext.d.ts +1 -2
- package/dist/lib/helpers.d.ts +1 -4
- package/dist/lib/helpers.js +40 -60
- package/dist/lib/http.js +6 -1
- package/dist/lib/schemaHandler.js +48 -19
- package/package.json +1 -1
|
@@ -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(
|
|
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
|
-
|
|
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
|
-
|
|
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 {
|
|
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
|
|
26
|
-
|
|
27
|
-
|
|
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, {
|
|
@@ -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.
|
|
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.
|
|
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.
|
|
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("
|
|
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
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
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:
|
|
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(
|
|
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
|
|
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
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
(
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
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:
|
|
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:
|
|
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 =
|
|
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.
|
|
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(
|
|
106
|
-
case
|
|
107
|
+
return _context2.finish(24);
|
|
108
|
+
case 27:
|
|
107
109
|
return _context2.abrupt("return");
|
|
108
|
-
case
|
|
110
|
+
case 28:
|
|
109
111
|
if (!props.modal) {
|
|
110
|
-
_context2.next =
|
|
112
|
+
_context2.next = 32;
|
|
111
113
|
break;
|
|
112
114
|
}
|
|
113
|
-
_context2.next =
|
|
115
|
+
_context2.next = 31;
|
|
114
116
|
return modalShow(props.modal);
|
|
115
|
-
case
|
|
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,,
|
|
123
|
+
}, _callee, null, [[19,, 24, 27]]);
|
|
125
124
|
}));
|
|
126
125
|
return function onClick() {
|
|
127
126
|
return _ref.apply(this, arguments);
|
|
@@ -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$(
|
|
40
|
-
while (1) switch (
|
|
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
|
-
|
|
44
|
-
|
|
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:
|
|
94
|
+
data: data
|
|
49
95
|
});
|
|
50
|
-
case
|
|
51
|
-
|
|
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
|
|
54
|
-
|
|
99
|
+
case 18:
|
|
100
|
+
_context2.prev = 18;
|
|
55
101
|
setLoading(false);
|
|
56
|
-
return
|
|
57
|
-
case
|
|
102
|
+
return _context2.finish(18);
|
|
103
|
+
case 21:
|
|
58
104
|
onCancelClick();
|
|
59
|
-
case
|
|
105
|
+
case 22:
|
|
60
106
|
case "end":
|
|
61
|
-
return
|
|
107
|
+
return _context2.stop();
|
|
62
108
|
}
|
|
63
|
-
}, _callee, null, [[
|
|
109
|
+
}, _callee, null, [[13,, 18, 21]]);
|
|
64
110
|
}));
|
|
65
111
|
return function onSaveClick() {
|
|
66
112
|
return _ref.apply(this, arguments);
|
package/dist/components/Table.js
CHANGED
|
@@ -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
|
-
|
|
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 {};
|
package/dist/lib/helpers.d.ts
CHANGED
|
@@ -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;
|
package/dist/lib/helpers.js
CHANGED
|
@@ -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(
|
|
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
|
|
63
|
+
_modalShow = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(options) {
|
|
112
64
|
var props, res, Component, _afterClose, modal;
|
|
113
|
-
return _regeneratorRuntime().wrap(function
|
|
114
|
-
while (1) switch (
|
|
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
|
-
|
|
70
|
+
_context.next = 8;
|
|
119
71
|
break;
|
|
120
72
|
}
|
|
121
|
-
|
|
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 =
|
|
82
|
+
res = _context.sent;
|
|
131
83
|
if (!(typeof res.data === 'string')) {
|
|
132
|
-
|
|
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
|
-
|
|
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
|
|
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
|
|
126
|
+
return _context.stop();
|
|
175
127
|
}
|
|
176
|
-
},
|
|
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
|
-
|
|
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.
|
|
108
|
-
schema.
|
|
119
|
+
if (!schema.formItemProps.rules) {
|
|
120
|
+
schema.formItemProps.rules = [];
|
|
109
121
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
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
|
|
155
|
+
var _request = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(params) {
|
|
127
156
|
var res;
|
|
128
|
-
return _regeneratorRuntime().wrap(function
|
|
129
|
-
while (1) switch (
|
|
157
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
158
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
130
159
|
case 0:
|
|
131
|
-
|
|
160
|
+
_context2.next = 2;
|
|
132
161
|
return http(schema.fieldProps.searchUrl, {
|
|
133
162
|
params: params
|
|
134
163
|
});
|
|
135
164
|
case 2:
|
|
136
|
-
res =
|
|
137
|
-
return
|
|
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
|
|
174
|
+
return _context2.stop();
|
|
146
175
|
}
|
|
147
|
-
},
|
|
176
|
+
}, _callee2);
|
|
148
177
|
}));
|
|
149
|
-
function request(
|
|
178
|
+
function request(_x3) {
|
|
150
179
|
return _request.apply(this, arguments);
|
|
151
180
|
}
|
|
152
181
|
return request;
|