@ebiz/designer-components 0.0.18-tj.1 → 0.0.19-beta.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 (70) hide show
  1. package/dist/designer-components.css +1 -1
  2. package/dist/index.mjs +66100 -52710
  3. package/package.json +1 -1
  4. package/src/apiService/mockDataService.js +116 -0
  5. package/src/apiService/simpleDataService.js +186 -80
  6. package/src/components/Button.vue +72 -22
  7. package/src/components/EbizAvatar.vue +116 -0
  8. package/src/components/EbizCheckbox.vue +94 -0
  9. package/src/components/EbizCheckboxGroup.vue +70 -0
  10. package/src/components/EbizDetailBlock.vue +82 -0
  11. package/src/components/EbizDialog.vue +249 -0
  12. package/src/components/EbizEmployeeInfo.vue +139 -0
  13. package/src/components/EbizPageHeader.vue +96 -0
  14. package/src/components/EbizPagination.vue +163 -0
  15. package/src/components/EbizRadio.vue +87 -0
  16. package/src/components/EbizRadioGroup.vue +84 -0
  17. package/src/components/EbizRemoteSelect.vue +107 -41
  18. package/src/components/EbizStatistic.vue +150 -0
  19. package/src/components/EbizSwiper.vue +3 -3
  20. package/src/components/EbizSwitch.vue +86 -0
  21. package/src/components/EbizTabHeader.vue +6 -10
  22. package/src/components/EbizTabPanel.vue +23 -0
  23. package/src/components/EbizTable.vue +466 -0
  24. package/src/components/EbizTableColumn.vue +117 -0
  25. package/src/components/EbizTableSort.vue +181 -0
  26. package/src/components/EbizTabs.vue +143 -0
  27. package/src/components/EbizTimePicker.vue +144 -0
  28. package/src/components/EbizTitle.vue +36 -37
  29. package/src/components/EbizTree.vue +153 -0
  30. package/src/components/EbizTreeSelector.vue +418 -0
  31. package/src/components/TdesignAlert.vue +116 -0
  32. package/src/components/TdesignCalendar/index.vue +6 -3
  33. package/src/components/TdesignCol.vue +102 -0
  34. package/src/components/TdesignDialog.vue +226 -0
  35. package/src/components/TdesignGrid.vue +56 -0
  36. package/src/components/TdesignInput.vue +23 -23
  37. package/src/components/TdesignTextarea.vue +143 -0
  38. package/src/components/TdesignTimeline.vue +58 -0
  39. package/src/components/TdesignTimelineItem.vue +72 -0
  40. package/src/components/TdesignUpload.vue +757 -0
  41. package/src/components/TdesignWatermark.vue +108 -0
  42. package/src/index.js +85 -0
  43. package/src/main.js +2 -2
  44. package/src/router/index.js +160 -5
  45. package/src/views/Button.vue +7 -3
  46. package/src/views/CheckboxDemo.vue +105 -0
  47. package/src/views/DialogDemo.vue +126 -0
  48. package/src/views/EbizAvatar.vue +224 -0
  49. package/src/views/EbizDetailBlockDemo.vue +31 -0
  50. package/src/views/EbizEmployeeInfo.vue +250 -0
  51. package/src/views/EbizRadioDemo.vue +152 -0
  52. package/src/views/GridDemo.vue +239 -0
  53. package/src/views/Home.vue +49 -2
  54. package/src/views/PageHeaderDemo.vue +105 -0
  55. package/src/views/PaginationDemo.vue +97 -0
  56. package/src/views/RemoteSelect.vue +336 -5
  57. package/src/views/StatisticDemo.vue +191 -0
  58. package/src/views/SwitchDemo.vue +80 -0
  59. package/src/views/TableDemo.vue +335 -0
  60. package/src/views/TableSortDemo.vue +144 -0
  61. package/src/views/TableView.vue +69 -0
  62. package/src/views/TabsDemo.vue +283 -0
  63. package/src/views/TdesignAlert.vue +99 -0
  64. package/src/views/TextareaDemo.vue +94 -0
  65. package/src/views/TimePickerDemo.vue +147 -0
  66. package/src/views/TimelineDemo.vue +161 -0
  67. package/src/views/TreeDemo.vue +255 -0
  68. package/src/views/TreeSelectorDemo.vue +246 -0
  69. package/src/views/UploadDemo.vue +122 -0
  70. package/src/views/WatermarkDemo.vue +86 -0
@@ -0,0 +1,181 @@
1
+ <template>
2
+ <div class="ebiz-table-sort">
3
+ <t-popup :visible="sortVisible" trigger="click" placement="bottom-right" :overlay-style="{ width: '450px' }"
4
+ @visible-change="handleVisibleChange" :destroy-on-close="false">
5
+ <template #content>
6
+ <t-card :title="popupTitle" size="small" :bordered="false">
7
+ <div class="sort-content">
8
+ <div class="sort-item" v-for="(item, index) in sortItems" :key="index">
9
+ <div class="sort-item-content" style="display: flex; margin-bottom: 12px;">
10
+ <t-select v-model="item.type" :placeholder="fieldPlaceholder" :options="fieldOptions" :clearable="false"
11
+ :style="{ width: '170px' }" @change="handleSortChange" />
12
+ <t-select v-model="item.sort" :placeholder="orderPlaceholder" :options="orderOptions" :clearable="false"
13
+ :style="{ width: '170px', marginLeft: '8px' }" @change="handleSortChange" />
14
+ <t-button theme="default" variant="text" shape="circle" @click="removeSortItem(index)"
15
+ v-if="sortItems.length > 1" :style="{ marginLeft: '8px', flexShrink: 0 }">
16
+ <template #icon>
17
+ <t-icon name="close" />
18
+ </template>
19
+ </t-button>
20
+ </div>
21
+ </div>
22
+ <div class="sort-footer">
23
+ <t-button theme="default" variant="outline" @click="addSortItem"
24
+ v-if="sortItems.length < maxSortItems">
25
+ <template #icon>
26
+ <t-icon name="add" />
27
+ </template>
28
+ {{ addConditionText }}
29
+ </t-button>
30
+ </div>
31
+ </div>
32
+ </t-card>
33
+ </template>
34
+ <t-button block variant="outline" :title="title">
35
+ <template #icon>
36
+ <t-icon :name="icon" />
37
+ </template>
38
+ <div v-if="buttonText">
39
+ {{ buttonText }}
40
+ </div>
41
+ </t-button>
42
+ </t-popup>
43
+ </div>
44
+ </template>
45
+
46
+ <script>
47
+ export default {
48
+ name: "EbizTableSort"
49
+ }
50
+ </script>
51
+
52
+ <script setup>
53
+ import { ref, computed, defineProps, defineEmits, watch } from 'vue';
54
+ import { Button as TButton, Popup as TPopup, Card as TCard, Select as TSelect, Icon as TIcon } from 'tdesign-vue-next';
55
+
56
+ const props = defineProps({
57
+ // v-model绑定值
58
+ modelValue: {
59
+ type: Array,
60
+ default: () => []
61
+ },
62
+ // 按钮图标
63
+ icon: {
64
+ type: String,
65
+ default: 'sort'
66
+ },
67
+ // 按钮文本
68
+ buttonText: {
69
+ type: String,
70
+ default: ''
71
+ },
72
+ // 按钮标题
73
+ title: {
74
+ type: String,
75
+ default: '排序'
76
+ },
77
+ // 弹出层标题
78
+ popupTitle: {
79
+ type: String,
80
+ default: '排序'
81
+ },
82
+ // 字段选项
83
+ fieldOptions: {
84
+ type: Array,
85
+ default: () => []
86
+ },
87
+ // 字段占位符
88
+ fieldPlaceholder: {
89
+ type: String,
90
+ default: '选择字段'
91
+ },
92
+ // 排序选项
93
+ orderOptions: {
94
+ type: Array,
95
+ default: () => [
96
+ { value: 'asc', label: '升序 ↑' },
97
+ { value: 'desc', label: '降序 ↓' }
98
+ ]
99
+ },
100
+ // 排序占位符
101
+ orderPlaceholder: {
102
+ type: String,
103
+ default: '选择排序'
104
+ },
105
+ // 最大排序条件数量
106
+ maxSortItems: {
107
+ type: Number,
108
+ default: 5
109
+ },
110
+ // 添加条件文本
111
+ addConditionText: {
112
+ type: String,
113
+ default: '添加排序条件'
114
+ }
115
+ });
116
+
117
+ const emit = defineEmits(['update:modelValue', 'sort', 'visible-change']);
118
+
119
+ // 排序弹出层显示状态
120
+ const sortVisible = ref(false);
121
+
122
+ // 排序条件列表
123
+ const sortItems = ref([]);
124
+
125
+ // 监听modelValue变化
126
+ watch(() => props.modelValue, (newVal) => {
127
+ if (newVal && newVal.length > 0) {
128
+ sortItems.value = JSON.parse(JSON.stringify(newVal));
129
+ } else {
130
+ // 默认添加一个空的排序条件
131
+ sortItems.value = [{ type: '', sort: 'desc' }];
132
+ }
133
+ }, { immediate: true });
134
+
135
+ // 添加排序条件
136
+ const addSortItem = () => {
137
+ if (sortItems.value.length < props.maxSortItems) {
138
+ sortItems.value.push({ type: '', sort: 'desc' });
139
+ }
140
+ };
141
+
142
+ // 移除排序条件
143
+ const removeSortItem = (index) => {
144
+ sortItems.value.splice(index, 1);
145
+ handleSortChange();
146
+ };
147
+
148
+ // 处理排序变更
149
+ const handleSortChange = () => {
150
+ // 过滤有效的排序条件(字段和排序方向都不为空)
151
+ const validSortItems = sortItems.value.filter(item => item.type && item.sort);
152
+ emit('update:modelValue', validSortItems);
153
+ emit('sort', validSortItems);
154
+ };
155
+
156
+ // 弹出层可见性变化
157
+ const handleVisibleChange = (visible) => {
158
+ sortVisible.value = visible;
159
+ emit('visible-change', visible);
160
+ };
161
+ </script>
162
+
163
+ <style lang="less" scoped>
164
+ .ebiz-table-sort {
165
+ display: inline-block;
166
+
167
+ .sort-content {
168
+ min-width: 400px;
169
+ width: 100%;
170
+ }
171
+
172
+ .sort-footer {
173
+ margin-top: 16px;
174
+ }
175
+
176
+ .sort-actions {
177
+ display: flex;
178
+ justify-content: flex-end;
179
+ }
180
+ }
181
+ </style>
@@ -0,0 +1,143 @@
1
+ <template>
2
+ <div class="tdesign-tabs-wrapper">
3
+ <t-tabs
4
+ v-model="innerValue"
5
+ :addable="addable"
6
+ :disabled="disabled"
7
+ :placement="placement"
8
+ :size="size"
9
+ :theme="theme"
10
+ :list="list"
11
+ :dragSort="dragSort"
12
+ @add="handleAdd"
13
+ @change="handleChange"
14
+ @dragSort="handleDragSort"
15
+ @remove="handleRemove"
16
+ >
17
+ <!-- 添加按钮插槽 -->
18
+ <template v-if="$slots.action" #action>
19
+ <slot name="action"></slot>
20
+ </template>
21
+
22
+ <!-- 直接输出默认插槽内容,这里应该只包含EbizTabPanel -->
23
+ <slot></slot>
24
+ </t-tabs>
25
+ </div>
26
+ </template>
27
+
28
+ <script>
29
+ import { Tabs as TTabs } from 'tdesign-vue-next';
30
+ import { defineComponent, toRefs, computed, watch } from 'vue';
31
+
32
+ export default defineComponent({
33
+ name: 'EbizTabs',
34
+ components: {
35
+ 't-tabs': TTabs,
36
+ },
37
+ props: {
38
+ // v-model绑定值
39
+ modelValue: {
40
+ type: [String, Number],
41
+ },
42
+ // 默认值
43
+ defaultValue: {
44
+ type: [String, Number],
45
+ },
46
+ // 选项卡右侧的操作区域
47
+ action: {
48
+ type: [Function, String],
49
+ default: undefined
50
+ },
51
+ // 选项卡是否可增加
52
+ addable: {
53
+ type: Boolean,
54
+ default: false
55
+ },
56
+ // 是否禁用选项卡
57
+ disabled: {
58
+ type: Boolean,
59
+ default: false
60
+ },
61
+ // 是否开启拖拽调整顺序
62
+ dragSort: {
63
+ type: Boolean,
64
+ default: false
65
+ },
66
+ // 选项卡列表
67
+ list: {
68
+ type: Array,
69
+ },
70
+ // 选项卡位置
71
+ placement: {
72
+ type: String,
73
+ default: 'top',
74
+ validator: (val) => ['top', 'bottom', 'left', 'right'].includes(val)
75
+ },
76
+ // 组件尺寸
77
+ size: {
78
+ type: String,
79
+ default: 'medium',
80
+ validator: (val) => ['medium', 'large'].includes(val)
81
+ },
82
+ // 选项卡风格
83
+ theme: {
84
+ type: String,
85
+ default: 'normal',
86
+ validator: (val) => ['normal', 'card'].includes(val)
87
+ }
88
+ },
89
+ emits: ['update:modelValue', 'add', 'change', 'dragSort', 'remove'],
90
+ setup(props, { emit }) {
91
+ const { modelValue, defaultValue } = toRefs(props);
92
+
93
+ // 内部值计算属性,用于双向绑定
94
+ const innerValue = computed({
95
+ get: () => modelValue.value !== undefined ? modelValue.value : defaultValue.value,
96
+ set: (val) => {
97
+ emit('update:modelValue', val);
98
+ }
99
+ });
100
+
101
+ // 监听modelValue变化
102
+ watch(modelValue, (newVal) => {
103
+ if (newVal !== innerValue.value) {
104
+ innerValue.value = newVal;
105
+ }
106
+ });
107
+
108
+ // 添加选项卡事件
109
+ const handleAdd = (context) => {
110
+ emit('add', context);
111
+ };
112
+
113
+ // 选项卡切换事件
114
+ const handleChange = (value, context) => {
115
+ emit('change', value, context);
116
+ };
117
+
118
+ // 拖拽排序事件
119
+ const handleDragSort = (context) => {
120
+ emit('dragSort', context);
121
+ };
122
+
123
+ // 删除选项卡事件
124
+ const handleRemove = (options) => {
125
+ emit('remove', options);
126
+ };
127
+
128
+ return {
129
+ innerValue,
130
+ handleAdd,
131
+ handleChange,
132
+ handleDragSort,
133
+ handleRemove
134
+ };
135
+ }
136
+ });
137
+ </script>
138
+
139
+ <style lang="less" scoped>
140
+ .tdesign-tabs-wrapper {
141
+ width: 100%;
142
+ }
143
+ </style>
@@ -0,0 +1,144 @@
1
+ <template>
2
+ <t-time-picker
3
+ v-bind="$attrs"
4
+ :value="modelValue"
5
+ :allow-input="allowInput"
6
+ :clearable="clearable"
7
+ :disabled="disabled"
8
+ :disable-time="disableTime"
9
+ :format="format"
10
+ :input-props="inputProps"
11
+ :placeholder="placeholder"
12
+ :popup-props="popupProps"
13
+ :size="size"
14
+ :steps="steps"
15
+ :range="range"
16
+ :range-separator="rangeSeparator"
17
+ :tips="tips"
18
+ @change="handleChange"
19
+ @blur="$emit('blur', $event)"
20
+ @focus="$emit('focus', $event)"
21
+ @close="$emit('close', $event)"
22
+ @open="$emit('open', $event)"
23
+ @dayclick="$emit('dayclick', $event)"
24
+ @pick="$emit('pick', $event)"
25
+ >
26
+ <template v-if="$slots.suffixIcon" #suffixIcon>
27
+ <slot name="suffixIcon"></slot>
28
+ </template>
29
+ <template v-if="$slots.panel" #panel="slotProps">
30
+ <slot name="panel" v-bind="slotProps"></slot>
31
+ </template>
32
+ <template v-if="$slots.prepend" #prepend>
33
+ <slot name="prepend"></slot>
34
+ </template>
35
+ <template v-if="$slots.tips" #tips>
36
+ <slot name="tips"></slot>
37
+ </template>
38
+ </t-time-picker>
39
+ </template>
40
+
41
+ <script setup>
42
+ import { TimePicker as TTimePicker } from 'tdesign-vue-next';
43
+ import { computed } from 'vue';
44
+
45
+ const props = defineProps({
46
+ // 选中值
47
+ modelValue: {
48
+ type: [String, Array],
49
+ default: '',
50
+ },
51
+ // 是否允许直接输入时间
52
+ allowInput: {
53
+ type: Boolean,
54
+ default: true,
55
+ },
56
+ // 是否允许清除选中值
57
+ clearable: {
58
+ type: Boolean,
59
+ default: true,
60
+ },
61
+ // 是否禁用组件
62
+ disabled: {
63
+ type: Boolean,
64
+ default: false,
65
+ },
66
+ // 禁用时间项
67
+ disableTime: {
68
+ type: Function,
69
+ default: null,
70
+ },
71
+ // 时间格式
72
+ format: {
73
+ type: String,
74
+ default: 'HH:mm:ss',
75
+ },
76
+ // 透传给输入框的属性
77
+ inputProps: {
78
+ type: Object,
79
+ default: () => ({}),
80
+ },
81
+ // 输入框占位文本
82
+ placeholder: {
83
+ type: String,
84
+ default: '请选择时间',
85
+ },
86
+ // 透传给 popup 组件的属性
87
+ popupProps: {
88
+ type: Object,
89
+ default: () => ({}),
90
+ },
91
+ // 尺寸
92
+ size: {
93
+ type: String,
94
+ default: 'medium',
95
+ validator(val) {
96
+ return ['small', 'medium', 'large'].includes(val);
97
+ },
98
+ },
99
+ // 时间间隔步数
100
+ steps: {
101
+ type: Array,
102
+ default: () => [1, 1, 1],
103
+ },
104
+ // 是否为时间范围选择
105
+ range: {
106
+ type: Boolean,
107
+ default: false,
108
+ },
109
+ // 范围分隔符
110
+ rangeSeparator: {
111
+ type: String,
112
+ default: ' - ',
113
+ },
114
+ // 提示文本
115
+ tips: {
116
+ type: [String, Function],
117
+ default: '',
118
+ },
119
+ });
120
+
121
+ const emit = defineEmits([
122
+ 'update:modelValue',
123
+ 'change',
124
+ 'blur',
125
+ 'focus',
126
+ 'close',
127
+ 'open',
128
+ 'dayclick',
129
+ 'pick',
130
+ ]);
131
+
132
+ // 处理值变更事件
133
+ const handleChange = (value) => {
134
+ emit('update:modelValue', value);
135
+ emit('change', value);
136
+ };
137
+
138
+ </script>
139
+
140
+ <style>
141
+ .t-time-picker {
142
+ width: 100%;
143
+ }
144
+ </style>
@@ -1,52 +1,51 @@
1
1
  <template>
2
2
  <div class="ebiz-title">
3
- <!-- <div class="color-block" :style="{ backgroundColor: color, width: `${blockWidth}px` }"></div> -->
4
- <!-- <div class="title-text">
3
+ <div class="color-block" :style="{ backgroundColor: color, width: `${blockWidth}px` }"></div>
4
+ <div class="title-text">
5
5
  <slot name="title">
6
6
  {{ displayTitle }}
7
7
  </slot>
8
- </div> -->
8
+ </div>
9
9
  </div>
10
10
  </template>
11
11
 
12
12
  <script setup>
13
+ import { defineProps, computed } from 'vue';
13
14
 
14
- // import { defineProps, computed } from 'vue';
15
+ /**
16
+ * EbizTitle 组件 - 带有色块的标题组件
17
+ * 支持自定义标题文本、色块颜色和色块宽度
18
+ * 包含一个按钮,点击时在标题后添加点号并触发事件
19
+ * 支持通过插槽自定义标题内容
20
+ */
21
+ const props = defineProps({
22
+ /**
23
+ * 标题文本 (当不使用插槽时显示)
24
+ */
25
+ title: {
26
+ type: String,
27
+ default: '标题'
28
+ },
29
+ /**
30
+ * 色块颜色,支持任何有效的CSS颜色值
31
+ */
32
+ color: {
33
+ type: String,
34
+ default: '#1890ff'
35
+ },
36
+ /**
37
+ * 色块宽度,单位为像素
38
+ */
39
+ blockWidth: {
40
+ type: Number,
41
+ default: 10
42
+ }
43
+ });
15
44
 
16
- // /**
17
- // * EbizTitle 组件 - 带有色块的标题组件
18
- // * 支持自定义标题文本、色块颜色和色块宽度
19
- // * 包含一个按钮,点击时在标题后添加点号并触发事件
20
- // * 支持通过插槽自定义标题内容
21
- // */
22
- // const props = defineProps({
23
- // /**
24
- // * 标题文本 (当不使用插槽时显示)
25
- // */
26
- // title: {
27
- // type: String,
28
- // default: '标题'
29
- // },
30
- // /**
31
- // * 色块颜色,支持任何有效的CSS颜色值
32
- // */
33
- // color: {
34
- // type: String,
35
- // default: '#1890ff'
36
- // },
37
- // /**
38
- // * 色块宽度,单位为像素
39
- // */
40
- // blockWidth: {
41
- // type: Number,
42
- // default: 10
43
- // }
44
- // });
45
45
 
46
- // // // 计算属性:根据点号数量生成显示的标题
47
- // const displayTitle = computed(() => {
48
- // return props.title;
49
- // });
46
+ const displayTitle = computed(() => {
47
+ return props.title;
48
+ });
50
49
  </script>
51
50
 
52
51
  <style scoped>
@@ -0,0 +1,153 @@
1
+ <template>
2
+ <t-tree
3
+ ref="treeRef"
4
+ v-bind="$attrs"
5
+ :data="data"
6
+ :value="modelValue"
7
+ :expanded="expandedModel"
8
+ :actived="activedModel"
9
+ :transition="transition"
10
+ :disable-check="disableCheck"
11
+ :keys="keys"
12
+ @change="handleChange"
13
+ @expand="handleExpand"
14
+ @active="handleActive"
15
+ @select="$emit('select', $event)"
16
+ @drag-start="$emit('drag-start', $event)"
17
+ @drag-end="$emit('drag-end', $event)"
18
+ @drag-over="$emit('drag-over', $event)"
19
+ @drag-leave="$emit('drag-leave', $event)"
20
+ @drag-drop="$emit('drag-drop', $event)"
21
+ @click="$emit('click', $event)"
22
+ @load="$emit('load', $event)"
23
+ >
24
+ <template v-if="$slots.default" #default="slotProps">
25
+ <slot :node="slotProps.node"></slot>
26
+ </template>
27
+ <template v-if="$slots.empty" #empty>
28
+ <slot name="empty"></slot>
29
+ </template>
30
+ <template v-if="$slots.icon" #icon="slotProps">
31
+ <slot name="icon" :node="slotProps.node"></slot>
32
+ </template>
33
+ <template v-if="$slots.label" #label="slotProps">
34
+ <slot name="label" :node="slotProps.node"></slot>
35
+ </template>
36
+ <template v-if="$slots.line" #line="slotProps">
37
+ <slot name="line" :node="slotProps.node"></slot>
38
+ </template>
39
+ <template v-if="$slots.operations" #operations="slotProps">
40
+ <slot name="operations" :node="slotProps.node"></slot>
41
+ </template>
42
+ </t-tree>
43
+ </template>
44
+
45
+ <script setup>
46
+ import { Tree as TTree } from 'tdesign-vue-next';
47
+ import { computed ,ref} from 'vue';
48
+
49
+ // 定义组件属性
50
+ const props = defineProps({
51
+ // 选中值
52
+ modelValue: {
53
+ type: Array,
54
+ default: () => []
55
+ },
56
+ // 展开节点
57
+ expanded: {
58
+ type: Array,
59
+ default: () => []
60
+ },
61
+ // 激活节点
62
+ actived: {
63
+ type: Array,
64
+ default: () => []
65
+ },
66
+ // 数据
67
+ items: {
68
+ type: Array,
69
+ default: () => []
70
+ },
71
+ // 是否启用过渡动画
72
+ transition: {
73
+ type: Boolean,
74
+ default: false
75
+ },
76
+ // 自定义节点禁用状态,返回true表示禁用
77
+ disableCheck: {
78
+ type: Function,
79
+ default: null
80
+ },
81
+ // 自定义节点数据中的字段名称
82
+ keys: {
83
+ type: Object,
84
+ default: () => ({
85
+ label: 'label',
86
+ value: 'value',
87
+ children: 'children'
88
+ })
89
+ }
90
+ });
91
+
92
+ const treeRef = ref();
93
+ // 定义组件事件
94
+ const emit = defineEmits([
95
+ 'update:modelValue',
96
+ 'update:expanded',
97
+ 'update:actived',
98
+ 'change',
99
+ 'expand',
100
+ 'active',
101
+ 'select',
102
+ 'click',
103
+ 'load',
104
+ 'drag-start',
105
+ 'drag-end',
106
+ 'drag-over',
107
+ 'drag-leave',
108
+ 'drag-drop'
109
+ ]);
110
+
111
+ // 处理items映射到data
112
+ const data = computed(() => props.items);
113
+
114
+ // 展开事件
115
+ const expandedModel = computed({
116
+ get: () => props.expanded,
117
+ set: (val) => emit('update:expanded', val)
118
+ });
119
+
120
+ // 激活节点
121
+ const activedModel = computed({
122
+ get: () => props.actived,
123
+ set: (val) => emit('update:actived', val)
124
+ });
125
+
126
+ // 值改变事件
127
+ const handleChange = (val, context) => {
128
+ emit('update:modelValue', val);
129
+ emit('change', val, context);
130
+ };
131
+
132
+ // 节点展开事件
133
+ const handleExpand = (val, context) => {
134
+ emit('update:expanded', val);
135
+ emit('expand', val, context);
136
+ };
137
+
138
+ // 节点激活事件
139
+ const handleActive = (val, context) => {
140
+ emit('update:actived', val);
141
+ emit('active', val, context);
142
+ };
143
+
144
+ defineExpose({
145
+ treeRef
146
+ });
147
+ </script>
148
+
149
+ <style>
150
+ .t-tree {
151
+ width: 100%;
152
+ }
153
+ </style>