@deepinnet-components/pc 0.0.1 → 0.0.3
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/AddressSelect/demo/basic.d.ts +3 -0
- package/dist/AddressSelect/demo/basic.js +9 -0
- package/dist/AddressSelect/demo/format.d.ts +3 -0
- package/dist/AddressSelect/demo/format.js +25 -0
- package/dist/AddressSelect/demo/level.d.ts +3 -0
- package/dist/AddressSelect/demo/level.js +34 -0
- package/dist/AddressSelect/demo/value.d.ts +3 -0
- package/dist/AddressSelect/demo/value.js +24 -0
- package/dist/AddressSelect/index.d.ts +52 -0
- package/dist/AddressSelect/index.js +272 -0
- package/dist/Table/demo/actionRef.d.ts +7 -0
- package/dist/Table/demo/actionRef.js +85 -0
- package/dist/Table/demo/basic.d.ts +7 -0
- package/dist/Table/demo/basic.js +42 -0
- package/dist/Table/demo/request.d.ts +7 -0
- package/dist/Table/demo/request.js +84 -0
- package/dist/Table/demo/search.d.ts +3 -0
- package/dist/Table/demo/search.js +117 -0
- package/dist/Table/index.d.ts +50 -0
- package/dist/Table/index.js +16 -6
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -0
- package/package.json +2 -1
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { AddressSelect } from "../..";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
var Basic = function Basic() {
|
|
4
|
+
return /*#__PURE__*/React.createElement(AddressSelect, {
|
|
5
|
+
placeholder: "\u8BF7\u9009\u62E9\u5730\u5740",
|
|
6
|
+
apiUrl: "http://192.168.3.200:40056/tpcommon/dictionary/item/get"
|
|
7
|
+
});
|
|
8
|
+
};
|
|
9
|
+
export default Basic;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
|
+
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."); }
|
|
3
|
+
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); }
|
|
4
|
+
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; }
|
|
5
|
+
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
6
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
|
+
import { AddressSelect } from "../..";
|
|
8
|
+
import React, { useState } from 'react';
|
|
9
|
+
var Basic = function Basic() {
|
|
10
|
+
var _useState = useState('110000_110100_110101'),
|
|
11
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
12
|
+
value = _useState2[0],
|
|
13
|
+
setValue = _useState2[1];
|
|
14
|
+
var onChange = function onChange(value) {
|
|
15
|
+
setValue(value);
|
|
16
|
+
};
|
|
17
|
+
return /*#__PURE__*/React.createElement(AddressSelect, {
|
|
18
|
+
value: value,
|
|
19
|
+
onChange: onChange,
|
|
20
|
+
placeholder: "\u8BF7\u9009\u62E9\u5730\u5740",
|
|
21
|
+
apiUrl: "http://192.168.3.200:40056/tpcommon/dictionary/item/get",
|
|
22
|
+
valueDivision: "_"
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
export default Basic;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { AddressSelect } from "../..";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
var Basic = function Basic() {
|
|
4
|
+
return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("h3", null, "\u4E00\u7EA7\u5730\u5740"), /*#__PURE__*/React.createElement(AddressSelect, {
|
|
5
|
+
placeholder: "\u8BF7\u9009\u62E9\u5730\u5740",
|
|
6
|
+
level: 1,
|
|
7
|
+
apiUrl: "http://192.168.3.200:40056/tpcommon/dictionary/item/get"
|
|
8
|
+
}), /*#__PURE__*/React.createElement("h3", {
|
|
9
|
+
style: {
|
|
10
|
+
marginTop: 10
|
|
11
|
+
}
|
|
12
|
+
}, "\u4E8C\u7EA7\u5730\u5740"), /*#__PURE__*/React.createElement(AddressSelect, {
|
|
13
|
+
placeholder: "\u8BF7\u9009\u62E9\u5730\u5740",
|
|
14
|
+
level: 2,
|
|
15
|
+
apiUrl: "http://192.168.3.200:40056/tpcommon/dictionary/item/get"
|
|
16
|
+
}), /*#__PURE__*/React.createElement("h3", {
|
|
17
|
+
style: {
|
|
18
|
+
marginTop: 10
|
|
19
|
+
}
|
|
20
|
+
}, "\u4E09\u7EA7\u5730\u5740 \u9ED8\u8BA4\u4E09\u7EA7\u53EF\u4E0D\u4F20"), /*#__PURE__*/React.createElement(AddressSelect, {
|
|
21
|
+
placeholder: "\u8BF7\u9009\u62E9\u5730\u5740",
|
|
22
|
+
level: 3,
|
|
23
|
+
apiUrl: "http://192.168.3.200:40056/tpcommon/dictionary/item/get"
|
|
24
|
+
}), /*#__PURE__*/React.createElement("h3", {
|
|
25
|
+
style: {
|
|
26
|
+
marginTop: 10
|
|
27
|
+
}
|
|
28
|
+
}, "\u56DB\u7EA7\u5730\u5740"), /*#__PURE__*/React.createElement(AddressSelect, {
|
|
29
|
+
placeholder: "\u8BF7\u9009\u62E9\u5730\u5740",
|
|
30
|
+
level: 4,
|
|
31
|
+
apiUrl: "http://192.168.3.200:40056/tpcommon/dictionary/item/get"
|
|
32
|
+
}));
|
|
33
|
+
};
|
|
34
|
+
export default Basic;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
|
+
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."); }
|
|
3
|
+
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); }
|
|
4
|
+
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; }
|
|
5
|
+
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
6
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
|
+
import { AddressSelect } from "../..";
|
|
8
|
+
import React, { useState } from 'react';
|
|
9
|
+
var Basic = function Basic() {
|
|
10
|
+
var _useState = useState([]),
|
|
11
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
12
|
+
value = _useState2[0],
|
|
13
|
+
setValue = _useState2[1];
|
|
14
|
+
var onChange = function onChange(value) {
|
|
15
|
+
setValue(value);
|
|
16
|
+
};
|
|
17
|
+
return /*#__PURE__*/React.createElement(AddressSelect, {
|
|
18
|
+
value: value,
|
|
19
|
+
onChange: onChange,
|
|
20
|
+
placeholder: "\u8BF7\u9009\u62E9\u5730\u5740",
|
|
21
|
+
apiUrl: "http://192.168.3.200:40056/tpcommon/dictionary/item/get"
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
export default Basic;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { CascaderProps } from 'antd';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
export declare type CascaderValueType = string | (string | number)[];
|
|
4
|
+
export interface CascaderOptionType {
|
|
5
|
+
value?: string | number;
|
|
6
|
+
label?: React.ReactNode;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
isLeaf?: boolean;
|
|
9
|
+
loading?: boolean;
|
|
10
|
+
children?: Array<CascaderOptionType>;
|
|
11
|
+
[key: string]: any;
|
|
12
|
+
}
|
|
13
|
+
export interface addressItem {
|
|
14
|
+
value?: string | number;
|
|
15
|
+
code?: string | number;
|
|
16
|
+
name?: string | number;
|
|
17
|
+
label?: string;
|
|
18
|
+
tree?: string;
|
|
19
|
+
level?: string;
|
|
20
|
+
isLeaf?: boolean;
|
|
21
|
+
children?: addressItem[];
|
|
22
|
+
}
|
|
23
|
+
export interface SelectProps extends Omit<CascaderProps<any>, 'options' | 'value'> {
|
|
24
|
+
/**
|
|
25
|
+
* @description 格式化value
|
|
26
|
+
* @default
|
|
27
|
+
*/
|
|
28
|
+
valueDivision?: string;
|
|
29
|
+
/**
|
|
30
|
+
* @description 接口地址 全地址哦
|
|
31
|
+
* @default
|
|
32
|
+
*/
|
|
33
|
+
apiUrl: string;
|
|
34
|
+
/**
|
|
35
|
+
* @description 地址层级 默认三级
|
|
36
|
+
* @default 3
|
|
37
|
+
*/
|
|
38
|
+
level?: number;
|
|
39
|
+
/**
|
|
40
|
+
* @description 指定选中项
|
|
41
|
+
* @default []
|
|
42
|
+
*/
|
|
43
|
+
value?: CascaderValueType;
|
|
44
|
+
/**
|
|
45
|
+
* @description 可选项数据源
|
|
46
|
+
* @default []
|
|
47
|
+
*/
|
|
48
|
+
options?: CascaderOptionType[];
|
|
49
|
+
onSelectedOptionsChange?: any;
|
|
50
|
+
}
|
|
51
|
+
declare const AddressSelect: React.FC<SelectProps>;
|
|
52
|
+
export default AddressSelect;
|
|
@@ -0,0 +1,272 @@
|
|
|
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 = ["level", "value", "onChange", "valueDivision", "apiUrl", "onSelectedOptionsChange"];
|
|
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
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
5
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
6
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
7
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
8
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return 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; }
|
|
9
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
10
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
11
|
+
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; }
|
|
12
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
13
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
14
|
+
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); } }
|
|
15
|
+
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); }); }; }
|
|
16
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
17
|
+
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."); }
|
|
18
|
+
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); }
|
|
19
|
+
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; }
|
|
20
|
+
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
21
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
22
|
+
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; }
|
|
23
|
+
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; }
|
|
24
|
+
/* eslint-disable */
|
|
25
|
+
|
|
26
|
+
import { Cascader } from 'antd';
|
|
27
|
+
import axios from 'axios';
|
|
28
|
+
import { isArray } from 'lodash-es';
|
|
29
|
+
import React, { useEffect, useState } from 'react';
|
|
30
|
+
var AddressSelect = function AddressSelect(props) {
|
|
31
|
+
var level = props.level,
|
|
32
|
+
value = props.value,
|
|
33
|
+
onChange = props.onChange,
|
|
34
|
+
valueDivision = props.valueDivision,
|
|
35
|
+
apiUrl = props.apiUrl,
|
|
36
|
+
onSelectedOptionsChange = props.onSelectedOptionsChange,
|
|
37
|
+
otherProps = _objectWithoutProperties(props, _excluded);
|
|
38
|
+
var _useState = useState([]),
|
|
39
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
40
|
+
addressList = _useState2[0],
|
|
41
|
+
setAddressList = _useState2[1];
|
|
42
|
+
var _useState3 = useState(false),
|
|
43
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
44
|
+
isLoad = _useState4[0],
|
|
45
|
+
setIsLoad = _useState4[1];
|
|
46
|
+
var _useState5 = useState([]),
|
|
47
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
48
|
+
stateValue = _useState6[0],
|
|
49
|
+
setStateValue = _useState6[1];
|
|
50
|
+
useEffect(function () {
|
|
51
|
+
if (!value || !(value !== null && value !== void 0 && value.length)) {
|
|
52
|
+
initAddress(formatValue(props.defaultValue || ''), 0);
|
|
53
|
+
setStateValue(props.defaultValue || '');
|
|
54
|
+
} else {
|
|
55
|
+
setStateValue([]);
|
|
56
|
+
}
|
|
57
|
+
}, []);
|
|
58
|
+
useEffect(function () {
|
|
59
|
+
if (!isLoad || level) {
|
|
60
|
+
initAddress(formatValue(value), 0);
|
|
61
|
+
setStateValue(formatValue(value));
|
|
62
|
+
} else {
|
|
63
|
+
setStateValue([]);
|
|
64
|
+
}
|
|
65
|
+
}, [value, level]);
|
|
66
|
+
var formatValue = function formatValue(value) {
|
|
67
|
+
var localvalue = [];
|
|
68
|
+
if (value) {
|
|
69
|
+
if (!!valueDivision && !isArray(value)) {
|
|
70
|
+
localvalue = value.split(valueDivision);
|
|
71
|
+
} else {
|
|
72
|
+
localvalue = value;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
if (isArray(localvalue)) {
|
|
76
|
+
var _localvalue;
|
|
77
|
+
localvalue = (_localvalue = localvalue) === null || _localvalue === void 0 ? void 0 : _localvalue.map(function (item) {
|
|
78
|
+
return item;
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
return localvalue;
|
|
82
|
+
};
|
|
83
|
+
var formatArea = function formatArea(list, isLeaf) {
|
|
84
|
+
return list === null || list === void 0 ? void 0 : list.map(function (item) {
|
|
85
|
+
return {
|
|
86
|
+
value: item.code,
|
|
87
|
+
label: item.name,
|
|
88
|
+
// tree: item.tree,
|
|
89
|
+
level: item.level,
|
|
90
|
+
isLeaf: isLeaf
|
|
91
|
+
};
|
|
92
|
+
});
|
|
93
|
+
};
|
|
94
|
+
var getAddressAPI = /*#__PURE__*/function () {
|
|
95
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
96
|
+
var params,
|
|
97
|
+
res,
|
|
98
|
+
_res$data,
|
|
99
|
+
_res$data$data,
|
|
100
|
+
_args = arguments;
|
|
101
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
102
|
+
while (1) switch (_context.prev = _context.next) {
|
|
103
|
+
case 0:
|
|
104
|
+
params = _args.length > 0 && _args[0] !== undefined ? _args[0] : {};
|
|
105
|
+
_context.next = 3;
|
|
106
|
+
return axios.post(apiUrl, _objectSpread(_objectSpread({}, params), {}, {
|
|
107
|
+
type: 'address'
|
|
108
|
+
}));
|
|
109
|
+
case 3:
|
|
110
|
+
res = _context.sent;
|
|
111
|
+
if (!((res === null || res === void 0 ? void 0 : res.status) === 200)) {
|
|
112
|
+
_context.next = 6;
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
115
|
+
return _context.abrupt("return", res === null || res === void 0 ? void 0 : (_res$data = res.data) === null || _res$data === void 0 ? void 0 : (_res$data$data = _res$data.data) === null || _res$data$data === void 0 ? void 0 : _res$data$data.items);
|
|
116
|
+
case 6:
|
|
117
|
+
case "end":
|
|
118
|
+
return _context.stop();
|
|
119
|
+
}
|
|
120
|
+
}, _callee);
|
|
121
|
+
}));
|
|
122
|
+
return function getAddressAPI() {
|
|
123
|
+
return _ref.apply(this, arguments);
|
|
124
|
+
};
|
|
125
|
+
}();
|
|
126
|
+
var initAddress = /*#__PURE__*/function () {
|
|
127
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(defaultValue, parentCode) {
|
|
128
|
+
var data, provinceList, len, thisAddress, _loop, i;
|
|
129
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context3) {
|
|
130
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
131
|
+
case 0:
|
|
132
|
+
_context3.next = 2;
|
|
133
|
+
return getAddressAPI({});
|
|
134
|
+
case 2:
|
|
135
|
+
data = _context3.sent;
|
|
136
|
+
provinceList = formatArea(data, level === 1);
|
|
137
|
+
if (!defaultValue) {
|
|
138
|
+
_context3.next = 14;
|
|
139
|
+
break;
|
|
140
|
+
}
|
|
141
|
+
len = defaultValue === null || defaultValue === void 0 ? void 0 : defaultValue.length;
|
|
142
|
+
thisAddress = provinceList;
|
|
143
|
+
_loop = /*#__PURE__*/_regeneratorRuntime().mark(function _loop(i) {
|
|
144
|
+
var _thisAddress;
|
|
145
|
+
var levelData, thisIndex;
|
|
146
|
+
return _regeneratorRuntime().wrap(function _loop$(_context2) {
|
|
147
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
148
|
+
case 0:
|
|
149
|
+
_context2.next = 2;
|
|
150
|
+
return getAddressAPI({
|
|
151
|
+
code: defaultValue[i]
|
|
152
|
+
});
|
|
153
|
+
case 2:
|
|
154
|
+
levelData = _context2.sent;
|
|
155
|
+
thisIndex = -1;
|
|
156
|
+
(_thisAddress = thisAddress) === null || _thisAddress === void 0 ? void 0 : _thisAddress.forEach(function (item, index) {
|
|
157
|
+
if (item.value === defaultValue[i]) {
|
|
158
|
+
thisIndex = index;
|
|
159
|
+
thisAddress[index].children = formatArea(levelData, level === i + 2);
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
if (thisIndex !== -1 && thisAddress[thisIndex].children) {
|
|
163
|
+
thisAddress = thisAddress[thisIndex].children;
|
|
164
|
+
}
|
|
165
|
+
case 6:
|
|
166
|
+
case "end":
|
|
167
|
+
return _context2.stop();
|
|
168
|
+
}
|
|
169
|
+
}, _loop);
|
|
170
|
+
});
|
|
171
|
+
i = 0;
|
|
172
|
+
case 9:
|
|
173
|
+
if (!(i < len - 1)) {
|
|
174
|
+
_context3.next = 14;
|
|
175
|
+
break;
|
|
176
|
+
}
|
|
177
|
+
return _context3.delegateYield(_loop(i), "t0", 11);
|
|
178
|
+
case 11:
|
|
179
|
+
i++;
|
|
180
|
+
_context3.next = 9;
|
|
181
|
+
break;
|
|
182
|
+
case 14:
|
|
183
|
+
setAddressList(provinceList);
|
|
184
|
+
case 15:
|
|
185
|
+
case "end":
|
|
186
|
+
return _context3.stop();
|
|
187
|
+
}
|
|
188
|
+
}, _callee2);
|
|
189
|
+
}));
|
|
190
|
+
return function initAddress(_x2, _x3) {
|
|
191
|
+
return _ref2.apply(this, arguments);
|
|
192
|
+
};
|
|
193
|
+
}();
|
|
194
|
+
var loadData = /*#__PURE__*/function () {
|
|
195
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(selectedOptions) {
|
|
196
|
+
var targetOption, data;
|
|
197
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context4) {
|
|
198
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
199
|
+
case 0:
|
|
200
|
+
targetOption = selectedOptions[selectedOptions.length - 1];
|
|
201
|
+
targetOption.loading = true;
|
|
202
|
+
_context4.next = 4;
|
|
203
|
+
return getAddressAPI({
|
|
204
|
+
code: targetOption.value
|
|
205
|
+
});
|
|
206
|
+
case 4:
|
|
207
|
+
data = _context4.sent;
|
|
208
|
+
targetOption.loading = false;
|
|
209
|
+
if (data.length) {
|
|
210
|
+
targetOption.children = formatArea(data, targetOption.level + 1 === level);
|
|
211
|
+
} else {
|
|
212
|
+
targetOption.isLeaf = true;
|
|
213
|
+
}
|
|
214
|
+
setIsLoad(true);
|
|
215
|
+
setAddressList(_toConsumableArray(addressList));
|
|
216
|
+
case 9:
|
|
217
|
+
case "end":
|
|
218
|
+
return _context4.stop();
|
|
219
|
+
}
|
|
220
|
+
}, _callee3);
|
|
221
|
+
}));
|
|
222
|
+
return function loadData(_x4) {
|
|
223
|
+
return _ref3.apply(this, arguments);
|
|
224
|
+
};
|
|
225
|
+
}();
|
|
226
|
+
var handleChange = function handleChange(info, selectedOptions) {
|
|
227
|
+
var cascaderValue = info;
|
|
228
|
+
if (valueDivision) {
|
|
229
|
+
cascaderValue = cascaderValue.join(valueDivision);
|
|
230
|
+
}
|
|
231
|
+
setStateValue(info);
|
|
232
|
+
onChange && onChange(cascaderValue, selectedOptions);
|
|
233
|
+
onSelectedOptionsChange && onSelectedOptionsChange(selectedOptions);
|
|
234
|
+
};
|
|
235
|
+
useEffect(function () {
|
|
236
|
+
if (onSelectedOptionsChange) {
|
|
237
|
+
if ((value === null || value === void 0 ? void 0 : value.length) === 3) {
|
|
238
|
+
var _item1$children, _item2$children;
|
|
239
|
+
var v1 = value[0];
|
|
240
|
+
var v2 = value[1];
|
|
241
|
+
var v3 = value[2];
|
|
242
|
+
var item1 = addressList.find(function (item) {
|
|
243
|
+
return item.value === v1;
|
|
244
|
+
});
|
|
245
|
+
if (!item1 || !((_item1$children = item1.children) !== null && _item1$children !== void 0 && _item1$children.length)) return undefined;
|
|
246
|
+
var item2 = item1.children.find(function (item) {
|
|
247
|
+
return item.value === v2;
|
|
248
|
+
});
|
|
249
|
+
if (!item2 || !((_item2$children = item2.children) !== null && _item2$children !== void 0 && _item2$children.length)) return undefined;
|
|
250
|
+
var item3 = item2.children.find(function (item) {
|
|
251
|
+
return item.value === v3;
|
|
252
|
+
});
|
|
253
|
+
if (!item3) return undefined;
|
|
254
|
+
onSelectedOptionsChange && onSelectedOptionsChange([item1, item2, item3]);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
}, [value, addressList]);
|
|
258
|
+
return /*#__PURE__*/React.createElement(Cascader, _extends({}, otherProps, {
|
|
259
|
+
loadData: loadData,
|
|
260
|
+
options: addressList,
|
|
261
|
+
onChange: handleChange,
|
|
262
|
+
value: formatValue(value).length === 0 ? stateValue : formatValue(value)
|
|
263
|
+
}));
|
|
264
|
+
};
|
|
265
|
+
AddressSelect.defaultProps = {
|
|
266
|
+
level: 3,
|
|
267
|
+
valueDivision: '',
|
|
268
|
+
value: [],
|
|
269
|
+
onChange: function onChange() {},
|
|
270
|
+
apiUrl: ''
|
|
271
|
+
};
|
|
272
|
+
export default AddressSelect;
|
|
@@ -0,0 +1,85 @@
|
|
|
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
|
+
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; }
|
|
3
|
+
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
|
+
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
|
+
/**
|
|
6
|
+
* title: actionRef 用法
|
|
7
|
+
* description: 供外部调用的事件 reload、reloadCurrentPage、reset
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
// import { ShenduTable } from '@deepinnet-components/pc';
|
|
11
|
+
import { Button } from 'antd';
|
|
12
|
+
import React from 'react';
|
|
13
|
+
import ShenduTable from "../index";
|
|
14
|
+
var getDataPromise = function getDataPromise() {
|
|
15
|
+
return new Promise(function (resolve) {
|
|
16
|
+
setTimeout(function () {
|
|
17
|
+
resolve({
|
|
18
|
+
list: [{
|
|
19
|
+
id: 1,
|
|
20
|
+
name: '小白',
|
|
21
|
+
age: '21',
|
|
22
|
+
sex: '女'
|
|
23
|
+
}, {
|
|
24
|
+
id: 2,
|
|
25
|
+
name: '小黑',
|
|
26
|
+
age: '22',
|
|
27
|
+
sex: '男'
|
|
28
|
+
}],
|
|
29
|
+
total: 15
|
|
30
|
+
});
|
|
31
|
+
}, 300);
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
var Demo1 = function Demo1() {
|
|
35
|
+
var columns = [{
|
|
36
|
+
title: '姓名',
|
|
37
|
+
dataIndex: 'name',
|
|
38
|
+
width: 150,
|
|
39
|
+
align: 'left'
|
|
40
|
+
}, {
|
|
41
|
+
title: '年龄',
|
|
42
|
+
dataIndex: 'age',
|
|
43
|
+
width: 150,
|
|
44
|
+
align: 'left'
|
|
45
|
+
}, {
|
|
46
|
+
title: '性别',
|
|
47
|
+
dataIndex: 'sex',
|
|
48
|
+
width: 150,
|
|
49
|
+
align: 'left'
|
|
50
|
+
}];
|
|
51
|
+
return /*#__PURE__*/React.createElement(ShenduTable, {
|
|
52
|
+
request: /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
53
|
+
var data;
|
|
54
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
55
|
+
while (1) switch (_context.prev = _context.next) {
|
|
56
|
+
case 0:
|
|
57
|
+
_context.next = 2;
|
|
58
|
+
return getDataPromise();
|
|
59
|
+
case 2:
|
|
60
|
+
data = _context.sent;
|
|
61
|
+
return _context.abrupt("return", {
|
|
62
|
+
data: data.list,
|
|
63
|
+
success: true,
|
|
64
|
+
total: data.total || 0
|
|
65
|
+
});
|
|
66
|
+
case 4:
|
|
67
|
+
case "end":
|
|
68
|
+
return _context.stop();
|
|
69
|
+
}
|
|
70
|
+
}, _callee);
|
|
71
|
+
})),
|
|
72
|
+
columns: columns,
|
|
73
|
+
rowKey: "id",
|
|
74
|
+
toolbar: {
|
|
75
|
+
title: /*#__PURE__*/React.createElement("div", {
|
|
76
|
+
style: {
|
|
77
|
+
marginBottom: 20
|
|
78
|
+
}
|
|
79
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
80
|
+
type: "primary"
|
|
81
|
+
}, "\u65B0\u589E"))
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
};
|
|
85
|
+
export default Demo1;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* title: 基础用法
|
|
3
|
+
* description: dataSource
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { ShenduTable } from "../..";
|
|
7
|
+
import React from 'react';
|
|
8
|
+
var App = function App() {
|
|
9
|
+
var dataSource = [{
|
|
10
|
+
id: 1,
|
|
11
|
+
name: '小白',
|
|
12
|
+
age: '21',
|
|
13
|
+
sex: '女'
|
|
14
|
+
}, {
|
|
15
|
+
id: 2,
|
|
16
|
+
name: '小黑',
|
|
17
|
+
age: '22',
|
|
18
|
+
sex: '男'
|
|
19
|
+
}];
|
|
20
|
+
var columns = [{
|
|
21
|
+
title: '姓名',
|
|
22
|
+
dataIndex: 'name',
|
|
23
|
+
width: 150,
|
|
24
|
+
align: 'left'
|
|
25
|
+
}, {
|
|
26
|
+
title: '年龄',
|
|
27
|
+
dataIndex: 'age',
|
|
28
|
+
width: 150,
|
|
29
|
+
align: 'left'
|
|
30
|
+
}, {
|
|
31
|
+
title: '性别',
|
|
32
|
+
dataIndex: 'sex',
|
|
33
|
+
width: 150,
|
|
34
|
+
align: 'left'
|
|
35
|
+
}];
|
|
36
|
+
return /*#__PURE__*/React.createElement(ShenduTable, {
|
|
37
|
+
dataSource: dataSource,
|
|
38
|
+
columns: columns,
|
|
39
|
+
rowKey: "id"
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
export default App;
|
|
@@ -0,0 +1,84 @@
|
|
|
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
|
+
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; }
|
|
3
|
+
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
|
+
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
|
+
/**
|
|
6
|
+
* title: request用法
|
|
7
|
+
* description: 从接口获取数据源。
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { ShenduTable } from "../..";
|
|
11
|
+
import { Button } from 'antd';
|
|
12
|
+
import React from 'react';
|
|
13
|
+
var getDataPromise = function getDataPromise() {
|
|
14
|
+
return new Promise(function (resolve) {
|
|
15
|
+
setTimeout(function () {
|
|
16
|
+
resolve({
|
|
17
|
+
list: [{
|
|
18
|
+
id: 1,
|
|
19
|
+
name: '小白',
|
|
20
|
+
age: '21',
|
|
21
|
+
sex: '女'
|
|
22
|
+
}, {
|
|
23
|
+
id: 2,
|
|
24
|
+
name: '小黑',
|
|
25
|
+
age: '22',
|
|
26
|
+
sex: '男'
|
|
27
|
+
}],
|
|
28
|
+
total: 15
|
|
29
|
+
});
|
|
30
|
+
}, 300);
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
var Demo1 = function Demo1() {
|
|
34
|
+
var columns = [{
|
|
35
|
+
title: '姓名',
|
|
36
|
+
dataIndex: 'name',
|
|
37
|
+
width: 150,
|
|
38
|
+
align: 'left'
|
|
39
|
+
}, {
|
|
40
|
+
title: '年龄',
|
|
41
|
+
dataIndex: 'age',
|
|
42
|
+
width: 150,
|
|
43
|
+
align: 'left'
|
|
44
|
+
}, {
|
|
45
|
+
title: '性别',
|
|
46
|
+
dataIndex: 'sex',
|
|
47
|
+
width: 150,
|
|
48
|
+
align: 'left'
|
|
49
|
+
}];
|
|
50
|
+
return /*#__PURE__*/React.createElement(ShenduTable, {
|
|
51
|
+
request: /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
52
|
+
var data;
|
|
53
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
54
|
+
while (1) switch (_context.prev = _context.next) {
|
|
55
|
+
case 0:
|
|
56
|
+
_context.next = 2;
|
|
57
|
+
return getDataPromise();
|
|
58
|
+
case 2:
|
|
59
|
+
data = _context.sent;
|
|
60
|
+
return _context.abrupt("return", {
|
|
61
|
+
data: data.list,
|
|
62
|
+
success: true,
|
|
63
|
+
total: data.total || 0
|
|
64
|
+
});
|
|
65
|
+
case 4:
|
|
66
|
+
case "end":
|
|
67
|
+
return _context.stop();
|
|
68
|
+
}
|
|
69
|
+
}, _callee);
|
|
70
|
+
})),
|
|
71
|
+
columns: columns,
|
|
72
|
+
rowKey: "id",
|
|
73
|
+
toolbar: {
|
|
74
|
+
title: /*#__PURE__*/React.createElement("div", {
|
|
75
|
+
style: {
|
|
76
|
+
marginBottom: 20
|
|
77
|
+
}
|
|
78
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
79
|
+
type: "primary"
|
|
80
|
+
}, "\u65B0\u589E"))
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
};
|
|
84
|
+
export default Demo1;
|
|
@@ -0,0 +1,117 @@
|
|
|
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
|
+
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; }
|
|
3
|
+
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
|
+
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
|
+
/**
|
|
6
|
+
* title: 搜索查询
|
|
7
|
+
* description: searchConfig
|
|
8
|
+
*/
|
|
9
|
+
/* eslint-disable */
|
|
10
|
+
import { ShenduTable } from "../..";
|
|
11
|
+
import { TimePicker } from 'antd';
|
|
12
|
+
import React from 'react';
|
|
13
|
+
var getDataPromise = function getDataPromise() {
|
|
14
|
+
return new Promise(function (resolve) {
|
|
15
|
+
setTimeout(function () {
|
|
16
|
+
resolve({
|
|
17
|
+
list: [{
|
|
18
|
+
id: 1,
|
|
19
|
+
key1: 'x',
|
|
20
|
+
key2: 'xx',
|
|
21
|
+
key3: 'xxx'
|
|
22
|
+
}, {
|
|
23
|
+
id: 2,
|
|
24
|
+
key1: 'x',
|
|
25
|
+
key2: 'xx',
|
|
26
|
+
key3: 'xxx'
|
|
27
|
+
}],
|
|
28
|
+
total: 3
|
|
29
|
+
});
|
|
30
|
+
}, 300);
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
var Index = function Index() {
|
|
34
|
+
var columns = [{
|
|
35
|
+
title: '字段1',
|
|
36
|
+
dataIndex: 'key1',
|
|
37
|
+
width: 100,
|
|
38
|
+
align: 'left',
|
|
39
|
+
searchConfig: {}
|
|
40
|
+
}, {
|
|
41
|
+
title: '字段2',
|
|
42
|
+
dataIndex: 'key2',
|
|
43
|
+
width: 100,
|
|
44
|
+
align: 'left',
|
|
45
|
+
searchConfig: {
|
|
46
|
+
props: {
|
|
47
|
+
placeholder: '请输入',
|
|
48
|
+
allowClear: true
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}, {
|
|
52
|
+
title: '字段3',
|
|
53
|
+
dataIndex: 'key3',
|
|
54
|
+
width: 100,
|
|
55
|
+
align: 'left',
|
|
56
|
+
searchConfig: {
|
|
57
|
+
// 自定义组件
|
|
58
|
+
component: 'Select',
|
|
59
|
+
enum: [{
|
|
60
|
+
label: '待支付',
|
|
61
|
+
value: 1
|
|
62
|
+
}, {
|
|
63
|
+
label: '已支付',
|
|
64
|
+
value: 2
|
|
65
|
+
}]
|
|
66
|
+
}
|
|
67
|
+
}, {
|
|
68
|
+
title: '字段4',
|
|
69
|
+
dataIndex: 'key4',
|
|
70
|
+
width: 100,
|
|
71
|
+
align: 'left',
|
|
72
|
+
searchConfig: {
|
|
73
|
+
component: 'TimePicker',
|
|
74
|
+
searchKey: 'time'
|
|
75
|
+
}
|
|
76
|
+
}];
|
|
77
|
+
return /*#__PURE__*/React.createElement(ShenduTable, {
|
|
78
|
+
search: {
|
|
79
|
+
labelWidth: 'auto'
|
|
80
|
+
},
|
|
81
|
+
searchComponents: {
|
|
82
|
+
TimePicker: TimePicker
|
|
83
|
+
},
|
|
84
|
+
request: /*#__PURE__*/function () {
|
|
85
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(searchInfo) {
|
|
86
|
+
var data;
|
|
87
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
88
|
+
while (1) switch (_context.prev = _context.next) {
|
|
89
|
+
case 0:
|
|
90
|
+
console.log(searchInfo);
|
|
91
|
+
_context.next = 3;
|
|
92
|
+
return getDataPromise();
|
|
93
|
+
case 3:
|
|
94
|
+
data = _context.sent;
|
|
95
|
+
return _context.abrupt("return", {
|
|
96
|
+
data: data.list,
|
|
97
|
+
success: true,
|
|
98
|
+
total: data.total || 0
|
|
99
|
+
});
|
|
100
|
+
case 5:
|
|
101
|
+
case "end":
|
|
102
|
+
return _context.stop();
|
|
103
|
+
}
|
|
104
|
+
}, _callee);
|
|
105
|
+
}));
|
|
106
|
+
return function (_x) {
|
|
107
|
+
return _ref.apply(this, arguments);
|
|
108
|
+
};
|
|
109
|
+
}(),
|
|
110
|
+
columns: columns,
|
|
111
|
+
rowKey: "id",
|
|
112
|
+
scroll: {
|
|
113
|
+
x: 1200
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
};
|
|
117
|
+
export default Index;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { PaginationProps, TableProps } from 'antd';
|
|
2
|
+
import { ColumnType } from 'antd/lib/table';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
interface SearchConfig {
|
|
5
|
+
labelWidth: number | string;
|
|
6
|
+
}
|
|
7
|
+
interface Columns extends ColumnType<any> {
|
|
8
|
+
align?: 'left' | 'right' | 'center' | any;
|
|
9
|
+
hideInTable?: boolean;
|
|
10
|
+
searchConfig?: {
|
|
11
|
+
sort?: number;
|
|
12
|
+
title?: string;
|
|
13
|
+
labelWidth?: number | string;
|
|
14
|
+
searchKey?: string;
|
|
15
|
+
component?: any;
|
|
16
|
+
props?: any;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
declare type RequestData<T> = {
|
|
20
|
+
data: T[] | undefined;
|
|
21
|
+
success?: boolean;
|
|
22
|
+
total?: number;
|
|
23
|
+
} & Record<string, any>;
|
|
24
|
+
interface ShenduTableProps<T> extends Omit<TableProps<T>, 'columns' | 'pagination' | 'align'> {
|
|
25
|
+
searchComponents?: Record<string, any>;
|
|
26
|
+
className?: string;
|
|
27
|
+
params?: Record<string, any>;
|
|
28
|
+
pagination?: PaginationProps | false;
|
|
29
|
+
actionRef?: {
|
|
30
|
+
current: any;
|
|
31
|
+
};
|
|
32
|
+
toolbar?: {
|
|
33
|
+
title?: React.ReactNode;
|
|
34
|
+
className?: string;
|
|
35
|
+
};
|
|
36
|
+
request?: (data: any) => Promise<RequestData<T>>;
|
|
37
|
+
columns: Columns[];
|
|
38
|
+
search?: SearchConfig | false;
|
|
39
|
+
initSearchKey?: string;
|
|
40
|
+
ignoreSearchParamsKey?: string[];
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Table + formily
|
|
44
|
+
* 基本用法类似 Protable
|
|
45
|
+
* 新功能:
|
|
46
|
+
* 2、toolbar: { title: ReactNode, className: '' }
|
|
47
|
+
* 3、search: { labelWidth: '统一设置搜索字段label宽度' }
|
|
48
|
+
*/
|
|
49
|
+
declare const ShenduTable: <T extends Record<string, any>>(props: ShenduTableProps<T>) => React.JSX.Element | null;
|
|
50
|
+
export default ShenduTable;
|
package/dist/Table/index.js
CHANGED
|
@@ -23,15 +23,13 @@ import { createForm } from '@formily/core';
|
|
|
23
23
|
import { createSchemaField } from '@formily/react';
|
|
24
24
|
import { DatePicker, Pagination, Table } from 'antd';
|
|
25
25
|
import { cloneDeep, isEmpty, isEqual } from 'lodash-es';
|
|
26
|
-
import React from 'react';
|
|
27
|
-
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
26
|
+
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
28
27
|
/**
|
|
29
28
|
* Table + formily
|
|
30
29
|
* 基本用法类似 Protable
|
|
31
30
|
* 新功能:
|
|
32
31
|
* 2、toolbar: { title: ReactNode, className: '' }
|
|
33
32
|
* 3、search: { labelWidth: '统一设置搜索字段label宽度' }
|
|
34
|
-
* 4、actionRef: 绑定了内部方法 reload,可以手动更新
|
|
35
33
|
*/
|
|
36
34
|
var ShenduTable = function ShenduTable(props) {
|
|
37
35
|
var initSearchKey = props.initSearchKey,
|
|
@@ -126,10 +124,13 @@ var ShenduTable = function ShenduTable(props) {
|
|
|
126
124
|
var RenderActions = function RenderActions() {
|
|
127
125
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Submit, {
|
|
128
126
|
onSubmit: onAutoSubmit,
|
|
129
|
-
className: "mr-2.5",
|
|
130
127
|
type: "primary",
|
|
131
128
|
ghost: true
|
|
132
129
|
// loading={props.loading}
|
|
130
|
+
,
|
|
131
|
+
style: {
|
|
132
|
+
marginRight: 10
|
|
133
|
+
}
|
|
133
134
|
}, "\u67E5\u8BE2"), /*#__PURE__*/React.createElement(Reset, {
|
|
134
135
|
onClick: reset
|
|
135
136
|
}, "\u91CD\u7F6E"));
|
|
@@ -238,6 +239,7 @@ var ShenduTable = function ShenduTable(props) {
|
|
|
238
239
|
// 保存搜索条件
|
|
239
240
|
var saveSearch = function saveSearch() {
|
|
240
241
|
var req = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
242
|
+
req = _objectSpread({}, req);
|
|
241
243
|
if (initSearchKey) {
|
|
242
244
|
var keys = Object.keys(req);
|
|
243
245
|
keys.forEach(function (key) {
|
|
@@ -393,6 +395,9 @@ var ShenduTable = function ShenduTable(props) {
|
|
|
393
395
|
};
|
|
394
396
|
}
|
|
395
397
|
}, []);
|
|
398
|
+
if (search && isEmpty(schema)) {
|
|
399
|
+
return null;
|
|
400
|
+
}
|
|
396
401
|
return /*#__PURE__*/React.createElement("div", {
|
|
397
402
|
className: "".concat(className)
|
|
398
403
|
}, renderSearchForm(), toolbar !== null && toolbar !== void 0 && toolbar.title ? /*#__PURE__*/React.createElement("div", {
|
|
@@ -404,11 +409,16 @@ var ShenduTable = function ShenduTable(props) {
|
|
|
404
409
|
}, extra, {
|
|
405
410
|
pagination: false
|
|
406
411
|
})), props.pagination !== false && Number(pagination.total) > 10 ? /*#__PURE__*/React.createElement(Pagination, _extends({
|
|
407
|
-
|
|
412
|
+
style: {
|
|
413
|
+
textAlign: 'right',
|
|
414
|
+
padding: '10px 0'
|
|
415
|
+
}
|
|
408
416
|
}, pagination, {
|
|
409
417
|
onChange: handlePaginationChange
|
|
410
418
|
})) : /*#__PURE__*/React.createElement("div", {
|
|
411
|
-
|
|
419
|
+
style: {
|
|
420
|
+
height: 54
|
|
421
|
+
}
|
|
412
422
|
}));
|
|
413
423
|
};
|
|
414
424
|
export default ShenduTable;
|
package/dist/index.d.ts
ADDED
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deepinnet-components/pc",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"description": "A react library developed with dumi",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -48,6 +48,7 @@
|
|
|
48
48
|
"@formily/core": "^2.2.29",
|
|
49
49
|
"@formily/react": "^2.2.29",
|
|
50
50
|
"antd": "^5.8.2",
|
|
51
|
+
"axios": "^1.5.1",
|
|
51
52
|
"lodash-es": "^4.17.21"
|
|
52
53
|
},
|
|
53
54
|
"devDependencies": {
|