@cloudbase/weda-ui 3.13.0 → 3.13.2
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 +14 -0
- package/dist/configs/components/wd-select-multiple.js +18 -1
- package/dist/configs/components/wd-select.d.ts +9 -4
- package/dist/configs/components/wd-select.js +11 -2
- package/dist/configs/components/wd-store-product.d.ts +1 -1
- package/dist/configs/components/wd-store-product.js +1 -1
- package/dist/configs/components/wd-table.d.ts +2 -0
- package/dist/configs/components/wd-table.js +7 -0
- package/dist/configs/components/wd-upload-image.d.ts +7 -2
- package/dist/configs/components/wd-upload-image.js +40 -6
- package/dist/configs/index.d.ts +60 -14
- package/dist/configs/type-utils/classes.js +1 -1
- package/dist/configs/type-utils/type-form.d.ts +2 -0
- package/dist/configs/type-utils/type-form.js +25 -7
- package/dist/configs/type-utils/x-runtime-default.d.ts +1 -0
- package/dist/configs/type-utils/x-runtime-default.js +1 -0
- package/dist/style/weda-ui.min.css +2 -2
- package/dist/web/components/echart/echart.js +3 -4
- package/dist/web/components/form/uploader/uploader.h5.js +14 -17
- package/dist/web/components/form/uploader/uploader.pc.js +3 -3
- package/dist/web/components/wd-form-item/wd-form-item-read-only.d.ts +1 -0
- package/dist/web/components/wd-form-item/wd-form-item-read-only.js +2 -2
- package/dist/web/components/wd-location/wd-location.css +7 -10
- package/dist/web/components/wd-location/wd-location.js +4 -0
- package/dist/web/components/wd-select/relationSelect/relationSelect.js +12 -4
- package/dist/web/components/wd-select/select/selectUI.js +12 -8
- package/dist/web/components/wd-select/wd-select.css +12 -22
- package/dist/web/components/wd-select/wd-select.js +2 -2
- package/dist/web/components/wd-select-multiple/wd-select-multiple.js +2 -2
- package/dist/web/components/wd-store-home/index.d.ts +3 -3
- package/dist/web/components/wd-store-home/index.js +8 -2
- package/dist/web/components/wd-store-product/index.d.ts +3 -3
- package/dist/web/components/wd-store-product/index.js +8 -2
- package/dist/web/components/wd-table/components/FieldRender/index.d.ts +3 -3
- package/dist/web/components/wd-table/components/FieldRender/index.js +31 -46
- package/dist/web/components/wd-table/hooks/useChooseList.d.ts +2 -1
- package/dist/web/components/wd-table/hooks/useChooseList.js +17 -4
- package/dist/web/components/wd-table/wd-table.js +6 -3
- package/dist/web/utils/moment.js +3 -0
- package/package.json +4 -4
|
@@ -39,7 +39,7 @@ export const TextWrap = React.memo(function TextWrapComp(props) {
|
|
|
39
39
|
export function getFieldRender(field = {}, extra = {}) {
|
|
40
40
|
var _a;
|
|
41
41
|
const { type, format, items, properties, title, parentDatasource } = field;
|
|
42
|
-
const { modelType, showTip = true, detailText = '详情', isH5, showRelationWithTag = true
|
|
42
|
+
const { modelType, showTip = true, detailText = '详情', isH5, showRelationWithTag = true } = extra;
|
|
43
43
|
const textProps = { showTip };
|
|
44
44
|
// 枚举-旧,新版 TODO
|
|
45
45
|
if ((_a = field['x-enumObj']) === null || _a === void 0 ? void 0 : _a.length) {
|
|
@@ -81,7 +81,7 @@ export function getFieldRender(field = {}, extra = {}) {
|
|
|
81
81
|
properties: locationProperties,
|
|
82
82
|
},
|
|
83
83
|
};
|
|
84
|
-
return
|
|
84
|
+
return _jsx(ArrayComponent, { isH5: isH5, value: value, modelType: modelType, field: locationField, items: items });
|
|
85
85
|
}
|
|
86
86
|
if (modelType === 'table') {
|
|
87
87
|
const content = (_a = formatLocationData(val)) === null || _a === void 0 ? void 0 : _a.flatContent;
|
|
@@ -115,10 +115,9 @@ export function getFieldRender(field = {}, extra = {}) {
|
|
|
115
115
|
}
|
|
116
116
|
else if (format === 'x-file') {
|
|
117
117
|
// 文件
|
|
118
|
-
return
|
|
118
|
+
return _jsx(UploaderFileView, { value: fieldValue, single: (extra === null || extra === void 0 ? void 0 : extra.modelType) !== 'detail' });
|
|
119
119
|
}
|
|
120
|
-
else if (!(extra === null || extra === void 0 ? void 0 : extra.supportManyRelated) &&
|
|
121
|
-
isShowOrgsView(field, modelType)) {
|
|
120
|
+
else if (!(extra === null || extra === void 0 ? void 0 : extra.supportManyRelated) && isShowOrgsView(field, modelType)) {
|
|
122
121
|
return (_jsx(ViewCell, { data: fieldValue, showType: modelType,
|
|
123
122
|
// type={field['x-parent']?.parentDataSourceName === 'sys_department' ? 'org' : 'user'}
|
|
124
123
|
relation: extra === null || extra === void 0 ? void 0 : extra.relation }));
|
|
@@ -131,15 +130,14 @@ export function getFieldRender(field = {}, extra = {}) {
|
|
|
131
130
|
// 网址
|
|
132
131
|
return (_jsx("a", { className: "wd-table__a", target: "_blank", href: fieldValue, rel: "noreferrer", children: _jsx(TextWrap, { ...textProps, children: fieldValue }) }));
|
|
133
132
|
}
|
|
134
|
-
else if ((extra === null || extra === void 0 ? void 0 : extra.supportManyRelated) &&
|
|
135
|
-
(format === 'father-son' || format === 'related')) {
|
|
133
|
+
else if ((extra === null || extra === void 0 ? void 0 : extra.supportManyRelated) && (format === 'father-son' || format === 'related')) {
|
|
136
134
|
const primaryField = ((_b = (_a = field === null || field === void 0 ? void 0 : field.parentDatasource) === null || _a === void 0 ? void 0 : _a.schema) === null || _b === void 0 ? void 0 : _b['x-primary-column']) || '';
|
|
137
135
|
const relatedField = (_c = extra === null || extra === void 0 ? void 0 : extra.columnSet) === null || _c === void 0 ? void 0 : _c.relatedField;
|
|
138
136
|
if (!showRelationWithTag) {
|
|
139
137
|
if (typeof fieldValue === 'string') {
|
|
140
138
|
return _jsx(TextWrap, { ...textProps, children: fieldValue });
|
|
141
139
|
}
|
|
142
|
-
return
|
|
140
|
+
return _jsx(TextWrap, { ...textProps, children: fieldValue[relatedField] || fieldValue[primaryField] || '-' });
|
|
143
141
|
}
|
|
144
142
|
if (typeof fieldValue === 'string') {
|
|
145
143
|
return fieldValue && fieldValue !== '-' ? (_jsx(WdTag, { range: fieldValue === null || fieldValue === void 0 ? void 0 : fieldValue.split(',').map((i) => ({
|
|
@@ -167,6 +165,10 @@ export function getFieldRender(field = {}, extra = {}) {
|
|
|
167
165
|
}
|
|
168
166
|
else if (type === 'number') {
|
|
169
167
|
fieldValue = formatNumber(val, field);
|
|
168
|
+
if (Object.prototype.hasOwnProperty.call(val, '$date')) {
|
|
169
|
+
field.format = 'datetime';
|
|
170
|
+
fieldValue = formatNumber(val.$date, field);
|
|
171
|
+
}
|
|
170
172
|
return _jsx(TextWrap, { children: fieldValue });
|
|
171
173
|
}
|
|
172
174
|
else if (type === 'boolean') {
|
|
@@ -176,7 +178,7 @@ export function getFieldRender(field = {}, extra = {}) {
|
|
|
176
178
|
else if (type === 'object') {
|
|
177
179
|
const objectRender = ({ value, modelType, fields }) => {
|
|
178
180
|
if (typeof val === 'object') {
|
|
179
|
-
return
|
|
181
|
+
return _jsx(DataItemView, { value: value, modelType: modelType, fields: fields, isH5: isH5 });
|
|
180
182
|
}
|
|
181
183
|
return _jsx(TextWrap, { ...textProps, children: value });
|
|
182
184
|
};
|
|
@@ -194,14 +196,12 @@ export function getFieldRender(field = {}, extra = {}) {
|
|
|
194
196
|
fields: properties,
|
|
195
197
|
});
|
|
196
198
|
}
|
|
197
|
-
else if (format === 'many-one' ||
|
|
198
|
-
format === 'one-one' ||
|
|
199
|
-
format === 'one-one-r') {
|
|
199
|
+
else if (format === 'many-one' || format === 'one-one' || format === 'one-one-r') {
|
|
200
200
|
const primaryField = ((_e = (_d = field === null || field === void 0 ? void 0 : field.parentDatasource) === null || _d === void 0 ? void 0 : _d.schema) === null || _e === void 0 ? void 0 : _e['x-primary-column']) || '';
|
|
201
201
|
const relatedField = (_f = extra === null || extra === void 0 ? void 0 : extra.columnSet) === null || _f === void 0 ? void 0 : _f.relatedField;
|
|
202
202
|
const _readValue = fieldValue[relatedField] || fieldValue[primaryField];
|
|
203
203
|
if (!showRelationWithTag) {
|
|
204
|
-
return
|
|
204
|
+
return _jsx(TextWrap, { ...textProps, children: fieldValue[relatedField] || fieldValue[primaryField] });
|
|
205
205
|
}
|
|
206
206
|
return _readValue ? (_jsx(WdTag, { range: _readValue === null || _readValue === void 0 ? void 0 : _readValue.split(',').map((i) => ({
|
|
207
207
|
label: i,
|
|
@@ -219,8 +219,7 @@ export function getFieldRender(field = {}, extra = {}) {
|
|
|
219
219
|
}
|
|
220
220
|
}
|
|
221
221
|
else if (type === 'array') {
|
|
222
|
-
if (field.name === '_departmentList' &&
|
|
223
|
-
['table', 'detail'].includes(modelType)) {
|
|
222
|
+
if (field.name === '_departmentList' && ['table', 'detail'].includes(modelType)) {
|
|
224
223
|
return _jsx(TextWrap, { ...textProps, children: val || '-' });
|
|
225
224
|
}
|
|
226
225
|
if (format === 'x-enum') {
|
|
@@ -243,8 +242,7 @@ export function getFieldRender(field = {}, extra = {}) {
|
|
|
243
242
|
// 文件数组,在详情页和表格页展示不同
|
|
244
243
|
return _jsx(UploaderFileView, { value: fieldValue, single: false });
|
|
245
244
|
}
|
|
246
|
-
else if ((extra === null || extra === void 0 ? void 0 : extra.supportManyRelated) &&
|
|
247
|
-
(format === 'one-many' || format === 'many-many')) {
|
|
245
|
+
else if ((extra === null || extra === void 0 ? void 0 : extra.supportManyRelated) && (format === 'one-many' || format === 'many-many')) {
|
|
248
246
|
const primaryField = ((_h = (_g = field === null || field === void 0 ? void 0 : field.parentDatasource) === null || _g === void 0 ? void 0 : _g.schema) === null || _h === void 0 ? void 0 : _h['x-primary-column']) || '';
|
|
249
247
|
const relatedField = (_j = extra === null || extra === void 0 ? void 0 : extra.columnSet) === null || _j === void 0 ? void 0 : _j.relatedField;
|
|
250
248
|
const rowId = extra === null || extra === void 0 ? void 0 : extra.rowId;
|
|
@@ -252,8 +250,7 @@ export function getFieldRender(field = {}, extra = {}) {
|
|
|
252
250
|
const propertyArr = Object.keys(properties);
|
|
253
251
|
const relatedKey = propertyArr.find((item) => {
|
|
254
252
|
var _a;
|
|
255
|
-
if (properties[item].format === 'many-one' ||
|
|
256
|
-
properties[item].format === 'many-many') {
|
|
253
|
+
if (properties[item].format === 'many-one' || properties[item].format === 'many-many') {
|
|
257
254
|
return ((_a = properties[item]['x-parent']) === null || _a === void 0 ? void 0 : _a.parentFieldKey) === field.name;
|
|
258
255
|
}
|
|
259
256
|
else {
|
|
@@ -287,7 +284,7 @@ export function getFieldRender(field = {}, extra = {}) {
|
|
|
287
284
|
}
|
|
288
285
|
else {
|
|
289
286
|
fieldValue = safeJsonParse(val);
|
|
290
|
-
return
|
|
287
|
+
return _jsx(ArrayComponent, { isH5: isH5, value: fieldValue, field: field, modelType: modelType, items: items });
|
|
291
288
|
}
|
|
292
289
|
}
|
|
293
290
|
return _jsx("span", { children: JSON.stringify(fieldValue) });
|
|
@@ -368,8 +365,7 @@ const ArrayComponent = ({ items, modelType, value, field, isH5 }) => {
|
|
|
368
365
|
export const formatNumber = (value, field) => {
|
|
369
366
|
let newValue = value;
|
|
370
367
|
try {
|
|
371
|
-
if (['date', 'time', 'datetime'].includes(field === null || field === void 0 ? void 0 : field.format) &&
|
|
372
|
-
typeof value === 'number') {
|
|
368
|
+
if (['date', 'time', 'datetime'].includes(field === null || field === void 0 ? void 0 : field.format) && typeof value === 'number') {
|
|
373
369
|
newValue = formatTimeByType(field === null || field === void 0 ? void 0 : field.format, value, field);
|
|
374
370
|
}
|
|
375
371
|
else {
|
|
@@ -433,8 +429,8 @@ export const formatNumberFix = (val, field, setZero = false) => {
|
|
|
433
429
|
* 根据 fields 信息生成 column
|
|
434
430
|
* h5 和 pc 部分参数不同
|
|
435
431
|
*/
|
|
436
|
-
export const getColumns = ({ columnSets = [], fields, isH5 = false, supportManyRelated, showRelationWithTag
|
|
437
|
-
const TableCell = ({ record, field, isH5, supportManyRelated, showRelationWithTag
|
|
432
|
+
export const getColumns = ({ columnSets = [], fields, isH5 = false, supportManyRelated, showRelationWithTag }) => fields === null || fields === void 0 ? void 0 : fields.map((item) => formatFieldToColumn(item, isH5, columnSets, supportManyRelated, showRelationWithTag));
|
|
433
|
+
const TableCell = ({ record, field, isH5, supportManyRelated, showRelationWithTag }) => {
|
|
438
434
|
const component = React.useMemo(() => {
|
|
439
435
|
const { name } = field;
|
|
440
436
|
const value = getFieldValue(name, record);
|
|
@@ -457,7 +453,7 @@ const TableCell = ({ record, field, isH5, supportManyRelated, showRelationWithTa
|
|
|
457
453
|
return getFieldRender(field, extra)(value);
|
|
458
454
|
}, [record, field, isH5]);
|
|
459
455
|
// 处理渲染错误
|
|
460
|
-
return
|
|
456
|
+
return _jsx(ErrorBoundary, { FallbackComponent: () => _jsx("span", { className: "", children: "\u274C \u6570\u636E\u5F02\u5E38" }), children: component });
|
|
461
457
|
};
|
|
462
458
|
/**
|
|
463
459
|
* 根据 field 属性,生成 column 配置
|
|
@@ -470,9 +466,7 @@ export const formatFieldToColumn = (field, isH5, columnSets, supportManyRelated,
|
|
|
470
466
|
const item = columnSets === null || columnSets === void 0 ? void 0 : columnSets.find((i) => i.key === name);
|
|
471
467
|
const isIllegalWidth = typeof (item === null || item === void 0 ? void 0 : item.width) !== 'number';
|
|
472
468
|
return {
|
|
473
|
-
width: !item || (item === null || item === void 0 ? void 0 : item.widthType) === 'auto' || isIllegalWidth
|
|
474
|
-
? width
|
|
475
|
-
: item === null || item === void 0 ? void 0 : item.width,
|
|
469
|
+
width: !item || (item === null || item === void 0 ? void 0 : item.widthType) === 'auto' || isIllegalWidth ? width : item === null || item === void 0 ? void 0 : item.width,
|
|
476
470
|
render: (record) => (_jsx(TableCell, { record: record, field: field, isH5: isH5, supportManyRelated: supportManyRelated, showRelationWithTag: showRelationWithTag })),
|
|
477
471
|
key: name,
|
|
478
472
|
slotKey: (item === null || item === void 0 ? void 0 : item.slotKey) || name,
|
|
@@ -515,9 +509,7 @@ export const getFieldWidth = (field) => {
|
|
|
515
509
|
// 按类型列宽度
|
|
516
510
|
const typeWidth = ((_a = TypeFormatWidthMap === null || TypeFormatWidthMap === void 0 ? void 0 : TypeFormatWidthMap[type]) === null || _a === void 0 ? void 0 : _a[format || (items === null || items === void 0 ? void 0 : items.format) || 'default']) || 0;
|
|
517
511
|
// 最终宽度
|
|
518
|
-
const width = typeWidth
|
|
519
|
-
? Math.max(nameWidth, typeWidth)
|
|
520
|
-
: Math.max(nameWidth, 120);
|
|
512
|
+
const width = typeWidth ? Math.max(nameWidth, typeWidth) : Math.max(nameWidth, 120);
|
|
521
513
|
return width;
|
|
522
514
|
};
|
|
523
515
|
/**
|
|
@@ -595,9 +587,7 @@ export const formatDataToExport = (datas, fields, enumOptions = {}) => {
|
|
|
595
587
|
newDatas[zhTitle] = formatDataToExport([].concat(data), Object.values(((_d = field === null || field === void 0 ? void 0 : field.items) === null || _d === void 0 ? void 0 : _d.properties) || {}));
|
|
596
588
|
}
|
|
597
589
|
else if (((_e = field === null || field === void 0 ? void 0 : field.items) === null || _e === void 0 ? void 0 : _e.type) === 'number') {
|
|
598
|
-
newDatas[zhTitle] = []
|
|
599
|
-
.concat(data)
|
|
600
|
-
.map((d) => formatNumber(d, field === null || field === void 0 ? void 0 : field.items));
|
|
590
|
+
newDatas[zhTitle] = [].concat(data).map((d) => formatNumber(d, field === null || field === void 0 ? void 0 : field.items));
|
|
601
591
|
}
|
|
602
592
|
else if (((_f = field === null || field === void 0 ? void 0 : field.items) === null || _f === void 0 ? void 0 : _f.type) === 'boolean') {
|
|
603
593
|
newDatas[zhTitle] = [].concat(data).map((d) => formatBoolean(d));
|
|
@@ -732,7 +722,7 @@ export const slotRender = (Slot, props = {}) => {
|
|
|
732
722
|
}
|
|
733
723
|
return Slot !== null && Slot !== void 0 ? Slot : null;
|
|
734
724
|
};
|
|
735
|
-
const TableSlotCell = ({ record, rowKey, recordIndex, column, columnIndex, slot
|
|
725
|
+
const TableSlotCell = ({ record, rowKey, recordIndex, column, columnIndex, slot }) => {
|
|
736
726
|
return slotRender(slot, {
|
|
737
727
|
record,
|
|
738
728
|
rowKey,
|
|
@@ -810,12 +800,11 @@ export const filterCustomColumns = ({ columns, columnSets, slots, fields, isH5,
|
|
|
810
800
|
};
|
|
811
801
|
const value = getFieldValue(key, record, relatedField, isMany(_oriField));
|
|
812
802
|
const component = getFieldRender(field, extra)(value);
|
|
813
|
-
return
|
|
803
|
+
return _jsx(ErrorBoundary, { FallbackComponent: () => _jsx("span", { className: "", children: "\u274C \u6570\u636E\u5F02\u5E38" }), children: component });
|
|
814
804
|
};
|
|
815
805
|
const _oriWidth = getFieldWidth(field) + 10;
|
|
816
806
|
const isIllegalWidth = typeof (item2 === null || item2 === void 0 ? void 0 : item2.width) !== 'number';
|
|
817
|
-
item2.width =
|
|
818
|
-
(item2 === null || item2 === void 0 ? void 0 : item2.widthType) === 'auto' || isIllegalWidth ? _oriWidth : item2 === null || item2 === void 0 ? void 0 : item2.width;
|
|
807
|
+
item2.width = (item2 === null || item2 === void 0 ? void 0 : item2.widthType) === 'auto' || isIllegalWidth ? _oriWidth : item2 === null || item2 === void 0 ? void 0 : item2.width;
|
|
819
808
|
// 拿到自定义列属性值
|
|
820
809
|
const customColumn = {
|
|
821
810
|
...columnsMap[key],
|
|
@@ -882,22 +871,20 @@ const getCustomField = (_field, columnSet) => {
|
|
|
882
871
|
* 过滤字段列表
|
|
883
872
|
* 导出/搜索框,不展示自定义列
|
|
884
873
|
*/
|
|
885
|
-
export const filterCustomFields = ({ fields, columnSets, isFilterGenre = false
|
|
874
|
+
export const filterCustomFields = ({ fields, columnSets, isFilterGenre = false }) => {
|
|
886
875
|
if (!Array.isArray(fields))
|
|
887
876
|
return [];
|
|
888
877
|
if (!Array.isArray(columnSets))
|
|
889
878
|
return fields;
|
|
890
879
|
const fieldsMap = fromEntries(fields.map((item) => [item.name, item]));
|
|
891
880
|
return columnSets
|
|
892
|
-
.filter((item1) => (item1 === null || item1 === void 0 ? void 0 : item1.key) &&
|
|
893
|
-
fieldsMap[item1.key] &&
|
|
894
|
-
((item1 === null || item1 === void 0 ? void 0 : item1.genre) !== 'slot' || isFilterGenre))
|
|
881
|
+
.filter((item1) => (item1 === null || item1 === void 0 ? void 0 : item1.key) && fieldsMap[item1.key] && ((item1 === null || item1 === void 0 ? void 0 : item1.genre) !== 'slot' || isFilterGenre))
|
|
895
882
|
.map((item2) => ({ ...fieldsMap[item2.key], title: item2.header }));
|
|
896
883
|
};
|
|
897
884
|
/**
|
|
898
885
|
* 列管理加入冻结属性
|
|
899
886
|
*/
|
|
900
|
-
export const getFixedColumnSets = ({ fixedFront = '', fixedEnd = '', columnSets
|
|
887
|
+
export const getFixedColumnSets = ({ fixedFront = '', fixedEnd = '', columnSets }) => {
|
|
901
888
|
if (!Array.isArray(columnSets))
|
|
902
889
|
return columnSets;
|
|
903
890
|
const fixedFrontIndex = columnSets.findIndex((item) => (item === null || item === void 0 ? void 0 : item.key) && item.key.length > 0 && item.key === fixedFront);
|
|
@@ -905,9 +892,7 @@ export const getFixedColumnSets = ({ fixedFront = '', fixedEnd = '', columnSets,
|
|
|
905
892
|
return Array.isArray(columnSets)
|
|
906
893
|
? columnSets.map((item, index) => {
|
|
907
894
|
// 当冻结尾列在冻结前列之后时,冻结尾列属性才生效
|
|
908
|
-
if (fixedEndIndex >= 0 &&
|
|
909
|
-
fixedEndIndex > fixedFrontIndex &&
|
|
910
|
-
index >= fixedEndIndex) {
|
|
895
|
+
if (fixedEndIndex >= 0 && fixedEndIndex > fixedFrontIndex && index >= fixedEndIndex) {
|
|
911
896
|
return { ...item, fixed: 'right' };
|
|
912
897
|
}
|
|
913
898
|
else if (fixedFrontIndex >= 0 && index <= fixedFrontIndex) {
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
export declare const getDataBaseInfo: (fields: any, format: any, childDbName: any) => any;
|
|
2
2
|
export declare const mapResult: (records: any, primaryColumn: any) => any;
|
|
3
|
-
export declare const useChooseList: ({ dataSourceAPI, queryParams, childDbName, primaryColumn, value }: {
|
|
3
|
+
export declare const useChooseList: ({ dataSourceAPI, queryParams, childDbName, primaryColumn, value, isInsertSelectedValue, }: {
|
|
4
4
|
dataSourceAPI: any;
|
|
5
5
|
queryParams: any;
|
|
6
6
|
childDbName: any;
|
|
7
7
|
primaryColumn: any;
|
|
8
8
|
value: any;
|
|
9
|
+
isInsertSelectedValue?: boolean;
|
|
9
10
|
}) => {
|
|
10
11
|
result: any[];
|
|
11
12
|
total: number;
|
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
import { useState, useEffect, useCallback } from 'react';
|
|
2
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
|
+
};
|
|
3
14
|
const getDataBase = (format, fields) => {
|
|
4
15
|
const filter = fields.filter((item) => (item === null || item === void 0 ? void 0 : item.format) === format);
|
|
5
16
|
const data = filter === null || filter === void 0 ? void 0 : filter.map((item) => {
|
|
@@ -34,7 +45,8 @@ export const getDataBaseInfo = (fields, format, childDbName) => {
|
|
|
34
45
|
return dataBase;
|
|
35
46
|
};
|
|
36
47
|
export const mapResult = (records, primaryColumn) => {
|
|
37
|
-
|
|
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) => ({
|
|
38
50
|
_id: childItem._id,
|
|
39
51
|
value: childItem._id,
|
|
40
52
|
text: childItem[primaryColumn] ? childItem[primaryColumn] : childItem._id,
|
|
@@ -42,7 +54,7 @@ export const mapResult = (records, primaryColumn) => {
|
|
|
42
54
|
extra: childItem,
|
|
43
55
|
}));
|
|
44
56
|
};
|
|
45
|
-
export const useChooseList = ({ dataSourceAPI, queryParams, childDbName, primaryColumn, value }) => {
|
|
57
|
+
export const useChooseList = ({ dataSourceAPI, queryParams, childDbName, primaryColumn, value, isInsertSelectedValue = true, }) => {
|
|
46
58
|
const [option, setOption] = useState([]);
|
|
47
59
|
const [total, setTotal] = useState(0);
|
|
48
60
|
const [loading, setLoading] = useState(true);
|
|
@@ -62,7 +74,7 @@ export const useChooseList = ({ dataSourceAPI, queryParams, childDbName, primary
|
|
|
62
74
|
db: childDbName,
|
|
63
75
|
}),
|
|
64
76
|
];
|
|
65
|
-
if (value) {
|
|
77
|
+
if (value && isInsertSelectedValue) {
|
|
66
78
|
if (isMultiple) {
|
|
67
79
|
value.forEach((i) => {
|
|
68
80
|
if (i) {
|
|
@@ -82,7 +94,7 @@ export const useChooseList = ({ dataSourceAPI, queryParams, childDbName, primary
|
|
|
82
94
|
let transformedRecords = [...((result === null || result === void 0 ? void 0 : result.records) || [])];
|
|
83
95
|
const itemResult = [...rest];
|
|
84
96
|
// 若下拉列表中无选中值,则将选中值插到数组头部
|
|
85
|
-
if ((isMultiple && (value === null || value === void 0 ? void 0 : value.length)) || value) {
|
|
97
|
+
if ((isMultiple && (value === null || value === void 0 ? void 0 : value.length) && isInsertSelectedValue) || (value && isInsertSelectedValue)) {
|
|
86
98
|
itemResult.forEach((i) => {
|
|
87
99
|
transformedRecords = unshiftVal(transformedRecords, i, option);
|
|
88
100
|
});
|
|
@@ -91,6 +103,7 @@ export const useChooseList = ({ dataSourceAPI, queryParams, childDbName, primary
|
|
|
91
103
|
if ((queryParams === null || queryParams === void 0 ? void 0 : queryParams.pageNo) > defaultPage) {
|
|
92
104
|
optionRes = [...option, ...optionRes];
|
|
93
105
|
}
|
|
106
|
+
optionRes = getUniqueOption(optionRes);
|
|
94
107
|
setOption(optionRes);
|
|
95
108
|
setTotal(result === null || result === void 0 ? void 0 : result.total);
|
|
96
109
|
setLoading(false);
|
|
@@ -73,7 +73,8 @@ export const WdTable = forwardRef(function TableComp(tableProps, ref) {
|
|
|
73
73
|
isSuspendFooter = true, // 是否分页器在页面底部悬停
|
|
74
74
|
isSupportMultipleSort = false, // 是否支持多字段排序
|
|
75
75
|
sorter, // 排序规则
|
|
76
|
-
__innerSlot,
|
|
76
|
+
__innerSlot, enableRelationTag = true, // 关联关系字段是否开启关联标签
|
|
77
|
+
...props } = tableProps;
|
|
77
78
|
const wList = convertWhere(props, supportManyRelated); // 查询参数
|
|
78
79
|
const { classPrefix } = useConfig();
|
|
79
80
|
const platform = usePlatform();
|
|
@@ -211,6 +212,7 @@ export const WdTable = forwardRef(function TableComp(tableProps, ref) {
|
|
|
211
212
|
fixedEnd,
|
|
212
213
|
isH5,
|
|
213
214
|
supportManyRelated,
|
|
215
|
+
showRelationWithTag: enableRelationTag,
|
|
214
216
|
});
|
|
215
217
|
// 操作列
|
|
216
218
|
if (enableCellCustomOption && !isH5) {
|
|
@@ -259,11 +261,12 @@ export const WdTable = forwardRef(function TableComp(tableProps, ref) {
|
|
|
259
261
|
fixedFront,
|
|
260
262
|
fixedEnd,
|
|
261
263
|
isH5,
|
|
264
|
+
supportManyRelated,
|
|
265
|
+
enableRelationTag,
|
|
262
266
|
enableCellCustomOption,
|
|
263
|
-
customOptionTitle,
|
|
264
267
|
columnSelectType,
|
|
268
|
+
customOptionTitle,
|
|
265
269
|
classPrefix,
|
|
266
|
-
supportManyRelated,
|
|
267
270
|
resizeColumns,
|
|
268
271
|
]);
|
|
269
272
|
// 主键
|
package/dist/web/utils/moment.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudbase/weda-ui",
|
|
3
|
-
"version": "3.13.
|
|
3
|
+
"version": "3.13.2",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"module": "./dist/index",
|
|
6
6
|
"miniprogram": "mpdist",
|
|
@@ -85,7 +85,7 @@
|
|
|
85
85
|
"description": "腾讯云微搭低代码组件库模板",
|
|
86
86
|
"dependencies": {
|
|
87
87
|
"@antv/g6": "^4.8.5",
|
|
88
|
-
"@cloudbase/weda-client": "^1.1.
|
|
88
|
+
"@cloudbase/weda-client": "^1.1.15",
|
|
89
89
|
"@codemirror/autocomplete": "^6.16.0",
|
|
90
90
|
"@codemirror/lang-javascript": "^6.2.2",
|
|
91
91
|
"@codemirror/lang-json": "^6.0.1",
|
|
@@ -147,9 +147,9 @@
|
|
|
147
147
|
"@babel/preset-env": "^7.22.15",
|
|
148
148
|
"@babel/preset-react": "^7.22.15",
|
|
149
149
|
"@babel/preset-typescript": "^7.22.15",
|
|
150
|
-
"@cloudbase/cals": "^1.2.
|
|
150
|
+
"@cloudbase/cals": "^1.2.7",
|
|
151
151
|
"@cloudbase/lowcode-cli": "^0.22.0",
|
|
152
|
-
"@cloudbase/weda-cloud-sdk": "^1.0.
|
|
152
|
+
"@cloudbase/weda-cloud-sdk": "^1.0.96",
|
|
153
153
|
"@commitlint/cli": "^16.0.2",
|
|
154
154
|
"@commitlint/config-conventional": "^17.7.0",
|
|
155
155
|
"@craco/craco": "^7.1.0",
|