@ebiz/designer-components 0.0.58 → 0.0.60
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/README.md +29 -29
- package/dist/designer-components.css +1 -1
- package/dist/index.mjs +5925 -5923
- package/package.json +1 -1
- package/src/App.vue +26 -26
- package/src/apiService/SIMPLE_DATA_SERVICE.md +284 -284
- package/src/apiService/mockDataService.js +115 -115
- package/src/apiService/simpleDataService.js +297 -297
- package/src/assets/base.css +86 -86
- package/src/assets/logo.svg +1 -1
- package/src/components/Button.vue +149 -149
- package/src/components/DataContainer.vue +40 -40
- package/src/components/EbizApproval.vue +332 -338
- package/src/components/EbizAutoForm.vue +596 -596
- package/src/components/EbizAvatar.vue +115 -115
- package/src/components/EbizCheckbox.vue +93 -93
- package/src/components/EbizCheckboxGroup.vue +69 -69
- package/src/components/EbizDepartmentSelector.vue +144 -144
- package/src/components/EbizDescriptions.vue +340 -340
- package/src/components/EbizDescriptionsItem.vue +47 -47
- package/src/components/EbizDetailBlock.vue +81 -81
- package/src/components/EbizDialog.vue +260 -260
- package/src/components/EbizDiv.vue +32 -32
- package/src/components/EbizDivider.vue +96 -96
- package/src/components/EbizEmployeeInfo.vue +138 -138
- package/src/components/EbizEmployeeSelector.vue +1093 -1086
- package/src/components/EbizFileUpload.vue +238 -238
- package/src/components/EbizMap.vue +541 -541
- package/src/components/EbizOkrTree.vue +99 -99
- package/src/components/EbizPageHeader.vue +95 -95
- package/src/components/EbizPagination.vue +162 -162
- package/src/components/EbizPopconfirm.vue +47 -47
- package/src/components/EbizRadio.vue +86 -86
- package/src/components/EbizRadioGroup.vue +83 -83
- package/src/components/EbizRemoteSelect.vue +232 -232
- package/src/components/EbizRouteBreadcrumb.vue +46 -46
- package/src/components/EbizSelect.vue +85 -85
- package/src/components/EbizSpace.vue +100 -100
- package/src/components/EbizStatistic.vue +149 -149
- package/src/components/EbizStatsCard.vue +113 -113
- package/src/components/EbizSwiper.vue +113 -113
- package/src/components/EbizSwiperItem.vue +13 -13
- package/src/components/EbizSwitch.vue +85 -85
- package/src/components/EbizTabHeader.vue +132 -132
- package/src/components/EbizTabPanel.vue +22 -22
- package/src/components/EbizTable.vue +469 -469
- package/src/components/EbizTableColumn.vue +116 -116
- package/src/components/EbizTableSort.vue +179 -179
- package/src/components/EbizTabs.vue +142 -142
- package/src/components/EbizTdesignButtonDialog.vue +332 -332
- package/src/components/EbizTdesignLoading.vue +107 -107
- package/src/components/EbizTimePicker.vue +143 -143
- package/src/components/EbizTitle.vue +91 -91
- package/src/components/EbizTree.vue +152 -152
- package/src/components/EbizTreeMergeTable.vue +1414 -1414
- package/src/components/EbizTreeSelector.vue +418 -418
- package/src/components/EbizVxeTable.vue +290 -290
- package/src/components/Form.vue +28 -28
- package/src/components/Home.vue +7 -7
- package/src/components/MyComponent.vue +39 -39
- package/src/components/Table.vue +45 -45
- package/src/components/TdesignAlert.vue +115 -115
- package/src/components/TdesignButton.vue +135 -135
- package/src/components/TdesignCalendar/index.vue +145 -145
- package/src/components/TdesignCard.vue +195 -195
- package/src/components/TdesignCol.vue +101 -101
- package/src/components/TdesignCollapse.vue +142 -142
- package/src/components/TdesignCollapsePanel.vue +79 -79
- package/src/components/TdesignDatePicker.vue +124 -124
- package/src/components/TdesignDescriptions.vue +74 -74
- package/src/components/TdesignDescriptionsItem.vue +50 -50
- package/src/components/TdesignDialog.vue +225 -225
- package/src/components/TdesignForm.vue +138 -138
- package/src/components/TdesignFormItem.vue +105 -105
- package/src/components/TdesignGrid.vue +55 -55
- package/src/components/TdesignIcon.vue +67 -67
- package/src/components/TdesignImage.vue +162 -162
- package/src/components/TdesignImageViewer.vue +200 -200
- package/src/components/TdesignInput.vue +242 -242
- package/src/components/TdesignSelect.vue +444 -444
- package/src/components/TdesignTag.vue +117 -117
- package/src/components/TdesignTextarea.vue +142 -142
- package/src/components/TdesignTimeline.vue +58 -58
- package/src/components/TdesignTimelineItem.vue +71 -71
- package/src/components/TdesignUpload.vue +388 -388
- package/src/components/TdesignWatermark.vue +107 -107
- package/src/components/ebiz-form/components/cascader.vue +61 -61
- package/src/components/ebiz-form/components/checkbox.vue +37 -37
- package/src/components/ebiz-form/components/city.vue +137 -137
- package/src/components/ebiz-form/components/date-panel.vue +52 -52
- package/src/components/ebiz-form/components/date-range-panel.vue +52 -52
- package/src/components/ebiz-form/components/date-range.vue +56 -56
- package/src/components/ebiz-form/components/date.vue +52 -52
- package/src/components/ebiz-form/components/editor-multi-language.vue +47 -47
- package/src/components/ebiz-form/components/editor.vue +78 -78
- package/src/components/ebiz-form/components/file-multi-language.vue +52 -52
- package/src/components/ebiz-form/components/file.vue +149 -149
- package/src/components/ebiz-form/components/images-multi-language.vue +52 -52
- package/src/components/ebiz-form/components/images.vue +129 -129
- package/src/components/ebiz-form/components/img-multi-language.vue +51 -51
- package/src/components/ebiz-form/components/img.vue +129 -129
- package/src/components/ebiz-form/components/number.vue +50 -50
- package/src/components/ebiz-form/components/radio.vue +28 -28
- package/src/components/ebiz-form/components/select.vue +119 -119
- package/src/components/ebiz-form/components/switch.vue +23 -23
- package/src/components/ebiz-form/components/text-multi-language.vue +47 -47
- package/src/components/ebiz-form/components/text.vue +52 -52
- package/src/components/ebiz-form/components/textarea-multi-language.vue +48 -48
- package/src/components/ebiz-form/components/textarea.vue +29 -29
- package/src/components/ebiz-form/components/video-multi-language.vue +51 -51
- package/src/components/ebiz-form/components/video.vue +97 -97
- package/src/components/ebiz-form/index.vue +157 -157
- package/src/components/examples/PopconfirmExample.vue +149 -149
- package/src/components/icons/IconCommunity.vue +7 -7
- package/src/components/icons/IconDocumentation.vue +7 -7
- package/src/components/icons/IconEcosystem.vue +7 -7
- package/src/components/icons/IconSupport.vue +7 -7
- package/src/components/icons/IconTooling.vue +19 -19
- package/src/components/senior/EbizSData/index.vue +262 -260
- package/src/components/senior/EbizSDialog/index.vue +713 -713
- package/src/components/senior/EbizSForm/README.md +157 -157
- package/src/components/senior/EbizSForm/index.vue +668 -668
- package/src/components/senior/EbizSForm/item.vue +522 -522
- package/src/components/senior/EbizSForm/mItems/DateTimePicker.vue +51 -51
- package/src/components/senior/EbizSForm/mItems/Picker.vue +63 -63
- package/src/index.js +218 -218
- package/src/main.js +55 -55
- package/src/router/index.js +374 -374
- package/src/utils/formatCode.js +24 -24
- package/src/utils/generateImportStatement.js +52 -52
- package/src/utils/hasJsx.js +25 -25
- package/src/utils/index.js +166 -166
- package/src/utils/mergeOptions.js +29 -29
- package/src/utils/parseRequiredBlocks.js +18 -18
- package/src/utils/upload.ts +126 -126
- package/src/utils/vue-sfc-validator.js +155 -155
- package/src/views/Button.vue +23 -23
- package/src/views/CheckboxDemo.vue +104 -104
- package/src/views/DataContainer.vue +19 -19
- package/src/views/DialogDemo.vue +125 -125
- package/src/views/EbizApprovalDemo.vue +76 -76
- package/src/views/EbizAutoFormDemo.vue +129 -129
- package/src/views/EbizAvatar.vue +223 -223
- package/src/views/EbizDepartmentSelectorDemo.vue +169 -169
- package/src/views/EbizDetailBlockDemo.vue +30 -30
- package/src/views/EbizEmployeeInfo.vue +249 -249
- package/src/views/EbizEmployeeSelector.vue +83 -83
- package/src/views/EbizMap.vue +201 -201
- package/src/views/EbizRadioDemo.vue +151 -151
- package/src/views/EbizSDataDemo.vue +136 -136
- package/src/views/EbizSDialogDemo.vue +301 -301
- package/src/views/EbizSForm/index.vue +359 -359
- package/src/views/EbizSFormDemo.vue +420 -420
- package/src/views/EbizSpace.vue +185 -185
- package/src/views/EbizSwiper.vue +157 -157
- package/src/views/EbizTdesignButtonDialogExample.vue +437 -437
- package/src/views/Form.vue +19 -19
- package/src/views/GridDemo.vue +238 -238
- package/src/views/Home.vue +146 -146
- package/src/views/Mindmap.vue +17 -17
- package/src/views/MyComponent.vue +19 -19
- package/src/views/OkrTree.vue +19 -19
- package/src/views/PageHeaderDemo.vue +104 -104
- package/src/views/PaginationDemo.vue +96 -96
- package/src/views/PermissionBoxDemo.vue +85 -85
- package/src/views/PopconfirmDemo.vue +80 -80
- package/src/views/RemoteSelect.vue +350 -350
- package/src/views/StatisticDemo.vue +190 -190
- package/src/views/SwitchDemo.vue +79 -79
- package/src/views/Table.vue +19 -19
- package/src/views/TableDemo.vue +334 -334
- package/src/views/TableSortDemo.vue +143 -143
- package/src/views/TableView.vue +68 -68
- package/src/views/TabsDemo.vue +282 -282
- package/src/views/TagDemo.vue +101 -101
- package/src/views/TdesignAlert.vue +98 -98
- package/src/views/TdesignButton.vue +190 -190
- package/src/views/TdesignCalendar.vue +94 -94
- package/src/views/TdesignCard.vue +296 -296
- package/src/views/TdesignCollapse.vue +293 -293
- package/src/views/TdesignDatePicker.vue +187 -187
- package/src/views/TdesignDescriptions.vue +101 -101
- package/src/views/TdesignForm.vue +248 -248
- package/src/views/TdesignIcon.vue +203 -203
- package/src/views/TdesignImage.vue +215 -215
- package/src/views/TdesignImageViewer.vue +198 -198
- package/src/views/TdesignInput.vue +252 -252
- package/src/views/TdesignSelect.vue +473 -473
- package/src/views/TdesignSwiper.vue +157 -157
- package/src/views/TextareaDemo.vue +93 -93
- package/src/views/TimePickerDemo.vue +146 -146
- package/src/views/TimelineDemo.vue +160 -160
- package/src/views/Title.vue +19 -19
- package/src/views/TreeDemo.vue +254 -254
- package/src/views/TreeMergeTableDemo.vue +239 -239
- package/src/views/TreeSelectorDemo.vue +245 -245
- package/src/views/UploadDemo.vue +121 -121
- package/src/views/VxeTableDemo.vue +279 -279
- package/src/views/WatermarkDemo.vue +85 -85
@@ -1,419 +1,419 @@
|
|
1
|
-
<template>
|
2
|
-
<div class="ebiz-tree-selector">
|
3
|
-
<div class="selected-items" v-if="modelValue && modelValue.length">
|
4
|
-
<div v-for="(item, index) in modelValue" :key="index" class="selected-item">
|
5
|
-
<span class="item-text">{{ item.label }}</span>
|
6
|
-
<span class="item-remove" @click="removeItem(index)">×</span>
|
7
|
-
</div>
|
8
|
-
</div>
|
9
|
-
<t-button @click="showDialog" variant="text" theme="primary" size="small"> 添加 </t-button>
|
10
|
-
|
11
|
-
<EbizDialog attach="body" :zIndex="10000" v-model:visible="dialogVisible" header="选择人员/部门" width="800px"
|
12
|
-
placement="center" confirmBtn="确定" cancelBtn="取消" @confirm="handleConfirm" @cancel="handleCancel"
|
13
|
-
@close="handleCancel">
|
14
|
-
<div class="selector-container">
|
15
|
-
<!-- 左侧选择区域 -->
|
16
|
-
<div class="left-panel">
|
17
|
-
<!-- 顶部搜索区域 -->
|
18
|
-
<div class="search-box">
|
19
|
-
<t-input v-model="searchText" placeholder="搜索成员、部门或标签" clearable>
|
20
|
-
<template #suffix-icon>
|
21
|
-
<t-icon name="search"></t-icon>
|
22
|
-
</template>
|
23
|
-
</t-input>
|
24
|
-
</div>
|
25
|
-
|
26
|
-
<!-- 选项卡 -->
|
27
|
-
<t-tabs v-model="activeTab" class="selector-tabs">
|
28
|
-
<t-tab-panel value="organization" label="组织架构" :destroyOnHide="false">
|
29
|
-
|
30
|
-
</t-tab-panel>
|
31
|
-
<!-- <t-tab-panel value="department" label="部门"></t-tab-panel> -->
|
32
|
-
<!-- <t-tab-panel value="position" label="岗位"></t-tab-panel> -->
|
33
|
-
<t-tab-panel value="employee" label="员工"></t-tab-panel>
|
34
|
-
</t-tabs>
|
35
|
-
|
36
|
-
<!-- 树形结构区域 -->
|
37
|
-
<div class="tree-content">
|
38
|
-
<div v-if="loading" class="loading-container">
|
39
|
-
<t-loading />
|
40
|
-
</div>
|
41
|
-
<EbizTree ref="organizationTree" v-show="activeTab === 'organization'" checkable :items="organizationData"
|
42
|
-
v-model="checkedNodes" v-model:expanded="expandedNodes" :disable-check="disableCheck"
|
43
|
-
:keys="{ label: 'name', value: 'id', children: 'childs' }" />
|
44
|
-
<!-- <EbizTree
|
45
|
-
v-else-if="activeTab === 'department'"
|
46
|
-
checkable
|
47
|
-
:items="filteredData."
|
48
|
-
v-model="checkedNodes"
|
49
|
-
:disable-check="disableCheck"
|
50
|
-
/>
|
51
|
-
<EbizTree
|
52
|
-
v-else-if="activeTab === 'position'"
|
53
|
-
checkable
|
54
|
-
:items="filteredData.position"
|
55
|
-
v-model="checkedNodes"
|
56
|
-
:disable-check="disableCheck"
|
57
|
-
/> -->
|
58
|
-
<EbizTree ref="employeeTree" v-show="activeTab === 'employee'" checkable :items="employeeData"
|
59
|
-
:keys="{ label: 'label', value: 'bindid', children: 'childs' }" v-model="checkedUserNodes"
|
60
|
-
:disable-check="disableCheck" />
|
61
|
-
</div>
|
62
|
-
</div>
|
63
|
-
|
64
|
-
<!-- 右侧已选区域 -->
|
65
|
-
<div class="right-panel">
|
66
|
-
<div class="selected-title">已选择的部门、成员</div>
|
67
|
-
<div class="selected-count">共 {{ [...selectPreview, ...selectPreviewUser].length }} 项</div>
|
68
|
-
<div class="selected-list">
|
69
|
-
<div v-for="(item, index) in [...selectPreview,...selectPreviewUser]" :key="index"
|
70
|
-
class="selected-list-item">
|
71
|
-
<t-icon :name="getIconForType(item)" class="item-icon" />
|
72
|
-
<span class="selected-label">{{ item.label }}</span>
|
73
|
-
<t-icon name="close-circle" class="remove-icon" @click="removePreviewItem(item)" />
|
74
|
-
</div>
|
75
|
-
<div v-if="[...selectPreview, ...selectPreviewUser].length === 0" class="no-selection">
|
76
|
-
<t-icon name="info-circle" />
|
77
|
-
<span style="user-select: none">请在左侧选择部门或成员</span>
|
78
|
-
</div>
|
79
|
-
</div>
|
80
|
-
</div>
|
81
|
-
</div>
|
82
|
-
</EbizDialog>
|
83
|
-
</div>
|
84
|
-
</template>
|
85
|
-
|
86
|
-
<script setup>
|
87
|
-
import { onMounted, ref, watch } from 'vue'
|
88
|
-
import {
|
89
|
-
Button as TButton,
|
90
|
-
Icon as TIcon,
|
91
|
-
Input as TInput,
|
92
|
-
Loading as TLoading,
|
93
|
-
TabPanel as TTabPanel,
|
94
|
-
Tabs as TTabs
|
95
|
-
} from 'tdesign-vue-next'
|
96
|
-
import EbizDialog from './TdesignDialog.vue'
|
97
|
-
import EbizTree from './EbizTree.vue'
|
98
|
-
import dataService from '../apiService/simpleDataService'
|
99
|
-
|
100
|
-
const props = defineProps({
|
101
|
-
// 选中的数据,支持v-model
|
102
|
-
modelValue: {
|
103
|
-
type: Array,
|
104
|
-
default: () => []
|
105
|
-
},
|
106
|
-
// 树形数据,可以是单个数组或分类对象
|
107
|
-
data: {
|
108
|
-
type: [Array, Object],
|
109
|
-
default: () => []
|
110
|
-
},
|
111
|
-
// 禁用选择的节点
|
112
|
-
disableCheck: {
|
113
|
-
type: Function,
|
114
|
-
default: null
|
115
|
-
},
|
116
|
-
// 标题
|
117
|
-
title: {
|
118
|
-
type: String,
|
119
|
-
default: '选择人员/部门'
|
120
|
-
}
|
121
|
-
})
|
122
|
-
|
123
|
-
const emit = defineEmits(['update:modelValue', 'change'])
|
124
|
-
|
125
|
-
// 弹窗显示状态
|
126
|
-
const dialogVisible = ref(false)
|
127
|
-
// 搜索文本
|
128
|
-
const searchText = ref('')
|
129
|
-
// 选中的节点
|
130
|
-
const checkedNodes = ref([])
|
131
|
-
const checkedUserNodes = ref([]);
|
132
|
-
// 展开的节点
|
133
|
-
const expandedNodes = ref([])
|
134
|
-
// 当前活动的选项卡
|
135
|
-
const activeTab = ref('organization')
|
136
|
-
// 弹窗内预览的选中项
|
137
|
-
const selectPreview = ref([])
|
138
|
-
const selectPreviewUser = ref([])
|
139
|
-
// 加载状态
|
140
|
-
const loading = ref(false)
|
141
|
-
// API返回的数据
|
142
|
-
const organizationData = ref([])
|
143
|
-
const employeeData = ref([])
|
144
|
-
const organizationTree = ref()
|
145
|
-
const employeeTree = ref()
|
146
|
-
|
147
|
-
// 获取API数据
|
148
|
-
const fetchApiData = async () => {
|
149
|
-
loading.value = true
|
150
|
-
try {
|
151
|
-
organizationData.value = await dataService.fetch(
|
152
|
-
{ keyWord: activeTab.value === 'organization' ? searchText.value : '' },
|
153
|
-
{},
|
154
|
-
'/appdata/execute/plugin?key=organizational_structure'
|
155
|
-
)
|
156
|
-
employeeData.value = (await dataService.fetch(
|
157
|
-
{postEnable:true, keyWord:activeTab.value === 'employee' ? searchText.value : ''},
|
158
|
-
{},
|
159
|
-
"/appdata/execute/plugin?key=all_active_employesse"
|
160
|
-
)).map(i=>({
|
161
|
-
label:i.name,
|
162
|
-
bindid:i.id,
|
163
|
-
type:'employee'
|
164
|
-
}))
|
165
|
-
} catch (error) {
|
166
|
-
} finally {
|
167
|
-
loading.value = false
|
168
|
-
}
|
169
|
-
}
|
170
|
-
|
171
|
-
// 根据类型获取对应图标
|
172
|
-
const getIconForType = (item) => {
|
173
|
-
const iconMap = {
|
174
|
-
GS: 'internet',
|
175
|
-
DEPT: 'folder',
|
176
|
-
GW: 'user-list',
|
177
|
-
employee: 'user'
|
178
|
-
}
|
179
|
-
return iconMap[item.type] || 'user'
|
180
|
-
}
|
181
|
-
|
182
|
-
// 显示对话框
|
183
|
-
function showDialog() {
|
184
|
-
// 获取API数据
|
185
|
-
fetchApiData()
|
186
|
-
// 重置选中的节点
|
187
|
-
checkedNodes.value = props.modelValue.filter(i => i.type !== 'employee').map((item) => item.bindid);
|
188
|
-
checkedUserNodes.value = props.modelValue.filter(i => i.type === 'employee').map((item) => item.bindid);
|
189
|
-
dialogVisible.value = true
|
190
|
-
}
|
191
|
-
|
192
|
-
// 确认选择
|
193
|
-
function handleConfirm() {
|
194
|
-
const finalValue = [...selectPreview.value.map((item) => ({
|
195
|
-
label: item.label,
|
196
|
-
bindid: item.bindid,
|
197
|
-
type: item.type
|
198
|
-
})), ...selectPreviewUser.value];
|
199
|
-
emit(
|
200
|
-
'update:modelValue', finalValue
|
201
|
-
)
|
202
|
-
emit('change', finalValue)
|
203
|
-
dialogVisible.value = false
|
204
|
-
}
|
205
|
-
|
206
|
-
// 取消选择
|
207
|
-
function handleCancel() {
|
208
|
-
dialogVisible.value = false
|
209
|
-
}
|
210
|
-
|
211
|
-
// 移除已选择预览中的项目
|
212
|
-
function removePreviewItem(item) {
|
213
|
-
const isUser = item.type == 'employee';
|
214
|
-
if(isUser){
|
215
|
-
let index = selectPreviewUser.value.findIndex(i=>i.bindid === item.bindid);
|
216
|
-
const removedUser = selectPreviewUser.value[index];
|
217
|
-
selectPreviewUser.value.splice(index,1);
|
218
|
-
checkedUserNodes.value = checkedUserNodes.value.filter((value) => value !== removedUser.bindid)
|
219
|
-
return
|
220
|
-
}
|
221
|
-
let index = selectPreview.value.findIndex(i => i.bindid === item.bindid);
|
222
|
-
const removedItem = selectPreview.value[index];
|
223
|
-
selectPreview.value.splice(index, 1)
|
224
|
-
checkedNodes.value = checkedNodes.value.filter((value) => value !== removedItem.bindid)
|
225
|
-
}
|
226
|
-
|
227
|
-
// 移除选中项
|
228
|
-
function removeItem(index) {
|
229
|
-
const newValue = [...props.modelValue]
|
230
|
-
newValue.splice(index, 1)
|
231
|
-
emit('update:modelValue', newValue)
|
232
|
-
emit('change', newValue)
|
233
|
-
}
|
234
|
-
|
235
|
-
// 监听选中节点变化,同步到预览
|
236
|
-
watch(
|
237
|
-
checkedNodes,
|
238
|
-
(newValues) => {
|
239
|
-
if (!organizationTree.value?.treeRef) return
|
240
|
-
selectPreview.value = (newValues.map(organizationTree.value.treeRef.getItem) ?? []).map((i) => ({
|
241
|
-
label: i?.label,
|
242
|
-
type: i?.data?.type || i?.type,
|
243
|
-
bindid: i?.value
|
244
|
-
}))
|
245
|
-
},
|
246
|
-
{ deep: true }
|
247
|
-
)
|
248
|
-
watch(checkedUserNodes,nVal=>{
|
249
|
-
selectPreviewUser.value = employeeData.value.filter(i=>nVal.includes(i.bindid))
|
250
|
-
},{deep:true})
|
251
|
-
// 监听modelValue变化,同步到选中节点
|
252
|
-
watch(
|
253
|
-
() => props.modelValue,
|
254
|
-
(newValue) => {
|
255
|
-
checkedNodes.value = newValue.filter(i=>i.type!=='employee').map((item) => item.bindid);
|
256
|
-
checkedUserNodes.value = newValue.filter(i => i.type === 'employee').map((item) => item.bindid);
|
257
|
-
console.log(newValue,checkedUserNodes.value,267)
|
258
|
-
},
|
259
|
-
{ deep: true ,immediate:true}
|
260
|
-
)
|
261
|
-
watch(activeTab,nVal=>{
|
262
|
-
searchText.value = ''
|
263
|
-
})
|
264
|
-
watch(searchText,nVal=>{
|
265
|
-
fetchApiData()
|
266
|
-
})
|
267
|
-
</script>
|
268
|
-
|
269
|
-
<style scoped>
|
270
|
-
.ebiz-tree-selector {
|
271
|
-
display: flex;
|
272
|
-
flex-wrap: wrap;
|
273
|
-
align-items: center;
|
274
|
-
gap: 8px;
|
275
|
-
min-height: 32px;
|
276
|
-
}
|
277
|
-
|
278
|
-
.selected-items {
|
279
|
-
display: flex;
|
280
|
-
flex-wrap: wrap;
|
281
|
-
gap: 4px;
|
282
|
-
}
|
283
|
-
|
284
|
-
.selected-item {
|
285
|
-
display: flex;
|
286
|
-
align-items: center;
|
287
|
-
padding: 4px 8px;
|
288
|
-
background-color: #f0f0f0;
|
289
|
-
border-radius: 4px;
|
290
|
-
font-size: 14px;
|
291
|
-
}
|
292
|
-
|
293
|
-
.item-text {
|
294
|
-
margin-right: 4px;
|
295
|
-
}
|
296
|
-
|
297
|
-
.item-remove {
|
298
|
-
cursor: pointer;
|
299
|
-
color: #999;
|
300
|
-
font-size: 16px;
|
301
|
-
}
|
302
|
-
|
303
|
-
.item-remove:hover {
|
304
|
-
color: #ff4d4f;
|
305
|
-
}
|
306
|
-
|
307
|
-
.add-button {
|
308
|
-
display: flex;
|
309
|
-
align-items: center;
|
310
|
-
}
|
311
|
-
|
312
|
-
.selector-container {
|
313
|
-
display: flex;
|
314
|
-
height: 500px;
|
315
|
-
}
|
316
|
-
|
317
|
-
.left-panel {
|
318
|
-
flex: 1;
|
319
|
-
display: flex;
|
320
|
-
flex-direction: column;
|
321
|
-
border-right: 1px solid #e0e0e0;
|
322
|
-
padding-right: 16px;
|
323
|
-
}
|
324
|
-
|
325
|
-
.right-panel {
|
326
|
-
width: 280px;
|
327
|
-
display: flex;
|
328
|
-
flex-direction: column;
|
329
|
-
padding-left: 16px;
|
330
|
-
}
|
331
|
-
|
332
|
-
.search-box {
|
333
|
-
margin-bottom: 12px;
|
334
|
-
}
|
335
|
-
|
336
|
-
.selector-tabs {
|
337
|
-
margin-bottom: 12px;
|
338
|
-
}
|
339
|
-
|
340
|
-
.tree-content {
|
341
|
-
flex: 1;
|
342
|
-
overflow: auto;
|
343
|
-
border: 1px solid #e0e0e0;
|
344
|
-
border-radius: 4px;
|
345
|
-
padding: 12px;
|
346
|
-
position: relative;
|
347
|
-
}
|
348
|
-
|
349
|
-
.loading-container {
|
350
|
-
position: absolute;
|
351
|
-
top: 0;
|
352
|
-
left: 0;
|
353
|
-
right: 0;
|
354
|
-
bottom: 0;
|
355
|
-
display: flex;
|
356
|
-
align-items: center;
|
357
|
-
justify-content: center;
|
358
|
-
background-color: rgba(255, 255, 255, 0.7);
|
359
|
-
}
|
360
|
-
|
361
|
-
.selected-title {
|
362
|
-
font-weight: bold;
|
363
|
-
margin-bottom: 8px;
|
364
|
-
}
|
365
|
-
|
366
|
-
.selected-count {
|
367
|
-
color: #999;
|
368
|
-
font-size: 12px;
|
369
|
-
margin-bottom: 12px;
|
370
|
-
}
|
371
|
-
|
372
|
-
.selected-list {
|
373
|
-
flex: 1;
|
374
|
-
overflow: auto;
|
375
|
-
border: 1px solid #e0e0e0;
|
376
|
-
border-radius: 4px;
|
377
|
-
padding: 8px;
|
378
|
-
}
|
379
|
-
|
380
|
-
.selected-list-item {
|
381
|
-
display: flex;
|
382
|
-
align-items: center;
|
383
|
-
padding: 8px;
|
384
|
-
border-bottom: 1px solid #f0f0f0;
|
385
|
-
}
|
386
|
-
|
387
|
-
.selected-list-item:last-child {
|
388
|
-
border-bottom: none;
|
389
|
-
}
|
390
|
-
|
391
|
-
.item-icon {
|
392
|
-
color: #0052d9;
|
393
|
-
margin-right: 8px;
|
394
|
-
}
|
395
|
-
|
396
|
-
.selected-label {
|
397
|
-
flex: 1;
|
398
|
-
user-select: none;
|
399
|
-
}
|
400
|
-
|
401
|
-
.remove-icon {
|
402
|
-
color: #999;
|
403
|
-
cursor: pointer;
|
404
|
-
}
|
405
|
-
|
406
|
-
.remove-icon:hover {
|
407
|
-
color: #ff4d4f;
|
408
|
-
}
|
409
|
-
|
410
|
-
.no-selection {
|
411
|
-
display: flex;
|
412
|
-
flex-direction: column;
|
413
|
-
align-items: center;
|
414
|
-
justify-content: center;
|
415
|
-
height: 100%;
|
416
|
-
color: #999;
|
417
|
-
gap: 8px;
|
418
|
-
}
|
1
|
+
<template>
|
2
|
+
<div class="ebiz-tree-selector">
|
3
|
+
<div class="selected-items" v-if="modelValue && modelValue.length">
|
4
|
+
<div v-for="(item, index) in modelValue" :key="index" class="selected-item">
|
5
|
+
<span class="item-text">{{ item.label }}</span>
|
6
|
+
<span class="item-remove" @click="removeItem(index)">×</span>
|
7
|
+
</div>
|
8
|
+
</div>
|
9
|
+
<t-button @click="showDialog" variant="text" theme="primary" size="small"> 添加 </t-button>
|
10
|
+
|
11
|
+
<EbizDialog attach="body" :zIndex="10000" v-model:visible="dialogVisible" header="选择人员/部门" width="800px"
|
12
|
+
placement="center" confirmBtn="确定" cancelBtn="取消" @confirm="handleConfirm" @cancel="handleCancel"
|
13
|
+
@close="handleCancel">
|
14
|
+
<div class="selector-container">
|
15
|
+
<!-- 左侧选择区域 -->
|
16
|
+
<div class="left-panel">
|
17
|
+
<!-- 顶部搜索区域 -->
|
18
|
+
<div class="search-box">
|
19
|
+
<t-input v-model="searchText" placeholder="搜索成员、部门或标签" clearable>
|
20
|
+
<template #suffix-icon>
|
21
|
+
<t-icon name="search"></t-icon>
|
22
|
+
</template>
|
23
|
+
</t-input>
|
24
|
+
</div>
|
25
|
+
|
26
|
+
<!-- 选项卡 -->
|
27
|
+
<t-tabs v-model="activeTab" class="selector-tabs">
|
28
|
+
<t-tab-panel value="organization" label="组织架构" :destroyOnHide="false">
|
29
|
+
|
30
|
+
</t-tab-panel>
|
31
|
+
<!-- <t-tab-panel value="department" label="部门"></t-tab-panel> -->
|
32
|
+
<!-- <t-tab-panel value="position" label="岗位"></t-tab-panel> -->
|
33
|
+
<t-tab-panel value="employee" label="员工"></t-tab-panel>
|
34
|
+
</t-tabs>
|
35
|
+
|
36
|
+
<!-- 树形结构区域 -->
|
37
|
+
<div class="tree-content">
|
38
|
+
<div v-if="loading" class="loading-container">
|
39
|
+
<t-loading />
|
40
|
+
</div>
|
41
|
+
<EbizTree ref="organizationTree" v-show="activeTab === 'organization'" checkable :items="organizationData"
|
42
|
+
v-model="checkedNodes" v-model:expanded="expandedNodes" :disable-check="disableCheck"
|
43
|
+
:keys="{ label: 'name', value: 'id', children: 'childs' }" />
|
44
|
+
<!-- <EbizTree
|
45
|
+
v-else-if="activeTab === 'department'"
|
46
|
+
checkable
|
47
|
+
:items="filteredData."
|
48
|
+
v-model="checkedNodes"
|
49
|
+
:disable-check="disableCheck"
|
50
|
+
/>
|
51
|
+
<EbizTree
|
52
|
+
v-else-if="activeTab === 'position'"
|
53
|
+
checkable
|
54
|
+
:items="filteredData.position"
|
55
|
+
v-model="checkedNodes"
|
56
|
+
:disable-check="disableCheck"
|
57
|
+
/> -->
|
58
|
+
<EbizTree ref="employeeTree" v-show="activeTab === 'employee'" checkable :items="employeeData"
|
59
|
+
:keys="{ label: 'label', value: 'bindid', children: 'childs' }" v-model="checkedUserNodes"
|
60
|
+
:disable-check="disableCheck" />
|
61
|
+
</div>
|
62
|
+
</div>
|
63
|
+
|
64
|
+
<!-- 右侧已选区域 -->
|
65
|
+
<div class="right-panel">
|
66
|
+
<div class="selected-title">已选择的部门、成员</div>
|
67
|
+
<div class="selected-count">共 {{ [...selectPreview, ...selectPreviewUser].length }} 项</div>
|
68
|
+
<div class="selected-list">
|
69
|
+
<div v-for="(item, index) in [...selectPreview,...selectPreviewUser]" :key="index"
|
70
|
+
class="selected-list-item">
|
71
|
+
<t-icon :name="getIconForType(item)" class="item-icon" />
|
72
|
+
<span class="selected-label">{{ item.label }}</span>
|
73
|
+
<t-icon name="close-circle" class="remove-icon" @click="removePreviewItem(item)" />
|
74
|
+
</div>
|
75
|
+
<div v-if="[...selectPreview, ...selectPreviewUser].length === 0" class="no-selection">
|
76
|
+
<t-icon name="info-circle" />
|
77
|
+
<span style="user-select: none">请在左侧选择部门或成员</span>
|
78
|
+
</div>
|
79
|
+
</div>
|
80
|
+
</div>
|
81
|
+
</div>
|
82
|
+
</EbizDialog>
|
83
|
+
</div>
|
84
|
+
</template>
|
85
|
+
|
86
|
+
<script setup>
|
87
|
+
import { onMounted, ref, watch } from 'vue'
|
88
|
+
import {
|
89
|
+
Button as TButton,
|
90
|
+
Icon as TIcon,
|
91
|
+
Input as TInput,
|
92
|
+
Loading as TLoading,
|
93
|
+
TabPanel as TTabPanel,
|
94
|
+
Tabs as TTabs
|
95
|
+
} from 'tdesign-vue-next'
|
96
|
+
import EbizDialog from './TdesignDialog.vue'
|
97
|
+
import EbizTree from './EbizTree.vue'
|
98
|
+
import dataService from '../apiService/simpleDataService'
|
99
|
+
|
100
|
+
const props = defineProps({
|
101
|
+
// 选中的数据,支持v-model
|
102
|
+
modelValue: {
|
103
|
+
type: Array,
|
104
|
+
default: () => []
|
105
|
+
},
|
106
|
+
// 树形数据,可以是单个数组或分类对象
|
107
|
+
data: {
|
108
|
+
type: [Array, Object],
|
109
|
+
default: () => []
|
110
|
+
},
|
111
|
+
// 禁用选择的节点
|
112
|
+
disableCheck: {
|
113
|
+
type: Function,
|
114
|
+
default: null
|
115
|
+
},
|
116
|
+
// 标题
|
117
|
+
title: {
|
118
|
+
type: String,
|
119
|
+
default: '选择人员/部门'
|
120
|
+
}
|
121
|
+
})
|
122
|
+
|
123
|
+
const emit = defineEmits(['update:modelValue', 'change'])
|
124
|
+
|
125
|
+
// 弹窗显示状态
|
126
|
+
const dialogVisible = ref(false)
|
127
|
+
// 搜索文本
|
128
|
+
const searchText = ref('')
|
129
|
+
// 选中的节点
|
130
|
+
const checkedNodes = ref([])
|
131
|
+
const checkedUserNodes = ref([]);
|
132
|
+
// 展开的节点
|
133
|
+
const expandedNodes = ref([])
|
134
|
+
// 当前活动的选项卡
|
135
|
+
const activeTab = ref('organization')
|
136
|
+
// 弹窗内预览的选中项
|
137
|
+
const selectPreview = ref([])
|
138
|
+
const selectPreviewUser = ref([])
|
139
|
+
// 加载状态
|
140
|
+
const loading = ref(false)
|
141
|
+
// API返回的数据
|
142
|
+
const organizationData = ref([])
|
143
|
+
const employeeData = ref([])
|
144
|
+
const organizationTree = ref()
|
145
|
+
const employeeTree = ref()
|
146
|
+
|
147
|
+
// 获取API数据
|
148
|
+
const fetchApiData = async () => {
|
149
|
+
loading.value = true
|
150
|
+
try {
|
151
|
+
organizationData.value = await dataService.fetch(
|
152
|
+
{ keyWord: activeTab.value === 'organization' ? searchText.value : '' },
|
153
|
+
{},
|
154
|
+
'/appdata/execute/plugin?key=organizational_structure'
|
155
|
+
)
|
156
|
+
employeeData.value = (await dataService.fetch(
|
157
|
+
{postEnable:true, keyWord:activeTab.value === 'employee' ? searchText.value : ''},
|
158
|
+
{},
|
159
|
+
"/appdata/execute/plugin?key=all_active_employesse"
|
160
|
+
)).map(i=>({
|
161
|
+
label:i.name,
|
162
|
+
bindid:i.id,
|
163
|
+
type:'employee'
|
164
|
+
}))
|
165
|
+
} catch (error) {
|
166
|
+
} finally {
|
167
|
+
loading.value = false
|
168
|
+
}
|
169
|
+
}
|
170
|
+
|
171
|
+
// 根据类型获取对应图标
|
172
|
+
const getIconForType = (item) => {
|
173
|
+
const iconMap = {
|
174
|
+
GS: 'internet',
|
175
|
+
DEPT: 'folder',
|
176
|
+
GW: 'user-list',
|
177
|
+
employee: 'user'
|
178
|
+
}
|
179
|
+
return iconMap[item.type] || 'user'
|
180
|
+
}
|
181
|
+
|
182
|
+
// 显示对话框
|
183
|
+
function showDialog() {
|
184
|
+
// 获取API数据
|
185
|
+
fetchApiData()
|
186
|
+
// 重置选中的节点
|
187
|
+
checkedNodes.value = props.modelValue.filter(i => i.type !== 'employee').map((item) => item.bindid);
|
188
|
+
checkedUserNodes.value = props.modelValue.filter(i => i.type === 'employee').map((item) => item.bindid);
|
189
|
+
dialogVisible.value = true
|
190
|
+
}
|
191
|
+
|
192
|
+
// 确认选择
|
193
|
+
function handleConfirm() {
|
194
|
+
const finalValue = [...selectPreview.value.map((item) => ({
|
195
|
+
label: item.label,
|
196
|
+
bindid: item.bindid,
|
197
|
+
type: item.type
|
198
|
+
})), ...selectPreviewUser.value];
|
199
|
+
emit(
|
200
|
+
'update:modelValue', finalValue
|
201
|
+
)
|
202
|
+
emit('change', finalValue)
|
203
|
+
dialogVisible.value = false
|
204
|
+
}
|
205
|
+
|
206
|
+
// 取消选择
|
207
|
+
function handleCancel() {
|
208
|
+
dialogVisible.value = false
|
209
|
+
}
|
210
|
+
|
211
|
+
// 移除已选择预览中的项目
|
212
|
+
function removePreviewItem(item) {
|
213
|
+
const isUser = item.type == 'employee';
|
214
|
+
if(isUser){
|
215
|
+
let index = selectPreviewUser.value.findIndex(i=>i.bindid === item.bindid);
|
216
|
+
const removedUser = selectPreviewUser.value[index];
|
217
|
+
selectPreviewUser.value.splice(index,1);
|
218
|
+
checkedUserNodes.value = checkedUserNodes.value.filter((value) => value !== removedUser.bindid)
|
219
|
+
return
|
220
|
+
}
|
221
|
+
let index = selectPreview.value.findIndex(i => i.bindid === item.bindid);
|
222
|
+
const removedItem = selectPreview.value[index];
|
223
|
+
selectPreview.value.splice(index, 1)
|
224
|
+
checkedNodes.value = checkedNodes.value.filter((value) => value !== removedItem.bindid)
|
225
|
+
}
|
226
|
+
|
227
|
+
// 移除选中项
|
228
|
+
function removeItem(index) {
|
229
|
+
const newValue = [...props.modelValue]
|
230
|
+
newValue.splice(index, 1)
|
231
|
+
emit('update:modelValue', newValue)
|
232
|
+
emit('change', newValue)
|
233
|
+
}
|
234
|
+
|
235
|
+
// 监听选中节点变化,同步到预览
|
236
|
+
watch(
|
237
|
+
checkedNodes,
|
238
|
+
(newValues) => {
|
239
|
+
if (!organizationTree.value?.treeRef) return
|
240
|
+
selectPreview.value = (newValues.map(organizationTree.value.treeRef.getItem) ?? []).map((i) => ({
|
241
|
+
label: i?.label,
|
242
|
+
type: i?.data?.type || i?.type,
|
243
|
+
bindid: i?.value
|
244
|
+
}))
|
245
|
+
},
|
246
|
+
{ deep: true }
|
247
|
+
)
|
248
|
+
watch(checkedUserNodes,nVal=>{
|
249
|
+
selectPreviewUser.value = employeeData.value.filter(i=>nVal.includes(i.bindid))
|
250
|
+
},{deep:true})
|
251
|
+
// 监听modelValue变化,同步到选中节点
|
252
|
+
watch(
|
253
|
+
() => props.modelValue,
|
254
|
+
(newValue) => {
|
255
|
+
checkedNodes.value = newValue.filter(i=>i.type!=='employee').map((item) => item.bindid);
|
256
|
+
checkedUserNodes.value = newValue.filter(i => i.type === 'employee').map((item) => item.bindid);
|
257
|
+
console.log(newValue,checkedUserNodes.value,267)
|
258
|
+
},
|
259
|
+
{ deep: true ,immediate:true}
|
260
|
+
)
|
261
|
+
watch(activeTab,nVal=>{
|
262
|
+
searchText.value = ''
|
263
|
+
})
|
264
|
+
watch(searchText,nVal=>{
|
265
|
+
fetchApiData()
|
266
|
+
})
|
267
|
+
</script>
|
268
|
+
|
269
|
+
<style scoped>
|
270
|
+
.ebiz-tree-selector {
|
271
|
+
display: flex;
|
272
|
+
flex-wrap: wrap;
|
273
|
+
align-items: center;
|
274
|
+
gap: 8px;
|
275
|
+
min-height: 32px;
|
276
|
+
}
|
277
|
+
|
278
|
+
.selected-items {
|
279
|
+
display: flex;
|
280
|
+
flex-wrap: wrap;
|
281
|
+
gap: 4px;
|
282
|
+
}
|
283
|
+
|
284
|
+
.selected-item {
|
285
|
+
display: flex;
|
286
|
+
align-items: center;
|
287
|
+
padding: 4px 8px;
|
288
|
+
background-color: #f0f0f0;
|
289
|
+
border-radius: 4px;
|
290
|
+
font-size: 14px;
|
291
|
+
}
|
292
|
+
|
293
|
+
.item-text {
|
294
|
+
margin-right: 4px;
|
295
|
+
}
|
296
|
+
|
297
|
+
.item-remove {
|
298
|
+
cursor: pointer;
|
299
|
+
color: #999;
|
300
|
+
font-size: 16px;
|
301
|
+
}
|
302
|
+
|
303
|
+
.item-remove:hover {
|
304
|
+
color: #ff4d4f;
|
305
|
+
}
|
306
|
+
|
307
|
+
.add-button {
|
308
|
+
display: flex;
|
309
|
+
align-items: center;
|
310
|
+
}
|
311
|
+
|
312
|
+
.selector-container {
|
313
|
+
display: flex;
|
314
|
+
height: 500px;
|
315
|
+
}
|
316
|
+
|
317
|
+
.left-panel {
|
318
|
+
flex: 1;
|
319
|
+
display: flex;
|
320
|
+
flex-direction: column;
|
321
|
+
border-right: 1px solid #e0e0e0;
|
322
|
+
padding-right: 16px;
|
323
|
+
}
|
324
|
+
|
325
|
+
.right-panel {
|
326
|
+
width: 280px;
|
327
|
+
display: flex;
|
328
|
+
flex-direction: column;
|
329
|
+
padding-left: 16px;
|
330
|
+
}
|
331
|
+
|
332
|
+
.search-box {
|
333
|
+
margin-bottom: 12px;
|
334
|
+
}
|
335
|
+
|
336
|
+
.selector-tabs {
|
337
|
+
margin-bottom: 12px;
|
338
|
+
}
|
339
|
+
|
340
|
+
.tree-content {
|
341
|
+
flex: 1;
|
342
|
+
overflow: auto;
|
343
|
+
border: 1px solid #e0e0e0;
|
344
|
+
border-radius: 4px;
|
345
|
+
padding: 12px;
|
346
|
+
position: relative;
|
347
|
+
}
|
348
|
+
|
349
|
+
.loading-container {
|
350
|
+
position: absolute;
|
351
|
+
top: 0;
|
352
|
+
left: 0;
|
353
|
+
right: 0;
|
354
|
+
bottom: 0;
|
355
|
+
display: flex;
|
356
|
+
align-items: center;
|
357
|
+
justify-content: center;
|
358
|
+
background-color: rgba(255, 255, 255, 0.7);
|
359
|
+
}
|
360
|
+
|
361
|
+
.selected-title {
|
362
|
+
font-weight: bold;
|
363
|
+
margin-bottom: 8px;
|
364
|
+
}
|
365
|
+
|
366
|
+
.selected-count {
|
367
|
+
color: #999;
|
368
|
+
font-size: 12px;
|
369
|
+
margin-bottom: 12px;
|
370
|
+
}
|
371
|
+
|
372
|
+
.selected-list {
|
373
|
+
flex: 1;
|
374
|
+
overflow: auto;
|
375
|
+
border: 1px solid #e0e0e0;
|
376
|
+
border-radius: 4px;
|
377
|
+
padding: 8px;
|
378
|
+
}
|
379
|
+
|
380
|
+
.selected-list-item {
|
381
|
+
display: flex;
|
382
|
+
align-items: center;
|
383
|
+
padding: 8px;
|
384
|
+
border-bottom: 1px solid #f0f0f0;
|
385
|
+
}
|
386
|
+
|
387
|
+
.selected-list-item:last-child {
|
388
|
+
border-bottom: none;
|
389
|
+
}
|
390
|
+
|
391
|
+
.item-icon {
|
392
|
+
color: #0052d9;
|
393
|
+
margin-right: 8px;
|
394
|
+
}
|
395
|
+
|
396
|
+
.selected-label {
|
397
|
+
flex: 1;
|
398
|
+
user-select: none;
|
399
|
+
}
|
400
|
+
|
401
|
+
.remove-icon {
|
402
|
+
color: #999;
|
403
|
+
cursor: pointer;
|
404
|
+
}
|
405
|
+
|
406
|
+
.remove-icon:hover {
|
407
|
+
color: #ff4d4f;
|
408
|
+
}
|
409
|
+
|
410
|
+
.no-selection {
|
411
|
+
display: flex;
|
412
|
+
flex-direction: column;
|
413
|
+
align-items: center;
|
414
|
+
justify-content: center;
|
415
|
+
height: 100%;
|
416
|
+
color: #999;
|
417
|
+
gap: 8px;
|
418
|
+
}
|
419
419
|
</style>
|