@king-one/antdv 1.1.13 → 1.2.1
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 +18 -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
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
function debounce(func, wait) {
|
|
2
|
+
let timeout;
|
|
3
|
+
function debounced(...args) {
|
|
4
|
+
clearTimeout(timeout);
|
|
5
|
+
timeout = setTimeout(() => func.apply(this, args), wait);
|
|
6
|
+
}
|
|
7
|
+
debounced.cancel = function() {
|
|
8
|
+
clearTimeout(timeout);
|
|
9
|
+
};
|
|
10
|
+
return debounced;
|
|
11
|
+
}
|
|
12
|
+
function uniqueById(array) {
|
|
13
|
+
const seen = /* @__PURE__ */ new Map();
|
|
14
|
+
return array.filter((item) => {
|
|
15
|
+
if (!item || item.id === void 0)
|
|
16
|
+
return false;
|
|
17
|
+
return seen.has(item.id) ? false : (seen.set(item.id, true), true);
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
function formatOrgTree(orgTree) {
|
|
21
|
+
if (!orgTree || orgTree.length === 0)
|
|
22
|
+
return;
|
|
23
|
+
for (const dept of orgTree) {
|
|
24
|
+
if (dept.deptType === "department") {
|
|
25
|
+
dept.checkedUserIds = [];
|
|
26
|
+
}
|
|
27
|
+
if (dept.members && dept.members.length > 0) {
|
|
28
|
+
dept.members.forEach((member) => {
|
|
29
|
+
member.checked = false;
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
if (dept.children && dept.children.length > 0) {
|
|
33
|
+
formatOrgTree(dept.children);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
const orgTreeUtil = {
|
|
38
|
+
initOrgTree(data) {
|
|
39
|
+
formatOrgTree(data);
|
|
40
|
+
return data;
|
|
41
|
+
},
|
|
42
|
+
getChildrenByParentId: (parentId) => {
|
|
43
|
+
return [];
|
|
44
|
+
},
|
|
45
|
+
getDeptById: (id) => {
|
|
46
|
+
return {};
|
|
47
|
+
},
|
|
48
|
+
getDeptMemberById: (id) => {
|
|
49
|
+
return {};
|
|
50
|
+
},
|
|
51
|
+
setCheckedValue: (depts, id, flag) => {
|
|
52
|
+
for (const dept of depts) {
|
|
53
|
+
if (dept.members && dept.members.length > 0) {
|
|
54
|
+
dept.members.forEach((member) => {
|
|
55
|
+
member.checked = flag;
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
if (dept.children && dept.children.length > 0) {
|
|
59
|
+
orgTreeUtil.setCheckedValue(dept.children, id, flag);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
findMembersByIds(checkedIds, orgTree) {
|
|
64
|
+
const selectedMembers = [];
|
|
65
|
+
const idSet = /* @__PURE__ */ new Set();
|
|
66
|
+
function traverseTree(departments) {
|
|
67
|
+
if (!departments || departments.length === 0)
|
|
68
|
+
return;
|
|
69
|
+
for (const dept of departments) {
|
|
70
|
+
if (dept.members && dept.members.length > 0) {
|
|
71
|
+
const matchedMembers = dept.members.filter(
|
|
72
|
+
(member) => checkedIds.includes(member.id) && !idSet.has(member.id)
|
|
73
|
+
);
|
|
74
|
+
for (const member of matchedMembers) {
|
|
75
|
+
selectedMembers.push(member);
|
|
76
|
+
idSet.add(member.id);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
if (dept.children && dept.children.length > 0) {
|
|
80
|
+
traverseTree(dept.children);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
traverseTree(orgTree);
|
|
85
|
+
return selectedMembers;
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
export {
|
|
89
|
+
debounce,
|
|
90
|
+
formatOrgTree,
|
|
91
|
+
orgTreeUtil,
|
|
92
|
+
uniqueById
|
|
93
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
function useHttp(http) {
|
|
1
|
+
function useHttp(http, prefix) {
|
|
2
2
|
return {
|
|
3
3
|
// 获取文件上传的地址
|
|
4
|
-
getUploadUrl: (config) => http.get(
|
|
4
|
+
getUploadUrl: (config) => http.get(`${prefix}/file/aio/upload/url`, config),
|
|
5
5
|
// 文件上传
|
|
6
6
|
uploadFileApi: (url, config) => http.post(url, config, {
|
|
7
7
|
headers: {
|
|
@@ -9,13 +9,13 @@ function useHttp(http) {
|
|
|
9
9
|
}
|
|
10
10
|
}),
|
|
11
11
|
// 删除文件
|
|
12
|
-
deleteFileApi: (config) => http.delete(
|
|
12
|
+
deleteFileApi: (config) => http.delete(`${prefix}/file/aio`, config),
|
|
13
13
|
// 获取文件下载地址
|
|
14
|
-
getDownloadUrlApi: (config) => http.post(
|
|
14
|
+
getDownloadUrlApi: (config) => http.post(`${prefix}/file/aio/download/url`, config),
|
|
15
15
|
// 下载文件
|
|
16
16
|
downloadFileApi: (url, config) => http.get(url, config),
|
|
17
17
|
// 获取文件详情
|
|
18
|
-
getFileDetailApi: (config) => http.post(
|
|
18
|
+
getFileDetailApi: (config) => http.post(`${prefix}/aio/batch/info`, config)
|
|
19
19
|
};
|
|
20
20
|
}
|
|
21
21
|
export {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { message } from "ant-design-vue";
|
|
2
2
|
import { useHttp } from "./useHttp.mjs";
|
|
3
|
-
function useUpload(httpConfig) {
|
|
4
|
-
const http = useHttp(httpConfig);
|
|
3
|
+
function useUpload(httpConfig, prefix) {
|
|
4
|
+
const http = useHttp(httpConfig, prefix);
|
|
5
5
|
return {
|
|
6
6
|
// 文件上传
|
|
7
7
|
uploadFile: (config) => new Promise(async (resolve, reject) => {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { withInstall } from "@king-one/utils";
|
|
2
|
+
import "./src/index.vue.mjs";
|
|
3
|
+
import "./src/style/index.mjs";
|
|
4
|
+
import "./src/types.mjs";
|
|
5
|
+
import _sfc_main from "./src/index.vue2.mjs";
|
|
6
|
+
const KUserAvatar = withInstall(_sfc_main);
|
|
7
|
+
export {
|
|
8
|
+
KUserAvatar,
|
|
9
|
+
KUserAvatar as default
|
|
10
|
+
};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { defineComponent, ref, computed, createElementBlock, openBlock, normalizeClass, unref, normalizeStyle, toDisplayString } from "vue";
|
|
2
|
+
import { useNamespace } from "../../../hooks/use-namespace/index.mjs";
|
|
3
|
+
import { getColorFromString } from "./util.mjs";
|
|
4
|
+
const _hoisted_1 = ["src", "alt"];
|
|
5
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
6
|
+
...{
|
|
7
|
+
name: "ProUserAvatar"
|
|
8
|
+
},
|
|
9
|
+
__name: "index",
|
|
10
|
+
props: {
|
|
11
|
+
name: { default: "未知" },
|
|
12
|
+
avatar: {},
|
|
13
|
+
size: { default: "default" }
|
|
14
|
+
},
|
|
15
|
+
emits: ["error"],
|
|
16
|
+
setup(__props, { emit: __emit }) {
|
|
17
|
+
const props = __props;
|
|
18
|
+
const emit = __emit;
|
|
19
|
+
const ns = useNamespace("user-avatar");
|
|
20
|
+
const imgLoadError = ref(false);
|
|
21
|
+
const nameChars = computed(() => {
|
|
22
|
+
if (props.name.length >= 2) {
|
|
23
|
+
return props.name.slice(props.name.length - 2);
|
|
24
|
+
} else {
|
|
25
|
+
return props.name ? props.name : "未知";
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
function handleError(event) {
|
|
29
|
+
imgLoadError.value = true;
|
|
30
|
+
emit("error", event);
|
|
31
|
+
}
|
|
32
|
+
return (_ctx, _cache) => {
|
|
33
|
+
return openBlock(), createElementBlock(
|
|
34
|
+
"div",
|
|
35
|
+
{
|
|
36
|
+
class: normalizeClass([unref(ns).b(), unref(ns).b(_ctx.size)])
|
|
37
|
+
},
|
|
38
|
+
[
|
|
39
|
+
_ctx.avatar && !imgLoadError.value ? (openBlock(), createElementBlock("img", {
|
|
40
|
+
key: 0,
|
|
41
|
+
class: normalizeClass([unref(ns).e("img")]),
|
|
42
|
+
src: _ctx.avatar,
|
|
43
|
+
alt: _ctx.name,
|
|
44
|
+
loading: "lazy",
|
|
45
|
+
decoding: "async",
|
|
46
|
+
onError: handleError
|
|
47
|
+
}, null, 42, _hoisted_1)) : (openBlock(), createElementBlock(
|
|
48
|
+
"div",
|
|
49
|
+
{
|
|
50
|
+
key: 1,
|
|
51
|
+
class: normalizeClass([unref(ns).e("name")]),
|
|
52
|
+
style: normalizeStyle({
|
|
53
|
+
backgroundColor: unref(getColorFromString)(_ctx.name)
|
|
54
|
+
})
|
|
55
|
+
},
|
|
56
|
+
toDisplayString(nameChars.value),
|
|
57
|
+
7
|
|
58
|
+
/* TEXT, CLASS, STYLE */
|
|
59
|
+
))
|
|
60
|
+
],
|
|
61
|
+
2
|
|
62
|
+
/* CLASS */
|
|
63
|
+
);
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
export {
|
|
68
|
+
_sfc_main as default
|
|
69
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
function getColorFromString(str) {
|
|
2
|
+
if (!str)
|
|
3
|
+
return "#e1e1e1";
|
|
4
|
+
let hash = 0;
|
|
5
|
+
for (let i = 0; i < str.length; i++) {
|
|
6
|
+
hash = str.charCodeAt(i) + ((hash << 5) - hash);
|
|
7
|
+
}
|
|
8
|
+
const colors = [
|
|
9
|
+
"#3286fa",
|
|
10
|
+
"#f56a00",
|
|
11
|
+
"#7265e6",
|
|
12
|
+
"#ffbf00",
|
|
13
|
+
"#00a2ae",
|
|
14
|
+
"#1890ff",
|
|
15
|
+
"#52c41a",
|
|
16
|
+
"#faad14",
|
|
17
|
+
"#722ed1",
|
|
18
|
+
"#eb2f96",
|
|
19
|
+
"#fa8c16",
|
|
20
|
+
"#13c2c2",
|
|
21
|
+
"#fadb14"
|
|
22
|
+
];
|
|
23
|
+
const index = Math.abs(hash) % colors.length;
|
|
24
|
+
return colors[index];
|
|
25
|
+
}
|
|
26
|
+
export {
|
|
27
|
+
getColorFromString
|
|
28
|
+
};
|
package/dist/es/index.mjs
CHANGED
|
@@ -37,6 +37,9 @@ import { onSignConfirm, onSignInit, onSignSuccess } from "./components/pro-sign/
|
|
|
37
37
|
import { initProSign } from "./components/pro-sign/src/core/index.mjs";
|
|
38
38
|
import { useProSign } from "./components/pro-sign/src/hook/useProSign.mjs";
|
|
39
39
|
import { KProSign } from "./components/pro-sign/index.mjs";
|
|
40
|
+
import { useUserSelector } from "./components/pro-selector/src/hooks/useUserSelector.mjs";
|
|
41
|
+
import { default as default3 } from "./components/pro-selector/src/pro-user.mjs";
|
|
42
|
+
import { KUserAvatar } from "./components/pro-user-avatar/index.mjs";
|
|
40
43
|
import { useProForm, useProFormInit } from "./hooks/useProForm.mjs";
|
|
41
44
|
export {
|
|
42
45
|
CoverScrollbarProps,
|
|
@@ -60,10 +63,12 @@ export {
|
|
|
60
63
|
default2 as KProloading,
|
|
61
64
|
KScaleVirtualList,
|
|
62
65
|
KScrollBar,
|
|
66
|
+
KUserAvatar,
|
|
63
67
|
PickerApiEnum,
|
|
64
68
|
ProAreaProps,
|
|
65
69
|
ProPickerProps,
|
|
66
70
|
ProSignatureProps,
|
|
71
|
+
default3 as ProUserSelector,
|
|
67
72
|
TitleProps,
|
|
68
73
|
collapseProps,
|
|
69
74
|
plugin as default,
|
|
@@ -83,5 +88,6 @@ export {
|
|
|
83
88
|
useProModalInit,
|
|
84
89
|
useProSign,
|
|
85
90
|
useProTable,
|
|
86
|
-
useUpload
|
|
91
|
+
useUpload,
|
|
92
|
+
useUserSelector
|
|
87
93
|
};
|
|
@@ -19,6 +19,8 @@ require("./pro-loading/index.js");
|
|
|
19
19
|
const index$f = require("./plus-upload/index.js");
|
|
20
20
|
const index$g = require("./pro-overlay/index.js");
|
|
21
21
|
const index$h = require("./pro-sign/index.js");
|
|
22
|
+
require("./pro-selector/index.js");
|
|
23
|
+
const index$j = require("./pro-user-avatar/index.js");
|
|
22
24
|
exports.KForm = index.KForm;
|
|
23
25
|
exports.KFormItem = index.KFormItem;
|
|
24
26
|
exports.KCollapseTranstion = index$1.KCollapseTranstion;
|
|
@@ -38,3 +40,4 @@ exports.KProContractView = index$e.KProContractView;
|
|
|
38
40
|
exports.KPlusUpload = index$f.KPlusUpload;
|
|
39
41
|
exports.KProOverlay = index$g.KProOverlay;
|
|
40
42
|
exports.KProSign = index$h.KProSign;
|
|
43
|
+
exports.KUserAvatar = index$j.KUserAvatar;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const proUser = require("./src/pro-user.js");
|
|
4
|
+
require("./style/index.js");
|
|
5
|
+
require("./src/types.js");
|
|
6
|
+
require("./src/hooks/index.js");
|
|
7
|
+
proUser.default.GTE_ORGTREE_URL = "/security/dept/user/tree";
|
|
8
|
+
exports.ProUserSelector = proUser.default;
|
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
+
const vue = require("vue");
|
|
4
|
+
const index = require("../../../../hooks/use-namespace/index.js");
|
|
5
|
+
require("../../../index.js");
|
|
6
|
+
const antDesignVue = require("ant-design-vue");
|
|
7
|
+
const utils = require("@king-one/utils");
|
|
8
|
+
const orgTree = require("../utils/orgTree.js");
|
|
9
|
+
const user = require("./user.js");
|
|
10
|
+
const index$1 = require("../../../icon/index.js");
|
|
11
|
+
function _isSlot(s) {
|
|
12
|
+
return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !vue.isVNode(s);
|
|
13
|
+
}
|
|
14
|
+
const {
|
|
15
|
+
b
|
|
16
|
+
} = index.useNamespace("pro-user-selector");
|
|
17
|
+
const OrgTree = /* @__PURE__ */ vue.defineComponent({
|
|
18
|
+
name: "OrgTree",
|
|
19
|
+
props: {
|
|
20
|
+
selectUserList: {
|
|
21
|
+
type: Array,
|
|
22
|
+
default: () => []
|
|
23
|
+
},
|
|
24
|
+
initUserList: {
|
|
25
|
+
type: Array,
|
|
26
|
+
default: () => []
|
|
27
|
+
},
|
|
28
|
+
keyword: {
|
|
29
|
+
type: String,
|
|
30
|
+
default: ""
|
|
31
|
+
},
|
|
32
|
+
initData: {
|
|
33
|
+
type: Function,
|
|
34
|
+
default: () => Promise.resolve([])
|
|
35
|
+
},
|
|
36
|
+
maxCount: {
|
|
37
|
+
type: Number,
|
|
38
|
+
default: 25
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
emits: {
|
|
42
|
+
"update:selectUserList": (list) => list
|
|
43
|
+
},
|
|
44
|
+
setup(props, {
|
|
45
|
+
emit,
|
|
46
|
+
expose
|
|
47
|
+
}) {
|
|
48
|
+
const initData = vue.ref([]);
|
|
49
|
+
const currentViewDept = vue.ref({});
|
|
50
|
+
const breadCrumbList = vue.ref([]);
|
|
51
|
+
const currentBreadCrumbItem = vue.ref({});
|
|
52
|
+
const keywordUserList = vue.ref([]);
|
|
53
|
+
const isSearching = vue.ref(false);
|
|
54
|
+
const debouncedHandleKeywordChange = orgTree.debounce((keyword) => {
|
|
55
|
+
const list = [];
|
|
56
|
+
const loop = (data) => {
|
|
57
|
+
for (const item of data) {
|
|
58
|
+
if (item.members && item.members.length > 0) {
|
|
59
|
+
for (const member of item.members) {
|
|
60
|
+
if (member.realName.includes(keyword)) {
|
|
61
|
+
list.push(member);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
if (item.children && item.children.length > 0) {
|
|
66
|
+
loop(item.children);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
loop(initData.value);
|
|
71
|
+
keywordUserList.value = orgTree.uniqueById(list);
|
|
72
|
+
isSearching.value = keyword !== "";
|
|
73
|
+
}, 300);
|
|
74
|
+
vue.watch(() => props.keyword, (newVal, oldVal) => {
|
|
75
|
+
if (newVal === "") {
|
|
76
|
+
debouncedHandleKeywordChange.cancel();
|
|
77
|
+
isSearching.value = false;
|
|
78
|
+
keywordUserList.value = [];
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
if (newVal !== oldVal) {
|
|
82
|
+
debouncedHandleKeywordChange(newVal);
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
const deleteDeptUser = (id) => {
|
|
86
|
+
var _a;
|
|
87
|
+
(_a = currentViewDept.value.members) == null ? void 0 : _a.forEach((member) => {
|
|
88
|
+
if (member.id === id) {
|
|
89
|
+
member.checked = false;
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
keywordUserList.value = keywordUserList.value.map((item) => {
|
|
93
|
+
if (item.id === id) {
|
|
94
|
+
item.checked = false;
|
|
95
|
+
}
|
|
96
|
+
return item;
|
|
97
|
+
});
|
|
98
|
+
};
|
|
99
|
+
const handleChangeCheckedValue = (checked, info) => {
|
|
100
|
+
if (props.selectUserList.length === props.maxCount) {
|
|
101
|
+
info.checked = false;
|
|
102
|
+
antDesignVue.Modal.warning({
|
|
103
|
+
title: "温馨提示",
|
|
104
|
+
content: `最多只能选择${props.maxCount}个用户`
|
|
105
|
+
});
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
emit("update:selectUserList", checked ? [...props.selectUserList, info] : props.selectUserList.filter((item) => item.id !== info.id));
|
|
109
|
+
};
|
|
110
|
+
const handleClickOrgItem = (item) => {
|
|
111
|
+
var _a;
|
|
112
|
+
if (item.parentId === "root") {
|
|
113
|
+
breadCrumbList.value.push({
|
|
114
|
+
id: utils.uid(32),
|
|
115
|
+
deptName: "组织内联系人",
|
|
116
|
+
children: initData.value[0].children,
|
|
117
|
+
members: initData.value[0].members
|
|
118
|
+
});
|
|
119
|
+
} else {
|
|
120
|
+
breadCrumbList.value.push(item);
|
|
121
|
+
}
|
|
122
|
+
(_a = item.members) == null ? void 0 : _a.forEach((member) => {
|
|
123
|
+
member.checked = props.selectUserList.some((val) => val.id === member.id);
|
|
124
|
+
});
|
|
125
|
+
currentViewDept.value = item;
|
|
126
|
+
currentBreadCrumbItem.value = item;
|
|
127
|
+
};
|
|
128
|
+
const handleClickBreadCrumbItem = (item, _index) => {
|
|
129
|
+
var _a;
|
|
130
|
+
let dept = {};
|
|
131
|
+
if (currentBreadCrumbItem.value.id === item.id) {
|
|
132
|
+
console.log(`当前组织架构树展示的视图已经是《${item.deptName}》部门下面的数据`);
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
if (_index === 0) {
|
|
136
|
+
dept = {
|
|
137
|
+
children: initData.value
|
|
138
|
+
};
|
|
139
|
+
breadCrumbList.value = [{
|
|
140
|
+
id: utils.uid(32),
|
|
141
|
+
deptName: "联系人",
|
|
142
|
+
children: initData.value
|
|
143
|
+
}];
|
|
144
|
+
} else if (_index === 1) {
|
|
145
|
+
dept = initData.value[0];
|
|
146
|
+
breadCrumbList.value = breadCrumbList.value.slice(0, 2);
|
|
147
|
+
} else {
|
|
148
|
+
dept = item;
|
|
149
|
+
const index2 = breadCrumbList.value.findIndex((val) => val.id === item.id);
|
|
150
|
+
if (index2 !== -1) {
|
|
151
|
+
breadCrumbList.value = breadCrumbList.value.slice(0, index2 + 1);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
(_a = dept.members) == null ? void 0 : _a.forEach((member) => {
|
|
155
|
+
member.checked = props.selectUserList.some((val) => val.id === member.id);
|
|
156
|
+
});
|
|
157
|
+
currentViewDept.value = dept;
|
|
158
|
+
};
|
|
159
|
+
const getOrgTitle = (item) => {
|
|
160
|
+
return vue.createVNode(vue.Fragment, null, [vue.createVNode("div", {
|
|
161
|
+
"class": b("org-tree-item-title")
|
|
162
|
+
}, [item.parentId === "root" ? vue.createVNode(index$1.KIcon, {
|
|
163
|
+
"name": "zuzhijiagou",
|
|
164
|
+
"size": 18,
|
|
165
|
+
"color": "#00d6b9"
|
|
166
|
+
}, null) : vue.createVNode("div", {
|
|
167
|
+
"class": b("org-tree-dept-icon")
|
|
168
|
+
}, [vue.createVNode(index$1.KIcon, {
|
|
169
|
+
"name": "zuzhijiagou",
|
|
170
|
+
"size": 18,
|
|
171
|
+
"color": "#ffffff"
|
|
172
|
+
}, null)], 2), vue.createVNode("div", {
|
|
173
|
+
"class": b("org-tree-item-title-text")
|
|
174
|
+
}, [item.deptName, item.parentId !== "root" && vue.createVNode(vue.Fragment, null, [vue.createTextVNode("("), item.members && item.members.length > 0 ? item.members.length : 0, vue.createTextVNode(")")])], 2)], 2), item.parentId === "root" ? vue.createVNode(index$1.KIcon, {
|
|
175
|
+
"name": "right",
|
|
176
|
+
"size": 14,
|
|
177
|
+
"color": "#bbbfc4"
|
|
178
|
+
}, null) : vue.createVNode("a", {
|
|
179
|
+
"style": "width: 50px",
|
|
180
|
+
"href": "javascript:void(0)"
|
|
181
|
+
}, [vue.createTextVNode("下级")])]);
|
|
182
|
+
};
|
|
183
|
+
const getUserList = (objData) => {
|
|
184
|
+
var _a;
|
|
185
|
+
return vue.createVNode("div", {
|
|
186
|
+
"class": b("user-list")
|
|
187
|
+
}, [(_a = objData.members) == null ? void 0 : _a.map((member) => vue.createVNode(user.default, {
|
|
188
|
+
"userInfo": member,
|
|
189
|
+
"onChange-checked": handleChangeCheckedValue
|
|
190
|
+
}, null, 8, ["userInfo", "onChange-checked"]))], 2);
|
|
191
|
+
};
|
|
192
|
+
const getOrgElement = (objData) => {
|
|
193
|
+
if (objData.parentId === "root" && breadCrumbList.value.length === 1) {
|
|
194
|
+
return vue.createVNode("div", {
|
|
195
|
+
"class": b("org-tree-item"),
|
|
196
|
+
"onClick": () => handleClickOrgItem(objData)
|
|
197
|
+
}, [getOrgTitle(objData)], 10, ["onClick"]);
|
|
198
|
+
}
|
|
199
|
+
return vue.createVNode(vue.Fragment, null, [objData.children && objData.children.length > 0 ? objData.children.map((item) => vue.createVNode("div", {
|
|
200
|
+
"class": b("org-tree-item"),
|
|
201
|
+
"onClick": () => handleClickOrgItem(item)
|
|
202
|
+
}, [getOrgTitle(item)], 10, ["onClick"])) : null, getUserList(objData)]);
|
|
203
|
+
};
|
|
204
|
+
const getKeyordUserList = () => {
|
|
205
|
+
return vue.createVNode("div", {
|
|
206
|
+
"class": b("user-list")
|
|
207
|
+
}, [keywordUserList.value.length > 0 ? keywordUserList.value.map((member) => vue.createVNode(user.default, {
|
|
208
|
+
"userInfo": member,
|
|
209
|
+
"onChange-checked": handleChangeCheckedValue
|
|
210
|
+
}, {
|
|
211
|
+
name: () => vue.createVNode("div", {
|
|
212
|
+
"style": "font-size: 14px;color: #000;"
|
|
213
|
+
}, [(member == null ? void 0 : member.realName.includes(props.keyword)) ? member == null ? void 0 : member.realName.split(props.keyword).map((part, index2) => vue.createVNode(vue.Fragment, null, [part, index2 < (member == null ? void 0 : member.realName.split(props.keyword).length) - 1 && vue.createVNode("span", {
|
|
214
|
+
"style": "color: red;"
|
|
215
|
+
}, [props.keyword])])) : member == null ? void 0 : member.realName]),
|
|
216
|
+
_: 1
|
|
217
|
+
}, 8, ["userInfo", "onChange-checked"])) : vue.createVNode(antDesignVue.Empty, {
|
|
218
|
+
"description": "暂无数据"
|
|
219
|
+
}, null)], 2);
|
|
220
|
+
};
|
|
221
|
+
const loading = vue.ref(false);
|
|
222
|
+
let resolveDataLoaded;
|
|
223
|
+
const dataLoadPromise = new Promise((resolve) => {
|
|
224
|
+
resolveDataLoaded = resolve;
|
|
225
|
+
});
|
|
226
|
+
vue.onMounted(async () => {
|
|
227
|
+
try {
|
|
228
|
+
loading.value = true;
|
|
229
|
+
initData.value = await props.initData();
|
|
230
|
+
orgTree.formatOrgTree(initData.value);
|
|
231
|
+
loading.value = false;
|
|
232
|
+
resolveDataLoaded(initData.value);
|
|
233
|
+
currentViewDept.value = {
|
|
234
|
+
children: initData.value
|
|
235
|
+
};
|
|
236
|
+
breadCrumbList.value = [{
|
|
237
|
+
id: utils.uid(32),
|
|
238
|
+
deptName: "联系人",
|
|
239
|
+
children: initData.value
|
|
240
|
+
}];
|
|
241
|
+
handleClickOrgItem(initData.value[0]);
|
|
242
|
+
} finally {
|
|
243
|
+
loading.value = false;
|
|
244
|
+
}
|
|
245
|
+
});
|
|
246
|
+
const getInitData = (_initData, orgData) => {
|
|
247
|
+
const list = [];
|
|
248
|
+
const loop = (data) => {
|
|
249
|
+
for (const item of data) {
|
|
250
|
+
if (item.members && item.members.length > 0) {
|
|
251
|
+
for (const member of item.members) {
|
|
252
|
+
if (_initData.some((val) => val.id === member.id)) {
|
|
253
|
+
member.checked = true;
|
|
254
|
+
list.push(member);
|
|
255
|
+
} else {
|
|
256
|
+
member.checked = false;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
if (item.children && item.children.length > 0) {
|
|
261
|
+
loop(item.children);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
};
|
|
265
|
+
loop(orgData);
|
|
266
|
+
emit("update:selectUserList", orgTree.uniqueById(list));
|
|
267
|
+
};
|
|
268
|
+
expose({
|
|
269
|
+
deleteDeptUser,
|
|
270
|
+
getInitData,
|
|
271
|
+
dataLoadPromise
|
|
272
|
+
});
|
|
273
|
+
return () => {
|
|
274
|
+
let _slot;
|
|
275
|
+
return vue.createVNode(vue.Fragment, null, [vue.createVNode("div", {
|
|
276
|
+
"style": "padding:0 16px"
|
|
277
|
+
}, [breadCrumbList.value.length > 1 && !isSearching.value ? vue.createVNode(antDesignVue.Breadcrumb, {
|
|
278
|
+
"separator": ">",
|
|
279
|
+
"class": b("breadcrumb")
|
|
280
|
+
}, _isSlot(_slot = breadCrumbList.value.map((item, index2) => vue.createVNode(antDesignVue.BreadcrumbItem, {
|
|
281
|
+
"onClick": () => handleClickBreadCrumbItem(item, index2)
|
|
282
|
+
}, {
|
|
283
|
+
default: () => [index2 === breadCrumbList.value.length - 1 ? item.deptName : vue.createVNode("a", {
|
|
284
|
+
"href": "javascript:void(0)"
|
|
285
|
+
}, [item.deptName])]
|
|
286
|
+
}, 8, ["onClick"]))) ? _slot : {
|
|
287
|
+
default: () => [_slot],
|
|
288
|
+
_: 1
|
|
289
|
+
}, 8, ["class"]) : null]), !isSearching.value ? vue.createVNode("div", {
|
|
290
|
+
"class": b("org-tree")
|
|
291
|
+
}, [loading.value ? vue.createVNode("div", {
|
|
292
|
+
"class": b("org-tree-item"),
|
|
293
|
+
"style": "height: 200px;display: block;"
|
|
294
|
+
}, [vue.createVNode(antDesignVue.Skeleton, {
|
|
295
|
+
"active": true,
|
|
296
|
+
"avatar": true
|
|
297
|
+
}, null, 8, ["active", "avatar"]), vue.createVNode(antDesignVue.Skeleton, {
|
|
298
|
+
"active": true,
|
|
299
|
+
"avatar": true
|
|
300
|
+
}, null, 8, ["active", "avatar"])], 2) : getOrgElement(currentViewDept.value)], 2) : vue.createVNode(vue.Fragment, null, [getKeyordUserList()])]);
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
});
|
|
304
|
+
exports.default = OrgTree;
|