@ditari/bsui 1.0.64 → 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.
|
@@ -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,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
|
});
|
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>
|