@ebiz/designer-components 0.0.18 → 0.0.19

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 (99) hide show
  1. package/package.json +3 -2
  2. package/src/apiService/mockDataService.js +116 -0
  3. package/src/apiService/simpleDataService.js +186 -80
  4. package/src/components/Button.vue +72 -22
  5. package/src/components/EbizAvatar.vue +116 -0
  6. package/src/components/EbizCheckbox.vue +94 -0
  7. package/src/components/EbizCheckboxGroup.vue +70 -0
  8. package/src/components/EbizDetailBlock.vue +82 -0
  9. package/src/components/EbizDialog.vue +244 -56
  10. package/src/components/EbizEmployeeInfo.vue +139 -0
  11. package/src/components/EbizFileUpload.vue +202 -0
  12. package/src/components/EbizPageHeader.vue +96 -0
  13. package/src/components/EbizPagination.vue +163 -0
  14. package/src/components/EbizRadio.vue +87 -0
  15. package/src/components/EbizRadioGroup.vue +84 -0
  16. package/src/components/EbizRemoteSelect.vue +118 -40
  17. package/src/components/EbizSpace.vue +101 -0
  18. package/src/components/EbizStatistic.vue +150 -0
  19. package/src/components/EbizSwiper.vue +114 -0
  20. package/src/components/EbizSwiperItem.vue +14 -0
  21. package/src/components/EbizSwitch.vue +86 -0
  22. package/src/components/EbizTabHeader.vue +145 -0
  23. package/src/components/EbizTabPanel.vue +23 -0
  24. package/src/components/EbizTable.vue +466 -0
  25. package/src/components/EbizTableColumn.vue +117 -0
  26. package/src/components/EbizTableSort.vue +181 -0
  27. package/src/components/EbizTabs.vue +133 -91
  28. package/src/components/EbizTimePicker.vue +144 -0
  29. package/src/components/EbizTitle.vue +3 -10
  30. package/src/components/EbizTree.vue +153 -0
  31. package/src/components/EbizTreeSelector.vue +423 -0
  32. package/src/components/Home.vue +8 -0
  33. package/src/components/TdesignAlert.vue +116 -0
  34. package/src/components/TdesignButton.vue +130 -0
  35. package/src/components/TdesignCalendar/index.vue +146 -0
  36. package/src/components/TdesignCard.vue +196 -0
  37. package/src/components/TdesignCol.vue +102 -0
  38. package/src/components/TdesignCollapse.vue +143 -0
  39. package/src/components/TdesignCollapsePanel.vue +80 -0
  40. package/src/components/TdesignDatePicker.vue +125 -0
  41. package/src/components/TdesignDialog.vue +226 -0
  42. package/src/components/TdesignForm.vue +134 -0
  43. package/src/components/TdesignFormItem.vue +106 -0
  44. package/src/components/TdesignGrid.vue +56 -0
  45. package/src/components/TdesignIcon.vue +68 -0
  46. package/src/components/TdesignImage.vue +163 -0
  47. package/src/components/TdesignImageViewer.vue +201 -0
  48. package/src/components/TdesignInput.vue +243 -0
  49. package/src/components/TdesignSelect.vue +445 -0
  50. package/src/components/TdesignTag.vue +118 -0
  51. package/src/components/TdesignTextarea.vue +143 -0
  52. package/src/components/TdesignTimeline.vue +58 -0
  53. package/src/components/TdesignTimelineItem.vue +72 -0
  54. package/src/components/TdesignUpload.vue +757 -0
  55. package/src/components/TdesignWatermark.vue +108 -0
  56. package/src/index.js +130 -0
  57. package/src/main.js +20 -4
  58. package/src/router/index.js +244 -5
  59. package/src/views/Button.vue +7 -3
  60. package/src/views/CheckboxDemo.vue +105 -0
  61. package/src/views/DialogDemo.vue +126 -0
  62. package/src/views/EbizAvatar.vue +224 -0
  63. package/src/views/EbizDetailBlockDemo.vue +31 -0
  64. package/src/views/EbizEmployeeInfo.vue +250 -0
  65. package/src/views/EbizRadioDemo.vue +152 -0
  66. package/src/views/EbizSpace.vue +186 -0
  67. package/src/views/EbizSwiper.vue +158 -0
  68. package/src/views/GridDemo.vue +239 -0
  69. package/src/views/Home.vue +63 -2
  70. package/src/views/PageHeaderDemo.vue +105 -0
  71. package/src/views/PaginationDemo.vue +97 -0
  72. package/src/views/RemoteSelect.vue +336 -5
  73. package/src/views/StatisticDemo.vue +191 -0
  74. package/src/views/SwitchDemo.vue +80 -0
  75. package/src/views/TableDemo.vue +335 -0
  76. package/src/views/TableSortDemo.vue +144 -0
  77. package/src/views/TableView.vue +69 -0
  78. package/src/views/TabsDemo.vue +283 -0
  79. package/src/views/TagDemo.vue +102 -0
  80. package/src/views/TdesignAlert.vue +99 -0
  81. package/src/views/TdesignButton.vue +191 -0
  82. package/src/views/TdesignCalendar.vue +95 -0
  83. package/src/views/TdesignCard.vue +297 -0
  84. package/src/views/TdesignCollapse.vue +294 -0
  85. package/src/views/TdesignDatePicker.vue +188 -0
  86. package/src/views/TdesignForm.vue +249 -0
  87. package/src/views/TdesignIcon.vue +204 -0
  88. package/src/views/TdesignImage.vue +216 -0
  89. package/src/views/TdesignImageViewer.vue +199 -0
  90. package/src/views/TdesignInput.vue +253 -0
  91. package/src/views/TdesignSelect.vue +474 -0
  92. package/src/views/TdesignSwiper.vue +158 -0
  93. package/src/views/TextareaDemo.vue +94 -0
  94. package/src/views/TimePickerDemo.vue +147 -0
  95. package/src/views/TimelineDemo.vue +161 -0
  96. package/src/views/TreeDemo.vue +255 -0
  97. package/src/views/TreeSelectorDemo.vue +246 -0
  98. package/src/views/UploadDemo.vue +122 -0
  99. package/src/views/WatermarkDemo.vue +86 -0
@@ -0,0 +1,94 @@
1
+ <template>
2
+ <div class="textarea-demo">
3
+ <h1>Textarea 多行文本框</h1>
4
+
5
+ <section>
6
+ <h2>基础多行文本框</h2>
7
+ <p>用于多行文本的输入。</p>
8
+ <div class="demo-item">
9
+ <ebiz-textarea placeholder="请输入多行文本"></ebiz-textarea>
10
+ </div>
11
+ </section>
12
+
13
+ <section>
14
+ <h2>限制最大字符数</h2>
15
+ <p>限制输入的最大字符数并展示字符数。</p>
16
+ <div class="demo-item">
17
+ <ebiz-textarea placeholder="请输入" :max-length="20" :max-character="true"></ebiz-textarea>
18
+ </div>
19
+ </section>
20
+
21
+ <section>
22
+ <h2>自动调整高度</h2>
23
+ <p>根据内容自动调整输入框的高度。</p>
24
+ <div class="demo-item">
25
+ <ebiz-textarea placeholder="请输入" :autosize="true"></ebiz-textarea>
26
+ </div>
27
+ </section>
28
+
29
+ <section>
30
+ <h2>不同状态的多行文本框</h2>
31
+ <p>支持只读、禁用和不同的状态样式。</p>
32
+ <div class="demo-item">
33
+ <p>默认状态:</p>
34
+ <ebiz-textarea placeholder="默认状态" tips="这是默认提示文本"></ebiz-textarea>
35
+ </div>
36
+ <div class="demo-item">
37
+ <p>成功状态:</p>
38
+ <ebiz-textarea placeholder="成功状态" status="success" tips="校验通过文本提示"></ebiz-textarea>
39
+ </div>
40
+ <div class="demo-item">
41
+ <p>警告状态:</p>
42
+ <ebiz-textarea placeholder="警告状态" status="warning" tips="校验存在警告文本提示"></ebiz-textarea>
43
+ </div>
44
+ <div class="demo-item">
45
+ <p>错误状态:</p>
46
+ <ebiz-textarea placeholder="错误状态" status="error" tips="校验不通过文本提示"></ebiz-textarea>
47
+ </div>
48
+ <div class="demo-item">
49
+ <p>只读状态:</p>
50
+ <ebiz-textarea placeholder="只读状态" :readonly="true" value="这是只读文本"></ebiz-textarea>
51
+ </div>
52
+ <div class="demo-item">
53
+ <p>禁用状态:</p>
54
+ <ebiz-textarea placeholder="禁用状态" :disabled="true"></ebiz-textarea>
55
+ </div>
56
+ </section>
57
+ </div>
58
+ </template>
59
+
60
+ <script setup>
61
+ import { EbizTextarea } from '../index.js';
62
+ </script>
63
+
64
+ <style scoped>
65
+ .textarea-demo {
66
+ max-width: 800px;
67
+ margin: 0 auto;
68
+ padding: 20px;
69
+ }
70
+
71
+ h1 {
72
+ font-size: 28px;
73
+ margin-bottom: 24px;
74
+ }
75
+
76
+ h2 {
77
+ font-size: 20px;
78
+ margin-top: 32px;
79
+ margin-bottom: 16px;
80
+ }
81
+
82
+ section {
83
+ margin-bottom: 40px;
84
+ }
85
+
86
+ .demo-item {
87
+ margin-bottom: 16px;
88
+ max-width: 400px;
89
+ }
90
+
91
+ p {
92
+ margin-bottom: 8px;
93
+ }
94
+ </style>
@@ -0,0 +1,147 @@
1
+ <template>
2
+ <div class="time-picker-demo">
3
+ <h2>时间选择器 EbizTimePicker</h2>
4
+
5
+ <h3>基本用法</h3>
6
+ <div class="demo-section">
7
+ <EbizTimePicker v-model="value1" placeholder="请选择时间" />
8
+ <div class="demo-value">选中值: {{ value1 }}</div>
9
+ </div>
10
+
11
+ <h3>时间格式</h3>
12
+ <div class="demo-section">
13
+ <EbizTimePicker v-model="value2" format="HH:mm" placeholder="时分格式 HH:mm" />
14
+ <div class="demo-value">选中值: {{ value2 }}</div>
15
+ </div>
16
+
17
+ <h3>禁用状态</h3>
18
+ <div class="demo-section">
19
+ <EbizTimePicker v-model="value3" disabled placeholder="禁用状态" />
20
+ </div>
21
+
22
+ <h3>时间范围选择</h3>
23
+ <div class="demo-section">
24
+ <EbizTimePicker v-model="value4" range placeholder="请选择时间范围" />
25
+ <div class="demo-value">选中值: {{ value4 }}</div>
26
+ </div>
27
+
28
+ <h3>步长设置</h3>
29
+ <div class="demo-section">
30
+ <EbizTimePicker v-model="value5" :steps="[2, 10, 15]" placeholder="步长:时(2) 分(10) 秒(15)" />
31
+ <div class="demo-value">选中值: {{ value5 }}</div>
32
+ </div>
33
+
34
+ <h3>禁用时间</h3>
35
+ <div class="demo-section">
36
+ <EbizTimePicker v-model="value6" :disable-time="disableTime" placeholder="上午禁用" />
37
+ <div class="demo-value">选中值: {{ value6 }}</div>
38
+ </div>
39
+
40
+ <h3>不同尺寸</h3>
41
+ <div class="demo-section">
42
+ <div class="size-row">
43
+ <EbizTimePicker v-model="value7" size="small" placeholder="小尺寸" />
44
+ <EbizTimePicker v-model="value7" size="medium" placeholder="中尺寸(默认)" />
45
+ <EbizTimePicker v-model="value7" size="large" placeholder="大尺寸" />
46
+ </div>
47
+ </div>
48
+
49
+ <h3>提示信息</h3>
50
+ <div class="demo-section">
51
+ <EbizTimePicker v-model="value8" tips="这是一个提示文本" placeholder="带提示信息" />
52
+ </div>
53
+
54
+ <h3>前置/后置插槽</h3>
55
+ <div class="demo-section">
56
+ <EbizTimePicker v-model="value9" placeholder="带前置内容">
57
+ <template #prepend>
58
+ <span class="prepend-content">时间:</span>
59
+ </template>
60
+ </EbizTimePicker>
61
+ </div>
62
+ </div>
63
+ </template>
64
+
65
+ <script setup>
66
+ import { ref } from 'vue';
67
+ import { EbizTimePicker } from '../index.js';
68
+
69
+ // 基本用法
70
+ const value1 = ref('');
71
+
72
+ // 时间格式
73
+ const value2 = ref('');
74
+
75
+ // 禁用状态
76
+ const value3 = ref('12:30:00');
77
+
78
+ // 时间范围选择
79
+ const value4 = ref(['09:00:00', '18:00:00']);
80
+
81
+ // 步长设置
82
+ const value5 = ref('');
83
+
84
+ // 禁用时间
85
+ const value6 = ref('');
86
+ const disableTime = (h) => {
87
+ // 禁用上午时间段 (0-12点)
88
+ return h < 12;
89
+ };
90
+
91
+ // 不同尺寸
92
+ const value7 = ref('');
93
+
94
+ // 提示信息
95
+ const value8 = ref('');
96
+
97
+ // 前置/后置插槽
98
+ const value9 = ref('');
99
+ </script>
100
+
101
+ <style scoped>
102
+ .time-picker-demo {
103
+ padding: 20px;
104
+ max-width: 800px;
105
+ margin: 0 auto;
106
+ }
107
+
108
+ h2 {
109
+ margin-bottom: 30px;
110
+ font-weight: 500;
111
+ border-bottom: 1px solid #eee;
112
+ padding-bottom: 10px;
113
+ }
114
+
115
+ h3 {
116
+ margin-top: 30px;
117
+ margin-bottom: 15px;
118
+ font-weight: 400;
119
+ font-size: 18px;
120
+ color: #333;
121
+ }
122
+
123
+ .demo-section {
124
+ margin-bottom: 30px;
125
+ padding: 20px;
126
+ background-color: #f9f9f9;
127
+ border-radius: 4px;
128
+ }
129
+
130
+ .demo-value {
131
+ margin-top: 10px;
132
+ color: #606060;
133
+ font-size: 14px;
134
+ padding: 5px 0;
135
+ }
136
+
137
+ .size-row {
138
+ display: flex;
139
+ gap: 20px;
140
+ align-items: center;
141
+ }
142
+
143
+ .prepend-content {
144
+ padding: 0 10px;
145
+ color: #0052D9;
146
+ }
147
+ </style>
@@ -0,0 +1,161 @@
1
+ <template>
2
+ <div class="timeline-demo">
3
+ <h1>TDesign Timeline 组件示例</h1>
4
+
5
+ <h2>基础时间轴</h2>
6
+ <div class="demo-section">
7
+ <EbizTimeline>
8
+ <EbizTimelineItem label="2022-01-01" content="事件一" />
9
+ <EbizTimelineItem label="2022-02-01" content="事件二" />
10
+ <EbizTimelineItem label="2022-03-01" content="事件三" />
11
+ <EbizTimelineItem label="2022-04-01" content="事件四" />
12
+ </EbizTimeline>
13
+ </div>
14
+
15
+ <h2>时间轴方向</h2>
16
+ <div class="demo-section">
17
+ <h3>水平方向</h3>
18
+ <EbizTimeline layout="horizontal">
19
+ <EbizTimelineItem label="2022-01-01" content="事件一" />
20
+ <EbizTimelineItem label="2022-02-01" content="事件二" />
21
+ <EbizTimelineItem label="2022-03-01" content="事件三" />
22
+ <EbizTimelineItem label="2022-04-01" content="事件四" />
23
+ </EbizTimeline>
24
+ </div>
25
+
26
+ <h2>时间轴主题</h2>
27
+ <div class="demo-section">
28
+ <h3>点状主题</h3>
29
+ <EbizTimeline theme="dot">
30
+ <EbizTimelineItem label="2022-01-01" content="事件一" />
31
+ <EbizTimelineItem label="2022-02-01" content="事件二" />
32
+ <EbizTimelineItem label="2022-03-01" content="事件三" />
33
+ <EbizTimelineItem label="2022-04-01" content="事件四" />
34
+ </EbizTimeline>
35
+ </div>
36
+
37
+ <h2>不同的展示方式</h2>
38
+ <div class="demo-section">
39
+ <h3>左侧展示</h3>
40
+ <EbizTimeline mode="left">
41
+ <EbizTimelineItem label="2022-01-01" content="事件一" />
42
+ <EbizTimelineItem label="2022-02-01" content="事件二" />
43
+ <EbizTimelineItem label="2022-03-01" content="事件三" />
44
+ <EbizTimelineItem label="2022-04-01" content="事件四" />
45
+ </EbizTimeline>
46
+
47
+ <h3>右侧展示</h3>
48
+ <EbizTimeline mode="right">
49
+ <EbizTimelineItem label="2022-01-01" content="事件一" />
50
+ <EbizTimelineItem label="2022-02-01" content="事件二" />
51
+ <EbizTimelineItem label="2022-03-01" content="事件三" />
52
+ <EbizTimelineItem label="2022-04-01" content="事件四" />
53
+ </EbizTimeline>
54
+
55
+ <h3>同侧展示</h3>
56
+ <EbizTimeline mode="same">
57
+ <EbizTimelineItem label="2022-01-01" content="事件一" />
58
+ <EbizTimelineItem label="2022-02-01" content="事件二" />
59
+ <EbizTimelineItem label="2022-03-01" content="事件三" />
60
+ <EbizTimelineItem label="2022-04-01" content="事件四" />
61
+ </EbizTimeline>
62
+ </div>
63
+
64
+ <h2>标签位置</h2>
65
+ <div class="demo-section">
66
+ <h3>标签在左侧</h3>
67
+ <EbizTimeline labelAlign="left">
68
+ <EbizTimelineItem label="2022-01-01" content="事件一" />
69
+ <EbizTimelineItem label="2022-02-01" content="事件二" />
70
+ <EbizTimelineItem label="2022-03-01" content="事件三" />
71
+ <EbizTimelineItem label="2022-04-01" content="事件四" />
72
+ </EbizTimeline>
73
+
74
+ <h3>标签在顶部</h3>
75
+ <EbizTimeline labelAlign="top">
76
+ <EbizTimelineItem label="2022-01-01" content="事件一" />
77
+ <EbizTimelineItem label="2022-02-01" content="事件二" />
78
+ <EbizTimelineItem label="2022-03-01" content="事件三" />
79
+ <EbizTimelineItem label="2022-04-01" content="事件四" />
80
+ </EbizTimeline>
81
+ </div>
82
+
83
+ <h2>自定义节点颜色</h2>
84
+ <div class="demo-section">
85
+ <EbizTimeline>
86
+ <EbizTimelineItem label="2022-01-01" content="事件一" dotColor="primary" />
87
+ <EbizTimelineItem label="2022-02-01" content="事件二" dotColor="warning" />
88
+ <EbizTimelineItem label="2022-03-01" content="事件三" dotColor="error" />
89
+ <EbizTimelineItem label="2022-04-01" content="事件四" dotColor="success" />
90
+ </EbizTimeline>
91
+ </div>
92
+
93
+ <h2>使用插槽自定义内容</h2>
94
+ <div class="demo-section">
95
+ <EbizTimeline>
96
+ <EbizTimelineItem label="2022-01-01">
97
+ <div class="custom-content">
98
+ <h4>自定义内容一</h4>
99
+ <p>这是一个自定义内容示例</p>
100
+ </div>
101
+ </EbizTimelineItem>
102
+ <EbizTimelineItem label="2022-02-01">
103
+ <div class="custom-content">
104
+ <h4>自定义内容二</h4>
105
+ <p>这是一个自定义内容示例</p>
106
+ </div>
107
+ </EbizTimelineItem>
108
+ </EbizTimeline>
109
+ </div>
110
+
111
+ <h2>加载状态</h2>
112
+ <div class="demo-section">
113
+ <EbizTimeline>
114
+ <EbizTimelineItem label="2022-01-01" content="已完成" />
115
+ <EbizTimelineItem label="2022-02-01" content="进行中" loading />
116
+ <EbizTimelineItem label="2022-03-01" content="未开始" />
117
+ <EbizTimelineItem label="2022-04-01" content="未开始" />
118
+ </EbizTimeline>
119
+ </div>
120
+ </div>
121
+ </template>
122
+
123
+ <script setup>
124
+ import { EbizTimeline, EbizTimelineItem } from '../index.js';
125
+ </script>
126
+
127
+ <style scoped>
128
+ .timeline-demo {
129
+ padding: 20px;
130
+ }
131
+
132
+ .demo-section {
133
+ margin-bottom: 40px;
134
+ }
135
+
136
+ h1 {
137
+ margin-bottom: 30px;
138
+ }
139
+
140
+ h2 {
141
+ margin: 20px 0;
142
+ }
143
+
144
+ h3 {
145
+ margin: 15px 0;
146
+ }
147
+
148
+ .custom-content {
149
+ padding: 10px;
150
+ border: 1px solid #eee;
151
+ border-radius: 4px;
152
+ }
153
+
154
+ .custom-content h4 {
155
+ margin: 0 0 10px 0;
156
+ }
157
+
158
+ .custom-content p {
159
+ margin: 0;
160
+ }
161
+ </style>
@@ -0,0 +1,255 @@
1
+ <template>
2
+ <div class="tree-demo">
3
+ <h1>树组件示例</h1>
4
+
5
+ <h2>基础树</h2>
6
+ <div class="demo-section">
7
+ <EbizTree :items="treeData" />
8
+ </div>
9
+
10
+ <h2>可选择的树</h2>
11
+ <div class="demo-section">
12
+ <EbizTree :items="treeData" checkable v-model="checkedValue" @change="handleChange" />
13
+ <div class="result-panel">
14
+ <p>当前选中值: {{ checkedValue.join(', ') }}</p>
15
+ </div>
16
+ </div>
17
+
18
+ <h2>带禁用节点的树</h2>
19
+ <div class="demo-section">
20
+ <EbizTree :items="treeData" checkable :disable-check="disableTreeNode" />
21
+ <div class="description">
22
+ <p>通过 disableCheck 函数自定义禁用节点,所有值为"1.1"的节点无法被勾选</p>
23
+ </div>
24
+ </div>
25
+
26
+ <h2>带连接线的树</h2>
27
+ <div class="demo-section">
28
+ <EbizTree :items="treeData" line v-model:expanded="expandedNodes" />
29
+ </div>
30
+
31
+ <h2>启用动画效果的树</h2>
32
+ <div class="demo-section">
33
+ <EbizTree :items="treeData" line :transition="true" />
34
+ <div class="description">
35
+ <p>启用节点展开/收起的过渡动画效果</p>
36
+ </div>
37
+ </div>
38
+
39
+ <h2>可拖拽的树</h2>
40
+ <div class="demo-section">
41
+ <EbizTree
42
+ :items="treeData"
43
+ draggable
44
+ @drag-drop="handleDragDrop"
45
+ />
46
+ </div>
47
+
48
+ <h2>自定义图标的树</h2>
49
+ <div class="demo-section">
50
+ <EbizTree :items="treeData" line>
51
+ <template #icon="{ node }">
52
+ <span v-if="node.children && node.children.length">📁</span>
53
+ <span v-else>📄</span>
54
+ </template>
55
+ </EbizTree>
56
+ </div>
57
+
58
+ <h2>节点操作</h2>
59
+ <div class="demo-section">
60
+ <EbizTree :items="operableTreeData" line>
61
+ <template #operations="{ node }">
62
+ <div class="node-operations">
63
+ <button @click.stop="addChildNode(node)">添加</button>
64
+ <button @click.stop="removeNode(node)">删除</button>
65
+ </div>
66
+ </template>
67
+ </EbizTree>
68
+ </div>
69
+ </div>
70
+ </template>
71
+
72
+ <script setup>
73
+ import { ref } from 'vue';
74
+ import { EbizTree } from '../index.js';
75
+
76
+ // 树的数据
77
+ const treeData = ref([
78
+ {
79
+ label: '节点1',
80
+ value: '1',
81
+ children: [
82
+ {
83
+ label: '节点1.1',
84
+ value: '1.1',
85
+ children: [
86
+ {
87
+ label: '节点1.1.1',
88
+ value: '1.1.1'
89
+ },
90
+ {
91
+ label: '节点1.1.2',
92
+ value: '1.1.2'
93
+ }
94
+ ]
95
+ },
96
+ {
97
+ label: '节点1.2',
98
+ value: '1.2'
99
+ }
100
+ ]
101
+ },
102
+ {
103
+ label: '节点2',
104
+ value: '2',
105
+ children: [
106
+ {
107
+ label: '节点2.1',
108
+ value: '2.1'
109
+ },
110
+ {
111
+ label: '节点2.2',
112
+ value: '2.2'
113
+ }
114
+ ]
115
+ }
116
+ ]);
117
+
118
+ // 禁用特定节点选择的函数
119
+ const disableTreeNode = (node) => {
120
+ return node.value === '1.1';
121
+ };
122
+
123
+ // 可操作的树数据
124
+ const operableTreeData = ref([
125
+ {
126
+ label: '节点1',
127
+ value: '1',
128
+ children: [
129
+ {
130
+ label: '节点1.1',
131
+ value: '1.1'
132
+ }
133
+ ]
134
+ },
135
+ {
136
+ label: '节点2',
137
+ value: '2',
138
+ children: []
139
+ }
140
+ ]);
141
+
142
+ // 选中的值
143
+ const checkedValue = ref([]);
144
+
145
+ // 展开的节点
146
+ const expandedNodes = ref(['1', '1.1']);
147
+
148
+ // 选中值变化处理
149
+ const handleChange = (values, context) => {
150
+ console.log('选中值变化:', values);
151
+ console.log('选中上下文:', context);
152
+ };
153
+
154
+ // 拖拽处理
155
+ const handleDragDrop = (context) => {
156
+ console.log('拖拽结束:', context);
157
+ };
158
+
159
+ // 添加子节点
160
+ const addChildNode = (node) => {
161
+ const newNodeId = `${node.value}-${Date.now()}`;
162
+ const newNode = {
163
+ label: `节点${newNodeId}`,
164
+ value: newNodeId,
165
+ children: []
166
+ };
167
+
168
+ if (!node.children) {
169
+ node.children = [];
170
+ }
171
+
172
+ node.children.push(newNode);
173
+ };
174
+
175
+ // 删除节点
176
+ const removeNode = (node) => {
177
+ // 找到父节点,从父节点的children中删除当前节点
178
+ operableTreeData.value = removeNodeByValue(operableTreeData.value, node.value);
179
+ };
180
+
181
+ // 根据值递归删除节点
182
+ const removeNodeByValue = (nodes, value) => {
183
+ return nodes.filter(node => {
184
+ if (node.value === value) {
185
+ return false;
186
+ }
187
+
188
+ if (node.children && node.children.length) {
189
+ node.children = removeNodeByValue(node.children, value);
190
+ }
191
+
192
+ return true;
193
+ });
194
+ };
195
+ </script>
196
+
197
+ <style scoped>
198
+ .tree-demo {
199
+ padding: 20px;
200
+
201
+ h1 {
202
+ margin-bottom: 20px;
203
+ font-size: 24px;
204
+ }
205
+
206
+ h2 {
207
+ margin-top: 30px;
208
+ margin-bottom: 15px;
209
+ font-size: 20px;
210
+ }
211
+
212
+ .demo-section {
213
+ margin-bottom: 30px;
214
+ padding: 20px;
215
+ border: 1px solid #eee;
216
+ border-radius: 4px;
217
+ }
218
+
219
+ .result-panel {
220
+ margin-top: 16px;
221
+ padding: 10px;
222
+ background-color: #f5f5f5;
223
+ border-radius: 4px;
224
+
225
+ p {
226
+ margin: 0;
227
+ }
228
+ }
229
+
230
+ .node-operations {
231
+ display: inline-flex;
232
+ margin-left: 8px;
233
+
234
+ button {
235
+ margin-left: 4px;
236
+ padding: 2px 6px;
237
+ font-size: 12px;
238
+ background-color: #f0f0f0;
239
+ border: 1px solid #ddd;
240
+ border-radius: 3px;
241
+ cursor: pointer;
242
+
243
+ &:hover {
244
+ background-color: #e0e0e0;
245
+ }
246
+ }
247
+ }
248
+
249
+ .description {
250
+ margin-top: 10px;
251
+ color: #666;
252
+ font-size: 14px;
253
+ }
254
+ }
255
+ </style>