@deepinnet-components/pc 0.0.6 → 0.0.8
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/Table/demo/actionRef.d.ts +2 -2
- package/dist/Table/demo/actionRef.js +27 -7
- package/dist/Table/demo/request.js +30 -20
- package/dist/Table/index.d.ts +15 -9
- package/dist/Table/index.js +192 -87
- package/package.json +5 -5
|
@@ -7,10 +7,9 @@ function _asyncToGenerator(fn) { return function () { var self = this, args = ar
|
|
|
7
7
|
* description: 供外部调用的事件 reload、reloadCurrentPage、reset
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
import { ShenduTable } from "../..";
|
|
11
11
|
import { Button } from 'antd';
|
|
12
|
-
import React from 'react';
|
|
13
|
-
import ShenduTable from "../index";
|
|
12
|
+
import React, { useRef } from 'react';
|
|
14
13
|
var getDataPromise = function getDataPromise() {
|
|
15
14
|
return new Promise(function (resolve) {
|
|
16
15
|
setTimeout(function () {
|
|
@@ -31,7 +30,7 @@ var getDataPromise = function getDataPromise() {
|
|
|
31
30
|
}, 300);
|
|
32
31
|
});
|
|
33
32
|
};
|
|
34
|
-
var
|
|
33
|
+
var Demo = function Demo() {
|
|
35
34
|
var columns = [{
|
|
36
35
|
title: '姓名',
|
|
37
36
|
dataIndex: 'name',
|
|
@@ -48,6 +47,7 @@ var Demo1 = function Demo1() {
|
|
|
48
47
|
width: 150,
|
|
49
48
|
align: 'left'
|
|
50
49
|
}];
|
|
50
|
+
var tableRef = useRef();
|
|
51
51
|
return /*#__PURE__*/React.createElement(ShenduTable, {
|
|
52
52
|
request: /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
53
53
|
var data;
|
|
@@ -71,15 +71,35 @@ var Demo1 = function Demo1() {
|
|
|
71
71
|
})),
|
|
72
72
|
columns: columns,
|
|
73
73
|
rowKey: "id",
|
|
74
|
+
actionRef: tableRef,
|
|
74
75
|
toolbar: {
|
|
75
76
|
title: /*#__PURE__*/React.createElement("div", {
|
|
76
77
|
style: {
|
|
77
78
|
marginBottom: 20
|
|
78
79
|
}
|
|
79
80
|
}, /*#__PURE__*/React.createElement(Button, {
|
|
80
|
-
type: "primary"
|
|
81
|
-
|
|
81
|
+
type: "primary",
|
|
82
|
+
onClick: function onClick() {
|
|
83
|
+
tableRef.current.reloadCurrentPage();
|
|
84
|
+
}
|
|
85
|
+
}, "\u5F53\u524D\u9875\u641C\u7D22"), /*#__PURE__*/React.createElement(Button, {
|
|
86
|
+
type: "primary",
|
|
87
|
+
style: {
|
|
88
|
+
marginLeft: 10
|
|
89
|
+
},
|
|
90
|
+
onClick: function onClick() {
|
|
91
|
+
tableRef.current.reload();
|
|
92
|
+
}
|
|
93
|
+
}, "\u9875\u7801\u53D8\u62101 & \u91CD\u65B0\u641C\u7D22"), /*#__PURE__*/React.createElement(Button, {
|
|
94
|
+
type: "primary",
|
|
95
|
+
style: {
|
|
96
|
+
marginLeft: 10
|
|
97
|
+
},
|
|
98
|
+
onClick: function onClick() {
|
|
99
|
+
tableRef.current.reset();
|
|
100
|
+
}
|
|
101
|
+
}, "\u9875\u7801\u53D8\u62101\u91CD\u7F6E\u6240\u6709\u641C\u7D22\u6761\u4EF6"))
|
|
82
102
|
}
|
|
83
103
|
});
|
|
84
104
|
};
|
|
85
|
-
export default
|
|
105
|
+
export default Demo;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
2
|
+
var _excluded = ["current", "pageSize"];
|
|
2
3
|
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 exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
4
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
5
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
3
6
|
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); } }
|
|
4
7
|
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); }); }; }
|
|
5
8
|
/**
|
|
@@ -48,26 +51,33 @@ var Demo1 = function Demo1() {
|
|
|
48
51
|
align: 'left'
|
|
49
52
|
}];
|
|
50
53
|
return /*#__PURE__*/React.createElement(ShenduTable, {
|
|
51
|
-
request: /*#__PURE__*/
|
|
52
|
-
var
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
54
|
+
request: /*#__PURE__*/function () {
|
|
55
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(searchInfo) {
|
|
56
|
+
var pageNum, pageSize, search, data;
|
|
57
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
58
|
+
while (1) switch (_context.prev = _context.next) {
|
|
59
|
+
case 0:
|
|
60
|
+
// searchInfo 搜索参数
|
|
61
|
+
pageNum = searchInfo.current, pageSize = searchInfo.pageSize, search = _objectWithoutProperties(searchInfo, _excluded);
|
|
62
|
+
_context.next = 3;
|
|
63
|
+
return getDataPromise();
|
|
64
|
+
case 3:
|
|
65
|
+
data = _context.sent;
|
|
66
|
+
return _context.abrupt("return", {
|
|
67
|
+
data: data.list,
|
|
68
|
+
success: true,
|
|
69
|
+
total: data.total || 0
|
|
70
|
+
});
|
|
71
|
+
case 5:
|
|
72
|
+
case "end":
|
|
73
|
+
return _context.stop();
|
|
74
|
+
}
|
|
75
|
+
}, _callee);
|
|
76
|
+
}));
|
|
77
|
+
return function (_x) {
|
|
78
|
+
return _ref.apply(this, arguments);
|
|
79
|
+
};
|
|
80
|
+
}(),
|
|
71
81
|
columns: columns,
|
|
72
82
|
rowKey: "id",
|
|
73
83
|
toolbar: {
|
package/dist/Table/index.d.ts
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
import type { PaginationProps, TableProps } from 'antd';
|
|
2
|
-
import { ColumnType } from 'antd/lib/table';
|
|
3
2
|
import React from 'react';
|
|
4
3
|
interface SearchConfig {
|
|
5
4
|
labelWidth: number | string;
|
|
6
5
|
}
|
|
7
|
-
interface Columns
|
|
8
|
-
|
|
9
|
-
hideInTable?: boolean;
|
|
10
|
-
searchConfig?: {
|
|
6
|
+
interface Columns {
|
|
7
|
+
searchConfig: {
|
|
11
8
|
sort?: number;
|
|
12
9
|
title?: string;
|
|
13
10
|
labelWidth?: number | string;
|
|
@@ -21,11 +18,12 @@ declare type RequestData<T> = {
|
|
|
21
18
|
success?: boolean;
|
|
22
19
|
total?: number;
|
|
23
20
|
} & Record<string, any>;
|
|
24
|
-
|
|
21
|
+
declare type ShenduTableProps<T> = {
|
|
25
22
|
searchComponents?: Record<string, any>;
|
|
23
|
+
searchRenderEffect?: number;
|
|
26
24
|
className?: string;
|
|
27
25
|
params?: Record<string, any>;
|
|
28
|
-
pagination?: PaginationProps
|
|
26
|
+
pagination?: PaginationProps;
|
|
29
27
|
actionRef?: {
|
|
30
28
|
current: any;
|
|
31
29
|
};
|
|
@@ -34,17 +32,25 @@ interface ShenduTableProps<T> extends Omit<TableProps<T>, 'columns' | 'paginatio
|
|
|
34
32
|
className?: string;
|
|
35
33
|
};
|
|
36
34
|
request?: (data: any) => Promise<RequestData<T>>;
|
|
37
|
-
columns: Columns[];
|
|
35
|
+
columns: any[] | Columns[];
|
|
38
36
|
search?: SearchConfig | false;
|
|
39
37
|
initSearchKey?: string;
|
|
40
38
|
ignoreSearchParamsKey?: string[];
|
|
41
|
-
|
|
39
|
+
pageSizeOptions?: number[];
|
|
40
|
+
onSearch?: any;
|
|
41
|
+
hiddenFooterBlock?: boolean;
|
|
42
|
+
searchParamsKeyLocalFormat?: any;
|
|
43
|
+
ignoreResetSearchField?: string[];
|
|
44
|
+
resetSearchValues?: any;
|
|
45
|
+
initSearchValues?: any;
|
|
46
|
+
} & Omit<TableProps<T>, 'columns'>;
|
|
42
47
|
/**
|
|
43
48
|
* Table + formily
|
|
44
49
|
* 基本用法类似 Protable
|
|
45
50
|
* 新功能:
|
|
46
51
|
* 2、toolbar: { title: ReactNode, className: '' }
|
|
47
52
|
* 3、search: { labelWidth: '统一设置搜索字段label宽度' }
|
|
53
|
+
* 4、actionRef: 绑定了内部方法 reload,可以手动更新
|
|
48
54
|
*/
|
|
49
55
|
declare const ShenduTable: <T extends Record<string, any>>(props: ShenduTableProps<T>) => React.JSX.Element | null;
|
|
50
56
|
export default ShenduTable;
|
package/dist/Table/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
2
|
-
var _excluded = ["initSearchKey", "ignoreSearchParamsKey", "toolbar", "columns", "search", "params", "className", "dataSource", "searchComponents"];
|
|
2
|
+
var _excluded = ["initSearchKey", "ignoreSearchParamsKey", "ignoreResetSearchField", "resetSearchValues", "toolbar", "columns", "search", "params", "className", "dataSource", "searchComponents", "searchRenderEffect", "pageSizeOptions", "searchParamsKeyLocalFormat", "initSearchValues"];
|
|
3
3
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
4
4
|
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 exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
5
5
|
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); } }
|
|
@@ -18,23 +18,36 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input ==
|
|
|
18
18
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
19
19
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
20
20
|
/* eslint-disable */
|
|
21
|
-
import { Form, FormGrid, FormItem, Input,
|
|
21
|
+
import { DatePicker as DatePickerFormily, Form, FormGrid, FormItem, Input, Select, Submit } from '@formily/antd-v5';
|
|
22
22
|
import { createForm } from '@formily/core';
|
|
23
23
|
import { createSchemaField } from '@formily/react';
|
|
24
|
-
import { DatePicker, Pagination, Table } from 'antd';
|
|
24
|
+
import { Button, ConfigProvider, DatePicker, Empty, Pagination, Table } from 'antd';
|
|
25
25
|
import { cloneDeep, isEmpty, isEqual } from 'lodash-es';
|
|
26
26
|
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
27
|
+
var renderEmpty = function renderEmpty(componentName) {
|
|
28
|
+
if (componentName === 'Table' /** 👈 5.20.0+ */) {
|
|
29
|
+
return /*#__PURE__*/React.createElement(Empty, {
|
|
30
|
+
image: Empty.PRESENTED_IMAGE_SIMPLE,
|
|
31
|
+
description: "\u6682\u65E0\u6570\u636E"
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
};
|
|
27
35
|
/**
|
|
28
36
|
* Table + formily
|
|
29
37
|
* 基本用法类似 Protable
|
|
30
38
|
* 新功能:
|
|
31
39
|
* 2、toolbar: { title: ReactNode, className: '' }
|
|
32
40
|
* 3、search: { labelWidth: '统一设置搜索字段label宽度' }
|
|
41
|
+
* 4、actionRef: 绑定了内部方法 reload,可以手动更新
|
|
33
42
|
*/
|
|
34
43
|
var ShenduTable = function ShenduTable(props) {
|
|
44
|
+
var _beforeSearch, _beforeSearch2;
|
|
35
45
|
var initSearchKey = props.initSearchKey,
|
|
36
46
|
_props$ignoreSearchPa = props.ignoreSearchParamsKey,
|
|
37
47
|
ignoreSearchParamsKey = _props$ignoreSearchPa === void 0 ? [] : _props$ignoreSearchPa,
|
|
48
|
+
_props$ignoreResetSea = props.ignoreResetSearchField,
|
|
49
|
+
ignoreResetSearchField = _props$ignoreResetSea === void 0 ? [] : _props$ignoreResetSea,
|
|
50
|
+
resetSearchValues = props.resetSearchValues,
|
|
38
51
|
toolbar = props.toolbar,
|
|
39
52
|
columns = props.columns,
|
|
40
53
|
search = props.search,
|
|
@@ -42,24 +55,35 @@ var ShenduTable = function ShenduTable(props) {
|
|
|
42
55
|
className = props.className,
|
|
43
56
|
dataSource = props.dataSource,
|
|
44
57
|
searchComponents = props.searchComponents,
|
|
58
|
+
_props$searchRenderEf = props.searchRenderEffect,
|
|
59
|
+
searchRenderEffect = _props$searchRenderEf === void 0 ? 0 : _props$searchRenderEf,
|
|
60
|
+
_props$pageSizeOption = props.pageSizeOptions,
|
|
61
|
+
pageSizeOptions = _props$pageSizeOption === void 0 ? [10, 20, 50] : _props$pageSizeOption,
|
|
62
|
+
searchParamsKeyLocalFormat = props.searchParamsKeyLocalFormat,
|
|
63
|
+
initSearchValues = props.initSearchValues,
|
|
45
64
|
extra = _objectWithoutProperties(props, _excluded);
|
|
46
65
|
var beforeSearch;
|
|
47
66
|
var sessionSearch;
|
|
48
67
|
if (initSearchKey) {
|
|
49
68
|
sessionSearch = 'SEARCH::' + initSearchKey;
|
|
50
|
-
var str = sessionStorage.getItem(sessionSearch);
|
|
69
|
+
var str = window.sessionStorage.getItem(sessionSearch);
|
|
51
70
|
if (str) {
|
|
52
71
|
beforeSearch = JSON.parse(str);
|
|
53
|
-
|
|
72
|
+
var keys = Object.keys(beforeSearch);
|
|
73
|
+
keys.forEach(function (key) {
|
|
74
|
+
if (searchParamsKeyLocalFormat !== null && searchParamsKeyLocalFormat !== void 0 && searchParamsKeyLocalFormat[key]) {
|
|
75
|
+
beforeSearch[key] = searchParamsKeyLocalFormat[key].get(beforeSearch[key]);
|
|
76
|
+
}
|
|
77
|
+
});
|
|
54
78
|
}
|
|
55
79
|
}
|
|
56
|
-
|
|
57
80
|
var SchemaField = createSchemaField({
|
|
58
81
|
components: _objectSpread({
|
|
59
82
|
FormItem: FormItem,
|
|
60
83
|
FormGrid: FormGrid,
|
|
61
84
|
Input: Input,
|
|
62
85
|
DatePicker: DatePicker,
|
|
86
|
+
DatePickerFormily: DatePickerFormily,
|
|
63
87
|
Select: Select
|
|
64
88
|
}, searchComponents || {})
|
|
65
89
|
});
|
|
@@ -83,13 +107,13 @@ var ShenduTable = function ShenduTable(props) {
|
|
|
83
107
|
size: 'default',
|
|
84
108
|
showSizeChanger: true,
|
|
85
109
|
showQuickJumper: true,
|
|
86
|
-
showTotal: function showTotal() {
|
|
87
|
-
return
|
|
110
|
+
showTotal: function showTotal(v) {
|
|
111
|
+
return "\u5171 ".concat(v, " \u6761\u6570\u636E");
|
|
88
112
|
},
|
|
89
|
-
pageSize: beforeSearch ?
|
|
90
|
-
current: beforeSearch ?
|
|
113
|
+
pageSize: ((_beforeSearch = beforeSearch) === null || _beforeSearch === void 0 ? void 0 : _beforeSearch.pageSize) || 10,
|
|
114
|
+
current: ((_beforeSearch2 = beforeSearch) === null || _beforeSearch2 === void 0 ? void 0 : _beforeSearch2.current) || 1,
|
|
91
115
|
total: 0,
|
|
92
|
-
pageSizeOptions:
|
|
116
|
+
pageSizeOptions: pageSizeOptions
|
|
93
117
|
}),
|
|
94
118
|
_useState10 = _slicedToArray(_useState9, 2),
|
|
95
119
|
pagination = _useState10[0],
|
|
@@ -106,32 +130,53 @@ var ShenduTable = function ShenduTable(props) {
|
|
|
106
130
|
useMemo(function () {
|
|
107
131
|
var initialValues = {};
|
|
108
132
|
if (beforeSearch) {
|
|
109
|
-
initialValues =
|
|
133
|
+
initialValues = beforeSearch;
|
|
110
134
|
}
|
|
135
|
+
initialValues = _objectSpread(_objectSpread({}, initialValues), initSearchValues || {});
|
|
111
136
|
setForm(createForm({
|
|
112
137
|
validateFirst: true,
|
|
113
138
|
values: initialValues
|
|
114
139
|
}));
|
|
115
140
|
}, []);
|
|
116
|
-
var reset = function reset() {
|
|
141
|
+
var reset = function reset(params) {
|
|
142
|
+
var _ref = params || {},
|
|
143
|
+
isRequest = _ref.isRequest;
|
|
117
144
|
deleteSearch();
|
|
118
|
-
|
|
145
|
+
if ((ignoreResetSearchField === null || ignoreResetSearchField === void 0 ? void 0 : ignoreResetSearchField.length) > 0) {
|
|
146
|
+
var resetKey = [];
|
|
147
|
+
Object.keys(form.values || {}).forEach(function (key) {
|
|
148
|
+
if (!ignoreResetSearchField.includes(key)) {
|
|
149
|
+
resetKey.push(key);
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
form.deleteValuesIn(resetKey);
|
|
153
|
+
} else if (resetSearchValues) {
|
|
154
|
+
var resetVal = {};
|
|
155
|
+
Object.keys(form.values || {}).forEach(function (key) {
|
|
156
|
+
resetVal[key] = null;
|
|
157
|
+
});
|
|
158
|
+
var newVal = _objectSpread(_objectSpread({}, resetVal || {}), resetSearchValues);
|
|
159
|
+
form.setValues(newVal);
|
|
160
|
+
} else {
|
|
161
|
+
form.reset();
|
|
162
|
+
}
|
|
119
163
|
resetPagination();
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
164
|
+
if (isRequest !== false) {
|
|
165
|
+
request({
|
|
166
|
+
current: 1
|
|
167
|
+
}, true, true);
|
|
168
|
+
}
|
|
123
169
|
};
|
|
124
|
-
var RenderActions = function RenderActions() {
|
|
170
|
+
var RenderActions = function RenderActions(props) {
|
|
125
171
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Submit, {
|
|
126
172
|
onSubmit: onAutoSubmit,
|
|
127
|
-
type: "primary",
|
|
128
|
-
ghost: true
|
|
129
|
-
// loading={props.loading}
|
|
130
|
-
,
|
|
131
173
|
style: {
|
|
132
174
|
marginRight: 10
|
|
133
|
-
}
|
|
134
|
-
|
|
175
|
+
},
|
|
176
|
+
type: "primary",
|
|
177
|
+
ghost: true,
|
|
178
|
+
loading: props.loading
|
|
179
|
+
}, "\u67E5\u8BE2"), /*#__PURE__*/React.createElement(Button, {
|
|
135
180
|
onClick: reset
|
|
136
181
|
}, "\u91CD\u7F6E"));
|
|
137
182
|
};
|
|
@@ -162,8 +207,8 @@ var ShenduTable = function ShenduTable(props) {
|
|
|
162
207
|
'x-component': 'FormGrid',
|
|
163
208
|
'x-component-props': {
|
|
164
209
|
columnGap: 32,
|
|
165
|
-
maxColumns:
|
|
166
|
-
minColumns:
|
|
210
|
+
maxColumns: 4,
|
|
211
|
+
minColumns: 4
|
|
167
212
|
},
|
|
168
213
|
properties: {}
|
|
169
214
|
}
|
|
@@ -175,12 +220,12 @@ var ShenduTable = function ShenduTable(props) {
|
|
|
175
220
|
}).forEach(function (field) {
|
|
176
221
|
if (field.searchConfig) {
|
|
177
222
|
var _field$searchConfig;
|
|
178
|
-
var
|
|
179
|
-
title =
|
|
180
|
-
labelWidth =
|
|
181
|
-
searchKey =
|
|
182
|
-
component =
|
|
183
|
-
_props =
|
|
223
|
+
var _ref2 = field.searchConfig || {},
|
|
224
|
+
title = _ref2.title,
|
|
225
|
+
labelWidth = _ref2.labelWidth,
|
|
226
|
+
searchKey = _ref2.searchKey,
|
|
227
|
+
component = _ref2.component,
|
|
228
|
+
_props = _ref2.props;
|
|
184
229
|
var searchLabelWidth = search ? search.labelWidth : '';
|
|
185
230
|
var componentProps = _objectSpread({}, _props);
|
|
186
231
|
if (component) {
|
|
@@ -224,37 +269,59 @@ var ShenduTable = function ShenduTable(props) {
|
|
|
224
269
|
};
|
|
225
270
|
setSchema(schemaObj);
|
|
226
271
|
};
|
|
272
|
+
useEffect(function () {
|
|
273
|
+
if (searchRenderEffect > 0) {
|
|
274
|
+
initSchema();
|
|
275
|
+
}
|
|
276
|
+
}, [searchRenderEffect]);
|
|
227
277
|
var handleColumns = function handleColumns() {
|
|
228
278
|
return cloneDeep(columns).filter(function (column) {
|
|
229
279
|
return column.hideInTable !== true;
|
|
230
280
|
});
|
|
231
281
|
};
|
|
232
|
-
var onAutoSubmit = function
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
282
|
+
var onAutoSubmit = /*#__PURE__*/function () {
|
|
283
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(searchInfo) {
|
|
284
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
285
|
+
while (1) switch (_context.prev = _context.next) {
|
|
286
|
+
case 0:
|
|
287
|
+
resetPagination();
|
|
288
|
+
request(_objectSpread(_objectSpread({}, searchInfo), {}, {
|
|
289
|
+
current: 1
|
|
290
|
+
}), true);
|
|
291
|
+
case 2:
|
|
292
|
+
case "end":
|
|
293
|
+
return _context.stop();
|
|
294
|
+
}
|
|
295
|
+
}, _callee);
|
|
296
|
+
}));
|
|
297
|
+
return function onAutoSubmit(_x2) {
|
|
298
|
+
return _ref3.apply(this, arguments);
|
|
299
|
+
};
|
|
300
|
+
}();
|
|
238
301
|
|
|
239
302
|
// 保存搜索条件
|
|
240
303
|
var saveSearch = function saveSearch() {
|
|
241
304
|
var req = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
242
305
|
req = _objectSpread({}, req);
|
|
243
306
|
if (initSearchKey) {
|
|
244
|
-
var
|
|
245
|
-
|
|
307
|
+
var _keys = Object.keys(req);
|
|
308
|
+
_keys.forEach(function (key) {
|
|
246
309
|
if (ignoreSearchParamsKey.includes(key)) {
|
|
247
310
|
delete req[key];
|
|
311
|
+
return;
|
|
312
|
+
}
|
|
313
|
+
if (searchParamsKeyLocalFormat !== null && searchParamsKeyLocalFormat !== void 0 && searchParamsKeyLocalFormat[key]) {
|
|
314
|
+
req[key] = searchParamsKeyLocalFormat[key].set(req[key]);
|
|
248
315
|
}
|
|
249
316
|
});
|
|
250
|
-
sessionStorage.setItem(sessionSearch, JSON.stringify(req));
|
|
317
|
+
window.sessionStorage.setItem(sessionSearch, JSON.stringify(req));
|
|
251
318
|
}
|
|
252
319
|
};
|
|
253
320
|
|
|
254
321
|
// 删除搜索条件
|
|
255
322
|
var deleteSearch = function deleteSearch() {
|
|
256
323
|
if (initSearchKey) {
|
|
257
|
-
sessionStorage.removeItem(sessionSearch);
|
|
324
|
+
window.sessionStorage.removeItem(sessionSearch);
|
|
258
325
|
}
|
|
259
326
|
};
|
|
260
327
|
var resetPagination = function resetPagination() {
|
|
@@ -263,51 +330,54 @@ var ShenduTable = function ShenduTable(props) {
|
|
|
263
330
|
}));
|
|
264
331
|
};
|
|
265
332
|
var request = /*#__PURE__*/function () {
|
|
266
|
-
var
|
|
333
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(reqParams) {
|
|
334
|
+
var _reqDataRef$current$p, _reqDataRef$current$p2, _props$onSearch;
|
|
267
335
|
var flag,
|
|
268
336
|
isReset,
|
|
269
337
|
searchValue,
|
|
338
|
+
req,
|
|
270
339
|
result,
|
|
271
|
-
|
|
272
|
-
return _regeneratorRuntime().wrap(function
|
|
273
|
-
while (1) switch (
|
|
340
|
+
_args2 = arguments;
|
|
341
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
342
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
274
343
|
case 0:
|
|
275
|
-
flag =
|
|
276
|
-
isReset =
|
|
344
|
+
flag = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : false;
|
|
345
|
+
isReset = _args2.length > 2 && _args2[2] !== undefined ? _args2[2] : false;
|
|
346
|
+
// return
|
|
277
347
|
searchValue = form.values;
|
|
278
348
|
req = _objectSpread(_objectSpread(_objectSpread({}, reqDataRef.current.params || {}), searchValue), {}, {
|
|
279
|
-
pageSize: reqDataRef.current.pagination.pageSize,
|
|
280
|
-
current: reqDataRef.current.pagination.current
|
|
281
|
-
},
|
|
282
|
-
// 去除为空内容
|
|
349
|
+
pageSize: (_reqDataRef$current$p = reqDataRef.current.pagination) === null || _reqDataRef$current$p === void 0 ? void 0 : _reqDataRef$current$p.pageSize,
|
|
350
|
+
current: (_reqDataRef$current$p2 = reqDataRef.current.pagination) === null || _reqDataRef$current$p2 === void 0 ? void 0 : _reqDataRef$current$p2.current
|
|
351
|
+
}, reqParams); // 去除为空内容
|
|
283
352
|
Object.keys(req).forEach(function (key) {
|
|
284
353
|
if (!req[key] && req[key] !== 0) delete req[key];
|
|
285
354
|
});
|
|
286
355
|
setLoading(true);
|
|
287
356
|
!isReset && flag && saveSearch(req);
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
357
|
+
(_props$onSearch = props.onSearch) === null || _props$onSearch === void 0 ? void 0 : _props$onSearch.call(props, req);
|
|
358
|
+
_context2.prev = 8;
|
|
359
|
+
_context2.t1 = props.request;
|
|
360
|
+
if (!_context2.t1) {
|
|
361
|
+
_context2.next = 14;
|
|
292
362
|
break;
|
|
293
363
|
}
|
|
294
|
-
|
|
364
|
+
_context2.next = 13;
|
|
295
365
|
return props.request(req);
|
|
296
|
-
case 12:
|
|
297
|
-
_context.t1 = _context.sent;
|
|
298
366
|
case 13:
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
367
|
+
_context2.t1 = _context2.sent;
|
|
368
|
+
case 14:
|
|
369
|
+
_context2.t0 = _context2.t1;
|
|
370
|
+
if (_context2.t0) {
|
|
371
|
+
_context2.next = 17;
|
|
302
372
|
break;
|
|
303
373
|
}
|
|
304
|
-
|
|
374
|
+
_context2.t0 = {
|
|
305
375
|
data: [],
|
|
306
376
|
total: 0,
|
|
307
377
|
success: true
|
|
308
378
|
};
|
|
309
|
-
case
|
|
310
|
-
result =
|
|
379
|
+
case 17:
|
|
380
|
+
result = _context2.t0;
|
|
311
381
|
if (result.success) {
|
|
312
382
|
// 外部不传 dataSource 时,table 内部更新数据
|
|
313
383
|
if (!dataSource && Array.isArray(result.data)) {
|
|
@@ -319,30 +389,41 @@ var ShenduTable = function ShenduTable(props) {
|
|
|
319
389
|
});
|
|
320
390
|
}
|
|
321
391
|
setLoading(false);
|
|
322
|
-
|
|
392
|
+
_context2.next = 27;
|
|
323
393
|
break;
|
|
324
|
-
case
|
|
325
|
-
|
|
326
|
-
|
|
394
|
+
case 22:
|
|
395
|
+
_context2.prev = 22;
|
|
396
|
+
_context2.t2 = _context2["catch"](8);
|
|
397
|
+
if (!dataSource) {
|
|
398
|
+
setTableDataSource([]);
|
|
399
|
+
}
|
|
400
|
+
setPagination(function (pagination) {
|
|
401
|
+
pagination.total = 0;
|
|
402
|
+
return pagination;
|
|
403
|
+
});
|
|
327
404
|
setLoading(false);
|
|
328
|
-
case
|
|
405
|
+
case 27:
|
|
329
406
|
case "end":
|
|
330
|
-
return
|
|
407
|
+
return _context2.stop();
|
|
331
408
|
}
|
|
332
|
-
},
|
|
409
|
+
}, _callee2, null, [[8, 22]]);
|
|
333
410
|
}));
|
|
334
|
-
return function request(
|
|
335
|
-
return
|
|
411
|
+
return function request(_x3) {
|
|
412
|
+
return _ref4.apply(this, arguments);
|
|
336
413
|
};
|
|
337
414
|
}();
|
|
338
415
|
var handlePaginationChange = function handlePaginationChange(page, pageSize) {
|
|
339
|
-
if (pageSize !== pagination.pageSize) {
|
|
416
|
+
if (pageSize !== (pagination === null || pagination === void 0 ? void 0 : pagination.pageSize)) {
|
|
340
417
|
page = 1;
|
|
341
418
|
}
|
|
342
419
|
setPagination(_objectSpread(_objectSpread({}, pagination), {}, {
|
|
343
420
|
current: page,
|
|
344
421
|
pageSize: pageSize
|
|
345
422
|
}));
|
|
423
|
+
reqDataRef.current.pagination = _objectSpread(_objectSpread({}, pagination), {}, {
|
|
424
|
+
current: page,
|
|
425
|
+
pageSize: pageSize
|
|
426
|
+
});
|
|
346
427
|
var searchValue = form.values;
|
|
347
428
|
request(Object.assign({}, searchValue, {
|
|
348
429
|
pageSize: pageSize,
|
|
@@ -352,12 +433,12 @@ var ShenduTable = function ShenduTable(props) {
|
|
|
352
433
|
|
|
353
434
|
// 缓存优化 防止重复渲染
|
|
354
435
|
var renderSearchForm = useCallback(function () {
|
|
355
|
-
return isEmpty(schema) || isEmpty(form) ? null : /*#__PURE__*/React.createElement(
|
|
436
|
+
return isEmpty(schema) || isEmpty(form) ? null : /*#__PURE__*/React.createElement(Form, {
|
|
356
437
|
form: form,
|
|
357
438
|
onAutoSubmit: onAutoSubmit
|
|
358
439
|
}, /*#__PURE__*/React.createElement(SchemaField, {
|
|
359
440
|
schema: schema
|
|
360
|
-
}))
|
|
441
|
+
}));
|
|
361
442
|
}, [schema, form]);
|
|
362
443
|
useEffect(function () {
|
|
363
444
|
reqDataRef.current = {
|
|
@@ -366,12 +447,17 @@ var ShenduTable = function ShenduTable(props) {
|
|
|
366
447
|
};
|
|
367
448
|
}, [pagination, params]);
|
|
368
449
|
useEffect(function () {
|
|
450
|
+
// setTimeout 处理外部设置 pagination 时,由于异步更新数据问题,导致 request 调用拿不到最新的 pagination
|
|
369
451
|
if (params && !isEqual(params, parmasData)) {
|
|
370
452
|
setParmasData(params);
|
|
371
|
-
|
|
453
|
+
setTimeout(function () {
|
|
454
|
+
return request(params, true);
|
|
455
|
+
}, 100);
|
|
372
456
|
return;
|
|
373
457
|
}
|
|
374
|
-
if (!params)
|
|
458
|
+
if (!params) setTimeout(function () {
|
|
459
|
+
return request({});
|
|
460
|
+
}, 100);
|
|
375
461
|
}, [params]);
|
|
376
462
|
useEffect(function () {
|
|
377
463
|
// 优化渲染, 外部传 {} 会导致每次都渲染,在此做个比较阻止重复渲染
|
|
@@ -381,6 +467,10 @@ var ShenduTable = function ShenduTable(props) {
|
|
|
381
467
|
}
|
|
382
468
|
}, [search]);
|
|
383
469
|
useEffect(function () {
|
|
470
|
+
reqDataRef.current = {
|
|
471
|
+
pagination: pagination,
|
|
472
|
+
params: params
|
|
473
|
+
};
|
|
384
474
|
setPagination(Object.assign(pagination, props.pagination || {}));
|
|
385
475
|
}, [props.pagination]);
|
|
386
476
|
useEffect(function () {
|
|
@@ -402,24 +492,39 @@ var ShenduTable = function ShenduTable(props) {
|
|
|
402
492
|
return null;
|
|
403
493
|
}
|
|
404
494
|
return /*#__PURE__*/React.createElement("div", {
|
|
405
|
-
className: "".concat(className)
|
|
495
|
+
className: "".concat(className, " table-search-form")
|
|
406
496
|
}, renderSearchForm(), toolbar !== null && toolbar !== void 0 && toolbar.title ? /*#__PURE__*/React.createElement("div", {
|
|
407
|
-
className: "
|
|
408
|
-
|
|
497
|
+
className: "".concat(toolbar === null || toolbar === void 0 ? void 0 : toolbar.className),
|
|
498
|
+
style: {
|
|
499
|
+
marginBottom: 16
|
|
500
|
+
}
|
|
501
|
+
}, toolbar === null || toolbar === void 0 ? void 0 : toolbar.title) : null, /*#__PURE__*/React.createElement(ConfigProvider, {
|
|
502
|
+
renderEmpty: renderEmpty
|
|
503
|
+
}, /*#__PURE__*/React.createElement(Table, _extends({
|
|
409
504
|
columns: handleColumns(),
|
|
410
505
|
dataSource: tableDataSource,
|
|
411
506
|
loading: loading
|
|
412
507
|
}, extra, {
|
|
413
|
-
pagination: false
|
|
414
|
-
|
|
508
|
+
pagination: false,
|
|
509
|
+
style: {
|
|
510
|
+
borderRadius: 100
|
|
511
|
+
}
|
|
512
|
+
}))), props.pagination !== false && Number(pagination.total) > 10 ? /*#__PURE__*/React.createElement("div", {
|
|
513
|
+
style: {
|
|
514
|
+
display: 'flex',
|
|
515
|
+
justifyContent: 'flex-end'
|
|
516
|
+
}
|
|
517
|
+
}, /*#__PURE__*/React.createElement(Pagination, _extends({
|
|
415
518
|
style: {
|
|
416
|
-
|
|
417
|
-
|
|
519
|
+
paddingTop: 16,
|
|
520
|
+
paddingBottom: 16
|
|
418
521
|
}
|
|
419
522
|
}, pagination, {
|
|
420
523
|
onChange: handlePaginationChange
|
|
421
|
-
})) : /*#__PURE__*/React.createElement("div", {
|
|
524
|
+
}))) : /*#__PURE__*/React.createElement("div", {
|
|
525
|
+
className: "footer-block",
|
|
422
526
|
style: {
|
|
527
|
+
display: props.hiddenFooterBlock ? 'none' : 'block',
|
|
423
528
|
height: 54
|
|
424
529
|
}
|
|
425
530
|
}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deepinnet-components/pc",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.8",
|
|
4
4
|
"description": "A react library developed with dumi",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -44,10 +44,10 @@
|
|
|
44
44
|
]
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@formily/antd-v5": "^1.
|
|
48
|
-
"@formily/core": "^2.2
|
|
49
|
-
"@formily/react": "^2.2
|
|
50
|
-
"antd": "^5.
|
|
47
|
+
"@formily/antd-v5": "^1.2.3",
|
|
48
|
+
"@formily/core": "^2.3.2",
|
|
49
|
+
"@formily/react": "^2.3.2",
|
|
50
|
+
"antd": "^5.16.1",
|
|
51
51
|
"axios": "^1.5.1",
|
|
52
52
|
"lodash-es": "^4.17.21"
|
|
53
53
|
},
|