fast-crud-ui3 1.5.16-tsc-beta1 → 1.5.17
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/lib/fast-crud-ui3.cjs.js +44 -17
- package/lib/fast-crud-ui3.es.js +9389 -5695
- package/lib/fast-crud-ui3.umd.js +44 -17
- package/lib/model/filterComponentConfig.d.ts +16 -18
- package/package.json +1 -1
- package/packages/model/filterComponentConfig.js +17 -11
- package/packages/util/util.js +10 -10
|
@@ -1,31 +1,29 @@
|
|
|
1
|
+
import { default as Opt } from './opt.js';
|
|
1
2
|
export default FilterComponentConfig;
|
|
2
3
|
/**
|
|
3
4
|
* 筛选组件配置
|
|
4
5
|
*/
|
|
6
|
+
export type OptValue = (typeof Opt)[keyof typeof Opt];
|
|
7
|
+
/**
|
|
8
|
+
* 筛选组件配置
|
|
9
|
+
* @typedef {typeof Opt[keyof typeof Opt]} OptValue
|
|
10
|
+
*/
|
|
5
11
|
declare class FilterComponentConfig {
|
|
6
12
|
/**
|
|
7
13
|
* 构造函数
|
|
8
|
-
* @param component
|
|
9
|
-
* @param col 字段名
|
|
10
|
-
* @param opt 操作符
|
|
11
|
-
* @param val 值
|
|
12
|
-
* @param label 中文名
|
|
13
|
-
* @param props 组件对应的props
|
|
14
|
-
* @param condMapFn 条件获取过滤函数
|
|
14
|
+
* @param component {string} 组件名
|
|
15
|
+
* @param col {string} 字段名
|
|
16
|
+
* @param opt {OptValue} 操作符
|
|
17
|
+
* @param val {any} 值
|
|
18
|
+
* @param label {string} 中文名
|
|
19
|
+
* @param props {Object} 组件对应的props
|
|
20
|
+
* @param condMapFn {Function} 条件获取过滤函数
|
|
21
|
+
* @param type {string} quick|easy|dynamic
|
|
15
22
|
*/
|
|
16
|
-
constructor({ component, col, opt, val, label, props, condMapFn, type }:
|
|
17
|
-
component: any;
|
|
18
|
-
col: any;
|
|
19
|
-
opt?: "like";
|
|
20
|
-
val: any;
|
|
21
|
-
label: any;
|
|
22
|
-
props: any;
|
|
23
|
-
condMapFn?: (cond: any) => any[];
|
|
24
|
-
type: any;
|
|
25
|
-
});
|
|
23
|
+
constructor({ component, col, opt, val, label, props, condMapFn, type }: string);
|
|
26
24
|
component: any;
|
|
27
25
|
col: any;
|
|
28
|
-
opt:
|
|
26
|
+
opt: any;
|
|
29
27
|
val: any;
|
|
30
28
|
label: any;
|
|
31
29
|
props: any;
|
package/package.json
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import
|
|
1
|
+
import _ from 'lodash-es'
|
|
2
|
+
import {isString, isUndefined} from "../util/util.js"
|
|
2
3
|
import {escapeValToLabel} from "../util/escape.js"
|
|
3
4
|
import Cond from './cond.js'
|
|
4
5
|
import Opt from './opt.js'
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* 筛选组件配置
|
|
9
|
+
* @typedef {typeof Opt[keyof typeof Opt]} OptValue
|
|
8
10
|
*/
|
|
9
11
|
class FilterComponentConfig {
|
|
10
12
|
component; // 渲染组件
|
|
@@ -22,13 +24,14 @@ class FilterComponentConfig {
|
|
|
22
24
|
|
|
23
25
|
/**
|
|
24
26
|
* 构造函数
|
|
25
|
-
* @param component
|
|
26
|
-
* @param col 字段名
|
|
27
|
-
* @param opt 操作符
|
|
28
|
-
* @param val 值
|
|
29
|
-
* @param label 中文名
|
|
30
|
-
* @param props 组件对应的props
|
|
31
|
-
* @param condMapFn 条件获取过滤函数
|
|
27
|
+
* @param component {string} 组件名
|
|
28
|
+
* @param col {string} 字段名
|
|
29
|
+
* @param opt {OptValue} 操作符
|
|
30
|
+
* @param val {any} 值
|
|
31
|
+
* @param label {string} 中文名
|
|
32
|
+
* @param props {Object} 组件对应的props
|
|
33
|
+
* @param condMapFn {Function} 条件获取过滤函数
|
|
34
|
+
* @param type {string} quick|easy|dynamic
|
|
32
35
|
*/
|
|
33
36
|
constructor({
|
|
34
37
|
component,
|
|
@@ -50,11 +53,11 @@ class FilterComponentConfig {
|
|
|
50
53
|
if (!isUndefined(condMapFn)) {
|
|
51
54
|
this.condMapFn = condMapFn;
|
|
52
55
|
}
|
|
53
|
-
|
|
54
|
-
this.defaultVal =
|
|
56
|
+
const finalVal = isString(val) ? _.trim(val) : val
|
|
57
|
+
this.defaultVal = finalVal;
|
|
55
58
|
this.disabled = false;
|
|
56
59
|
this.type = type;
|
|
57
|
-
this.val =
|
|
60
|
+
this.val = finalVal;
|
|
58
61
|
}
|
|
59
62
|
|
|
60
63
|
/**
|
|
@@ -89,6 +92,9 @@ class FilterComponentConfig {
|
|
|
89
92
|
if (this.opt === Opt.NULL || this.opt === Opt.NNULL || this.opt === Opt.EMPTY || this.opt === Opt.NEMPTY) {
|
|
90
93
|
return [new Cond(this.col, this.opt, null)]
|
|
91
94
|
}
|
|
95
|
+
if (isString(this.val)) {
|
|
96
|
+
this.val = _.trim(this.val)
|
|
97
|
+
}
|
|
92
98
|
return this.condMapFn(new Cond(this.col, this.opt, this.val));
|
|
93
99
|
}
|
|
94
100
|
|
package/packages/util/util.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import _ from 'lodash-es'
|
|
2
2
|
import moment from "moment/moment"
|
|
3
3
|
import {ElMessage} from "element-plus";
|
|
4
4
|
|
|
@@ -329,7 +329,7 @@ export function isEmpty(value) {
|
|
|
329
329
|
case '[object String]':
|
|
330
330
|
return value.trim() === '';
|
|
331
331
|
case "[object Object]":
|
|
332
|
-
return
|
|
332
|
+
return _.isEmpty(value);
|
|
333
333
|
case "[object Array]":
|
|
334
334
|
return value.length === 0;
|
|
335
335
|
case "[object Undefined]":
|
|
@@ -373,7 +373,7 @@ export function deepClone(obj) {
|
|
|
373
373
|
if (isObject(obj)) {
|
|
374
374
|
// return Object.assign({}, obj)
|
|
375
375
|
try {
|
|
376
|
-
return cloneDeep(obj);
|
|
376
|
+
return _.cloneDeep(obj);
|
|
377
377
|
} catch (err) {
|
|
378
378
|
console.error(err)
|
|
379
379
|
return {...obj}
|
|
@@ -382,7 +382,7 @@ export function deepClone(obj) {
|
|
|
382
382
|
if (isArray(obj)) {
|
|
383
383
|
// return Object.assign([], obj)
|
|
384
384
|
try {
|
|
385
|
-
return cloneDeep(obj);
|
|
385
|
+
return _.cloneDeep(obj);
|
|
386
386
|
} catch (err) {
|
|
387
387
|
console.error(err);
|
|
388
388
|
return [...obj];
|
|
@@ -520,9 +520,9 @@ export function easyOptParse(cond, optMapping = {}) {
|
|
|
520
520
|
const regex = new RegExp(reg);
|
|
521
521
|
const {opt, valExtract} = obj
|
|
522
522
|
if (regex.test(cond.val)) {
|
|
523
|
-
cond.opt = opt
|
|
524
|
-
cond.val = valExtract(cond)
|
|
525
|
-
break
|
|
523
|
+
cond.opt = opt
|
|
524
|
+
cond.val = valExtract(cond)
|
|
525
|
+
break
|
|
526
526
|
}
|
|
527
527
|
}
|
|
528
528
|
return cond;
|
|
@@ -676,7 +676,7 @@ export const getBeginOfDate = function (date) {
|
|
|
676
676
|
if (isEmpty(date)) {
|
|
677
677
|
d = new Date()
|
|
678
678
|
} else {
|
|
679
|
-
d = cloneDeep(date)
|
|
679
|
+
d = _.cloneDeep(date)
|
|
680
680
|
}
|
|
681
681
|
d.setHours(0, 0, 0, 0)
|
|
682
682
|
return d
|
|
@@ -692,7 +692,7 @@ export const getBeginOfWeek = function (date) {
|
|
|
692
692
|
if (isEmpty(date)) {
|
|
693
693
|
d = new Date()
|
|
694
694
|
} else {
|
|
695
|
-
d = cloneDeep(date)
|
|
695
|
+
d = _.cloneDeep(date)
|
|
696
696
|
}
|
|
697
697
|
const day = d.getDay();
|
|
698
698
|
const diff = d.getDate() - day + (day === 0 ? -6 : 1)
|
|
@@ -710,7 +710,7 @@ export const getBeginOfMonth = function (date) {
|
|
|
710
710
|
if (isEmpty(date)) {
|
|
711
711
|
d = new Date()
|
|
712
712
|
} else {
|
|
713
|
-
d = cloneDeep(date)
|
|
713
|
+
d = _.cloneDeep(date)
|
|
714
714
|
}
|
|
715
715
|
d.setDate(1); // 设置为当月的 1 号
|
|
716
716
|
d.setHours(0, 0, 0, 0);
|