@duxweb/dvha-core 1.0.17 → 1.0.18
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/hooks/form.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("lodash-es"),i=require("vue"),d=require("./data.cjs");function b(e){const n=i.toRef(e,"form",{}),c=i.ref(u.cloneDeep(e.form||{})),o=i.computed(()=>e.action==="edit"||e.id),{data:m,isLoading:r,refetch:f}=d.useOne({path:e.path||"",id:e.id,options:{enabled:!!e.id},providerName:e.providerName});i.watch([()=>e.action,()=>e.id],async()=>{var t;if(!o.value)return;await f();const a=u.cloneDeep(((t=m.value)==null?void 0:t.data)||{});Object.assign(n.value,a),Object.assign(c.value,a)},{immediate:!0});const g=()=>{const a=u.cloneDeep(c.value);Object.assign(n.value,a)},l=d.useCreate({path:e.path??"",data:n.value,onSuccess:a=>{var t;(t=e.onSuccess)==null||t.call(e,a)},onError:a=>{var t;(t=e.onError)==null||t.call(e,a)},providerName:e.providerName}),v=d.useUpdate({path:e.path??"",id:e.id,data:n.value,onSuccess:a=>{var t;(t=e.onSuccess)==null||t.call(e,a)},onError:a=>{var t;(t=e.onError)==null||t.call(e,a)},providerName:e.providerName}),s=a=>{e.action==="create"?l.mutate({data:a||n.value}):v.mutate({id:e.id,data:a||n.value})},h=i.computed(()=>r.value||l.isLoading.value||v.isLoading.value);return{form:n,initData:c,isLoading:h,isEdit:o,onSubmit:s,onReset:g}}exports.useForm=b;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("lodash-es"),i=require("vue"),d=require("./data.cjs");function b(e){const n=i.toRef(e,"form",{}),c=i.ref(u.cloneDeep(e.form||{})),o=i.computed(()=>e.action==="edit"||e.id),{data:m,isLoading:r,refetch:f}=d.useOne({path:e.path||"",id:e.id,options:{enabled:!!e.id},providerName:e.providerName});i.watch([()=>e.action,()=>e.id],async()=>{var t;if(!o.value)return;await f();const a=u.cloneDeep(((t=m.value)==null?void 0:t.data)||{});Object.assign(n.value,a),Object.assign(c.value,a)},{immediate:!0,deep:!0});const g=()=>{const a=u.cloneDeep(c.value);Object.assign(n.value,a)},l=d.useCreate({path:e.path??"",data:n.value,onSuccess:a=>{var t;(t=e.onSuccess)==null||t.call(e,a)},onError:a=>{var t;(t=e.onError)==null||t.call(e,a)},providerName:e.providerName}),v=d.useUpdate({path:e.path??"",id:e.id,data:n.value,onSuccess:a=>{var t;(t=e.onSuccess)==null||t.call(e,a)},onError:a=>{var t;(t=e.onError)==null||t.call(e,a)},providerName:e.providerName}),s=a=>{e.action==="create"?l.mutate({data:a||n.value}):v.mutate({id:e.id,data:a||n.value})},h=i.computed(()=>r.value||l.isLoading.value||v.isLoading.value);return{form:n,initData:c,isLoading:h,isEdit:o,onSubmit:s,onReset:g}}exports.useForm=b;
|
package/dist/cjs/hooks/tree.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("vue");require("../utils/bus.cjs");const s=require("../utils/tree.cjs"),v=require("./data.cjs");function m(e){const{data:o,isLoading:l}=v.useList({get path(){return e.path||""},get filters(){return e.params},get providerName(){return e.providerName}}),u=a.computed(()=>{var r,n,i,t,d,c;return e.converTree?s.arrayToTree(((n=o.value)==null?void 0:n.data)||[],{idKey:((i=e.treeOptions)==null?void 0:i.valueKey)||"id",parentKey:((t=e.treeOptions)==null?void 0:t.parentKey)||"
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("vue");require("../utils/bus.cjs");const s=require("../utils/tree.cjs"),v=require("./data.cjs");function m(e){const{data:o,isLoading:l}=v.useList({get path(){return e.path||""},get filters(){return e.params},get providerName(){return e.providerName}}),u=a.computed(()=>{var r,n,i,t,d,c;return e.converTree?s.arrayToTree(((n=o.value)==null?void 0:n.data)||[],{idKey:((i=e.treeOptions)==null?void 0:i.valueKey)||"id",parentKey:((t=e.treeOptions)==null?void 0:t.parentKey)||"parent_id",sortKey:((d=e.treeOptions)==null?void 0:d.sortKey)||"sort",childrenKey:((c=e.treeOptions)==null?void 0:c.childrenKey)||"children"}):((r=o.value)==null?void 0:r.data)||[]}),y=a.computed(()=>{var r,n;return s.treeToArr(u.value,((r=e.treeOptions)==null?void 0:r.valueKey)||"id",((n=e.treeOptions)==null?void 0:n.childrenKey)||"children")}),h=a.computed(()=>l.value);return{options:a.computed(()=>{const r=n=>n.map(i=>{const t={...i};return Array.isArray(t.children)&&(t.children.length===0?delete t.children:t.children=r(t.children)),t});return r(u.value||[])}),loading:h,expanded:y}}exports.useTree=m;
|
package/dist/esm/hooks/form.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { cloneDeep as
|
|
1
|
+
import { cloneDeep as d } from "lodash-es";
|
|
2
2
|
import { toRef as N, ref as b, computed as o, watch as E } from "vue";
|
|
3
3
|
import { useOne as L, useCreate as O, useUpdate as S } from "./data.js";
|
|
4
4
|
function w(e) {
|
|
5
|
-
const i = N(e, "form", {}), n = b(
|
|
5
|
+
const i = N(e, "form", {}), n = b(d(e.form || {})), c = o(() => e.action === "edit" || e.id), { data: v, isLoading: l, refetch: r } = L({
|
|
6
6
|
path: e.path || "",
|
|
7
7
|
id: e.id,
|
|
8
8
|
options: {
|
|
@@ -12,16 +12,17 @@ function w(e) {
|
|
|
12
12
|
});
|
|
13
13
|
E([() => e.action, () => e.id], async () => {
|
|
14
14
|
var t;
|
|
15
|
-
if (!
|
|
15
|
+
if (!c.value)
|
|
16
16
|
return;
|
|
17
|
-
await
|
|
18
|
-
const a =
|
|
17
|
+
await r();
|
|
18
|
+
const a = d(((t = v.value) == null ? void 0 : t.data) || {});
|
|
19
19
|
Object.assign(i.value, a), Object.assign(n.value, a);
|
|
20
20
|
}, {
|
|
21
|
-
immediate: !0
|
|
21
|
+
immediate: !0,
|
|
22
|
+
deep: !0
|
|
22
23
|
});
|
|
23
|
-
const
|
|
24
|
-
const a =
|
|
24
|
+
const f = () => {
|
|
25
|
+
const a = d(n.value);
|
|
25
26
|
Object.assign(i.value, a);
|
|
26
27
|
}, u = O({
|
|
27
28
|
path: e.path ?? "",
|
|
@@ -60,9 +61,9 @@ function w(e) {
|
|
|
60
61
|
form: i,
|
|
61
62
|
initData: n,
|
|
62
63
|
isLoading: h,
|
|
63
|
-
isEdit:
|
|
64
|
+
isEdit: c,
|
|
64
65
|
onSubmit: g,
|
|
65
|
-
onReset:
|
|
66
|
+
onReset: f
|
|
66
67
|
};
|
|
67
68
|
}
|
|
68
69
|
export {
|
package/dist/esm/hooks/tree.js
CHANGED
|
@@ -17,7 +17,7 @@ function T(e) {
|
|
|
17
17
|
var r, n, i, t, l, s;
|
|
18
18
|
return e.converTree ? m(((n = o.value) == null ? void 0 : n.data) || [], {
|
|
19
19
|
idKey: ((i = e.treeOptions) == null ? void 0 : i.valueKey) || "id",
|
|
20
|
-
parentKey: ((t = e.treeOptions) == null ? void 0 : t.parentKey) || "
|
|
20
|
+
parentKey: ((t = e.treeOptions) == null ? void 0 : t.parentKey) || "parent_id",
|
|
21
21
|
sortKey: ((l = e.treeOptions) == null ? void 0 : l.sortKey) || "sort",
|
|
22
22
|
childrenKey: ((s = e.treeOptions) == null ? void 0 : s.childrenKey) || "children"
|
|
23
23
|
}) : ((r = o.value) == null ? void 0 : r.data) || [];
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { MaybeRef } from 'vue';
|
|
2
2
|
import type { IDataProviderError, IDataProviderResponse } from '../types';
|
|
3
|
+
type Key = string | number | undefined;
|
|
3
4
|
export interface IUseFormProps {
|
|
4
5
|
path?: string;
|
|
5
|
-
id?:
|
|
6
|
+
id?: Key;
|
|
6
7
|
form?: MaybeRef<Record<string, any>>;
|
|
7
8
|
onSuccess?: (data: IDataProviderResponse) => void;
|
|
8
9
|
onError?: (error: IDataProviderError) => void;
|
|
@@ -13,7 +14,8 @@ export declare function useForm(props: IUseFormProps): {
|
|
|
13
14
|
form: import("vue").Ref<MaybeRef<Record<string, any>>, MaybeRef<Record<string, any>>>;
|
|
14
15
|
initData: any;
|
|
15
16
|
isLoading: import("vue").ComputedRef<boolean>;
|
|
16
|
-
isEdit: import("vue").ComputedRef<
|
|
17
|
+
isEdit: import("vue").ComputedRef<true | Key>;
|
|
17
18
|
onSubmit: (data?: Record<string, any>) => void;
|
|
18
19
|
onReset: () => void;
|
|
19
20
|
};
|
|
21
|
+
export {};
|
|
@@ -5,7 +5,7 @@ export interface UseExtendFormProps extends IUseFormProps {
|
|
|
5
5
|
}
|
|
6
6
|
export declare function useExtendForm(props: UseExtendFormProps): {
|
|
7
7
|
isLoading: import("vue").ComputedRef<boolean>;
|
|
8
|
-
isEdit: import("vue").ComputedRef<
|
|
8
|
+
isEdit: import("vue").ComputedRef<true | (string | number | undefined)>;
|
|
9
9
|
form: import("vue").Ref<import("vue").MaybeRef<Record<string, any>>, import("vue").MaybeRef<Record<string, any>>>;
|
|
10
10
|
onSubmit: (data?: Record<string, any>) => void;
|
|
11
11
|
onReset: () => void;
|