yahee-components 0.0.102 → 0.0.103

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.
@@ -1,226 +1,7 @@
1
- import { defineComponent as se, ref as g, reactive as _, toRefs as ae, watch as ce, onMounted as re, createElementBlock as i, openBlock as a, createVNode as W, unref as u, normalizeStyle as R, withCtx as d, createTextVNode as k, createCommentVNode as N, toDisplayString as v, createElementVNode as E, Fragment as b, renderList as z, createBlock as y } from "vue";
2
- import s from "../_virtual/lodash.js";
3
- import { stylesUtils as U } from "../utils/style.js";
4
- import { storage as G } from "../utils/storage.js";
5
- import { M2 as x } from "../utils/translate.js";
6
- import { ElButton as P, ElDropdown as ie, ElCheckboxGroup as Y, ElCheckbox as j } from "element-plus";
7
- import "element-plus/theme-chalk/src/base.scss";
8
- import "element-plus/theme-chalk/src/button.scss";
9
- import "element-plus/theme-chalk/src/checkbox.scss";
10
- import "element-plus/theme-chalk/src/checkbox-group.scss";
11
- import "element-plus/theme-chalk/src/button-group.scss";
12
- import "element-plus/theme-chalk/src/popper.scss";
13
- import "element-plus/theme-chalk/src/scrollbar.scss";
14
- import "element-plus/theme-chalk/src/dropdown.scss";
15
- const de = { class: "yahee-drop-down-condition" }, ve = { key: 0 }, fe = { style: { display: "flex", "align-items": "center", outline: "none" } }, pe = { key: 0 }, he = { style: { display: "flex", width: "auto", padding: "10px" } }, me = ["onClick"], ge = { class: "scrollable-container" }, ye = { key: 0 }, Ae = /* @__PURE__ */ se({
16
- name: "YaheeDropDownCondition",
17
- __name: "drop-down-condition",
18
- props: {
19
- filterList: {},
20
- totalCount: {},
21
- level1Count: {},
22
- level2Count: {},
23
- filterKey: {},
24
- enumEntity: {},
25
- noNeedRefreshNumFilterName: {},
26
- initFilters: { type: Function }
27
- },
28
- emits: ["filterChange", "setNoNeedRefreshNumFilterName"],
29
- setup(H, { emit: J }) {
30
- const Q = g(), n = _({});
31
- let K = _({});
32
- const r = _({}), p = _({}), h = g(!0), m = H, $ = J, { filterKey: w, filterList: M, totalCount: C, level1Count: V, level2Count: F, noNeedRefreshNumFilterName: O } = ae(m), T = g(s.get(C, "value", 0)), S = g(s.get(V, "value", [])), B = g(s.get(F, "value", [])), c = g();
33
- M.value && (c.value = [...M.value]);
34
- function q(t) {
35
- const { text: o, value: e } = t, l = n[o];
36
- s.isNil(l) || s.isEmpty(l) ? n[o] = [e] : n[o] = [], p[o] = !p[o], p[o] ? (oe(o), r[o] = U.getBackgroundColor(!0), h.value = !1) : (ne(o), r[t.text] = {}, h.value = !0), h.value = L(), D();
37
- }
38
- function L() {
39
- const t = c.value.filter((l) => !s.isEmpty(l.subs)).flatMap((l) => l.subs).length, o = c.value.filter((l) => s.isEmpty(l.subs)).length;
40
- return Object.values(n).map((l) => l.length).reduce((l, f) => l + f, 0) === t + o || s.isEmpty(Object.values(n).flat());
41
- }
42
- function X(t) {
43
- s.isEmpty(n[t.text]) ? (r[t.text] = {}, p[t.text] = !1) : n[t.text].length === s.get(t, "subs.length", 1) ? (r[t.text] = U.getBackgroundColor(!0), p[t.text] = !0) : r[t.text] = {
44
- backgroundColor: "#0F7535",
45
- color: "#fff",
46
- borderColor: "#0F7535"
47
- }, h.value = L(), D();
48
- }
49
- function Z() {
50
- h.value = L(), D();
51
- }
52
- function D() {
53
- $("setNoNeedRefreshNumFilterName", w.value);
54
- }
55
- function ee() {
56
- h.value = !0;
57
- for (const t in r)
58
- r[t] = {};
59
- for (const t in n)
60
- delete n[t];
61
- for (const t in p)
62
- delete p[t];
63
- I();
64
- }
65
- const te = (t) => U.getBackgroundColor(t);
66
- function le(t) {
67
- if (t)
68
- K = s.cloneDeep(n);
69
- else {
70
- if (s.isEqual(K, n))
71
- return;
72
- I();
73
- }
74
- }
75
- function I() {
76
- $("filterChange", [
77
- {
78
- filterKey: w.value,
79
- checkedValues: Object.values(n).flat()
80
- }
81
- ]);
82
- }
83
- function oe(t) {
84
- const o = c.value.find((e) => e.text === t);
85
- o && o.subs && (n[t] = o.subs.map((e) => e.value));
86
- }
87
- function ne(t) {
88
- n[t] = [];
89
- }
90
- function ue() {
91
- var e;
92
- const t = `filter-key-${m.enumEntity}`, o = G.getWithExpireTime(t);
93
- o ? c.value = o : (console.log(m.enumEntity), (e = m == null ? void 0 : m.initFilters(m.enumEntity)) == null || e.then((l) => {
94
- console.log(l), c.value = l.data, G.setWithExpireTime(t, c.value, 1200 * 1e3), console.log(c.value);
95
- }).catch((l) => {
96
- console.log(l);
97
- }));
98
- }
99
- return ce(
100
- [() => C.value, () => V.value, () => F.value],
101
- ([t, o, e], [l, f, A]) => {
102
- console.log(t, o, e), console.log(l, f, A), (!O.value || !s.eq(O.value, w.value)) && (T.value = C.value, S.value = V.value, B.value = F.value);
103
- }
104
- ), re(() => {
105
- ue();
106
- }), (t, o) => (a(), i("div", de, [
107
- W(u(P), {
108
- size: "small",
109
- class: "el-button el-button--small custom-total-button",
110
- style: R(te(h.value)),
111
- onClick: ee
112
- }, {
113
- default: d(() => [
114
- k(v(u(x)("全部")) + " ", 1),
115
- u(C) ? (a(), i("span", ve, "(" + v(T.value) + ")", 1)) : N("", !0)
116
- ]),
117
- _: 1
118
- }, 8, ["style"]),
119
- W(u(ie), {
120
- ref_key: "dropdown1",
121
- ref: Q,
122
- "popper-class": "custom-dropdown",
123
- onVisibleChange: le
124
- }, {
125
- dropdown: d(() => [
126
- E("div", he, [
127
- (a(!0), i(b, null, z(c.value, (e) => (a(), y(u(Y), {
128
- key: e.value,
129
- modelValue: n[e.text],
130
- "onUpdate:modelValue": (l) => n[e.text] = l,
131
- size: "small",
132
- class: "checkbox-group inner-checkbox-group custom-dropdown-checkbox-group",
133
- onChange: (l) => X(e)
134
- }, {
135
- default: d(() => [
136
- u(s).isNil(e.subs) ? (a(), y(u(j), {
137
- key: 1,
138
- value: e.value,
139
- class: "checkbox custom-dropdown-button",
140
- border: ""
141
- }, {
142
- default: d(() => [
143
- k(v(u(x)(e.text)), 1)
144
- ]),
145
- _: 2
146
- }, 1032, ["value"])) : (a(), i(b, { key: 0 }, [
147
- E("span", {
148
- class: "el-button custom-dropdown-button el-button--small inner-el-button",
149
- style: R(r[e.text]),
150
- onClick: (l) => q(e)
151
- }, v(u(x)(e.text)), 13, me),
152
- E("div", ge, [
153
- (a(!0), i(b, null, z(e.subs, (l) => (a(), y(u(j), {
154
- key: l.value,
155
- class: "checkbox custom-dropdown-button",
156
- value: l.value,
157
- border: ""
158
- }, {
159
- default: d(() => {
160
- var f;
161
- return [
162
- k(v(u(x)(l.text)), 1),
163
- u(s).isEmpty(B.value) ? N("", !0) : (a(), i("span", ye, "(" + v((f = B.value.filter((A) => A.value == l.value)[0]) == null ? void 0 : f.count) + ")", 1))
164
- ];
165
- }),
166
- _: 2
167
- }, 1032, ["value"]))), 128))
168
- ])
169
- ], 64))
170
- ]),
171
- _: 2
172
- }, 1032, ["modelValue", "onUpdate:modelValue", "onChange"]))), 128))
173
- ])
174
- ]),
175
- default: d(() => [
176
- E("div", fe, [
177
- (a(!0), i(b, null, z(c.value, (e) => (a(), i(b, null, [
178
- e.isCheckbox ? (a(), y(u(Y), {
179
- key: e.value,
180
- modelValue: n[e.text],
181
- "onUpdate:modelValue": (l) => n[e.text] = l,
182
- class: "checkbox-group",
183
- size: "small",
184
- onChange: Z
185
- }, {
186
- default: d(() => [
187
- e.isCheckbox ? (a(), y(u(j), {
188
- key: 0,
189
- class: "custom-dropdown-button",
190
- value: e.value,
191
- border: ""
192
- }, {
193
- default: d(() => [
194
- k(v(u(x)(e.text)), 1)
195
- ]),
196
- _: 2
197
- }, 1032, ["value"])) : N("", !0)
198
- ]),
199
- _: 2
200
- }, 1032, ["modelValue", "onUpdate:modelValue"])) : (a(), y(u(P), {
201
- key: e.text,
202
- style: R(r[e.text]),
203
- class: "custom-dropdown-button",
204
- size: "small",
205
- onClick: (l) => q(e)
206
- }, {
207
- default: d(() => {
208
- var l;
209
- return [
210
- k(v(u(x)(e.text)) + " ", 1),
211
- u(s).isEmpty(S.value) ? N("", !0) : (a(), i("span", pe, "(" + v((l = S.value.filter((f) => f.value == e.value)[0]) == null ? void 0 : l.count) + ")", 1))
212
- ];
213
- }),
214
- _: 2
215
- }, 1032, ["style", "onClick"]))
216
- ], 64))), 256))
217
- ])
218
- ]),
219
- _: 1
220
- }, 512)
221
- ]));
222
- }
223
- });
1
+ import o from "./drop-down-condition.vue2.js";
2
+ import "E:/工作/项目代码/common_componentsweb/packages/components/src/drop-down-condition/drop-down-condition.vue?vue&type=style&index=0&scoped=dcda9a8e&lang.scss";
3
+ import t from "../_virtual/_plugin-vue_export-helper.js";
4
+ const d = /* @__PURE__ */ t(o, [["__scopeId", "data-v-dcda9a8e"]]);
224
5
  export {
225
- Ae as default
6
+ d as default
226
7
  };
@@ -1,4 +1,222 @@
1
- import f from "./drop-down-condition.vue.js";
1
+ import { defineComponent as re, ref as g, reactive as E, toRefs as ie, watch as I, onMounted as de, resolveComponent as w, createElementBlock as f, openBlock as a, createVNode as A, normalizeStyle as R, withCtx as v, createTextVNode as y, createCommentVNode as z, toDisplayString as p, unref as i, createElementVNode as V, Fragment as _, renderList as L, createBlock as x } from "vue";
2
+ import s from "../_virtual/lodash.js";
3
+ import { stylesUtils as U } from "../utils/style.js";
4
+ import { storage as J } from "../utils/storage.js";
5
+ import { M2 as b } from "../utils/translate.js";
6
+ const fe = { class: "yahee-drop-down-condition" }, ve = { key: 0 }, pe = { style: { display: "flex", "align-items": "center", outline: "none" } }, he = { key: 0 }, me = { style: { display: "flex", width: "auto", padding: "10px" } }, ge = ["onClick"], be = { class: "scrollable-container" }, ke = { key: 0 }, Ee = /* @__PURE__ */ re({
7
+ name: "YaheeDropDownCondition",
8
+ __name: "drop-down-condition",
9
+ props: {
10
+ filterList: {},
11
+ totalCount: {},
12
+ level1Count: {},
13
+ level2Count: {},
14
+ filterKey: {},
15
+ enumEntity: {},
16
+ noNeedRefreshNumFilterName: {},
17
+ initFilters: { type: Function }
18
+ },
19
+ emits: ["filterChange", "setNoNeedRefreshNumFilterName"],
20
+ setup(Q, { emit: X }) {
21
+ const Z = g(), n = E({}), $ = E({}), d = E({}), h = E({}), k = g(!0), r = g([]), m = Q, K = X, { filterKey: F, filterList: C, totalCount: S, level1Count: M, level2Count: T, noNeedRefreshNumFilterName: q } = ie(m), W = g(s.get(S, "value", 0)), j = g(s.get(M, "value", [])), B = g(s.get(T, "value", []));
22
+ function ee() {
23
+ if (C.value && C.value.length > 0) {
24
+ r.value = [...C.value];
25
+ return;
26
+ }
27
+ const e = `filter-key-${m.enumEntity}`, t = J.getWithExpireTime(e);
28
+ t ? r.value = t : m.initFilters && m.initFilters(m.enumEntity).then((o) => {
29
+ r.value = o.data, J.setWithExpireTime(e, r.value, 1200 * 1e3);
30
+ }).catch((o) => {
31
+ console.error(`获取${m.enumEntity}筛选列表失败:`, o);
32
+ });
33
+ }
34
+ function P(e) {
35
+ const { text: t, value: o } = e, c = n[t];
36
+ s.isNil(c) || s.isEmpty(c) ? n[t] = [o] : n[t] = [], h[t] = !h[t], h[t] ? (se(t), d[t] = U.getBackgroundColor(!0)) : (ue(t), d[e.text] = {}), k.value = D(), O();
37
+ }
38
+ function D() {
39
+ if (!r.value.length) return !0;
40
+ const e = r.value.filter((c) => !s.isEmpty(c.subs)).flatMap((c) => c.subs).length, t = r.value.filter((c) => s.isEmpty(c.subs)).length, o = Object.values(n).flat().length;
41
+ return o === e + t || o === 0;
42
+ }
43
+ function te(e) {
44
+ const t = n[e.text] || [], o = s.get(e, "subs.length", 1);
45
+ s.isEmpty(t) ? (d[e.text] = {}, h[e.text] = !1) : t.length === o ? (d[e.text] = U.getBackgroundColor(!0), h[e.text] = !0) : d[e.text] = {
46
+ backgroundColor: "#0F7535",
47
+ color: "#fff",
48
+ borderColor: "#0F7535"
49
+ }, k.value = D(), O();
50
+ }
51
+ function le() {
52
+ k.value = D(), O();
53
+ }
54
+ function O() {
55
+ K("setNoNeedRefreshNumFilterName", F.value);
56
+ }
57
+ function Y() {
58
+ k.value = !0, Object.keys(d).forEach((e) => {
59
+ d[e] = {};
60
+ }), Object.keys(n).forEach((e) => {
61
+ delete n[e];
62
+ }), Object.keys(h).forEach((e) => {
63
+ delete h[e];
64
+ }), G();
65
+ }
66
+ const oe = (e) => U.getBackgroundColor(e);
67
+ function ne(e) {
68
+ e ? Object.assign($, s.cloneDeep(n)) : s.isEqual($, n) || G();
69
+ }
70
+ function G() {
71
+ K("filterChange", [
72
+ {
73
+ filterKey: F.value,
74
+ checkedValues: Object.values(n).flat()
75
+ }
76
+ ]);
77
+ }
78
+ function se(e) {
79
+ const t = r.value.find((o) => o.text === e);
80
+ t != null && t.subs && (n[e] = t.subs.map((o) => o.value));
81
+ }
82
+ function ue(e) {
83
+ n[e] = [];
84
+ }
85
+ return I(
86
+ () => C.value,
87
+ (e) => {
88
+ e && e.length > 0 && (r.value = [...e], Y());
89
+ },
90
+ { deep: !0 }
91
+ ), I(
92
+ [() => S.value, () => M.value, () => T.value],
93
+ ([e, t, o]) => {
94
+ (!q.value || !s.eq(q.value, F.value)) && (W.value = e, j.value = t, B.value = o);
95
+ }
96
+ ), de(() => {
97
+ ee();
98
+ }), (e, t) => {
99
+ const o = w("el-button"), c = w("el-checkbox"), H = w("el-checkbox-group"), ae = w("el-dropdown");
100
+ return a(), f("div", fe, [
101
+ A(o, {
102
+ size: "small",
103
+ class: "el-button el-button--small custom-total-button",
104
+ style: R(oe(k.value)),
105
+ onClick: Y
106
+ }, {
107
+ default: v(() => [
108
+ y(p(i(b)("全部")) + " ", 1),
109
+ i(S) ? (a(), f("span", ve, "(" + p(W.value) + ")", 1)) : z("", !0)
110
+ ]),
111
+ _: 1
112
+ }, 8, ["style"]),
113
+ A(ae, {
114
+ ref_key: "dropdown1",
115
+ ref: Z,
116
+ "popper-class": "custom-dropdown",
117
+ onVisibleChange: ne
118
+ }, {
119
+ dropdown: v(() => [
120
+ V("div", me, [
121
+ (a(!0), f(_, null, L(r.value, (l) => (a(), x(H, {
122
+ key: l.value,
123
+ modelValue: n[l.text],
124
+ "onUpdate:modelValue": (u) => n[l.text] = u,
125
+ size: "small",
126
+ class: "checkbox-group inner-checkbox-group custom-dropdown-checkbox-group",
127
+ onChange: (u) => te(l)
128
+ }, {
129
+ default: v(() => [
130
+ i(s).isNil(l.subs) ? (a(), x(c, {
131
+ key: 1,
132
+ value: l.value,
133
+ class: "checkbox custom-dropdown-button",
134
+ border: ""
135
+ }, {
136
+ default: v(() => [
137
+ y(p(i(b)(l.text)), 1)
138
+ ]),
139
+ _: 2
140
+ }, 1032, ["value"])) : (a(), f(_, { key: 0 }, [
141
+ V("span", {
142
+ class: "el-button custom-dropdown-button el-button--small inner-el-button",
143
+ style: R(d[l.text]),
144
+ onClick: (u) => P(l)
145
+ }, p(i(b)(l.text)), 13, ge),
146
+ V("div", be, [
147
+ (a(!0), f(_, null, L(l.subs, (u) => (a(), x(c, {
148
+ key: u.value,
149
+ class: "checkbox custom-dropdown-button",
150
+ value: u.value,
151
+ border: ""
152
+ }, {
153
+ default: v(() => {
154
+ var N;
155
+ return [
156
+ y(p(i(b)(u.text)), 1),
157
+ i(s).isEmpty(B.value) ? z("", !0) : (a(), f("span", ke, "(" + p((N = B.value.filter((ce) => ce.value == u.value)[0]) == null ? void 0 : N.count) + ")", 1))
158
+ ];
159
+ }),
160
+ _: 2
161
+ }, 1032, ["value"]))), 128))
162
+ ])
163
+ ], 64))
164
+ ]),
165
+ _: 2
166
+ }, 1032, ["modelValue", "onUpdate:modelValue", "onChange"]))), 128))
167
+ ])
168
+ ]),
169
+ default: v(() => [
170
+ V("div", pe, [
171
+ (a(!0), f(_, null, L(r.value, (l) => (a(), f(_, {
172
+ key: l.value
173
+ }, [
174
+ l.isCheckbox ? (a(), x(H, {
175
+ key: 0,
176
+ modelValue: n[l.text],
177
+ "onUpdate:modelValue": (u) => n[l.text] = u,
178
+ class: "checkbox-group",
179
+ size: "small",
180
+ onChange: le
181
+ }, {
182
+ default: v(() => [
183
+ A(c, {
184
+ class: "custom-dropdown-button",
185
+ value: l.value,
186
+ border: ""
187
+ }, {
188
+ default: v(() => [
189
+ y(p(i(b)(l.text)), 1)
190
+ ]),
191
+ _: 2
192
+ }, 1032, ["value"])
193
+ ]),
194
+ _: 2
195
+ }, 1032, ["modelValue", "onUpdate:modelValue"])) : (a(), x(o, {
196
+ key: 1,
197
+ style: R(d[l.text]),
198
+ class: "custom-dropdown-button",
199
+ size: "small",
200
+ onClick: (u) => P(l)
201
+ }, {
202
+ default: v(() => {
203
+ var u;
204
+ return [
205
+ y(p(i(b)(l.text)) + " ", 1),
206
+ i(s).isEmpty(j.value) ? z("", !0) : (a(), f("span", he, "(" + p((u = j.value.filter((N) => N.value == l.value)[0]) == null ? void 0 : u.count) + ")", 1))
207
+ ];
208
+ }),
209
+ _: 2
210
+ }, 1032, ["style", "onClick"]))
211
+ ], 64))), 128))
212
+ ])
213
+ ]),
214
+ _: 1
215
+ }, 512)
216
+ ]);
217
+ };
218
+ }
219
+ });
2
220
  export {
3
- f as default
221
+ Ee as default
4
222
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "yahee-components",
3
3
  "private": false,
4
- "version": "0.0.102",
4
+ "version": "0.0.103",
5
5
  "description": "深圳前海亚讯前端组件库",
6
6
  "main": "lib",
7
7
  "module": "es",
@@ -1,28 +1,42 @@
1
1
  import { DropdownEntity } from './drop-down-condition';
2
2
  import { DefineComponent, ComponentOptionsMixin, PublicProps, ComponentProvideOptions, CreateComponentPublicInstanceWithMixins, ExtractPropTypes, PropType, ComputedRef, Ref, CSSProperties, VNodeProps, AllowedComponentProps, ComponentCustomProps, GlobalComponents, GlobalDirectives } from 'vue';
3
3
  import { TooltipTriggerType, PopperEffect, Placement, Options, ButtonProps, Translator, TooltipInstance } from 'element-plus';
4
+ interface CountItem {
5
+ value: string;
6
+ count: number;
7
+ }
4
8
  type __VLS_Props = {
5
- filterList?: Array<DropdownEntity>;
9
+ /** 父子层级渲染条件项(优先级最高,传入后跳过接口请求) */
10
+ filterList?: DropdownEntity[];
11
+ /** 当前条件下显示的条数 */
6
12
  totalCount?: number;
7
- level1Count?: Array<{
8
- value: string;
9
- count: number;
10
- }>;
11
- level2Count?: Array<{
12
- value: string;
13
- count: number;
14
- }>;
13
+ /** 父级显示条数 */
14
+ level1Count?: CountItem[];
15
+ /** 子级显示数量 */
16
+ level2Count?: CountItem[];
17
+ /** 发往后端的请求参数key */
15
18
  filterKey: string;
19
+ /** 后端接口枚举标识(用于缓存key) */
16
20
  enumEntity: string;
21
+ /** 是否需要刷新当前项 */
17
22
  noNeedRefreshNumFilterName?: string;
18
- initFilters?: Function;
23
+ /** 查询接口方法(仅当未传入filterList时调用) */
24
+ initFilters?: (enumEntity: string) => Promise<{
25
+ data: DropdownEntity[];
26
+ }>;
19
27
  };
20
28
  declare const _default: DefineComponent<__VLS_Props, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
21
- filterChange: (...args: any[]) => void;
22
- setNoNeedRefreshNumFilterName: (...args: any[]) => void;
29
+ filterChange: (payload: {
30
+ filterKey: string;
31
+ checkedValues: string[];
32
+ }[]) => any;
33
+ setNoNeedRefreshNumFilterName: (filterKey: string) => any;
23
34
  }, string, PublicProps, Readonly<__VLS_Props> & Readonly<{
24
- onFilterChange?: (...args: any[]) => any;
25
- onSetNoNeedRefreshNumFilterName?: (...args: any[]) => any;
35
+ onFilterChange?: (payload: {
36
+ filterKey: string;
37
+ checkedValues: string[];
38
+ }[]) => any;
39
+ onSetNoNeedRefreshNumFilterName?: (filterKey: string) => any;
26
40
  }>, {}, {}, {}, {}, string, ComponentProvideOptions, false, {
27
41
  dropdown1: CreateComponentPublicInstanceWithMixins<Readonly< ExtractPropTypes<{
28
42
  readonly trigger: {