vue2-client 1.14.20 → 1.14.22
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 +1 -1
- package/src/base-client/components/his/XHisEditor/XHisEditor.vue +1 -0
- package/src/base-client/components/his/XSidebar/XSidebar.vue +3 -3
- package/src/base-client/components/his/XTextCard/XTextCard.vue +207 -207
- package/src/base-client/components/his/XTreeRows/TreeNode.vue +100 -100
- package/src/base-client/components/his/XTreeRows/XTreeRows.vue +197 -197
- package/src/base-client/components/his/threeTestOrders/editor.vue +111 -111
- package/src/base-client/components/his/threeTestOrders/textBox.vue +522 -522
- package/src/base-client/components/his/threeTestOrders/threeTestOrders.vue +386 -386
- package/src/router/async/router.map.js +2 -2
- package/src/base-client/components/TreeList/TreeList.vue +0 -91
- package/src/base-client/components/TreeList/TreeNode.vue +0 -81
- package/src/base-client/components/common/XCardSet/XTiltle.vue +0 -191
- package/src/base-client/components/his/threeTestOrders/test.vue +0 -21
package/package.json
CHANGED
|
@@ -132,14 +132,14 @@ export default {
|
|
|
132
132
|
currentCol = currentCol.parentNode
|
|
133
133
|
}
|
|
134
134
|
if (currentCol) {
|
|
135
|
-
//
|
|
135
|
+
// 更新当前列的宽度
|
|
136
136
|
const drawerWidth = isOpen ? 33.3 : 2
|
|
137
137
|
// 强制更新样式
|
|
138
138
|
currentCol.style.cssText = `
|
|
139
139
|
flex: 0 0 ${drawerWidth}% !important;
|
|
140
140
|
max-width: ${drawerWidth}% !important;
|
|
141
141
|
transition: all 0.3s;`
|
|
142
|
-
//
|
|
142
|
+
// 触发XTab组件重新计算宽度
|
|
143
143
|
this.$nextTick(() => {
|
|
144
144
|
const tabComponent = this.$el.querySelector('.ant-tabs')
|
|
145
145
|
if (tabComponent) {
|
|
@@ -147,7 +147,7 @@ export default {
|
|
|
147
147
|
window.dispatchEvent(new Event('resize'))
|
|
148
148
|
}
|
|
149
149
|
})
|
|
150
|
-
//
|
|
150
|
+
// 更新其他列宽度
|
|
151
151
|
otherCols.forEach((col, index) => {
|
|
152
152
|
if (index < this.mainWithData.length) {
|
|
153
153
|
const widthValue = isOpen ? this.mainWithData[index].min : this.mainWithData[index].max
|
|
@@ -1,207 +1,207 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div>
|
|
3
|
-
<div class="text-card">
|
|
4
|
-
<div
|
|
5
|
-
v-for="(item, index) in displayItems"
|
|
6
|
-
:key="index"
|
|
7
|
-
class="text-item"
|
|
8
|
-
@click="handleItemClick(index, item.id)"
|
|
9
|
-
@contextmenu.prevent="handleContextMenu(index, item.id)">
|
|
10
|
-
<div class="text-content" :class="{ 'is-empty': !item.content }">
|
|
11
|
-
{{ item.content || '+' }}
|
|
12
|
-
</div>
|
|
13
|
-
</div>
|
|
14
|
-
<!-- 编辑弹出框 -->
|
|
15
|
-
<div
|
|
16
|
-
v-if="showEdit"
|
|
17
|
-
class="edit-overlay"
|
|
18
|
-
@click.self="handleOverlayClick">
|
|
19
|
-
<div class="edit-card">
|
|
20
|
-
<a-textarea
|
|
21
|
-
v-model="editingContent"
|
|
22
|
-
:autoSize="{ minRows: 3 }"
|
|
23
|
-
@keyup.enter="handleSave"
|
|
24
|
-
ref="textarea"/>
|
|
25
|
-
</div>
|
|
26
|
-
</div>
|
|
27
|
-
<!-- 删除确认弹框 -->
|
|
28
|
-
<a-modal
|
|
29
|
-
v-model="showDeleteModal"
|
|
30
|
-
title="确认删除"
|
|
31
|
-
okText="确认"
|
|
32
|
-
cancelText="取消"
|
|
33
|
-
@ok="handleDeleteConfirm">
|
|
34
|
-
<p>确定要删除这条内容吗?</p>
|
|
35
|
-
</a-modal>
|
|
36
|
-
</div>
|
|
37
|
-
</div>
|
|
38
|
-
</template>
|
|
39
|
-
|
|
40
|
-
<script>
|
|
41
|
-
import { runLogic } from '@vue2-client/services/api/common'
|
|
42
|
-
|
|
43
|
-
export default {
|
|
44
|
-
name: 'XTextCard',
|
|
45
|
-
props: {
|
|
46
|
-
// logic配置名,要求返回一个数组[{ id: , content: }]
|
|
47
|
-
queryParamsName: {
|
|
48
|
-
type: String,
|
|
49
|
-
default: 'memorandumLOGIC'
|
|
50
|
-
},
|
|
51
|
-
queryParams: {
|
|
52
|
-
type: Object,
|
|
53
|
-
default: () => { return {} }
|
|
54
|
-
},
|
|
55
|
-
// 请求参数
|
|
56
|
-
parameter: {
|
|
57
|
-
type: Object,
|
|
58
|
-
default: () => { return {} }
|
|
59
|
-
}
|
|
60
|
-
},
|
|
61
|
-
data () {
|
|
62
|
-
return {
|
|
63
|
-
localItems: [], // 本地数据
|
|
64
|
-
showEdit: false, // 是否显示编辑框
|
|
65
|
-
editingIndex: -1, // 当前编辑的索引
|
|
66
|
-
editingContent: '', // 编辑框的内容
|
|
67
|
-
showDeleteModal: false, // 是否显示删除确认框
|
|
68
|
-
deleteIndex: -1, // 要删除的项目索引
|
|
69
|
-
ID: 0
|
|
70
|
-
}
|
|
71
|
-
},
|
|
72
|
-
computed: {
|
|
73
|
-
// 显示的列表,始终保持一个空行
|
|
74
|
-
displayItems () {
|
|
75
|
-
const items = [...this.localItems]
|
|
76
|
-
// 如果最后一项不是空的,添加一个空项
|
|
77
|
-
if (!items.length || items[items.length - 1].content) {
|
|
78
|
-
items.push({ content: '' })
|
|
79
|
-
}
|
|
80
|
-
return items
|
|
81
|
-
}
|
|
82
|
-
},
|
|
83
|
-
methods: {
|
|
84
|
-
// 点击项目
|
|
85
|
-
handleItemClick (index, id) {
|
|
86
|
-
this.ID = id
|
|
87
|
-
this.editingIndex = index
|
|
88
|
-
this.editingContent = this.displayItems[index].content
|
|
89
|
-
this.showEdit = true
|
|
90
|
-
this.$nextTick(() => {
|
|
91
|
-
this.$refs.textarea?.focus()
|
|
92
|
-
})
|
|
93
|
-
},
|
|
94
|
-
// 点击遮罩层保存
|
|
95
|
-
handleOverlayClick () {
|
|
96
|
-
this.handleSave()
|
|
97
|
-
},
|
|
98
|
-
// 保存内容
|
|
99
|
-
handleSave () {
|
|
100
|
-
if (this.editingContent.trim()) {
|
|
101
|
-
if (this.editingIndex === this.localItems.length) {
|
|
102
|
-
// 如果是在最后一个空行添加,push新内容
|
|
103
|
-
this.localItems.push({ content: this.editingContent.trim() })
|
|
104
|
-
} else {
|
|
105
|
-
// 否则更新现有内容
|
|
106
|
-
this.localItems[this.editingIndex].content = this.editingContent.trim()
|
|
107
|
-
}
|
|
108
|
-
const addData = { data: this.editingContent.trim(), ID: this.ID }
|
|
109
|
-
// 触发更新事件
|
|
110
|
-
this.$emit('add', addData)
|
|
111
|
-
}
|
|
112
|
-
this.showEdit = false
|
|
113
|
-
this.editingIndex = -1
|
|
114
|
-
this.editingContent = ''
|
|
115
|
-
},
|
|
116
|
-
// 初始化数据
|
|
117
|
-
async initData (data, parameter) {
|
|
118
|
-
// 从配置中获取数据
|
|
119
|
-
const resData = await runLogic(data, parameter, 'af-his')
|
|
120
|
-
this.localItems = resData
|
|
121
|
-
return resData
|
|
122
|
-
},
|
|
123
|
-
// 处理右键菜单
|
|
124
|
-
handleContextMenu (index, id) {
|
|
125
|
-
// 如果是最后一个空行,不显示删除框
|
|
126
|
-
if (index === this.localItems.length) {
|
|
127
|
-
return
|
|
128
|
-
}
|
|
129
|
-
this.ID = id
|
|
130
|
-
this.deleteIndex = index
|
|
131
|
-
this.showDeleteModal = true
|
|
132
|
-
},
|
|
133
|
-
// 确认删除
|
|
134
|
-
handleDeleteConfirm () {
|
|
135
|
-
if (this.deleteIndex > -1) {
|
|
136
|
-
this.localItems.splice(this.deleteIndex, 1)
|
|
137
|
-
const deleteData = { data: [...this.localItems][this.deleteIndex], ID: this.ID }
|
|
138
|
-
this.$emit('deleteData', deleteData)
|
|
139
|
-
this.deleteIndex = -1
|
|
140
|
-
}
|
|
141
|
-
this.showDeleteModal = false
|
|
142
|
-
}
|
|
143
|
-
},
|
|
144
|
-
watch: {
|
|
145
|
-
queryParamsName: {
|
|
146
|
-
immediate: true,
|
|
147
|
-
handler (newVal) {
|
|
148
|
-
this.initData(newVal, this.parameter)
|
|
149
|
-
},
|
|
150
|
-
deep: true
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
</script>
|
|
155
|
-
|
|
156
|
-
<style scoped lang="less">
|
|
157
|
-
.text-card {
|
|
158
|
-
position: relative;
|
|
159
|
-
width: 100%;
|
|
160
|
-
.text-item {
|
|
161
|
-
padding: 8px 12px;
|
|
162
|
-
border-bottom: 1px solid #f0f0f0;
|
|
163
|
-
cursor: pointer;
|
|
164
|
-
transition: all 0.3s;
|
|
165
|
-
user-select: none;
|
|
166
|
-
|
|
167
|
-
&:hover {
|
|
168
|
-
background-color: #f5f5f5;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
.text-content {
|
|
172
|
-
white-space: nowrap;
|
|
173
|
-
overflow: hidden;
|
|
174
|
-
text-overflow: ellipsis;
|
|
175
|
-
line-height: 1.5;
|
|
176
|
-
|
|
177
|
-
&.is-empty {
|
|
178
|
-
color: #5D5C5C;
|
|
179
|
-
font-weight: 400;
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
.edit-overlay {
|
|
184
|
-
position: fixed;
|
|
185
|
-
top: 0;
|
|
186
|
-
left: 0;
|
|
187
|
-
right: 0;
|
|
188
|
-
bottom: 0;
|
|
189
|
-
background-color: rgba(0, 0, 0, 0.45);
|
|
190
|
-
z-index: 1000;
|
|
191
|
-
display: flex;
|
|
192
|
-
align-items: center;
|
|
193
|
-
justify-content: center;
|
|
194
|
-
.edit-card {
|
|
195
|
-
background: white;
|
|
196
|
-
padding: 16px;
|
|
197
|
-
border-radius: 8px;
|
|
198
|
-
width: 90%;
|
|
199
|
-
max-width: 500px;
|
|
200
|
-
box-shadow: 0 3px 6px -4px rgba(0, 0, 0, 0.12);
|
|
201
|
-
.ant-input {
|
|
202
|
-
width: 100%;
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
</style>
|
|
1
|
+
<template>
|
|
2
|
+
<div>
|
|
3
|
+
<div class="text-card">
|
|
4
|
+
<div
|
|
5
|
+
v-for="(item, index) in displayItems"
|
|
6
|
+
:key="index"
|
|
7
|
+
class="text-item"
|
|
8
|
+
@click="handleItemClick(index, item.id)"
|
|
9
|
+
@contextmenu.prevent="handleContextMenu(index, item.id)">
|
|
10
|
+
<div class="text-content" :class="{ 'is-empty': !item.content }">
|
|
11
|
+
{{ item.content || '+' }}
|
|
12
|
+
</div>
|
|
13
|
+
</div>
|
|
14
|
+
<!-- 编辑弹出框 -->
|
|
15
|
+
<div
|
|
16
|
+
v-if="showEdit"
|
|
17
|
+
class="edit-overlay"
|
|
18
|
+
@click.self="handleOverlayClick">
|
|
19
|
+
<div class="edit-card">
|
|
20
|
+
<a-textarea
|
|
21
|
+
v-model="editingContent"
|
|
22
|
+
:autoSize="{ minRows: 3 }"
|
|
23
|
+
@keyup.enter="handleSave"
|
|
24
|
+
ref="textarea"/>
|
|
25
|
+
</div>
|
|
26
|
+
</div>
|
|
27
|
+
<!-- 删除确认弹框 -->
|
|
28
|
+
<a-modal
|
|
29
|
+
v-model="showDeleteModal"
|
|
30
|
+
title="确认删除"
|
|
31
|
+
okText="确认"
|
|
32
|
+
cancelText="取消"
|
|
33
|
+
@ok="handleDeleteConfirm">
|
|
34
|
+
<p>确定要删除这条内容吗?</p>
|
|
35
|
+
</a-modal>
|
|
36
|
+
</div>
|
|
37
|
+
</div>
|
|
38
|
+
</template>
|
|
39
|
+
|
|
40
|
+
<script>
|
|
41
|
+
import { runLogic } from '@vue2-client/services/api/common'
|
|
42
|
+
|
|
43
|
+
export default {
|
|
44
|
+
name: 'XTextCard',
|
|
45
|
+
props: {
|
|
46
|
+
// logic配置名,要求返回一个数组[{ id: , content: }]
|
|
47
|
+
queryParamsName: {
|
|
48
|
+
type: String,
|
|
49
|
+
default: 'memorandumLOGIC'
|
|
50
|
+
},
|
|
51
|
+
queryParams: {
|
|
52
|
+
type: Object,
|
|
53
|
+
default: () => { return {} }
|
|
54
|
+
},
|
|
55
|
+
// 请求参数
|
|
56
|
+
parameter: {
|
|
57
|
+
type: Object,
|
|
58
|
+
default: () => { return {} }
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
data () {
|
|
62
|
+
return {
|
|
63
|
+
localItems: [], // 本地数据
|
|
64
|
+
showEdit: false, // 是否显示编辑框
|
|
65
|
+
editingIndex: -1, // 当前编辑的索引
|
|
66
|
+
editingContent: '', // 编辑框的内容
|
|
67
|
+
showDeleteModal: false, // 是否显示删除确认框
|
|
68
|
+
deleteIndex: -1, // 要删除的项目索引
|
|
69
|
+
ID: 0
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
computed: {
|
|
73
|
+
// 显示的列表,始终保持一个空行
|
|
74
|
+
displayItems () {
|
|
75
|
+
const items = [...this.localItems]
|
|
76
|
+
// 如果最后一项不是空的,添加一个空项
|
|
77
|
+
if (!items.length || items[items.length - 1].content) {
|
|
78
|
+
items.push({ content: '' })
|
|
79
|
+
}
|
|
80
|
+
return items
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
methods: {
|
|
84
|
+
// 点击项目
|
|
85
|
+
handleItemClick (index, id) {
|
|
86
|
+
this.ID = id
|
|
87
|
+
this.editingIndex = index
|
|
88
|
+
this.editingContent = this.displayItems[index].content
|
|
89
|
+
this.showEdit = true
|
|
90
|
+
this.$nextTick(() => {
|
|
91
|
+
this.$refs.textarea?.focus()
|
|
92
|
+
})
|
|
93
|
+
},
|
|
94
|
+
// 点击遮罩层保存
|
|
95
|
+
handleOverlayClick () {
|
|
96
|
+
this.handleSave()
|
|
97
|
+
},
|
|
98
|
+
// 保存内容
|
|
99
|
+
handleSave () {
|
|
100
|
+
if (this.editingContent.trim()) {
|
|
101
|
+
if (this.editingIndex === this.localItems.length) {
|
|
102
|
+
// 如果是在最后一个空行添加,push新内容
|
|
103
|
+
this.localItems.push({ content: this.editingContent.trim() })
|
|
104
|
+
} else {
|
|
105
|
+
// 否则更新现有内容
|
|
106
|
+
this.localItems[this.editingIndex].content = this.editingContent.trim()
|
|
107
|
+
}
|
|
108
|
+
const addData = { data: this.editingContent.trim(), ID: this.ID }
|
|
109
|
+
// 触发更新事件
|
|
110
|
+
this.$emit('add', addData)
|
|
111
|
+
}
|
|
112
|
+
this.showEdit = false
|
|
113
|
+
this.editingIndex = -1
|
|
114
|
+
this.editingContent = ''
|
|
115
|
+
},
|
|
116
|
+
// 初始化数据
|
|
117
|
+
async initData (data, parameter) {
|
|
118
|
+
// 从配置中获取数据
|
|
119
|
+
const resData = await runLogic(data, parameter, 'af-his')
|
|
120
|
+
this.localItems = resData
|
|
121
|
+
return resData
|
|
122
|
+
},
|
|
123
|
+
// 处理右键菜单
|
|
124
|
+
handleContextMenu (index, id) {
|
|
125
|
+
// 如果是最后一个空行,不显示删除框
|
|
126
|
+
if (index === this.localItems.length) {
|
|
127
|
+
return
|
|
128
|
+
}
|
|
129
|
+
this.ID = id
|
|
130
|
+
this.deleteIndex = index
|
|
131
|
+
this.showDeleteModal = true
|
|
132
|
+
},
|
|
133
|
+
// 确认删除
|
|
134
|
+
handleDeleteConfirm () {
|
|
135
|
+
if (this.deleteIndex > -1) {
|
|
136
|
+
this.localItems.splice(this.deleteIndex, 1)
|
|
137
|
+
const deleteData = { data: [...this.localItems][this.deleteIndex], ID: this.ID }
|
|
138
|
+
this.$emit('deleteData', deleteData)
|
|
139
|
+
this.deleteIndex = -1
|
|
140
|
+
}
|
|
141
|
+
this.showDeleteModal = false
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
watch: {
|
|
145
|
+
queryParamsName: {
|
|
146
|
+
immediate: true,
|
|
147
|
+
handler (newVal) {
|
|
148
|
+
this.initData(newVal, this.parameter)
|
|
149
|
+
},
|
|
150
|
+
deep: true
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
</script>
|
|
155
|
+
|
|
156
|
+
<style scoped lang="less">
|
|
157
|
+
.text-card {
|
|
158
|
+
position: relative;
|
|
159
|
+
width: 100%;
|
|
160
|
+
.text-item {
|
|
161
|
+
padding: 8px 12px;
|
|
162
|
+
border-bottom: 1px solid #f0f0f0;
|
|
163
|
+
cursor: pointer;
|
|
164
|
+
transition: all 0.3s;
|
|
165
|
+
user-select: none;
|
|
166
|
+
|
|
167
|
+
&:hover {
|
|
168
|
+
background-color: #f5f5f5;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
.text-content {
|
|
172
|
+
white-space: nowrap;
|
|
173
|
+
overflow: hidden;
|
|
174
|
+
text-overflow: ellipsis;
|
|
175
|
+
line-height: 1.5;
|
|
176
|
+
|
|
177
|
+
&.is-empty {
|
|
178
|
+
color: #5D5C5C;
|
|
179
|
+
font-weight: 400;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
.edit-overlay {
|
|
184
|
+
position: fixed;
|
|
185
|
+
top: 0;
|
|
186
|
+
left: 0;
|
|
187
|
+
right: 0;
|
|
188
|
+
bottom: 0;
|
|
189
|
+
background-color: rgba(0, 0, 0, 0.45);
|
|
190
|
+
z-index: 1000;
|
|
191
|
+
display: flex;
|
|
192
|
+
align-items: center;
|
|
193
|
+
justify-content: center;
|
|
194
|
+
.edit-card {
|
|
195
|
+
background: white;
|
|
196
|
+
padding: 16px;
|
|
197
|
+
border-radius: 8px;
|
|
198
|
+
width: 90%;
|
|
199
|
+
max-width: 500px;
|
|
200
|
+
box-shadow: 0 3px 6px -4px rgba(0, 0, 0, 0.12);
|
|
201
|
+
.ant-input {
|
|
202
|
+
width: 100%;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
</style>
|
|
@@ -1,100 +1,100 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="tree-node">
|
|
3
|
-
<div class="node-content" @click="handleClick">
|
|
4
|
-
<span v-if="hasChildren" class="toggle-icon">
|
|
5
|
-
{{ node.expanded ? '-' : '+' }}
|
|
6
|
-
</span>
|
|
7
|
-
<span v-else class="empty-space"></span>
|
|
8
|
-
<span class="node-title" :title="node.title">{{ node.title }}</span>
|
|
9
|
-
</div>
|
|
10
|
-
<div v-if="hasChildren && node.expanded" class="node-children">
|
|
11
|
-
<tree-node
|
|
12
|
-
v-for="child in node.children"
|
|
13
|
-
:key="child.id"
|
|
14
|
-
:node="child"
|
|
15
|
-
@toggle="handleToggle"
|
|
16
|
-
:level="level + 1"/>
|
|
17
|
-
</div>
|
|
18
|
-
</div>
|
|
19
|
-
</template>
|
|
20
|
-
|
|
21
|
-
<script>
|
|
22
|
-
export default {
|
|
23
|
-
name: 'TreeNode',
|
|
24
|
-
props: {
|
|
25
|
-
node: {
|
|
26
|
-
type: Object,
|
|
27
|
-
required: true
|
|
28
|
-
},
|
|
29
|
-
level: {
|
|
30
|
-
type: Number,
|
|
31
|
-
default: 0
|
|
32
|
-
}
|
|
33
|
-
},
|
|
34
|
-
computed: {
|
|
35
|
-
hasChildren () {
|
|
36
|
-
return this.node.children && this.node.children.length > 0
|
|
37
|
-
}
|
|
38
|
-
},
|
|
39
|
-
methods: {
|
|
40
|
-
handleClick () {
|
|
41
|
-
if (this.hasChildren) {
|
|
42
|
-
this.$emit('toggle', this.node)
|
|
43
|
-
}
|
|
44
|
-
},
|
|
45
|
-
handleToggle (childNode) {
|
|
46
|
-
this.$emit('toggle', childNode)
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
</script>
|
|
51
|
-
|
|
52
|
-
<style scoped>
|
|
53
|
-
.tree-node {
|
|
54
|
-
margin: 1px 0;
|
|
55
|
-
white-space: nowrap;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
.node-content {
|
|
59
|
-
display: flex;
|
|
60
|
-
align-items: center;
|
|
61
|
-
padding: 3px 2px;
|
|
62
|
-
user-select: none;
|
|
63
|
-
border-radius: 2px;
|
|
64
|
-
overflow: hidden;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
.toggle-icon {
|
|
68
|
-
width: 12px;
|
|
69
|
-
text-align: center;
|
|
70
|
-
font-size: 14px;
|
|
71
|
-
color:#5D5C5C;
|
|
72
|
-
font-weight: 400;
|
|
73
|
-
margin-right: 3px;
|
|
74
|
-
cursor: pointer;
|
|
75
|
-
flex-shrink: 0;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
.empty-space {
|
|
79
|
-
width: 12px;
|
|
80
|
-
margin-right: 3px;
|
|
81
|
-
flex-shrink: 0;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
.node-title {
|
|
85
|
-
flex: 1;
|
|
86
|
-
cursor: default;
|
|
87
|
-
white-space: nowrap;
|
|
88
|
-
overflow: hidden;
|
|
89
|
-
text-overflow: ellipsis;
|
|
90
|
-
min-width: 0;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
.node-content:hover {
|
|
94
|
-
background-color: #f5f5f5;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
.node-children {
|
|
98
|
-
padding-left: 15px;
|
|
99
|
-
}
|
|
100
|
-
</style>
|
|
1
|
+
<template>
|
|
2
|
+
<div class="tree-node">
|
|
3
|
+
<div class="node-content" @click="handleClick">
|
|
4
|
+
<span v-if="hasChildren" class="toggle-icon">
|
|
5
|
+
{{ node.expanded ? '-' : '+' }}
|
|
6
|
+
</span>
|
|
7
|
+
<span v-else class="empty-space"></span>
|
|
8
|
+
<span class="node-title" :title="node.title">{{ node.title }}</span>
|
|
9
|
+
</div>
|
|
10
|
+
<div v-if="hasChildren && node.expanded" class="node-children">
|
|
11
|
+
<tree-node
|
|
12
|
+
v-for="child in node.children"
|
|
13
|
+
:key="child.id"
|
|
14
|
+
:node="child"
|
|
15
|
+
@toggle="handleToggle"
|
|
16
|
+
:level="level + 1"/>
|
|
17
|
+
</div>
|
|
18
|
+
</div>
|
|
19
|
+
</template>
|
|
20
|
+
|
|
21
|
+
<script>
|
|
22
|
+
export default {
|
|
23
|
+
name: 'TreeNode',
|
|
24
|
+
props: {
|
|
25
|
+
node: {
|
|
26
|
+
type: Object,
|
|
27
|
+
required: true
|
|
28
|
+
},
|
|
29
|
+
level: {
|
|
30
|
+
type: Number,
|
|
31
|
+
default: 0
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
computed: {
|
|
35
|
+
hasChildren () {
|
|
36
|
+
return this.node.children && this.node.children.length > 0
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
methods: {
|
|
40
|
+
handleClick () {
|
|
41
|
+
if (this.hasChildren) {
|
|
42
|
+
this.$emit('toggle', this.node)
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
handleToggle (childNode) {
|
|
46
|
+
this.$emit('toggle', childNode)
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
</script>
|
|
51
|
+
|
|
52
|
+
<style scoped>
|
|
53
|
+
.tree-node {
|
|
54
|
+
margin: 1px 0;
|
|
55
|
+
white-space: nowrap;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.node-content {
|
|
59
|
+
display: flex;
|
|
60
|
+
align-items: center;
|
|
61
|
+
padding: 3px 2px;
|
|
62
|
+
user-select: none;
|
|
63
|
+
border-radius: 2px;
|
|
64
|
+
overflow: hidden;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.toggle-icon {
|
|
68
|
+
width: 12px;
|
|
69
|
+
text-align: center;
|
|
70
|
+
font-size: 14px;
|
|
71
|
+
color:#5D5C5C;
|
|
72
|
+
font-weight: 400;
|
|
73
|
+
margin-right: 3px;
|
|
74
|
+
cursor: pointer;
|
|
75
|
+
flex-shrink: 0;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.empty-space {
|
|
79
|
+
width: 12px;
|
|
80
|
+
margin-right: 3px;
|
|
81
|
+
flex-shrink: 0;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.node-title {
|
|
85
|
+
flex: 1;
|
|
86
|
+
cursor: default;
|
|
87
|
+
white-space: nowrap;
|
|
88
|
+
overflow: hidden;
|
|
89
|
+
text-overflow: ellipsis;
|
|
90
|
+
min-width: 0;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.node-content:hover {
|
|
94
|
+
background-color: #f5f5f5;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.node-children {
|
|
98
|
+
padding-left: 15px;
|
|
99
|
+
}
|
|
100
|
+
</style>
|