@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.
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const a=require("vue"),x=require("../../store/modules/DataDictionary.cjs.js"),B={name:"DSelect"},y=a.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:s}){const u=r,{getDicByKey:v}=x.useDataDicStore(),{modelValue:i,data:h,onSearch:p,onSelect:S,onChange:C}=g();function g(){const o=[...v(u.name)],l=a.ref([]),t=a.ref(u.value);a.watch(()=>u.include,()=>{f(t.value)}),a.watch(()=>u.value,e=>{t.value=e,m(e)}),f(t.value);const d=e=>{f(e)};function f(e){e=e??"",l.value=o.filter(n=>n.value.toLowerCase().indexOf(e.toLowerCase())!==-1||n.label.toLowerCase().includes(e.toLowerCase())).splice(0,10),l.value.length===0&&(l.value=[...o].splice(0,10))}function m(e){const n=o.findIndex(c=>c.value.toLowerCase().indexOf(e.toLowerCase())!==-1||c.label.toLowerCase().includes(e));n===-1?l.value=[...o].splice(0,10):l.value=L(o,n)}function L(e,n){const c=Math.max(0,n-5),_=Math.min(e.length,n+6);return e.slice(c,_)}const b=e=>{s("update:value",e),D()},w=()=>{s("update:value",t.value),s("change",t.value)};function D(){const n=v(u.name).find(c=>c.value===t.value);s("select",n)}return{data:l,modelValue:t,onSearch:d,onSelect:b,onChange:w}}return(o,l)=>{const t=a.resolveComponent("a-select");return a.openBlock(),a.createBlock(t,{value:a.unref(i),"onUpdate:value":l[0]||(l[0]=d=>a.isRef(i)?i.value=d:null),"allow-clear":"","show-search":"","filter-option":!1,options:a.unref(h),placeholder:r.placeholder,disabled:r.disabled,onSelect:a.unref(S),onSearch:a.unref(p),onChange:a.unref(C)},null,8,["value","options","placeholder","disabled","onSelect","onSearch","onChange"])}}});exports.default=y;
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"),z=require("../../utils/get.cjs.js"),f=(r,e={})=>{e.pagination||(e.pagination={currentKey:"page",pageSizeKey:"limit",totalKey:"data.total"});const{dataKey:i,pagination:{currentKey:l,pageSizeKey:c}}=e,a=e.params||n.ref({}),{total:s,pageSize:g,current:v,loading:d,data:p,run:u}=q.usePagination(r,{manual:!0,pagination:e.pagination,loadingDelay:400,loadingKeep:100,onSuccess:(t,o)=>{e.onSuccess&&e.onSuccess(t,o)},onError:(t,o)=>{console.log(o,t)}}),y=n.computed(()=>({total:s.value,current:v.value,pageSize:g.value})),S=n.computed(()=>z.get(p.value,i||"data",[])||[]),m=t=>{a.value[l]=t.page,a.value[c]=t.size,u(a.value||{})},K=t=>{a.value={...a.value,...t},a.value[l]=1,u(a.value||{})};return n.onMounted(()=>{e.manual&&u(a.value)}),{data:S,pagination:y,loading:d,run:u,onPageChange:m,onQuery:K}};exports.useRequestList=f;
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 V, ref as p, watch as v, resolveComponent as y, openBlock as M, createBlock as O, unref as u, isRef as A } from "vue";
2
- import { useDataDicStore as H } from "../../store/modules/DataDictionary.esm.js";
3
- const I = {
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__ */ V({
6
- ...I,
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: s }) {
16
- const c = r, { getDicByKey: h } = H(), { modelValue: d, data: S, onSearch: m, onSelect: C, onChange: g } = L();
17
- function L() {
18
- const t = [...h(c.name)], n = p([]), l = p(c.value);
19
- v(
20
- () => c.include,
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
- l.value = e, w(e);
22
+ t.value = e, L(e);
28
23
  }
29
- ), f(l.value);
30
- const i = (e) => {
31
- f(e);
24
+ );
25
+ const d = (e) => {
26
+ g(e);
32
27
  };
33
- function f(e) {
34
- e = e ?? "", n.value = t.filter((a) => a.value.toLowerCase().indexOf(e.toLowerCase()) !== -1 || a.label.toLowerCase().includes(e.toLowerCase())).splice(0, 10), n.value.length === 0 && (n.value = [...t].splice(0, 10));
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 w(e) {
37
- const a = t.findIndex((o) => o.value.toLowerCase().indexOf(e.toLowerCase()) !== -1 || o.label.toLowerCase().includes(e));
38
- a === -1 ? n.value = [...t].splice(0, 10) : n.value = x(t, 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 x(e, a) {
41
- const o = Math.max(0, a - 5), _ = Math.min(e.length, a + 6);
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 b = (e) => {
45
- s("update:value", e), D();
46
- }, B = () => {
47
- s("update:value", l.value), s("change", l.value);
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 D() {
50
- const a = h(c.name).find((o) => o.value === l.value);
51
- s("select", a);
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: l,
56
- onSearch: i,
57
- onSelect: b,
58
- onChange: B
51
+ modelValue: t,
52
+ onSearch: d,
53
+ onSelect: w,
54
+ onChange: x
59
55
  };
60
56
  }
61
- return (t, n) => {
62
- const l = y("a-select");
63
- return M(), O(l, {
64
- value: u(d),
65
- "onUpdate:value": n[0] || (n[0] = (i) => A(d) ? d.value = i : null),
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
- "filter-option": !1,
69
- options: u(S),
65
+ options: s(h),
70
66
  placeholder: r.placeholder,
71
67
  disabled: r.disabled,
72
- onSelect: u(C),
73
- onSearch: u(m),
74
- onChange: u(g)
75
- }, null, 8, ["value", "options", "placeholder", "disabled", "onSelect", "onSearch", "onChange"]);
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 f, computed as l, onMounted as z } from "vue";
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 = (r, a = {}) => {
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: o, pageSizeKey: c }
13
- } = a, e = a.params || f({}), {
12
+ pagination: { currentKey: l, pageSizeKey: c }
13
+ } = a, e = a.params || S({}), {
14
14
  total: g,
15
- pageSize: s,
16
- current: v,
17
- loading: m,
18
- data: p,
15
+ pageSize: m,
16
+ current: s,
17
+ loading: v,
18
+ data: d,
19
19
  run: n
20
- } = D(r, {
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
- }), d = l(() => ({
31
+ }), p = r(() => ({
32
32
  total: g.value,
33
- current: v.value,
34
- pageSize: s.value
35
- })), y = l(
36
- () => P(p.value, i || "data", []) || []
37
- ), K = (t) => {
38
- e.value[o] = t.page, e.value[c] = t.size, n(e.value || {});
39
- }, S = (t) => {
40
- e.value = { ...e.value, ...t }, e.value[o] = 1, n(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: d,
47
- loading: m,
46
+ pagination: p,
47
+ loading: v,
48
48
  run: n,
49
- onPageChange: K,
50
- onQuery: S
49
+ onPageChange: f,
50
+ onQuery: K
51
51
  };
52
52
  };
53
53
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ditari/bsui",
3
- "version": "1.0.63",
3
+ "version": "1.0.65",
4
4
  "files": [
5
5
  "dist/**",
6
6
  "src"
@@ -37,38 +37,12 @@ const { getDicByKey } = useDataDicStore();
37
37
  const { modelValue, data, onSearch, onSelect, onChange } = useSelect();
38
38
 
39
39
  function useSelect() {
40
- // 保存worker启动状态
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>
@@ -29,7 +29,9 @@ const useRequestList = (service: any, options: Options = {}) => {
29
29
  totalKey: "data.total"
30
30
  };
31
31
  }
32
-
32
+ if (options.manual === undefined) {
33
+ options.manual = true;
34
+ }
33
35
  const {
34
36
  dataKey,
35
37
  pagination: { currentKey, pageSizeKey }