@ebiz/designer-components 0.0.18-kzy.2 → 0.0.18-kzy.3

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-kzy.2",
3
+ "version": "0.0.18-kzy.3",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -7,8 +7,10 @@
7
7
  import axios from 'axios'
8
8
  import { TinyNotify } from '@opentiny/vue'
9
9
 
10
- // 从环境变量获取API基础URL
11
- const API_BASE_URL = "http://localhost:8090/api";
10
+ // 本地开发使用
11
+ // const API_BASE_URL = "http://localhost:8090/api";
12
+ // 组件发布使用
13
+ const API_BASE_URL = 'http://' + window.location.host + '/api'
12
14
 
13
15
  /**
14
16
  * 创建axios实例
@@ -0,0 +1,104 @@
1
+ <template>
2
+ <tiny-tooltip :content="!isNormal && !apiConfig.apiId ? tooltipText : ''" placement="top">
3
+
4
+ <tiny-button :disabled="disabled" :type="type" :size="size" @click="click">
5
+ <slot>{{ text }}</slot>
6
+ </tiny-button>
7
+
8
+ </tiny-tooltip>
9
+ </template>
10
+
11
+
12
+ <script lang='js'>
13
+ export default {
14
+ name: "EbizButton"
15
+ }
16
+ </script>
17
+
18
+ <script lang='js' setup>
19
+
20
+ import { ref, reactive, computed, toRef, toRefs } from 'vue';
21
+ import { TinyButton, TinyTooltip, TinyNotify } from '@opentiny/vue';
22
+ import dataService from '../apiService/simpleDataService';
23
+
24
+
25
+ const props = defineProps({
26
+ text: {
27
+ type: String,
28
+ default: ''
29
+ },
30
+ isNormal: {//是否为普通按钮
31
+ type: Boolean,
32
+ default: false
33
+ },
34
+ disabled: {
35
+ type: Boolean,
36
+ default: false
37
+ },
38
+ type: {//'default' | 'primary' | 'success' | 'warning' | 'danger' | 'info' | 'text'
39
+ type: String,
40
+ default: 'default'
41
+ },
42
+ size: {//'large' | 'medium' | 'small' | 'mini'
43
+ type: String,
44
+ default: 'medium'
45
+ },
46
+ apiConfig: {//接口配置
47
+ type: Object,
48
+ default: {
49
+ key: null,
50
+ apiId: null,
51
+ apiType: ''
52
+ }
53
+ },
54
+ data: {
55
+ type: Object,
56
+ default: {}
57
+ },
58
+ onClick: {
59
+ type: Function,
60
+ default: () => { }
61
+ },
62
+ onPrepare: {//调用接口前置事件
63
+ type: Function,
64
+ default: () => { }
65
+ },
66
+ onFinish: {//调用接口后置事件
67
+ type: Function,
68
+ default: () => { }
69
+ }
70
+ })
71
+
72
+ const apiMap = [
73
+ 'MULTIPLE_DATA_SEARCH',
74
+ 'DETAILS_DATA',
75
+ 'INTERFACE_PLUGIN',
76
+ 'DATA_INSERT',
77
+ 'BATCH_DATA_INSERT',
78
+ 'DATA_MODIFY',
79
+ 'BATCH_DATA_MODIFY',
80
+ 'DEL_DATA',
81
+ 'BATCH_DEL_DATA',
82
+ 'MULTIPLE_DATA_LINK_SEARCH'
83
+ ];
84
+
85
+ const emit = defineEmits(['click'])
86
+
87
+ const { text, isNormal, disabled, type, size, apiConfig, data, isUseMethod } = toRefs(props)
88
+
89
+ const tooltipText = ref('请先设置接口配置')
90
+
91
+ const click = () => {
92
+ props.onClick()
93
+ if (!isNormal.value && apiConfig.value.apiId) {
94
+ props.onPrepare()
95
+ dataService.fetch(data.value, { key: apiConfig.value.key, apiId: apiConfig.value.apiId, apiType: apiMap[apiConfig.value.apiType] }).then((res) => {
96
+ emit('click', res)
97
+ props.onFinish()
98
+ })
99
+ }
100
+ }
101
+
102
+ </script>
103
+
104
+ <style lang='less' scoped></style>
@@ -62,7 +62,7 @@ const props = defineProps({
62
62
  */
63
63
  clearable: {
64
64
  type: Boolean,
65
- default: true
65
+ default: false
66
66
  },
67
67
  /**
68
68
  * 是否禁用
@@ -155,11 +155,16 @@ const handleRemoteSearch = async (keyword) => {
155
155
  keyword
156
156
  }
157
157
  };
158
- const res = await dataService.fetch(params, props.apiConfig);
158
+ const res = await dataService.fetch(params, {
159
+ key: props.apiConfig.key,
160
+ apiId: props.apiConfig.apiId,
161
+ apiType: 'MULTIPLE_DATA_SEARCH'
162
+ });
159
163
 
160
164
  options.value = res.data.map(item => ({
161
- label: labelField.value ? item[labelField.value] : item.name,
162
- value: valueField.value ? item[valueField.value] : item.id
165
+ ...item,
166
+ label: labelField.value ? item[labelField.value] : (item.label || item.name),
167
+ value: valueField.value ? item[valueField.value] : (item.value || item.id)
163
168
  }));
164
169
  } catch (error) {
165
170
  console.error('远程搜索失败:', error);
@@ -188,7 +193,11 @@ const handleBlur = (value, context) => {
188
193
  const handleChange = (value, context) => {
189
194
  emit('update:modelValue', value);
190
195
  emit('change', value, context);
191
- emit('selectOption', options.value.find(item => item.value === value));
196
+ if (value instanceof Array) {
197
+ emit('selectOption', options.value.filter(item => value.includes(item.value)));
198
+ } else {
199
+ emit('selectOption', options.value.find(item => item.value === value));
200
+ }
192
201
  };
193
202
 
194
203
  // 组件挂载时,如果有默认值则加载对应的选项
@@ -205,10 +214,10 @@ onMounted(async () => {
205
214
  apiType: 'MULTIPLE_DATA_SEARCH'
206
215
  });
207
216
 
208
- console.log('res', res)
209
217
  options.value = res.data.map(item => ({
210
- label: labelField.value ? item[labelField.value] : item.name,
211
- value: valueField.value ? item[valueField.value] : item.id
218
+ ...item,
219
+ label: labelField.value ? item[labelField.value] : (item.label || item.name),
220
+ value: valueField.value ? item[valueField.value] : (item.value || item.id)
212
221
  }));
213
222
  } catch (error) {
214
223
  console.error('加载默认选项失败:', error);
@@ -29,7 +29,9 @@ export default {
29
29
  const matched = route.matched.filter(item => item.meta && item.meta.title)
30
30
  return matched.map(item => ({
31
31
  title: item.meta.title,
32
- path: item.path
32
+ path: {
33
+ path: item.path
34
+ }
33
35
  }))
34
36
  })
35
37
 
@@ -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);
@@ -0,0 +1,117 @@
1
+ <script setup>
2
+ import { computed, inject, onMounted, getCurrentInstance } from 'vue';
3
+
4
+ const props = defineProps({
5
+ // 列唯一标识
6
+ colKey: {
7
+ type: String,
8
+ required: true
9
+ },
10
+ // 列标题
11
+ title: {
12
+ type: String,
13
+ default: ''
14
+ },
15
+ // 列宽度
16
+ width: {
17
+ type: [String, Number],
18
+ default: ''
19
+ },
20
+ // 最小列宽
21
+ minWidth: {
22
+ type: [String, Number],
23
+ default: ''
24
+ },
25
+ // 水平对齐方式
26
+ align: {
27
+ type: String,
28
+ default: 'left',
29
+ validator: (val) => ['left', 'center', 'right'].includes(val)
30
+ },
31
+ // 固定列位置
32
+ fixed: {
33
+ type: String,
34
+ default: '',
35
+ validator: (val) => ['', 'left', 'right'].includes(val)
36
+ },
37
+ // 列类型
38
+ type: {
39
+ type: String,
40
+ default: '',
41
+ validator: (val) => ['', 'multiple', 'single', 'index', 'expand'].includes(val)
42
+ },
43
+ // 超出省略
44
+ ellipsis: {
45
+ type: Boolean,
46
+ default: false
47
+ },
48
+ // 标题超出省略
49
+ ellipsisTitle: {
50
+ type: Boolean,
51
+ default: false
52
+ },
53
+ // 是否支持排序
54
+ sorter: {
55
+ type: Boolean,
56
+ default: false
57
+ },
58
+ // 过滤配置
59
+ filter: {
60
+ type: Object,
61
+ default: null
62
+ },
63
+ // 自定义类名
64
+ className: {
65
+ type: String,
66
+ default: ''
67
+ },
68
+ // 是否禁用
69
+ disabled: {
70
+ type: Boolean,
71
+ default: false
72
+ }
73
+ });
74
+
75
+ // 获取父级表格组件实例
76
+ const tableCtx = inject('tableCtx', null);
77
+ const instance = getCurrentInstance();
78
+
79
+ // 格式化列配置对象
80
+ const columnConfig = computed(() => {
81
+ return {
82
+ colKey: props.colKey,
83
+ title: props.title,
84
+ width: props.width,
85
+ minWidth: props.minWidth,
86
+ align: props.align,
87
+ fixed: props.fixed || '',
88
+ type: props.type || '',
89
+ ellipsis: props.ellipsis,
90
+ ellipsisTitle: props.ellipsisTitle,
91
+ sorter: props.sorter,
92
+ filter: props.filter,
93
+ className: props.className,
94
+ disabled: props.disabled,
95
+ cell: instance.slots.default ? props.colKey : undefined,
96
+ title: instance.slots.title ? `title-${props.colKey}` : undefined
97
+ };
98
+ });
99
+
100
+ // 在组件挂载时将列配置注册到表格组件
101
+ onMounted(() => {
102
+ if (tableCtx && typeof tableCtx.registerColumn === 'function') {
103
+ tableCtx.registerColumn(columnConfig.value);
104
+ } else {
105
+ console.warn('EbizTableColumn必须在EbizTable内部使用');
106
+ }
107
+ });
108
+ </script>
109
+
110
+ <template>
111
+ <template v-if="$slots.default">
112
+ <slot></slot>
113
+ </template>
114
+ <template v-if="$slots.title">
115
+ <slot name="title"></slot>
116
+ </template>
117
+ </template>