@king-one/antdv 2.6.0 → 2.6.2

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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # @king-one/antdv
2
2
 
3
+ ## 2.6.2
4
+
5
+ ### Patch Changes
6
+
7
+ - 解决角色选择器回显问题,根据 value 去匹配对应的 label
8
+
9
+ ## 2.6.1
10
+
11
+ ### Patch Changes
12
+
13
+ - 动态 tag 组件增加 size 属性
14
+
3
15
  ## 2.6.0
4
16
 
5
17
  ### Minor Changes
@@ -1,71 +1,72 @@
1
- import { defineComponent as H, ref as s, watch as k, createVNode as n, Fragment as J } from "vue";
2
- import { useNamespace as Q } from "../../../hooks/use-namespace/index.mjs";
1
+ import { defineComponent as X, ref as s, watch as E, computed as Y, createVNode as i, Fragment as Z } from "vue";
2
+ import { useNamespace as ee } from "../../../hooks/use-namespace/index.mjs";
3
3
  import "../../index.mjs";
4
- import { message as W, FormItemRest as X, InputSearch as Y, Tree as Z, Empty as C, Input as ee } from "ant-design-vue";
5
- import { GET_DEPT_TREE_URL as le, deptSelectorEmits as te, deptSelectorProps as ae } from "./types.mjs";
6
- import { KProModal as ne } from "../../pro-modal/index.mjs";
7
- import { KIcon as P } from "../../icon/index.mjs";
8
- const h = Q("dept-selector"), ve = /* @__PURE__ */ H({
4
+ import { message as le, FormItemRest as te, InputSearch as ae, Tree as ne, Empty as C } from "ant-design-vue";
5
+ import { GET_DEPT_TREE_URL as ue, deptSelectorEmits as ie, deptSelectorProps as de } from "./types.mjs";
6
+ import { KProModal as ce } from "../../pro-modal/index.mjs";
7
+ import { KIcon as V } from "../../icon/index.mjs";
8
+ import { KProDynamicTags as re } from "../../pro-dynamic-tags/index.mjs";
9
+ const h = ee("dept-selector"), ke = /* @__PURE__ */ X({
9
10
  name: "KDeptSelector",
10
- props: ae,
11
- emits: te,
12
- setup(t, {
11
+ props: de,
12
+ emits: ie,
13
+ setup(a, {
13
14
  emit: f,
14
- attrs: V,
15
- slots: E
15
+ attrs: R,
16
+ slots: x
16
17
  }) {
17
- const x = s(!0), I = s(!0), m = s([]), y = s([]), d = s([]), A = s(!1), u = s(t.isBuiltInRequest ? {
18
+ const S = s(!0), N = s(!0), m = s([]), y = s([]), r = s([]), _ = s(!1), t = s(a.isBuiltInRequest ? {
18
19
  children: "children",
19
20
  title: "deptName",
20
21
  key: "id"
21
- } : t.fieldNames), S = s(""), r = s([]), v = s(t.treeData), g = s(!1), p = s("");
22
- if (t.isBuiltInRequest) {
23
- if (!t.http)
22
+ } : a.fieldNames), A = s(""), o = s([]), p = s([]), v = s(a.treeData), k = s(!1), g = s("");
23
+ if (a.isBuiltInRequest) {
24
+ if (!a.http)
24
25
  throw new Error("请传入http实例");
25
- t.http.get(`${t.prefix}${le}`).then((e) => {
26
+ a.http.get(`${a.prefix}${ue}`).then((e) => {
26
27
  e.status === 0 && (v.value = e.data, e.data && e.data.length > 0 && (m.value = [e.data[0].id]));
27
28
  });
28
29
  }
29
30
  const w = () => {
30
- if (t.type === "checkbox") {
31
- if (!Array.isArray(t.modelValue)) return;
32
- const e = t.modelValue.map((l) => l[u.value.key]);
33
- x.value ? d.value = {
31
+ if (a.type === "checkbox") {
32
+ if (!Array.isArray(a.modelValue)) return;
33
+ const e = a.modelValue.map((l) => l[t.value.key]);
34
+ S.value ? r.value = {
34
35
  checked: e,
35
36
  halfChecked: []
36
- } : d.value = e, m.value = e;
37
+ } : r.value = e, m.value = e;
37
38
  } else {
38
- if (Array.isArray(t.modelValue)) return;
39
- const e = t.modelValue[u.value.key];
39
+ if (Array.isArray(a.modelValue)) return;
40
+ const e = a.modelValue[t.value.key];
40
41
  y.value = [e], m.value = [e];
41
42
  }
42
- }, N = (e) => {
43
- if (g.value)
44
- return g.value = !1;
45
- t.type === "radio" ? r.value.length > 0 && (S.value = r.value[0][u.value.title] || "") : S.value = r.value.map((l) => l[u.value.title]).join(",");
43
+ }, D = (e) => {
44
+ if (k.value)
45
+ return k.value = !1;
46
+ a.type === "radio" ? o.value.length > 0 && (A.value = o.value[0][t.value.title] || "") : A.value = o.value.map((l) => l[t.value.title]).join(",");
46
47
  };
47
- k(() => t.visible, () => {
48
- t.visible && w();
48
+ E(() => a.visible, () => {
49
+ a.visible && w();
49
50
  }, {
50
51
  immediate: !0
51
- }), k(() => t.modelValue, () => {
52
- v.value.length > 0 && w();
52
+ }), E(() => a.modelValue, (e) => {
53
+ v.value.length > 0 && w(), k.value || (Array.isArray(e) ? p.value = [...e] : e ? p.value = [e] : p.value = []);
53
54
  }, {
54
55
  immediate: !0,
55
56
  deep: !0
56
- }), k(v, () => {
57
+ }), E(v, () => {
57
58
  v.value.length > 0 && w();
58
59
  }, {
59
60
  immediate: !0,
60
61
  deep: !0
61
62
  });
62
- function R(e) {
63
- const l = (i, o) => {
64
- for (const a of i) {
65
- if (a[u.value.key] === o)
66
- return a;
67
- if (a.children && a.children.length) {
68
- const c = l(a.children, o);
63
+ function U(e) {
64
+ const l = (u, d) => {
65
+ for (const n of u) {
66
+ if (n[t.value.key] === d)
67
+ return n;
68
+ if (n.children && n.children.length) {
69
+ const c = l(n.children, d);
69
70
  if (c) return c;
70
71
  }
71
72
  }
@@ -73,197 +74,200 @@ const h = Q("dept-selector"), ve = /* @__PURE__ */ H({
73
74
  };
74
75
  return l(v.value, e);
75
76
  }
76
- function D(e) {
77
- return e ? e.map((l) => R(l)).filter(Boolean) : [];
77
+ function I(e) {
78
+ return e ? e.map((l) => U(l)).filter(Boolean) : [];
78
79
  }
79
- k(d, () => {
80
- t.type === "checkbox" && (x.value ? r.value = D(d.value.checked) : r.value = D(d.value), N("watch checkedKeys..."));
80
+ E(r, () => {
81
+ a.type === "checkbox" && (S.value ? o.value = I(r.value.checked) : o.value = I(r.value), D("watch checkedKeys..."));
81
82
  }, {
82
83
  immediate: !0,
83
84
  deep: !0
84
- }), k(y, () => {
85
- t.type === "radio" && (r.value = D(y.value), N("watch selectedKeys..."));
85
+ }), E(y, () => {
86
+ a.type === "radio" && (o.value = I(y.value), D("watch selectedKeys..."));
86
87
  }, {
87
88
  immediate: !0,
88
89
  deep: !0
89
- }), k(() => t.treeData, () => {
90
- t.isBuiltInRequest || (v.value = t.treeData);
90
+ }), E(() => a.treeData, () => {
91
+ a.isBuiltInRequest || (v.value = a.treeData);
91
92
  });
92
- const _ = () => {
93
- g.value = !0;
93
+ const O = () => {
94
+ k.value = !0;
94
95
  }, B = () => {
95
- g.value = !0;
96
- }, O = () => {
96
+ k.value = !0;
97
+ }, M = () => {
97
98
  f("update:visible", !1), f("cancel");
98
99
  }, F = () => {
99
- if (!r.value.length) {
100
- W.warn("请选择部门");
100
+ if (!o.value.length) {
101
+ le.warn("请选择部门");
101
102
  return;
102
103
  }
103
- t.type === "radio" ? f("update:modelValue", {
104
- [u.value.key]: y.value[0],
105
- [u.value.title]: r.value[0][u.value.title]
106
- }) : f("update:modelValue", r.value.map((e) => ({
107
- [u.value.key]: e[u.value.key],
108
- [u.value.title]: e[u.value.title]
109
- }))), f("update:visible", !1), f("confirm", r.value), N("handleConfirm ...");
110
- }, M = (e) => {
111
- if (g.value = !0, t.type === "radio")
112
- return r.value = [], y.value = [], !1;
113
- if (x.value)
114
- d.value.checked = d.value.checked.filter((l) => l !== e[u.value.key]);
104
+ p.value = [...o.value], a.type === "radio" ? f("update:modelValue", {
105
+ [t.value.key]: y.value[0],
106
+ [t.value.title]: o.value[0][t.value.title]
107
+ }) : f("update:modelValue", o.value.map((e) => ({
108
+ [t.value.key]: e[t.value.key],
109
+ [t.value.title]: e[t.value.title]
110
+ }))), f("update:visible", !1), f("confirm", o.value), D("handleConfirm ...");
111
+ }, L = (e) => {
112
+ if (k.value = !0, a.type === "radio")
113
+ return o.value = [], y.value = [], !1;
114
+ if (S.value)
115
+ r.value.checked = r.value.checked.filter((l) => l !== e[t.value.key]);
115
116
  else {
116
- const l = e.parentId, i = d.value.indexOf(l);
117
- i !== -1 && d.value.splice(i, 1), d.value = d.value.filter((a) => a !== e[u.value.key]), L(e.children).forEach((a) => {
118
- const c = d.value.indexOf(a);
119
- c !== -1 && d.value.splice(c, 1);
117
+ const l = e.parentId, u = r.value.indexOf(l);
118
+ u !== -1 && r.value.splice(u, 1), r.value = r.value.filter((n) => n !== e[t.value.key]), q(e.children).forEach((n) => {
119
+ const c = r.value.indexOf(n);
120
+ c !== -1 && r.value.splice(c, 1);
120
121
  });
121
122
  }
122
- }, L = (e) => {
123
- const l = [], i = (o) => {
124
- for (const a of o)
125
- l.push(a[u.value.key]), a.children && a.children.length && i(a.children);
123
+ }, q = (e) => {
124
+ const l = [], u = (d) => {
125
+ for (const n of d)
126
+ l.push(n[t.value.key]), n.children && n.children.length && u(n.children);
126
127
  };
127
- return i(e), l;
128
- }, q = () => n(J, null, [n(ne, {
129
- modelValue: t.visible,
128
+ return u(e), l;
129
+ }, G = Y(() => p.value.map((e) => ({
130
+ label: e[t.value.title],
131
+ value: e[t.value.key],
132
+ closable: !0
133
+ }))), z = (e, l) => {
134
+ const u = p.value.filter((d, n) => n !== l);
135
+ p.value = u, a.type === "radio" ? f("update:modelValue", null) : f("update:modelValue", u.map((d) => ({
136
+ [t.value.key]: d[t.value.key],
137
+ [t.value.title]: d[t.value.title]
138
+ })));
139
+ }, $ = () => {
140
+ f("update:visible", !0);
141
+ }, j = () => i(Z, null, [i(ce, {
142
+ modelValue: a.visible,
130
143
  modalProps: {
131
144
  cancelText: "取消",
132
145
  okText: "确定",
133
146
  width: "700px",
134
- ...V
147
+ ...R
135
148
  },
136
149
  title: "选择部门",
137
- onOnCancel: O,
150
+ onOnCancel: M,
138
151
  onOnConfirm: F
139
152
  }, {
140
- default: () => [n("div", {
153
+ default: () => [i("div", {
141
154
  class: h.e("modal-content")
142
- }, [$(), j()], 2)]
143
- }, 8, ["modelValue", "modalProps", "onOnCancel", "onOnConfirm"])]), K = (e, l) => {
144
- let i;
145
- for (let o = 0; o < l.length; o++) {
146
- const a = l[o];
147
- if (a.children)
148
- if (a.children.some((c) => c[u.value.key] === e)) {
149
- i = a[u.value.key];
155
+ }, [Q(), W()], 2)]
156
+ }, 8, ["modelValue", "modalProps", "onOnCancel", "onOnConfirm"])]), b = (e, l) => {
157
+ let u;
158
+ for (let d = 0; d < l.length; d++) {
159
+ const n = l[d];
160
+ if (n.children)
161
+ if (n.children.some((c) => c[t.value.key] === e)) {
162
+ u = n[t.value.key];
150
163
  break;
151
- } else K(e, a.children) && (i = K(e, a.children));
164
+ } else b(e, n.children) && (u = b(e, n.children));
152
165
  }
153
- return i;
154
- }, z = (e) => {
166
+ return u;
167
+ }, H = (e) => {
155
168
  if (!e.trim()) {
156
- m.value = [], p.value = "", I.value = !0;
169
+ m.value = [], g.value = "", N.value = !0;
157
170
  return;
158
171
  }
159
- const l = /* @__PURE__ */ new Set(), i = (o, a) => {
160
- o.forEach((c) => {
161
- var U;
162
- if ((U = c[u.value.title]) != null && U.includes(a)) {
163
- let b = K(c[u.value.key], v.value);
164
- for (; b; )
165
- l.add(b), b = K(b, v.value);
166
- l.add(c[u.value.key]);
172
+ const l = /* @__PURE__ */ new Set(), u = (d, n) => {
173
+ d.forEach((c) => {
174
+ var P;
175
+ if ((P = c[t.value.title]) != null && P.includes(n)) {
176
+ let K = b(c[t.value.key], v.value);
177
+ for (; K; )
178
+ l.add(K), K = b(K, v.value);
179
+ l.add(c[t.value.key]);
167
180
  }
168
- c.children && c.children.length > 0 && i(c.children, a);
181
+ c.children && c.children.length > 0 && u(c.children, n);
169
182
  });
170
183
  };
171
- i(v.value, e), m.value = Array.from(l), p.value = e, I.value = !0;
172
- }, G = (e) => {
173
- const l = e[u.value.title] || "";
174
- if (!p.value)
175
- return n("span", null, [l]);
176
- const i = l.indexOf(p.value);
177
- if (i === -1)
178
- return n("span", null, [l]);
179
- const o = l.substring(0, i), a = l.substring(i, i + p.value.length), c = l.substring(i + p.value.length);
180
- return n("span", null, [o, n("span", {
184
+ u(v.value, e), m.value = Array.from(l), g.value = e, N.value = !0;
185
+ }, J = (e) => {
186
+ const l = e[t.value.title] || "";
187
+ if (!g.value)
188
+ return i("span", null, [l]);
189
+ const u = l.indexOf(g.value);
190
+ if (u === -1)
191
+ return i("span", null, [l]);
192
+ const d = l.substring(0, u), n = l.substring(u, u + g.value.length), c = l.substring(u + g.value.length);
193
+ return i("span", null, [d, i("span", {
181
194
  style: "color: #f50; font-weight: bold"
182
- }, [a]), c]);
183
- }, $ = () => n("div", {
195
+ }, [n]), c]);
196
+ }, Q = () => i("div", {
184
197
  class: h.e("modal-content-left")
185
- }, [n(X, null, {
186
- default: () => [n(Y, {
198
+ }, [i(te, null, {
199
+ default: () => [i(ae, {
187
200
  placeholder: "请输入部门名称",
188
- onSearch: z,
201
+ onSearch: H,
189
202
  style: {
190
203
  marginBottom: "10px"
191
204
  },
192
205
  allowClear: !0
193
206
  }, null, 8, ["onSearch", "allowClear"])]
194
- }), v.value.length > 0 ? n(Z, {
207
+ }), v.value.length > 0 ? i(ne, {
195
208
  expandedKeys: m.value,
196
209
  "onUpdate:expandedKeys": (e) => m.value = e,
197
210
  selectedKeys: y.value,
198
211
  "onUpdate:selectedKeys": (e) => y.value = e,
199
- checkedKeys: d.value,
200
- "onUpdate:checkedKeys": (e) => d.value = e,
201
- checkable: t.type === "checkbox",
202
- checkStrictly: x.value,
212
+ checkedKeys: r.value,
213
+ "onUpdate:checkedKeys": (e) => r.value = e,
214
+ checkable: a.type === "checkbox",
215
+ checkStrictly: S.value,
203
216
  "show-icon": !0,
204
- autoExpandParent: I.value,
217
+ autoExpandParent: N.value,
205
218
  blockNode: !0,
206
219
  defaultExpandAll: !0,
207
- fieldNames: u.value,
208
- "show-line": A.value,
220
+ fieldNames: t.value,
221
+ "show-line": _.value,
209
222
  "tree-data": v.value,
210
- onCheck: _,
223
+ onCheck: O,
211
224
  onSelect: B,
212
225
  class: h.e("modal-content-left-tree")
213
226
  }, {
214
227
  icon: (e) => T(e),
215
- title: G,
228
+ title: J,
216
229
  _: 1
217
- }, 8, ["expandedKeys", "onUpdate:expandedKeys", "selectedKeys", "onUpdate:selectedKeys", "checkedKeys", "onUpdate:checkedKeys", "checkable", "checkStrictly", "show-icon", "autoExpandParent", "blockNode", "defaultExpandAll", "fieldNames", "show-line", "tree-data", "onCheck", "onSelect", "class"]) : n(C, {
230
+ }, 8, ["expandedKeys", "onUpdate:expandedKeys", "selectedKeys", "onUpdate:selectedKeys", "checkedKeys", "onUpdate:checkedKeys", "checkable", "checkStrictly", "show-icon", "autoExpandParent", "blockNode", "defaultExpandAll", "fieldNames", "show-line", "tree-data", "onCheck", "onSelect", "class"]) : i(C, {
218
231
  description: "暂无数据",
219
232
  image: C.PRESENTED_IMAGE_SIMPLE
220
- }, null, 8, ["image"])], 2), T = (e) => n(P, {
233
+ }, null, 8, ["image"])], 2), T = (e) => i(V, {
221
234
  name: e.parentId === "0" ? "qiye" : "bumen",
222
235
  size: 16
223
- }, null, 8, ["name"]), j = () => n("div", {
236
+ }, null, 8, ["name"]), W = () => i("div", {
224
237
  class: h.e("modal-content-right")
225
- }, [r.value.length > 0 ? r.value.map((e) => n("div", {
238
+ }, [o.value.length > 0 ? o.value.map((e) => i("div", {
226
239
  class: h.e("modal-content-right-item")
227
- }, [n("div", {
240
+ }, [i("div", {
228
241
  class: h.e("modal-content-right-item-label")
229
- }, [T(e), n("span", null, [e[u.value.title]])], 2), n("div", {
242
+ }, [T(e), i("span", null, [e[t.value.title]])], 2), i("div", {
230
243
  class: h.e("modal-content-right-item-del"),
231
- onClick: () => M(e)
232
- }, [n(P, {
244
+ onClick: () => L(e)
245
+ }, [i(V, {
233
246
  name: "shanchu",
234
247
  size: 16
235
- }, null)], 10, ["onClick"])], 2)) : n(C, {
248
+ }, null)], 10, ["onClick"])], 2)) : i(C, {
236
249
  description: "暂无数据",
237
250
  image: C.PRESENTED_IMAGE_SIMPLE
238
251
  }, null, 8, ["image"])], 2);
239
252
  return () => {
240
253
  var e;
241
- return n("div", {
254
+ return i("div", {
242
255
  class: h.b()
243
- }, [t.hideSlot ? null : (e = E.default) != null && e.call(E) ? E.default() : n("div", null, [n(ee, {
244
- style: "width: 100%;height: 30px;",
245
- readonly: !0,
246
- value: S.value,
247
- "onUpdate:value": (l) => S.value = l,
248
- onInput: () => {
249
- },
250
- placeholder: "请选择部门"
251
- }, {
252
- suffix: () => n("div", {
253
- onClick: () => f("update:visible", !0)
254
- }, [n(P, {
255
- style: {
256
- cursor: "pointer"
257
- },
258
- name: "bumen",
259
- size: 14,
260
- color: "#606266"
261
- }, null)], 8, ["onClick"]),
262
- _: 1
263
- }, 8, ["readonly", "value", "onUpdate:value", "onInput"])]), q()], 2);
256
+ }, [a.hideSlot ? null : (e = x.default) != null && e.call(x) ? x.default() : i("div", null, [i(re, {
257
+ modelValue: G.value,
258
+ showAdd: !0,
259
+ addText: "选择部门",
260
+ closable: !0,
261
+ onClose: z,
262
+ onAdd: $,
263
+ customStyle: {
264
+ width: "100%",
265
+ minHeight: "30px"
266
+ }
267
+ }, null, 8, ["modelValue", "onClose", "onAdd"])]), j()], 2);
264
268
  };
265
269
  }
266
270
  });
267
271
  export {
268
- ve as default
272
+ ke as default
269
273
  };
@@ -1,7 +1,7 @@
1
1
  import o from "./index.vue2.mjs";
2
2
  import "./index.vue3.mjs";
3
- import r from "../../../_virtual/_plugin-vue_export-helper.mjs";
4
- const p = /* @__PURE__ */ r(o, [["__scopeId", "data-v-60156660"]]);
3
+ import c from "../../../_virtual/_plugin-vue_export-helper.mjs";
4
+ const m = /* @__PURE__ */ c(o, [["__scopeId", "data-v-c1cc89fd"]]);
5
5
  export {
6
- p as default
6
+ m as default
7
7
  };