@cloudbase/weda-ui 3.10.3 → 3.11.1

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 (101) hide show
  1. package/dist/configs/components/button.js +1 -1
  2. package/dist/configs/components/chart/bar.d.ts +146 -0
  3. package/dist/configs/components/chart/bar.js +1147 -0
  4. package/dist/configs/components/dataView.js +0 -16
  5. package/dist/configs/components/image.js +1 -1
  6. package/dist/configs/components/listView.js +0 -16
  7. package/dist/configs/components/lottery.js +1 -1
  8. package/dist/configs/components/navigationBar.json +1 -1
  9. package/dist/configs/components/wd-audio.js +1 -1
  10. package/dist/configs/components/wd-button.js +2 -2
  11. package/dist/configs/components/wd-icon.js +1 -1
  12. package/dist/configs/components/wd-image.js +1 -1
  13. package/dist/configs/components/wd-input-email.d.ts +2 -2
  14. package/dist/configs/components/wd-input-phone.d.ts +2 -2
  15. package/dist/configs/components/wd-input-url.d.ts +2 -2
  16. package/dist/configs/components/wd-link.js +1 -1
  17. package/dist/configs/components/wd-progress.d.ts +10 -0
  18. package/dist/configs/components/wd-progress.js +39 -2
  19. package/dist/configs/components/wd-rating.js +2 -2
  20. package/dist/configs/components/wd-select-multiple.d.ts +23 -0
  21. package/dist/configs/components/wd-select-multiple.js +26 -1
  22. package/dist/configs/components/wd-select.d.ts +23 -0
  23. package/dist/configs/components/wd-select.js +25 -0
  24. package/dist/configs/components/wd-side-tab.js +2 -2
  25. package/dist/configs/components/wd-table.d.ts +1 -1
  26. package/dist/configs/components/wd-table.js +1 -0
  27. package/dist/configs/components/wd-top-tab.d.ts +4 -0
  28. package/dist/configs/components/wd-top-tab.js +7 -2
  29. package/dist/configs/components/wd-upload-image.js +1 -1
  30. package/dist/configs/components/wedaVideo.js +3 -3
  31. package/dist/configs/components/wxOpenApi/share.js +1 -1
  32. package/dist/configs/index.d.ts +765 -2065
  33. package/dist/configs/index.js +1 -1
  34. package/dist/configs/type-utils/type-form.d.ts +6 -0
  35. package/dist/configs/type-utils/type-form.js +64 -22
  36. package/dist/configs/type-utils/x-runtime-default.d.ts +1 -0
  37. package/dist/configs/type-utils/x-runtime-default.js +1 -0
  38. package/dist/enum/index.js +5 -1
  39. package/dist/style/index.css +16 -4
  40. package/dist/style/index.scss +1 -1
  41. package/dist/style/weda-ui.min.css +2 -2
  42. package/dist/web/components/form/location/common/propsConfig.d.ts +1 -1
  43. package/dist/web/components/form/select/index.css +2 -2
  44. package/dist/web/components/form/select/request.d.ts +3 -3
  45. package/dist/web/components/form/select/request.js +1 -0
  46. package/dist/web/components/form/select/status/index.d.ts +3 -1
  47. package/dist/web/components/form/select/status/index.js +3 -1
  48. package/dist/web/components/form/selectMultiple/dropdown-select/index.css +5 -5
  49. package/dist/web/components/form/uploader/uploader.h5.js +13 -4
  50. package/dist/web/components/form/uploader/util.d.ts +1 -0
  51. package/dist/web/components/form/uploader/util.js +28 -0
  52. package/dist/web/components/form/uploaderFile/uploadFile.h5.js +14 -6
  53. package/dist/web/components/form-date/index.d.ts +1 -1
  54. package/dist/web/components/form-email/index.d.ts +1 -1
  55. package/dist/web/components/form-input/index.d.ts +1 -1
  56. package/dist/web/components/form-input-hooks/index.js +10 -1
  57. package/dist/web/components/form-input-hooks/validator.d.ts +1 -0
  58. package/dist/web/components/form-input-hooks/validator.js +6 -2
  59. package/dist/web/components/form-phone/index.d.ts +1 -1
  60. package/dist/web/components/form-time/index.d.ts +1 -1
  61. package/dist/web/components/form-url/index.d.ts +1 -1
  62. package/dist/web/components/grid/col.d.ts +2 -2
  63. package/dist/web/components/wd-date/elements/Modal.h5.d.ts +2 -0
  64. package/dist/web/components/wd-date/elements/Modal.h5.js +3 -3
  65. package/dist/web/components/wd-form/index.js +1 -1
  66. package/dist/web/components/wd-form-item/wd-form-item-read-only.d.ts +1 -0
  67. package/dist/web/components/wd-input/wd-input.d.ts +1 -1
  68. package/dist/web/components/wd-input-email/wd-input-email.d.ts +1 -1
  69. package/dist/web/components/wd-input-phone/wd-input-phone.d.ts +1 -1
  70. package/dist/web/components/wd-input-url/wd-input-url.d.ts +1 -1
  71. package/dist/web/components/wd-progress/wd-progress.js +5 -3
  72. package/dist/web/components/wd-select/relationSelect/relationSelect.d.ts +4 -0
  73. package/dist/web/components/wd-select/relationSelect/relationSelect.js +202 -0
  74. package/dist/web/components/wd-select/{relationalSetting.js → relationSelect/relationalSetting.js} +4 -4
  75. package/dist/web/components/wd-select/select/index.d.ts +2 -0
  76. package/dist/web/components/wd-select/select/index.js +8 -0
  77. package/dist/web/components/wd-select/select/selectUI.d.ts +3 -0
  78. package/dist/web/components/wd-select/select/selectUI.js +190 -0
  79. package/dist/web/components/wd-select/style.d.ts +2 -0
  80. package/dist/web/components/wd-select/style.js +2 -0
  81. package/dist/web/components/wd-select/wd-select.css +83 -0
  82. package/dist/web/components/wd-select/wd-select.d.ts +0 -1
  83. package/dist/web/components/wd-select/wd-select.js +18 -8
  84. package/dist/web/components/wd-select-multiple/style.d.ts +2 -0
  85. package/dist/web/components/wd-select-multiple/style.js +2 -0
  86. package/dist/web/components/wd-select-multiple/wd-select-multiple.css +30 -4
  87. package/dist/web/components/wd-select-multiple/wd-select-multiple.js +18 -7
  88. package/dist/web/components/wd-table/components/FieldRender/index.d.ts +7 -4
  89. package/dist/web/components/wd-table/components/FieldRender/index.js +42 -15
  90. package/dist/web/components/wd-table/components/ModalTable/index.js +4 -3
  91. package/dist/web/components/wd-table/hooks/useChooseList.d.ts +1 -0
  92. package/dist/web/components/wd-table/hooks/useChooseList.js +55 -26
  93. package/dist/web/components/wd-table/utils/index.js +1 -1
  94. package/dist/web/components/wd-table/wd-table.js +2 -2
  95. package/dist/web/utils/isObjectEqual.d.ts +1 -1
  96. package/dist/web/utils/moment.d.ts +1 -0
  97. package/dist/web/utils/platform.js +3 -3
  98. package/dist/web/utils/tool.js +2 -2
  99. package/package.json +18 -13
  100. package/dist/configs/components/chart/bar.json +0 -1144
  101. /package/dist/web/components/wd-select/{relationalSetting.d.ts → relationSelect/relationalSetting.d.ts} +0 -0
@@ -76,10 +76,6 @@
76
76
  color: var(--wd-color-text-placeholder) !important;
77
77
  }
78
78
 
79
- .wd-tag-root {
80
- cursor: pointer;
81
- }
82
-
83
79
  .wd-pc-select-multiple-root .wd-form-item-wrap__control {
84
80
  overflow: hidden;
85
81
  }
@@ -91,3 +87,33 @@
91
87
  width: 100%;
92
88
  padding-right: calc(var(--wd-size-icon-md));
93
89
  }
90
+
91
+ .wd-relation-select-overlay.multiple
92
+ .wedatea2td-dropdown-box
93
+ .wedatea2td-list--option
94
+ > li {
95
+ width: fit-content !important;
96
+ min-width: 100%;
97
+ padding: 0;
98
+ }
99
+ .wd-relation-select-overlay.multiple .wd-relation-select-option-wrap {
100
+ padding: 0 8px;
101
+ margin-top: -6px;
102
+ }
103
+ .wd-form-item.wd-pc-select-multiple-root .wedatea2td-dropdown__value div {
104
+ text-overflow: ellipsis;
105
+ white-space: nowrap;
106
+ overflow: hidden;
107
+ }
108
+ /* h5端关联下拉样式 */
109
+ .weda-ui-custom-picker__cloumns.weda-ui-custom-picker__cloumns--select-multiple.wd-relation-select-overlay
110
+ .weda-ui-custom-picker__cloumn-item {
111
+ height: auto;
112
+ }
113
+ .weda-ui-custom-picker__cloumns--select-multiple
114
+ .weda-ui-custom-picker__cloumn-item-text {
115
+ overflow: hidden;
116
+ text-overflow: ellipsis;
117
+ white-space: nowrap;
118
+ margin-left: 30px;
119
+ }
@@ -1,10 +1,9 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import React, { forwardRef, useState, useCallback, useRef } from 'react';
3
3
  import { WdFormItem, WdInputGroup, WdInputWrap } from '../wd-form-item';
4
- import SelectMultiple from '../form/selectMultiple';
4
+ import { SelectCom as SelectMultiple } from '../wd-select/select';
5
5
  import { useHandleClear, useFixedIcon, SELECT_ICON_H5, SELECT_ICON_PC, } from '../../utils/hooks/useFormLegacy';
6
6
  import { useFormInputTrait } from '../../components/form-input-hooks';
7
- import { RecycleProvider } from '../../utils/hooks/useRecycle';
8
7
  import { useSelected } from '../../utils/hooks/use-selected';
9
8
  import { emptyObject } from '../../utils/constant';
10
9
  import { useSetWidgetApi } from '../../utils/widget-api/use-set-widget-api';
@@ -13,12 +12,13 @@ import { X_RUNTIME_DEFAULT } from '../../../configs/type-utils/x-runtime-default
13
12
  import './style';
14
13
  import { useDebouncedCallback, useSyncedRef } from '@react-hookz/web';
15
14
  import { isFormatWithRelation } from '../form/select/formats-util';
16
- import { RelationalSetting } from '../wd-select/relationalSetting';
15
+ import { RelationalSetting } from '../wd-select/relationSelect/relationalSetting';
17
16
  /**
18
17
  * 下拉多选-标准化
19
18
  */
20
19
  export const WdSelectMultiple = forwardRef(function WdSelectMultiple(props, ref) {
21
- const { classRoot = 'select-multiple', clearable = X_RUNTIME_DEFAULT.clearable, placeholder, range, enumName, format, primaryField, tipBlock = X_RUNTIME_DEFAULT.tipBlock, viewId, dataSourceName, events = emptyObject, ignoreCase = X_RUNTIME_DEFAULT.ignoreCase, staticSearchable = X_RUNTIME_DEFAULT.staticSearchable, where = X_RUNTIME_DEFAULT.where, enableRelationalSetting = X_RUNTIME_DEFAULT.enableRelationalSetting, enableRelationalRefresh = X_RUNTIME_DEFAULT.enableRelationalRefresh, addRelationButtonText = X_RUNTIME_DEFAULT.addRelationButtonText, enableAddRelationButton = X_RUNTIME_DEFAULT.enableAddRelationButton, popupContainer, } = props;
20
+ const { classRoot = 'select-multiple', clearable = X_RUNTIME_DEFAULT.clearable, placeholder, range, enumName, format, primaryField, tipBlock = X_RUNTIME_DEFAULT.tipBlock, viewId, dataSourceName, events = emptyObject, ignoreCase = X_RUNTIME_DEFAULT.ignoreCase, staticSearchable = X_RUNTIME_DEFAULT.staticSearchable, where = X_RUNTIME_DEFAULT.where, enableRelationalSetting = X_RUNTIME_DEFAULT.enableRelationalSetting, enableRelationalRefresh = X_RUNTIME_DEFAULT.enableRelationalRefresh, addRelationButtonText = X_RUNTIME_DEFAULT.addRelationButtonText, enableAddRelationButton = X_RUNTIME_DEFAULT.enableAddRelationButton, enableRelationOptionJump = X_RUNTIME_DEFAULT.enableRelationOptionJump, popupContainer, selectFields: customFields = [], // 自定义展示字段
21
+ selectFieldType = 'primary', } = props;
22
22
  const childRef = useRef(null);
23
23
  const [options, setOptions] = useState([]);
24
24
  const [innerHandle, setInnerHandle] = useState({});
@@ -48,6 +48,11 @@ export const WdSelectMultiple = forwardRef(function WdSelectMultiple(props, ref)
48
48
  disabled,
49
49
  value,
50
50
  });
51
+ const handleChange = (v) => {
52
+ var _a;
53
+ onChange === null || onChange === void 0 ? void 0 : onChange(v);
54
+ (_a = delayEvents === null || delayEvents === void 0 ? void 0 : delayEvents.change) === null || _a === void 0 ? void 0 : _a.call(delayEvents, { value: v });
55
+ };
51
56
  const isRelation = isFormatWithRelation(format);
52
57
  const LabelAdornment = isRelation && (_jsx(RelationalSetting, { size: props.size, refresh: () => {
53
58
  var _a;
@@ -81,7 +86,10 @@ export const WdSelectMultiple = forwardRef(function WdSelectMultiple(props, ref)
81
86
  }), [innerHandle, selectedLabel, primaryField, selectedItem, value], ref);
82
87
  const eventsRef = useSyncedRef(events);
83
88
  const debouncedTriggerSearchEvent = useDebouncedCallback((value) => {
84
- eventsRef.current.search({ value });
89
+ var _a, _b;
90
+ if (typeof ((_a = eventsRef.current) === null || _a === void 0 ? void 0 : _a.search) === 'function') {
91
+ (_b = eventsRef.current) === null || _b === void 0 ? void 0 : _b.search({ value });
92
+ }
85
93
  }, [eventsRef],
86
94
  // eslint-disable-next-line @typescript-eslint/no-magic-numbers
87
95
  300);
@@ -90,8 +98,11 @@ export const WdSelectMultiple = forwardRef(function WdSelectMultiple(props, ref)
90
98
  }, [debouncedTriggerSearchEvent]);
91
99
  if (!visible)
92
100
  return null;
93
- return (_jsx(WdFormItem, { ...formItemProps, children: _jsxs(_Fragment, { children: [_jsx(WdInputGroup, { ...inputGroupProps, children: _jsx(WdInputWrap, { ...inputWrapProps, children: _jsx(RecycleProvider, { readOnly: readOnly, recycleBack: setOptions, format: format, portalContainer: popupContainer, onRelationTagClick: (item) => {
101
+ return (_jsx(WdFormItem, { ...formItemProps, children: _jsxs(_Fragment, { children: [_jsx(WdInputGroup, { ...inputGroupProps, children: _jsx(WdInputWrap, { ...inputWrapProps, children: _jsx(SelectMultiple, { ...props, setAllOption: setOptions, onRelationTagClick: (item) => {
94
102
  var _a;
95
103
  (_a = delayEvents === null || delayEvents === void 0 ? void 0 : delayEvents.onRelationTagClick) === null || _a === void 0 ? void 0 : _a.call(delayEvents, item);
96
- }, children: _jsx(SelectMultiple, { addRelationButtonText: addRelationButtonText, enableAddRelationButton: enableAddRelationButton, childRef: childRef, events: delayEvents, labelVisible: false, defaultValue: value, enumName: enumName, format: format, placeholder: placeholder, primaryField: primaryField, range: range, size: "full", tipBlock: tipBlock, viewId: viewId, dataSourceName: dataSourceName, readOnly: readOnly, disabled: disabled, mode: "selector", decorator: null, ignoreCase: ignoreCase, staticSearchable: staticSearchable, where: where, onChange: onChange, onSearchValueInput: onSearchValueInput, popupContainer: popupContainer }) }) }) }), layout === 'horizontal' && LabelAdornment] }) }));
104
+ }, enableRelationOptionJump: enableRelationOptionJump, onRelationOptionJump: (item) => {
105
+ var _a;
106
+ (_a = delayEvents === null || delayEvents === void 0 ? void 0 : delayEvents.onRelationOptionJump) === null || _a === void 0 ? void 0 : _a.call(delayEvents, item);
107
+ }, selectFieldType: selectFieldType, selectFields: customFields, isRelation: isRelation, addRelationButtonText: addRelationButtonText, enableAddRelationButton: enableAddRelationButton, childRef: childRef, events: delayEvents, labelVisible: false, value: value, enumName: enumName, format: format, placeholder: placeholder, primaryField: primaryField, options: range, size: "full", tipBlock: tipBlock, viewId: viewId, dataSourceName: dataSourceName, readOnly: readOnly, disabled: disabled, mode: "multiple", decorator: null, ignoreCase: ignoreCase, staticSearchable: staticSearchable, where: where, onChange: handleChange, onSearch: onSearchValueInput, popupContainer: popupContainer, searchable: true }) }) }), layout === 'horizontal' && LabelAdornment] }) }));
97
108
  });
@@ -56,17 +56,18 @@ export declare const formatNumberFix: (val: any, field: any, setZero?: boolean)
56
56
  * 根据 fields 信息生成 column
57
57
  * h5 和 pc 部分参数不同
58
58
  */
59
- export declare const getColumns: ({ columnSets, fields, isH5, supportManyRelated, }: {
59
+ export declare const getColumns: ({ columnSets, fields, isH5, supportManyRelated, showRelationWithTag, }: {
60
60
  columnSets?: any[];
61
61
  fields: any;
62
62
  isH5?: boolean;
63
63
  supportManyRelated: any;
64
+ showRelationWithTag: any;
64
65
  }) => any;
65
66
  /**
66
67
  * 根据 field 属性,生成 column 配置
67
68
  * https://git.woa.com/QBase/lcap/common-application-specs/blob/master/types/platform/datasource.ts
68
69
  */
69
- export declare const formatFieldToColumn: (field: any, isH5: any, columnSets: any, supportManyRelated: any) => {
70
+ export declare const formatFieldToColumn: (field: any, isH5: any, columnSets: any, supportManyRelated: any, showRelationWithTag: any) => {
70
71
  width: any;
71
72
  render: (record: any) => JSX.Element;
72
73
  key: any;
@@ -109,13 +110,14 @@ export declare const slotRender: (Slot: any, props?: {}) => any;
109
110
  * slots: object 模型表格作用域插槽
110
111
  * isH5: 判断自定义插槽列能否展示,目前是正常展示
111
112
  */
112
- export declare const filterCustomColumns: ({ columns, columnSets, slots, fields, isH5, supportManyRelated, }: {
113
+ export declare const filterCustomColumns: ({ columns, columnSets, slots, fields, isH5, supportManyRelated, showRelationWithTag, }: {
113
114
  columns: any;
114
115
  columnSets: any;
115
116
  slots: any;
116
117
  fields: any;
117
118
  isH5: any;
118
119
  supportManyRelated: any;
120
+ showRelationWithTag: any;
119
121
  }) => any;
120
122
  /**
121
123
  * 过滤字段列表
@@ -137,7 +139,7 @@ export declare const getFixedColumnSets: ({ fixedFront, fixedEnd, columnSets, }:
137
139
  /**
138
140
  * 列管理字段转换
139
141
  */
140
- export declare const getTableColumns: ({ fields, columnSets, slots, fixedFront, fixedEnd, isH5, supportManyRelated, }: {
142
+ export declare const getTableColumns: ({ fields, columnSets, slots, fixedFront, fixedEnd, isH5, supportManyRelated, showRelationWithTag, }: {
141
143
  fields: any;
142
144
  columnSets: any;
143
145
  slots: any;
@@ -145,5 +147,6 @@ export declare const getTableColumns: ({ fields, columnSets, slots, fixedFront,
145
147
  fixedEnd: any;
146
148
  isH5: any;
147
149
  supportManyRelated: any;
150
+ showRelationWithTag?: boolean;
148
151
  }) => any;
149
152
  export declare const mapColumKey: (columnSets: any) => any;
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  /* eslint-disable */
3
- import React, { useMemo, useRef } from 'react';
3
+ import React, { useMemo, useRef, useState } from 'react';
4
4
  import fromEntries from 'object.fromentries';
5
5
  import { Modal, Table, Form, ConfigProvider } from 'tea-component';
6
6
  import { formatTimeByType } from '../../../../utils/date';
@@ -21,7 +21,7 @@ import { errorHandler } from '../../../../utils/error';
21
21
  import { ImagePreview } from './ImagePreview';
22
22
  import { VideoPreview } from './VideoPreview';
23
23
  import { ModalTable } from '../ModalTable';
24
- import { getWhereParam } from '../../utils';
24
+ import { getWhereParam, getSortColumns } from '../../utils';
25
25
  import lodashGet from 'lodash.get';
26
26
  const MODAL_SIZE = '80%';
27
27
  // 文字提示框包裹组件
@@ -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 } = extra;
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) {
@@ -135,6 +135,12 @@ export function getFieldRender(field = {}, extra = {}) {
135
135
  (format === 'father-son' || format === 'related')) {
136
136
  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
137
  const relatedField = (_c = extra === null || extra === void 0 ? void 0 : extra.columnSet) === null || _c === void 0 ? void 0 : _c.relatedField;
138
+ if (!showRelationWithTag) {
139
+ if (typeof fieldValue === 'string') {
140
+ return _jsx(TextWrap, { ...textProps, children: fieldValue });
141
+ }
142
+ return (_jsx(TextWrap, { ...textProps, children: fieldValue[relatedField] || fieldValue[primaryField] || '-' }));
143
+ }
138
144
  if (typeof fieldValue === 'string') {
139
145
  return fieldValue && fieldValue !== '-' ? (_jsx(WdTag, { range: fieldValue === null || fieldValue === void 0 ? void 0 : fieldValue.split(',').map((i) => ({
140
146
  label: i,
@@ -194,6 +200,9 @@ export function getFieldRender(field = {}, extra = {}) {
194
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']) || '';
195
201
  const relatedField = (_f = extra === null || extra === void 0 ? void 0 : extra.columnSet) === null || _f === void 0 ? void 0 : _f.relatedField;
196
202
  const _readValue = fieldValue[relatedField] || fieldValue[primaryField];
203
+ if (!showRelationWithTag) {
204
+ return (_jsx(TextWrap, { ...textProps, children: fieldValue[relatedField] || fieldValue[primaryField] }));
205
+ }
197
206
  return _readValue ? (_jsx(WdTag, { range: _readValue === null || _readValue === void 0 ? void 0 : _readValue.split(',').map((i) => ({
198
207
  label: i,
199
208
  value: i,
@@ -243,7 +252,7 @@ export function getFieldRender(field = {}, extra = {}) {
243
252
  const propertyArr = Object.keys(properties);
244
253
  const relatedKey = propertyArr.find((item) => {
245
254
  var _a;
246
- if (properties[item].format === 'one-many' ||
255
+ if (properties[item].format === 'many-one' ||
247
256
  properties[item].format === 'many-many') {
248
257
  return ((_a = properties[item]['x-parent']) === null || _a === void 0 ? void 0 : _a.parentFieldKey) === field.name;
249
258
  }
@@ -253,9 +262,7 @@ export function getFieldRender(field = {}, extra = {}) {
253
262
  });
254
263
  const param = {
255
264
  datasource: parentDatasource,
256
- enabledFieldNames: relatedField
257
- ? [relatedField]
258
- : [primaryField] || [],
265
+ isNewData: true,
259
266
  };
260
267
  const whereList = getWhereParam(relatedKey, rowId);
261
268
  const modalSize = isH5 ? 'auto' : 'l';
@@ -305,6 +312,7 @@ export const DataItemView = ({ fields, modelType, value, isH5 }) => {
305
312
  */
306
313
  export const DataTableView = ({ fields, value }) => {
307
314
  var _a;
315
+ const { sortable } = Table.addons;
308
316
  const { classPrefix } = useConfig();
309
317
  const rawFields = (_a = Object === null || Object === void 0 ? void 0 : Object.entries(fields.properties)) === null || _a === void 0 ? void 0 : _a.map(([name, field]) => Object.assign({}, field, { name }));
310
318
  const columns = useMemo(() => {
@@ -314,10 +322,23 @@ export const DataTableView = ({ fields, value }) => {
314
322
  fields: rawFieldsSort,
315
323
  isH5: false,
316
324
  supportManyRelated: false,
325
+ showRelationWithTag: false,
317
326
  });
318
- return baseColumns;
327
+ return baseColumns === null || baseColumns === void 0 ? void 0 : baseColumns.map((i) => ({ ...i, isSort: true }));
319
328
  }, [rawFields]);
320
- return (_jsx(ConfigProvider, { classPrefix: classPrefix, children: _jsx(EnumHoc, { fields: rawFields, children: _jsx(Table, { className: `${classPrefix}-table-wrap`, bordered: "all", recordKey: "_id", records: [].concat(value), columns: columns }) }) }));
329
+ // 当前排序列
330
+ const [sorts, setSorts] = useState([]);
331
+ const sortColumns = getSortColumns({
332
+ fields: rawFields,
333
+ columnSets: columns,
334
+ });
335
+ return (_jsx(ConfigProvider, { classPrefix: classPrefix, children: _jsx(EnumHoc, { fields: rawFields, children: _jsx(Table, { className: `${classPrefix}-table-wrap`, bordered: "all", recordKey: "_id", records: [].concat(value).sort(sortable.comparer(sorts)), columns: columns, addons: [
336
+ sortable({
337
+ columns: sortColumns,
338
+ value: sorts,
339
+ onChange: (value) => setSorts(value),
340
+ }),
341
+ ] }) }) }));
321
342
  };
322
343
  /**
323
344
  * array类型,展示组件
@@ -412,8 +433,8 @@ export const formatNumberFix = (val, field, setZero = false) => {
412
433
  * 根据 fields 信息生成 column
413
434
  * h5 和 pc 部分参数不同
414
435
  */
415
- export const getColumns = ({ columnSets = [], fields, isH5 = false, supportManyRelated, }) => fields === null || fields === void 0 ? void 0 : fields.map((item) => formatFieldToColumn(item, isH5, columnSets, supportManyRelated));
416
- const TableCell = ({ record, field, isH5, supportManyRelated }) => {
436
+ 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));
437
+ const TableCell = ({ record, field, isH5, supportManyRelated, showRelationWithTag, }) => {
417
438
  const component = React.useMemo(() => {
418
439
  const { name } = field;
419
440
  const value = getFieldValue(name, record);
@@ -424,12 +445,14 @@ const TableCell = ({ record, field, isH5, supportManyRelated }) => {
424
445
  relation: record[`@${name}`],
425
446
  supportManyRelated,
426
447
  isH5,
448
+ showRelationWithTag,
427
449
  }
428
450
  : {
429
451
  modelType: 'table',
430
452
  relation: record[`@${name}`],
431
453
  supportManyRelated,
432
454
  isH5,
455
+ showRelationWithTag,
433
456
  };
434
457
  return getFieldRender(field, extra)(value);
435
458
  }, [record, field, isH5]);
@@ -440,7 +463,7 @@ const TableCell = ({ record, field, isH5, supportManyRelated }) => {
440
463
  * 根据 field 属性,生成 column 配置
441
464
  * https://git.woa.com/QBase/lcap/common-application-specs/blob/master/types/platform/datasource.ts
442
465
  */
443
- export const formatFieldToColumn = (field, isH5, columnSets, supportManyRelated) => {
466
+ export const formatFieldToColumn = (field, isH5, columnSets, supportManyRelated, showRelationWithTag) => {
444
467
  const { name, title } = field;
445
468
  // 计算列宽度,略大于计算宽度
446
469
  const width = getFieldWidth(field) + 10;
@@ -450,7 +473,7 @@ export const formatFieldToColumn = (field, isH5, columnSets, supportManyRelated)
450
473
  width: !item || (item === null || item === void 0 ? void 0 : item.widthType) === 'auto' || isIllegalWidth
451
474
  ? width
452
475
  : item === null || item === void 0 ? void 0 : item.width,
453
- render: (record) => (_jsx(TableCell, { record: record, field: field, isH5: isH5, supportManyRelated: supportManyRelated })),
476
+ render: (record) => (_jsx(TableCell, { record: record, field: field, isH5: isH5, supportManyRelated: supportManyRelated, showRelationWithTag: showRelationWithTag })),
454
477
  key: name,
455
478
  slotKey: (item === null || item === void 0 ? void 0 : item.slotKey) || name,
456
479
  header: title,
@@ -725,7 +748,7 @@ const TableSlotCell = ({ record, rowKey, recordIndex, column, columnIndex, slot,
725
748
  * slots: object 模型表格作用域插槽
726
749
  * isH5: 判断自定义插槽列能否展示,目前是正常展示
727
750
  */
728
- export const filterCustomColumns = ({ columns, columnSets, slots, fields, isH5, supportManyRelated, }) => {
751
+ export const filterCustomColumns = ({ columns, columnSets, slots, fields, isH5, supportManyRelated, showRelationWithTag, }) => {
729
752
  if (!Array.isArray(columnSets) || !(columnSets === null || columnSets === void 0 ? void 0 : columnSets.length))
730
753
  return columns;
731
754
  const columnSetsReg = columnSets.map((item) => {
@@ -774,6 +797,7 @@ export const filterCustomColumns = ({ columns, columnSets, slots, fields, isH5,
774
797
  rowId: record._id,
775
798
  supportManyRelated,
776
799
  isH5,
800
+ showRelationWithTag,
777
801
  }
778
802
  : {
779
803
  modelType: 'table',
@@ -782,6 +806,7 @@ export const filterCustomColumns = ({ columns, columnSets, slots, fields, isH5,
782
806
  rowId: record._id,
783
807
  supportManyRelated,
784
808
  isH5,
809
+ showRelationWithTag,
785
810
  };
786
811
  const value = getFieldValue(key, record, relatedField, isMany(_oriField));
787
812
  const component = getFieldRender(field, extra)(value);
@@ -897,12 +922,13 @@ export const getFixedColumnSets = ({ fixedFront = '', fixedEnd = '', columnSets,
897
922
  /**
898
923
  * 列管理字段转换
899
924
  */
900
- export const getTableColumns = ({ fields, columnSets, slots, fixedFront, fixedEnd, isH5, supportManyRelated, }) => {
925
+ export const getTableColumns = ({ fields, columnSets, slots, fixedFront, fixedEnd, isH5, supportManyRelated, showRelationWithTag = true, }) => {
901
926
  const defaultColumns = getColumns({
902
927
  columnSets,
903
928
  fields,
904
929
  isH5: false,
905
930
  supportManyRelated,
931
+ showRelationWithTag,
906
932
  });
907
933
  let fixedColumnSets = columnSets;
908
934
  // h5端不冻结
@@ -920,6 +946,7 @@ export const getTableColumns = ({ fields, columnSets, slots, fixedFront, fixedEn
920
946
  fields,
921
947
  isH5,
922
948
  supportManyRelated,
949
+ showRelationWithTag,
923
950
  });
924
951
  return baseColumns.map((i) => ({
925
952
  ...i,
@@ -80,8 +80,6 @@ enablePagination = true, columnSelectType = 'select', defaultPageIndex = _defaul
80
80
  columnSetsKey,
81
81
  });
82
82
  const fields = authFields;
83
- // 可排序字段
84
- const sortColumns = getSortColumns({ fields, columnSets });
85
83
  // 查询参数
86
84
  const { query } = useQueryParams({
87
85
  queryParams,
@@ -152,8 +150,9 @@ enablePagination = true, columnSelectType = 'select', defaultPageIndex = _defaul
152
150
  fixedEnd,
153
151
  isH5,
154
152
  supportManyRelated: true,
153
+ showRelationWithTag: false,
155
154
  });
156
- return baseColumns;
155
+ return baseColumns === null || baseColumns === void 0 ? void 0 : baseColumns.map((i) => ({ ...i, isSort: true }));
157
156
  }, [
158
157
  isNoDataSourceBind,
159
158
  fieldsLoading,
@@ -163,6 +162,8 @@ enablePagination = true, columnSelectType = 'select', defaultPageIndex = _defaul
163
162
  fixedEnd,
164
163
  isH5,
165
164
  ]);
165
+ // 可排序字段
166
+ const sortColumns = getSortColumns({ fields, columnSets: columns });
166
167
  // 事件属性
167
168
  useImperativeHandle(ref, () => ({
168
169
  refresh: () => {
@@ -11,4 +11,5 @@ export declare const useChooseList: ({ dataSourceAPI, queryParams, childDbName,
11
11
  total: number;
12
12
  isValidating: boolean;
13
13
  empty: () => void;
14
+ getRelationOptions: () => Promise<void>;
14
15
  };
@@ -1,4 +1,4 @@
1
- import { useState, useEffect } from 'react';
1
+ import { useState, useEffect, useCallback } from 'react';
2
2
  const defaultPage = 1;
3
3
  const getDataBase = (format, fields) => {
4
4
  const filter = fields.filter((item) => (item === null || item === void 0 ? void 0 : item.format) === format);
@@ -37,41 +37,69 @@ export const mapResult = (records, primaryColumn) => {
37
37
  return records === null || records === void 0 ? void 0 : records.map((childItem) => ({
38
38
  value: childItem._id,
39
39
  text: childItem[primaryColumn] ? childItem[primaryColumn] : childItem._id,
40
+ label: childItem[primaryColumn] ? childItem[primaryColumn] : childItem._id,
41
+ extra: childItem,
40
42
  }));
41
43
  };
42
44
  export const useChooseList = ({ dataSourceAPI, queryParams, childDbName, primaryColumn, value, }) => {
43
45
  const [option, setOption] = useState([]);
44
46
  const [total, setTotal] = useState(0);
45
47
  const [loading, setLoading] = useState(true);
46
- useEffect(() => {
47
- async function fetchData() {
48
- setLoading(true);
49
- const [result, itemResult] = await Promise.all([
50
- dataSourceAPI.getRecordList(queryParams, {
51
- db: childDbName,
52
- }),
53
- value
54
- ? dataSourceAPI.getRecord(value, {
55
- db: childDbName,
56
- })
57
- : Promise.resolve(),
58
- ]);
59
- let transformedRecords = [...((result === null || result === void 0 ? void 0 : result.records) || [])];
60
- if (value &&
61
- transformedRecords.findIndex((item) => item._id === value) < 0) {
62
- transformedRecords = [itemResult, ...transformedRecords];
48
+ const unshiftVal = (transformedRecords, itemResult) => {
49
+ if (itemResult &&
50
+ transformedRecords.findIndex((item) => item._id === itemResult._id) < 0 &&
51
+ option.findIndex((item) => item._id === itemResult._id) < 0) {
52
+ return [itemResult, ...transformedRecords];
53
+ }
54
+ return transformedRecords;
55
+ };
56
+ const fetchData = useCallback(async () => {
57
+ setLoading(true);
58
+ const isMultiple = Array.isArray(value);
59
+ const promiseList = [
60
+ dataSourceAPI.getRecordList(queryParams, {
61
+ db: childDbName,
62
+ }),
63
+ ];
64
+ if (value === null || value === void 0 ? void 0 : value.length) {
65
+ if (isMultiple) {
66
+ value.forEach((i) => {
67
+ if (i) {
68
+ promiseList.push(dataSourceAPI.getRecord(i, {
69
+ db: childDbName,
70
+ }));
71
+ }
72
+ });
63
73
  }
64
- let optionRes = mapResult(transformedRecords, primaryColumn);
65
- if ((queryParams === null || queryParams === void 0 ? void 0 : queryParams.pageNo) > defaultPage) {
66
- optionRes = [...option, ...optionRes];
74
+ else {
75
+ promiseList.push(dataSourceAPI.getRecord(value, {
76
+ db: childDbName,
77
+ }));
67
78
  }
68
- setOption(optionRes);
69
- setTotal(result === null || result === void 0 ? void 0 : result.total);
70
- setLoading(false);
71
79
  }
72
- fetchData();
80
+ const [result, ...rest] = await Promise.all(promiseList);
81
+ let transformedRecords = [...((result === null || result === void 0 ? void 0 : result.records) || [])];
82
+ const itemResult = [...rest];
83
+ // 若下拉列表中无选中值,则将选中值插到数组头部
84
+ if ((isMultiple && (value === null || value === void 0 ? void 0 : value.length)) || value) {
85
+ itemResult.forEach((i) => {
86
+ transformedRecords = unshiftVal(transformedRecords, i);
87
+ });
88
+ }
89
+ let optionRes = mapResult(transformedRecords, primaryColumn);
90
+ if ((queryParams === null || queryParams === void 0 ? void 0 : queryParams.pageNo) > defaultPage) {
91
+ optionRes = [...option, ...optionRes];
92
+ }
93
+ setOption(optionRes);
94
+ setTotal(result === null || result === void 0 ? void 0 : result.total);
95
+ setLoading(false);
73
96
  // eslint-disable-next-line react-hooks/exhaustive-deps
74
- }, [childDbName, queryParams]);
97
+ }, [childDbName, primaryColumn, queryParams]);
98
+ useEffect(() => {
99
+ if (childDbName) {
100
+ fetchData();
101
+ }
102
+ }, [childDbName, fetchData]);
75
103
  return {
76
104
  result: option || [],
77
105
  total: total,
@@ -79,5 +107,6 @@ export const useChooseList = ({ dataSourceAPI, queryParams, childDbName, primary
79
107
  empty: () => {
80
108
  setOption([]);
81
109
  },
110
+ getRelationOptions: fetchData,
82
111
  };
83
112
  };
@@ -412,7 +412,7 @@ export const getFilterFields = (filterFields, authFields) => {
412
412
  var _a;
413
413
  let result = [];
414
414
  try {
415
- const filterFieldsObj = JSON.parse(JSON.stringify(filterFields));
415
+ const filterFieldsObj = filterFields && JSON.parse(JSON.stringify(filterFields));
416
416
  if (filterFields === null || filterFields === void 0 ? void 0 : filterFields.filterConfig) {
417
417
  // 变量绑定的情况
418
418
  // 筛选有权限的字段
@@ -371,10 +371,10 @@ export const WdTable = forwardRef(function TableComp(tableProps, ref) {
371
371
  if (isExpression &&
372
372
  Array.isArray(dataSourceData) &&
373
373
  !isObjectEqual((_a = dataRef === null || dataRef === void 0 ? void 0 : dataRef.current) === null || _a === void 0 ? void 0 : _a.dataSourceData, dataSourceData)) {
374
- dataRef.current.dataSourceData = dataSourceData || [];
374
+ dataRef.current.dataSourceData = [...dataSourceData];
375
375
  }
376
376
  if (!isObjectEqual((_b = dataRef === null || dataRef === void 0 ? void 0 : dataRef.current) === null || _b === void 0 ? void 0 : _b.tableRecords, tableRecords)) {
377
- dataRef.current.tableRecords = tableRecords || [];
377
+ dataRef.current.tableRecords = [...tableRecords];
378
378
  }
379
379
  }, [dataSourceData, tableRecords, isExpression]);
380
380
  const beforeModalDestroy = () => {
@@ -1,2 +1,2 @@
1
1
  export function serde(a: any): any;
2
- export default function _default(a: any, b: any, shouldSerde?: boolean): any;
2
+ export default function _default(a: any, b: any, shouldSerde?: boolean): boolean;
@@ -1,3 +1,4 @@
1
+ /// <reference types="moment" />
1
2
  declare const moment: typeof import("moment");
2
3
  export declare const convertMoment: (val: any) => any;
3
4
  export default moment;
@@ -284,12 +284,12 @@ export const textToString = (text) => {
284
284
  * 统一错误提示
285
285
  */
286
286
  export function alertErrorMessage({ message, duration = 3000, icon = 'none' }) {
287
- var _a, _b, _c, _d, _e;
287
+ var _a, _b, _c, _d, _e, _f;
288
288
  const smallScreen = (_b = (_a = window === null || window === void 0 ? void 0 : window.matchMedia('(max-width: 768px)')) === null || _a === void 0 ? void 0 : _a.matches) !== null && _b !== void 0 ? _b : isH5Platform();
289
289
  const touchDevice = (_d = (_c = window === null || window === void 0 ? void 0 : window.matchMedia('(pointer:coarse)')) === null || _c === void 0 ? void 0 : _c.matches) !== null && _d !== void 0 ? _d : smallScreen;
290
290
  const platform = touchDevice || smallScreen ? 'h5' : 'pc';
291
- if (platform === 'h5') {
292
- (_e = window === null || window === void 0 ? void 0 : window.app) === null || _e === void 0 ? void 0 : _e.showToast({
291
+ if (platform === 'h5' && ((_e = window === null || window === void 0 ? void 0 : window.app) === null || _e === void 0 ? void 0 : _e.showToast)) {
292
+ (_f = window === null || window === void 0 ? void 0 : window.app) === null || _f === void 0 ? void 0 : _f.showToast({
293
293
  title: message,
294
294
  icon,
295
295
  duration,
@@ -227,10 +227,10 @@ export const convertSingleValue = (value, single) => {
227
227
  let v = value;
228
228
  if (value !== null) {
229
229
  if (single && typeof value !== 'string') {
230
- v = null;
230
+ v = Array.isArray(value) ? value[0] : null;
231
231
  }
232
232
  else if (!single && !Array.isArray(value)) {
233
- v = [];
233
+ v = value ? [].concat(value) : [];
234
234
  }
235
235
  }
236
236
  return v;