@aplus-frontend/ui 0.0.34 → 0.0.35

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.
@@ -23,7 +23,7 @@ declare const _default: __VLS_WithTemplateSlots< DefineComponent<__VLS_WithDefau
23
23
  validateOnRuleChange: boolean;
24
24
  validateTrigger: string;
25
25
  }>, {
26
- resetFields: () => void;
26
+ resetFields: () => Promise<void>;
27
27
  clearValidate: (name?: NamePath | undefined) => void;
28
28
  validateFields: (nameList?: string | NamePath[] | undefined, options?: ValidateOptions | undefined) => Promise<{
29
29
  [key: string]: any;
@@ -1,7 +1,7 @@
1
- import { defineComponent as A, ref as E, reactive as N, nextTick as O, toRaw as m, computed as w, openBlock as j, createBlock as S, unref as C, mergeProps as W, withCtx as q, renderSlot as z } from "vue";
2
- import { Form as D } from "ant-design-vue";
3
- import { useProvideForm as L } from "./context.mjs";
4
- import { isArray as g, cloneDeep as P, omit as K } from "lodash-unified";
1
+ import { defineComponent as A, ref as E, reactive as N, nextTick as O, toRaw as m, computed as j, openBlock as S, createBlock as W, unref as C, mergeProps as q, withCtx as z, renderSlot as D } from "vue";
2
+ import { Form as L } from "ant-design-vue";
3
+ import { useProvideForm as P } from "./context.mjs";
4
+ import { isArray as g, cloneDeep as V, omit as K } from "lodash-unified";
5
5
  import { INTERNAL_FORM_INSTANCE_MARK as $ } from "./constant.mjs";
6
6
  import { isDef as p } from "../utils/index.mjs";
7
7
  const Y = /* @__PURE__ */ A({
@@ -32,8 +32,8 @@ const Y = /* @__PURE__ */ A({
32
32
  onValidate: {},
33
33
  initialValues: {}
34
34
  },
35
- setup(_, { expose: V }) {
36
- const a = _;
35
+ setup(_, { expose: R }) {
36
+ const i = _;
37
37
  function h(e, t, l = !0) {
38
38
  var y;
39
39
  if (g(e)) {
@@ -44,33 +44,33 @@ const Y = /* @__PURE__ */ A({
44
44
  } else
45
45
  o[e] = t;
46
46
  let r = g(e) ? e[0] : e;
47
- l && ((y = a.onValuesChange) == null || y.call(a, { [r]: o[r] }, o)), d();
47
+ l && ((y = i.onValuesChange) == null || y.call(i, { [r]: o[r] }, o)), d();
48
48
  }
49
- const i = E();
50
- let f = a.initialValues || {};
51
- const o = N(a.initialValues || {});
49
+ const a = E();
50
+ let f = i.initialValues ? V(i.initialValues) : {};
51
+ const o = N(i.initialValues || {});
52
52
  let s = [];
53
- const R = () => {
53
+ const B = async () => {
54
54
  var e;
55
- (e = i.value) == null || e.resetFields(), O(() => {
56
- Object.keys(o).forEach((t) => delete o[t]), Object.assign(o, P(f)), d();
55
+ (e = a.value) == null || e.resetFields(), await O(() => {
56
+ Object.keys(o).forEach((t) => delete o[t]), Object.assign(o, V(f)), d();
57
57
  });
58
- }, B = (e) => {
58
+ }, I = (e) => {
59
59
  var t;
60
- (t = i.value) == null || t.clearValidate(e);
61
- }, I = (e, t) => {
60
+ (t = a.value) == null || t.clearValidate(e);
61
+ }, M = (e, t) => {
62
62
  var l;
63
- return (l = i.value) == null ? void 0 : l.validateFields(e, t);
64
- }, M = (e) => {
63
+ return (l = a.value) == null ? void 0 : l.validateFields(e, t);
64
+ }, T = (e) => {
65
65
  var t;
66
- return (t = i.value) == null ? void 0 : t.getFieldsValue(e);
67
- }, T = (e, t) => {
66
+ return (t = a.value) == null ? void 0 : t.getFieldsValue(e);
67
+ }, b = (e, t) => {
68
68
  var l;
69
- return (l = i.value) == null ? void 0 : l.validate(e, t);
70
- }, b = (e, t = {}) => {
69
+ return (l = a.value) == null ? void 0 : l.validate(e, t);
70
+ }, k = (e, t = {}) => {
71
71
  var l;
72
- (l = i.value) == null || l.scrollToField(e, t);
73
- }, k = (e) => {
72
+ (l = a.value) == null || l.scrollToField(e, t);
73
+ }, w = (e) => {
74
74
  Object.assign(o, e), d();
75
75
  }, F = (e, t) => {
76
76
  o[e] = t, d();
@@ -108,31 +108,31 @@ const Y = /* @__PURE__ */ A({
108
108
  });
109
109
  }
110
110
  }
111
- return L({
112
- model: w(() => o),
111
+ return P({
112
+ model: j(() => o),
113
113
  updateModel: h,
114
114
  internalInstance: {
115
115
  registerWatch: c,
116
116
  registerField: v,
117
117
  setFieldValue: F
118
118
  }
119
- }), V({
120
- resetFields: R,
121
- clearValidate: B,
122
- validateFields: I,
123
- getFieldsValue: M,
124
- validate: T,
125
- scrollToField: b,
126
- setFieldsValue: k,
119
+ }), R({
120
+ resetFields: B,
121
+ clearValidate: I,
122
+ validateFields: M,
123
+ getFieldsValue: T,
124
+ validate: b,
125
+ scrollToField: k,
126
+ setFieldsValue: w,
127
127
  setFieldValue: F,
128
128
  registerWatch: c,
129
129
  getInternalInstance: x
130
- }), (e, t) => (j(), S(C(D), W({
130
+ }), (e, t) => (S(), W(C(L), q({
131
131
  ref_key: "formRef",
132
- ref: i
133
- }, C(K)(a, ["initialValues"]), { model: o }), {
134
- default: q(() => [
135
- z(e.$slots, "default")
132
+ ref: a
133
+ }, C(K)(i, ["initialValues"]), { model: o }), {
134
+ default: z(() => [
135
+ D(e.$slots, "default")
136
136
  ]),
137
137
  _: 3
138
138
  }, 16, ["model"]));
@@ -37,7 +37,7 @@ export type WatchFunc = (values?: Recordable) => void;
37
37
  export type ApFormExpose<ModelType = any> = {
38
38
  setFieldsValue: (fields: Partial<ModelType>) => void;
39
39
  setFieldValue: (key: keyof ModelType, value: any) => void;
40
- resetFields: () => void;
40
+ resetFields: () => Promise<void>;
41
41
  clearValidate: (name?: NamePath) => void;
42
42
  validateFields: (nameList?: NamePath[] | string, options?: ValidateOptions) => Promise<Partial<ModelType>> | undefined;
43
43
  getFieldsValue: (nameList?: true | InternalNamePath[]) => Partial<ModelType> | undefined;
@@ -4,24 +4,24 @@ import { isArray as Y } from "lodash-unified";
4
4
  import "../../config-provider/index.mjs";
5
5
  import { useLocale as Z } from "../../config-provider/hooks/use-locale.mjs";
6
6
  const oe = ({
7
- manual: j = !1,
8
- defaultCurrent: y = 1,
7
+ manual: $ = !1,
8
+ defaultCurrent: j = 1,
9
9
  defaultPageSize: T = 10,
10
10
  request: D,
11
11
  defaultParams: R = {},
12
12
  defaultData: A = [],
13
13
  formatParams: z,
14
14
  paramsValueTypeMap: P,
15
- resetFieldsIgnores: V,
15
+ resetFieldsIgnores: w,
16
16
  filterFields: B = [],
17
17
  sortFields: E = []
18
18
  }) => {
19
19
  let F = 0, f = {};
20
- const L = (e) => z ? z(e) : e, l = v(), i = v(y), g = v(T), { t: b } = Z(), n = v({
20
+ const L = (e) => z ? z(e) : e, l = v(), i = v(j), g = v(T), { t: V } = Z(), n = v({
21
21
  total: 0,
22
22
  records: A,
23
23
  loading: !1
24
- }), w = async (e) => {
24
+ }), b = async (e) => {
25
25
  var r;
26
26
  const a = L(e), t = Date.now();
27
27
  F = t, n.value.loading = !0;
@@ -44,18 +44,18 @@ const oe = ({
44
44
  s && (a[t] = W(s, r));
45
45
  }
46
46
  }), a;
47
- }, M = (e) => {
47
+ }, M = async (e) => {
48
48
  var r, s, d, p, m, u, c;
49
49
  const a = ((s = (r = l.value) == null ? void 0 : r.apForm) == null ? void 0 : s.getFieldsValue()) || {}, t = {};
50
- Object.entries(a).forEach(([$, K]) => {
51
- V && V.indexOf($) > -1 && (t[$] = K);
52
- }), (p = (d = l.value) == null ? void 0 : d.apForm) == null || p.resetFields(), (c = (u = (m = l.value) == null ? void 0 : m.apForm) == null ? void 0 : u.setFieldsValue) == null || c.call(u, t), N(() => {
50
+ Object.entries(a).forEach(([O, K]) => {
51
+ w && w.indexOf(O) > -1 && (t[O] = K);
52
+ }), await ((p = (d = l.value) == null ? void 0 : d.apForm) == null ? void 0 : p.resetFields()), (c = (u = (m = l.value) == null ? void 0 : m.apForm) == null ? void 0 : u.setFieldsValue) == null || c.call(u, t), N(() => {
53
53
  e == null || e();
54
54
  });
55
55
  }, h = (e) => {
56
56
  f = e;
57
57
  const a = C(e);
58
- w(a);
58
+ b(a);
59
59
  }, q = (e) => {
60
60
  h({
61
61
  ...f,
@@ -78,7 +78,7 @@ const oe = ({
78
78
  q({
79
79
  current: r > 0 ? r : 1
80
80
  });
81
- }, O = (e, a, t) => {
81
+ }, y = (e, a, t) => {
82
82
  var m, u;
83
83
  const r = ((u = (m = l.value) == null ? void 0 : m.apForm) == null ? void 0 : u.getFieldsValue(!0)) || {};
84
84
  i.value = e.current, g.value = e.pageSize;
@@ -103,9 +103,9 @@ const oe = ({
103
103
  current: o(i),
104
104
  pageSize: o(g),
105
105
  ...e
106
- }, !j) {
106
+ }, !$) {
107
107
  const r = C(f);
108
- w(r);
108
+ b(r);
109
109
  }
110
110
  });
111
111
  const H = S(() => o(n).total === 0 ? "-" : `${o(i.value)}/${Math.ceil(
@@ -118,12 +118,12 @@ const oe = ({
118
118
  total: o(n).total,
119
119
  showSizeChanger: !0,
120
120
  showQuickJumper: !0,
121
- showTotal: (e) => `${b("ap.apTable.pagination.totalLeft", { total: e })} ${b(
121
+ showTotal: (e) => `${V("ap.apTable.pagination.totalLeft", { total: e })} ${V(
122
122
  "ap.apTable.pagination.totalRight",
123
123
  { page: o(H) }
124
124
  )}`
125
125
  },
126
- onChange: O,
126
+ onChange: y,
127
127
  dataSource: o(n).records
128
128
  }));
129
129
  return {
@@ -135,7 +135,7 @@ const oe = ({
135
135
  data: n,
136
136
  current: i,
137
137
  pageSize: g,
138
- handleTableChange: O,
138
+ handleTableChange: y,
139
139
  tableProps: I,
140
140
  dataSource: S(() => o(n).records)
141
141
  };
@@ -23,7 +23,7 @@ declare const _default: __VLS_WithTemplateSlots< DefineComponent<__VLS_WithDefau
23
23
  validateOnRuleChange: boolean;
24
24
  validateTrigger: string;
25
25
  }>, {
26
- resetFields: () => void;
26
+ resetFields: () => Promise<void>;
27
27
  clearValidate: (name?: NamePath | undefined) => void;
28
28
  validateFields: (nameList?: string | NamePath[] | undefined, options?: ValidateOptions | undefined) => Promise<{
29
29
  [key: string]: any;
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const r=require("vue"),x=require("ant-design-vue"),O=require("./context.js"),c=require("lodash-unified"),k=require("./constant.js"),p=require("../utils/index.js"),w=r.defineComponent({__name:"ap-form",props:{layout:{default:"horizontal"},labelCol:{},wrapperCol:{},colon:{type:Boolean,default:!0},labelAlign:{default:"right"},labelWrap:{type:Boolean},prefixCls:{},requiredMark:{},hideRequiredMark:{type:Boolean,default:!1},rules:{},validateMessages:{},validateOnRuleChange:{type:Boolean,default:!0},scrollToFirstError:{},onSubmit:{},name:{},validateTrigger:{default:"change"},size:{},disabled:{type:Boolean},onValuesChange:{},onFieldsChange:{},onFinish:{},onFinishFailed:{},onValidate:{},initialValues:{}},setup(C,{expose:V}){const n=C;function F(e,t,l=!0){var _;if(c.isArray(e)){let u=i;for(let d=0;d<e.length-1;d++)e[d]in u||(u[e[d]]={}),u=u[e[d]];u[e[e.length-1]]=t}else i[e]=t;let o=c.isArray(e)?e[0]:e;l&&((_=n.onValuesChange)==null||_.call(n,{[o]:i[o]},i)),f()}const s=r.ref();let g=n.initialValues||{};const i=r.reactive(n.initialValues||{});let a=[];const M=()=>{var e;(e=s.value)==null||e.resetFields(),r.nextTick(()=>{Object.keys(i).forEach(t=>delete i[t]),Object.assign(i,c.cloneDeep(g)),f()})},R=e=>{var t;(t=s.value)==null||t.clearValidate(e)},b=(e,t)=>{var l;return(l=s.value)==null?void 0:l.validateFields(e,t)},q=e=>{var t;return(t=s.value)==null?void 0:t.getFieldsValue(e)},T=(e,t)=>{var l;return(l=s.value)==null?void 0:l.validate(e,t)},A=(e,t={})=>{var l;(l=s.value)==null||l.scrollToField(e,t)},B=e=>{Object.assign(i,e),f()},v=(e,t)=>{i[e]=t,f()};function h(e,t){return t||e(r.toRaw(i)),a.push(e),()=>{a=a.filter(l=>l!==e)}}function y({initialValue:e,name:t}){if(p.isDef(e)&&p.isDef(t))if(F(t,e,!1),c.isArray(t)){let l=g;for(let o=0;o<t.length-1;o++)p.isDef(l[t[o]])||(l[t[o]]={}),l=l[t[o]];l[t[t.length-1]]=e}else g[t]=e}function I(e){if(e!==k.INTERNAL_FORM_INSTANCE_MARK){console.warn("getInternalInstance should only used at internal");return}return{registerField:y,registerWatch:h}}function f(){if(a.length){const e=r.toRaw(i);a.forEach(t=>{t(e)})}}return O.useProvideForm({model:r.computed(()=>i),updateModel:F,internalInstance:{registerWatch:h,registerField:y,setFieldValue:v}}),V({resetFields:M,clearValidate:R,validateFields:b,getFieldsValue:q,validate:T,scrollToField:A,setFieldsValue:B,setFieldValue:v,registerWatch:h,getInternalInstance:I}),(e,t)=>(r.openBlock(),r.createBlock(r.unref(x.Form),r.mergeProps({ref_key:"formRef",ref:s},r.unref(c.omit)(n,["initialValues"]),{model:i}),{default:r.withCtx(()=>[r.renderSlot(e.$slots,"default")]),_:3},16,["model"]))}});exports.default=w;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const i=require("vue"),w=require("ant-design-vue"),x=require("./context.js"),a=require("lodash-unified"),D=require("./constant.js"),p=require("../utils/index.js"),O=i.defineComponent({__name:"ap-form",props:{layout:{default:"horizontal"},labelCol:{},wrapperCol:{},colon:{type:Boolean,default:!0},labelAlign:{default:"right"},labelWrap:{type:Boolean},prefixCls:{},requiredMark:{},hideRequiredMark:{type:Boolean,default:!1},rules:{},validateMessages:{},validateOnRuleChange:{type:Boolean,default:!0},scrollToFirstError:{},onSubmit:{},name:{},validateTrigger:{default:"change"},size:{},disabled:{type:Boolean},onValuesChange:{},onFieldsChange:{},onFinish:{},onFinishFailed:{},onValidate:{},initialValues:{}},setup(V,{expose:C}){const n=V;function F(e,t,l=!0){var _;if(a.isArray(e)){let c=r;for(let d=0;d<e.length-1;d++)e[d]in c||(c[e[d]]={}),c=c[e[d]];c[e[e.length-1]]=t}else r[e]=t;let o=a.isArray(e)?e[0]:e;l&&((_=n.onValuesChange)==null||_.call(n,{[o]:r[o]},r)),f()}const s=i.ref();let g=n.initialValues?a.cloneDeep(n.initialValues):{};const r=i.reactive(n.initialValues||{});let u=[];const M=async()=>{var e;(e=s.value)==null||e.resetFields(),await i.nextTick(()=>{Object.keys(r).forEach(t=>delete r[t]),Object.assign(r,a.cloneDeep(g)),f()})},R=e=>{var t;(t=s.value)==null||t.clearValidate(e)},b=(e,t)=>{var l;return(l=s.value)==null?void 0:l.validateFields(e,t)},q=e=>{var t;return(t=s.value)==null?void 0:t.getFieldsValue(e)},T=(e,t)=>{var l;return(l=s.value)==null?void 0:l.validate(e,t)},A=(e,t={})=>{var l;(l=s.value)==null||l.scrollToField(e,t)},B=e=>{Object.assign(r,e),f()},v=(e,t)=>{r[e]=t,f()};function h(e,t){return t||e(i.toRaw(r)),u.push(e),()=>{u=u.filter(l=>l!==e)}}function y({initialValue:e,name:t}){if(p.isDef(e)&&p.isDef(t))if(F(t,e,!1),a.isArray(t)){let l=g;for(let o=0;o<t.length-1;o++)p.isDef(l[t[o]])||(l[t[o]]={}),l=l[t[o]];l[t[t.length-1]]=e}else g[t]=e}function I(e){if(e!==D.INTERNAL_FORM_INSTANCE_MARK){console.warn("getInternalInstance should only used at internal");return}return{registerField:y,registerWatch:h}}function f(){if(u.length){const e=i.toRaw(r);u.forEach(t=>{t(e)})}}return x.useProvideForm({model:i.computed(()=>r),updateModel:F,internalInstance:{registerWatch:h,registerField:y,setFieldValue:v}}),C({resetFields:M,clearValidate:R,validateFields:b,getFieldsValue:q,validate:T,scrollToField:A,setFieldsValue:B,setFieldValue:v,registerWatch:h,getInternalInstance:I}),(e,t)=>(i.openBlock(),i.createBlock(i.unref(w.Form),i.mergeProps({ref_key:"formRef",ref:s},i.unref(a.omit)(n,["initialValues"]),{model:r}),{default:i.withCtx(()=>[i.renderSlot(e.$slots,"default")]),_:3},16,["model"]))}});exports.default=O;
@@ -37,7 +37,7 @@ export type WatchFunc = (values?: Recordable) => void;
37
37
  export type ApFormExpose<ModelType = any> = {
38
38
  setFieldsValue: (fields: Partial<ModelType>) => void;
39
39
  setFieldValue: (key: keyof ModelType, value: any) => void;
40
- resetFields: () => void;
40
+ resetFields: () => Promise<void>;
41
41
  clearValidate: (name?: NamePath) => void;
42
42
  validateFields: (nameList?: NamePath[] | string, options?: ValidateOptions) => Promise<Partial<ModelType>> | undefined;
43
43
  getFieldsValue: (nameList?: true | InternalNamePath[]) => Partial<ModelType> | undefined;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("vue"),C=require("../utils.js"),I=require("lodash-unified");require("../../config-provider/index.js");const K=require("../../config-provider/hooks/use-locale.js"),N=({manual:O=!1,defaultCurrent:j=1,defaultPageSize:S=10,request:$,defaultParams:x={},defaultData:D=[],formatParams:F,paramsValueTypeMap:T,resetFieldsIgnores:P,filterFields:L=[],sortFields:M=[]})=>{let v=0,f={};const R=e=>F?F(e):e,i=t.ref(),c=t.ref(j),d=t.ref(S),{t:b}=K.useLocale(),o=t.ref({total:0,records:D,loading:!1}),z=async e=>{var n;const a=R(e),r=Date.now();v=r,o.value.loading=!0;try{const s=await $({...x,...a});v===r&&(o.value.total=s.total||((n=s.data)==null?void 0:n.length)||0,o.value.records=[...s.data||[]])}catch{v===r&&(o.value.records=[],o.value.total=0)}finally{o.value.loading=!1}},q=e=>{const a={};return Object.entries(e).forEach(([r,n])=>{if(a[r]=n,T&&n){const s=T[r];s&&(a[r]=C.parseFieldValue(s,n))}}),a},A=e=>{var n,s,g,p,h,l,u;const a=((s=(n=i.value)==null?void 0:n.apForm)==null?void 0:s.getFieldsValue())||{},r={};Object.entries(a).forEach(([y,H])=>{P&&P.indexOf(y)>-1&&(r[y]=H)}),(p=(g=i.value)==null?void 0:g.apForm)==null||p.resetFields(),(u=(l=(h=i.value)==null?void 0:h.apForm)==null?void 0:l.setFieldsValue)==null||u.call(l,r),t.nextTick(()=>{e==null||e()})},m=e=>{f=e;const a=q(e);z(a)},B=e=>{m({...f,...e})},V=()=>{var a,r;const e=((r=(a=i.value)==null?void 0:a.apForm)==null?void 0:r.getFieldsValue(!0))||{};c.value=1,m({...e,current:1,pageSize:f.pageSize||S})},E=()=>{A(V)},J=()=>{m(f)},Q=e=>{const a=t.unref(o).total-e,r=Math.ceil(a/t.unref(d)),n=t.unref(c)>r?r:t.unref(c);B({current:n>0?n:1})},w=(e,a,r)=>{var h,l;const n=((l=(h=i.value)==null?void 0:h.apForm)==null?void 0:l.getFieldsValue(!0))||{};c.value=e.current,d.value=e.pageSize;const s=I.isArray(r)?[...r]:[r],g={};for(const u of s)M.includes(u.field)&&(g[C.dataIndexToStr(u.field)]=u.order);const p={};for(const u of Object.keys(a))L.includes(u)&&(p[u]=a[u]);m({...n,filter:p,sort:g,current:e.current,pageSize:e.pageSize})};t.onMounted(()=>{var a,r;const e=((r=(a=i.value)==null?void 0:a.apForm)==null?void 0:r.getFieldsValue(!0))||{};if(f={current:t.unref(c),pageSize:t.unref(d),...e},!O){const n=q(f);z(n)}});const U=t.computed(()=>t.unref(o).total===0?"-":`${t.unref(c.value)}/${Math.ceil(t.unref(o).total/t.unref(d))}`),G=t.computed(()=>({loading:t.unref(o).loading,pagination:{current:t.unref(c),pageSize:t.unref(d),total:t.unref(o).total,showSizeChanger:!0,showQuickJumper:!0,showTotal:e=>`${b("ap.apTable.pagination.totalLeft",{total:e})} ${b("ap.apTable.pagination.totalRight",{page:t.unref(U)})}`},onChange:w,dataSource:t.unref(o).records}));return{formRef:i,submit:V,reset:E,refresh:J,refreshByDelete:Q,data:o,current:c,pageSize:d,handleTableChange:w,tableProps:G,dataSource:t.computed(()=>t.unref(o).records)}};exports.useTablePaging=N;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("vue"),C=require("../utils.js"),I=require("lodash-unified");require("../../config-provider/index.js");const K=require("../../config-provider/hooks/use-locale.js"),N=({manual:O=!1,defaultCurrent:j=1,defaultPageSize:S=10,request:$,defaultParams:x={},defaultData:D=[],formatParams:F,paramsValueTypeMap:T,resetFieldsIgnores:P,filterFields:L=[],sortFields:M=[]})=>{let v=0,f={};const R=e=>F?F(e):e,i=t.ref(),c=t.ref(j),d=t.ref(S),{t:b}=K.useLocale(),o=t.ref({total:0,records:D,loading:!1}),z=async e=>{var n;const a=R(e),r=Date.now();v=r,o.value.loading=!0;try{const s=await $({...x,...a});v===r&&(o.value.total=s.total||((n=s.data)==null?void 0:n.length)||0,o.value.records=[...s.data||[]])}catch{v===r&&(o.value.records=[],o.value.total=0)}finally{o.value.loading=!1}},q=e=>{const a={};return Object.entries(e).forEach(([r,n])=>{if(a[r]=n,T&&n){const s=T[r];s&&(a[r]=C.parseFieldValue(s,n))}}),a},A=async e=>{var n,s,g,p,h,l,u;const a=((s=(n=i.value)==null?void 0:n.apForm)==null?void 0:s.getFieldsValue())||{},r={};Object.entries(a).forEach(([V,H])=>{P&&P.indexOf(V)>-1&&(r[V]=H)}),await((p=(g=i.value)==null?void 0:g.apForm)==null?void 0:p.resetFields()),(u=(l=(h=i.value)==null?void 0:h.apForm)==null?void 0:l.setFieldsValue)==null||u.call(l,r),t.nextTick(()=>{e==null||e()})},m=e=>{f=e;const a=q(e);z(a)},B=e=>{m({...f,...e})},w=()=>{var a,r;const e=((r=(a=i.value)==null?void 0:a.apForm)==null?void 0:r.getFieldsValue(!0))||{};c.value=1,m({...e,current:1,pageSize:f.pageSize||S})},E=()=>{A(w)},J=()=>{m(f)},Q=e=>{const a=t.unref(o).total-e,r=Math.ceil(a/t.unref(d)),n=t.unref(c)>r?r:t.unref(c);B({current:n>0?n:1})},y=(e,a,r)=>{var h,l;const n=((l=(h=i.value)==null?void 0:h.apForm)==null?void 0:l.getFieldsValue(!0))||{};c.value=e.current,d.value=e.pageSize;const s=I.isArray(r)?[...r]:[r],g={};for(const u of s)M.includes(u.field)&&(g[C.dataIndexToStr(u.field)]=u.order);const p={};for(const u of Object.keys(a))L.includes(u)&&(p[u]=a[u]);m({...n,filter:p,sort:g,current:e.current,pageSize:e.pageSize})};t.onMounted(()=>{var a,r;const e=((r=(a=i.value)==null?void 0:a.apForm)==null?void 0:r.getFieldsValue(!0))||{};if(f={current:t.unref(c),pageSize:t.unref(d),...e},!O){const n=q(f);z(n)}});const U=t.computed(()=>t.unref(o).total===0?"-":`${t.unref(c.value)}/${Math.ceil(t.unref(o).total/t.unref(d))}`),G=t.computed(()=>({loading:t.unref(o).loading,pagination:{current:t.unref(c),pageSize:t.unref(d),total:t.unref(o).total,showSizeChanger:!0,showQuickJumper:!0,showTotal:e=>`${b("ap.apTable.pagination.totalLeft",{total:e})} ${b("ap.apTable.pagination.totalRight",{page:t.unref(U)})}`},onChange:y,dataSource:t.unref(o).records}));return{formRef:i,submit:w,reset:E,refresh:J,refreshByDelete:Q,data:o,current:c,pageSize:d,handleTableChange:y,tableProps:G,dataSource:t.computed(()=>t.unref(o).records)}};exports.useTablePaging=N;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aplus-frontend/ui",
3
- "version": "0.0.34",
3
+ "version": "0.0.35",
4
4
  "main": "lib/index.js",
5
5
  "module": "es/index.mjs",
6
6
  "files": [