npmapps 1.0.21 → 1.0.23
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/app/Wscats.vue-1.0.26.vsix +0 -0
- package/app/febean.vue-format-0.1.8.vsix +0 -0
- package/app/wujie-vue3-child/.claude/settings.local.json +8 -0
- package/app/wujie-vue3-child/.vscode/extensions.json +3 -0
- package/app/wujie-vue3-child/PROJECT_MEMORY.md +427 -0
- package/app/wujie-vue3-child/README.md +5 -0
- package/app/wujie-vue3-child/index.html +13 -0
- package/app/wujie-vue3-child/package-lock.json +5744 -0
- package/app/wujie-vue3-child/package.json +28 -0
- package/app/wujie-vue3-child/public/vite.svg +1 -0
- package/app/wujie-vue3-child/src/App.vue +130 -0
- package/app/wujie-vue3-child/src/assets/vue.svg +1 -0
- package/app/wujie-vue3-child/src/components/HelloWorld.vue +43 -0
- package/app/wujie-vue3-child/src/components/tags-view.vue +193 -0
- package/app/wujie-vue3-child/src/components/tags-view1.vue +131 -0
- package/app/wujie-vue3-child/src/hooks/useClickOutside.js +11 -0
- package/app/wujie-vue3-child/src/hooks/useTableDragSort.js +28 -0
- package/app/wujie-vue3-child/src/main.js +15 -0
- package/app/wujie-vue3-child/src/router/index.js +104 -0
- package/app/wujie-vue3-child/src/store/tagsViewStroe.js +34 -0
- package/app/wujie-vue3-child/src/style.css +4 -0
- package/app/wujie-vue3-child/src/views/aiCoach/departmentPersonnel/README.md +836 -0
- package/app/wujie-vue3-child/src/views/aiCoach/departmentPersonnel/REFLEX_EXAMPLES.md +728 -0
- package/app/wujie-vue3-child/src/views/aiCoach/departmentPersonnel/components/DepartmentPersonnelSelector.jsx +687 -0
- package/app/wujie-vue3-child/src/views/aiCoach/departmentPersonnel/components/DepartmentPersonnelSelector.module.scss +560 -0
- package/app/wujie-vue3-child/src/views/aiCoach/departmentPersonnel/components/DepartmentSelector.jsx +570 -0
- package/app/wujie-vue3-child/src/views/aiCoach/departmentPersonnel/components/DepartmentSelector.module.scss +330 -0
- package/app/wujie-vue3-child/src/views/aiCoach/departmentPersonnel/components/DepartmentSelectorV2.jsx +378 -0
- package/app/wujie-vue3-child/src/views/aiCoach/departmentPersonnel/components/DepartmentSelectorV2.module.scss +228 -0
- package/app/wujie-vue3-child/src/views/aiCoach/departmentPersonnel/components/OptionsSelector.jsx +399 -0
- package/app/wujie-vue3-child/src/views/aiCoach/departmentPersonnel/components/OptionsSelector.module.scss +252 -0
- package/app/wujie-vue3-child/src/views/aiCoach/departmentPersonnel/components/PersonnelSelector.jsx +585 -0
- package/app/wujie-vue3-child/src/views/aiCoach/departmentPersonnel/components/PersonnelSelector.module.scss +331 -0
- package/app/wujie-vue3-child/src/views/aiCoach/departmentPersonnel/components/PopoverSelector.jsx +392 -0
- package/app/wujie-vue3-child/src/views/aiCoach/departmentPersonnel/components/PopoverSelector.module.scss +39 -0
- package/app/wujie-vue3-child/src/views/aiCoach/departmentPersonnel/components/README.md +248 -0
- package/app/wujie-vue3-child/src/views/aiCoach/departmentPersonnel/components/SelectorTrigger.jsx +194 -0
- package/app/wujie-vue3-child/src/views/aiCoach/departmentPersonnel/index.jsx +1459 -0
- package/app/wujie-vue3-child/src/views/aiCoach/departmentPersonnel/mockData.js +301 -0
- package/app/{aiCoach → wujie-vue3-child/src/views/aiCoach}/dialogueSegment/index.jsx +28 -4
- package/app/wujie-vue3-child/src/views/aiCoach/index.jsx +32 -0
- package/app/wujie-vue3-child/src/views/aiCoach/practiceStatus/components/ChartsPanel/index.jsx +121 -0
- package/app/wujie-vue3-child/src/views/aiCoach/practiceStatus/components/ChartsPanel/index.module.scss +76 -0
- package/app/wujie-vue3-child/src/views/aiCoach/practiceStatus/components/DonutChart/index.jsx +104 -0
- package/app/wujie-vue3-child/src/views/aiCoach/practiceStatus/components/PracticeTable/index.jsx +75 -0
- package/app/wujie-vue3-child/src/views/aiCoach/practiceStatus/components/PracticeTable/index.module.scss +12 -0
- package/app/wujie-vue3-child/src/views/aiCoach/practiceStatus/components/RankBarChart/index.jsx +62 -0
- package/app/wujie-vue3-child/src/views/aiCoach/practiceStatus/components/RankBarChart/index.module.scss +43 -0
- package/app/wujie-vue3-child/src/views/aiCoach/practiceStatus/components/RankingGroup/index.jsx +29 -0
- package/app/wujie-vue3-child/src/views/aiCoach/practiceStatus/components/RankingGroup/index.module.scss +5 -0
- package/app/wujie-vue3-child/src/views/aiCoach/practiceStatus/components/RankingList/index.jsx +58 -0
- package/app/wujie-vue3-child/src/views/aiCoach/practiceStatus/components/RankingList/index.module.scss +85 -0
- package/app/wujie-vue3-child/src/views/aiCoach/practiceStatus/components/ScriptStatsPanel/index.jsx +92 -0
- package/app/wujie-vue3-child/src/views/aiCoach/practiceStatus/components/ScriptStatsPanel/index.module.scss +56 -0
- package/app/wujie-vue3-child/src/views/aiCoach/practiceStatus/components/StatCardsRow/index.jsx +40 -0
- package/app/wujie-vue3-child/src/views/aiCoach/practiceStatus/components/StatCardsRow/index.module.scss +53 -0
- package/app/wujie-vue3-child/src/views/aiCoach/practiceStatus/components/echarts/EchartsDonut.jsx +106 -0
- package/app/wujie-vue3-child/src/views/aiCoach/practiceStatus/components/echarts/EchartsRankBar.jsx +132 -0
- package/app/wujie-vue3-child/src/views/aiCoach/practiceStatus/index.jsx +176 -0
- package/app/wujie-vue3-child/src/views/aiCoach/practiceStatus/index.module.scss +96 -0
- package/app/wujie-vue3-child/src/views/aiCoach/reportDetail/components/CoachReport/index.jsx +162 -0
- package/app/wujie-vue3-child/src/views/aiCoach/reportDetail/components/CoachReport/index.module.scss +16 -0
- package/app/wujie-vue3-child/src/views/aiCoach/reportDetail/components/ComprehensiveEvaluation/index.jsx +29 -0
- package/app/wujie-vue3-child/src/views/aiCoach/reportDetail/components/ComprehensiveEvaluation/index.module.scss +25 -0
- package/app/wujie-vue3-child/src/views/aiCoach/reportDetail/components/DialogueBubble/index.jsx +106 -0
- package/app/wujie-vue3-child/src/views/aiCoach/reportDetail/components/DialogueBubble/index.module.scss +164 -0
- package/app/wujie-vue3-child/src/views/aiCoach/reportDetail/components/DialogueRecord/index.jsx +182 -0
- package/app/wujie-vue3-child/src/views/aiCoach/reportDetail/components/DialogueRecord/index.module.scss +203 -0
- package/app/wujie-vue3-child/src/views/aiCoach/reportDetail/components/DimensionDetail/index.jsx +145 -0
- package/app/wujie-vue3-child/src/views/aiCoach/reportDetail/components/DimensionDetail/index.module.scss +126 -0
- package/app/wujie-vue3-child/src/views/aiCoach/reportDetail/components/DimensionScores/index.jsx +67 -0
- package/app/wujie-vue3-child/src/views/aiCoach/reportDetail/components/DimensionScores/index.module.scss +105 -0
- package/app/wujie-vue3-child/src/views/aiCoach/reportDetail/components/ReportHeader/index.jsx +81 -0
- package/app/wujie-vue3-child/src/views/aiCoach/reportDetail/components/ReportHeader/index.module.scss +47 -0
- package/app/wujie-vue3-child/src/views/aiCoach/reportDetail/components/RoleInfo/index.jsx +64 -0
- package/app/wujie-vue3-child/src/views/aiCoach/reportDetail/components/RoleInfo/index.module.scss +85 -0
- package/app/wujie-vue3-child/src/views/aiCoach/reportDetail/components/ScoreBadge/index.jsx +39 -0
- package/app/wujie-vue3-child/src/views/aiCoach/reportDetail/components/ScoreBadge/index.module.scss +44 -0
- package/app/wujie-vue3-child/src/views/aiCoach/reportDetail/components/SubDimensionItem/index.jsx +83 -0
- package/app/wujie-vue3-child/src/views/aiCoach/reportDetail/components/SubDimensionItem/index.module.scss +101 -0
- package/app/wujie-vue3-child/src/views/aiCoach/reportDetail/index.jsx +50 -0
- package/app/wujie-vue3-child/src/views/aiCoach/reportDetail/index.module.scss +25 -0
- package/app/wujie-vue3-child/src/views/child-to-parent.vue +117 -0
- package/app/wujie-vue3-child/src/views/home.vue +53 -0
- package/app/wujie-vue3-child/src/views/jsx/btnSelect/btnSelect.vue +169 -0
- package/app/wujie-vue3-child/src/views/jsx/btnSelect/index.vue +69 -0
- package/app/wujie-vue3-child/src/views/jsx/com.vue +44 -0
- package/app/wujie-vue3-child/src/views/jsx/dialog.jsx +66 -0
- package/app/wujie-vue3-child/src/views/jsx/index.vue +72 -0
- package/app/wujie-vue3-child/src/views/jsx/props.vue +33 -0
- package/app/wujie-vue3-child/src/views/parent-to-child.vue +225 -0
- package/app/wujie-vue3-child/src/views/phone-code.vue +318 -0
- package/app/wujie-vue3-child/src/views/router-jump.vue +123 -0
- package/app/wujie-vue3-child/src/views/test.vue +192 -0
- package/app/wujie-vue3-child/vite.config.js +15 -0
- package/package.json +1 -1
- package/app/aiCoach/index.jsx +0 -20
- package/npmapps-1.0.20.tgz +0 -0
- /package/app/{aiCoach → wujie-vue3-child/src/views/aiCoach}/collapseExpand/index.jsx +0 -0
- /package/app/{aiCoach → wujie-vue3-child/src/views/aiCoach}/collapseExpand/index.module.scss +0 -0
- /package/app/{aiCoach → wujie-vue3-child/src/views/aiCoach}/dialogueSegment/index.module.scss +0 -0
- /package/app/{aiCoach → wujie-vue3-child/src/views/aiCoach}/scriptTable/index.jsx +0 -0
- /package/app/{aiCoach → wujie-vue3-child/src/views/aiCoach}/scriptTable/index.module.scss +0 -0
- /package/app/{aiCoach → wujie-vue3-child/src/views/aiCoach}/scriptTable/inputColumn/index.jsx +0 -0
- /package/app/{aiCoach → wujie-vue3-child/src/views/aiCoach}/scriptTable/inputColumn/index.module.scss +0 -0
|
@@ -0,0 +1,687 @@
|
|
|
1
|
+
import { defineComponent, ref, computed, nextTick, onBeforeUnmount } from 'vue'
|
|
2
|
+
import { Search, Delete, Loading } from '@element-plus/icons-vue'
|
|
3
|
+
import { debounce } from 'lodash-es'
|
|
4
|
+
import PopoverSelector from './PopoverSelector.jsx'
|
|
5
|
+
import SelectorTrigger from './SelectorTrigger.jsx'
|
|
6
|
+
import { fetchDepartments, fetchPersonnel, searchPersonnel } from '../mockData.js'
|
|
7
|
+
import styles from './DepartmentPersonnelSelector.module.scss'
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* 部门人员选择器组件(三栏布局)
|
|
11
|
+
* @component DepartmentPersonnelSelector
|
|
12
|
+
* @description 左侧部门树,中间人员列表,右侧已选人员的三栏布局选择器
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* // 单选
|
|
16
|
+
* <DepartmentPersonnelSelector
|
|
17
|
+
* v-model={selectedPersonnel}
|
|
18
|
+
* placeholder="请选择人员"
|
|
19
|
+
* />
|
|
20
|
+
*
|
|
21
|
+
* // 多选
|
|
22
|
+
* <DepartmentPersonnelSelector
|
|
23
|
+
* v-model={selectedPersonnelList}
|
|
24
|
+
* multiple={true}
|
|
25
|
+
* placeholder="请选择人员"
|
|
26
|
+
* />
|
|
27
|
+
*/
|
|
28
|
+
export default defineComponent({
|
|
29
|
+
name: 'DepartmentPersonnelSelector',
|
|
30
|
+
|
|
31
|
+
props: {
|
|
32
|
+
/**
|
|
33
|
+
* 选中的人员(单选时为对象,多选时为对象数组)
|
|
34
|
+
* @type {Object|Array<Object>}
|
|
35
|
+
* @example 单选:{ id: 1001, name: '张伟', position: '部门总经理' }
|
|
36
|
+
* @example 多选:[{ id: 1001, name: '张伟' }, { id: 1002, name: '王芳' }]
|
|
37
|
+
*/
|
|
38
|
+
modelValue: {
|
|
39
|
+
type: [Object, Array],
|
|
40
|
+
default: null,
|
|
41
|
+
},
|
|
42
|
+
/**
|
|
43
|
+
* 是否多选
|
|
44
|
+
* @type {boolean}
|
|
45
|
+
*/
|
|
46
|
+
multiple: {
|
|
47
|
+
type: Boolean,
|
|
48
|
+
default: true,
|
|
49
|
+
},
|
|
50
|
+
/**
|
|
51
|
+
* 输入框占位文本
|
|
52
|
+
* @type {string}
|
|
53
|
+
*/
|
|
54
|
+
placeholder: {
|
|
55
|
+
type: String,
|
|
56
|
+
default: '请选择人员',
|
|
57
|
+
},
|
|
58
|
+
/**
|
|
59
|
+
* 显示类型:input 输入框模式 | button 按钮模式
|
|
60
|
+
* @type {string}
|
|
61
|
+
*/
|
|
62
|
+
displayType: {
|
|
63
|
+
type: String,
|
|
64
|
+
default: 'input',
|
|
65
|
+
validator: (value) => ['input', 'button'].includes(value),
|
|
66
|
+
},
|
|
67
|
+
/**
|
|
68
|
+
* 前置标签文本,如:"人员:"
|
|
69
|
+
* @type {string}
|
|
70
|
+
*/
|
|
71
|
+
label: {
|
|
72
|
+
type: String,
|
|
73
|
+
default: '',
|
|
74
|
+
},
|
|
75
|
+
/**
|
|
76
|
+
* 是否禁用
|
|
77
|
+
* @type {boolean}
|
|
78
|
+
*/
|
|
79
|
+
disabled: {
|
|
80
|
+
type: Boolean,
|
|
81
|
+
default: false,
|
|
82
|
+
},
|
|
83
|
+
/**
|
|
84
|
+
* 是否可清空
|
|
85
|
+
* @type {boolean}
|
|
86
|
+
*/
|
|
87
|
+
clearable: {
|
|
88
|
+
type: Boolean,
|
|
89
|
+
default: false,
|
|
90
|
+
},
|
|
91
|
+
/**
|
|
92
|
+
* 多选时是否将选中值按文字的形式展示
|
|
93
|
+
* @type {boolean}
|
|
94
|
+
*/
|
|
95
|
+
collapseTags: {
|
|
96
|
+
type: Boolean,
|
|
97
|
+
default: false,
|
|
98
|
+
},
|
|
99
|
+
/**
|
|
100
|
+
* 当鼠标悬停于折叠标签的文本时,是否显示所有选中的标签
|
|
101
|
+
* @type {boolean}
|
|
102
|
+
*/
|
|
103
|
+
collapseTagsTooltip: {
|
|
104
|
+
type: Boolean,
|
|
105
|
+
default: false,
|
|
106
|
+
},
|
|
107
|
+
/**
|
|
108
|
+
* 多选时用户最多可以选择的项目数,为 0 则不限制
|
|
109
|
+
* @type {number}
|
|
110
|
+
*/
|
|
111
|
+
maxCollapseTags: {
|
|
112
|
+
type: Number,
|
|
113
|
+
default: 0,
|
|
114
|
+
},
|
|
115
|
+
/**
|
|
116
|
+
* 是否默认选择第一个部门
|
|
117
|
+
* @type {boolean}
|
|
118
|
+
*/
|
|
119
|
+
defaultSelectFirstDepartment: {
|
|
120
|
+
type: Boolean,
|
|
121
|
+
default: true,
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
|
|
125
|
+
emits: ['update:modelValue', 'change'],
|
|
126
|
+
|
|
127
|
+
setup(props, { emit }) {
|
|
128
|
+
// 部门树数据
|
|
129
|
+
const departments = ref([])
|
|
130
|
+
// 所有人员数据
|
|
131
|
+
const allPersonnel = ref([])
|
|
132
|
+
// 当前部门的人员列表
|
|
133
|
+
const currentPersonnel = ref([])
|
|
134
|
+
// 当前选中的部门ID
|
|
135
|
+
const selectedDepartmentId = ref(null)
|
|
136
|
+
|
|
137
|
+
// 数据加载状态
|
|
138
|
+
const isLoadingDepartments = ref(false)
|
|
139
|
+
const isLoadingPersonnel = ref(false)
|
|
140
|
+
|
|
141
|
+
// 树组件 ref
|
|
142
|
+
const treeRef = ref(null)
|
|
143
|
+
|
|
144
|
+
// 搜索关键词
|
|
145
|
+
const searchKeyword = ref('')
|
|
146
|
+
// 是否正在搜索
|
|
147
|
+
const isSearching = computed(() => searchKeyword.value.trim() !== '')
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* 获取选中的人员信息
|
|
151
|
+
* @returns {Array}
|
|
152
|
+
*/
|
|
153
|
+
const selectedPersonnel = computed(() => {
|
|
154
|
+
if (!props.modelValue) return []
|
|
155
|
+
// v-model 直接绑定对象,单选转数组,多选直接使用
|
|
156
|
+
return Array.isArray(props.modelValue) ? props.modelValue : [props.modelValue]
|
|
157
|
+
})
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* 显示在输入框中的文本
|
|
161
|
+
* @returns {string}
|
|
162
|
+
*/
|
|
163
|
+
const displayText = computed(() => {
|
|
164
|
+
if (selectedPersonnel.value.length === 0) return ''
|
|
165
|
+
return selectedPersonnel.value.map(p => p.name).join(', ')
|
|
166
|
+
})
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* 已选人员统计
|
|
170
|
+
*/
|
|
171
|
+
const selectedCount = computed(() => selectedPersonnel.value.length)
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* 加载部门数据
|
|
175
|
+
*/
|
|
176
|
+
const loadDepartments = async () => {
|
|
177
|
+
try {
|
|
178
|
+
isLoadingDepartments.value = true
|
|
179
|
+
departments.value = await fetchDepartments(1500)
|
|
180
|
+
} catch (error) {
|
|
181
|
+
console.error('加载部门数据失败:', error)
|
|
182
|
+
} finally {
|
|
183
|
+
isLoadingDepartments.value = false
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* 加载所有人员数据
|
|
189
|
+
*/
|
|
190
|
+
const loadAllPersonnel = async () => {
|
|
191
|
+
try {
|
|
192
|
+
isLoadingPersonnel.value = true
|
|
193
|
+
allPersonnel.value = await fetchPersonnel(1500, null)
|
|
194
|
+
} catch (error) {
|
|
195
|
+
console.error('加载人员数据失败:', error)
|
|
196
|
+
} finally {
|
|
197
|
+
isLoadingPersonnel.value = false
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* 加载指定部门的人员
|
|
203
|
+
* @param {number} departmentId - 部门ID
|
|
204
|
+
*/
|
|
205
|
+
const loadPersonnelByDepartment = async (departmentId) => {
|
|
206
|
+
try {
|
|
207
|
+
isLoadingPersonnel.value = true
|
|
208
|
+
currentPersonnel.value = await fetchPersonnel(1500, departmentId)
|
|
209
|
+
} catch (error) {
|
|
210
|
+
console.error('加载部门人员失败:', error)
|
|
211
|
+
} finally {
|
|
212
|
+
isLoadingPersonnel.value = false
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* 悬浮窗打开时的回调
|
|
218
|
+
*/
|
|
219
|
+
const handleOpen = async () => {
|
|
220
|
+
// 异步加载数据(不阻塞悬浮窗打开)
|
|
221
|
+
const loadDataPromises = []
|
|
222
|
+
|
|
223
|
+
// 如果数据未加载,先加载
|
|
224
|
+
if (departments.value.length === 0) {
|
|
225
|
+
loadDataPromises.push(loadDepartments())
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
// 等待数据加载完成
|
|
229
|
+
if (loadDataPromises.length > 0) {
|
|
230
|
+
await Promise.all(loadDataPromises)
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
// 如果配置了默认选择第一个部门
|
|
234
|
+
if (props.defaultSelectFirstDepartment) {
|
|
235
|
+
// 如果没有选中部门,默认选中第一个部门
|
|
236
|
+
if (!selectedDepartmentId.value && departments.value.length > 0) {
|
|
237
|
+
const firstDept = departments.value[0]
|
|
238
|
+
selectedDepartmentId.value = firstDept.id
|
|
239
|
+
await loadPersonnelByDepartment(firstDept.id)
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
// 设置树的选中状态(每次打开都设置,确保高亮显示)
|
|
244
|
+
await nextTick()
|
|
245
|
+
if (treeRef.value && selectedDepartmentId.value) {
|
|
246
|
+
treeRef.value.setCurrentKey(selectedDepartmentId.value)
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* 部门树节点点击事件
|
|
252
|
+
* @param {Object} data - 节点数据
|
|
253
|
+
*/
|
|
254
|
+
const handleDepartmentClick = async (data) => {
|
|
255
|
+
selectedDepartmentId.value = data.id
|
|
256
|
+
searchKeyword.value = ''
|
|
257
|
+
await loadPersonnelByDepartment(data.id)
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* 检查人员是否被选中
|
|
262
|
+
* @param {number|string} id - 人员ID
|
|
263
|
+
* @returns {boolean}
|
|
264
|
+
*/
|
|
265
|
+
const isPersonSelected = (id) => {
|
|
266
|
+
if (!props.multiple) {
|
|
267
|
+
return props.modelValue?.id === id
|
|
268
|
+
} else {
|
|
269
|
+
const currentValue = Array.isArray(props.modelValue) ? props.modelValue : []
|
|
270
|
+
return currentValue.some(p => p.id === id)
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* 人员项点击事件(添加到已选列表)
|
|
276
|
+
* @param {Object} person - 人员数据
|
|
277
|
+
* @param {Function} close - 关闭悬浮窗的函数
|
|
278
|
+
*/
|
|
279
|
+
const handlePersonClick = (person, close) => {
|
|
280
|
+
if (!props.multiple) {
|
|
281
|
+
// 单选模式:直接选择并关闭,emit 完整对象
|
|
282
|
+
emit('update:modelValue', person)
|
|
283
|
+
emit('change', person)
|
|
284
|
+
close()
|
|
285
|
+
} else {
|
|
286
|
+
// 多选模式:切换选中状态
|
|
287
|
+
const currentValue = Array.isArray(props.modelValue) ? props.modelValue : []
|
|
288
|
+
const index = currentValue.findIndex(p => p.id === person.id)
|
|
289
|
+
|
|
290
|
+
let newValue
|
|
291
|
+
if (index > -1) {
|
|
292
|
+
// 已选中,取消选中
|
|
293
|
+
newValue = currentValue.filter(p => p.id !== person.id)
|
|
294
|
+
} else {
|
|
295
|
+
// 未选中,添加选中
|
|
296
|
+
newValue = [...currentValue, person]
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
emit('update:modelValue', newValue)
|
|
300
|
+
emit('change', newValue) // 返回完整对象数组
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* 从已选列表中移除人员
|
|
306
|
+
* @param {number|string} id - 人员ID
|
|
307
|
+
*/
|
|
308
|
+
const removeSelectedPerson = (id) => {
|
|
309
|
+
if (props.multiple) {
|
|
310
|
+
const newValue = (Array.isArray(props.modelValue) ? props.modelValue : [])
|
|
311
|
+
.filter(item => item.id !== id)
|
|
312
|
+
emit('update:modelValue', newValue)
|
|
313
|
+
emit('change', newValue) // 返回完整对象数组
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
/**
|
|
318
|
+
* 清空所有已选人员
|
|
319
|
+
*/
|
|
320
|
+
const clearAllSelected = () => {
|
|
321
|
+
emit('update:modelValue', props.multiple ? [] : null)
|
|
322
|
+
emit('change', props.multiple ? [] : null) // 空值时直接返回 null 或 []
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
/**
|
|
326
|
+
* 清空选择(从输入框)
|
|
327
|
+
*/
|
|
328
|
+
const handleClear = (e) => {
|
|
329
|
+
e.stopPropagation()
|
|
330
|
+
clearAllSelected()
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
/**
|
|
334
|
+
* 移除单个标签
|
|
335
|
+
* @param {number|string} id - 人员ID
|
|
336
|
+
*/
|
|
337
|
+
const removeTag = (e, id) => {
|
|
338
|
+
e.stopPropagation()
|
|
339
|
+
removeSelectedPerson(id)
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
/**
|
|
343
|
+
* 搜索关键词变化处理(防抖)
|
|
344
|
+
*/
|
|
345
|
+
const performSearch = () => {
|
|
346
|
+
const keyword = searchKeyword.value.trim()
|
|
347
|
+
if (!keyword) {
|
|
348
|
+
// 清空搜索,恢复当前部门人员
|
|
349
|
+
if (selectedDepartmentId.value) {
|
|
350
|
+
loadPersonnelByDepartment(selectedDepartmentId.value)
|
|
351
|
+
}
|
|
352
|
+
} else {
|
|
353
|
+
// 搜索全局人员
|
|
354
|
+
currentPersonnel.value = searchPersonnel(keyword, allPersonnel.value)
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
// 创建防抖搜索函数(300ms延迟)
|
|
359
|
+
const debouncedSearch = debounce(performSearch, 300)
|
|
360
|
+
|
|
361
|
+
/**
|
|
362
|
+
* 搜索输入变化处理
|
|
363
|
+
*/
|
|
364
|
+
const handleSearchChange = () => {
|
|
365
|
+
debouncedSearch()
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
// 组件卸载时
|
|
369
|
+
onBeforeUnmount(() => {
|
|
370
|
+
// 取消防抖函数
|
|
371
|
+
debouncedSearch.cancel()
|
|
372
|
+
})
|
|
373
|
+
|
|
374
|
+
return () => {
|
|
375
|
+
// 渲染多选标签
|
|
376
|
+
const renderTags = () => {
|
|
377
|
+
if (!props.multiple || selectedPersonnel.value.length === 0) return null
|
|
378
|
+
|
|
379
|
+
const persons = selectedPersonnel.value
|
|
380
|
+
|
|
381
|
+
// collapse-tags 模式:只显示第一个 + 剩余数量
|
|
382
|
+
if (props.collapseTags) {
|
|
383
|
+
const firstPerson = persons[0]
|
|
384
|
+
const restCount = persons.length - 1
|
|
385
|
+
|
|
386
|
+
const tagsContent = (
|
|
387
|
+
<div class={styles.tagsWrapper}>
|
|
388
|
+
<el-tag
|
|
389
|
+
closable
|
|
390
|
+
disable-transitions
|
|
391
|
+
onClose={(e) => removeTag(e, firstPerson.id)}
|
|
392
|
+
size="small"
|
|
393
|
+
type="info"
|
|
394
|
+
class={styles.tag}
|
|
395
|
+
>
|
|
396
|
+
{firstPerson.name}
|
|
397
|
+
</el-tag>
|
|
398
|
+
{restCount > 0 && (
|
|
399
|
+
<el-tag
|
|
400
|
+
disable-transitions
|
|
401
|
+
size="small"
|
|
402
|
+
type="info"
|
|
403
|
+
class={styles.tag}
|
|
404
|
+
>
|
|
405
|
+
+{restCount}
|
|
406
|
+
</el-tag>
|
|
407
|
+
)}
|
|
408
|
+
</div>
|
|
409
|
+
)
|
|
410
|
+
|
|
411
|
+
// collapse-tags-tooltip 模式:悬停显示所有标签
|
|
412
|
+
if (props.collapseTagsTooltip && restCount > 0) {
|
|
413
|
+
const tooltipContent = persons.slice(1).map(p => p.name).join('、')
|
|
414
|
+
return (
|
|
415
|
+
<el-tooltip
|
|
416
|
+
content={tooltipContent}
|
|
417
|
+
placement="top"
|
|
418
|
+
effect="light"
|
|
419
|
+
>
|
|
420
|
+
{tagsContent}
|
|
421
|
+
</el-tooltip>
|
|
422
|
+
)
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
return tagsContent
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
// max-collapse-tags 模式:限制显示的标签数量
|
|
429
|
+
if (props.maxCollapseTags > 0 && persons.length > props.maxCollapseTags) {
|
|
430
|
+
const visiblePersons = persons.slice(0, props.maxCollapseTags)
|
|
431
|
+
const restCount = persons.length - props.maxCollapseTags
|
|
432
|
+
|
|
433
|
+
return (
|
|
434
|
+
<div class={styles.tagsWrapper}>
|
|
435
|
+
{visiblePersons.map(person => (
|
|
436
|
+
<el-tag
|
|
437
|
+
key={person.id}
|
|
438
|
+
closable
|
|
439
|
+
disable-transitions
|
|
440
|
+
onClose={(e) => removeTag(e, person.id)}
|
|
441
|
+
size="small"
|
|
442
|
+
type="info"
|
|
443
|
+
class={styles.tag}
|
|
444
|
+
>
|
|
445
|
+
{person.name}
|
|
446
|
+
</el-tag>
|
|
447
|
+
))}
|
|
448
|
+
<el-tag
|
|
449
|
+
disable-transitions
|
|
450
|
+
size="small"
|
|
451
|
+
type="info"
|
|
452
|
+
class={styles.tag}
|
|
453
|
+
>
|
|
454
|
+
+{restCount}
|
|
455
|
+
</el-tag>
|
|
456
|
+
</div>
|
|
457
|
+
)
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
// 默认模式:显示所有标签
|
|
461
|
+
return (
|
|
462
|
+
<div class={styles.tagsWrapper}>
|
|
463
|
+
{persons.map(person => (
|
|
464
|
+
<el-tag
|
|
465
|
+
key={person.id}
|
|
466
|
+
closable
|
|
467
|
+
disable-transitions
|
|
468
|
+
onClose={(e) => removeTag(e, person.id)}
|
|
469
|
+
size="small"
|
|
470
|
+
type="info"
|
|
471
|
+
class={styles.tag}
|
|
472
|
+
>
|
|
473
|
+
{person.name}
|
|
474
|
+
</el-tag>
|
|
475
|
+
))}
|
|
476
|
+
</div>
|
|
477
|
+
)
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
// 渲染显示内容(文本或标签)
|
|
481
|
+
const renderContent = () => {
|
|
482
|
+
let content = null
|
|
483
|
+
|
|
484
|
+
if (props.multiple) {
|
|
485
|
+
// 多选模式
|
|
486
|
+
if (selectedPersonnel.value.length === 0) {
|
|
487
|
+
content = <span class={styles.placeholder}>{props.placeholder}</span>
|
|
488
|
+
} else if (props.displayType === 'button') {
|
|
489
|
+
// 按钮模式:显示文字 + 圆圈徽章
|
|
490
|
+
const firstPerson = selectedPersonnel.value[0]
|
|
491
|
+
const restCount = selectedPersonnel.value.length - 1
|
|
492
|
+
|
|
493
|
+
content = (
|
|
494
|
+
<div class={styles.buttonTextWrapper}>
|
|
495
|
+
<span class={styles.text}>{firstPerson.name}</span>
|
|
496
|
+
{restCount > 0 && (
|
|
497
|
+
<span class={styles.countBadge}>+{restCount}</span>
|
|
498
|
+
)}
|
|
499
|
+
</div>
|
|
500
|
+
)
|
|
501
|
+
} else {
|
|
502
|
+
// 输入框模式:显示标签
|
|
503
|
+
content = renderTags()
|
|
504
|
+
}
|
|
505
|
+
} else {
|
|
506
|
+
// 单选:显示文本
|
|
507
|
+
content = displayText.value ? (
|
|
508
|
+
<span class={styles.text}>{displayText.value}</span>
|
|
509
|
+
) : (
|
|
510
|
+
<span class={styles.placeholder}>{props.placeholder}</span>
|
|
511
|
+
)
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
// 如果有 label,添加前缀
|
|
515
|
+
if (props.label) {
|
|
516
|
+
return (
|
|
517
|
+
<>
|
|
518
|
+
<span class={styles.label}>{props.label}</span>
|
|
519
|
+
{content}
|
|
520
|
+
</>
|
|
521
|
+
)
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
return content
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
// 计算是否有选中值
|
|
528
|
+
const hasValue = props.multiple
|
|
529
|
+
? selectedPersonnel.value.length > 0
|
|
530
|
+
: !!displayText.value
|
|
531
|
+
|
|
532
|
+
// 计算悬浮窗宽度(单选520px,多选800px)
|
|
533
|
+
const popoverWidth = props.multiple ? 800 : 520
|
|
534
|
+
|
|
535
|
+
return (
|
|
536
|
+
<PopoverSelector
|
|
537
|
+
width={popoverWidth}
|
|
538
|
+
maxHeight={500}
|
|
539
|
+
disabled={props.disabled}
|
|
540
|
+
onOpen={handleOpen}
|
|
541
|
+
>
|
|
542
|
+
{{
|
|
543
|
+
// 触发器插槽
|
|
544
|
+
trigger: ({ open, visible }) => (
|
|
545
|
+
<SelectorTrigger
|
|
546
|
+
displayType={props.displayType}
|
|
547
|
+
visible={visible}
|
|
548
|
+
disabled={props.disabled}
|
|
549
|
+
clearable={props.clearable}
|
|
550
|
+
hasValue={hasValue}
|
|
551
|
+
onClick={open}
|
|
552
|
+
onClear={handleClear}
|
|
553
|
+
>
|
|
554
|
+
{renderContent()}
|
|
555
|
+
</SelectorTrigger>
|
|
556
|
+
),
|
|
557
|
+
|
|
558
|
+
// 悬浮窗内容插槽
|
|
559
|
+
default: ({ close }) => (
|
|
560
|
+
<div class={styles.dropdownContent}>
|
|
561
|
+
{/* 搜索栏 */}
|
|
562
|
+
<div class={styles.searchBar}>
|
|
563
|
+
<el-input
|
|
564
|
+
v-model={searchKeyword.value}
|
|
565
|
+
placeholder="搜索人员(姓名/职位/电话/邮箱)"
|
|
566
|
+
prefix-icon="Search"
|
|
567
|
+
onInput={handleSearchChange}
|
|
568
|
+
/>
|
|
569
|
+
</div>
|
|
570
|
+
|
|
571
|
+
{/* 三栏内容区域 */}
|
|
572
|
+
<div class={styles.contentArea}>
|
|
573
|
+
{/* 左侧:部门树 */}
|
|
574
|
+
<div class={styles.leftPanel}>
|
|
575
|
+
<div class={styles.panelTitle}>部门</div>
|
|
576
|
+
<div class={styles.treeWrapper}>
|
|
577
|
+
{isLoadingDepartments.value ? (
|
|
578
|
+
<div class={styles.loading}>
|
|
579
|
+
<el-icon class="is-loading">
|
|
580
|
+
<Loading />
|
|
581
|
+
</el-icon>
|
|
582
|
+
<span>加载部门中...</span>
|
|
583
|
+
</div>
|
|
584
|
+
) : (
|
|
585
|
+
<el-tree
|
|
586
|
+
ref={treeRef}
|
|
587
|
+
data={departments.value}
|
|
588
|
+
node-key="id"
|
|
589
|
+
props={{ label: 'label', children: 'children' }}
|
|
590
|
+
default-expand-all={false}
|
|
591
|
+
highlight-current={true}
|
|
592
|
+
expand-on-click-node={true}
|
|
593
|
+
onNodeClick={handleDepartmentClick}
|
|
594
|
+
/>
|
|
595
|
+
)}
|
|
596
|
+
</div>
|
|
597
|
+
</div>
|
|
598
|
+
|
|
599
|
+
{/* 中间:人员列表 */}
|
|
600
|
+
<div class={styles.middlePanel}>
|
|
601
|
+
<div class={styles.panelTitle}>
|
|
602
|
+
{isSearching.value ? '搜索结果' : '人员列表'}
|
|
603
|
+
</div>
|
|
604
|
+
<div class={styles.personnelList}>
|
|
605
|
+
{isLoadingPersonnel.value ? (
|
|
606
|
+
<div class={styles.loading}>
|
|
607
|
+
<el-icon class="is-loading">
|
|
608
|
+
<Loading />
|
|
609
|
+
</el-icon>
|
|
610
|
+
<span>加载人员中...</span>
|
|
611
|
+
</div>
|
|
612
|
+
) : currentPersonnel.value.length === 0 ? (
|
|
613
|
+
<div class={styles.empty}>
|
|
614
|
+
{isSearching.value ? '未找到相关人员' : '暂无人员'}
|
|
615
|
+
</div>
|
|
616
|
+
) : (
|
|
617
|
+
currentPersonnel.value.map(person => (
|
|
618
|
+
<div
|
|
619
|
+
key={person.id}
|
|
620
|
+
class={[
|
|
621
|
+
styles.personnelItem,
|
|
622
|
+
isPersonSelected(person.id) && styles.selected,
|
|
623
|
+
]}
|
|
624
|
+
onClick={() => handlePersonClick(person, close)}
|
|
625
|
+
>
|
|
626
|
+
{/* 人员信息 */}
|
|
627
|
+
<div class={styles.personInfo}>
|
|
628
|
+
<div class={styles.personName}>{person.name}</div>
|
|
629
|
+
<div class={styles.personMeta}>
|
|
630
|
+
<span class={styles.position}>{person.position}</span>
|
|
631
|
+
</div>
|
|
632
|
+
</div>
|
|
633
|
+
</div>
|
|
634
|
+
))
|
|
635
|
+
)}
|
|
636
|
+
</div>
|
|
637
|
+
</div>
|
|
638
|
+
|
|
639
|
+
{/* 右侧:已选人员(仅多选模式显示) */}
|
|
640
|
+
{props.multiple && (
|
|
641
|
+
<div class={styles.rightPanel}>
|
|
642
|
+
<div class={styles.panelTitle}>
|
|
643
|
+
已选择 ({selectedCount.value})
|
|
644
|
+
{selectedCount.value > 0 && (
|
|
645
|
+
<span
|
|
646
|
+
class={styles.clearAll}
|
|
647
|
+
onClick={clearAllSelected}
|
|
648
|
+
>
|
|
649
|
+
清空
|
|
650
|
+
</span>
|
|
651
|
+
)}
|
|
652
|
+
</div>
|
|
653
|
+
<div class={styles.selectedList}>
|
|
654
|
+
{selectedPersonnel.value.length === 0 ? (
|
|
655
|
+
<div class={styles.empty}>暂无选择</div>
|
|
656
|
+
) : (
|
|
657
|
+
selectedPersonnel.value.map(person => (
|
|
658
|
+
<div key={person.id} class={styles.selectedItem}>
|
|
659
|
+
<div class={styles.selectedPersonInfo}>
|
|
660
|
+
<div class={styles.selectedPersonName}>
|
|
661
|
+
{person.name}
|
|
662
|
+
</div>
|
|
663
|
+
<div class={styles.selectedPersonMeta}>
|
|
664
|
+
{person.position}
|
|
665
|
+
</div>
|
|
666
|
+
</div>
|
|
667
|
+
<el-icon
|
|
668
|
+
class={styles.removeIcon}
|
|
669
|
+
onClick={() => removeSelectedPerson(person.id)}
|
|
670
|
+
>
|
|
671
|
+
<Delete />
|
|
672
|
+
</el-icon>
|
|
673
|
+
</div>
|
|
674
|
+
))
|
|
675
|
+
)}
|
|
676
|
+
</div>
|
|
677
|
+
</div>
|
|
678
|
+
)}
|
|
679
|
+
</div>
|
|
680
|
+
</div>
|
|
681
|
+
),
|
|
682
|
+
}}
|
|
683
|
+
</PopoverSelector>
|
|
684
|
+
)
|
|
685
|
+
}
|
|
686
|
+
},
|
|
687
|
+
})
|