cd-personselector 1.3.4 → 1.3.5

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cd-personselector",
3
- "version": "1.3.4",
3
+ "version": "1.3.5",
4
4
  "description": "人员选择器组件 - 支持多Tab、树形结构、搜索、懒加载、输入框选择模式",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -40,18 +40,23 @@
40
40
  </div>
41
41
  <div v-else class="cd-input-select__option-avatar cd-input-select__option-avatar--placeholder"
42
42
  :style="{
43
- backgroundColor: isDepartment(result.id) ? '#e6f4ff' : getAvatarColor(result.name),
44
- color: isDepartment(result.id) ? '#0052d9' : '#fff'
43
+ backgroundColor: getNodeTypeColor(result.nodeType),
44
+ color: '#fff'
45
45
  }">
46
- {{ getAvatarInitial(result.name) }}
46
+ {{ getNodeTypeIcon(result.nodeType) }}
47
47
  </div>
48
48
  <div class="cd-input-select__option-info">
49
49
  <div class="cd-input-select__option-name">{{ result.name }}</div>
50
- <div v-if="result.department || result.position" class="cd-input-select__option-desc">
51
- {{ result.department }}{{ result.department && result.position ? ' · ' : '' }}{{ result.position }}
50
+ <div v-if="result.isUser && (result.department || result.post)" class="cd-input-select__option-desc">
51
+ {{ result.department }}{{ result.department && result.post ? ' · ' : '' }}{{ result.post }}
52
+ </div>
53
+ <div v-else-if="result.fnumber" class="cd-input-select__option-desc">
54
+ {{ result.fnumber }}
52
55
  </div>
53
56
  </div>
54
- <i v-if="isDepartment(result.id)" class="ri-building-line cd-input-select__option-icon"></i>
57
+ <span class="cd-input-select__option-tag" :style="{ backgroundColor: getNodeTypeColor(result.nodeType) + '18', color: getNodeTypeColor(result.nodeType) }">
58
+ {{ getNodeTypeLabel(result.nodeType) }}
59
+ </span>
55
60
  </div>
56
61
  </t-checkbox>
57
62
  </div>
@@ -137,6 +142,19 @@ const isDepartment = (id: string | number): boolean => {
137
142
  return String(id).startsWith('dept-');
138
143
  };
139
144
 
145
+ // nodeType 辅助函数
146
+ const nodeTypeMap: Record<string, { label: string; color: string; icon: string }> = {
147
+ department: { label: '部门', color: '#0052d9', icon: '部' },
148
+ user: { label: '人员', color: '#1890ff', icon: '人' },
149
+ post: { label: '岗位', color: '#52c41a', icon: '岗' },
150
+ position: { label: '职务', color: '#722ed1', icon: '职' },
151
+ business: { label: '商业', color: '#fa8c16', icon: '商' },
152
+ external: { label: '外部', color: '#eb2f96', icon: '外' },
153
+ };
154
+ const getNodeTypeLabel = (t?: string) => nodeTypeMap[t || '']?.label || '其他';
155
+ const getNodeTypeColor = (t?: string) => nodeTypeMap[t || '']?.color || '#999';
156
+ const getNodeTypeIcon = (t?: string) => nodeTypeMap[t || '']?.icon || '?';
157
+
140
158
  // 根据 value (ID) 获取标签主题颜色
141
159
  const getTagThemeByValue = (value: string | number): 'default' | 'primary' | 'success' | 'warning' | 'danger' | 'info' => {
142
160
  const idStr = String(value);
@@ -315,6 +333,8 @@ watch(inputValue, (keyword) => {
315
333
  &__panel {
316
334
  max-height: 300px;
317
335
  overflow-y: auto;
336
+ width: 100%;
337
+ box-sizing: border-box;
318
338
  }
319
339
  &__loading,
320
340
  &__empty {
@@ -383,5 +403,12 @@ watch(inputValue, (keyword) => {
383
403
  color: var(--td-brand-color, #0052d9);
384
404
  flex-shrink: 0;
385
405
  }
406
+ &-tag {
407
+ font-size: 11px;
408
+ padding: 1px 6px;
409
+ border-radius: 3px;
410
+ flex-shrink: 0;
411
+ white-space: nowrap;
412
+ }
386
413
  }
387
414
  </style>
@@ -6,6 +6,7 @@
6
6
  :footer="true"
7
7
  placement="center"
8
8
  destroy-on-close
9
+ attach="body"
9
10
  @confirm="handleConfirm"
10
11
  @close="handleClose"
11
12
  >