@dt-frames/ui 2.0.3 → 2.0.4

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.
Files changed (44) hide show
  1. package/es/assets/locales/en.ts +1 -1
  2. package/es/components/curd/index.js +279 -269
  3. package/es/components/drawer/index.d.ts +1 -1
  4. package/es/components/drawer/index.js +27 -27
  5. package/es/components/drawer/src/index.d.ts +2 -3
  6. package/es/components/form/index.d.ts +20 -20
  7. package/es/components/form/index.js +91 -45
  8. package/es/components/form/index.less +206 -8
  9. package/es/components/form/src/components/FormItem.d.ts +3 -7
  10. package/es/components/form/src/components/formIcon.d.ts +14 -14
  11. package/es/components/form/src/components/formInputUseDialog.d.ts +8 -8
  12. package/es/components/form/src/enums/index.d.ts +1 -1
  13. package/es/components/form/src/index.d.ts +16 -16
  14. package/es/components/form/src/props.d.ts +2 -6
  15. package/es/components/form/src/types/form.type.d.ts +1 -1
  16. package/es/components/icons/index.less +5 -0
  17. package/es/components/modal/index.js +35 -34
  18. package/es/components/modal/index.less +10 -0
  19. package/es/components/modal/src/components/ModalFooter.d.ts +3 -3
  20. package/es/components/modal/src/index.d.ts +9 -9
  21. package/es/components/source/hooks/useSource.d.ts +14 -0
  22. package/es/components/source/index.js +66 -28
  23. package/es/components/source/types/source.type.d.ts +4 -8
  24. package/es/components/table/index.js +278 -215
  25. package/es/components/table/index.less +41 -14
  26. package/es/components/table/src/index.d.ts +20 -10
  27. package/es/components/table/src/props.d.ts +8 -4
  28. package/es/components/table/src/types/table.type.d.ts +4 -5
  29. package/es/theme/index.js +342 -120
  30. package/es/theme/index.less +150 -0
  31. package/es/theme/src/components/header/components/size.d.ts +5 -5
  32. package/es/theme/src/components/header/helper/menu-tree.d.ts +1 -0
  33. package/es/theme/src/components/header/index.d.ts +5 -5
  34. package/es/theme/src/components/header/multiple-header.d.ts +6 -7
  35. package/es/theme/src/components/sider/components/drag-bar.d.ts +1 -1
  36. package/es/theme/src/components/sider/components/sider-trigger.d.ts +0 -1
  37. package/es/theme/src/components/sider/index.d.ts +147 -3
  38. package/es/theme/src/components/sider/mix-sider.d.ts +146 -0
  39. package/es/theme/src/enums/theme.enum.d.ts +2 -1
  40. package/es/theme/src/hooks/useMenu.d.ts +5 -3
  41. package/es/theme/src/index.d.ts +159 -15
  42. package/es/theme/src/stores/theme.store.d.ts +3 -0
  43. package/es/theme/src/types/theme.type.d.ts +1 -0
  44. package/package.json +1 -3
@@ -100,7 +100,7 @@ declare const _sfc_main: import("vue").DefineComponent<{
100
100
  afterClose: FunctionConstructor;
101
101
  }, {
102
102
  props: any;
103
- emits: (event: "register" | "visible-change" | "height-change" | "cancel" | "save" | "update:visible", ...args: any[]) => void;
103
+ emits: (event: "visible-change" | "height-change" | "cancel" | "save" | "register" | "update:visible", ...args: any[]) => void;
104
104
  visibleRef: import("vue").Ref<boolean>;
105
105
  propsRef: import("vue").Ref<Partial<ExtractPropTypes<{
106
106
  t: {
@@ -620,11 +620,11 @@ declare const _sfc_main: import("vue").DefineComponent<{
620
620
  "onHandle-method"?: (...args: any[]) => any;
621
621
  }, {
622
622
  mode: "search" | "dialog";
623
- minShowColumn: number;
624
- showAdvancedButton: boolean;
625
623
  show: boolean;
626
- isAdvanced: boolean;
624
+ showAdvancedButton: boolean;
625
+ minShowColumn: number;
627
626
  buttonList: import("../../form/src/types/form.type").ButtonProps[];
627
+ isAdvanced: boolean;
628
628
  }>;
629
629
  }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("handleSave" | "handleCancel")[], "handleSave" | "handleCancel", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<ExtractPropTypes<{
630
630
  buttons: import("vue").PropType<import("../../form/src/types/form.type").ButtonProps[]>;
@@ -649,7 +649,7 @@ declare const _sfc_main: import("vue").DefineComponent<{
649
649
  showSave: boolean;
650
650
  showCancel: boolean;
651
651
  }>;
652
- }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("register" | "visible-change" | "height-change" | "cancel" | "save" | "update:visible")[], "register" | "visible-change" | "height-change" | "cancel" | "save" | "update:visible", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<ExtractPropTypes<{
652
+ }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("visible-change" | "height-change" | "cancel" | "save" | "register" | "update:visible")[], "visible-change" | "height-change" | "cancel" | "save" | "register" | "update:visible", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<ExtractPropTypes<{
653
653
  t: {
654
654
  type: StringConstructor;
655
655
  };
@@ -747,27 +747,27 @@ declare const _sfc_main: import("vue").DefineComponent<{
747
747
  closeFunc: import("vue").PropType<() => Promise<boolean>>;
748
748
  afterClose: FunctionConstructor;
749
749
  }>> & {
750
- onRegister?: (...args: any[]) => any;
751
- "onUpdate:visible"?: (...args: any[]) => any;
752
750
  "onVisible-change"?: (...args: any[]) => any;
753
751
  "onHeight-change"?: (...args: any[]) => any;
754
752
  onCancel?: (...args: any[]) => any;
755
753
  onSave?: (...args: any[]) => any;
754
+ onRegister?: (...args: any[]) => any;
755
+ "onUpdate:visible"?: (...args: any[]) => any;
756
756
  }, {
757
- loading: boolean;
758
757
  visible: boolean;
759
- mask: boolean;
760
758
  closable: boolean;
761
759
  destroyOnClose: boolean;
762
760
  scrollTop: boolean;
763
761
  draggable: boolean;
764
762
  defaultFullscreen: boolean;
765
763
  canFullscreen: boolean;
764
+ loading: boolean;
766
765
  loadingTip: string;
767
766
  useWrapper: boolean;
768
767
  centered: boolean;
769
768
  showOkBtn: boolean;
770
769
  showCancelBtn: boolean;
770
+ mask: boolean;
771
771
  maskClosable: boolean;
772
772
  keyboard: boolean;
773
773
  }>;
@@ -21,6 +21,7 @@ export declare function useSource(props: SourceOption): {
21
21
  total: number;
22
22
  }>;
23
23
  loading: import("vue").Ref<boolean>;
24
+ onSearch: () => void;
24
25
  onTableChange: (params: TableParamsType) => void;
25
26
  onAdd: () => void;
26
27
  onUpdate: (arg: any) => void;
@@ -35,6 +36,19 @@ export declare function useSource(props: SourceOption): {
35
36
  onQueryById: (id: Key) => Promise<unknown>;
36
37
  registerInstance: (instance: CurdActionType) => CurdActionType;
37
38
  };
39
+ api: import("../types/source.type").ApiObjType;
40
+ loading: {
41
+ [key: string]: import("vue").Ref<boolean>;
42
+ };
43
+ dataSource: import("vue").Ref<any[]>;
44
+ onAdd: () => void;
45
+ onUpdate: (arg: any) => void;
46
+ onDelete: (arg: any) => void;
47
+ onDeletes: (ids: Key[]) => void;
48
+ onQueryById: (id: Key) => Promise<unknown>;
49
+ onDownload: (excelData: DownloadType, extraData?: any[]) => void;
50
+ onSave: () => void;
38
51
  onSearch: () => void;
52
+ onReset: () => void;
39
53
  onTableChange: (params: TableParamsType) => void;
40
54
  };
@@ -1,5 +1,5 @@
1
- import { ref, unref, reactive, toRaw } from "vue";
2
- import { isString, http, isObject, useAppStore, error, getDictValueByCode, formatNumber, useI18n, useMessage, isArray } from "@dt-frames/core";
1
+ import { ref, unref, toRaw } from "vue";
2
+ import { isString, http, isObject, useAppStore, error, getDictValueByCode, formatNumber, useI18n, useMessage, isArray, isFunction, isBoolean } from "@dt-frames/core";
3
3
  import { isObject as isObject$1 } from "@vueuse/core";
4
4
  import { capitalize } from "lodash-es";
5
5
  import * as xlsx from "xlsx";
@@ -134,7 +134,7 @@ function useSource(props) {
134
134
  const { t } = useI18n("UI");
135
135
  const { confirm, message } = useMessage();
136
136
  const { appConf } = useAppStore();
137
- const { baseUrl, api: orgApi, immediateSearch = true, exportName, beforeUpdate, afterUpdate } = props;
137
+ const { baseUrl, api: orgApi, exportName, beforeUpdate, afterUpdate } = props;
138
138
  const pagination = ref({
139
139
  current: appConf?.ui?.table?.defaultPageNo || 1,
140
140
  pageSize: appConf?.ui?.table?.defaultPageSize || 20,
@@ -142,27 +142,34 @@ function useSource(props) {
142
142
  });
143
143
  const { loading, api } = getApi(orgApi, baseUrl);
144
144
  const dataSource = ref([]);
145
- const baseData = reactive({
146
- entityDTO: {},
147
- orderDTOs: []
148
- });
145
+ let baseData = {
146
+ pageNumber: 1,
147
+ pageSize: appConf?.ui?.table?.defaultPageSize || 20
148
+ };
149
149
  let tableInstance = null;
150
150
  let formInstance = null;
151
151
  let curdInstance = null;
152
152
  function onSearch() {
153
153
  tableInstance?.clearSelectedRowKeys();
154
154
  const { defaultPageSize } = tableInstance?.getPagination() || {};
155
- baseData.pageDTO = {
156
- pageNo: 0,
155
+ baseData = {
156
+ ...formInstance?.getFormValues() ?? {},
157
+ pageNumber: 1,
157
158
  pageSize: defaultPageSize
158
159
  };
159
160
  loading.onSearch.value = true;
161
+ loading.onQuerypage.value = true;
160
162
  setPage();
161
163
  }
162
164
  function onReset() {
163
- baseData.entityDTO = { ...formInstance?.getFormValues() ?? {} };
164
- baseData.pageDTO.pageNo = 0;
165
+ const { defaultPageSize } = tableInstance?.getPagination() || {};
166
+ baseData = {
167
+ ...formInstance?.getFormValues() ?? {},
168
+ pageNumber: 1,
169
+ pageSize: defaultPageSize
170
+ };
165
171
  loading.onReset.value = true;
172
+ loading.onQuerypage.value = true;
166
173
  tableInstance?.clearSelectedRowKeys();
167
174
  setPage();
168
175
  }
@@ -177,12 +184,12 @@ function useSource(props) {
177
184
  dataSource.value.splice(0, dataSource.value.length, ...rsp);
178
185
  return;
179
186
  }
180
- const { records, pageDTO } = rsp;
187
+ const { records, total, size, current } = rsp;
181
188
  dataSource.value.splice(0, dataSource.value.length, ...records);
182
189
  pagination.value = {
183
- current: (pageDTO?.pageNo ?? 0) + 1,
184
- pageSize: pageDTO?.pageSize ?? appConf?.ui?.table?.defaultPageSize,
185
- total: pageDTO?.totalCount ?? 0
190
+ current,
191
+ pageSize: size || appConf?.ui?.table?.defaultPageSize,
192
+ total
186
193
  };
187
194
  }).finally(() => {
188
195
  loading.onSearch.value = false;
@@ -192,18 +199,29 @@ function useSource(props) {
192
199
  }
193
200
  function onTableChange(params) {
194
201
  const { pagination: pagination2, sort, filter } = params;
195
- baseData.pageDTO = {
196
- pageNo: pagination2.current - 1,
202
+ if (!appConf?.ui?.table?.multipleSorter) {
203
+ let order = sort.order;
204
+ let sortOrder = order === "ascend" ? "asc" : order === "descend" ? "desc" : null;
205
+ baseData = {
206
+ ...baseData,
207
+ sortName: sortOrder ? sort.field : "",
208
+ sortOrder
209
+ };
210
+ } else {
211
+ baseData.sort = (sort || []).map((it) => {
212
+ if (it.order) {
213
+ return {
214
+ sortName: it.field,
215
+ sortOrder: it.order === "ascend" ? "asc" : "desc"
216
+ };
217
+ }
218
+ }).filter((it) => it);
219
+ }
220
+ baseData = {
221
+ ...baseData,
222
+ pageNumber: pagination2.current,
197
223
  pageSize: pagination2.pageSize
198
224
  };
199
- baseData.orderDTOs = (isObject$1(sort) ? [sort] : sort).map((it) => {
200
- if (it.order) {
201
- return {
202
- propertyName: it.field,
203
- dir: it.order === "ascend" ? "asc" : "desc"
204
- };
205
- }
206
- }).filter((it) => it);
207
225
  setPage(filter);
208
226
  }
209
227
  function onAdd() {
@@ -221,10 +239,18 @@ function useSource(props) {
221
239
  function onSave() {
222
240
  let model = curdInstance && curdInstance.curdFormMethods.getFormValues();
223
241
  curdInstance.curdFormMethods.validate().then((rsp) => {
242
+ if (beforeUpdate && isFunction(beforeUpdate)) {
243
+ let canUpdate = beforeUpdate(model);
244
+ if (isBoolean(canUpdate) && canUpdate === false) {
245
+ return false;
246
+ } else if (!isBoolean(canUpdate)) {
247
+ model = { ...canUpdate };
248
+ }
249
+ }
224
250
  if (!model.id) {
225
251
  loading.onAdd.value = true;
226
252
  fetch(api.add, { ...model }, false).then((rsp2) => {
227
- if (rsp2?.code === 0) {
253
+ if (rsp2?.code === appConf?.http?.okCode) {
228
254
  message.success(t("ADD_SUCCESS"));
229
255
  curdInstance.closeModal();
230
256
  onSearch();
@@ -234,7 +260,7 @@ function useSource(props) {
234
260
  } else {
235
261
  loading.onUpdate.value = true;
236
262
  fetch(api.update, { ...model }, false).then((rsp2) => {
237
- if (rsp2?.code === 0) {
263
+ if (rsp2?.code === appConf?.http?.okCode) {
238
264
  message.success(t("UPDATE_SUCCESS"));
239
265
  curdInstance.closeModal();
240
266
  onSearch();
@@ -264,7 +290,7 @@ function useSource(props) {
264
290
  iconType: "warning",
265
291
  onOk() {
266
292
  fetch(api.deletes, toRaw(_ids), false).then((rsp) => {
267
- if (rsp?.code === 0) {
293
+ if (rsp?.code === appConf?.http?.okCode) {
268
294
  message.success((isSingleDelete ? "" : t("MULTIFY")) + t("DELETE_SUCCESS"));
269
295
  !isSingleDelete && tableInstance.clearSelectedRowKeys();
270
296
  onSearch();
@@ -305,6 +331,7 @@ function useSource(props) {
305
331
  dataSource,
306
332
  pagination,
307
333
  loading: loading.onQuerypage,
334
+ onSearch,
308
335
  onTableChange,
309
336
  onAdd,
310
337
  onUpdate,
@@ -323,7 +350,18 @@ function useSource(props) {
323
350
  form,
324
351
  table,
325
352
  curd,
353
+ api,
354
+ loading,
355
+ dataSource,
356
+ onAdd,
357
+ onUpdate,
358
+ onDelete,
359
+ onDeletes,
360
+ onQueryById,
361
+ onDownload,
362
+ onSave,
326
363
  onSearch,
364
+ onReset,
327
365
  onTableChange
328
366
  };
329
367
  }
@@ -12,8 +12,7 @@ export declare type ApiObjType = {
12
12
  export declare type SourceOption = {
13
13
  baseUrl?: string;
14
14
  exportName?: string | ComputedRef;
15
- immediateSearch?: boolean;
16
- beforeUpdate?: () => boolean | undefined;
15
+ beforeUpdate?: (model: Recordable) => boolean | Recordable | undefined;
17
16
  afterUpdate?: () => void;
18
17
  api?: ApiObjType;
19
18
  };
@@ -22,12 +21,9 @@ export declare type orderType = {
22
21
  order: 'asc' | 'desc';
23
22
  };
24
23
  export declare type BaseDataType = {
25
- entityDTO?: any;
26
- pageDTO?: {
27
- pageNo: Number;
28
- pageSize: Number;
29
- } | null;
30
- orderDTOs: orderType[];
24
+ pageNumber: Number;
25
+ pageSize: Number;
26
+ [key: string]: any;
31
27
  };
32
28
  export declare type TableParamsType = {
33
29
  pagination: any;