@arim-aisdc/public-components 0.0.13 → 0.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/QueryFilter/QueryFilter.d.ts +26 -0
- package/dist/components/QueryFilter/QueryFilter.js +707 -0
- package/dist/components/QueryFilter/index.d.ts +5 -0
- package/dist/components/QueryFilter/index.js +4 -0
- package/dist/components/QueryFilter/index.less +63 -0
- package/dist/components/QueryFilter/type.d.ts +110 -0
- package/dist/components/QueryFilter/type.js +40 -0
- package/dist/components/TableMax/TableHeader/index.less +1 -1
- package/dist/components/TableMax/components/ColumnSort/customSortFns.d.ts +6 -6
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +7 -0
- package/package.json +1 -1
- package/dist/components/Foo/index.d.ts +0 -6
- package/dist/components/Foo/index.js +0 -15
- package/dist/components/Foo/index.less +0 -3
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import './index.less';
|
|
3
|
+
import { CustomFormProps } from './type';
|
|
4
|
+
export declare const typeList: {
|
|
5
|
+
min: string;
|
|
6
|
+
max: string;
|
|
7
|
+
start: string;
|
|
8
|
+
end: string;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* 处理公共动态查询的searchField
|
|
12
|
+
* @param searchField 查询的字段
|
|
13
|
+
* @param dynamicField 动态查询设置的字段
|
|
14
|
+
* @returns
|
|
15
|
+
*/
|
|
16
|
+
export declare function useDynamicSearchFiled(searchField: Array<any>, dynamicField: Array<{
|
|
17
|
+
field: string;
|
|
18
|
+
ApiFun: ({ key, isPage }: {
|
|
19
|
+
key: string;
|
|
20
|
+
isPage: boolean;
|
|
21
|
+
}) => Promise<any>;
|
|
22
|
+
settingHandler: (items: Array<any>) => Array<any>;
|
|
23
|
+
params?: any;
|
|
24
|
+
}>): any[];
|
|
25
|
+
declare const _default: React.NamedExoticComponent<CustomFormProps>;
|
|
26
|
+
export default _default;
|
|
@@ -0,0 +1,707 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
import "antd/es/button/style";
|
|
3
|
+
import _Button from "antd/es/button";
|
|
4
|
+
import "antd/es/checkbox/style";
|
|
5
|
+
import _Checkbox from "antd/es/checkbox";
|
|
6
|
+
import "antd/es/cascader/style";
|
|
7
|
+
import _Cascader from "antd/es/cascader";
|
|
8
|
+
import "antd/es/auto-complete/style";
|
|
9
|
+
import _AutoComplete from "antd/es/auto-complete";
|
|
10
|
+
import "antd/es/radio/style";
|
|
11
|
+
import _Radio from "antd/es/radio";
|
|
12
|
+
import "antd/es/badge/style";
|
|
13
|
+
import _Badge from "antd/es/badge";
|
|
14
|
+
import "antd/es/spin/style";
|
|
15
|
+
import _Spin from "antd/es/spin";
|
|
16
|
+
import "antd/es/switch/style";
|
|
17
|
+
import _Switch from "antd/es/switch";
|
|
18
|
+
import "antd/es/input-number/style";
|
|
19
|
+
import _InputNumber from "antd/es/input-number";
|
|
20
|
+
import "antd/es/input/style";
|
|
21
|
+
import _Input from "antd/es/input";
|
|
22
|
+
import "antd/es/date-picker/style";
|
|
23
|
+
import _DatePicker from "antd/es/date-picker";
|
|
24
|
+
import "antd/es/select/style";
|
|
25
|
+
import _Select from "antd/es/select";
|
|
26
|
+
import "antd/es/form/style";
|
|
27
|
+
import _Form from "antd/es/form";
|
|
28
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
29
|
+
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); } }
|
|
30
|
+
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); }); }; }
|
|
31
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
32
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
33
|
+
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; }
|
|
34
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
35
|
+
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); }
|
|
36
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
37
|
+
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."); }
|
|
38
|
+
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); }
|
|
39
|
+
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; }
|
|
40
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
41
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
42
|
+
import { to } from "../../utils";
|
|
43
|
+
import { MinusOutlined } from '@ant-design/icons';
|
|
44
|
+
import { useDebounceFn } from 'ahooks';
|
|
45
|
+
import TextArea from 'antd/lib/input/TextArea';
|
|
46
|
+
import { debounce } from 'lodash';
|
|
47
|
+
import moment from 'moment';
|
|
48
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
49
|
+
import "./index.less";
|
|
50
|
+
import { FormItemType, TimeFormatType } from "./type";
|
|
51
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
52
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
53
|
+
export var typeList = {
|
|
54
|
+
min: 'min',
|
|
55
|
+
max: 'max',
|
|
56
|
+
start: 'start',
|
|
57
|
+
end: 'end'
|
|
58
|
+
};
|
|
59
|
+
var QueryFilter = function QueryFilter(_ref) {
|
|
60
|
+
var data = _ref.data,
|
|
61
|
+
initialValues = _ref.initialValues,
|
|
62
|
+
_ref$isOkText = _ref.isOkText,
|
|
63
|
+
isOkText = _ref$isOkText === void 0 ? '确定' : _ref$isOkText,
|
|
64
|
+
_ref$cancelText = _ref.cancelText,
|
|
65
|
+
cancelText = _ref$cancelText === void 0 ? '重置' : _ref$cancelText,
|
|
66
|
+
handleSubmit = _ref.handleSubmit,
|
|
67
|
+
handleCancel = _ref.handleCancel,
|
|
68
|
+
_ref$showButton = _ref.showButton,
|
|
69
|
+
showButton = _ref$showButton === void 0 ? true : _ref$showButton,
|
|
70
|
+
handleInputClear = _ref.handleInputClear,
|
|
71
|
+
_ref$submitLoading = _ref.submitLoading,
|
|
72
|
+
submitLoading = _ref$submitLoading === void 0 ? false : _ref$submitLoading,
|
|
73
|
+
_ref$renderButton = _ref.renderButton,
|
|
74
|
+
renderButton = _ref$renderButton === void 0 ? null : _ref$renderButton;
|
|
75
|
+
var _Form$useForm = _Form.useForm(),
|
|
76
|
+
_Form$useForm2 = _slicedToArray(_Form$useForm, 1),
|
|
77
|
+
form = _Form$useForm2[0];
|
|
78
|
+
var Option = _Select.Option;
|
|
79
|
+
var RangePicker = _DatePicker.RangePicker;
|
|
80
|
+
var _useState = useState({}),
|
|
81
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
82
|
+
formValues = _useState2[0],
|
|
83
|
+
setFormValues = _useState2[1];
|
|
84
|
+
var displayRender = function displayRender(labels) {
|
|
85
|
+
return labels[labels.length - 1];
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
// 处理初始值格式问题,主要是日期数据的格式,字符串处理为date格式
|
|
89
|
+
var getHandledInitValues = function getHandledInitValues() {
|
|
90
|
+
var newFormValues = {};
|
|
91
|
+
data.forEach(function (item) {
|
|
92
|
+
if (initialValues && initialValues[item.field]) {
|
|
93
|
+
// 处理特殊数据
|
|
94
|
+
if (item.formType === 'daterang') {
|
|
95
|
+
newFormValues[item.field] = initialValues[item.field].map(function (value) {
|
|
96
|
+
return typeof value === 'string' ? moment(value) : value;
|
|
97
|
+
}) || [];
|
|
98
|
+
} else {
|
|
99
|
+
newFormValues[item.field] = initialValues[item.field];
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
var values = initialValues !== null && initialValues !== void 0 ? initialValues : {};
|
|
104
|
+
var newValues = _objectSpread(_objectSpread({}, values), newFormValues);
|
|
105
|
+
return newValues;
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
/**初始化表单 */
|
|
109
|
+
var FormRef = useRef(null);
|
|
110
|
+
useEffect(function () {
|
|
111
|
+
/**回显异步初始值 */
|
|
112
|
+
// FormRef && FormRef.current && FormRef.current.resetFields();
|
|
113
|
+
var handledInitValues = getHandledInitValues();
|
|
114
|
+
if (FormRef && FormRef.current) {
|
|
115
|
+
FormRef.current.setFieldsValue(handledInitValues);
|
|
116
|
+
}
|
|
117
|
+
// console.log('handledInitValues :>> ', handledInitValues);
|
|
118
|
+
|
|
119
|
+
// 更新表单数据
|
|
120
|
+
setFormValues(handledInitValues);
|
|
121
|
+
}, [initialValues]);
|
|
122
|
+
|
|
123
|
+
// 表单提交时保留数据
|
|
124
|
+
var onFinish = function onFinish(values) {
|
|
125
|
+
handleSubmit({
|
|
126
|
+
data: values
|
|
127
|
+
});
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
/**不显示按钮的时候,change改变 */
|
|
131
|
+
var commonChange = function commonChange(e, item, type) {
|
|
132
|
+
var _formValues$item$fiel, _newFormValue$item$fi, _formValues$item$fiel2, _newFormValue$item$fi2, _formValues$item$fiel3, _newFormValue$item$fi3, _formValues$item$fiel4, _newFormValue$item$fi4;
|
|
133
|
+
// 级联筛选主动抛出
|
|
134
|
+
if (item !== null && item !== void 0 && item.isActiveTrigger) {
|
|
135
|
+
var _item$activeTriggerFu;
|
|
136
|
+
(_item$activeTriggerFu = item.activeTriggerFun) === null || _item$activeTriggerFu === void 0 || _item$activeTriggerFu.call(item, e);
|
|
137
|
+
}
|
|
138
|
+
var newFormValue = {};
|
|
139
|
+
// if (showButton) return;
|
|
140
|
+
switch (type) {
|
|
141
|
+
case typeList.min:
|
|
142
|
+
newFormValue[item.field] = (_newFormValue$item$fi = {}, _defineProperty(_newFormValue$item$fi, typeList.min, e !== null && e !== void 0 && e.target ? e.target.value : e), _defineProperty(_newFormValue$item$fi, typeList.max, ((_formValues$item$fiel = formValues[item.field]) === null || _formValues$item$fiel === void 0 ? void 0 : _formValues$item$fiel[typeList.max]) || null), _newFormValue$item$fi);
|
|
143
|
+
break;
|
|
144
|
+
case typeList.max:
|
|
145
|
+
newFormValue[item.field] = (_newFormValue$item$fi2 = {}, _defineProperty(_newFormValue$item$fi2, typeList.min, ((_formValues$item$fiel2 = formValues[item.field]) === null || _formValues$item$fiel2 === void 0 ? void 0 : _formValues$item$fiel2[typeList.min]) || null), _defineProperty(_newFormValue$item$fi2, typeList.max, e !== null && e !== void 0 && e.target ? e.target.value : e), _newFormValue$item$fi2);
|
|
146
|
+
break;
|
|
147
|
+
case typeList.start:
|
|
148
|
+
newFormValue[item.field] = (_newFormValue$item$fi3 = {}, _defineProperty(_newFormValue$item$fi3, typeList.start, e !== null && e !== void 0 && e.target ? e.target.value : e), _defineProperty(_newFormValue$item$fi3, typeList.end, ((_formValues$item$fiel3 = formValues[item.field]) === null || _formValues$item$fiel3 === void 0 ? void 0 : _formValues$item$fiel3[typeList.end]) || null), _newFormValue$item$fi3);
|
|
149
|
+
break;
|
|
150
|
+
case typeList.end:
|
|
151
|
+
newFormValue[item.field] = (_newFormValue$item$fi4 = {}, _defineProperty(_newFormValue$item$fi4, typeList.start, ((_formValues$item$fiel4 = formValues[item.field]) === null || _formValues$item$fiel4 === void 0 ? void 0 : _formValues$item$fiel4[typeList.start]) || null), _defineProperty(_newFormValue$item$fi4, typeList.end, e !== null && e !== void 0 && e.target ? e.target.value : e), _newFormValue$item$fi4);
|
|
152
|
+
break;
|
|
153
|
+
default:
|
|
154
|
+
newFormValue[item.field] = e !== null && e !== void 0 && e.target ? e.target.value : e;
|
|
155
|
+
break;
|
|
156
|
+
}
|
|
157
|
+
var newValues = Object.assign({}, formValues, newFormValue);
|
|
158
|
+
setFormValues(newValues);
|
|
159
|
+
handleSubmit({
|
|
160
|
+
data: newValues
|
|
161
|
+
}, item, type);
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
/**input输入防抖 */
|
|
165
|
+
var _useDebounceFn = useDebounceFn(function (e, item, valueType) {
|
|
166
|
+
commonChange(e, item, valueType);
|
|
167
|
+
}, {
|
|
168
|
+
wait: 500
|
|
169
|
+
}),
|
|
170
|
+
run = _useDebounceFn.run;
|
|
171
|
+
var getElement = function getElement(item) {
|
|
172
|
+
var _item$setting, _item$inputTips, _item$inputTips2, _item$inputTips3, _item$inputTips4, _item$setting2, _item$setting3;
|
|
173
|
+
var element = /*#__PURE__*/_jsx(_Input, {});
|
|
174
|
+
switch (item.formType) {
|
|
175
|
+
case FormItemType.Text:
|
|
176
|
+
element = /*#__PURE__*/_jsx(_Input, {
|
|
177
|
+
placeholder: item.inputTips,
|
|
178
|
+
allowClear: true,
|
|
179
|
+
style: {
|
|
180
|
+
width: item !== null && item !== void 0 && item.wapperWidth ? item === null || item === void 0 ? void 0 : item.wapperWidth : '100%'
|
|
181
|
+
},
|
|
182
|
+
disabled: item.disabled,
|
|
183
|
+
onChange: function onChange(e) {
|
|
184
|
+
if (e.type === 'click') {
|
|
185
|
+
handleInputClear === null || handleInputClear === void 0 || handleInputClear();
|
|
186
|
+
}
|
|
187
|
+
run(e, item);
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
break;
|
|
191
|
+
case FormItemType.TextArea:
|
|
192
|
+
element = /*#__PURE__*/_jsx(TextArea, {
|
|
193
|
+
rows: item.rows,
|
|
194
|
+
placeholder: item.inputTips,
|
|
195
|
+
maxLength: item.maxLength
|
|
196
|
+
});
|
|
197
|
+
break;
|
|
198
|
+
case FormItemType.Number:
|
|
199
|
+
element = /*#__PURE__*/_jsx(_InputNumber, {
|
|
200
|
+
placeholder: item.inputTips,
|
|
201
|
+
disabled: item.disabled,
|
|
202
|
+
min: item.min,
|
|
203
|
+
max: item.max,
|
|
204
|
+
step: item.step,
|
|
205
|
+
onChange: function onChange(e) {
|
|
206
|
+
run(e, item);
|
|
207
|
+
}
|
|
208
|
+
});
|
|
209
|
+
break;
|
|
210
|
+
case FormItemType.Switch:
|
|
211
|
+
element = /*#__PURE__*/_jsx(_Switch, {
|
|
212
|
+
disabled: item === null || item === void 0 ? void 0 : item.disabled,
|
|
213
|
+
defaultChecked: item === null || item === void 0 ? void 0 : item.defaultValue,
|
|
214
|
+
onChange: function onChange(e) {
|
|
215
|
+
commonChange(e, item);
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
break;
|
|
219
|
+
case FormItemType.Select:
|
|
220
|
+
element = /*#__PURE__*/_jsx(_Select, {
|
|
221
|
+
mode: item.mode ? item.mode : undefined,
|
|
222
|
+
showSearch: item.showSearch,
|
|
223
|
+
placeholder: item.inputTips,
|
|
224
|
+
dropdownMatchSelectWidth: item.dropdownMatchSelectWidth,
|
|
225
|
+
allowClear: item.allowClear === false ? false : true,
|
|
226
|
+
disabled: item.disabled,
|
|
227
|
+
defaultValue: item.defaultValue,
|
|
228
|
+
onSearch: item.showSearch ? debounce(function (value) {
|
|
229
|
+
var _item$handleSearch;
|
|
230
|
+
return (_item$handleSearch = item.handleSearch) === null || _item$handleSearch === void 0 ? void 0 : _item$handleSearch.call(item, value);
|
|
231
|
+
}, 500) : undefined,
|
|
232
|
+
onChange: function onChange(e) {
|
|
233
|
+
commonChange(e, item);
|
|
234
|
+
},
|
|
235
|
+
filterOption: item.isFilter ? function (input, option) {
|
|
236
|
+
var _option$label;
|
|
237
|
+
return ((_option$label = option === null || option === void 0 ? void 0 : option.label) !== null && _option$label !== void 0 ? _option$label : '').toLowerCase().includes(input.toLowerCase());
|
|
238
|
+
} : false,
|
|
239
|
+
onSelect: item.showSelect ? debounce(function (value) {
|
|
240
|
+
var _item$handleSelect;
|
|
241
|
+
return (_item$handleSelect = item.handleSelect) === null || _item$handleSelect === void 0 ? void 0 : _item$handleSelect.call(item, value);
|
|
242
|
+
}, 500) : undefined,
|
|
243
|
+
notFoundContent: ((_item$setting = item.setting) === null || _item$setting === void 0 ? void 0 : _item$setting.length) >= 0 ? null : /*#__PURE__*/_jsx(_Spin, {
|
|
244
|
+
size: "small"
|
|
245
|
+
}),
|
|
246
|
+
maxTagCount: item.maxTagCount,
|
|
247
|
+
children: item.setting.map(function (el, num) {
|
|
248
|
+
return /*#__PURE__*/_jsx(Option, {
|
|
249
|
+
value: el.value,
|
|
250
|
+
label: el.label,
|
|
251
|
+
children: el.color ? /*#__PURE__*/_jsx(_Badge, {
|
|
252
|
+
color: el.color,
|
|
253
|
+
text: el.label
|
|
254
|
+
}) : el.label
|
|
255
|
+
}, num);
|
|
256
|
+
})
|
|
257
|
+
});
|
|
258
|
+
break;
|
|
259
|
+
case FormItemType.Radio:
|
|
260
|
+
element = /*#__PURE__*/_jsx(_Radio.Group, {
|
|
261
|
+
defaultValue: item.defaultValue,
|
|
262
|
+
onChange: function onChange(e) {
|
|
263
|
+
return commonChange(e, item);
|
|
264
|
+
},
|
|
265
|
+
children: item.setting.map(function (el, num) {
|
|
266
|
+
return /*#__PURE__*/_jsx(_Radio, {
|
|
267
|
+
value: el.value,
|
|
268
|
+
children: el.label
|
|
269
|
+
}, num);
|
|
270
|
+
})
|
|
271
|
+
});
|
|
272
|
+
break;
|
|
273
|
+
case FormItemType.AutoComplete:
|
|
274
|
+
element = /*#__PURE__*/_jsx(_AutoComplete, {
|
|
275
|
+
style: {
|
|
276
|
+
width: item !== null && item !== void 0 && item.wapperWidth ? item === null || item === void 0 ? void 0 : item.wapperWidth : '100%'
|
|
277
|
+
},
|
|
278
|
+
options: item.setting,
|
|
279
|
+
allowClear: item.allowClear === false ? false : true,
|
|
280
|
+
placeholder: item.inputTips,
|
|
281
|
+
onSearch: debounce(function (value) {
|
|
282
|
+
var _item$handleSearch2;
|
|
283
|
+
return (_item$handleSearch2 = item.handleSearch) === null || _item$handleSearch2 === void 0 ? void 0 : _item$handleSearch2.call(item, value);
|
|
284
|
+
}, 500),
|
|
285
|
+
onChange: function onChange(e) {
|
|
286
|
+
run(e, item);
|
|
287
|
+
}
|
|
288
|
+
});
|
|
289
|
+
break;
|
|
290
|
+
case FormItemType.Cascader:
|
|
291
|
+
element = /*#__PURE__*/_jsx(_Cascader, {
|
|
292
|
+
options: item.setting,
|
|
293
|
+
expandTrigger: "hover",
|
|
294
|
+
displayRender: displayRender,
|
|
295
|
+
onChange: function onChange(e) {
|
|
296
|
+
return commonChange(e, item);
|
|
297
|
+
},
|
|
298
|
+
placeholder: item.inputTips,
|
|
299
|
+
disabled: item.disabled
|
|
300
|
+
});
|
|
301
|
+
break;
|
|
302
|
+
case FormItemType.DateTime:
|
|
303
|
+
element = /*#__PURE__*/_jsx(_DatePicker, {
|
|
304
|
+
showTime: true,
|
|
305
|
+
style: {
|
|
306
|
+
width: item !== null && item !== void 0 && item.wapperWidth ? item === null || item === void 0 ? void 0 : item.wapperWidth : '100%'
|
|
307
|
+
},
|
|
308
|
+
format: (item === null || item === void 0 ? void 0 : item.defaultFormat) || 'YYYY-MM-DD HH:mm:ss',
|
|
309
|
+
onChange: function onChange(e) {
|
|
310
|
+
commonChange(e, item);
|
|
311
|
+
},
|
|
312
|
+
suffixIcon: /*#__PURE__*/_jsx("i", {
|
|
313
|
+
className: "iconfont-other icon-other-calendar"
|
|
314
|
+
}),
|
|
315
|
+
placeholder: item.inputTips,
|
|
316
|
+
allowClear: item === null || item === void 0 ? void 0 : item.allowClear
|
|
317
|
+
});
|
|
318
|
+
break;
|
|
319
|
+
case FormItemType.DateRang:
|
|
320
|
+
element = /*#__PURE__*/_jsx(RangePicker, {
|
|
321
|
+
style: {
|
|
322
|
+
width: item !== null && item !== void 0 && item.wapperWidth ? item === null || item === void 0 ? void 0 : item.wapperWidth : '100%'
|
|
323
|
+
},
|
|
324
|
+
format: item.defaultFormat,
|
|
325
|
+
showTime: item.showTimeFormat,
|
|
326
|
+
defaultValue: item.defaultValue ? [moment(item.defaultValue[0], item.defaultFormat), moment(item.defaultValue[1], item.defaultFormat)] : undefined,
|
|
327
|
+
separator: /*#__PURE__*/_jsx(MinusOutlined, {}),
|
|
328
|
+
suffixIcon: /*#__PURE__*/_jsx("i", {
|
|
329
|
+
className: "iconfont-other icon-other-calendar"
|
|
330
|
+
}),
|
|
331
|
+
onChange: function onChange(e) {
|
|
332
|
+
commonChange(e, item);
|
|
333
|
+
},
|
|
334
|
+
placeholder: [((_item$inputTips = item.inputTips) === null || _item$inputTips === void 0 ? void 0 : _item$inputTips.start) || item.inputTips, ((_item$inputTips2 = item.inputTips) === null || _item$inputTips2 === void 0 ? void 0 : _item$inputTips2.end) || item.inputTips],
|
|
335
|
+
picker: item === null || item === void 0 ? void 0 : item.picker,
|
|
336
|
+
disabledDate: item === null || item === void 0 ? void 0 : item.disabledDate,
|
|
337
|
+
disabledTime: item === null || item === void 0 ? void 0 : item.disabledTime,
|
|
338
|
+
allowClear: item === null || item === void 0 ? void 0 : item.allowClear
|
|
339
|
+
});
|
|
340
|
+
break;
|
|
341
|
+
case FormItemType.Interval:
|
|
342
|
+
element = /*#__PURE__*/_jsxs("div", {
|
|
343
|
+
className: "sectionInput",
|
|
344
|
+
children: [/*#__PURE__*/_jsx(_Form.Item, {
|
|
345
|
+
name: [item.field, typeList.min],
|
|
346
|
+
children: /*#__PURE__*/_jsx(_InputNumber, {
|
|
347
|
+
min: item.min,
|
|
348
|
+
max: item.max,
|
|
349
|
+
step: item.step,
|
|
350
|
+
precision: item.precision,
|
|
351
|
+
disabled: item.disabled,
|
|
352
|
+
placeholder: item.inputTips ? (_item$inputTips3 = item.inputTips) === null || _item$inputTips3 === void 0 ? void 0 : _item$inputTips3.min : null,
|
|
353
|
+
onBlur: function onBlur(e) {
|
|
354
|
+
// 这里不用走防抖,会出现异步问题
|
|
355
|
+
// run(e, item, typeList.min);
|
|
356
|
+
|
|
357
|
+
commonChange(e, item, typeList.min);
|
|
358
|
+
},
|
|
359
|
+
style: {
|
|
360
|
+
width: (item === null || item === void 0 ? void 0 : item.wapperWidth) || '80px'
|
|
361
|
+
}
|
|
362
|
+
})
|
|
363
|
+
}), /*#__PURE__*/_jsx("span", {
|
|
364
|
+
className: "inputBar"
|
|
365
|
+
}), /*#__PURE__*/_jsx(_Form.Item, {
|
|
366
|
+
name: [item.field, typeList.max],
|
|
367
|
+
children: /*#__PURE__*/_jsx(_InputNumber, {
|
|
368
|
+
min: item.min,
|
|
369
|
+
max: item.max,
|
|
370
|
+
precision: item.precision,
|
|
371
|
+
placeholder: item.inputTips ? (_item$inputTips4 = item.inputTips) === null || _item$inputTips4 === void 0 ? void 0 : _item$inputTips4.max : null,
|
|
372
|
+
step: item.step,
|
|
373
|
+
disabled: item.disabled,
|
|
374
|
+
onBlur: function onBlur(e) {
|
|
375
|
+
// 这里不用走防抖,会出现异步问题
|
|
376
|
+
// run(e, item, typeList.max);
|
|
377
|
+
commonChange(e, item, typeList.max);
|
|
378
|
+
},
|
|
379
|
+
style: {
|
|
380
|
+
width: (item === null || item === void 0 ? void 0 : item.wapperWidth) || '80px'
|
|
381
|
+
}
|
|
382
|
+
})
|
|
383
|
+
}), item.suffix ? /*#__PURE__*/_jsx("span", {
|
|
384
|
+
className: "interSuffix",
|
|
385
|
+
children: item.suffix
|
|
386
|
+
}) : null]
|
|
387
|
+
});
|
|
388
|
+
break;
|
|
389
|
+
case FormItemType.MinMax:
|
|
390
|
+
element = /*#__PURE__*/_jsx(_Form.Item, {
|
|
391
|
+
name: [item.field],
|
|
392
|
+
style: {
|
|
393
|
+
marginBottom: 0
|
|
394
|
+
},
|
|
395
|
+
children: /*#__PURE__*/_jsxs(_Input.Group, {
|
|
396
|
+
style: {
|
|
397
|
+
width: '100%'
|
|
398
|
+
},
|
|
399
|
+
compact: true,
|
|
400
|
+
children: [/*#__PURE__*/_jsx(_Input, {
|
|
401
|
+
style: {
|
|
402
|
+
width: (item === null || item === void 0 ? void 0 : item.wapperWidth) || '80px',
|
|
403
|
+
textAlign: 'center'
|
|
404
|
+
},
|
|
405
|
+
placeholder: "\u6700\u5C0F".concat(item.inputTips),
|
|
406
|
+
onChange: function onChange(e) {
|
|
407
|
+
run(e, item, typeList.min);
|
|
408
|
+
}
|
|
409
|
+
}), /*#__PURE__*/_jsx(_Input, {
|
|
410
|
+
className: "site-input-split",
|
|
411
|
+
style: {
|
|
412
|
+
width: '10%',
|
|
413
|
+
borderLeft: 0,
|
|
414
|
+
borderRight: 0,
|
|
415
|
+
pointerEvents: 'none'
|
|
416
|
+
},
|
|
417
|
+
placeholder: "\u2014",
|
|
418
|
+
disabled: true
|
|
419
|
+
}), /*#__PURE__*/_jsx(_Input, {
|
|
420
|
+
className: "site-input-right",
|
|
421
|
+
style: {
|
|
422
|
+
width: (item === null || item === void 0 ? void 0 : item.wapperWidth) || '80px',
|
|
423
|
+
textAlign: 'center'
|
|
424
|
+
},
|
|
425
|
+
placeholder: "\u6700\u5927".concat(item.inputTips),
|
|
426
|
+
suffix: item.suffix || 'mm',
|
|
427
|
+
onChange: function onChange(e) {
|
|
428
|
+
run(e, item, typeList.max);
|
|
429
|
+
}
|
|
430
|
+
})]
|
|
431
|
+
})
|
|
432
|
+
});
|
|
433
|
+
break;
|
|
434
|
+
case FormItemType.StartEnd:
|
|
435
|
+
element = /*#__PURE__*/_jsxs("div", {
|
|
436
|
+
className: "sectionInput",
|
|
437
|
+
children: [/*#__PURE__*/_jsx(_Form.Item, {
|
|
438
|
+
name: [item.field, typeList.start],
|
|
439
|
+
style: {
|
|
440
|
+
marginBottom: 0
|
|
441
|
+
},
|
|
442
|
+
children: /*#__PURE__*/_jsx(_Select, {
|
|
443
|
+
showSearch: item.showSearch,
|
|
444
|
+
placeholder: item.inputTips,
|
|
445
|
+
allowClear: item.allowClear === false ? false : true,
|
|
446
|
+
disabled: item.disabled,
|
|
447
|
+
defaultValue: item.defaultValue || null,
|
|
448
|
+
onSearch: item.showSearch ? debounce(function (value) {
|
|
449
|
+
var _item$handleSearch3;
|
|
450
|
+
return (_item$handleSearch3 = item.handleSearch) === null || _item$handleSearch3 === void 0 ? void 0 : _item$handleSearch3.call(item, value);
|
|
451
|
+
}, 500) : undefined,
|
|
452
|
+
onChange: function onChange(e) {
|
|
453
|
+
run(e, item, typeList.start);
|
|
454
|
+
},
|
|
455
|
+
filterOption: item.isFilter ? function (input, option) {
|
|
456
|
+
var _option$label2;
|
|
457
|
+
return ((_option$label2 = option === null || option === void 0 ? void 0 : option.label) !== null && _option$label2 !== void 0 ? _option$label2 : '').toLowerCase().includes(input.toLowerCase());
|
|
458
|
+
} : false,
|
|
459
|
+
onSelect: item.showSelect ? debounce(function (value) {
|
|
460
|
+
var _item$handleSelect2;
|
|
461
|
+
return (_item$handleSelect2 = item.handleSelect) === null || _item$handleSelect2 === void 0 ? void 0 : _item$handleSelect2.call(item, value);
|
|
462
|
+
}, 500) : undefined,
|
|
463
|
+
notFoundContent: ((_item$setting2 = item.setting) === null || _item$setting2 === void 0 ? void 0 : _item$setting2.length) >= 0 ? null : /*#__PURE__*/_jsx(_Spin, {
|
|
464
|
+
size: "small"
|
|
465
|
+
}),
|
|
466
|
+
style: {
|
|
467
|
+
width: (item === null || item === void 0 ? void 0 : item.wapperWidth) || '140px'
|
|
468
|
+
},
|
|
469
|
+
children: item.setting.map(function (el, num) {
|
|
470
|
+
return /*#__PURE__*/_jsx(Option, {
|
|
471
|
+
value: el.value,
|
|
472
|
+
label: el.label,
|
|
473
|
+
children: el.color ? /*#__PURE__*/_jsx(_Badge, {
|
|
474
|
+
color: el.color,
|
|
475
|
+
text: el.label
|
|
476
|
+
}) : el.label
|
|
477
|
+
}, num);
|
|
478
|
+
})
|
|
479
|
+
})
|
|
480
|
+
}), /*#__PURE__*/_jsx("span", {
|
|
481
|
+
className: "inputBar"
|
|
482
|
+
}), /*#__PURE__*/_jsx(_Form.Item, {
|
|
483
|
+
name: [item.field, typeList.end],
|
|
484
|
+
style: {
|
|
485
|
+
marginBottom: 0,
|
|
486
|
+
width: '120px'
|
|
487
|
+
},
|
|
488
|
+
children: /*#__PURE__*/_jsx(_Select, {
|
|
489
|
+
showSearch: item.showSearch,
|
|
490
|
+
placeholder: item.inputTips,
|
|
491
|
+
allowClear: item.allowClear === false ? false : true,
|
|
492
|
+
disabled: item.disabled,
|
|
493
|
+
defaultValue: item.defaultValue,
|
|
494
|
+
onSearch: item.showSearch ? debounce(function (value) {
|
|
495
|
+
var _item$handleSearch4;
|
|
496
|
+
return (_item$handleSearch4 = item.handleSearch) === null || _item$handleSearch4 === void 0 ? void 0 : _item$handleSearch4.call(item, value);
|
|
497
|
+
}, 500) : undefined,
|
|
498
|
+
onChange: function onChange(e) {
|
|
499
|
+
run(e, item, typeList.end);
|
|
500
|
+
},
|
|
501
|
+
filterOption: item.isFilter ? function (input, option) {
|
|
502
|
+
var _option$label3;
|
|
503
|
+
return ((_option$label3 = option === null || option === void 0 ? void 0 : option.label) !== null && _option$label3 !== void 0 ? _option$label3 : '').toLowerCase().includes(input.toLowerCase());
|
|
504
|
+
} : false,
|
|
505
|
+
onSelect: item.showSelect ? debounce(function (value) {
|
|
506
|
+
var _item$handleSelect3;
|
|
507
|
+
return (_item$handleSelect3 = item.handleSelect) === null || _item$handleSelect3 === void 0 ? void 0 : _item$handleSelect3.call(item, value);
|
|
508
|
+
}, 500) : undefined,
|
|
509
|
+
notFoundContent: ((_item$setting3 = item.setting) === null || _item$setting3 === void 0 ? void 0 : _item$setting3.length) >= 0 ? null : /*#__PURE__*/_jsx(_Spin, {
|
|
510
|
+
size: "small"
|
|
511
|
+
}),
|
|
512
|
+
style: {
|
|
513
|
+
width: (item === null || item === void 0 ? void 0 : item.wapperWidth) || '140px'
|
|
514
|
+
},
|
|
515
|
+
children: item.setting1.map(function (el, num) {
|
|
516
|
+
return /*#__PURE__*/_jsx(Option, {
|
|
517
|
+
value: el.value,
|
|
518
|
+
label: el.label,
|
|
519
|
+
children: el.color ? /*#__PURE__*/_jsx(_Badge, {
|
|
520
|
+
color: el.color,
|
|
521
|
+
text: el.label
|
|
522
|
+
}) : el.label
|
|
523
|
+
}, num);
|
|
524
|
+
})
|
|
525
|
+
})
|
|
526
|
+
})]
|
|
527
|
+
});
|
|
528
|
+
break;
|
|
529
|
+
case FormItemType.CheckBox:
|
|
530
|
+
element = /*#__PURE__*/_jsx(_Checkbox.Group, {
|
|
531
|
+
disabled: item.disabled,
|
|
532
|
+
onChange: function onChange(e) {
|
|
533
|
+
commonChange(e, item);
|
|
534
|
+
},
|
|
535
|
+
options: item.setting,
|
|
536
|
+
defaultValue: item.defaultValue
|
|
537
|
+
});
|
|
538
|
+
break;
|
|
539
|
+
}
|
|
540
|
+
return element;
|
|
541
|
+
};
|
|
542
|
+
var getWidth = function getWidth(item) {
|
|
543
|
+
switch (item.formType) {
|
|
544
|
+
case FormItemType.Radio:
|
|
545
|
+
return item.wapperWidth || '140px';
|
|
546
|
+
case FormItemType.Interval:
|
|
547
|
+
return item.wapperWidth ? item.wapperWidth * 2 + 24 : '184px';
|
|
548
|
+
case FormItemType.StartEnd:
|
|
549
|
+
return item.wapperWidth ? item.wapperWidth * 2 + 24 : '304px';
|
|
550
|
+
case FormItemType.DateRang:
|
|
551
|
+
if (item.defaultFormat === TimeFormatType.monthType) {
|
|
552
|
+
return item.wapperWidth || '180px';
|
|
553
|
+
} else if (item.defaultFormat === TimeFormatType.dayType) {
|
|
554
|
+
return item.wapperWidth || '220px';
|
|
555
|
+
} else if (item.defaultFormat === TimeFormatType.minuteType) {
|
|
556
|
+
return item.wapperWidth || '300px';
|
|
557
|
+
}
|
|
558
|
+
return item.wapperWidth || '340px';
|
|
559
|
+
default:
|
|
560
|
+
return item.wapperWidth || '160px';
|
|
561
|
+
}
|
|
562
|
+
};
|
|
563
|
+
return /*#__PURE__*/_jsx("div", {
|
|
564
|
+
id: "QueryFilter",
|
|
565
|
+
children: /*#__PURE__*/_jsxs(_Form, {
|
|
566
|
+
ref: FormRef,
|
|
567
|
+
form: form
|
|
568
|
+
// name={styles.customForm}
|
|
569
|
+
// initialValues={initialValues}
|
|
570
|
+
,
|
|
571
|
+
labelAlign: "left",
|
|
572
|
+
autoComplete: "off",
|
|
573
|
+
onFinish: onFinish,
|
|
574
|
+
children: [data.map(function (item, index) {
|
|
575
|
+
var _elementData = getElement(item);
|
|
576
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
577
|
+
style: {
|
|
578
|
+
display: 'inline-block',
|
|
579
|
+
lineHeight: '32px',
|
|
580
|
+
marginRight: '24px'
|
|
581
|
+
},
|
|
582
|
+
className: "custom-form-item",
|
|
583
|
+
children: [/*#__PURE__*/_jsx("span", {
|
|
584
|
+
style: {
|
|
585
|
+
marginRight: '8px'
|
|
586
|
+
},
|
|
587
|
+
children: item.label
|
|
588
|
+
}), /*#__PURE__*/_jsx(_Form.Item, {
|
|
589
|
+
name: item.isShowInterval ? undefined : item.field,
|
|
590
|
+
colon: false,
|
|
591
|
+
style: {
|
|
592
|
+
width: getWidth(item),
|
|
593
|
+
display: 'inline-block',
|
|
594
|
+
marginBottom: 12
|
|
595
|
+
},
|
|
596
|
+
children: _elementData
|
|
597
|
+
}, "".concat(index, "Row"))]
|
|
598
|
+
}, item.field);
|
|
599
|
+
}), showButton && /*#__PURE__*/_jsx(_Form.Item, {
|
|
600
|
+
style: {
|
|
601
|
+
display: 'inline-block',
|
|
602
|
+
marginRight: '24px',
|
|
603
|
+
marginBottom: 12
|
|
604
|
+
},
|
|
605
|
+
children: /*#__PURE__*/_jsxs("div", {
|
|
606
|
+
className: "btnContainer",
|
|
607
|
+
children: [/*#__PURE__*/_jsx(_Button, {
|
|
608
|
+
className: "xmTtn xmTtnDefault",
|
|
609
|
+
onClick: function onClick(e) {
|
|
610
|
+
handleCancel(e);
|
|
611
|
+
form.resetFields();
|
|
612
|
+
// 重置后 再次筛选 会带有上一次的记录(修改)
|
|
613
|
+
setFormValues({});
|
|
614
|
+
},
|
|
615
|
+
children: cancelText
|
|
616
|
+
}), /*#__PURE__*/_jsx(_Button, {
|
|
617
|
+
type: "primary",
|
|
618
|
+
className: "xmTtn",
|
|
619
|
+
loading: submitLoading,
|
|
620
|
+
onClick: function onClick() {
|
|
621
|
+
return form.submit();
|
|
622
|
+
},
|
|
623
|
+
children: isOkText
|
|
624
|
+
})]
|
|
625
|
+
})
|
|
626
|
+
}), renderButton ? /*#__PURE__*/_jsx(_Form.Item, {
|
|
627
|
+
style: {
|
|
628
|
+
display: 'inline-block',
|
|
629
|
+
marginRight: '24px',
|
|
630
|
+
marginBottom: 12
|
|
631
|
+
},
|
|
632
|
+
children: renderButton
|
|
633
|
+
}) : null]
|
|
634
|
+
})
|
|
635
|
+
});
|
|
636
|
+
};
|
|
637
|
+
|
|
638
|
+
/**
|
|
639
|
+
* 处理公共动态查询的searchField
|
|
640
|
+
* @param searchField 查询的字段
|
|
641
|
+
* @param dynamicField 动态查询设置的字段
|
|
642
|
+
* @returns
|
|
643
|
+
*/
|
|
644
|
+
export function useDynamicSearchFiled(searchField, dynamicField) {
|
|
645
|
+
var _useState3 = useState(function () {
|
|
646
|
+
return searchField.map(function (item) {
|
|
647
|
+
var tartget = dynamicField.find(function (dynamicFieldItem) {
|
|
648
|
+
return dynamicFieldItem.field === item.field;
|
|
649
|
+
});
|
|
650
|
+
if (tartget) {
|
|
651
|
+
var handleSearch = /*#__PURE__*/function () {
|
|
652
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(value) {
|
|
653
|
+
var _this = this;
|
|
654
|
+
var _settingList, _tartget$params, queryData, _yield$to, _yield$to2, err, data, _items;
|
|
655
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
656
|
+
while (1) switch (_context.prev = _context.next) {
|
|
657
|
+
case 0:
|
|
658
|
+
_settingList = [];
|
|
659
|
+
if (!value) {
|
|
660
|
+
_context.next = 11;
|
|
661
|
+
break;
|
|
662
|
+
}
|
|
663
|
+
// 接口查询参数
|
|
664
|
+
queryData = (_tartget$params = tartget.params) !== null && _tartget$params !== void 0 ? _tartget$params : {};
|
|
665
|
+
_context.next = 5;
|
|
666
|
+
return to(tartget.ApiFun(_objectSpread({
|
|
667
|
+
key: value,
|
|
668
|
+
isPage: false
|
|
669
|
+
}, queryData)));
|
|
670
|
+
case 5:
|
|
671
|
+
_yield$to = _context.sent;
|
|
672
|
+
_yield$to2 = _slicedToArray(_yield$to, 2);
|
|
673
|
+
err = _yield$to2[0];
|
|
674
|
+
data = _yield$to2[1];
|
|
675
|
+
if (!err) {
|
|
676
|
+
_items = data.items || data || [];
|
|
677
|
+
_settingList = this.settingHandler(_items || []);
|
|
678
|
+
}
|
|
679
|
+
setWrapSearchField(wrapSearchField.map(function (item) {
|
|
680
|
+
if (item.field === _this.field) {
|
|
681
|
+
item.setting = _settingList;
|
|
682
|
+
}
|
|
683
|
+
return item;
|
|
684
|
+
}));
|
|
685
|
+
case 11:
|
|
686
|
+
case "end":
|
|
687
|
+
return _context.stop();
|
|
688
|
+
}
|
|
689
|
+
}, _callee, this);
|
|
690
|
+
}));
|
|
691
|
+
return function handleSearch(_x) {
|
|
692
|
+
return _ref2.apply(this, arguments);
|
|
693
|
+
};
|
|
694
|
+
}();
|
|
695
|
+
item.handleSearch = handleSearch;
|
|
696
|
+
item.settingHandler = tartget.settingHandler;
|
|
697
|
+
return item;
|
|
698
|
+
}
|
|
699
|
+
return item;
|
|
700
|
+
});
|
|
701
|
+
}),
|
|
702
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
703
|
+
wrapSearchField = _useState4[0],
|
|
704
|
+
setWrapSearchField = _useState4[1];
|
|
705
|
+
return wrapSearchField;
|
|
706
|
+
}
|
|
707
|
+
export default /*#__PURE__*/React.memo(QueryFilter);
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import QueryFilter, { typeList, useDynamicSearchFiled } from './QueryFilter';
|
|
2
|
+
export { FormItemType, TimeFormatType } from './type';
|
|
3
|
+
export type { CustomFormProps, fieldType, inputValueType, searchFieldType } from './type';
|
|
4
|
+
export { typeList, useDynamicSearchFiled };
|
|
5
|
+
export default QueryFilter;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
.isTwoColumns {
|
|
2
|
+
flex: 1;
|
|
3
|
+
// display: flex;
|
|
4
|
+
// justify-content: space-between;
|
|
5
|
+
// flex-wrap: wrap;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.btnContainer {
|
|
9
|
+
width: 100%;
|
|
10
|
+
text-align: right;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.sectionInput {
|
|
14
|
+
display: flex;
|
|
15
|
+
align-items: baseline;
|
|
16
|
+
flex-direction: row;
|
|
17
|
+
|
|
18
|
+
.interSuffix {
|
|
19
|
+
display: inline-block;
|
|
20
|
+
width: 30px;
|
|
21
|
+
margin-left: 4px;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.inputBar {
|
|
25
|
+
display: inline-block;
|
|
26
|
+
width: 20px;
|
|
27
|
+
border-top: 2px solid #d8d8d8;
|
|
28
|
+
margin: 0 4px;
|
|
29
|
+
padding-top: 4px;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
:global {
|
|
33
|
+
.custom-light-form-item,
|
|
34
|
+
.custom-dark-form-item,
|
|
35
|
+
.ant-form-item {
|
|
36
|
+
margin: 0;
|
|
37
|
+
width: 168px !important;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.xmTtn {
|
|
43
|
+
width: 76px;
|
|
44
|
+
height: 32px;
|
|
45
|
+
border-radius: 2px;
|
|
46
|
+
// margin-bottom: 8px;
|
|
47
|
+
padding: 0 !important;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// .xmTtnDefault {
|
|
51
|
+
// background: rgba(245, 245, 245, 1);
|
|
52
|
+
// }
|
|
53
|
+
|
|
54
|
+
.xmTtn + .xmTtn {
|
|
55
|
+
margin-left: 12px;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
:global {
|
|
59
|
+
.custom-dark-input-number,
|
|
60
|
+
.custom-light-input-number {
|
|
61
|
+
width: 100% !important;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { FormProps } from 'antd';
|
|
2
|
+
import { MouseEventHandler } from 'react';
|
|
3
|
+
export declare enum FormItemType {
|
|
4
|
+
Text = "text",
|
|
5
|
+
TextArea = "textArea",
|
|
6
|
+
Number = "number",
|
|
7
|
+
Switch = "switch",
|
|
8
|
+
Select = "select",
|
|
9
|
+
Cascader = "cascader",
|
|
10
|
+
DateTime = "datetime",
|
|
11
|
+
DateRang = "daterang",
|
|
12
|
+
Interval = "interval",
|
|
13
|
+
Radio = "radio",
|
|
14
|
+
StartEnd = "start-end",
|
|
15
|
+
AutoComplete = "autoComplete",
|
|
16
|
+
MinMax = "min-max",
|
|
17
|
+
CheckBox = "checkbox"
|
|
18
|
+
}
|
|
19
|
+
export declare enum TimeFormatType {
|
|
20
|
+
monthType = "YYYY-MM",
|
|
21
|
+
dayType = "YYYY-MM-DD",
|
|
22
|
+
hourType = "YYYY-MM-DD HH",
|
|
23
|
+
minuteType = "YYYY-MM-DD HH:mm",
|
|
24
|
+
secondType = "YYYY-MM-DD HH:mm:ss",
|
|
25
|
+
nonYearMinuteType = "MM-DD HH:mm",
|
|
26
|
+
nonYearSecondType = "MM-DD HH:mm:ss",
|
|
27
|
+
onlyTimeType = "HH:mm:ss",
|
|
28
|
+
nonSecondTimeType = "HH:mm"
|
|
29
|
+
}
|
|
30
|
+
export interface fieldType {
|
|
31
|
+
field: string;
|
|
32
|
+
label?: string;
|
|
33
|
+
text: string | Element | JSX.Element;
|
|
34
|
+
value: any;
|
|
35
|
+
units?: string;
|
|
36
|
+
width?: string;
|
|
37
|
+
labelWidth?: string;
|
|
38
|
+
color?: string;
|
|
39
|
+
disabledColor?: string;
|
|
40
|
+
detail?: object;
|
|
41
|
+
isShowInterval?: boolean;
|
|
42
|
+
isActiveTrigger?: boolean;
|
|
43
|
+
activeTriggerFun?: (e: any) => void;
|
|
44
|
+
isShowToolTip?: boolean;
|
|
45
|
+
}
|
|
46
|
+
export type inputValueType = 'min' | 'max' | string;
|
|
47
|
+
export declare enum PickerType {
|
|
48
|
+
Date = "date",
|
|
49
|
+
Minute = "minute",
|
|
50
|
+
Year = "Year",
|
|
51
|
+
Month = "month",
|
|
52
|
+
Week = "week",
|
|
53
|
+
Quarter = "quarter "
|
|
54
|
+
}
|
|
55
|
+
export type searchFieldType = {
|
|
56
|
+
field: string;
|
|
57
|
+
label?: string;
|
|
58
|
+
formType: FormItemType;
|
|
59
|
+
defaultValue?: string | any[] | number;
|
|
60
|
+
inputTips?: string | any;
|
|
61
|
+
setting?: any[];
|
|
62
|
+
setting1?: any[];
|
|
63
|
+
value?: string;
|
|
64
|
+
maxLength?: number;
|
|
65
|
+
rows?: number;
|
|
66
|
+
wapperWidth?: number;
|
|
67
|
+
picker?: PickerType;
|
|
68
|
+
defaultFormat?: any;
|
|
69
|
+
showTimeFormat?: any;
|
|
70
|
+
allowClear?: boolean;
|
|
71
|
+
isShowInterval?: boolean;
|
|
72
|
+
disabled?: boolean;
|
|
73
|
+
min?: number;
|
|
74
|
+
max?: number;
|
|
75
|
+
step?: number;
|
|
76
|
+
showSearch?: boolean;
|
|
77
|
+
handleSearch?: () => void;
|
|
78
|
+
suffix?: string;
|
|
79
|
+
isFilter?: boolean;
|
|
80
|
+
showSelect?: boolean;
|
|
81
|
+
handleSelect?: () => void;
|
|
82
|
+
mode?: 'multiple' | 'tags';
|
|
83
|
+
maxTagCount?: number | 'responsive';
|
|
84
|
+
};
|
|
85
|
+
export interface CustomFormProps {
|
|
86
|
+
data: searchFieldType[];
|
|
87
|
+
/**初始值 */
|
|
88
|
+
initialValues?: object;
|
|
89
|
+
/**labelWidth */
|
|
90
|
+
labelCol?: string;
|
|
91
|
+
/**确认按钮 text */
|
|
92
|
+
isOkText?: string;
|
|
93
|
+
/**取消按钮 text */
|
|
94
|
+
cancelText?: string;
|
|
95
|
+
/**提交方法 */
|
|
96
|
+
handleSubmit: ({ data }: {
|
|
97
|
+
data: any;
|
|
98
|
+
}, item?: fieldType, type?: inputValueType) => void;
|
|
99
|
+
/**重置方法 */
|
|
100
|
+
handleCancel: MouseEventHandler<HTMLElement>;
|
|
101
|
+
/** 配置列数,一般是 8 的倍数*/
|
|
102
|
+
layout?: FormProps['layout'];
|
|
103
|
+
/**是否展示按钮 */
|
|
104
|
+
showButton?: boolean;
|
|
105
|
+
/**输入框清空方法 */
|
|
106
|
+
handleInputClear?: () => void;
|
|
107
|
+
submitLoading?: boolean;
|
|
108
|
+
buttonRender?: any;
|
|
109
|
+
renderButton?: any;
|
|
110
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export var FormItemType = /*#__PURE__*/function (FormItemType) {
|
|
2
|
+
FormItemType["Text"] = "text";
|
|
3
|
+
FormItemType["TextArea"] = "textArea";
|
|
4
|
+
FormItemType["Number"] = "number";
|
|
5
|
+
FormItemType["Switch"] = "switch";
|
|
6
|
+
FormItemType["Select"] = "select";
|
|
7
|
+
FormItemType["Cascader"] = "cascader";
|
|
8
|
+
FormItemType["DateTime"] = "datetime";
|
|
9
|
+
FormItemType["DateRang"] = "daterang";
|
|
10
|
+
FormItemType["Interval"] = "interval";
|
|
11
|
+
FormItemType["Radio"] = "radio";
|
|
12
|
+
FormItemType["StartEnd"] = "start-end";
|
|
13
|
+
FormItemType["AutoComplete"] = "autoComplete";
|
|
14
|
+
FormItemType["MinMax"] = "min-max";
|
|
15
|
+
FormItemType["CheckBox"] = "checkbox";
|
|
16
|
+
return FormItemType;
|
|
17
|
+
}({});
|
|
18
|
+
|
|
19
|
+
// 时间转换格式
|
|
20
|
+
export var TimeFormatType = /*#__PURE__*/function (TimeFormatType) {
|
|
21
|
+
TimeFormatType["monthType"] = "YYYY-MM";
|
|
22
|
+
TimeFormatType["dayType"] = "YYYY-MM-DD";
|
|
23
|
+
TimeFormatType["hourType"] = "YYYY-MM-DD HH";
|
|
24
|
+
TimeFormatType["minuteType"] = "YYYY-MM-DD HH:mm";
|
|
25
|
+
TimeFormatType["secondType"] = "YYYY-MM-DD HH:mm:ss";
|
|
26
|
+
TimeFormatType["nonYearMinuteType"] = "MM-DD HH:mm";
|
|
27
|
+
TimeFormatType["nonYearSecondType"] = "MM-DD HH:mm:ss";
|
|
28
|
+
TimeFormatType["onlyTimeType"] = "HH:mm:ss";
|
|
29
|
+
TimeFormatType["nonSecondTimeType"] = "HH:mm";
|
|
30
|
+
return TimeFormatType;
|
|
31
|
+
}({});
|
|
32
|
+
export var PickerType = /*#__PURE__*/function (PickerType) {
|
|
33
|
+
PickerType["Date"] = "date";
|
|
34
|
+
PickerType["Minute"] = "minute";
|
|
35
|
+
PickerType["Year"] = "Year";
|
|
36
|
+
PickerType["Month"] = "month";
|
|
37
|
+
PickerType["Week"] = "week";
|
|
38
|
+
PickerType["Quarter"] = "quarter ";
|
|
39
|
+
return PickerType;
|
|
40
|
+
}({});
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export declare const numberSortFn: (rowA: any, rowB: any, columnId: string) =>
|
|
2
|
-
export declare const stringSortFn: (rowA: any, rowB: any, columnId: string) =>
|
|
3
|
-
export declare const timeSortFn: (rowA: any, rowB: any, columnId: string) =>
|
|
1
|
+
export declare const numberSortFn: (rowA: any, rowB: any, columnId: string) => 1 | 0 | -1;
|
|
2
|
+
export declare const stringSortFn: (rowA: any, rowB: any, columnId: string) => 1 | 0 | -1;
|
|
3
|
+
export declare const timeSortFn: (rowA: any, rowB: any, columnId: string) => 1 | 0 | -1;
|
|
4
4
|
declare const customSortFns: {
|
|
5
|
-
numberSortFn: (rowA: any, rowB: any, columnId: string) =>
|
|
6
|
-
stringSortFn: (rowA: any, rowB: any, columnId: string) =>
|
|
7
|
-
timeSortFn: (rowA: any, rowB: any, columnId: string) =>
|
|
5
|
+
numberSortFn: (rowA: any, rowB: any, columnId: string) => 1 | 0 | -1;
|
|
6
|
+
stringSortFn: (rowA: any, rowB: any, columnId: string) => 1 | 0 | -1;
|
|
7
|
+
timeSortFn: (rowA: any, rowB: any, columnId: string) => 1 | 0 | -1;
|
|
8
8
|
};
|
|
9
9
|
export default customSortFns;
|
|
10
10
|
export type SortFnType = keyof typeof customSortFns | undefined;
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/dist/utils/index.d.ts
CHANGED
package/dist/utils/index.js
CHANGED
|
@@ -5,4 +5,11 @@ export function getTextWidth(text, fontSize) {
|
|
|
5
5
|
context.font = "".concat(fontSize, " Microsoft YaHei"); // 字体一定要写,不能只写一个字体大小,不启用
|
|
6
6
|
var dimension = context === null || context === void 0 ? void 0 : context.measureText(text);
|
|
7
7
|
return dimension === null || dimension === void 0 ? void 0 : dimension.width;
|
|
8
|
+
}
|
|
9
|
+
export function to(promise) {
|
|
10
|
+
return promise.then(function (data) {
|
|
11
|
+
return [null, data];
|
|
12
|
+
}).catch(function (err) {
|
|
13
|
+
return [err, null];
|
|
14
|
+
});
|
|
8
15
|
}
|
package/package.json
CHANGED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import "./index.less";
|
|
2
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
var Foo = function Foo(props) {
|
|
4
|
-
return /*#__PURE__*/_jsx("h4", {
|
|
5
|
-
className: "title",
|
|
6
|
-
children: props.title
|
|
7
|
-
});
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
// const Foo: FC<{ title: string }> = (props) => {
|
|
11
|
-
|
|
12
|
-
// return <h4 className="title">{props.title}</h4>
|
|
13
|
-
// }
|
|
14
|
-
|
|
15
|
-
export default Foo;
|