@cloudbase/weda-ui 3.17.6 → 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.
Files changed (38) hide show
  1. package/dist/configs/components/wd-select-multiple.d.ts +2 -0
  2. package/dist/configs/components/wd-select-multiple.js +4 -2
  3. package/dist/configs/components/wd-select.d.ts +2 -0
  4. package/dist/configs/components/wd-select.js +4 -2
  5. package/dist/configs/components/wd-table.js +1 -1
  6. package/dist/configs/index.d.ts +4 -0
  7. package/dist/configs/type-utils/type-form.d.ts +2 -0
  8. package/dist/configs/type-utils/type-form.js +32 -4
  9. package/dist/style/index.css +14 -3
  10. package/dist/style/index.scss +1 -1
  11. package/dist/style/weda-ui.min.css +5 -5
  12. package/dist/web/components/form/uploader/upload/index.js +4 -0
  13. package/dist/web/components/wd-input/wd-input.js +2 -2
  14. package/dist/web/components/wd-select/hooks/useChooseList.js +5 -3
  15. package/dist/web/components/wd-select/relationSelect/index.js +2 -7
  16. package/dist/web/components/wd-select/relationSelect/relationSelect.js +6 -4
  17. package/dist/web/components/wd-select/select/index.js +9 -3
  18. package/dist/web/components/wd-select/select/selectUI.js +1 -1
  19. package/dist/web/components/wd-select/style.d.ts +0 -2
  20. package/dist/web/components/wd-select/style.js +2 -2
  21. package/dist/web/components/wd-select/wd-select.js +4 -7
  22. package/dist/web/components/wd-select-multiple/wd-select-multiple.js +4 -4
  23. package/dist/web/components/wd-table/components/FilterFieldsPanel/Fields.d.ts +3 -3
  24. package/dist/web/components/wd-table/components/FilterFieldsPanel/Fields.js +51 -50
  25. package/dist/web/components/wd-table/components/FilterFieldsPanel/FilterFieldItem.d.ts +2 -1
  26. package/dist/web/components/wd-table/components/FilterFieldsPanel/FilterFieldItem.js +18 -8
  27. package/dist/web/components/wd-table/components/FilterFieldsPanel/SelectSearch.d.ts +5 -3
  28. package/dist/web/components/wd-table/components/FilterFieldsPanel/SelectSearch.js +20 -41
  29. package/dist/web/components/wd-table/components/FilterFieldsPanel/filterFieldsGenerate.d.ts +7 -0
  30. package/dist/web/components/wd-table/components/FilterFieldsPanel/filterFieldsGenerate.js +44 -14
  31. package/dist/web/components/wd-table/components/FilterFieldsPanel/index.js +13 -8
  32. package/dist/web/components/wd-table/utils/index.d.ts +18 -0
  33. package/dist/web/components/wd-table/utils/index.js +64 -56
  34. package/dist/web/components/wd-table/wd-table.js +4 -2
  35. package/dist/web/weda-ui.css +28 -63
  36. package/package.json +1 -1
  37. package/dist/web/components/wd-table/hooks/useChooseList.d.ts +0 -16
  38. 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: 'exclude' },
20
+ { text: '不包含', value: 'nsearch_ci' },
17
21
  { text: '等于', value: 'eq' },
18
22
  { text: '不等于', value: 'neq' },
19
- { text: '开头是', value: 'startWith' },
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.format) === 'father-son' && (field === null || field === void 0 ? void 0 : field.default) === '') ||
51
- (field === null || field === void 0 ? void 0 : field.type) === 'object' ||
52
- (field === null || field === void 0 ? void 0 : field.format) === 'x-file' ||
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
- filterFieldItemConfig.value = ((_c = i.filterConfig) === null || _c === void 0 ? void 0 : _c.value) || '';
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 { formatDateToNumber, dateCalculation } from '../../../../utils/date';
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 !!(i.value && i.value.length);
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: formatDateToNumber(i.filterType, i.value[0]),
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: formatDateToNumber(i.filterType, i.value[1]) + 999,
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 = formatDateToNumber(i.filterType, i.value);
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 = 'nsearch';
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, SearchConfig, ConditionConfig) => {
130
+ export const getFilter = ({ wList, searchValues, searchConfig = [], conditionConfig = [], relatedSearchValues }) => {
129
131
  var _a, _b, _c;
130
- let where = [];
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
- where = [...wList, ...SearchConfig, ...ConditionConfig];
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
- where: {
160
- $and: where,
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
- ...filter,
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
- return searchValues.map((item) => {
178
- const obj = {};
179
- const exp = {};
180
- if (item.val !== undefined && item.key !== undefined && item.rel !== undefined) {
181
- exp[`$${item.rel}`] = item.val;
182
- obj[item.key] = exp;
183
- }
184
- return {
185
- ...obj,
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 SearchConfig = (viewed === null || viewed === void 0 ? void 0 : viewed.SearchConfig) || [];
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 ConditionConfig;
241
+ let conditionConfig;
240
242
  if (supportManyRelated) {
241
- ConditionConfig = (viewed === null || viewed === void 0 ? void 0 : viewed.ConditionConfig) ? [viewed === null || viewed === void 0 ? void 0 : viewed.ConditionConfig] : [];
242
- const formatSearchValues = getSearchValues(searchValues);
243
- params.filter = getFilter(wList, formatSearchValues, SearchConfig, ConditionConfig);
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
- ConditionConfig = (viewed === null || viewed === void 0 ? void 0 : viewed.ConditionConfig) || {};
251
- params.where = [...searchValues, ...wList, ...SearchConfig, ConditionConfig];
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 = getFilterFields(filterFields, fields);
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);
@@ -237,67 +237,50 @@ body .weda-ui {
237
237
  .weda-ui.gsd-h5-react-formitem.weda-ui-to-wd .wedatea2td-input::placeholder {
238
238
  color: var(--wd-color-text-placeholder);
239
239
  }
240
- .weda-ui.gsd-h5-react-formitem.weda-ui-to-wd
241
- .weui-input::-webkit-input-placeholder,
242
- .weda-ui.gsd-h5-react-formitem.weda-ui-to-wd
243
- .wedatea2td-input::-webkit-input-placeholder {
240
+ .weda-ui.gsd-h5-react-formitem.weda-ui-to-wd .weui-input::-webkit-input-placeholder,
241
+ .weda-ui.gsd-h5-react-formitem.weda-ui-to-wd .wedatea2td-input::-webkit-input-placeholder {
244
242
  color: var(--wd-color-text-placeholder);
245
243
  }
246
244
  .weda-ui.gsd-h5-react-formitem.weda-ui-to-wd .weui-input:-moz-placeholder,
247
- .weda-ui.gsd-h5-react-formitem.weda-ui-to-wd
248
- .wedatea2td-input:-moz-placeholder {
245
+ .weda-ui.gsd-h5-react-formitem.weda-ui-to-wd .wedatea2td-input:-moz-placeholder {
249
246
  color: var(--wd-color-text-placeholder);
250
247
  }
251
248
  .weda-ui.gsd-h5-react-formitem.weda-ui-to-wd .weui-input::-moz-placeholder,
252
- .weda-ui.gsd-h5-react-formitem.weda-ui-to-wd
253
- .wedatea2td-input::-moz-placeholder {
249
+ .weda-ui.gsd-h5-react-formitem.weda-ui-to-wd .wedatea2td-input::-moz-placeholder {
254
250
  color: var(--wd-color-text-placeholder);
255
251
  }
256
252
  .weda-ui.gsd-h5-react-formitem.weda-ui-to-wd .weui-input:-ms-input-placeholder,
257
- .weda-ui.gsd-h5-react-formitem.weda-ui-to-wd
258
- .wedatea2td-input:-ms-input-placeholder {
253
+ .weda-ui.gsd-h5-react-formitem.weda-ui-to-wd .wedatea2td-input:-ms-input-placeholder {
259
254
  color: var(--wd-color-text-placeholder);
260
255
  }
261
- .weda-ui.gsd-h5-react-formitem.weda-ui-to-wd
262
- .form-select-pc
263
- .wedatea2td-text-weak {
256
+ .weda-ui.gsd-h5-react-formitem.weda-ui-to-wd .form-select-pc .wedatea2td-text-weak {
264
257
  color: var(--wd-color-text-placeholder) !important;
265
258
  }
266
259
  /* pc 字体 */
267
260
  .weda-ui.gsd-h5-react-formitem.weda-ui-to-wd .wedatea2td-input,
268
261
  .weda-ui.gsd-h5-react-formitem.weda-ui-to-wd .wedatea2td-textarea,
269
262
  .weda-ui.gsd-h5-react-formitem.weda-ui-to-wd .wedatea2td-textarea-group,
270
- .weda-ui.gsd-h5-react-formitem.weda-ui-to-wd
271
- .form-select-pc
272
- .wedatea2td-dropdown__header {
263
+ .weda-ui.gsd-h5-react-formitem.weda-ui-to-wd .form-select-pc .wedatea2td-dropdown__header {
273
264
  font: inherit;
274
265
  }
275
266
  .weda-ui.gsd-h5-react-formitem.weda-ui-to-wd .wedatea2td-input,
276
- .weda-ui.gsd-h5-react-formitem.weda-ui-to-wd
277
- .form-select-pc
278
- .wedatea2td-dropdown__header {
267
+ .weda-ui.gsd-h5-react-formitem.weda-ui-to-wd .form-select-pc .wedatea2td-dropdown__header {
279
268
  height: var(--wd-form-item-height-md);
280
269
  }
281
- .weda-ui.gsd-h5-react-formitem.weda-ui-to-wd
282
- .form-select-pc
283
- .wedatea2td-dropdown__header
284
- .wedatea2td-dropdown__value {
270
+ .weda-ui.gsd-h5-react-formitem.weda-ui-to-wd .form-select-pc .wedatea2td-dropdown__header .wedatea2td-dropdown__value {
285
271
  font: inherit;
286
272
  line-height: var(--wd-form-item-height-md);
287
273
  }
288
274
  /* h5 外边框 */
289
275
  .weui-cells__group_form .weui-cells::before,
290
- .weda-ui.gsd-h5-react-formitem.weda-ui-to-wd.wa-comp-CLOUDBASE_STANDARD-FormItem
291
- .weui-cells::before {
276
+ .weda-ui.gsd-h5-react-formitem.weda-ui-to-wd.wa-comp-CLOUDBASE_STANDARD-FormItem .weui-cells::before {
292
277
  border-top-color: transparent;
293
278
  left: 0;
294
279
  right: 0;
295
280
  }
296
281
  .weui-cells__group_form .weui-cells::after,
297
- .weda-ui.gsd-h5-react-formitem.weda-ui-to-wd.wa-comp-CLOUDBASE_STANDARD-FormItem
298
- .weui-cells::after {
299
- border-bottom: var(--wd-form-item-border-width) solid
300
- var(--wd-form-item-border-color);
282
+ .weda-ui.gsd-h5-react-formitem.weda-ui-to-wd.wa-comp-CLOUDBASE_STANDARD-FormItem .weui-cells::after {
283
+ border-bottom: var(--wd-form-item-border-width) solid var(--wd-form-item-border-color);
301
284
  left: 0;
302
285
  right: 0;
303
286
  transform: none;
@@ -315,8 +298,7 @@ body .weda-ui {
315
298
  padding-right: 0;
316
299
  margin-right: var(--wd-form-item-label-mr);
317
300
  }
318
- .weda-ui.gsd-h5-react-formitem.weda-ui-to-wd.form-detail-wrap.pc-form-detail-wrap
319
- .form-detail-group-label-container {
301
+ .weda-ui.gsd-h5-react-formitem.weda-ui-to-wd.form-detail-wrap.pc-form-detail-wrap .form-detail-group-label-container {
320
302
  width: 98px;
321
303
  }
322
304
  /* 旧版组件支持表单容器垂直布局 */
@@ -334,28 +316,21 @@ body .weda-ui {
334
316
  flex-direction: column;
335
317
  }
336
318
  .wedatea2td-form--vertical .wd-form--horizontal-left .wd-form-item-wrap,
337
- .wedatea2td-form--vertical
338
- .wd-form-item.wd-form-item--horizontal-left
339
- .wd-form-item-wrap,
319
+ .wedatea2td-form--vertical .wd-form-item.wd-form-item--horizontal-left .wd-form-item-wrap,
340
320
  .wedatea2td-form--vertical .wd-form--horizontal-right .wd-form-item-wrap,
341
- .wedatea2td-form--vertical
342
- .wd-form-item.wd-form-item--horizontal-right
343
- .wd-form-item-wrap {
321
+ .wedatea2td-form--vertical .wd-form-item.wd-form-item--horizontal-right .wd-form-item-wrap {
344
322
  flex-direction: column;
345
323
  }
346
324
  /* h5 两边间距 */
347
- .weda-ui.gsd-h5-react-formitem.weda-ui-to-wd.wa-comp-CLOUDBASE_STANDARD-FormItem
348
- > .weda-ui {
325
+ .weda-ui.gsd-h5-react-formitem.weda-ui-to-wd.wa-comp-CLOUDBASE_STANDARD-FormItem > .weda-ui {
349
326
  padding-left: var(--wd-form-item-pd);
350
327
  padding-right: var(--wd-form-item-pd);
351
328
  }
352
- .weda-ui.gsd-h5-react-formitem.weda-ui-to-wd.wa-comp-CLOUDBASE_STANDARD-FormItem
353
- > .weda-ui.wedatea2td-form__item {
329
+ .weda-ui.gsd-h5-react-formitem.weda-ui-to-wd.wa-comp-CLOUDBASE_STANDARD-FormItem > .weda-ui.wedatea2td-form__item {
354
330
  padding-left: 0;
355
331
  padding-right: 0;
356
332
  }
357
- .weda-ui.gsd-h5-react-formitem.weda-ui-to-wd.form-detail-wrap.pc-form-detail-wrap
358
- .form-detail-group-parent-container {
333
+ .weda-ui.gsd-h5-react-formitem.weda-ui-to-wd.form-detail-wrap.pc-form-detail-wrap .form-detail-group-parent-container {
359
334
  width: calc(100% - 102px);
360
335
  padding-left: 0;
361
336
  padding-right: 0;
@@ -366,25 +341,17 @@ body .weda-ui {
366
341
  color: var(--wd-color-text-error);
367
342
  margin-left: 0;
368
343
  }
369
- .weda-ui.gsd-h5-react-formitem.weda-ui-to-wd
370
- .wedatea2td-form__item
371
- .wedatea2td-form__label.is-required
372
- label::after {
344
+ .weda-ui.gsd-h5-react-formitem.weda-ui-to-wd .wedatea2td-form__item .wedatea2td-form__label.is-required label::after {
373
345
  content: '';
374
346
  display: none;
375
347
  }
376
- .weda-ui.gsd-h5-react-formitem.weda-ui-to-wd
377
- .wedatea2td-form__item
378
- .wedatea2td-form__label.is-required
379
- label::before {
348
+ .weda-ui.gsd-h5-react-formitem.weda-ui-to-wd .wedatea2td-form__item .wedatea2td-form__label.is-required label::before {
380
349
  content: '*';
381
350
  color: var(--wd-color-text-error);
382
351
  margin-right: var(--wd-space-base);
383
352
  }
384
353
  /* h5 垂直时 */
385
- .weda-ui.gsd-h5-react-formitem.weda-ui-to-wd.wa-comp-CLOUDBASE_STANDARD-FormItem
386
- .weda-formcells
387
- .weda-formcells__label,
354
+ .weda-ui.gsd-h5-react-formitem.weda-ui-to-wd.wa-comp-CLOUDBASE_STANDARD-FormItem .weda-formcells .weda-formcells__label,
388
355
  .weda-ui.gsd-h5-react-formitem.weda-ui-to-wd.wa-comp-CLOUDBASE_STANDARD-FormItem
389
356
  .weda-formcells
390
357
  .weda-formcells__content
@@ -395,11 +362,8 @@ body .weda-ui {
395
362
  .weda-ui.gsd-h5-react-formitem.weda-ui-to-wd.wa-comp-CLOUDBASE_STANDARD-FormItem
396
363
  .weui-uploader.vertical
397
364
  .weui-uploader__bd,
398
- .weda-ui.gsd-h5-react-formitem.weda-ui-to-wd.wa-comp-CLOUDBASE_STANDARD-FormItem
399
- .weda-upload-file-mobile
400
- .vertical,
401
- .weda-ui.gsd-h5-react-formitem.weda-ui-to-wd.wa-comp-CLOUDBASE_STANDARD-FormItem
402
- .form-location-con_vertical {
365
+ .weda-ui.gsd-h5-react-formitem.weda-ui-to-wd.wa-comp-CLOUDBASE_STANDARD-FormItem .weda-upload-file-mobile .vertical,
366
+ .weda-ui.gsd-h5-react-formitem.weda-ui-to-wd.wa-comp-CLOUDBASE_STANDARD-FormItem .form-location-con_vertical {
403
367
  padding-left: 0;
404
368
  }
405
369
  /* ios safari 特别是小屏幕 iphone SE 之流
@@ -479,10 +443,7 @@ NED }}}
479
443
  background-color: unset;
480
444
  }
481
445
 
482
- .wd-form-item.wd-pc-form-item
483
- .wd-form-item-wrap
484
- .wedatea2td-dropdown-btn
485
- .wedatea2td-dropdown__value {
446
+ .wd-form-item.wd-pc-form-item .wd-form-item-wrap .wedatea2td-dropdown-btn .wedatea2td-dropdown__value {
486
447
  line-height: inherit;
487
448
  font-size: inherit;
488
449
  }
@@ -548,3 +509,7 @@ NED }}}
548
509
  }
549
510
 
550
511
  /* 事件样式 end */
512
+
513
+ .wd-form-item input:disabled {
514
+ -webkit-text-fill-color: unset;
515
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudbase/weda-ui",
3
- "version": "3.17.6",
3
+ "version": "3.18.0",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index",
6
6
  "miniprogram": "mpdist",
@@ -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
- };