@cloudbase/weda-ui 3.17.7 → 3.18.0
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/configs/components/wd-select-multiple.d.ts +2 -0
- package/dist/configs/components/wd-select-multiple.js +4 -2
- package/dist/configs/components/wd-select.d.ts +2 -0
- package/dist/configs/components/wd-select.js +4 -2
- package/dist/configs/components/wd-table.js +1 -1
- package/dist/configs/index.d.ts +4 -0
- package/dist/configs/type-utils/type-form.d.ts +2 -0
- package/dist/configs/type-utils/type-form.js +32 -4
- package/dist/style/index.css +7 -3
- package/dist/style/index.scss +1 -1
- package/dist/style/weda-ui.min.css +3 -3
- package/dist/web/components/wd-input/wd-input.js +2 -2
- package/dist/web/components/wd-select/hooks/useChooseList.js +5 -3
- package/dist/web/components/wd-select/relationSelect/index.js +2 -7
- package/dist/web/components/wd-select/relationSelect/relationSelect.js +6 -4
- package/dist/web/components/wd-select/select/index.js +9 -3
- package/dist/web/components/wd-select/select/selectUI.js +1 -1
- package/dist/web/components/wd-select/style.d.ts +0 -2
- package/dist/web/components/wd-select/style.js +2 -2
- package/dist/web/components/wd-select/wd-select.js +4 -7
- package/dist/web/components/wd-select-multiple/wd-select-multiple.js +4 -4
- package/dist/web/components/wd-table/components/FilterFieldsPanel/Fields.d.ts +3 -3
- package/dist/web/components/wd-table/components/FilterFieldsPanel/Fields.js +51 -50
- package/dist/web/components/wd-table/components/FilterFieldsPanel/FilterFieldItem.d.ts +2 -1
- package/dist/web/components/wd-table/components/FilterFieldsPanel/FilterFieldItem.js +18 -8
- package/dist/web/components/wd-table/components/FilterFieldsPanel/SelectSearch.d.ts +5 -3
- package/dist/web/components/wd-table/components/FilterFieldsPanel/SelectSearch.js +20 -41
- package/dist/web/components/wd-table/components/FilterFieldsPanel/filterFieldsGenerate.d.ts +7 -0
- package/dist/web/components/wd-table/components/FilterFieldsPanel/filterFieldsGenerate.js +44 -14
- package/dist/web/components/wd-table/components/FilterFieldsPanel/index.js +13 -8
- package/dist/web/components/wd-table/utils/index.d.ts +18 -0
- package/dist/web/components/wd-table/utils/index.js +64 -56
- package/dist/web/components/wd-table/wd-table.js +4 -2
- package/package.json +1 -1
- package/dist/web/components/wd-table/hooks/useChooseList.d.ts +0 -16
- package/dist/web/components/wd-table/hooks/useChooseList.js +0 -126
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
/* eslint-disable complexity */
|
|
2
|
+
const NEW_SINGLE_RELATION_FORMATS = ['many-one', 'one-one', 'one-one-r'];
|
|
3
|
+
const NEW_MULTIPLE_RELATION_FORMATS = ['many-many', 'one-many'];
|
|
4
|
+
export const NEW_RELATION_FORMATS = ['many-one', 'one-one', 'one-one-r', 'many-many', 'one-many'];
|
|
1
5
|
// 计算方式
|
|
2
6
|
export const fieldCalculations = {
|
|
3
7
|
number: [
|
|
@@ -13,10 +17,10 @@ export const fieldCalculations = {
|
|
|
13
17
|
],
|
|
14
18
|
string: [
|
|
15
19
|
{ text: '包含', value: 'search_ci' },
|
|
16
|
-
{ text: '不包含', value: '
|
|
20
|
+
{ text: '不包含', value: 'nsearch_ci' },
|
|
17
21
|
{ text: '等于', value: 'eq' },
|
|
18
22
|
{ text: '不等于', value: 'neq' },
|
|
19
|
-
{ text: '开头是', value: '
|
|
23
|
+
{ text: '开头是', value: 'regex' },
|
|
20
24
|
// { text: '为空', value: '$empty' },
|
|
21
25
|
// { text: '不为空', value: '$nempty' },
|
|
22
26
|
],
|
|
@@ -39,6 +43,12 @@ export const fieldCalculations = {
|
|
|
39
43
|
* 2、生成配置
|
|
40
44
|
* 3、枚举/数字需要特殊处理(即format,用于处理查询数据转换)
|
|
41
45
|
* { filterType: 'datetime' | 'date' | 'time' | 'string' |'number' | 'x-enumObj' , isRange: boolean }
|
|
46
|
+
*
|
|
47
|
+
*
|
|
48
|
+
* field?.type === 'array' && field?.format === '' 非关联关系 数组类型 不支持搜索
|
|
49
|
+
* field?.type === 'object' && field?.format === '' 非关联关系 对象类型 不支持搜索
|
|
50
|
+
* field?.name === '_departmentList' && field?.format === '' 所属部门 系统字段 不支持搜索
|
|
51
|
+
* ['x-markdown', 'x-location', 'x-music', 'x-json', 'x-video', 'x-file', 'x-image', 'x-rtf', 'function'] 不支持搜索
|
|
42
52
|
*/
|
|
43
53
|
export const filterFieldsGenerate = (fields) => {
|
|
44
54
|
var _a;
|
|
@@ -47,15 +57,14 @@ export const filterFieldsGenerate = (fields) => {
|
|
|
47
57
|
if (!field)
|
|
48
58
|
return false;
|
|
49
59
|
if (((field === null || field === void 0 ? void 0 : field.type) === 'array' && (field === null || field === void 0 ? void 0 : field.format) === '') ||
|
|
50
|
-
((field === null || field === void 0 ? void 0 : field.
|
|
51
|
-
(field === null || field === void 0 ? void 0 : field.
|
|
52
|
-
(field === null || field === void 0 ? void 0 : field.format)
|
|
53
|
-
(field === null || field === void 0 ? void 0 : field.format) === 'x-image' ||
|
|
54
|
-
(field === null || field === void 0 ? void 0 : field.format) === 'x-rtf')
|
|
60
|
+
((field === null || field === void 0 ? void 0 : field.type) === 'object' && (field === null || field === void 0 ? void 0 : field.format) === '') ||
|
|
61
|
+
((field === null || field === void 0 ? void 0 : field.name) === '_departmentList' && (field === null || field === void 0 ? void 0 : field.format) === '') ||
|
|
62
|
+
['x-markdown', 'x-location', 'x-music', 'x-json', 'x-video', 'x-file', 'x-image', 'x-rtf', 'function'].includes(field === null || field === void 0 ? void 0 : field.format)) {
|
|
55
63
|
return false;
|
|
64
|
+
}
|
|
56
65
|
return true;
|
|
57
66
|
})) === null || _a === void 0 ? void 0 : _a.map((i) => {
|
|
58
|
-
var _a, _b, _c;
|
|
67
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
59
68
|
// 生成计算方式
|
|
60
69
|
const fieldCalculation = ['string', 'number'].includes(i.type)
|
|
61
70
|
? { type: i.type, value: fieldCalculations[i.type][0].value }
|
|
@@ -72,13 +81,17 @@ export const filterFieldsGenerate = (fields) => {
|
|
|
72
81
|
};
|
|
73
82
|
if (i.type === 'number' && ['time', 'date', 'datetime'].includes(i.format)) {
|
|
74
83
|
filterFieldItemConfig.filterType = i.format;
|
|
84
|
+
if ('time' === i.format) {
|
|
85
|
+
filterFieldItemConfig.fieldCalculation.value = 'eq';
|
|
86
|
+
filterFieldItemConfig.isRange = false;
|
|
87
|
+
}
|
|
75
88
|
}
|
|
76
89
|
if (i.type === 'boolean') {
|
|
77
90
|
filterFieldItemConfig.filterType = i.type;
|
|
78
91
|
filterFieldItemConfig.options = [
|
|
79
|
-
{ value: true, text: '是' },
|
|
80
|
-
{ value: false, text: '否' },
|
|
81
|
-
{ value: null, text: '空' },
|
|
92
|
+
{ value: true, text: '是', label: '是' },
|
|
93
|
+
{ value: false, text: '否', label: '否' },
|
|
94
|
+
{ value: null, text: '空', label: '空' },
|
|
82
95
|
];
|
|
83
96
|
filterFieldItemConfig.fieldCalculation.type = 'checkbox';
|
|
84
97
|
filterFieldItemConfig.fieldCalculation.value = 'in';
|
|
@@ -88,8 +101,9 @@ export const filterFieldsGenerate = (fields) => {
|
|
|
88
101
|
filterFieldItemConfig.options = i['x-enumObj'].map((enumItem) => ({
|
|
89
102
|
value: enumItem === null || enumItem === void 0 ? void 0 : enumItem.value,
|
|
90
103
|
text: enumItem === null || enumItem === void 0 ? void 0 : enumItem.label,
|
|
104
|
+
label: enumItem === null || enumItem === void 0 ? void 0 : enumItem.label,
|
|
91
105
|
}));
|
|
92
|
-
filterFieldItemConfig.options.push({ value: null, text: '空' });
|
|
106
|
+
filterFieldItemConfig.options.push({ value: null, text: '空', label: '空' });
|
|
93
107
|
}
|
|
94
108
|
if (i.format === 'x-enum') {
|
|
95
109
|
filterFieldItemConfig.fieldCalculation.value = 'eq';
|
|
@@ -99,17 +113,33 @@ export const filterFieldsGenerate = (fields) => {
|
|
|
99
113
|
filterFieldItemConfig.fieldCalculation.type = filterFieldItemConfig.xMultiSelect ? 'checkbox' : 'radio';
|
|
100
114
|
filterFieldItemConfig.fieldCalculation.value = filterFieldItemConfig.xMultiSelect ? 'in' : 'eq';
|
|
101
115
|
}
|
|
102
|
-
if (i.format === 'father-son' || i.format === 'related') {
|
|
116
|
+
if (NEW_SINGLE_RELATION_FORMATS.includes(i.format) || i.format === 'father-son' || i.format === 'related') {
|
|
103
117
|
filterFieldItemConfig.filterType = i.format;
|
|
104
118
|
filterFieldItemConfig.childDbName = (_b = i['x-parent']) === null || _b === void 0 ? void 0 : _b.parentDataSourceName;
|
|
119
|
+
filterFieldItemConfig.primaryColumn = (_d = (_c = i === null || i === void 0 ? void 0 : i.parentDatasource) === null || _c === void 0 ? void 0 : _c.schema) === null || _d === void 0 ? void 0 : _d['x-primary-column'];
|
|
105
120
|
filterFieldItemConfig.fieldCalculation.type = 'radio';
|
|
106
121
|
filterFieldItemConfig.fieldCalculation.value = 'eq';
|
|
107
122
|
}
|
|
123
|
+
if (NEW_MULTIPLE_RELATION_FORMATS.includes(i.format)) {
|
|
124
|
+
filterFieldItemConfig.filterType = i.format;
|
|
125
|
+
filterFieldItemConfig.childDbName = (_e = i['x-parent']) === null || _e === void 0 ? void 0 : _e.parentDataSourceName;
|
|
126
|
+
filterFieldItemConfig.primaryColumn = (_g = (_f = i === null || i === void 0 ? void 0 : i.parentDatasource) === null || _f === void 0 ? void 0 : _f.schema) === null || _g === void 0 ? void 0 : _g['x-primary-column'];
|
|
127
|
+
filterFieldItemConfig.fieldCalculation.type = 'checkbox';
|
|
128
|
+
filterFieldItemConfig.fieldCalculation.value = 'in';
|
|
129
|
+
}
|
|
130
|
+
if (i.format === 'x-area-code') {
|
|
131
|
+
filterFieldItemConfig.filterType = i.format;
|
|
132
|
+
filterFieldItemConfig.regionType = i['x-area-code-type'];
|
|
133
|
+
filterFieldItemConfig.fieldCalculation.type = 'string';
|
|
134
|
+
filterFieldItemConfig.fieldCalculation.value = 'search_ci';
|
|
135
|
+
}
|
|
108
136
|
const fieldCalculationOption = fieldCalculations[filterFieldItemConfig.fieldCalculation.type];
|
|
109
137
|
filterFieldItemConfig.fieldCalculationOption = fieldCalculationOption;
|
|
110
138
|
// 用户自定义配置
|
|
111
139
|
if (i === null || i === void 0 ? void 0 : i.filterConfig) {
|
|
112
|
-
|
|
140
|
+
// 配置关联关系展示其他字段,仅对关联关系筛选器有效
|
|
141
|
+
filterFieldItemConfig.primaryColumn = ((_h = i.filterConfig) === null || _h === void 0 ? void 0 : _h.relationFieldName) || filterFieldItemConfig.primaryColumn;
|
|
142
|
+
filterFieldItemConfig.value = (_k = (_j = i.filterConfig) === null || _j === void 0 ? void 0 : _j.value) !== null && _k !== void 0 ? _k : undefined;
|
|
113
143
|
// 默认计算方式
|
|
114
144
|
const customFieldCalculation = fieldCalculationOption === null || fieldCalculationOption === void 0 ? void 0 : fieldCalculationOption.find((option) => { var _a; return option.value === ((_a = i.filterConfig) === null || _a === void 0 ? void 0 : _a.filterType); });
|
|
115
145
|
filterFieldItemConfig.fieldCalculation = customFieldCalculation || filterFieldItemConfig.fieldCalculation;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { useState, useEffect, forwardRef } from 'react';
|
|
3
3
|
import { Row, Col, ConfigProvider, Drawer } from 'tea-component';
|
|
4
|
-
import {
|
|
4
|
+
import { dateCalculation } from '../../../../utils/date';
|
|
5
5
|
import isObjectEqual from '../../../../utils/isObjectEqual';
|
|
6
6
|
import { useConfig } from '../../../../utils/config-context';
|
|
7
7
|
import { FilterFieldItem } from './FilterFieldItem';
|
|
@@ -18,7 +18,7 @@ const getFilterConfig = (data) => data.map(({ name, label, value, fieldCalculati
|
|
|
18
18
|
}));
|
|
19
19
|
// 筛选表单
|
|
20
20
|
export const FilterFieldsPanel = forwardRef(function Comp(props, ref) {
|
|
21
|
-
const { filterFields, fetchData, openMobileFilter, setOpenMobileFilter, setFilterConfig } = props;
|
|
21
|
+
const { filterFields, fetchData, openMobileFilter, setOpenMobileFilter, setFilterConfig, supportManyRelated } = props;
|
|
22
22
|
const num = 2;
|
|
23
23
|
const maxlength = 3;
|
|
24
24
|
const { classPrefix } = useConfig();
|
|
@@ -58,7 +58,7 @@ export const FilterFieldsPanel = forwardRef(function Comp(props, ref) {
|
|
|
58
58
|
// 若筛选字段为number类型,且为范围选择时,只要有一个值则返回
|
|
59
59
|
return i.value[0] || i.value[1];
|
|
60
60
|
}
|
|
61
|
-
return
|
|
61
|
+
return i.value !== null && i.value !== undefined && i.value !== '';
|
|
62
62
|
});
|
|
63
63
|
// 为空不为空筛选条件
|
|
64
64
|
searchData.forEach((i) => {
|
|
@@ -107,14 +107,14 @@ export const FilterFieldsPanel = forwardRef(function Comp(props, ref) {
|
|
|
107
107
|
else {
|
|
108
108
|
searchValues.push({
|
|
109
109
|
key: i.name,
|
|
110
|
-
val:
|
|
110
|
+
val: i.value[0],
|
|
111
111
|
rel: 'gte',
|
|
112
112
|
});
|
|
113
113
|
searchValues.push({
|
|
114
114
|
key: i.name,
|
|
115
115
|
// @ts-ignore 兼容字符串和数字
|
|
116
116
|
// eslint-disable-next-line @typescript-eslint/no-magic-numbers
|
|
117
|
-
val:
|
|
117
|
+
val: i.value[1] + 999,
|
|
118
118
|
rel: 'lte',
|
|
119
119
|
});
|
|
120
120
|
}
|
|
@@ -140,7 +140,7 @@ export const FilterFieldsPanel = forwardRef(function Comp(props, ref) {
|
|
|
140
140
|
searchValues.push(searchItem);
|
|
141
141
|
}
|
|
142
142
|
else if (['date', 'datetime', 'time'].includes(i.filterType)) {
|
|
143
|
-
searchItem.val =
|
|
143
|
+
searchItem.val = i.value;
|
|
144
144
|
dateCalculation(searchItem, i.filterType).forEach((i) => {
|
|
145
145
|
searchValues.push(i);
|
|
146
146
|
});
|
|
@@ -151,6 +151,11 @@ export const FilterFieldsPanel = forwardRef(function Comp(props, ref) {
|
|
|
151
151
|
}
|
|
152
152
|
}
|
|
153
153
|
});
|
|
154
|
+
searchValues = searchValues.map((i) => {
|
|
155
|
+
var _a;
|
|
156
|
+
const format = (_a = filterValues.find((j) => j.name === i.key)) === null || _a === void 0 ? void 0 : _a.filterType;
|
|
157
|
+
return { ...i, format };
|
|
158
|
+
});
|
|
154
159
|
fetchData(searchValues);
|
|
155
160
|
};
|
|
156
161
|
const onFormSubmit = (e) => {
|
|
@@ -170,7 +175,7 @@ export const FilterFieldsPanel = forwardRef(function Comp(props, ref) {
|
|
|
170
175
|
useSetWidgetApi(() => ({ resetFilter }), [initFilterData], ref);
|
|
171
176
|
return (_jsxs(ConfigProvider, { classPrefix: "wedatea2td", children: [_jsx(Drawer, { className: `${classPrefix}-table-mobile-filter-drawer ${classPrefix}-table-wrap-filter ${classPrefix}-h5-table-wrap-filter`, title: "\u7B5B\u9009\u5668", visible: isH5 && openMobileFilter, onClose: () => {
|
|
172
177
|
setOpenMobileFilter(false);
|
|
173
|
-
}, children: _jsxs("div", { children: [_jsx("div", { className: `${classPrefix}-table-wrap-filter__body`, children: filterData === null || filterData === void 0 ? void 0 : filterData.map((i) => (_jsx(FilterFieldItem, { ...i, updateFilterData: updateFilterData, fields: filterFields }, i.id))) }), _jsx("div", { className: `${classPrefix}-table-wrap-filter__footer`, children: _jsxs("div", { className: `${classPrefix}-table-wrap-filter__btn`, children: [_jsx("div", { className: `${classPrefix}-table-wrap-filter__btn-item`, children: _jsx(WdButton, { theme: "primary", variant: "outline", size: "lg", text: "\u91CD\u7F6E", events: {
|
|
178
|
+
}, children: _jsxs("div", { children: [_jsx("div", { className: `${classPrefix}-table-wrap-filter__body`, children: filterData === null || filterData === void 0 ? void 0 : filterData.map((i) => (_jsx(FilterFieldItem, { ...i, updateFilterData: updateFilterData, fields: filterFields, supportManyRelated: supportManyRelated }, i.id))) }), _jsx("div", { className: `${classPrefix}-table-wrap-filter__footer`, children: _jsxs("div", { className: `${classPrefix}-table-wrap-filter__btn`, children: [_jsx("div", { className: `${classPrefix}-table-wrap-filter__btn-item`, children: _jsx(WdButton, { theme: "primary", variant: "outline", size: "lg", text: "\u91CD\u7F6E", events: {
|
|
174
179
|
tap: resetFilter,
|
|
175
180
|
} }) }), _jsx("div", { className: `${classPrefix}-table-wrap-filter__btn-item`, children: _jsx(WdButton, { theme: "primary", size: "lg", text: "\u786E\u5B9A", events: {
|
|
176
181
|
tap: () => {
|
|
@@ -179,7 +184,7 @@ export const FilterFieldsPanel = forwardRef(function Comp(props, ref) {
|
|
|
179
184
|
},
|
|
180
185
|
} }) })] }) })] }) }), !isH5 && !!filterData.length && (_jsx("form", { className: `${classPrefix}-table-wrap-filter`, onSubmit: onFormSubmit, children: _jsxs(Row, { gap: 20, verticalAlign: 'bottom', style: { justifyContent: 'space-between' }, children: [_jsx(_Fragment, { children: filterData === null || filterData === void 0 ? void 0 : filterData.map((i, index) => (_jsx(Col, { span: 6, style: {
|
|
181
186
|
display: `${index > num && collapse ? 'none' : 'block'}`,
|
|
182
|
-
}, children: _jsx(FilterFieldItem, { ...i, updateFilterData: updateFilterData, fields: filterFields }) }, i.id))) }), _jsx(Col, { span: 24, style: { flex: '1', textAlign: 'right' }, children: _jsxs("div", { className: `${classPrefix}-space`, children: [_jsx("div", { className: `${classPrefix}-space-item`, children: _jsx(WdButton, { size: "md", theme: "secondary", text: "\u91CD\u7F6E", events: {
|
|
187
|
+
}, children: _jsx(FilterFieldItem, { ...i, updateFilterData: updateFilterData, fields: filterFields, supportManyRelated: supportManyRelated }) }, i.id))) }), _jsx(Col, { span: 24, style: { flex: '1', textAlign: 'right' }, children: _jsxs("div", { className: `${classPrefix}-space`, children: [_jsx("div", { className: `${classPrefix}-space-item`, children: _jsx(WdButton, { size: "md", theme: "secondary", text: "\u91CD\u7F6E", events: {
|
|
183
188
|
tap: resetFilter,
|
|
184
189
|
} }) }), _jsxs("div", { className: `${classPrefix}-space-item`, children: [_jsx("input", { type: "submit", style: { display: 'none' } }), _jsx(WdButton, { size: "md", theme: "primary", text: "\u67E5\u8BE2", events: {
|
|
185
190
|
tap: () => {
|
|
@@ -2,6 +2,24 @@ export declare const getSlots: (props: any) => {
|
|
|
2
2
|
globalButton?: any;
|
|
3
3
|
};
|
|
4
4
|
export declare const whereList: (whereProxy: any) => any[];
|
|
5
|
+
export declare const getFilter: ({ wList, searchValues, searchConfig, conditionConfig, relatedSearchValues }: {
|
|
6
|
+
wList: any;
|
|
7
|
+
searchValues: any;
|
|
8
|
+
searchConfig?: any[];
|
|
9
|
+
conditionConfig?: any[];
|
|
10
|
+
relatedSearchValues: any;
|
|
11
|
+
}) => {
|
|
12
|
+
where: {};
|
|
13
|
+
relateWhere: {};
|
|
14
|
+
};
|
|
15
|
+
export declare const getSearchValues: (searchValues?: any[]) => {
|
|
16
|
+
commonSearchValue: {
|
|
17
|
+
[x: number]: {
|
|
18
|
+
[x: string]: any;
|
|
19
|
+
};
|
|
20
|
+
}[];
|
|
21
|
+
relatedSearchValues: any;
|
|
22
|
+
};
|
|
5
23
|
export declare const getQueryParams: ({ queryParams, wList, viewFieldsData, connectorParams, isModel, isViewTable, authFields, supportManyRelated, columns, selectFieldType, selectFields, isSupportMultipleSort, }: any) => {
|
|
6
24
|
pageNo: number;
|
|
7
25
|
pageSize: number;
|
|
@@ -3,6 +3,7 @@ import { TABLE_SLOT_PREFIX, GLOBAL_BUTTON, REL_DICT } from '../../../utils/const
|
|
|
3
3
|
import { callWedaApi, appCloudGetWedaUserId, getIsExitApi } from '../../../utils/tcb';
|
|
4
4
|
import { isObj, deepClone } from '../../../utils/tool';
|
|
5
5
|
import { errorHandler } from '../../../utils/error';
|
|
6
|
+
import { NEW_RELATION_FORMATS } from '../components/FilterFieldsPanel/filterFieldsGenerate';
|
|
6
7
|
// 新接口没有返回关联表的主列字段,从旧接口中查询出来
|
|
7
8
|
const getPrimaryColumn = (fields, dataViewPropertiesList, selectedView) => {
|
|
8
9
|
var _a, _b;
|
|
@@ -63,7 +64,7 @@ export const whereList = (whereProxy) => {
|
|
|
63
64
|
val = `^${val}`;
|
|
64
65
|
}
|
|
65
66
|
if ('_exclude' === rel) {
|
|
66
|
-
rel = '
|
|
67
|
+
rel = 'nsearch_ci';
|
|
67
68
|
}
|
|
68
69
|
rule['$' + rel] = val;
|
|
69
70
|
item2Result[item2 === null || item2 === void 0 ? void 0 : item2.key] = rule;
|
|
@@ -124,67 +125,68 @@ const selectParam = (columns, authFields, selectParam) => {
|
|
|
124
125
|
}
|
|
125
126
|
return select;
|
|
126
127
|
};
|
|
128
|
+
const isObject = (v) => v && typeof v === 'object' && !Array.isArray(v);
|
|
127
129
|
// 拼接filter参数
|
|
128
|
-
const getFilter = (wList, searchValues,
|
|
130
|
+
export const getFilter = ({ wList, searchValues, searchConfig = [], conditionConfig = [], relatedSearchValues }) => {
|
|
129
131
|
var _a, _b, _c;
|
|
130
|
-
let
|
|
131
|
-
let filter = { where: {} };
|
|
132
|
-
if ((_a = wList === null || wList === void 0 ? void 0 : wList.where) === null || _a === void 0 ? void 0 : _a.$or) {
|
|
133
|
-
const wListWhere = ((_b = wList === null || wList === void 0 ? void 0 : wList.where) === null || _b === void 0 ? void 0 : _b.$or) || [];
|
|
134
|
-
if ((wList === null || wList === void 0 ? void 0 : wList.constructor) === Object) {
|
|
135
|
-
where = [...SearchConfig, ...ConditionConfig, ...wListWhere];
|
|
136
|
-
filter = {
|
|
137
|
-
...wList,
|
|
138
|
-
where: {
|
|
139
|
-
$or: where,
|
|
140
|
-
},
|
|
141
|
-
};
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
else {
|
|
145
|
-
const wListWhere = ((_c = wList === null || wList === void 0 ? void 0 : wList.where) === null || _c === void 0 ? void 0 : _c.$and) || [];
|
|
146
|
-
if ((wList === null || wList === void 0 ? void 0 : wList.constructor) === Object) {
|
|
147
|
-
where = [...SearchConfig, ...ConditionConfig, ...wListWhere];
|
|
148
|
-
filter = {
|
|
149
|
-
...wList,
|
|
150
|
-
where: {
|
|
151
|
-
$and: where,
|
|
152
|
-
},
|
|
153
|
-
};
|
|
154
|
-
}
|
|
155
|
-
}
|
|
132
|
+
let filter = { where: {}, relateWhere: {} };
|
|
156
133
|
if (Array.isArray(wList)) {
|
|
157
|
-
|
|
134
|
+
// 兼容旧版筛选器传递的数据,没有relateWhere属性
|
|
135
|
+
filter.where = { $and: [...wList, ...searchConfig, ...conditionConfig] };
|
|
136
|
+
}
|
|
137
|
+
else if (isObject(wList)) {
|
|
138
|
+
const isOr = (_a = wList.where) === null || _a === void 0 ? void 0 : _a.$or;
|
|
139
|
+
const conditions = [...searchConfig, ...conditionConfig, ...(isOr ? wList.where.$or : ((_b = wList.where) === null || _b === void 0 ? void 0 : _b.$and) || [])];
|
|
158
140
|
filter = {
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
141
|
+
...filter,
|
|
142
|
+
...wList,
|
|
143
|
+
where: conditions.length
|
|
144
|
+
? {
|
|
145
|
+
[isOr ? '$or' : '$and']: conditions,
|
|
146
|
+
}
|
|
147
|
+
: {},
|
|
162
148
|
};
|
|
163
149
|
}
|
|
164
150
|
if (searchValues === null || searchValues === void 0 ? void 0 : searchValues.length) {
|
|
165
151
|
// 筛选面板的查询条件与数据过滤的查询条件是且的关系
|
|
166
|
-
filter = {
|
|
167
|
-
|
|
168
|
-
where: {
|
|
169
|
-
$and: [filter.where, { $and: searchValues }],
|
|
170
|
-
},
|
|
152
|
+
filter.where = {
|
|
153
|
+
$and: [filter.where, { $and: searchValues }],
|
|
171
154
|
};
|
|
172
155
|
}
|
|
156
|
+
if (relatedSearchValues && ((_c = Object.keys(relatedSearchValues)) === null || _c === void 0 ? void 0 : _c.length)) {
|
|
157
|
+
// 关联模型字段的查询条件与数据过滤的查询条件是且的关系,默认数据筛选的查询条件优先级更高
|
|
158
|
+
const _relateWhere = deepClone(filter.relateWhere);
|
|
159
|
+
Object.keys(relatedSearchValues).forEach((key) => {
|
|
160
|
+
_relateWhere[key] = _relateWhere[key] || { where: { $and: [] } };
|
|
161
|
+
_relateWhere[key].where.$and = [...(_relateWhere[key].where.$and || []), ...relatedSearchValues[key].where.$and];
|
|
162
|
+
});
|
|
163
|
+
filter.relateWhere = _relateWhere;
|
|
164
|
+
}
|
|
173
165
|
return filter;
|
|
174
166
|
};
|
|
175
167
|
// 拼接筛选条件参数
|
|
176
|
-
const getSearchValues = (searchValues) => {
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
};
|
|
187
|
-
|
|
168
|
+
export const getSearchValues = (searchValues = []) => {
|
|
169
|
+
// 1. 过滤无效条件(空值、缺失关键字段)
|
|
170
|
+
const isValidValue = (val) => val !== undefined && val !== null && val !== '' && !(Array.isArray(val) && val.length === 0);
|
|
171
|
+
const searchValuesList = (searchValues === null || searchValues === void 0 ? void 0 : searchValues.filter((item) => item.key && item.rel && isValidValue(item.val))) || [];
|
|
172
|
+
// 关联字段的特殊处理
|
|
173
|
+
const relatedSearchValues = searchValuesList
|
|
174
|
+
.filter((i) => NEW_RELATION_FORMATS.includes(i.format))
|
|
175
|
+
.reduce((acc, i) => {
|
|
176
|
+
const foreignKey = i.foreignKey || '_id'; // 默认使用 _id,可配置其他外键
|
|
177
|
+
const condition = { [foreignKey]: { [`$${i.rel}`]: i.val } };
|
|
178
|
+
acc[i.key] = acc[i.key] || { where: { $and: [] } };
|
|
179
|
+
acc[i.key].where.$and.push(condition);
|
|
180
|
+
return acc;
|
|
181
|
+
}, {});
|
|
182
|
+
// 普通字段的直接条件
|
|
183
|
+
const commonSearchValue = searchValuesList
|
|
184
|
+
.filter((i) => !NEW_RELATION_FORMATS.includes(i.format))
|
|
185
|
+
.map((item) => ({ [item.key]: { [`$${item.rel}`]: item.val } }));
|
|
186
|
+
return {
|
|
187
|
+
commonSearchValue,
|
|
188
|
+
relatedSearchValues,
|
|
189
|
+
};
|
|
188
190
|
};
|
|
189
191
|
const orderByFieldKey = (key, columns) => {
|
|
190
192
|
var _a;
|
|
@@ -234,21 +236,27 @@ export const getQueryParams = ({ queryParams, wList, viewFieldsData, connectorPa
|
|
|
234
236
|
const { orderBy, orderType } = queryParams;
|
|
235
237
|
const { viewList, selectedViewId } = viewFieldsData;
|
|
236
238
|
const viewed = viewList === null || viewList === void 0 ? void 0 : viewList.filter((item) => item.ViewId === selectedViewId)[0];
|
|
237
|
-
const
|
|
239
|
+
const searchConfig = (viewed === null || viewed === void 0 ? void 0 : viewed.SearchConfig) || [];
|
|
238
240
|
const searchValues = (queryParams === null || queryParams === void 0 ? void 0 : queryParams.searchValues) || [];
|
|
239
|
-
let
|
|
241
|
+
let conditionConfig;
|
|
240
242
|
if (supportManyRelated) {
|
|
241
|
-
|
|
242
|
-
const
|
|
243
|
-
params.filter = getFilter(
|
|
243
|
+
conditionConfig = (viewed === null || viewed === void 0 ? void 0 : viewed.ConditionConfig) ? [viewed === null || viewed === void 0 ? void 0 : viewed.ConditionConfig] : [];
|
|
244
|
+
const { relatedSearchValues, commonSearchValue } = getSearchValues(searchValues);
|
|
245
|
+
params.filter = getFilter({
|
|
246
|
+
wList,
|
|
247
|
+
searchValues: commonSearchValue,
|
|
248
|
+
relatedSearchValues,
|
|
249
|
+
searchConfig,
|
|
250
|
+
conditionConfig,
|
|
251
|
+
});
|
|
244
252
|
params.select = selectParam(columns, authFields, {
|
|
245
253
|
selectFieldType,
|
|
246
254
|
selectFields,
|
|
247
255
|
});
|
|
248
256
|
}
|
|
249
257
|
else {
|
|
250
|
-
|
|
251
|
-
params.where = [...searchValues, ...wList, ...
|
|
258
|
+
conditionConfig = (viewed === null || viewed === void 0 ? void 0 : viewed.ConditionConfig) || {};
|
|
259
|
+
params.where = [...searchValues, ...wList, ...searchConfig, conditionConfig];
|
|
252
260
|
}
|
|
253
261
|
// 如果视图里存在排序设置则以视图为主
|
|
254
262
|
if (isViewTable && (viewed === null || viewed === void 0 ? void 0 : viewed.sortItem)) {
|
|
@@ -184,7 +184,9 @@ export const WdTable = forwardRef(function TableComp(tableProps, ref) {
|
|
|
184
184
|
}));
|
|
185
185
|
}
|
|
186
186
|
// 筛选字段
|
|
187
|
-
const filterFieldsData =
|
|
187
|
+
const filterFieldsData = useMemo(() => {
|
|
188
|
+
return getFilterFields(filterFields, fields);
|
|
189
|
+
}, [fields, filterFields]);
|
|
188
190
|
const [filterConfig, setFilterConfig] = useState(() => {
|
|
189
191
|
return filterFieldsData.map((i) => (i === null || i === void 0 ? void 0 : i.filterConfig) || { name: i.name, label: i.title });
|
|
190
192
|
});
|
|
@@ -725,7 +727,7 @@ export const WdTable = forwardRef(function TableComp(tableProps, ref) {
|
|
|
725
727
|
};
|
|
726
728
|
const errorStatus = isError || fieldsError;
|
|
727
729
|
const errorMsg = isError ? errorObj : fieldsError;
|
|
728
|
-
return (_jsx(ConfigProvider, { classPrefix: classPrefix, children: _jsx(EnumHoc, { fields: authFields, children: _jsxs("div", { className: classNames(wrapClassList, className), style: style, id: id, children: [hasFilterButton && (_jsx(FilterFieldsPanel, { ref: filterMethodsRef, openMobileFilter: openMobileFilter, setOpenMobileFilter: setOpenMobileFilter, filterFields: filterFieldsData, fetchData: onFilterChange, setFilterConfig: setFilterConfig })), _jsxs("div", { className: `${classPrefix}-table-container`, children: [!isH5 && !isNoDataSourceBind && (_jsxs("div", { className: `${classPrefix}-table-wrap-toolbar`, children: [enableGlobalButton && (_jsx("div", { className: `${classPrefix}-table-wrap-toolbar__col ${classPrefix}-table-wrap-toolbar__col-start`, children: _jsx(GlobalButton, { classPrefix: classPrefix, slots: slots === null || slots === void 0 ? void 0 : slots.globalButton }) })), (enableRefreshBtn || enableTableHeightSizeBtn) && (_jsx("div", { className: `${classPrefix}-table-wrap-toolbar__col ${classPrefix}-table-wrap-toolbar__col-end`, children: _jsx(ToolBar, { hasFilterButton: hasFilterButton, total: total, refreshTable: onRefreshBtnClick, setTableHightSize: setTableHightSize, currentSize: tableHightSize, setOpenMobileFilter: () => {
|
|
730
|
+
return (_jsx(ConfigProvider, { classPrefix: classPrefix, children: _jsx(EnumHoc, { fields: authFields, children: _jsxs("div", { className: classNames(wrapClassList, className), style: style, id: id, children: [hasFilterButton && (_jsx(FilterFieldsPanel, { ref: filterMethodsRef, openMobileFilter: openMobileFilter, setOpenMobileFilter: setOpenMobileFilter, filterFields: filterFieldsData, fetchData: onFilterChange, setFilterConfig: setFilterConfig, supportManyRelated: supportManyRelated })), _jsxs("div", { className: `${classPrefix}-table-container`, children: [!isH5 && !isNoDataSourceBind && (_jsxs("div", { className: `${classPrefix}-table-wrap-toolbar`, children: [enableGlobalButton && (_jsx("div", { className: `${classPrefix}-table-wrap-toolbar__col ${classPrefix}-table-wrap-toolbar__col-start`, children: _jsx(GlobalButton, { classPrefix: classPrefix, slots: slots === null || slots === void 0 ? void 0 : slots.globalButton }) })), (enableRefreshBtn || enableTableHeightSizeBtn) && (_jsx("div", { className: `${classPrefix}-table-wrap-toolbar__col ${classPrefix}-table-wrap-toolbar__col-end`, children: _jsx(ToolBar, { hasFilterButton: hasFilterButton, total: total, refreshTable: onRefreshBtnClick, setTableHightSize: setTableHightSize, currentSize: tableHightSize, setOpenMobileFilter: () => {
|
|
729
731
|
setOpenMobileFilter(true);
|
|
730
732
|
}, enableRefreshBtn: enableRefreshBtn, enableTableHeightSizeBtn: enableTableHeightSizeBtn, enablePagination: enablePagination }) }))] })), isH5 && (enablePagination || enableRefreshBtn || enableTableHeightSizeBtn || hasFilterButton) && (_jsx(ToolBar, { hasFilterButton: hasFilterButton, total: total, refreshTable: onRefreshBtnClick, setTableHightSize: setTableHightSize, currentSize: tableHightSize, setOpenMobileFilter: () => {
|
|
731
733
|
setOpenMobileFilter(true);
|
package/package.json
CHANGED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export declare const getDataBaseInfo: (fields: any, format: any, childDbName: any) => any;
|
|
2
|
-
export declare const mapResult: (records: any, primaryColumn: any) => any;
|
|
3
|
-
export declare const useChooseList: ({ dataSourceAPI, queryParams, childDbName, primaryColumn, value, isInsertSelectedValue, }: {
|
|
4
|
-
dataSourceAPI: any;
|
|
5
|
-
queryParams: any;
|
|
6
|
-
childDbName: any;
|
|
7
|
-
primaryColumn: any;
|
|
8
|
-
value: any;
|
|
9
|
-
isInsertSelectedValue?: boolean;
|
|
10
|
-
}) => {
|
|
11
|
-
result: any[];
|
|
12
|
-
total: number;
|
|
13
|
-
isValidating: boolean;
|
|
14
|
-
empty: () => void;
|
|
15
|
-
getRelationOptions: () => Promise<void>;
|
|
16
|
-
};
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
import { useState, useEffect, useCallback } from 'react';
|
|
2
|
-
const defaultPage = 1;
|
|
3
|
-
const getUniqueOption = (option) => {
|
|
4
|
-
var _a;
|
|
5
|
-
const optionMap = option.reduce((acc, item) => {
|
|
6
|
-
if (!acc[item.value]) {
|
|
7
|
-
acc[item.value] = item;
|
|
8
|
-
}
|
|
9
|
-
return acc;
|
|
10
|
-
}, {});
|
|
11
|
-
const uniqueOption = (_a = Object.values(optionMap)) === null || _a === void 0 ? void 0 : _a.filter((item) => item === null || item === void 0 ? void 0 : item.value);
|
|
12
|
-
return uniqueOption;
|
|
13
|
-
};
|
|
14
|
-
const getDataBase = (format, fields) => {
|
|
15
|
-
const filter = fields.filter((item) => (item === null || item === void 0 ? void 0 : item.format) === format);
|
|
16
|
-
const data = filter === null || filter === void 0 ? void 0 : filter.map((item) => {
|
|
17
|
-
var _a, _b, _c;
|
|
18
|
-
const childDbName = (_a = item['x-parent']) === null || _a === void 0 ? void 0 : _a.parentDataSourceName;
|
|
19
|
-
const primaryColumn = (_c = (_b = item.parentDatasource) === null || _b === void 0 ? void 0 : _b.schema) === null || _c === void 0 ? void 0 : _c['x-primary-column'];
|
|
20
|
-
const childItem = {
|
|
21
|
-
childDbName,
|
|
22
|
-
primaryColumn,
|
|
23
|
-
};
|
|
24
|
-
return childItem;
|
|
25
|
-
});
|
|
26
|
-
return data;
|
|
27
|
-
};
|
|
28
|
-
export const getDataBaseInfo = (fields, format, childDbName) => {
|
|
29
|
-
var _a;
|
|
30
|
-
const FORMAT_FATHER_SON = 'father-son';
|
|
31
|
-
const FORMAT_RELATED = 'related';
|
|
32
|
-
const fatherSon = getDataBase(FORMAT_FATHER_SON, fields);
|
|
33
|
-
const related = getDataBase(FORMAT_RELATED, fields);
|
|
34
|
-
const dsList = [
|
|
35
|
-
{
|
|
36
|
-
format: FORMAT_FATHER_SON,
|
|
37
|
-
list: fatherSon,
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
format: FORMAT_RELATED,
|
|
41
|
-
list: related,
|
|
42
|
-
},
|
|
43
|
-
];
|
|
44
|
-
const dataBase = (_a = dsList === null || dsList === void 0 ? void 0 : dsList.find((child) => child.format === format)) === null || _a === void 0 ? void 0 : _a.list.find((item) => item.childDbName === childDbName);
|
|
45
|
-
return dataBase;
|
|
46
|
-
};
|
|
47
|
-
export const mapResult = (records, primaryColumn) => {
|
|
48
|
-
var _a;
|
|
49
|
-
return (_a = records === null || records === void 0 ? void 0 : records.filter((i) => i._id)) === null || _a === void 0 ? void 0 : _a.map((childItem) => ({
|
|
50
|
-
_id: childItem._id,
|
|
51
|
-
value: childItem._id,
|
|
52
|
-
text: childItem[primaryColumn] ? childItem[primaryColumn] : childItem._id,
|
|
53
|
-
label: childItem[primaryColumn] ? childItem[primaryColumn] : childItem._id,
|
|
54
|
-
extra: childItem,
|
|
55
|
-
}));
|
|
56
|
-
};
|
|
57
|
-
export const useChooseList = ({ dataSourceAPI, queryParams, childDbName, primaryColumn, value, isInsertSelectedValue = true, }) => {
|
|
58
|
-
const [option, setOption] = useState([]);
|
|
59
|
-
const [total, setTotal] = useState(0);
|
|
60
|
-
const [loading, setLoading] = useState(true);
|
|
61
|
-
const unshiftVal = (transformedRecords, itemResult, originOption) => {
|
|
62
|
-
if (itemResult &&
|
|
63
|
-
transformedRecords.findIndex((item) => item._id === itemResult._id) < 0 &&
|
|
64
|
-
originOption.findIndex((item) => item._id === itemResult._id) < 0) {
|
|
65
|
-
return [itemResult, ...transformedRecords];
|
|
66
|
-
}
|
|
67
|
-
return transformedRecords;
|
|
68
|
-
};
|
|
69
|
-
const fetchData = useCallback(async () => {
|
|
70
|
-
setLoading(true);
|
|
71
|
-
const isMultiple = Array.isArray(value);
|
|
72
|
-
const promiseList = [
|
|
73
|
-
dataSourceAPI.getRecordList(queryParams, {
|
|
74
|
-
db: childDbName,
|
|
75
|
-
}),
|
|
76
|
-
];
|
|
77
|
-
if (value && isInsertSelectedValue) {
|
|
78
|
-
if (isMultiple) {
|
|
79
|
-
value.forEach((i) => {
|
|
80
|
-
if (i) {
|
|
81
|
-
promiseList.push(dataSourceAPI.getRecord(i, {
|
|
82
|
-
db: childDbName,
|
|
83
|
-
}));
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
else {
|
|
88
|
-
promiseList.push(dataSourceAPI.getRecord(value, {
|
|
89
|
-
db: childDbName,
|
|
90
|
-
}));
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
const [result, ...rest] = await Promise.all(promiseList);
|
|
94
|
-
let transformedRecords = [...((result === null || result === void 0 ? void 0 : result.records) || [])];
|
|
95
|
-
const itemResult = [...rest];
|
|
96
|
-
// 若下拉列表中无选中值,则将选中值插到数组头部
|
|
97
|
-
if ((isMultiple && (value === null || value === void 0 ? void 0 : value.length) && isInsertSelectedValue) || (value && isInsertSelectedValue)) {
|
|
98
|
-
itemResult.forEach((i) => {
|
|
99
|
-
transformedRecords = unshiftVal(transformedRecords, i, option);
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
let optionRes = mapResult(transformedRecords, primaryColumn);
|
|
103
|
-
if ((queryParams === null || queryParams === void 0 ? void 0 : queryParams.pageNo) > defaultPage) {
|
|
104
|
-
optionRes = [...option, ...optionRes];
|
|
105
|
-
}
|
|
106
|
-
optionRes = getUniqueOption(optionRes);
|
|
107
|
-
setOption(optionRes);
|
|
108
|
-
setTotal(result === null || result === void 0 ? void 0 : result.total);
|
|
109
|
-
setLoading(false);
|
|
110
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
111
|
-
}, [childDbName, primaryColumn, queryParams, value]);
|
|
112
|
-
useEffect(() => {
|
|
113
|
-
if (childDbName) {
|
|
114
|
-
fetchData();
|
|
115
|
-
}
|
|
116
|
-
}, [childDbName, fetchData]);
|
|
117
|
-
return {
|
|
118
|
-
result: option || [],
|
|
119
|
-
total: total,
|
|
120
|
-
isValidating: loading,
|
|
121
|
-
empty: () => {
|
|
122
|
-
setOption([]);
|
|
123
|
-
},
|
|
124
|
-
getRelationOptions: fetchData,
|
|
125
|
-
};
|
|
126
|
-
};
|