@dazhicheng/ui 1.6.44 → 1.6.45

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,7 +1,7 @@
1
- import { defineComponent as H, useSlots as J, ref as K, computed as C, toValue as Q, nextTick as y, watch as W, createBlock as M, openBlock as B, unref as d, createSlots as P, withCtx as A, renderSlot as h, createVNode as X, renderList as S, normalizeProps as b, guardReactiveProps as V, createCommentVNode as Y } from "vue";
1
+ import { defineComponent as H, useSlots as J, ref as F, computed as K, toValue as Q, nextTick as y, watch as W, createBlock as C, openBlock as B, unref as d, createSlots as P, withCtx as A, renderSlot as g, createVNode as X, renderList as S, normalizeProps as b, guardReactiveProps as V, createCommentVNode as Y } from "vue";
2
2
  import "axios";
3
3
  import { ElCheckbox as Z, ElMessage as O } from "element-plus";
4
- import { isFunction as m } from "../../packages/utils/src/is.js";
4
+ import { isFunction as n } from "../../packages/utils/src/is.js";
5
5
  import "dayjs";
6
6
  import "numeral";
7
7
  import "xe-utils";
@@ -31,7 +31,7 @@ import "../tt-form/src/shared/zod-defaults.js";
31
31
  import { useGroupForm as te } from "../tt-form/src/group-form/useGroupForm.js";
32
32
  import "../tt-modal/index.js";
33
33
  import { useModalFormSlot as ie } from "./hooks/useModalFormSlot.js";
34
- import { useModalRender as ne } from "../tt-modal/src/hooks/useModalRender.js";
34
+ import { useModalRender as se } from "../tt-modal/src/hooks/useModalRender.js";
35
35
  const xe = /* @__PURE__ */ H({
36
36
  name: "TtModalForm",
37
37
  __name: "index",
@@ -40,6 +40,7 @@ const xe = /* @__PURE__ */ H({
40
40
  model: {},
41
41
  addApi: {},
42
42
  editApi: {},
43
+ successMessage: {},
43
44
  infoApi: {},
44
45
  infoApiBefore: {},
45
46
  infoApiAfter: {},
@@ -58,21 +59,21 @@ const xe = /* @__PURE__ */ H({
58
59
  },
59
60
  emits: ["submit", "fetch", "getinfo"],
60
61
  setup(I, { emit: D }) {
61
- var w, F;
62
- const o = I, p = D, L = J(), f = K(), r = K(!1), { getFormSlotKeys: T, getModalSlotKeys: E, replaceFormSlotKey: R, replaceModalSlotKey: _ } = ie(L), x = C(() => E.value.filter(Boolean)), $ = C(() => T.value.filter(Boolean)), v = {
62
+ var M, w;
63
+ const o = I, m = D, L = J(), c = F(), r = F(!1), { getFormSlotKeys: T, getModalSlotKeys: E, replaceFormSlotKey: R, replaceModalSlotKey: _ } = ie(L), x = K(() => E.value.filter(Boolean)), $ = K(() => T.value.filter(Boolean)), h = {
63
64
  showDefaultActions: !1,
64
65
  ...Q(o.formProps)
65
- }, [z, s] = o.renderType === "groupForm" ? te(v) : oe(v), [N, a] = ne({
66
+ }, [z, l] = o.renderType === "groupForm" ? te(h) : oe(h), [N, a] = se({
66
67
  ...o.modalProps,
67
68
  onReceiveSharedData: async (e) => {
68
69
  if (!e) {
69
- f.value = void 0;
70
+ c.value = void 0;
70
71
  return;
71
72
  }
72
- if (e.schemas && s.setState({ schema: e.schemas }), e != null && e.title && a.setModalProps({ title: e.title }), f.value = e[o.infoApiIdKey], e != null && e[o.infoApiIdKey]) {
73
+ if (e.schemas && l.setState({ schema: e.schemas }), e != null && e.title && a.setModalProps({ title: e.title }), c.value = e[o.infoApiIdKey], e != null && e[o.infoApiIdKey]) {
73
74
  const i = o.infoApi;
74
- if (!m(i)) {
75
- g(e);
75
+ if (!n(i)) {
76
+ v(e);
76
77
  return;
77
78
  }
78
79
  a.changeLoading(!0);
@@ -80,83 +81,92 @@ const xe = /* @__PURE__ */ H({
80
81
  const t = {
81
82
  ...o.infoApiParams,
82
83
  [o.infoApiIdKey]: e[o.infoApiIdKey]
83
- }, n = m(o.infoApiBefore) ? await o.infoApiBefore(t) : t, l = await i(n), c = o.dataField ? ee(l, o.dataField) : l, u = m(o.infoApiAfter) ? await o.infoApiAfter(c) : c;
84
- k(u), p("getinfo", u), await y(), await s.resetForm({ values: u });
84
+ }, s = n(o.infoApiBefore) ? await o.infoApiBefore(t) : t, u = await i(s), p = o.dataField ? ee(u, o.dataField) : u, f = n(o.infoApiAfter) ? await o.infoApiAfter(p) : p;
85
+ k(f), m("getinfo", f), await y(), await l.resetForm({ values: f });
85
86
  } finally {
86
87
  a.changeLoading(!1);
87
88
  }
88
89
  } else
89
- g(e);
90
+ v(e);
90
91
  },
91
92
  async onOk() {
92
93
  await q();
93
94
  }
94
95
  });
95
- function g(e) {
96
+ function v(e) {
96
97
  const i = e[o.infoDataKey || ""] || {};
97
98
  k(i), y(() => {
98
- s.resetForm({ values: i });
99
+ l.resetForm({ values: i });
99
100
  });
100
101
  }
101
102
  function k(e) {
102
103
  const i = Object.keys(o.checkedOptions || {});
103
104
  i.length && i.forEach((t) => {
104
- var u;
105
- const n = (u = o.checkedOptions) == null ? void 0 : u[t];
106
- if (!Array.isArray(n) || n.length === 0)
105
+ var f;
106
+ const s = (f = o.checkedOptions) == null ? void 0 : f[t];
107
+ if (!Array.isArray(s) || s.length === 0)
107
108
  return;
108
- const [l, c] = n.length === 1 ? [n[0], n[0]] : n;
109
- !l || !c || (e[t] = {
110
- label: e[l],
111
- value: e[c]
109
+ const [u, p] = s.length === 1 ? [s[0], s[0]] : s;
110
+ !u || !p || (e[t] = {
111
+ label: e[u],
112
+ value: e[p]
112
113
  });
113
114
  });
114
115
  }
115
116
  async function j() {
116
- const e = await s.getValues(), { apiParams: i } = o;
117
+ const e = await l.getValues(), { apiParams: i } = o;
117
118
  let t = {
118
119
  ...e,
119
120
  ...i
120
121
  };
121
- return t = m(o.saveApiBefore) ? await o.saveApiBefore(t) : t, { reqParams: t, formValue: e };
122
+ return t = n(o.saveApiBefore) ? await o.saveApiBefore(t) : t, { reqParams: t, formValue: e };
122
123
  }
123
124
  async function G(e, i) {
124
125
  const { editApi: t } = o;
125
- !t || !m(t) || (e[o.infoApiIdKey] = f.value, await t(e, i.files), O.success("修改成功"), p("submit", {
126
+ if (!t || !n(t)) return;
127
+ e[o.infoApiIdKey] = c.value;
128
+ const s = await t(e, i.files);
129
+ O.success(
130
+ n(o.successMessage) ? o.successMessage(s, "edit") : o.successMessage ?? "修改成功"
131
+ ), m("submit", {
126
132
  ...e,
127
133
  continuousChecked: r.value
128
- }), a.closeModal());
134
+ }), a.closeModal();
129
135
  }
130
136
  async function U(e, i) {
131
137
  const { addApi: t } = o;
132
- !t || !m(t) || (await t(e, i.files), O.success("新增成功"), p("submit", {
138
+ if (!t || !n(t)) return;
139
+ const s = await t(e, i.files);
140
+ O.success(
141
+ n(o.successMessage) ? o.successMessage(s, "add") : o.successMessage ?? "新增成功"
142
+ ), m("submit", {
133
143
  ...e,
134
144
  continuousChecked: r.value
135
- }), (!r.value || !o.isContinuousChecked) && a.closeModal());
145
+ }), (!r.value || !o.isContinuousChecked) && a.closeModal();
136
146
  }
137
147
  async function q() {
138
148
  a.changeOkLoading(!0);
139
149
  try {
140
- const { valid: e } = await s.validate();
150
+ const { valid: e } = await l.validate();
141
151
  if (!e) return;
142
152
  const { reqParams: i, formValue: t } = await j();
143
153
  if (!i)
144
154
  return;
145
- const { addApi: n, editApi: l } = o;
146
- if (!n && !l) {
147
- p("submit", {
155
+ const { addApi: s, editApi: u } = o;
156
+ if (!s && !u) {
157
+ m("submit", {
148
158
  ...i,
149
- [o.infoApiIdKey]: f.value,
159
+ [o.infoApiIdKey]: c.value,
150
160
  continuousChecked: r.value
151
161
  });
152
162
  return;
153
163
  }
154
- f.value ? await G(i, t) : await U(i, t);
164
+ c.value ? await G(i, t) : await U(i, t);
155
165
  } finally {
156
166
  a.changeOkLoading(!1);
157
167
  }
158
168
  }
159
- return (w = o.getFormApi) == null || w.call(o, s), (F = o.getModalApi) == null || F.call(o, a), W(
169
+ return (M = o.getFormApi) == null || M.call(o, l), (w = o.getModalApi) == null || w.call(o, a), W(
160
170
  () => {
161
171
  var e;
162
172
  return (e = a.getVisible) == null ? void 0 : e.value;
@@ -164,14 +174,14 @@ const xe = /* @__PURE__ */ H({
164
174
  async (e) => {
165
175
  if (e) {
166
176
  await y();
167
- const i = await s.getValues();
168
- p("fetch", i);
177
+ const i = await l.getValues();
178
+ m("fetch", i);
169
179
  } else
170
180
  r.value = !1;
171
181
  }
172
- ), (e, i) => (B(), M(d(N), null, P({
182
+ ), (e, i) => (B(), C(d(N), null, P({
173
183
  insertFooter: A(() => [
174
- o.isContinuousChecked && !f.value ? (B(), M(d(Z), {
184
+ o.isContinuousChecked && !c.value ? (B(), C(d(Z), {
175
185
  key: 0,
176
186
  modelValue: r.value,
177
187
  "onUpdate:modelValue": i[0] || (i[0] = (t) => r.value = t),
@@ -180,12 +190,12 @@ const xe = /* @__PURE__ */ H({
180
190
  }, null, 8, ["modelValue"])) : Y("", !0)
181
191
  ]),
182
192
  default: A(() => [
183
- h(e.$slots, "BasicMsgTop"),
193
+ g(e.$slots, "BasicMsgTop"),
184
194
  X(d(z), null, P({ _: 2 }, [
185
195
  S($.value, (t) => ({
186
196
  name: d(R)(t),
187
- fn: A((n) => [
188
- h(e.$slots, t, b(V(n)))
197
+ fn: A((s) => [
198
+ g(e.$slots, t, b(V(s)))
189
199
  ])
190
200
  }))
191
201
  ]), 1024)
@@ -194,8 +204,8 @@ const xe = /* @__PURE__ */ H({
194
204
  }, [
195
205
  S(x.value, (t) => ({
196
206
  name: d(_)(t),
197
- fn: A((n) => [
198
- h(e.$slots, t, b(V(n)))
207
+ fn: A((s) => [
208
+ g(e.$slots, t, b(V(s)))
199
209
  ])
200
210
  }))
201
211
  ]), 1024));
@@ -20,6 +20,8 @@ export type TtModalFormProps<TType extends ModalFormType = "form", TValues exten
20
20
  addApi?: (...arg: any[]) => Promise<any>;
21
21
  /** 编辑保存接口 */
22
22
  editApi?: (...arg: any[]) => Promise<any>;
23
+ /** 保存成功提示;函数接收保存接口返回值及操作类型,不传时使用新增/修改默认文案。 */
24
+ successMessage?: string | ((result: unknown, type: "add" | "edit") => string);
23
25
  /** 详情接口 */
24
26
  infoApi?: (...arg: any[]) => Promise<any>;
25
27
  /** 详情接口前置钩子 */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dazhicheng/ui",
3
- "version": "1.6.44",
3
+ "version": "1.6.45",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",