@duxweb/dvha-core 1.0.45 → 1.0.47

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.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const S=require("@vueuse/core"),a=require("vue"),H=require("./data.cjs"),E=require("./exportCsv.cjs"),J=require("./importCsv.cjs");function K(t){const u=a.toRef(t,"filters",{}),r=a.toRef(t,"sorters",{}),n=a.toRef(typeof t.pagination=="object"?t.pagination:{page:1,pageSize:20}),d=[10,20,30,40,50,100],p=e=>d.includes(e)?d:Array.from({length:5},(v,G)=>e*(G+1)),i=a.ref(p(n.value.pageSize));a.watch(()=>n.value.pageSize,e=>{i.value.includes(e)||(i.value=p(e))});const C=e=>{n.value.pageSize=e,n.value.page=1},P=e=>{n.value.page=e},{data:s,isLoading:z,refetch:R}=H.useList({path:t.path,pagination:t.pagination?n.value:!1,filters:u.value,sorters:r.value}),I=a.computed(()=>s.value?.data||[]),m=a.computed(()=>s.value?.meta||{}),f=a.computed(()=>t.total?.(s.value)||m.value?.[t.totalField||"total"]||0),L=a.computed(()=>Math.ceil(f.value/n.value.pageSize)||0),k=e=>{u.value=e},w=e=>{r.value=e},o=a.ref([]),h=a.computed(()=>o.value.length>0&&o.value.length===s.value?.data?.length),U=a.computed(()=>o.value.length>0&&o.value.length<(s.value?.data?.length||0)),q=e=>{const v=o.value.indexOf(e);v>-1?o.value.splice(v,1):o.value.push(e)},y=e=>{o.value=e},F=e=>o.value.includes(e),A=()=>{h.value?o.value=[]:o.value=s.value?.data?.map(e=>e[t.key||"id"]).filter(e=>e!=null)||[]};a.watch(()=>s.value?.data,()=>{o.value=[]});const c=()=>{o.value=[],R()},g=a.ref({page:1,pageSize:100}),{trigger:b,isLoading:M}=E.useExportCsv({path:t.path,filters:u.value||{},sorters:r.value||{},maxPage:()=>t.exportMaxPage||0,pagination:g.value,filename:t.exportFilename||"data.csv",onSuccess:e=>{t.onExportSuccess?.(e),g.value.page=1},onProgress:e=>{t.onExportProgress?.(e)},onError:e=>{t.onExportError?.(e),g.value.page=1}}),j=S.reactiveComputed(()=>({ids:o.value})),{trigger:O,isLoading:T}=E.useExportCsv({path:t.path,filters:j,maxPage:1,filename:t.exportFilename||"rows.csv",onSuccess:e=>{t.onExportSuccess?.(e)},onError:e=>{t.onExportError?.(e)}}),{open:V,isLoading:_}=J.useImportCsv({path:t.path,onComplete:e=>{t.onImportSuccess?.(e)},onProgress:e=>{t.onImportProgress?.(e)},onError:e=>{t.onImportError?.(e)}}),l=a.ref(!1),{remaining:$,start:x,stop:B}=S.useCountdown(10,{onComplete:()=>{c(),x()}}),D=()=>{l.value=!l.value,l.value?(c(),x()):B()};return{list:I,meta:m,isLoading:z,pagination:n,filters:u,sorters:r,onRefresh:c,onUpdateFilters:k,onUpdateSorters:w,checkeds:o,isAllChecked:h,isIndeterminate:U,toggleChecked:q,isChecked:F,toggleSelectAll:A,onUpdateChecked:y,total:f,page:a.computed(()=>n.value.page),pageSize:a.computed(()=>n.value.pageSize),pageSizes:i.value,pageCount:L,onUpdatePage:P,onUpdatePageSize:C,onExport:b,isExporting:M,onExportRows:O,isExportingRows:T,onImport:V,isImporting:_,autoRefetch:l,onAutoRefetch:D,autoCountdown:$}}exports.useExtendList=K;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const S=require("@vueuse/core"),o=require("vue"),E=require("./data.cjs"),C=require("./exportCsv.cjs"),Q=require("./importCsv.cjs");function W(t){const r=o.toRef(t,"filters",{}),c=o.toRef(t,"sorters",{}),n=o.toRef(typeof t.pagination=="object"?t.pagination:{page:1,pageSize:20}),d=[10,20,30,40,50,100],h=e=>d.includes(e)?d:Array.from({length:5},(l,N)=>e*(N+1)),g=o.ref(h(n.value.pageSize));o.watch(()=>n.value.pageSize,e=>{g.value.includes(e)||(g.value=h(e))});const P=e=>{n.value.pageSize=e,n.value.page=1},z=e=>{n.value.page=e},{data:s,isLoading:L,refetch:R}=E.useList({path:t.path,pagination:t.pagination?n.value:!1,filters:r.value,sorters:c.value}),b=o.computed(()=>s.value?.data||[]),m=o.computed(()=>s.value?.meta||{}),f=o.computed(()=>t.total?.(s.value)||m.value?.[t.totalField||"total"]||0),I=o.computed(()=>Math.ceil(f.value/n.value.pageSize)||0),k=e=>{r.value=e},w=e=>{c.value=e},a=o.ref([]),p=o.computed(()=>a.value.length>0&&a.value.length===s.value?.data?.length),y=o.computed(()=>a.value.length>0&&a.value.length<(s.value?.data?.length||0)),U=e=>{const l=a.value.indexOf(e);l>-1?a.value.splice(l,1):a.value.push(e)},q=e=>{a.value=e},F=e=>a.value.includes(e),M=()=>{p.value?a.value=[]:a.value=s.value?.data?.map(e=>e[t.key||"id"]).filter(e=>e!=null)||[]};o.watch(()=>s.value?.data,()=>{a.value=[]});const u=()=>{a.value=[],R()},v=o.ref({page:1,pageSize:100}),{trigger:A,isLoading:B}=C.useExportCsv({path:t.path,filters:r.value||{},sorters:c.value||{},maxPage:()=>t.exportMaxPage||0,pagination:v.value,filename:t.exportFilename||"data.csv",onSuccess:e=>{t.onExportSuccess?.(e),v.value.page=1},onProgress:e=>{t.onExportProgress?.(e)},onError:e=>{t.onExportError?.(e),v.value.page=1}}),O=S.reactiveComputed(()=>({ids:a.value})),{trigger:j,isLoading:T}=C.useExportCsv({path:t.path,filters:O,maxPage:1,filename:t.exportFilename||"rows.csv",onSuccess:e=>{t.onExportSuccess?.(e)},onError:e=>{t.onExportError?.(e)}}),{open:$,isLoading:V}=Q.useImportCsv({path:t.path,onComplete:e=>{t.onImportSuccess?.(e)},onProgress:e=>{t.onImportProgress?.(e)},onError:e=>{t.onImportError?.(e)}}),i=o.ref(!1),{remaining:_,start:x,stop:D}=S.useCountdown(10,{onComplete:()=>{u(),x()}}),G=()=>{i.value=!i.value,i.value?(u(),x()):D()},{mutate:H,isLoading:J}=E.useCustomMutation({path:t.batchPath||`${t.path}/batch`,method:"POST",onSuccess:e=>{t?.onBatchSuccess?.(e),a.value=[],u()},onError:e=>{t?.onBatchError?.(e),u()}}),K=(e,l)=>{H({payload:{type:e,ids:a.value,...l||{}}})};return{list:b,meta:m,isLoading:L,pagination:n,filters:r,sorters:c,onRefresh:u,onUpdateFilters:k,onUpdateSorters:w,checkeds:a,isAllChecked:p,isIndeterminate:y,toggleChecked:U,isChecked:F,toggleSelectAll:M,onUpdateChecked:q,total:f,page:o.computed(()=>n.value.page),pageSize:o.computed(()=>n.value.pageSize),pageSizes:g.value,pageCount:I,onUpdatePage:z,onUpdatePageSize:P,onExport:A,isExporting:B,onExportRows:j,isExportingRows:T,onImport:$,isImporting:V,autoRefetch:i,onAutoRefetch:G,autoCountdown:_,onBatch:K,isBatching:J}}exports.useExtendList=W;
@@ -1,78 +1,78 @@
1
- import { reactiveComputed as T, useCountdown as V } from "@vueuse/core";
2
- import { toRef as m, ref as u, watch as C, computed as n } from "vue";
3
- import { useList as W } from "./data.js";
4
- import { useExportCsv as z } from "./exportCsv.js";
5
- import { useImportCsv as X } from "./importCsv.js";
6
- function ae(t) {
7
- const r = m(t, "filters", {}), s = m(t, "sorters", {}), o = m(typeof t.pagination == "object" ? t.pagination : {
1
+ import { reactiveComputed as W, useCountdown as X } from "@vueuse/core";
2
+ import { toRef as h, ref as g, watch as C, computed as n } from "vue";
3
+ import { useList as Y, useCustomMutation as Z } from "./data.js";
4
+ import { useExportCsv as P } from "./exportCsv.js";
5
+ import { useImportCsv as ee } from "./importCsv.js";
6
+ function se(t) {
7
+ const u = h(t, "filters", {}), i = h(t, "sorters", {}), o = h(typeof t.pagination == "object" ? t.pagination : {
8
8
  page: 1,
9
9
  pageSize: 20
10
- }), f = [10, 20, 30, 40, 50, 100], p = (e) => f.includes(e) ? f : Array.from({
10
+ }), m = [10, 20, 30, 40, 50, 100], f = (e) => m.includes(e) ? m : Array.from({
11
11
  length: 5
12
- }, (d, Q) => e * (Q + 1)), c = u(p(o.value.pageSize));
12
+ }, (r, V) => e * (V + 1)), v = g(f(o.value.pageSize));
13
13
  C(() => o.value.pageSize, (e) => {
14
- c.value.includes(e) || (c.value = p(e));
14
+ v.value.includes(e) || (v.value = f(e));
15
15
  });
16
- const P = (e) => {
16
+ const z = (e) => {
17
17
  o.value.pageSize = e, o.value.page = 1;
18
- }, I = (e) => {
18
+ }, L = (e) => {
19
19
  o.value.page = e;
20
20
  }, {
21
21
  data: l,
22
- isLoading: k,
23
- refetch: L
24
- } = W({
22
+ isLoading: I,
23
+ refetch: k
24
+ } = Y({
25
25
  path: t.path,
26
26
  pagination: t.pagination ? o.value : !1,
27
- filters: r.value,
28
- sorters: s.value
29
- }), R = n(() => l.value?.data || []), h = n(() => l.value?.meta || {}), x = n(() => t.total?.(l.value) || h.value?.[t.totalField || "total"] || 0), w = n(() => Math.ceil(x.value / o.value.pageSize) || 0), F = (e) => {
30
- r.value = e;
31
- }, U = (e) => {
32
- s.value = e;
33
- }, a = u([]), S = n(() => a.value.length > 0 && a.value.length === l.value?.data?.length), A = n(() => a.value.length > 0 && a.value.length < (l.value?.data?.length || 0)), y = (e) => {
34
- const d = a.value.indexOf(e);
35
- d > -1 ? a.value.splice(d, 1) : a.value.push(e);
36
- }, M = (e) => {
27
+ filters: u.value,
28
+ sorters: i.value
29
+ }), R = n(() => l.value?.data || []), p = n(() => l.value?.meta || {}), x = n(() => t.total?.(l.value) || p.value?.[t.totalField || "total"] || 0), b = n(() => Math.ceil(x.value / o.value.pageSize) || 0), w = (e) => {
30
+ u.value = e;
31
+ }, F = (e) => {
32
+ i.value = e;
33
+ }, a = g([]), S = n(() => a.value.length > 0 && a.value.length === l.value?.data?.length), U = n(() => a.value.length > 0 && a.value.length < (l.value?.data?.length || 0)), y = (e) => {
34
+ const r = a.value.indexOf(e);
35
+ r > -1 ? a.value.splice(r, 1) : a.value.push(e);
36
+ }, A = (e) => {
37
37
  a.value = e;
38
- }, b = (e) => a.value.includes(e), j = () => {
38
+ }, B = (e) => a.value.includes(e), M = () => {
39
39
  S.value ? a.value = [] : a.value = l.value?.data?.map((e) => e[t.key || "id"]).filter((e) => e != null) || [];
40
40
  };
41
41
  C(() => l.value?.data, () => {
42
42
  a.value = [];
43
43
  });
44
- const g = () => {
45
- a.value = [], L();
46
- }, v = u({
44
+ const s = () => {
45
+ a.value = [], k();
46
+ }, d = g({
47
47
  page: 1,
48
48
  pageSize: 100
49
49
  }), {
50
50
  trigger: O,
51
- isLoading: _
52
- } = z({
51
+ isLoading: j
52
+ } = P({
53
53
  path: t.path,
54
- filters: r.value || {},
55
- sorters: s.value || {},
54
+ filters: u.value || {},
55
+ sorters: i.value || {},
56
56
  maxPage: () => t.exportMaxPage || 0,
57
- pagination: v.value,
57
+ pagination: d.value,
58
58
  filename: t.exportFilename || "data.csv",
59
59
  onSuccess: (e) => {
60
- t.onExportSuccess?.(e), v.value.page = 1;
60
+ t.onExportSuccess?.(e), d.value.page = 1;
61
61
  },
62
62
  onProgress: (e) => {
63
63
  t.onExportProgress?.(e);
64
64
  },
65
65
  onError: (e) => {
66
- t.onExportError?.(e), v.value.page = 1;
66
+ t.onExportError?.(e), d.value.page = 1;
67
67
  }
68
- }), q = T(() => ({
68
+ }), T = W(() => ({
69
69
  ids: a.value
70
70
  })), {
71
- trigger: B,
72
- isLoading: D
73
- } = z({
71
+ trigger: _,
72
+ isLoading: $
73
+ } = P({
74
74
  path: t.path,
75
- filters: q,
75
+ filters: T,
76
76
  maxPage: 1,
77
77
  filename: t.exportFilename || "rows.csv",
78
78
  onSuccess: (e) => {
@@ -82,9 +82,9 @@ function ae(t) {
82
82
  t.onExportError?.(e);
83
83
  }
84
84
  }), {
85
- open: G,
86
- isLoading: H
87
- } = X({
85
+ open: q,
86
+ isLoading: D
87
+ } = ee({
88
88
  path: t.path,
89
89
  onComplete: (e) => {
90
90
  t.onImportSuccess?.(e);
@@ -95,58 +95,81 @@ function ae(t) {
95
95
  onError: (e) => {
96
96
  t.onImportError?.(e);
97
97
  }
98
- }), i = u(!1), {
99
- remaining: J,
98
+ }), c = g(!1), {
99
+ remaining: G,
100
100
  start: E,
101
- stop: K
102
- } = V(10, {
101
+ stop: H
102
+ } = X(10, {
103
103
  onComplete: () => {
104
- g(), E();
104
+ s(), E();
105
+ }
106
+ }), J = () => {
107
+ c.value = !c.value, c.value ? (s(), E()) : H();
108
+ }, {
109
+ mutate: K,
110
+ isLoading: N
111
+ } = Z({
112
+ path: t.batchPath || `${t.path}/batch`,
113
+ method: "POST",
114
+ onSuccess: (e) => {
115
+ t?.onBatchSuccess?.(e), a.value = [], s();
116
+ },
117
+ onError: (e) => {
118
+ t?.onBatchError?.(e), s();
105
119
  }
106
- }), N = () => {
107
- i.value = !i.value, i.value ? (g(), E()) : K();
120
+ }), Q = (e, r) => {
121
+ K({
122
+ payload: {
123
+ type: e,
124
+ ids: a.value,
125
+ ...r || {}
126
+ }
127
+ });
108
128
  };
109
129
  return {
110
130
  // 数据
111
131
  list: R,
112
- meta: h,
113
- isLoading: k,
132
+ meta: p,
133
+ isLoading: I,
114
134
  pagination: o,
115
- filters: r,
116
- sorters: s,
117
- onRefresh: g,
118
- onUpdateFilters: F,
119
- onUpdateSorters: U,
135
+ filters: u,
136
+ sorters: i,
137
+ onRefresh: s,
138
+ onUpdateFilters: w,
139
+ onUpdateSorters: F,
120
140
  // 选中
121
141
  checkeds: a,
122
142
  isAllChecked: S,
123
- isIndeterminate: A,
143
+ isIndeterminate: U,
124
144
  toggleChecked: y,
125
- isChecked: b,
126
- toggleSelectAll: j,
127
- onUpdateChecked: M,
145
+ isChecked: B,
146
+ toggleSelectAll: M,
147
+ onUpdateChecked: A,
128
148
  // 分页
129
149
  total: x,
130
150
  page: n(() => o.value.page),
131
151
  pageSize: n(() => o.value.pageSize),
132
- pageSizes: c.value,
133
- pageCount: w,
134
- onUpdatePage: I,
135
- onUpdatePageSize: P,
152
+ pageSizes: v.value,
153
+ pageCount: b,
154
+ onUpdatePage: L,
155
+ onUpdatePageSize: z,
136
156
  // 导出
137
157
  onExport: O,
138
- isExporting: _,
139
- onExportRows: B,
140
- isExportingRows: D,
158
+ isExporting: j,
159
+ onExportRows: _,
160
+ isExportingRows: $,
141
161
  // 导入
142
- onImport: G,
143
- isImporting: H,
162
+ onImport: q,
163
+ isImporting: D,
144
164
  // 自动刷新
145
- autoRefetch: i,
146
- onAutoRefetch: N,
147
- autoCountdown: J
165
+ autoRefetch: c,
166
+ onAutoRefetch: J,
167
+ autoCountdown: G,
168
+ // 批量操作
169
+ onBatch: Q,
170
+ isBatching: N
148
171
  };
149
172
  }
150
173
  export {
151
- ae as useExtendList
174
+ se as useExtendList
152
175
  };
@@ -14,6 +14,7 @@ export interface UseExtendListProps {
14
14
  pagination?: boolean | IListPagination;
15
15
  exportFilename?: string;
16
16
  exportMaxPage?: number;
17
+ batchPath?: string;
17
18
  total?: (data?: IDataProviderResponse) => number;
18
19
  onExportSuccess?: (data?: IDataProviderResponse) => void;
19
20
  onExportProgress?: (data?: IDataProviderPagination) => void;
@@ -21,6 +22,8 @@ export interface UseExtendListProps {
21
22
  onImportSuccess?: (progress?: IImportProgress) => void;
22
23
  onImportProgress?: (progress?: IImportProgress) => void;
23
24
  onImportError?: (error?: IDataProviderError) => void;
25
+ onBatchSuccess?: (data?: IDataProviderResponse) => void;
26
+ onBatchError?: (error?: IDataProviderError) => void;
24
27
  }
25
28
  export declare function useExtendList(props: UseExtendListProps): {
26
29
  list: import("vue").ComputedRef<Record<string, any>[]>;
@@ -61,5 +64,7 @@ export declare function useExtendList(props: UseExtendListProps): {
61
64
  autoRefetch: import("vue").Ref<boolean, boolean>;
62
65
  onAutoRefetch: () => void;
63
66
  autoCountdown: import("vue").ShallowRef<number>;
67
+ onBatch: (type: string, data?: Record<string, any>) => void;
68
+ isBatching: import("vue").ComputedRef<boolean>;
64
69
  };
65
70
  export {};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@duxweb/dvha-core",
3
3
  "type": "module",
4
- "version": "1.0.45",
4
+ "version": "1.0.47",
5
5
  "author": "DuxWeb",
6
6
  "license": "MIT",
7
7
  "repository": {