@ebiz/designer-components 0.0.18-beta.25 → 0.0.18-beta.26

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ebiz/designer-components",
3
- "version": "0.0.18-beta.25",
3
+ "version": "0.0.18-beta.26",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -0,0 +1,249 @@
1
+ <template>
2
+ <t-dialog
3
+ v-model:visible="dialogVisible"
4
+ :attach="attach"
5
+ :body-class="bodyClass"
6
+ :body-scroll-lock="bodyScrollLock"
7
+ :cancel-btn="cancelBtn"
8
+ :class-prefix="classPrefix"
9
+ :close-btn="closeBtn"
10
+ :close-on-esc-keydown="closeOnEscKeydown"
11
+ :close-on-overlay-click="closeOnOverlayClick"
12
+ :confirm-btn="confirmBtn"
13
+ :content="content"
14
+ :default-visible="defaultVisible"
15
+ :destroy-on-close="destroyOnClose"
16
+ :dialog-class="dialogClass"
17
+ :draggable="draggable"
18
+ :footer="footer"
19
+ :header="header"
20
+ :mode="mode"
21
+ :placement="placement"
22
+ :prevent-scroll-through="preventScrollThrough"
23
+ :show-overlay="showOverlay"
24
+ :top="top"
25
+ :width="width"
26
+ :zIndex="zIndex"
27
+ @cancel="handleCancel"
28
+ @close="handleClose"
29
+ @closed="handleClosed"
30
+ @confirm="handleConfirm"
31
+ @opened="handleOpened"
32
+ @overlay-click="handleOverlayClick"
33
+ @update:visible="handleUpdateVisible"
34
+ >
35
+ <!-- 默认插槽 -->
36
+ <slot></slot>
37
+
38
+ <!-- 页脚插槽 -->
39
+ <template v-if="$slots.footer" #footer>
40
+ <slot name="footer"></slot>
41
+ </template>
42
+
43
+ <!-- 头部插槽 -->
44
+ <template #header>
45
+ <slot name="header">{{ title }}</slot>
46
+ </template>
47
+ </t-dialog>
48
+ </template>
49
+
50
+ <script>
51
+ export default {
52
+ name: "EbizDialog"
53
+ }
54
+ </script>
55
+
56
+ <script setup>
57
+ import { ref, defineProps, defineEmits, watch } from 'vue';
58
+ import { Dialog as TDialog } from 'tdesign-vue-next';
59
+
60
+ // 定义组件接收的属性
61
+ const props = defineProps({
62
+ // 对话框挂载的节点
63
+ attach: {
64
+ type: [String, Function, Element],
65
+ default: 'body'
66
+ },
67
+ // 对话框内容的类名
68
+ bodyClass: {
69
+ type: String,
70
+ default: ''
71
+ },
72
+ // 是否锁定body滚动
73
+ bodyScrollLock: {
74
+ type: Boolean,
75
+ default: true
76
+ },
77
+ // 取消按钮配置
78
+ cancelBtn: {
79
+ type: [String, Object, Boolean],
80
+ default: null
81
+ },
82
+ // 类名前缀
83
+ classPrefix: {
84
+ type: String,
85
+ default: 't'
86
+ },
87
+ // 关闭按钮配置
88
+ closeBtn: {
89
+ type: [String, Object, Boolean],
90
+ default: true
91
+ },
92
+ // 是否支持按ESC键关闭对话框
93
+ closeOnEscKeydown: {
94
+ type: Boolean,
95
+ default: true
96
+ },
97
+ // 点击蒙层是否关闭
98
+ closeOnOverlayClick: {
99
+ type: Boolean,
100
+ default: true
101
+ },
102
+ // 确认按钮配置
103
+ confirmBtn: {
104
+ type: [String, Object, Boolean],
105
+ default: '确认'
106
+ },
107
+ // 对话框内容
108
+ content: {
109
+ type: [String, Function],
110
+ default: ''
111
+ },
112
+ // 默认是否显示对话框
113
+ defaultVisible: {
114
+ type: Boolean,
115
+ default: false
116
+ },
117
+ // 关闭时是否销毁对话框
118
+ destroyOnClose: {
119
+ type: Boolean,
120
+ default: false
121
+ },
122
+ // 对话框样式类
123
+ dialogClass: {
124
+ type: String,
125
+ default: ''
126
+ },
127
+ // 是否可拖拽
128
+ draggable: {
129
+ type: Boolean,
130
+ default: false
131
+ },
132
+ // 底部内容
133
+ footer: {
134
+ type: [Boolean, Function],
135
+ default: true
136
+ },
137
+ // 头部内容
138
+ header: {
139
+ type: [Boolean, Function],
140
+ default: true
141
+ },
142
+ // 对话框类型
143
+ mode: {
144
+ type: String,
145
+ default: 'modal',
146
+ validator: (val) => ['modal', 'modeless', 'full-screen'].includes(val)
147
+ },
148
+ // 对话框位置
149
+ placement: {
150
+ type: String,
151
+ default: 'top',
152
+ validator: (val) => ['top', 'center'].includes(val)
153
+ },
154
+ // 防止滚动穿透
155
+ preventScrollThrough: {
156
+ type: Boolean,
157
+ default: true
158
+ },
159
+ // 是否显示遮罩层
160
+ showOverlay: {
161
+ type: Boolean,
162
+ default: true
163
+ },
164
+ // 对话框标题
165
+ title: {
166
+ type: [String, Function],
167
+ default: ''
168
+ },
169
+ // 距离顶部的位置
170
+ top: {
171
+ type: [String, Number],
172
+ default: '15%'
173
+ },
174
+ // 对话框可见性
175
+ visible: {
176
+ type: Boolean,
177
+ default: undefined
178
+ },
179
+ // 对话框宽度
180
+ width: {
181
+ type: [String, Number],
182
+ default: '500px'
183
+ },
184
+ // 对话框层级
185
+ zIndex: {
186
+ type: Number,
187
+ default: 2500
188
+ }
189
+ });
190
+
191
+ // 定义组件的事件
192
+ const emit = defineEmits([
193
+ 'cancel',
194
+ 'close',
195
+ 'closed',
196
+ 'confirm',
197
+ 'opened',
198
+ 'overlay-click',
199
+ 'update:visible'
200
+ ]);
201
+
202
+ // 内部维护的可见性状态
203
+ const dialogVisible = ref(props.visible !== undefined ? props.visible : props.defaultVisible);
204
+
205
+ // 监听visible属性变化
206
+ watch(() => props.visible, (newValue) => {
207
+ dialogVisible.value = newValue;
208
+ });
209
+
210
+ // 取消按钮点击事件
211
+ const handleCancel = (e) => {
212
+ emit('cancel', e);
213
+ };
214
+
215
+ // 关闭事件
216
+ const handleClose = (e) => {
217
+ emit('close', e);
218
+ };
219
+
220
+ // 关闭动画结束后触发
221
+ const handleClosed = () => {
222
+ emit('closed');
223
+ };
224
+
225
+ // 确认按钮点击事件
226
+ const handleConfirm = (e) => {
227
+ emit('confirm', e);
228
+ };
229
+
230
+ // 对话框打开动画结束后触发
231
+ const handleOpened = () => {
232
+ emit('opened');
233
+ };
234
+
235
+ // 点击遮罩层触发
236
+ const handleOverlayClick = (context) => {
237
+ emit('overlay-click', context);
238
+ };
239
+
240
+ // 可见性变化事件
241
+ const handleUpdateVisible = (visible) => {
242
+ dialogVisible.value = visible;
243
+ emit('update:visible', visible);
244
+ };
245
+ </script>
246
+
247
+ <style lang="less" scoped>
248
+ /* 自定义样式 */
249
+ </style>
@@ -41,9 +41,7 @@ const props = defineProps({
41
41
  */
42
42
  queryParams: {
43
43
  type: Object,
44
- default: () => ({
45
- name: ''
46
- })
44
+ default: () => ({})
47
45
  },
48
46
  /**
49
47
  * 是否多选
@@ -64,7 +62,7 @@ const props = defineProps({
64
62
  */
65
63
  clearable: {
66
64
  type: Boolean,
67
- default: true
65
+ default: false
68
66
  },
69
67
  /**
70
68
  * 是否禁用
@@ -148,18 +146,15 @@ defineExpose({
148
146
  // 远程搜索处理函数
149
147
  const handleRemoteSearch = async (keyword) => {
150
148
  loading.value = true;
149
+ console.log('handleRemoteSearch', keyword);
151
150
  try {
152
151
  const params = {
153
152
  queryParams: {
154
153
  ...queryParams.value,
155
- name: keyword
154
+ keyword
156
155
  }
157
156
  };
158
- const res = await dataService.fetch(params, {
159
- key: props.apiConfig.key,
160
- apiId: props.apiConfig.apiId,
161
- apiType: 'MULTIPLE_DATA_SEARCH'
162
- });
157
+ const res = await dataService.fetch(params, props.apiConfig);
163
158
  const { labelField, valueField } = props.optionsConfig;
164
159
 
165
160
  options.value = res.data.map(item => ({
@@ -1,130 +1,90 @@
1
1
  <template>
2
- <t-table
3
- :data="data"
4
- :columns="columns"
5
- :row-key="rowKey"
6
- :vertical-align="verticalAlign"
7
- :horizontal-align="horizontalAlign"
8
- :size="size"
9
- :bordered="bordered"
10
- :stripe="stripe"
11
- :hover="hover"
12
- :height="height"
13
- :max-height="maxHeight"
14
- :loading="loading"
15
- :loading-props="loadingProps"
16
- :load-more="loadMore"
17
- :empty="empty"
18
- :table-layout="tableLayout"
19
- :cell-empty-content="cellEmptyContent"
20
- :pagination="pagination"
21
- :show-header="showHeader"
22
- :header-affixed-top="headerAffixedTop"
23
- :footer-affixed-bottom="footerAffixedBottom"
24
- :top-content="topContent"
25
- :bottom-content="bottomContent"
26
- :sort="sort"
27
- :filter-value="filterValue"
28
- :filter-icon="filterIcon"
29
- :tree="tree"
30
- :resizable="resizable"
31
- :column-controller="columnController"
32
- :column-controller-visible="columnControllerVisible"
33
- :expandable="expandable"
34
- :disabled-sort="disabledSort"
35
- :virtual-scroll="virtualScroll"
36
- :indent="indent"
37
- :row-attributes="rowAttributes"
38
- :scroll="scroll"
39
- :show-sort-column-bg="showSortColumnBg"
40
- :allow-sort-by-click-header="allowSortByClickHeader"
41
- :dragSort="dragSort"
42
- :select-on-row-click="selectOnRowClick"
43
- :merge-cells="mergeCells"
44
- :value="value"
45
- :row-className="rowClassName"
46
- :fixed-rows="fixedRows"
47
- :highlight-current-row="highlightCurrentRow"
48
- :ellipsis-title="ellipsisTitle"
49
- @page-change="handlePageChange"
50
- @sort-change="handleSortChange"
51
- @filter-change="handleFilterChange"
52
- @select-change="handleSelectChange"
53
- @expanded-change="handleExpandedChange"
54
- @cell-click="handleCellClick"
55
- @row-click="handleRowClick"
56
- @row-hover="handleRowHover"
57
- @row-dblclick="handleRowDblclick"
58
- @scroll="handleScroll"
59
- @column-change="handleColumnChange"
60
- @expand-all="handleExpandAll"
61
- @tree-expand-change="handleTreeExpandChange"
62
- @display-columns-change="handleDisplayColumnsChange"
63
- @column-controller-visible-change="handleColumnControllerVisibleChange"
64
- @drag-sort="handleDragSort"
65
- @validate="handleValidate"
66
- >
67
-
68
-
69
-
70
- <!-- 顶部内容插槽 -->
71
- <template v-if="$slots.topContent" #topContent>
72
- <slot name="topContent"></slot>
73
- </template>
74
-
75
- <!-- 底部内容插槽 -->
76
- <template v-if="$slots.bottomContent" #bottomContent>
77
- <slot name="bottomContent"></slot>
78
- </template>
79
-
80
- <!-- 空状态插槽 -->
81
- <template v-if="$slots.empty" #empty>
82
- <slot name="empty"></slot>
83
- </template>
84
-
85
- <!-- 加载更多插槽 -->
86
- <template v-if="$slots.loadMore" #loadMore>
87
- <slot name="loadMore"></slot>
88
- </template>
89
-
90
- <!-- 表头插槽 -->
91
- <template v-if="$slots.header" #header>
92
- <slot name="header"></slot>
93
- </template>
94
-
95
- <!-- 表尾插槽 -->
96
- <template v-if="$slots.footer" #footer>
97
- <slot name="footer"></slot>
98
- </template>
99
-
100
- <!-- 自定义单元格插槽 -->
101
- <template v-if="$slots.cell" #cell="slotProps">
102
- <slot name="cell" v-bind="slotProps"></slot>
103
- </template>
104
-
105
- <!-- 展开行插槽 -->
106
- <template v-if="$slots.expandedRow" #expandedRow="slotProps">
107
- <slot name="expandedRow" v-bind="slotProps"></slot>
108
- </template>
109
-
110
- <!-- 过滤图标插槽 -->
111
- <template v-if="$slots.filterIcon" #filterIcon="slotProps">
112
- <slot name="filterIcon" v-bind="slotProps"></slot>
113
- </template>
114
-
115
- <!-- 自定义列配置按钮插槽 -->
116
- <template v-if="$slots.columnController" #columnController="slotProps">
117
- <slot name="columnController" v-bind="slotProps"></slot>
118
- </template>
119
-
120
- <!-- 自定义分页器插槽 -->
121
- <template v-if="$slots.pagination" #pagination="slotProps">
122
- <slot name="pagination" v-bind="slotProps"></slot>
123
- </template>
124
-
125
- <!-- 默认插槽 -->
126
- <slot></slot>
127
- </t-table>
2
+ <div>
3
+ <t-table :data="data" :columns="mergedColumns" :row-key="rowKey" :vertical-align="verticalAlign"
4
+ :horizontal-align="horizontalAlign" :size="size" :bordered="bordered" :stripe="stripe" :hover="hover"
5
+ :height="height" :max-height="maxHeight" :loading="loading" :loading-props="loadingProps" :load-more="loadMore"
6
+ :empty="empty" :table-layout="tableLayout" :cell-empty-content="cellEmptyContent" :pagination="pagination"
7
+ :show-header="showHeader" :header-affixed-top="headerAffixedTop" :footer-affixed-bottom="footerAffixedBottom"
8
+ :top-content="topContent" :bottom-content="bottomContent" :sort="sort" :filter-value="filterValue"
9
+ :filter-icon="filterIcon" :tree="tree" :resizable="resizable" :column-controller="columnController"
10
+ :column-controller-visible="columnControllerVisible" :expandable="expandable" :disabled-sort="disabledSort"
11
+ :virtual-scroll="virtualScroll" :indent="indent" :row-attributes="rowAttributes" :scroll="scroll"
12
+ :show-sort-column-bg="showSortColumnBg" :allow-sort-by-click-header="allowSortByClickHeader" :dragSort="dragSort"
13
+ :select-on-row-click="selectOnRowClick" :merge-cells="mergeCells" :value="value" :row-className="rowClassName"
14
+ :fixed-rows="fixedRows" :highlight-current-row="highlightCurrentRow" :ellipsis-title="ellipsisTitle"
15
+ @page-change="handlePageChange" @sort-change="handleSortChange" @filter-change="handleFilterChange"
16
+ @select-change="handleSelectChange" @expanded-change="handleExpandedChange" @cell-click="handleCellClick"
17
+ @row-click="handleRowClick" @row-hover="handleRowHover" @row-dblclick="handleRowDblclick" @scroll="handleScroll"
18
+ @column-change="handleColumnChange" @expand-all="handleExpandAll" @tree-expand-change="handleTreeExpandChange"
19
+ @display-columns-change="handleDisplayColumnsChange"
20
+ @column-controller-visible-change="handleColumnControllerVisibleChange" @drag-sort="handleDragSort"
21
+ @validate="handleValidate">
22
+
23
+
24
+
25
+ <!-- 顶部内容插槽 -->
26
+ <template v-if="$slots.topContent" #topContent>
27
+ <slot name="topContent"></slot>
28
+ </template>
29
+
30
+ <!-- 底部内容插槽 -->
31
+ <template v-if="$slots.bottomContent" #bottomContent>
32
+ <slot name="bottomContent"></slot>
33
+ </template>
34
+
35
+ <!-- 空状态插槽 -->
36
+ <template v-if="$slots.empty" #empty>
37
+ <slot name="empty"></slot>
38
+ </template>
39
+
40
+ <!-- 加载更多插槽 -->
41
+ <template v-if="$slots.loadMore" #loadMore>
42
+ <slot name="loadMore"></slot>
43
+ </template>
44
+
45
+ <!-- 表头插槽 -->
46
+ <template v-if="$slots.header" #header>
47
+ <slot name="header"></slot>
48
+ </template>
49
+
50
+ <!-- 表尾插槽 -->
51
+ <template v-if="$slots.footer" #footer>
52
+ <slot name="footer"></slot>
53
+ </template>
54
+
55
+ <!-- 自定义单元格插槽 -->
56
+ <template v-for="column in dynamicColumns" :key="column.colKey" v-if="column.cell" #[column.cell]="cellProps">
57
+ <slot :name="`cell-${column.colKey}`" v-bind="cellProps"></slot>
58
+ </template>
59
+ <template v-for="column in dynamicColumns" :key="column.colKey" v-if="column.title" #[column.title]="titleProps">
60
+ <slot :name="`title-${column.colKey}`" v-bind="titleProps"></slot>
61
+ </template>
62
+
63
+ <!-- 展开行插槽 -->
64
+ <template v-if="$slots.expandedRow" #expandedRow="slotProps">
65
+ <slot name="expandedRow" v-bind="slotProps"></slot>
66
+ </template>
67
+
68
+ <!-- 过滤图标插槽 -->
69
+ <template v-if="$slots.filterIcon" #filterIcon="slotProps">
70
+ <slot name="filterIcon" v-bind="slotProps"></slot>
71
+ </template>
72
+
73
+ <!-- 自定义列配置按钮插槽 -->
74
+ <template v-if="$slots.columnController" #columnController="slotProps">
75
+ <slot name="columnController" v-bind="slotProps"></slot>
76
+ </template>
77
+
78
+ <!-- 自定义分页器插槽 -->
79
+ <template v-if="$slots.pagination" #pagination="slotProps">
80
+ <slot name="pagination" v-bind="slotProps"></slot>
81
+ </template>
82
+
83
+ <!-- 默认插槽 -->
84
+ <slot></slot>
85
+ </t-table>
86
+ </div>
87
+
128
88
  </template>
129
89
 
130
90
  <script>
@@ -134,8 +94,8 @@ export default {
134
94
  </script>
135
95
 
136
96
  <script setup>
137
- import { defineProps, defineEmits } from 'vue';
138
- import { Table as TTable } from 'tdesign-vue-next';
97
+ import { ref, computed, onMounted, watch, provide } from 'vue';
98
+ import { Table } from 'tdesign-vue-next';
139
99
 
140
100
  const props = defineProps({
141
101
  // 表格数据
@@ -284,8 +244,8 @@ const props = defineProps({
284
244
  },
285
245
  // 列配置器
286
246
  columnController: {
287
- type: Object,
288
- default: undefined
247
+ type: Boolean,
248
+ default: false
289
249
  },
290
250
  // 列配置器是否显示
291
251
  columnControllerVisible: {
@@ -335,8 +295,8 @@ const props = defineProps({
335
295
  // 拖拽排序配置
336
296
  dragSort: {
337
297
  type: String,
338
- default: undefined,
339
- validator: (val) => ['row', 'row-handler', 'col', 'row-handler-col', 'drag-col'].includes(val)
298
+ default: '',
299
+ validator: (val) => ['', 'row', 'col', 'row-handler', 'row-handler-col'].includes(val)
340
300
  },
341
301
  // 点击行是否选中
342
302
  selectOnRowClick: {
@@ -371,7 +331,7 @@ const props = defineProps({
371
331
  // 表头文字超出是否显示省略号
372
332
  ellipsisTitle: {
373
333
  type: Boolean,
374
- default: undefined
334
+ default: false
375
335
  }
376
336
  });
377
337
 
@@ -395,6 +355,26 @@ const emit = defineEmits([
395
355
  'validate'
396
356
  ]);
397
357
 
358
+ // 动态列配置(由EbizTableColumn子组件注册)
359
+ const dynamicColumns = ref([]);
360
+
361
+ // 合并props中的columns和动态注册的columns
362
+ const mergedColumns = computed(() => {
363
+ return [...props.columns, ...dynamicColumns.value];
364
+ });
365
+
366
+ // 提供注册列的方法给子组件
367
+ const registerColumn = (column) => {
368
+ if (!dynamicColumns.value.some(item => item.colKey === column.colKey)) {
369
+ dynamicColumns.value.push(column);
370
+ }
371
+ };
372
+
373
+ // 提供表格上下文给子组件
374
+ provide('tableCtx', {
375
+ registerColumn
376
+ });
377
+
398
378
  // 分页变化
399
379
  const handlePageChange = (pageInfo) => {
400
380
  emit('page-change', pageInfo);