@king-one/antdv 1.1.13 → 1.2.0
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/CHANGELOG.md +12 -0
- package/dist/es/components/index.mjs +4 -1
- package/dist/es/components/pro-selector/index.mjs +8 -0
- package/dist/es/components/pro-selector/src/components/org-tree.mjs +304 -0
- package/dist/es/components/pro-selector/src/components/user.mjs +92 -0
- package/dist/es/components/pro-selector/src/hooks/index.mjs +4 -0
- package/dist/es/components/pro-selector/src/hooks/useUserSelector.mjs +9 -0
- package/dist/es/components/pro-selector/src/pro-user.mjs +210 -0
- package/dist/es/components/pro-selector/src/types.mjs +1 -0
- package/dist/es/components/pro-selector/src/utils/orgTree.mjs +93 -0
- package/dist/es/components/pro-selector/style/index.mjs +2 -0
- package/dist/es/components/pro-upload/src/gd-upload.mjs +1 -1
- package/dist/es/components/pro-upload/src/hooks/useHttp.mjs +5 -5
- package/dist/es/components/pro-upload/src/hooks/useUpload.mjs +2 -2
- package/dist/es/components/pro-upload/src/props.mjs +4 -0
- package/dist/es/components/pro-user-avatar/index.mjs +10 -0
- package/dist/es/components/pro-user-avatar/src/index.vue.mjs +4 -0
- package/dist/es/components/pro-user-avatar/src/index.vue2.mjs +69 -0
- package/dist/es/components/pro-user-avatar/src/style/index.mjs +2 -0
- package/dist/es/components/pro-user-avatar/src/types.mjs +1 -0
- package/dist/es/components/pro-user-avatar/src/util.mjs +28 -0
- package/dist/es/index.mjs +7 -1
- package/dist/lib/components/index.js +3 -0
- package/dist/lib/components/pro-selector/index.js +8 -0
- package/dist/lib/components/pro-selector/src/components/org-tree.js +304 -0
- package/dist/lib/components/pro-selector/src/components/user.js +92 -0
- package/dist/lib/components/pro-selector/src/hooks/index.js +4 -0
- package/dist/lib/components/pro-selector/src/hooks/useUserSelector.js +9 -0
- package/dist/lib/components/pro-selector/src/pro-user.js +210 -0
- package/dist/lib/components/pro-selector/src/types.js +1 -0
- package/dist/lib/components/pro-selector/src/utils/orgTree.js +93 -0
- package/dist/lib/components/pro-selector/style/index.js +3 -0
- package/dist/lib/components/pro-upload/src/gd-upload.js +1 -1
- package/dist/lib/components/pro-upload/src/hooks/useHttp.js +5 -5
- package/dist/lib/components/pro-upload/src/hooks/useUpload.js +2 -2
- package/dist/lib/components/pro-upload/src/props.js +4 -0
- package/dist/lib/components/pro-user-avatar/index.js +10 -0
- package/dist/lib/components/pro-user-avatar/src/index.vue.js +4 -0
- package/dist/lib/components/pro-user-avatar/src/index.vue2.js +69 -0
- package/dist/lib/components/pro-user-avatar/src/style/index.js +3 -0
- package/dist/lib/components/pro-user-avatar/src/types.js +1 -0
- package/dist/lib/components/pro-user-avatar/src/util.js +28 -0
- package/dist/lib/index.js +6 -0
- package/dist/theme-chalk/fonts/iconfont.ttf +0 -0
- package/dist/theme-chalk/fonts/iconfont.woff +0 -0
- package/dist/theme-chalk/fonts/iconfont.woff2 +0 -0
- package/dist/theme-chalk/icon.css +1 -1
- package/dist/theme-chalk/index.css +1 -1
- package/dist/theme-chalk/pro-selector.css +1 -0
- package/dist/theme-chalk/pro-user-avatar.css +1 -0
- package/dist/types/components/index.d.ts +2 -0
- package/dist/types/components/pro-selector/index.d.ts +4 -0
- package/dist/types/components/pro-selector/src/components/org-tree.d.ts +61 -0
- package/dist/types/components/pro-selector/src/components/user.d.ts +40 -0
- package/dist/types/components/pro-selector/src/hooks/index.d.ts +1 -0
- package/dist/types/components/pro-selector/src/hooks/useUserSelector.d.ts +3 -0
- package/dist/types/components/pro-selector/src/pro-user.d.ts +75 -0
- package/dist/types/components/pro-selector/src/types.d.ts +40 -0
- package/dist/types/components/pro-selector/src/util.d.ts +26 -0
- package/dist/types/components/pro-selector/src/utils/orgTree.d.ts +20 -0
- package/dist/types/components/pro-upload/index.d.ts +9 -0
- package/dist/types/components/pro-upload/src/gd-upload.d.ts +9 -0
- package/dist/types/components/pro-upload/src/hooks/useHttp.d.ts +1 -1
- package/dist/types/components/pro-upload/src/hooks/useUpload.d.ts +1 -1
- package/dist/types/components/pro-upload/src/props.d.ts +4 -0
- package/dist/types/components/pro-upload/src/types.d.ts +4 -0
- package/dist/types/components/pro-user-avatar/index.d.ts +39 -0
- package/dist/types/components/pro-user-avatar/src/index.vue.d.ts +34 -0
- package/dist/types/components/pro-user-avatar/src/types.d.ts +9 -0
- package/dist/types/components/pro-user-avatar/src/util.d.ts +1 -0
- package/global.d.ts +2 -0
- package/package.json +3 -3
- package/dist/theme-chalk/fonts//345/275/222/346/241/243.zip +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -17,6 +17,8 @@ import "./pro-loading/index.mjs";
|
|
|
17
17
|
import { KPlusUpload } from "./plus-upload/index.mjs";
|
|
18
18
|
import { KProOverlay } from "./pro-overlay/index.mjs";
|
|
19
19
|
import { KProSign } from "./pro-sign/index.mjs";
|
|
20
|
+
import "./pro-selector/index.mjs";
|
|
21
|
+
import { KUserAvatar } from "./pro-user-avatar/index.mjs";
|
|
20
22
|
export {
|
|
21
23
|
KCollapseTranstion,
|
|
22
24
|
KCoverScrollBar,
|
|
@@ -36,5 +38,6 @@ export {
|
|
|
36
38
|
KProTitle,
|
|
37
39
|
KProUpload,
|
|
38
40
|
KScaleVirtualList,
|
|
39
|
-
KScrollBar
|
|
41
|
+
KScrollBar,
|
|
42
|
+
KUserAvatar
|
|
40
43
|
};
|
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
import { isVNode, defineComponent, ref, watch, createVNode, Fragment, createTextVNode, onMounted } from "vue";
|
|
2
|
+
import { useNamespace } from "../../../../hooks/use-namespace/index.mjs";
|
|
3
|
+
import "../../../index.mjs";
|
|
4
|
+
import { Modal, Empty, Breadcrumb, BreadcrumbItem, Skeleton } from "ant-design-vue";
|
|
5
|
+
import { uid } from "@king-one/utils";
|
|
6
|
+
import { debounce, uniqueById, formatOrgTree } from "../utils/orgTree.mjs";
|
|
7
|
+
import User from "./user.mjs";
|
|
8
|
+
import { KIcon } from "../../../icon/index.mjs";
|
|
9
|
+
function _isSlot(s) {
|
|
10
|
+
return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
|
|
11
|
+
}
|
|
12
|
+
const {
|
|
13
|
+
b
|
|
14
|
+
} = useNamespace("pro-user-selector");
|
|
15
|
+
const OrgTree = /* @__PURE__ */ defineComponent({
|
|
16
|
+
name: "OrgTree",
|
|
17
|
+
props: {
|
|
18
|
+
selectUserList: {
|
|
19
|
+
type: Array,
|
|
20
|
+
default: () => []
|
|
21
|
+
},
|
|
22
|
+
initUserList: {
|
|
23
|
+
type: Array,
|
|
24
|
+
default: () => []
|
|
25
|
+
},
|
|
26
|
+
keyword: {
|
|
27
|
+
type: String,
|
|
28
|
+
default: ""
|
|
29
|
+
},
|
|
30
|
+
initData: {
|
|
31
|
+
type: Function,
|
|
32
|
+
default: () => Promise.resolve([])
|
|
33
|
+
},
|
|
34
|
+
maxCount: {
|
|
35
|
+
type: Number,
|
|
36
|
+
default: 25
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
emits: {
|
|
40
|
+
"update:selectUserList": (list) => list
|
|
41
|
+
},
|
|
42
|
+
setup(props, {
|
|
43
|
+
emit,
|
|
44
|
+
expose
|
|
45
|
+
}) {
|
|
46
|
+
const initData = ref([]);
|
|
47
|
+
const currentViewDept = ref({});
|
|
48
|
+
const breadCrumbList = ref([]);
|
|
49
|
+
const currentBreadCrumbItem = ref({});
|
|
50
|
+
const keywordUserList = ref([]);
|
|
51
|
+
const isSearching = ref(false);
|
|
52
|
+
const debouncedHandleKeywordChange = debounce((keyword) => {
|
|
53
|
+
const list = [];
|
|
54
|
+
const loop = (data) => {
|
|
55
|
+
for (const item of data) {
|
|
56
|
+
if (item.members && item.members.length > 0) {
|
|
57
|
+
for (const member of item.members) {
|
|
58
|
+
if (member.realName.includes(keyword)) {
|
|
59
|
+
list.push(member);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
if (item.children && item.children.length > 0) {
|
|
64
|
+
loop(item.children);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
loop(initData.value);
|
|
69
|
+
keywordUserList.value = uniqueById(list);
|
|
70
|
+
isSearching.value = keyword !== "";
|
|
71
|
+
}, 300);
|
|
72
|
+
watch(() => props.keyword, (newVal, oldVal) => {
|
|
73
|
+
if (newVal === "") {
|
|
74
|
+
debouncedHandleKeywordChange.cancel();
|
|
75
|
+
isSearching.value = false;
|
|
76
|
+
keywordUserList.value = [];
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
if (newVal !== oldVal) {
|
|
80
|
+
debouncedHandleKeywordChange(newVal);
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
const deleteDeptUser = (id) => {
|
|
84
|
+
var _a;
|
|
85
|
+
(_a = currentViewDept.value.members) == null ? void 0 : _a.forEach((member) => {
|
|
86
|
+
if (member.id === id) {
|
|
87
|
+
member.checked = false;
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
keywordUserList.value = keywordUserList.value.map((item) => {
|
|
91
|
+
if (item.id === id) {
|
|
92
|
+
item.checked = false;
|
|
93
|
+
}
|
|
94
|
+
return item;
|
|
95
|
+
});
|
|
96
|
+
};
|
|
97
|
+
const handleChangeCheckedValue = (checked, info) => {
|
|
98
|
+
if (props.selectUserList.length === props.maxCount) {
|
|
99
|
+
info.checked = false;
|
|
100
|
+
Modal.warning({
|
|
101
|
+
title: "温馨提示",
|
|
102
|
+
content: `最多只能选择${props.maxCount}个用户`
|
|
103
|
+
});
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
emit("update:selectUserList", checked ? [...props.selectUserList, info] : props.selectUserList.filter((item) => item.id !== info.id));
|
|
107
|
+
};
|
|
108
|
+
const handleClickOrgItem = (item) => {
|
|
109
|
+
var _a;
|
|
110
|
+
if (item.parentId === "root") {
|
|
111
|
+
breadCrumbList.value.push({
|
|
112
|
+
id: uid(32),
|
|
113
|
+
deptName: "组织内联系人",
|
|
114
|
+
children: initData.value[0].children,
|
|
115
|
+
members: initData.value[0].members
|
|
116
|
+
});
|
|
117
|
+
} else {
|
|
118
|
+
breadCrumbList.value.push(item);
|
|
119
|
+
}
|
|
120
|
+
(_a = item.members) == null ? void 0 : _a.forEach((member) => {
|
|
121
|
+
member.checked = props.selectUserList.some((val) => val.id === member.id);
|
|
122
|
+
});
|
|
123
|
+
currentViewDept.value = item;
|
|
124
|
+
currentBreadCrumbItem.value = item;
|
|
125
|
+
};
|
|
126
|
+
const handleClickBreadCrumbItem = (item, _index) => {
|
|
127
|
+
var _a;
|
|
128
|
+
let dept = {};
|
|
129
|
+
if (currentBreadCrumbItem.value.id === item.id) {
|
|
130
|
+
console.log(`当前组织架构树展示的视图已经是《${item.deptName}》部门下面的数据`);
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
if (_index === 0) {
|
|
134
|
+
dept = {
|
|
135
|
+
children: initData.value
|
|
136
|
+
};
|
|
137
|
+
breadCrumbList.value = [{
|
|
138
|
+
id: uid(32),
|
|
139
|
+
deptName: "联系人",
|
|
140
|
+
children: initData.value
|
|
141
|
+
}];
|
|
142
|
+
} else if (_index === 1) {
|
|
143
|
+
dept = initData.value[0];
|
|
144
|
+
breadCrumbList.value = breadCrumbList.value.slice(0, 2);
|
|
145
|
+
} else {
|
|
146
|
+
dept = item;
|
|
147
|
+
const index = breadCrumbList.value.findIndex((val) => val.id === item.id);
|
|
148
|
+
if (index !== -1) {
|
|
149
|
+
breadCrumbList.value = breadCrumbList.value.slice(0, index + 1);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
(_a = dept.members) == null ? void 0 : _a.forEach((member) => {
|
|
153
|
+
member.checked = props.selectUserList.some((val) => val.id === member.id);
|
|
154
|
+
});
|
|
155
|
+
currentViewDept.value = dept;
|
|
156
|
+
};
|
|
157
|
+
const getOrgTitle = (item) => {
|
|
158
|
+
return createVNode(Fragment, null, [createVNode("div", {
|
|
159
|
+
"class": b("org-tree-item-title")
|
|
160
|
+
}, [item.parentId === "root" ? createVNode(KIcon, {
|
|
161
|
+
"name": "zuzhijiagou",
|
|
162
|
+
"size": 18,
|
|
163
|
+
"color": "#00d6b9"
|
|
164
|
+
}, null) : createVNode("div", {
|
|
165
|
+
"class": b("org-tree-dept-icon")
|
|
166
|
+
}, [createVNode(KIcon, {
|
|
167
|
+
"name": "zuzhijiagou",
|
|
168
|
+
"size": 18,
|
|
169
|
+
"color": "#ffffff"
|
|
170
|
+
}, null)], 2), createVNode("div", {
|
|
171
|
+
"class": b("org-tree-item-title-text")
|
|
172
|
+
}, [item.deptName, item.parentId !== "root" && createVNode(Fragment, null, [createTextVNode("("), item.members && item.members.length > 0 ? item.members.length : 0, createTextVNode(")")])], 2)], 2), item.parentId === "root" ? createVNode(KIcon, {
|
|
173
|
+
"name": "right",
|
|
174
|
+
"size": 14,
|
|
175
|
+
"color": "#bbbfc4"
|
|
176
|
+
}, null) : createVNode("a", {
|
|
177
|
+
"style": "width: 50px",
|
|
178
|
+
"href": "javascript:void(0)"
|
|
179
|
+
}, [createTextVNode("下级")])]);
|
|
180
|
+
};
|
|
181
|
+
const getUserList = (objData) => {
|
|
182
|
+
var _a;
|
|
183
|
+
return createVNode("div", {
|
|
184
|
+
"class": b("user-list")
|
|
185
|
+
}, [(_a = objData.members) == null ? void 0 : _a.map((member) => createVNode(User, {
|
|
186
|
+
"userInfo": member,
|
|
187
|
+
"onChange-checked": handleChangeCheckedValue
|
|
188
|
+
}, null, 8, ["userInfo", "onChange-checked"]))], 2);
|
|
189
|
+
};
|
|
190
|
+
const getOrgElement = (objData) => {
|
|
191
|
+
if (objData.parentId === "root" && breadCrumbList.value.length === 1) {
|
|
192
|
+
return createVNode("div", {
|
|
193
|
+
"class": b("org-tree-item"),
|
|
194
|
+
"onClick": () => handleClickOrgItem(objData)
|
|
195
|
+
}, [getOrgTitle(objData)], 10, ["onClick"]);
|
|
196
|
+
}
|
|
197
|
+
return createVNode(Fragment, null, [objData.children && objData.children.length > 0 ? objData.children.map((item) => createVNode("div", {
|
|
198
|
+
"class": b("org-tree-item"),
|
|
199
|
+
"onClick": () => handleClickOrgItem(item)
|
|
200
|
+
}, [getOrgTitle(item)], 10, ["onClick"])) : null, getUserList(objData)]);
|
|
201
|
+
};
|
|
202
|
+
const getKeyordUserList = () => {
|
|
203
|
+
return createVNode("div", {
|
|
204
|
+
"class": b("user-list")
|
|
205
|
+
}, [keywordUserList.value.length > 0 ? keywordUserList.value.map((member) => createVNode(User, {
|
|
206
|
+
"userInfo": member,
|
|
207
|
+
"onChange-checked": handleChangeCheckedValue
|
|
208
|
+
}, {
|
|
209
|
+
name: () => createVNode("div", {
|
|
210
|
+
"style": "font-size: 14px;color: #000;"
|
|
211
|
+
}, [(member == null ? void 0 : member.realName.includes(props.keyword)) ? member == null ? void 0 : member.realName.split(props.keyword).map((part, index) => createVNode(Fragment, null, [part, index < (member == null ? void 0 : member.realName.split(props.keyword).length) - 1 && createVNode("span", {
|
|
212
|
+
"style": "color: red;"
|
|
213
|
+
}, [props.keyword])])) : member == null ? void 0 : member.realName]),
|
|
214
|
+
_: 1
|
|
215
|
+
}, 8, ["userInfo", "onChange-checked"])) : createVNode(Empty, {
|
|
216
|
+
"description": "暂无数据"
|
|
217
|
+
}, null)], 2);
|
|
218
|
+
};
|
|
219
|
+
const loading = ref(false);
|
|
220
|
+
let resolveDataLoaded;
|
|
221
|
+
const dataLoadPromise = new Promise((resolve) => {
|
|
222
|
+
resolveDataLoaded = resolve;
|
|
223
|
+
});
|
|
224
|
+
onMounted(async () => {
|
|
225
|
+
try {
|
|
226
|
+
loading.value = true;
|
|
227
|
+
initData.value = await props.initData();
|
|
228
|
+
formatOrgTree(initData.value);
|
|
229
|
+
loading.value = false;
|
|
230
|
+
resolveDataLoaded(initData.value);
|
|
231
|
+
currentViewDept.value = {
|
|
232
|
+
children: initData.value
|
|
233
|
+
};
|
|
234
|
+
breadCrumbList.value = [{
|
|
235
|
+
id: uid(32),
|
|
236
|
+
deptName: "联系人",
|
|
237
|
+
children: initData.value
|
|
238
|
+
}];
|
|
239
|
+
handleClickOrgItem(initData.value[0]);
|
|
240
|
+
} finally {
|
|
241
|
+
loading.value = false;
|
|
242
|
+
}
|
|
243
|
+
});
|
|
244
|
+
const getInitData = (_initData, orgData) => {
|
|
245
|
+
const list = [];
|
|
246
|
+
const loop = (data) => {
|
|
247
|
+
for (const item of data) {
|
|
248
|
+
if (item.members && item.members.length > 0) {
|
|
249
|
+
for (const member of item.members) {
|
|
250
|
+
if (_initData.some((val) => val.id === member.id)) {
|
|
251
|
+
member.checked = true;
|
|
252
|
+
list.push(member);
|
|
253
|
+
} else {
|
|
254
|
+
member.checked = false;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
if (item.children && item.children.length > 0) {
|
|
259
|
+
loop(item.children);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
};
|
|
263
|
+
loop(orgData);
|
|
264
|
+
emit("update:selectUserList", uniqueById(list));
|
|
265
|
+
};
|
|
266
|
+
expose({
|
|
267
|
+
deleteDeptUser,
|
|
268
|
+
getInitData,
|
|
269
|
+
dataLoadPromise
|
|
270
|
+
});
|
|
271
|
+
return () => {
|
|
272
|
+
let _slot;
|
|
273
|
+
return createVNode(Fragment, null, [createVNode("div", {
|
|
274
|
+
"style": "padding:0 16px"
|
|
275
|
+
}, [breadCrumbList.value.length > 1 && !isSearching.value ? createVNode(Breadcrumb, {
|
|
276
|
+
"separator": ">",
|
|
277
|
+
"class": b("breadcrumb")
|
|
278
|
+
}, _isSlot(_slot = breadCrumbList.value.map((item, index) => createVNode(BreadcrumbItem, {
|
|
279
|
+
"onClick": () => handleClickBreadCrumbItem(item, index)
|
|
280
|
+
}, {
|
|
281
|
+
default: () => [index === breadCrumbList.value.length - 1 ? item.deptName : createVNode("a", {
|
|
282
|
+
"href": "javascript:void(0)"
|
|
283
|
+
}, [item.deptName])]
|
|
284
|
+
}, 8, ["onClick"]))) ? _slot : {
|
|
285
|
+
default: () => [_slot],
|
|
286
|
+
_: 1
|
|
287
|
+
}, 8, ["class"]) : null]), !isSearching.value ? createVNode("div", {
|
|
288
|
+
"class": b("org-tree")
|
|
289
|
+
}, [loading.value ? createVNode("div", {
|
|
290
|
+
"class": b("org-tree-item"),
|
|
291
|
+
"style": "height: 200px;display: block;"
|
|
292
|
+
}, [createVNode(Skeleton, {
|
|
293
|
+
"active": true,
|
|
294
|
+
"avatar": true
|
|
295
|
+
}, null, 8, ["active", "avatar"]), createVNode(Skeleton, {
|
|
296
|
+
"active": true,
|
|
297
|
+
"avatar": true
|
|
298
|
+
}, null, 8, ["active", "avatar"])], 2) : getOrgElement(currentViewDept.value)], 2) : createVNode(Fragment, null, [getKeyordUserList()])]);
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
});
|
|
302
|
+
export {
|
|
303
|
+
OrgTree as default
|
|
304
|
+
};
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { isVNode, defineComponent, createVNode } from "vue";
|
|
2
|
+
import { useNamespace } from "../../../../hooks/use-namespace/index.mjs";
|
|
3
|
+
import { Checkbox } from "ant-design-vue";
|
|
4
|
+
import "../../../index.mjs";
|
|
5
|
+
import { KUserAvatar } from "../../../pro-user-avatar/index.mjs";
|
|
6
|
+
import { KIcon } from "../../../icon/index.mjs";
|
|
7
|
+
function _isSlot(s) {
|
|
8
|
+
return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
|
|
9
|
+
}
|
|
10
|
+
const {
|
|
11
|
+
b
|
|
12
|
+
} = useNamespace("pro-user-selector");
|
|
13
|
+
const User = /* @__PURE__ */ defineComponent({
|
|
14
|
+
name: "User",
|
|
15
|
+
props: {
|
|
16
|
+
userInfo: {
|
|
17
|
+
type: Object,
|
|
18
|
+
default: () => ({})
|
|
19
|
+
},
|
|
20
|
+
isChecked: {
|
|
21
|
+
type: Boolean,
|
|
22
|
+
default: true
|
|
23
|
+
},
|
|
24
|
+
isDelete: {
|
|
25
|
+
type: Boolean,
|
|
26
|
+
default: false
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
emits: {
|
|
30
|
+
"delete-user": (id) => id,
|
|
31
|
+
"change-checked": (checked, info) => checked
|
|
32
|
+
},
|
|
33
|
+
setup(props, {
|
|
34
|
+
emit,
|
|
35
|
+
slots
|
|
36
|
+
}) {
|
|
37
|
+
const handleChangeChecked = (e) => {
|
|
38
|
+
emit("change-checked", e.target.checked, props.userInfo);
|
|
39
|
+
};
|
|
40
|
+
const getUserInfo = () => createVNode("div", {
|
|
41
|
+
"class": b("user-item-content")
|
|
42
|
+
}, [createVNode("div", {
|
|
43
|
+
"style": {
|
|
44
|
+
width: "100%",
|
|
45
|
+
display: "flex",
|
|
46
|
+
alignItems: "center"
|
|
47
|
+
}
|
|
48
|
+
}, [createVNode(KUserAvatar, {
|
|
49
|
+
"name": props.userInfo.realName ? props.userInfo.realName : "",
|
|
50
|
+
"avatar": props.userInfo.avatar,
|
|
51
|
+
"size": "default"
|
|
52
|
+
}, null, 8, ["name", "avatar"]), createVNode("div", null, [createVNode("div", {
|
|
53
|
+
"style": "display: flex;align-items: center;"
|
|
54
|
+
}, [slots.name ? slots.name() : createVNode("div", {
|
|
55
|
+
"style": "font-size: 14px;color: #000;"
|
|
56
|
+
}, [props.userInfo.realName]), props.userInfo.position && createVNode("div", {
|
|
57
|
+
"class": b("user-item-content-tag")
|
|
58
|
+
}, [props.userInfo.position], 2)]), createVNode("div", {
|
|
59
|
+
"style": {
|
|
60
|
+
fontSize: "12px",
|
|
61
|
+
color: "#8f959e",
|
|
62
|
+
lineHeight: "20px"
|
|
63
|
+
}
|
|
64
|
+
}, [props.userInfo.stageName])])]), props.isDelete && createVNode("div", {
|
|
65
|
+
"class": "select-user-item-icon",
|
|
66
|
+
"onClick": () => emit("delete-user", props.userInfo.id)
|
|
67
|
+
}, [createVNode(KIcon, {
|
|
68
|
+
"name": "shanchu",
|
|
69
|
+
"size": 12,
|
|
70
|
+
"color": "#2b2f36"
|
|
71
|
+
}, null)], 8, ["onClick"])], 2);
|
|
72
|
+
return () => {
|
|
73
|
+
let _slot;
|
|
74
|
+
return createVNode("div", {
|
|
75
|
+
"class": b("user-item")
|
|
76
|
+
}, [props.isChecked ? createVNode(Checkbox, {
|
|
77
|
+
"style": "margin: 0 6px;width: 100%;",
|
|
78
|
+
"checked": props.userInfo.checked,
|
|
79
|
+
"onUpdate:checked": ($event) => props.userInfo.checked = $event,
|
|
80
|
+
"onChange": handleChangeChecked
|
|
81
|
+
}, _isSlot(_slot = getUserInfo()) ? _slot : {
|
|
82
|
+
default: () => [_slot],
|
|
83
|
+
_: 1
|
|
84
|
+
}, 8, ["checked", "onUpdate:checked", "onChange"]) : createVNode("div", {
|
|
85
|
+
"style": "width: 100%;"
|
|
86
|
+
}, [getUserInfo()])], 2);
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
export {
|
|
91
|
+
User as default
|
|
92
|
+
};
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import { defineComponent, ref, watch, nextTick, createVNode, createTextVNode } from "vue";
|
|
2
|
+
import "../../index.mjs";
|
|
3
|
+
import { useNamespace } from "../../../hooks/use-namespace/index.mjs";
|
|
4
|
+
import { Input, Empty } from "ant-design-vue";
|
|
5
|
+
import OrgTree from "./components/org-tree.mjs";
|
|
6
|
+
import User from "./components/user.mjs";
|
|
7
|
+
import { KProModal } from "../../pro-modal/index.mjs";
|
|
8
|
+
import { KIcon } from "../../icon/index.mjs";
|
|
9
|
+
import { KUserAvatar } from "../../pro-user-avatar/index.mjs";
|
|
10
|
+
const {
|
|
11
|
+
b
|
|
12
|
+
} = useNamespace("pro-user-selector");
|
|
13
|
+
const ns = useNamespace("user-selector-extermal");
|
|
14
|
+
const ProUserSelector = /* @__PURE__ */ defineComponent({
|
|
15
|
+
name: "ProUserSelector",
|
|
16
|
+
props: {
|
|
17
|
+
visible: {
|
|
18
|
+
type: Boolean,
|
|
19
|
+
default: false
|
|
20
|
+
},
|
|
21
|
+
title: {
|
|
22
|
+
type: String,
|
|
23
|
+
default: ""
|
|
24
|
+
},
|
|
25
|
+
modelValue: {
|
|
26
|
+
type: Array,
|
|
27
|
+
default: () => []
|
|
28
|
+
},
|
|
29
|
+
maxCount: {
|
|
30
|
+
type: Number,
|
|
31
|
+
default: 25
|
|
32
|
+
},
|
|
33
|
+
/** @description 单选还是多选,默认多选,单选逻辑后续在实现,单选感觉不能使用当前的 UI 展示 */
|
|
34
|
+
type: {
|
|
35
|
+
type: String,
|
|
36
|
+
default: "checkbox"
|
|
37
|
+
},
|
|
38
|
+
load: {
|
|
39
|
+
type: Function,
|
|
40
|
+
default: () => Promise.resolve([])
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
emits: {
|
|
44
|
+
"update:visible": (visible) => true,
|
|
45
|
+
"update:modelValue": (modelValue) => true,
|
|
46
|
+
"delete-user": (id) => true,
|
|
47
|
+
"confirm": (modelValue) => true,
|
|
48
|
+
"cancel": () => true
|
|
49
|
+
},
|
|
50
|
+
setup(props, {
|
|
51
|
+
emit,
|
|
52
|
+
slots,
|
|
53
|
+
expose,
|
|
54
|
+
attrs
|
|
55
|
+
}) {
|
|
56
|
+
const searchValue = ref("");
|
|
57
|
+
const selectUserList = ref([]);
|
|
58
|
+
const orgTreeRef = ref();
|
|
59
|
+
const userListRef = ref(null);
|
|
60
|
+
const localModelValue = ref(props.modelValue || []);
|
|
61
|
+
const isInternalUpdate = ref(false);
|
|
62
|
+
watch(() => props.modelValue, (newValue) => {
|
|
63
|
+
if (isInternalUpdate.value) {
|
|
64
|
+
isInternalUpdate.value = false;
|
|
65
|
+
} else {
|
|
66
|
+
localModelValue.value = JSON.parse(JSON.stringify(newValue));
|
|
67
|
+
nextTick(() => {
|
|
68
|
+
handleExternalDataChange(localModelValue.value);
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
}, {
|
|
72
|
+
deep: true,
|
|
73
|
+
immediate: true
|
|
74
|
+
});
|
|
75
|
+
watch(selectUserList, (newVal, oldVal) => {
|
|
76
|
+
if (newVal.length > oldVal.length) {
|
|
77
|
+
nextTick(() => {
|
|
78
|
+
if (userListRef.value) {
|
|
79
|
+
userListRef.value.scrollTop = userListRef.value.scrollHeight;
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
}, {
|
|
84
|
+
deep: true
|
|
85
|
+
});
|
|
86
|
+
async function handleExternalDataChange(data) {
|
|
87
|
+
if (orgTreeRef.value) {
|
|
88
|
+
const orgData = await orgTreeRef.value.dataLoadPromise;
|
|
89
|
+
orgTreeRef.value.getInitData(data, orgData);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
const handleDeleteSelectUser = (id) => {
|
|
93
|
+
var _a;
|
|
94
|
+
selectUserList.value = selectUserList.value.filter((item) => item.id !== id);
|
|
95
|
+
(_a = orgTreeRef.value) == null ? void 0 : _a.deleteDeptUser(id);
|
|
96
|
+
};
|
|
97
|
+
const handleOpen = () => {
|
|
98
|
+
emit("update:visible", false);
|
|
99
|
+
emit("cancel");
|
|
100
|
+
};
|
|
101
|
+
const handleDelUser = (id) => {
|
|
102
|
+
emit("update:modelValue", props.modelValue.filter((user) => user.id !== id));
|
|
103
|
+
};
|
|
104
|
+
const handleConfirm = () => {
|
|
105
|
+
const list = selectUserList.value.map((item) => {
|
|
106
|
+
return {
|
|
107
|
+
id: item.id,
|
|
108
|
+
realName: item.realName || "",
|
|
109
|
+
avatar: item.avatar
|
|
110
|
+
};
|
|
111
|
+
});
|
|
112
|
+
emit("update:visible", false);
|
|
113
|
+
isInternalUpdate.value = true;
|
|
114
|
+
emit("update:modelValue", list);
|
|
115
|
+
emit("confirm", list);
|
|
116
|
+
};
|
|
117
|
+
expose({
|
|
118
|
+
deleteCheckedUser: handleDelUser
|
|
119
|
+
});
|
|
120
|
+
const renderModal = () => createVNode(KProModal, {
|
|
121
|
+
"modelValue": props.visible,
|
|
122
|
+
"title": "选择联系人",
|
|
123
|
+
"modalProps": {
|
|
124
|
+
cancelText: "取消",
|
|
125
|
+
okText: "确定",
|
|
126
|
+
...attrs
|
|
127
|
+
},
|
|
128
|
+
"onOnCancel": () => handleOpen(),
|
|
129
|
+
"onOnConfirm": () => handleConfirm()
|
|
130
|
+
}, {
|
|
131
|
+
default: () => [createVNode("div", {
|
|
132
|
+
"class": b()
|
|
133
|
+
}, [createVNode("div", {
|
|
134
|
+
"class": b("content-left")
|
|
135
|
+
}, [createVNode("div", {
|
|
136
|
+
"style": "padding: 16px 16px 0 16px"
|
|
137
|
+
}, [createVNode(Input, {
|
|
138
|
+
"value": searchValue.value,
|
|
139
|
+
"onUpdate:value": ($event) => searchValue.value = $event,
|
|
140
|
+
"size": "small",
|
|
141
|
+
"placeholder": "搜索",
|
|
142
|
+
"allowClear": true
|
|
143
|
+
}, {
|
|
144
|
+
prefix: () => createVNode(KIcon, {
|
|
145
|
+
"name": "search"
|
|
146
|
+
}, null),
|
|
147
|
+
_: 1
|
|
148
|
+
}, 8, ["value", "onUpdate:value", "allowClear"])]), createVNode(OrgTree, {
|
|
149
|
+
"ref": orgTreeRef,
|
|
150
|
+
"selectUserList": selectUserList.value,
|
|
151
|
+
"onUpdate:selectUserList": ($event) => selectUserList.value = $event,
|
|
152
|
+
"maxCount": props.maxCount,
|
|
153
|
+
"keyword": searchValue.value,
|
|
154
|
+
"initData": props.load
|
|
155
|
+
}, null, 8, ["selectUserList", "onUpdate:selectUserList", "maxCount", "keyword", "initData"])], 2), createVNode("div", {
|
|
156
|
+
"class": b("content-right")
|
|
157
|
+
}, [createVNode("div", {
|
|
158
|
+
"class": b("content-right-title")
|
|
159
|
+
}, [createTextVNode("已选:"), selectUserList.value.length, createTextVNode("/"), props.maxCount, createTextVNode("人")], 2), createVNode("div", {
|
|
160
|
+
"class": "select-user-list",
|
|
161
|
+
"ref": userListRef
|
|
162
|
+
}, [createVNode("div", {
|
|
163
|
+
"class": b("user-list")
|
|
164
|
+
}, [selectUserList.value.length > 0 ? selectUserList.value.map((item) => createVNode(User, {
|
|
165
|
+
"key": item.id,
|
|
166
|
+
"userInfo": item,
|
|
167
|
+
"isChecked": false,
|
|
168
|
+
"isDelete": true,
|
|
169
|
+
"onDelete-user": handleDeleteSelectUser
|
|
170
|
+
}, null, 8, ["userInfo", "isDelete", "onDelete-user"])) : createVNode(Empty, {
|
|
171
|
+
"image": Empty.PRESENTED_IMAGE_SIMPLE,
|
|
172
|
+
"description": "暂无数据"
|
|
173
|
+
}, null, 8, ["image"])], 2)], 512)], 2)], 2)]
|
|
174
|
+
}, 8, ["modelValue", "modalProps", "onOnCancel", "onOnConfirm"]);
|
|
175
|
+
const renderComponent = () => {
|
|
176
|
+
return createVNode("div", {
|
|
177
|
+
"class": ns.b()
|
|
178
|
+
}, [slots.default ? slots.default() : createVNode("div", {
|
|
179
|
+
"class": ns.b("list")
|
|
180
|
+
}, [createVNode("div", {
|
|
181
|
+
"class": ns.b("icon"),
|
|
182
|
+
"onClick": () => emit("update:visible", true)
|
|
183
|
+
}, [createVNode(KIcon, {
|
|
184
|
+
"name": "plus",
|
|
185
|
+
"size": 20,
|
|
186
|
+
"color": "#409eff"
|
|
187
|
+
}, null)], 10, ["onClick"]), props.modelValue.map((user) => {
|
|
188
|
+
return createVNode("div", {
|
|
189
|
+
"class": ns.b("item")
|
|
190
|
+
}, [createVNode(KUserAvatar, {
|
|
191
|
+
"name": user.realName,
|
|
192
|
+
"avatar": user.avatar,
|
|
193
|
+
"size": "small"
|
|
194
|
+
}, null, 8, ["name", "avatar"]), createVNode("span", {
|
|
195
|
+
"class": ns.be("item", "name")
|
|
196
|
+
}, [user.realName], 2), createVNode("div", {
|
|
197
|
+
"onClick": () => handleDelUser(user.id)
|
|
198
|
+
}, [createVNode(KIcon, {
|
|
199
|
+
"name": "shanchu",
|
|
200
|
+
"size": 18,
|
|
201
|
+
"color": "#646a73"
|
|
202
|
+
}, null)], 8, ["onClick"])], 2);
|
|
203
|
+
})], 2), renderModal()], 2);
|
|
204
|
+
};
|
|
205
|
+
return () => renderComponent();
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
export {
|
|
209
|
+
ProUserSelector as default
|
|
210
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|