@ditari/bsui 1.0.63 → 1.0.65
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/dist/cjs/components/select/Select.vue.cjs.js +1 -1
- package/dist/cjs/hooks/http/index.cjs.js +1 -1
- package/dist/esm/components/select/Select.vue.esm.js +46 -50
- package/dist/esm/hooks/http/index.esm.js +23 -23
- package/package.json +1 -1
- package/src/components/select/Select.vue +14 -32
- package/src/hooks/http/index.ts +3 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const n=require("vue"),x=require("../../store/modules/DataDictionary.cjs.js"),B={name:"DSelect"},y=n.defineComponent({...B,props:{value:{default:null},name:{default:""},disabled:{type:Boolean,default:!1},placeholder:{default:"请填写默认占位符啊!老铁"},include:{default:[]}},emits:["update:value","change","select"],setup(r,{emit:u}){const s=r,{getDicByKey:f}=x.useDataDicStore(),{modelValue:i,data:h,onSearch:M,onSelect:p,onChange:v}=S();function S(){const l=[...f(s.name)],t=n.ref(l),o=n.ref(s.value);n.watch(()=>s.value,e=>{o.value=e,m(e)});const d=e=>{g(e)};function g(e){e=e??"",t.value=l.filter(a=>a.value.toLowerCase().indexOf(e.toLowerCase())!==-1||a.label.toLowerCase().includes(e.toLowerCase())).splice(0,10),t.value.length===0&&(t.value=[...l].splice(0,10))}function m(e){e=e||"";const a=l.findIndex(c=>c.value.toLowerCase().indexOf(e.toLowerCase())!==-1||c.label.toLowerCase().includes(e));a===-1?t.value=[...l].splice(0,10):t.value=b(l,a)}function b(e,a){const c=Math.max(0,a-5),_=Math.min(e.length,a+6);return e.slice(c,_)}const L=e=>{u("update:value",e),D()},w=()=>{u("update:value",o.value),u("change",o.value)};function D(){const a=f(s.name).find(c=>c.value===o.value);u("select",a)}return{data:t,modelValue:o,onSearch:d,onSelect:L,onChange:w}}const C=(l,t)=>t.label.includes(l);return(l,t)=>{const o=n.resolveComponent("a-select");return n.openBlock(),n.createBlock(o,{value:n.unref(i),"onUpdate:value":t[0]||(t[0]=d=>n.isRef(i)?i.value=d:null),"allow-clear":"","show-search":"",options:n.unref(h),placeholder:r.placeholder,disabled:r.disabled,"filter-option":C,onSelect:n.unref(p),onChange:n.unref(v)},null,8,["value","options","placeholder","disabled","onSelect","onChange"])}}});exports.default=y;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("vue"),q=require("vue-request"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("vue"),q=require("vue-request"),f=require("../../utils/get.cjs.js"),z=(i,e={})=>{e.pagination||(e.pagination={currentKey:"page",pageSizeKey:"limit",totalKey:"data.total"}),e.manual===void 0&&(e.manual=!0);const{dataKey:o,pagination:{currentKey:r,pageSizeKey:c}}=e,a=e.params||n.ref({}),{total:s,pageSize:g,current:v,loading:d,data:m,run:u}=q.usePagination(i,{manual:!0,pagination:e.pagination,loadingDelay:400,loadingKeep:100,onSuccess:(t,l)=>{e.onSuccess&&e.onSuccess(t,l)},onError:(t,l)=>{console.log(l,t)}}),y=n.computed(()=>({total:s.value,current:v.value,pageSize:g.value})),S=n.computed(()=>f.get(m.value,o||"data",[])||[]),p=t=>{a.value[r]=t.page,a.value[c]=t.size,u(a.value||{})},K=t=>{a.value={...a.value,...t},a.value[r]=1,u(a.value||{})};return n.onMounted(()=>{e.manual&&u(a.value)}),{data:S,pagination:y,loading:d,run:u,onPageChange:p,onQuery:K}};exports.useRequestList=z;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { useDataDicStore as
|
|
3
|
-
const
|
|
1
|
+
import { defineComponent as _, ref as p, watch as O, resolveComponent as V, openBlock as y, createBlock as M, unref as s, isRef as A } from "vue";
|
|
2
|
+
import { useDataDicStore as F } from "../../store/modules/DataDictionary.esm.js";
|
|
3
|
+
const H = {
|
|
4
4
|
name: "DSelect"
|
|
5
|
-
}, U = /* @__PURE__ */
|
|
6
|
-
...
|
|
5
|
+
}, U = /* @__PURE__ */ _({
|
|
6
|
+
...H,
|
|
7
7
|
props: {
|
|
8
8
|
value: { default: null },
|
|
9
9
|
name: { default: "" },
|
|
@@ -12,67 +12,63 @@ const I = {
|
|
|
12
12
|
include: { default: [] }
|
|
13
13
|
},
|
|
14
14
|
emits: ["update:value", "change", "select"],
|
|
15
|
-
setup(r, { emit:
|
|
16
|
-
const
|
|
17
|
-
function
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
() =>
|
|
21
|
-
() => {
|
|
22
|
-
f(l.value);
|
|
23
|
-
}
|
|
24
|
-
), v(
|
|
25
|
-
() => c.value,
|
|
15
|
+
setup(r, { emit: c }) {
|
|
16
|
+
const u = r, { getDicByKey: f } = F(), { modelValue: i, data: h, onSearch: I, onSelect: v, onChange: m } = C();
|
|
17
|
+
function C() {
|
|
18
|
+
const l = [...f(u.name)], n = p(l), t = p(u.value);
|
|
19
|
+
O(
|
|
20
|
+
() => u.value,
|
|
26
21
|
(e) => {
|
|
27
|
-
|
|
22
|
+
t.value = e, L(e);
|
|
28
23
|
}
|
|
29
|
-
)
|
|
30
|
-
const
|
|
31
|
-
|
|
24
|
+
);
|
|
25
|
+
const d = (e) => {
|
|
26
|
+
g(e);
|
|
32
27
|
};
|
|
33
|
-
function
|
|
34
|
-
e = e ?? "", n.value =
|
|
28
|
+
function g(e) {
|
|
29
|
+
e = e ?? "", n.value = l.filter((a) => a.value.toLowerCase().indexOf(e.toLowerCase()) !== -1 || a.label.toLowerCase().includes(e.toLowerCase())).splice(0, 10), n.value.length === 0 && (n.value = [...l].splice(0, 10));
|
|
35
30
|
}
|
|
36
|
-
function
|
|
37
|
-
|
|
38
|
-
a
|
|
31
|
+
function L(e) {
|
|
32
|
+
e = e || "";
|
|
33
|
+
const a = l.findIndex((o) => o.value.toLowerCase().indexOf(e.toLowerCase()) !== -1 || o.label.toLowerCase().includes(e));
|
|
34
|
+
a === -1 ? n.value = [...l].splice(0, 10) : n.value = b(l, a);
|
|
39
35
|
}
|
|
40
|
-
function
|
|
41
|
-
const o = Math.max(0, a - 5),
|
|
42
|
-
return e.slice(o,
|
|
36
|
+
function b(e, a) {
|
|
37
|
+
const o = Math.max(0, a - 5), D = Math.min(e.length, a + 6);
|
|
38
|
+
return e.slice(o, D);
|
|
43
39
|
}
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
},
|
|
47
|
-
|
|
40
|
+
const w = (e) => {
|
|
41
|
+
c("update:value", e), B();
|
|
42
|
+
}, x = () => {
|
|
43
|
+
c("update:value", t.value), c("change", t.value);
|
|
48
44
|
};
|
|
49
|
-
function
|
|
50
|
-
const a =
|
|
51
|
-
|
|
45
|
+
function B() {
|
|
46
|
+
const a = f(u.name).find((o) => o.value === t.value);
|
|
47
|
+
c("select", a);
|
|
52
48
|
}
|
|
53
49
|
return {
|
|
54
50
|
data: n,
|
|
55
|
-
modelValue:
|
|
56
|
-
onSearch:
|
|
57
|
-
onSelect:
|
|
58
|
-
onChange:
|
|
51
|
+
modelValue: t,
|
|
52
|
+
onSearch: d,
|
|
53
|
+
onSelect: w,
|
|
54
|
+
onChange: x
|
|
59
55
|
};
|
|
60
56
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
57
|
+
const S = (l, n) => n.label.includes(l);
|
|
58
|
+
return (l, n) => {
|
|
59
|
+
const t = V("a-select");
|
|
60
|
+
return y(), M(t, {
|
|
61
|
+
value: s(i),
|
|
62
|
+
"onUpdate:value": n[0] || (n[0] = (d) => A(i) ? i.value = d : null),
|
|
66
63
|
"allow-clear": "",
|
|
67
64
|
"show-search": "",
|
|
68
|
-
|
|
69
|
-
options: u(S),
|
|
65
|
+
options: s(h),
|
|
70
66
|
placeholder: r.placeholder,
|
|
71
67
|
disabled: r.disabled,
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
onChange:
|
|
75
|
-
}, null, 8, ["value", "options", "placeholder", "disabled", "onSelect", "
|
|
68
|
+
"filter-option": S,
|
|
69
|
+
onSelect: s(v),
|
|
70
|
+
onChange: s(m)
|
|
71
|
+
}, null, 8, ["value", "options", "placeholder", "disabled", "onSelect", "onChange"]);
|
|
76
72
|
};
|
|
77
73
|
}
|
|
78
74
|
});
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import { ref as
|
|
1
|
+
import { ref as S, computed as r, onMounted as z } from "vue";
|
|
2
2
|
import { usePagination as D } from "vue-request";
|
|
3
3
|
import { get as P } from "../../utils/get.esm.js";
|
|
4
|
-
const C = (
|
|
4
|
+
const C = (o, a = {}) => {
|
|
5
5
|
a.pagination || (a.pagination = {
|
|
6
6
|
currentKey: "page",
|
|
7
7
|
pageSizeKey: "limit",
|
|
8
8
|
totalKey: "data.total"
|
|
9
|
-
});
|
|
9
|
+
}), a.manual === void 0 && (a.manual = !0);
|
|
10
10
|
const {
|
|
11
11
|
dataKey: i,
|
|
12
|
-
pagination: { currentKey:
|
|
13
|
-
} = a, e = a.params ||
|
|
12
|
+
pagination: { currentKey: l, pageSizeKey: c }
|
|
13
|
+
} = a, e = a.params || S({}), {
|
|
14
14
|
total: g,
|
|
15
|
-
pageSize:
|
|
16
|
-
current:
|
|
17
|
-
loading:
|
|
18
|
-
data:
|
|
15
|
+
pageSize: m,
|
|
16
|
+
current: s,
|
|
17
|
+
loading: v,
|
|
18
|
+
data: d,
|
|
19
19
|
run: n
|
|
20
|
-
} = D(
|
|
20
|
+
} = D(o, {
|
|
21
21
|
manual: !0,
|
|
22
22
|
pagination: a.pagination,
|
|
23
23
|
loadingDelay: 400,
|
|
@@ -28,26 +28,26 @@ const C = (r, a = {}) => {
|
|
|
28
28
|
onError: (t, u) => {
|
|
29
29
|
console.log(u, t);
|
|
30
30
|
}
|
|
31
|
-
}),
|
|
31
|
+
}), p = r(() => ({
|
|
32
32
|
total: g.value,
|
|
33
|
-
current:
|
|
34
|
-
pageSize:
|
|
35
|
-
})), y =
|
|
36
|
-
() => P(
|
|
37
|
-
),
|
|
38
|
-
e.value[
|
|
39
|
-
},
|
|
40
|
-
e.value = { ...e.value, ...t }, e.value[
|
|
33
|
+
current: s.value,
|
|
34
|
+
pageSize: m.value
|
|
35
|
+
})), y = r(
|
|
36
|
+
() => P(d.value, i || "data", []) || []
|
|
37
|
+
), f = (t) => {
|
|
38
|
+
e.value[l] = t.page, e.value[c] = t.size, n(e.value || {});
|
|
39
|
+
}, K = (t) => {
|
|
40
|
+
e.value = { ...e.value, ...t }, e.value[l] = 1, n(e.value || {});
|
|
41
41
|
};
|
|
42
42
|
return z(() => {
|
|
43
43
|
a.manual && n(e.value);
|
|
44
44
|
}), {
|
|
45
45
|
data: y,
|
|
46
|
-
pagination:
|
|
47
|
-
loading:
|
|
46
|
+
pagination: p,
|
|
47
|
+
loading: v,
|
|
48
48
|
run: n,
|
|
49
|
-
onPageChange:
|
|
50
|
-
onQuery:
|
|
49
|
+
onPageChange: f,
|
|
50
|
+
onQuery: K
|
|
51
51
|
};
|
|
52
52
|
};
|
|
53
53
|
export {
|
package/package.json
CHANGED
|
@@ -37,38 +37,12 @@ const { getDicByKey } = useDataDicStore();
|
|
|
37
37
|
const { modelValue, data, onSearch, onSelect, onChange } = useSelect();
|
|
38
38
|
|
|
39
39
|
function useSelect() {
|
|
40
|
-
//
|
|
41
|
-
// let workerStatus = true;
|
|
40
|
+
// 字典数据
|
|
42
41
|
const dicData: any[] = [...getDicByKey(props.name)];
|
|
43
|
-
const data = ref<any>(
|
|
42
|
+
const data = ref<any>(dicData);
|
|
44
43
|
// 取值
|
|
45
44
|
const modelValue = ref(props.value);
|
|
46
45
|
|
|
47
|
-
/**
|
|
48
|
-
* web worker 启动失败
|
|
49
|
-
*/
|
|
50
|
-
// workerInstance.onerror = () => {
|
|
51
|
-
// workerStatus = false;
|
|
52
|
-
// // 启动失败使用store
|
|
53
|
-
// dicData = getDicByKey(props.name);
|
|
54
|
-
// };
|
|
55
|
-
/**
|
|
56
|
-
* 监听web worker发送的数据
|
|
57
|
-
* @param e
|
|
58
|
-
*/
|
|
59
|
-
// workerInstance.onmessage = (e: any) => {
|
|
60
|
-
// // 赋值给下拉选择数据变量
|
|
61
|
-
// data.value = e.data;
|
|
62
|
-
// };
|
|
63
|
-
|
|
64
|
-
// 当include变化的时候,需要重新发送搜索事件 返回对应的下拉数据
|
|
65
|
-
watch(
|
|
66
|
-
() => props.include,
|
|
67
|
-
() => {
|
|
68
|
-
sendWorkerSearch(modelValue.value);
|
|
69
|
-
}
|
|
70
|
-
);
|
|
71
|
-
|
|
72
46
|
// 监听value值的变化
|
|
73
47
|
watch(
|
|
74
48
|
() => props.value,
|
|
@@ -78,8 +52,7 @@ function useSelect() {
|
|
|
78
52
|
}
|
|
79
53
|
);
|
|
80
54
|
|
|
81
|
-
//
|
|
82
|
-
sendWorkerSearch(modelValue.value);
|
|
55
|
+
//initSearch(modelValue.value);
|
|
83
56
|
|
|
84
57
|
//监听用户搜索事件
|
|
85
58
|
const onSearch = (keywords: string) => {
|
|
@@ -107,6 +80,7 @@ function useSelect() {
|
|
|
107
80
|
* @param val
|
|
108
81
|
*/
|
|
109
82
|
function initSearch(val: any) {
|
|
83
|
+
val = val || "";
|
|
110
84
|
const index = dicData.findIndex((item: any) => {
|
|
111
85
|
return (
|
|
112
86
|
item.value.toLowerCase().indexOf(val.toLowerCase()) !== -1 ||
|
|
@@ -159,6 +133,15 @@ function useSelect() {
|
|
|
159
133
|
onChange
|
|
160
134
|
};
|
|
161
135
|
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* 过滤筛选
|
|
139
|
+
* @param inputValue
|
|
140
|
+
* @param options
|
|
141
|
+
*/
|
|
142
|
+
const onFilterOption = (inputValue: any, options: any) => {
|
|
143
|
+
return options.label.includes(inputValue);
|
|
144
|
+
};
|
|
162
145
|
</script>
|
|
163
146
|
<script lang="ts">
|
|
164
147
|
export default {
|
|
@@ -170,12 +153,11 @@ export default {
|
|
|
170
153
|
v-model:value="modelValue"
|
|
171
154
|
allow-clear
|
|
172
155
|
show-search
|
|
173
|
-
:filter-option="false"
|
|
174
156
|
:options="data"
|
|
175
157
|
:placeholder="placeholder"
|
|
176
158
|
:disabled="disabled"
|
|
159
|
+
:filter-option="onFilterOption"
|
|
177
160
|
@select="onSelect"
|
|
178
|
-
@search="onSearch"
|
|
179
161
|
@change="onChange"
|
|
180
162
|
>
|
|
181
163
|
</a-select>
|
package/src/hooks/http/index.ts
CHANGED