el-plus 0.0.79 → 0.0.81

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 (38) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/index.full.js +50 -31
  3. package/dist/index.full.min.js +4 -4
  4. package/dist/index.full.min.js.map +1 -1
  5. package/dist/index.full.min.mjs +4 -4
  6. package/dist/index.full.min.mjs.map +1 -1
  7. package/dist/index.full.mjs +50 -31
  8. package/es/components/header/index.d.ts +0 -6
  9. package/es/components/header/src/header.d.ts +0 -1
  10. package/es/components/header/src/header.mjs +1 -2
  11. package/es/components/header/src/header.mjs.map +1 -1
  12. package/es/components/header/src/header.vue.d.ts +0 -3
  13. package/es/components/header/src/use-header.mjs +3 -1
  14. package/es/components/header/src/use-header.mjs.map +1 -1
  15. package/es/components/search-list-page/src/use-search-list-page.d.ts +4 -3
  16. package/es/components/search-list-page/src/use-search-list-page.mjs +7 -2
  17. package/es/components/search-list-page/src/use-search-list-page.mjs.map +1 -1
  18. package/es/components/table/src/use-table.mjs +38 -25
  19. package/es/components/table/src/use-table.mjs.map +1 -1
  20. package/es/package.json.mjs +1 -1
  21. package/es/utils/file.mjs +1 -1
  22. package/es/utils/file.mjs.map +1 -1
  23. package/lib/components/header/index.d.ts +0 -6
  24. package/lib/components/header/src/header.d.ts +0 -1
  25. package/lib/components/header/src/header.js +1 -2
  26. package/lib/components/header/src/header.js.map +1 -1
  27. package/lib/components/header/src/header.vue.d.ts +0 -3
  28. package/lib/components/header/src/use-header.js +3 -1
  29. package/lib/components/header/src/use-header.js.map +1 -1
  30. package/lib/components/search-list-page/src/use-search-list-page.d.ts +4 -3
  31. package/lib/components/search-list-page/src/use-search-list-page.js +6 -1
  32. package/lib/components/search-list-page/src/use-search-list-page.js.map +1 -1
  33. package/lib/components/table/src/use-table.js +37 -24
  34. package/lib/components/table/src/use-table.js.map +1 -1
  35. package/lib/package.json.js +1 -1
  36. package/lib/utils/file.js +1 -1
  37. package/lib/utils/file.js.map +1 -1
  38. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- /*! ElPlus v0.0.79 */
1
+ /*! ElPlus v0.0.81 */
2
2
 
3
3
  import { useAttrs, getCurrentInstance, inject, provide, ref, nextTick, defineComponent, computed, createVNode, Fragment, withDirectives, resolveComponent, mergeProps, resolveDirective, useTemplateRef, createTextVNode, h, mergeModels, useModel, createElementBlock, openBlock, normalizeStyle, normalizeClass, unref, createCommentVNode, withCtx, renderSlot, renderList, createBlock, vShow, toDisplayString, reactive, useSlots, watch, onMounted, createSlots, normalizeProps, guardReactiveProps, markRaw, Transition, shallowReactive, isVNode, render, createElementVNode, toRaw } from 'vue';
4
4
  import { buttonProps, useLocale as useLocale$1, ElLoading, ElMessage, ElMessageBox, formProps as formProps$1, formEmits as formEmits$1, ElTooltip, formItemProps as formItemProps$1, ElFormItem, ElForm, ElRow, ElCol, inputProps as inputProps$1, inputEmits as inputEmits$1, configProviderContextKey, ElConfigProvider, ElDialog, ElButton, ElTable, ElIcon, selectProps as selectProps$1, selectEmits as selectEmits$1, ElPageHeader, datePickerProps, linkProps as linkProps$1, ElSkeleton } from 'element-plus';
@@ -1979,7 +1979,9 @@ const useFormDialog = (options = {}) => {
1979
1979
  const useTable$1 = (props) => {
1980
1980
  const elFormRef = useTemplateRef("elFormRef");
1981
1981
  const elTableRef = useTemplateRef("elTableRef");
1982
+ const allData = ref([]);
1982
1983
  const customData = ref([]);
1984
+ const apiTotal = ref(0);
1983
1985
  const {
1984
1986
  loading,
1985
1987
  requestFn
@@ -1994,15 +1996,18 @@ const useTable$1 = (props) => {
1994
1996
  hooks: {
1995
1997
  success(data) {
1996
1998
  if (Array.isArray(data)) {
1997
- customData.value = data;
1999
+ allData.value = data;
1998
2000
  } else if (data && typeof data === "object") {
1999
2001
  const rawData = data;
2000
- customData.value = rawData?.list || rawData?.data || [];
2002
+ allData.value = rawData?.list || rawData?.data || [];
2001
2003
  } else {
2002
- customData.value = [];
2004
+ allData.value = [];
2003
2005
  }
2004
- if (props.showPagination) {
2005
- pagination.total = (props.isFrontPage ? customData.value.length : data.total) || 0;
2006
+ if (props.isFrontPage) {
2007
+ frontPaginationHandler();
2008
+ } else {
2009
+ customData.value = allData.value;
2010
+ apiTotal.value = data.total || 0;
2006
2011
  }
2007
2012
  },
2008
2013
  fail(error) {
@@ -2015,21 +2020,13 @@ const useTable$1 = (props) => {
2015
2020
  const search = async (init = false, isPagination = false) => {
2016
2021
  const beforeSearch = attrs["before-search"];
2017
2022
  if (typeof beforeSearch === "function") {
2018
- await nextTick();
2019
2023
  await beforeSearch?.();
2020
2024
  }
2021
2025
  if (init) {
2022
2026
  pagination.pageNo = 1;
2023
2027
  }
2024
2028
  if (isPagination && props.isFrontPage) {
2025
- const {
2026
- pageNo,
2027
- pageSize
2028
- } = pagination;
2029
- const data = customData.value.filter((item, index) => {
2030
- return index < pageNo * pageSize && index >= (pageNo - 1) * pageSize;
2031
- });
2032
- customData.value = data;
2029
+ frontPaginationHandler();
2033
2030
  } else {
2034
2031
  if (props.api) {
2035
2032
  requestFn({
@@ -2037,22 +2034,36 @@ const useTable$1 = (props) => {
2037
2034
  pageSize: pagination.pageSize,
2038
2035
  pageNum: pagination.pageNo
2039
2036
  });
2040
- } else if (props.data?.length) {
2041
- customData.value = props.data;
2042
2037
  }
2043
2038
  }
2044
2039
  };
2040
+ const {
2041
+ pagination,
2042
+ paginationProps
2043
+ } = usePagination(props, search, allData, apiTotal);
2044
+ const frontPaginationHandler = () => {
2045
+ const {
2046
+ pageNo,
2047
+ pageSize
2048
+ } = pagination;
2049
+ const data = allData.value.filter((item, index) => {
2050
+ return index < pageNo * pageSize && index >= (pageNo - 1) * pageSize;
2051
+ });
2052
+ customData.value = data;
2053
+ };
2045
2054
  if (!props.api) {
2046
2055
  watch(() => props.data, (newValue) => {
2047
- customData.value = newValue;
2056
+ allData.value = newValue;
2057
+ if (props.isFrontPage) {
2058
+ frontPaginationHandler();
2059
+ } else {
2060
+ customData.value = allData.value;
2061
+ }
2048
2062
  }, {
2049
- deep: true
2063
+ deep: true,
2064
+ immediate: true
2050
2065
  });
2051
2066
  }
2052
- const {
2053
- pagination,
2054
- paginationProps
2055
- } = usePagination(props, search);
2056
2067
  (async () => {
2057
2068
  if (props.isInitSearch) {
2058
2069
  if (props.customColumnModule) {
@@ -2106,11 +2117,13 @@ const useTable$1 = (props) => {
2106
2117
  customColumns
2107
2118
  };
2108
2119
  };
2109
- const usePagination = function(props, search) {
2120
+ const usePagination = function(props, search, allData, apiTotal) {
2110
2121
  const defaultPaginationProps = props.paginationProps || {};
2111
2122
  const pageSizes = defaultPaginationProps.pageSizes || [20, 50, 100, 200];
2112
2123
  const pagination = reactive({
2113
- total: 0,
2124
+ total: computed(() => {
2125
+ return !props.isFrontPage && props.api ? apiTotal.value : allData.value.length;
2126
+ }),
2114
2127
  pageNo: 1,
2115
2128
  pageSize: pageSizes[0]
2116
2129
  });
@@ -2599,7 +2612,12 @@ const useSearchListPage = (props, config = {}) => {
2599
2612
  reset,
2600
2613
  tableRef,
2601
2614
  formRef,
2602
- beforeSearch: validate
2615
+ beforeSearch: async () => {
2616
+ if (!formRef.value) {
2617
+ await nextTick();
2618
+ }
2619
+ await validate();
2620
+ }
2603
2621
  };
2604
2622
  };
2605
2623
  const useTable = (props, config) => {
@@ -3175,8 +3193,7 @@ const headerProps = {
3175
3193
  // 权限前缀
3176
3194
  // 要展示的默认按钮
3177
3195
  defaultButtons: {
3178
- type: Array,
3179
- default: () => []
3196
+ type: Array
3180
3197
  },
3181
3198
  // 工作流id
3182
3199
  workflowId: String,
@@ -3355,10 +3372,12 @@ const useButtons = (props, emit) => {
3355
3372
  gotoTaskTrace(props.workflowId);
3356
3373
  }
3357
3374
  }];
3358
- if (props.defaultButtons.length) {
3375
+ if (props.defaultButtons?.length) {
3359
3376
  defaultButtons = defaultButtons.filter((item) => {
3360
3377
  return props.defaultButtons.some((item1) => item1 === item.prop);
3361
3378
  });
3379
+ } else if (props.defaultButtons?.length === 0) {
3380
+ defaultButtons = [];
3362
3381
  }
3363
3382
  const buttons = mergeListByKey(defaultButtons, props.buttons);
3364
3383
  return {
@@ -3406,7 +3425,7 @@ const attachmentProps = {
3406
3425
  };
3407
3426
 
3408
3427
  const getFullUrl = (filePath) => {
3409
- return filePath.indexOf("hongxinshop.com") > -1 ? filePath : `${window.location.protocol}${getEnv() === "local" ? `//${getLocationEnv()}-hxjf.hongxinshop.com` : ""}/image/${filePath}`;
3428
+ return filePath.indexOf("hongxinshop.com") > -1 ? filePath : `${window.location.protocol}//${getEnv() === "local" ? `${getLocationEnv()}-hxjf.hongxinshop.com` : window.location.host}/image/${filePath}`;
3410
3429
  };
3411
3430
  const downloadSrc = ({
3412
3431
  src,
@@ -4273,7 +4292,7 @@ var components = [
4273
4292
  EpUniVue
4274
4293
  ];
4275
4294
 
4276
- var version = "0.0.79";
4295
+ var version = "0.0.81";
4277
4296
 
4278
4297
  var globalProperties = {
4279
4298
  install(app) {
@@ -26,7 +26,6 @@ export declare const EpHeader: {
26
26
  readonly name: StringConstructor;
27
27
  readonly defaultButtons: {
28
28
  readonly type: import("vue").PropType<import("./src/header").defaultButtonsProps[]>;
29
- readonly default: () => never[];
30
29
  };
31
30
  readonly workflowId: StringConstructor;
32
31
  readonly isShowAttachmentButton: {
@@ -56,7 +55,6 @@ export declare const EpHeader: {
56
55
  hide?: (boolean | ((T: unknown) => boolean)) | undefined;
57
56
  }>[];
58
57
  readonly allowBack: boolean;
59
- readonly defaultButtons: import("./src/header").defaultButtonsProps[];
60
58
  readonly isShowAttachmentButton: boolean;
61
59
  readonly fileList: Record<string, any>[];
62
60
  readonly attachmentProps: {
@@ -116,7 +114,6 @@ export declare const EpHeader: {
116
114
  readonly name: StringConstructor;
117
115
  readonly defaultButtons: {
118
116
  readonly type: import("vue").PropType<import("./src/header").defaultButtonsProps[]>;
119
- readonly default: () => never[];
120
117
  };
121
118
  readonly workflowId: StringConstructor;
122
119
  readonly isShowAttachmentButton: {
@@ -146,7 +143,6 @@ export declare const EpHeader: {
146
143
  hide?: (boolean | ((T: unknown) => boolean)) | undefined;
147
144
  }>[];
148
145
  readonly allowBack: boolean;
149
- readonly defaultButtons: import("./src/header").defaultButtonsProps[];
150
146
  readonly isShowAttachmentButton: boolean;
151
147
  readonly fileList: Record<string, any>[];
152
148
  readonly attachmentProps: {
@@ -191,7 +187,6 @@ export declare const EpHeader: {
191
187
  readonly name: StringConstructor;
192
188
  readonly defaultButtons: {
193
189
  readonly type: import("vue").PropType<import("./src/header").defaultButtonsProps[]>;
194
- readonly default: () => never[];
195
190
  };
196
191
  readonly workflowId: StringConstructor;
197
192
  readonly isShowAttachmentButton: {
@@ -221,7 +216,6 @@ export declare const EpHeader: {
221
216
  hide?: (boolean | ((T: unknown) => boolean)) | undefined;
222
217
  }>[];
223
218
  readonly allowBack: boolean;
224
- readonly defaultButtons: import("./src/header").defaultButtonsProps[];
225
219
  readonly isShowAttachmentButton: boolean;
226
220
  readonly fileList: Record<string, any>[];
227
221
  readonly attachmentProps: {
@@ -17,7 +17,6 @@ export declare const headerProps: {
17
17
  readonly name: StringConstructor;
18
18
  readonly defaultButtons: {
19
19
  readonly type: PropType<defaultButtonsProps[]>;
20
- readonly default: () => never[];
21
20
  };
22
21
  readonly workflowId: StringConstructor;
23
22
  readonly isShowAttachmentButton: {
@@ -16,8 +16,7 @@ const headerProps = {
16
16
  // 权限前缀
17
17
  // 要展示的默认按钮
18
18
  defaultButtons: {
19
- type: Array,
20
- default: () => []
19
+ type: Array
21
20
  },
22
21
  // 工作流id
23
22
  workflowId: String,
@@ -1 +1 @@
1
- {"version":3,"file":"header.mjs","sources":["../../../../../../packages/components/header/src/header.ts"],"sourcesContent":["import type { ExtractPropTypes, PropType } from 'vue'\nimport { buttonsProps } from '@el-plus/components/buttons'\nimport type { AttachmentProps } from '@el-plus/components/attachment'\nimport type { PageMode } from '@el-plus/hooks/use-navigation'\nexport type defaultButtonsProps =\n | 'modify'\n | 'save'\n | 'cancel'\n | 'refresh'\n | 'auditLog'\n\nexport const headerProps = {\n // 页面模式\n mode: {\n type: String as PropType<PageMode>,\n },\n allowBack: {\n type: Boolean,\n default: true,\n },\n buttons: {\n ...buttonsProps.list,\n },\n name: String, // 权限前缀\n // 要展示的默认按钮\n defaultButtons: {\n type: Array as PropType<defaultButtonsProps[]>,\n default: () => [],\n },\n // 工作流id\n workflowId: String,\n // 是否显示附件按钮\n isShowAttachmentButton: {\n type: Boolean,\n default: false,\n },\n // 附件列表\n fileList: {\n type: Array as PropType<Record<string, any>[]>,\n default: () => [],\n },\n attachmentProps: {\n type: Object as PropType<AttachmentProps>,\n default: () => {},\n },\n} as const\nexport type HeaderProps = ExtractPropTypes<typeof headerProps>\n\nexport const headerEmits = {}\nexport type HeaderEmits = typeof headerEmits\n"],"names":[],"mappings":";;AAWO,MAAM,WAAA,GAAc;AAAA;AAAA,EAEzB,IAAA,EAAM;AAAA,IACJ,IAAA,EAAM;AAAA,GACR;AAAA,EACA,SAAA,EAAW;AAAA,IACT,IAAA,EAAM,OAAA;AAAA,IACN,OAAA,EAAS;AAAA,GACX;AAAA,EACA,OAAA,EAAS;AAAA,IACP,GAAG,YAAA,CAAa;AAAA,GAClB;AAAA,EACA,IAAA,EAAM,MAAA;AAAA;AAAA;AAAA,EAEN,cAAA,EAAgB;AAAA,IACd,IAAA,EAAM,KAAA;AAAA,IACN,OAAA,EAAS,MAAM;AAAC,GAClB;AAAA;AAAA,EAEA,UAAA,EAAY,MAAA;AAAA;AAAA,EAEZ,sBAAA,EAAwB;AAAA,IACtB,IAAA,EAAM,OAAA;AAAA,IACN,OAAA,EAAS;AAAA,GACX;AAAA;AAAA,EAEA,QAAA,EAAU;AAAA,IACR,IAAA,EAAM,KAAA;AAAA,IACN,OAAA,EAAS,MAAM;AAAC,GAClB;AAAA,EACA,eAAA,EAAiB;AAAA,IACf,IAAA,EAAM,MAAA;AAAA,IACN,SAAS,MAAM;AAAA,IAAC;AAAA;AAEpB;AAGO,MAAM,cAAc;;;;"}
1
+ {"version":3,"file":"header.mjs","sources":["../../../../../../packages/components/header/src/header.ts"],"sourcesContent":["import type { ExtractPropTypes, PropType } from 'vue'\nimport { buttonsProps } from '@el-plus/components/buttons'\nimport type { AttachmentProps } from '@el-plus/components/attachment'\nimport type { PageMode } from '@el-plus/hooks/use-navigation'\nexport type defaultButtonsProps =\n | 'modify'\n | 'save'\n | 'cancel'\n | 'refresh'\n | 'auditLog'\n\nexport const headerProps = {\n // 页面模式\n mode: {\n type: String as PropType<PageMode>,\n },\n allowBack: {\n type: Boolean,\n default: true,\n },\n buttons: {\n ...buttonsProps.list,\n },\n name: String, // 权限前缀\n // 要展示的默认按钮\n defaultButtons: {\n type: Array as PropType<defaultButtonsProps[]>,\n },\n // 工作流id\n workflowId: String,\n // 是否显示附件按钮\n isShowAttachmentButton: {\n type: Boolean,\n default: false,\n },\n // 附件列表\n fileList: {\n type: Array as PropType<Record<string, any>[]>,\n default: () => [],\n },\n attachmentProps: {\n type: Object as PropType<AttachmentProps>,\n default: () => {},\n },\n} as const\nexport type HeaderProps = ExtractPropTypes<typeof headerProps>\n\nexport const headerEmits = {}\nexport type HeaderEmits = typeof headerEmits\n"],"names":[],"mappings":";;AAWO,MAAM,WAAA,GAAc;AAAA;AAAA,EAEzB,IAAA,EAAM;AAAA,IACJ,IAAA,EAAM;AAAA,GACR;AAAA,EACA,SAAA,EAAW;AAAA,IACT,IAAA,EAAM,OAAA;AAAA,IACN,OAAA,EAAS;AAAA,GACX;AAAA,EACA,OAAA,EAAS;AAAA,IACP,GAAG,YAAA,CAAa;AAAA,GAClB;AAAA,EACA,IAAA,EAAM,MAAA;AAAA;AAAA;AAAA,EAEN,cAAA,EAAgB;AAAA,IACd,IAAA,EAAM;AAAA,GACR;AAAA;AAAA,EAEA,UAAA,EAAY,MAAA;AAAA;AAAA,EAEZ,sBAAA,EAAwB;AAAA,IACtB,IAAA,EAAM,OAAA;AAAA,IACN,OAAA,EAAS;AAAA,GACX;AAAA;AAAA,EAEA,QAAA,EAAU;AAAA,IACR,IAAA,EAAM,KAAA;AAAA,IACN,OAAA,EAAS,MAAM;AAAC,GAClB;AAAA,EACA,eAAA,EAAiB;AAAA,IACf,IAAA,EAAM,MAAA;AAAA,IACN,SAAS,MAAM;AAAA,IAAC;AAAA;AAEpB;AAGO,MAAM,cAAc;;;;"}
@@ -13,7 +13,6 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
13
13
  readonly name: StringConstructor;
14
14
  readonly defaultButtons: {
15
15
  readonly type: import("vue").PropType<import("./header").defaultButtonsProps[]>;
16
- readonly default: () => never[];
17
16
  };
18
17
  readonly workflowId: StringConstructor;
19
18
  readonly isShowAttachmentButton: {
@@ -43,7 +42,6 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
43
42
  readonly name: StringConstructor;
44
43
  readonly defaultButtons: {
45
44
  readonly type: import("vue").PropType<import("./header").defaultButtonsProps[]>;
46
- readonly default: () => never[];
47
45
  };
48
46
  readonly workflowId: StringConstructor;
49
47
  readonly isShowAttachmentButton: {
@@ -73,7 +71,6 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
73
71
  hide?: (boolean | ((T: unknown) => boolean)) | undefined;
74
72
  }>[];
75
73
  readonly allowBack: boolean;
76
- readonly defaultButtons: import("./header").defaultButtonsProps[];
77
74
  readonly isShowAttachmentButton: boolean;
78
75
  readonly fileList: Record<string, any>[];
79
76
  readonly attachmentProps: {
@@ -72,10 +72,12 @@ const useButtons = (props, emit) => {
72
72
  gotoTaskTrace(props.workflowId);
73
73
  }
74
74
  }];
75
- if (props.defaultButtons.length) {
75
+ if (props.defaultButtons?.length) {
76
76
  defaultButtons = defaultButtons.filter((item) => {
77
77
  return props.defaultButtons.some((item1) => item1 === item.prop);
78
78
  });
79
+ } else if (props.defaultButtons?.length === 0) {
80
+ defaultButtons = [];
79
81
  }
80
82
  const buttons = mergeListByKey(defaultButtons, props.buttons);
81
83
  return {
@@ -1 +1 @@
1
- {"version":3,"file":"use-header.mjs","sources":["../../../../../../packages/components/header/src/use-header.tsx"],"sourcesContent":["import { computed } from 'vue'\nimport { useRouter } from 'vue-router'\nimport type { HeaderProps } from '@el-plus/components/header'\nimport type { ButtonsProps } from '@el-plus/components/buttons'\nimport { mergeListByKey, gotoTaskTrace } from '@el-plus/utils'\nimport { useLocale } from '@el-plus/hooks/use-locale'\nimport { useNavigation } from '@el-plus/hooks/use-navigation'\nexport const useHeader = (props, emit) => {\n const router = useRouter()\n const isShowBack = computed(() => {\n if (!props.allowBack) {\n return false\n }\n if (window.parent.openMenuSelect) {\n return false\n }\n return true\n })\n const goBack = () => {\n router?.back()\n }\n return {\n isShowBack,\n goBack,\n }\n}\nexport const useButtons = (props: HeaderProps, emit) => {\n const { t } = useLocale()\n const { mode: defaultMode } = useNavigation()\n const mode = computed(() => {\n return props.mode || defaultMode.value\n })\n let defaultButtons: ButtonsProps['list'] = [\n {\n name: t('ep.header.edit'),\n prop: 'edit',\n permission: props.name ? `${props.name}:UPDATE` : '',\n disabled: () => {\n return mode.value !== 'browse'\n },\n },\n {\n name: t('ep.header.save'),\n prop: 'save',\n permission: props.name ? `${props.name}:SAVE` : '',\n disabled: () => {\n return !(mode.value === 'edit' || mode.value === 'add')\n },\n },\n {\n name: t('ep.header.cancel'),\n prop: 'cancel',\n disabled: () => {\n return mode.value !== 'edit'\n },\n },\n {\n name: t('ep.header.refresh'),\n prop: 'refresh',\n permission: props.name ? `${props.name}:REFRESH` : '',\n disabled: () => {\n return mode.value !== 'browse'\n },\n },\n {\n name: t('ep.header.approvalLog'),\n prop: 'approvalLog',\n permission: props.name ? `${props.name}:APPROVALLOG` : '',\n show: () => {\n return !!props.workflowId\n },\n onClick: () => {\n gotoTaskTrace(props.workflowId!)\n },\n },\n ]\n // 过滤要显示的\n if (props.defaultButtons.length) {\n defaultButtons = defaultButtons.filter((item) => {\n return props.defaultButtons.some((item1) => item1 === item.prop)\n })\n }\n const buttons = mergeListByKey(defaultButtons, props.buttons)\n return {\n buttons,\n }\n}\n"],"names":["useHeader","props","emit","router","useRouter","isShowBack","computed","allowBack","window","parent","openMenuSelect","goBack","back","useButtons","t","useLocale","mode","defaultMode","useNavigation","value","defaultButtons","name","prop","permission","disabled","show","workflowId","onClick","gotoTaskTrace","length","filter","item","some","item1","buttons","mergeListByKey"],"mappings":";;;;;;;AAOO,MAAMA,SAAAA,GAAYA,CAACC,KAAAA,EAAOC,IAAAA,KAAS;AACxC,EAAA,MAAMC,SAASC,SAAAA,EAAU;AACzB,EAAA,MAAMC,UAAAA,GAAaC,SAAS,MAAM;AAChC,IAAA,IAAI,CAACL,MAAMM,SAAAA,EAAW;AACpB,MAAA,OAAO,KAAA;AAAA,IACT;AACA,IAAA,IAAIC,MAAAA,CAAOC,OAAOC,cAAAA,EAAgB;AAChC,MAAA,OAAO,KAAA;AAAA,IACT;AACA,IAAA,OAAO,IAAA;AAAA,EACT,CAAC,CAAA;AACD,EAAA,MAAMC,SAASA,MAAM;AACnBR,IAAAA,MAAAA,EAAQS,IAAAA,EAAK;AAAA,EACf,CAAA;AACA,EAAA,OAAO;AAAA,IACLP,UAAAA;AAAAA,IACAM;AAAAA,GACF;AACF;AACO,MAAME,UAAAA,GAAaA,CAACZ,KAAAA,EAAoBC,IAAAA,KAAS;AACtD,EAAA,MAAM;AAAA,IAAEY;AAAAA,MAAMC,SAAAA,EAAU;AACxB,EAAA,MAAM;AAAA,IAAEC,IAAAA,EAAMC;AAAAA,MAAgBC,aAAAA,EAAc;AAC5C,EAAA,MAAMF,IAAAA,GAAOV,SAAS,MAAM;AAC1B,IAAA,OAAOL,KAAAA,CAAMe,QAAQC,WAAAA,CAAYE,KAAAA;AAAAA,EACnC,CAAC,CAAA;AACD,EAAA,IAAIC,iBAAuC,CACzC;AAAA,IACEC,IAAAA,EAAMP,EAAE,gBAAgB,CAAA;AAAA,IACxBQ,IAAAA,EAAM,MAAA;AAAA,IACNC,YAAYtB,KAAAA,CAAMoB,IAAAA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AO,CAAC,CAACxB,KAAAA,CAAMyB,UAAAA;AAAAA,IACjB,CAAA;AAAA,IACAC,SAASA,MAAM;AACbC,MAAAA,aAAAA,CAAc3B,MAAMyB,UAAW,CAAA;AAAA,IACjC;AAAA,GACD,CAAA;AAGH,EAAA,IAAIzB,KAAAA,CAAMmB,eAAeS,MAAAA,EAAQ;AAC/BT,IAAAA,cAAAA,GAAiBA,cAAAA,CAAeU,OAAQC,CAAAA,IAAAA,KAAS;AAC/C,MAAA,OAAO9B,MAAMmB,cAAAA,CAAeY,IAAAA,CAAMC,CAAAA,KAAAA,KAAUA,KAAAA,KAAUF,KAAKT,IAAI,CAAA;AAAA,IACjE,CAAC,CAAA;AAAA,EACH;AACA,EAAA,MAAMY,OAAAA,GAAUC,cAAAA,CAAef,cAAAA,EAAgBnB,KAAAA,CAAMiC,OAAO,CAAA;AAC5D,EAAA,OAAO;AAAA,IACLA;AAAAA,GACF;AACF;;;;"}
1
+ {"version":3,"file":"use-header.mjs","sources":["../../../../../../packages/components/header/src/use-header.tsx"],"sourcesContent":["import { computed } from 'vue'\nimport { useRouter } from 'vue-router'\nimport type { HeaderProps } from '@el-plus/components/header'\nimport type { ButtonsProps } from '@el-plus/components/buttons'\nimport { mergeListByKey, gotoTaskTrace } from '@el-plus/utils'\nimport { useLocale } from '@el-plus/hooks/use-locale'\nimport { useNavigation } from '@el-plus/hooks/use-navigation'\nexport const useHeader = (props, emit) => {\n const router = useRouter()\n const isShowBack = computed(() => {\n if (!props.allowBack) {\n return false\n }\n if (window.parent.openMenuSelect) {\n return false\n }\n return true\n })\n const goBack = () => {\n router?.back()\n }\n return {\n isShowBack,\n goBack,\n }\n}\nexport const useButtons = (props: HeaderProps, emit) => {\n const { t } = useLocale()\n const { mode: defaultMode } = useNavigation()\n const mode = computed(() => {\n return props.mode || defaultMode.value\n })\n let defaultButtons: ButtonsProps['list'] = [\n {\n name: t('ep.header.edit'),\n prop: 'edit',\n permission: props.name ? `${props.name}:UPDATE` : '',\n disabled: () => {\n return mode.value !== 'browse'\n },\n },\n {\n name: t('ep.header.save'),\n prop: 'save',\n permission: props.name ? `${props.name}:SAVE` : '',\n disabled: () => {\n return !(mode.value === 'edit' || mode.value === 'add')\n },\n },\n {\n name: t('ep.header.cancel'),\n prop: 'cancel',\n disabled: () => {\n return mode.value !== 'edit'\n },\n },\n {\n name: t('ep.header.refresh'),\n prop: 'refresh',\n permission: props.name ? `${props.name}:REFRESH` : '',\n disabled: () => {\n return mode.value !== 'browse'\n },\n },\n {\n name: t('ep.header.approvalLog'),\n prop: 'approvalLog',\n permission: props.name ? `${props.name}:APPROVALLOG` : '',\n show: () => {\n return !!props.workflowId\n },\n onClick: () => {\n gotoTaskTrace(props.workflowId!)\n },\n },\n ]\n // 过滤要显示的\n if (props.defaultButtons?.length) {\n defaultButtons = defaultButtons.filter((item) => {\n return props.defaultButtons!.some((item1) => item1 === item.prop)\n })\n }else if(props.defaultButtons?.length===0){\n defaultButtons = []\n }\n const buttons = mergeListByKey(defaultButtons, props.buttons)\n return {\n buttons,\n }\n}\n"],"names":["useHeader","props","emit","router","useRouter","isShowBack","computed","allowBack","window","parent","openMenuSelect","goBack","back","useButtons","t","useLocale","mode","defaultMode","useNavigation","value","defaultButtons","name","prop","permission","disabled","show","workflowId","onClick","gotoTaskTrace","length","filter","item","some","item1","buttons","mergeListByKey"],"mappings":";;;;;;;AAOO,MAAMA,SAAAA,GAAYA,CAACC,KAAAA,EAAOC,IAAAA,KAAS;AACxC,EAAA,MAAMC,SAASC,SAAAA,EAAU;AACzB,EAAA,MAAMC,UAAAA,GAAaC,SAAS,MAAM;AAChC,IAAA,IAAI,CAACL,MAAMM,SAAAA,EAAW;AACpB,MAAA,OAAO,KAAA;AAAA,IACT;AACA,IAAA,IAAIC,MAAAA,CAAOC,OAAOC,cAAAA,EAAgB;AAChC,MAAA,OAAO,KAAA;AAAA,IACT;AACA,IAAA,OAAO,IAAA;AAAA,EACT,CAAC,CAAA;AACD,EAAA,MAAMC,SA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,cAAAA,EAAgBnB,KAAAA,CAAMiC,OAAO,CAAA;AAC5D,EAAA,OAAO;AAAA,IACLA;AAAAA,GACF;AACF;;;;"}
@@ -1,3 +1,4 @@
1
+ import { nextTick } from 'vue';
1
2
  import type { SearchListPageProps } from './search-list-page';
2
3
  import type { FormItemProp } from 'element-plus';
3
4
  export declare const useSearchListPage: (props: SearchListPageProps, config?: {}) => {
@@ -1278,7 +1279,7 @@ export declare const useSearchListPage: (props: SearchListPageProps, config?: {}
1278
1279
  errorCaptured?: ((err: unknown, instance: import("vue").ComponentPublicInstance | null, info: string) => boolean | void) | ((err: unknown, instance: import("vue").ComponentPublicInstance | null, info: string) => boolean | void)[];
1279
1280
  };
1280
1281
  $forceUpdate: () => void;
1281
- $nextTick: typeof import("vue").nextTick;
1282
+ $nextTick: typeof nextTick;
1282
1283
  $watch<T extends string | ((...args: any) => any)>(source: T, cb: T extends (...args: any) => infer R ? (...args: [R, R, import("@vue/reactivity").OnCleanup]) => any : (...args: [any, any, import("@vue/reactivity").OnCleanup]) => any, options?: import("vue").WatchOptions): import("vue").WatchStopHandle;
1283
1284
  } & Readonly<{
1284
1285
  readonly data: any[];
@@ -2351,7 +2352,7 @@ export declare const useSearchListPage: (props: SearchListPageProps, config?: {}
2351
2352
  errorCaptured?: ((err: unknown, instance: import("vue").ComponentPublicInstance | null, info: string) => boolean | void) | ((err: unknown, instance: import("vue").ComponentPublicInstance | null, info: string) => boolean | void)[];
2352
2353
  };
2353
2354
  $forceUpdate: () => void;
2354
- $nextTick: typeof import("vue").nextTick;
2355
+ $nextTick: typeof nextTick;
2355
2356
  $watch<T extends string | ((...args: any) => any)>(source: T, cb: T extends (...args: any) => infer R ? (...args: [R, R, import("@vue/reactivity").OnCleanup]) => any : (...args: [any, any, import("@vue/reactivity").OnCleanup]) => any, options?: import("vue").WatchOptions): import("vue").WatchStopHandle;
2356
2357
  } & Readonly<{
2357
2358
  col: number;
@@ -2444,5 +2445,5 @@ export declare const useSearchListPage: (props: SearchListPageProps, config?: {}
2444
2445
  default?: (props: {}) => any;
2445
2446
  };
2446
2447
  }) | null>>;
2447
- beforeSearch: () => import("element-plus").FormValidationResult;
2448
+ beforeSearch: () => Promise<void>;
2448
2449
  };
@@ -1,4 +1,4 @@
1
- import { useTemplateRef, ref, computed, onMounted } from 'vue';
1
+ import { nextTick, useTemplateRef, ref, computed, onMounted } from 'vue';
2
2
  import { useLocale } from '../../../hooks/use-locale.mjs';
3
3
  import { mergeListByKey } from '../../../utils/utils.mjs';
4
4
  import { getEnv } from '../../../utils/env.mjs';
@@ -22,7 +22,12 @@ const useSearchListPage = (props, config = {}) => {
22
22
  reset,
23
23
  tableRef,
24
24
  formRef,
25
- beforeSearch: validate
25
+ beforeSearch: async () => {
26
+ if (!formRef.value) {
27
+ await nextTick();
28
+ }
29
+ await validate();
30
+ }
26
31
  };
27
32
  };
28
33
  const useTable = (props, config) => {
@@ -1 +1 @@
1
- {"version":3,"file":"use-search-list-page.mjs","sources":["../../../../../../packages/components/search-list-page/src/use-search-list-page.ts"],"sourcesContent":["import { ref, onMounted, computed, useTemplateRef } from 'vue'\nimport type { SearchListPageProps } from './search-list-page'\nimport type { ButtonsProps } from '@el-plus/components/buttons'\nimport type { FormInstance } from '@el-plus/components/form'\nimport type { TableInstance } from '@el-plus/components/table'\nimport type { FormItemProp } from 'element-plus'\nimport { mergeListByKey, getEnv } from '@el-plus/utils'\nimport { useLocale } from '@el-plus/hooks/use-locale'\n\nexport const useSearchListPage = (props: SearchListPageProps, config = {}) => {\n const { calcTableHeight, tableProps, tableRef } = useTable(props, config)\n const { formProps, validate, resetFields, formRef } = useForm(props, {\n calcTableHeight,\n })\n const { buttonsProps, searchButtons, search, reset } = useButtons(props, {\n validate,\n resetFields,\n tableRef,\n })\n return {\n formProps,\n tableProps,\n buttonsProps,\n searchButtons,\n search,\n reset,\n tableRef,\n formRef,\n beforeSearch: validate,\n }\n}\nconst useTable = (props: SearchListPageProps, config) => {\n const instanceName = 'tableRef'\n const tableRef = useTemplateRef<TableInstance>(instanceName)\n const tableHeight = ref(window.innerHeight)\n const tableProps = computed(() => {\n return {\n ref: instanceName,\n columns: props.columns,\n showPagination: true,\n height: tableHeight.value,\n showIndexCol: props.showIndexCol,\n showSelectionCol: props.showSelectionCol,\n showSingleSelectionCol: props.showSingleSelectionCol,\n actionButtons: props.actionButtons,\n formatColumns: props.formatColumns,\n api: props.api,\n reqAfter: props.reqAfter,\n reqBefore: props.reqBefore,\n reqData: props.formData,\n customColumnModule: props.customColumnModule,\n customColumnApi: props.customColumnApi,\n customColumnSaveApi: props.customColumnSaveApi,\n minWidth: props.minWidth,\n actionColWidth: props.actionColWidth,\n ...props.tableProps,\n }\n })\n const calcTableHeight = () => {\n setTimeout(() => {\n const topHeight = (document.getElementById('top') as HTMLElement)\n .offsetHeight\n const middleHeight = (document.getElementById('middle') as HTMLElement)\n .offsetHeight\n let paginationHeight = 0\n if (tableProps.value.showPagination) {\n paginationHeight =\n (document.querySelector('.el-pagination') as HTMLElement)\n .offsetHeight + 12\n }\n const frameDistance =\n window.parent.openMenuSelect || getEnv() !== 'local' ? 40 : 48 + 40\n\n tableHeight.value =\n window.innerHeight -\n topHeight -\n middleHeight -\n paginationHeight -\n frameDistance -\n props.offsetTop!\n }, 0)\n }\n\n onMounted(calcTableHeight)\n return {\n tableRef,\n tableProps,\n calcTableHeight,\n }\n}\nconst useForm = (props: SearchListPageProps, { calcTableHeight }) => {\n const instanceName = 'formRef'\n const formRef = useTemplateRef<FormInstance>(instanceName)\n const formProps = computed(() => {\n return {\n ref: instanceName,\n formItemList: props.formItemList,\n isShowFold: true,\n modelValue: props.formData,\n ...props.formProps,\n onToggleStatus: () => {\n calcTableHeight()\n },\n }\n })\n // 校验\n const validate = () => {\n return formRef.value!.validate()\n }\n // 重置校验\n const resetFields = (props: FormItemProp) => {\n return formRef.value!.resetFields(props)\n }\n // 清理某个字段的表单验证信息\n const clearValidate = (props: FormItemProp) => {\n return formRef.value!.clearValidate(props)\n }\n return {\n formProps,\n formRef,\n validate,\n resetFields,\n clearValidate,\n }\n}\nconst useButtons = (\n props: SearchListPageProps,\n { validate, resetFields, tableRef },\n) => {\n const { t } = useLocale()\n const defaultButtons: ButtonsProps['list'] = [\n {\n name: t('ep.searchListPage.add'),\n prop: 'add',\n permission: props.name ? `${props.name}:ADD` : '',\n show: () => {\n return !!props.add\n },\n onClick: () => {\n props.add?.()\n },\n },\n // {\n // name: t('ep.searchListPage.templateDownload'),\n // prop: 'templateDownload',\n // permission: props.name ? `${props.name}:TEMPLATEDOWNLOAD` : '',\n // show: !!props.templateDownloadApi,\n // },\n // {\n // name: t('ep.searchListPage.import'),\n // prop: 'import',\n // permission: props.name ? `${props.name}:IMPORT` : '',\n // show: !!props.importApi,\n // },\n // {\n // name: t('ep.searchListPage.export'),\n // prop: 'export',\n // permission: props.name ? `${props.name}:EXPORT` : '',\n // show: !!props.exportApi,\n // },\n ]\n const list = mergeListByKey(defaultButtons, props.leftButtons)\n if (props.customColumnModule) {\n list.push({\n name: t('ep.customColumn.columnSettings'),\n prop: 'customColumn',\n type: 'primary',\n onClick: () => {\n tableRef.value.openCustomColumnDialog()\n },\n })\n }\n list.forEach((item) => {\n if (item.onClick) {\n const clickFn = item.onClick\n item.onClick = () => {\n // 增加选中项\n const rows = tableRef.value.elTableRef.getSelectionRows()\n clickFn(rows)\n }\n }\n })\n\n const buttonsProps = computed(() => {\n return {\n list,\n ...props.buttonsProps,\n }\n })\n // 搜索\n const search = async (isInitSearch = false) => {\n // await validate()\n tableRef.value.search(isInitSearch)\n }\n // 清空\n const reset = async () => {\n resetFields()\n search(true)\n }\n const searchButtons: ButtonsProps['list'] = [\n {\n name: t('ep.searchListPage.search'),\n type: 'primary',\n onClick: search.bind(null, true),\n },\n {\n name: t('ep.searchListPage.clear'),\n onClick: reset,\n },\n ]\n return {\n buttonsProps,\n searchButtons,\n search,\n reset,\n }\n}\n"],"names":["props"],"mappings":";;;;;AASO,MAAM,iBAAA,GAAoB,CAAC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,CAAA;AAEA,EAAA,MAAM,QAAQ,YAAY;AACxB,IAAA,WAAA,EAAY;AACZ,IAAA,MAAA,CAAO,IAAI,CAAA;AAAA,EACb,CAAA;AACA,EAAA,MAAM,aAAA,GAAsC;AAAA,IAC1C;AAAA,MACE,IAAA,EAAM,EAAE,0BAA0B,CAAA;AAAA,MAClC,IAAA,EAAM,SAAA;AAAA,MACN,OAAA,EAAS,MAAA,CAAO,IAAA,CAAK,IAAA,EAAM,IAAI;AAAA,KACjC;AAAA,IACA;AAAA,MACE,IAAA,EAAM,EAAE,yBAAyB,CAAA;AAAA,MACjC,OAAA,EAAS;AAAA;AACX,GACF;AACA,EAAA,OAAO;AAAA,IACL,YAAA;AAAA,IACA,aAAA;AAAA,IACA,MAAA;AAAA,IACA;AAAA,GACF;AACF,CAAA;;;;"}
1
+ {"version":3,"file":"use-search-list-page.mjs","sources":["../../../../../../packages/components/search-list-page/src/use-search-list-page.ts"],"sourcesContent":["import { ref, onMounted, computed, useTemplateRef, nextTick } from 'vue'\nimport type { SearchListPageProps } from './search-list-page'\nimport type { ButtonsProps } from '@el-plus/components/buttons'\nimport type { FormInstance } from '@el-plus/components/form'\nimport type { TableInstance } from '@el-plus/components/table'\nimport type { FormItemProp } from 'element-plus'\nimport { mergeListByKey, getEnv } from '@el-plus/utils'\nimport { useLocale } from '@el-plus/hooks/use-locale'\n\nexport const useSearchListPage = (props: SearchListPageProps, config = {}) => {\n const { calcTableHeight, tableProps, tableRef } = useTable(props, config)\n const { formProps, validate, resetFields, formRef } = useForm(props, {\n calcTableHeight,\n })\n const { buttonsProps, searchButtons, search, reset } = useButtons(props, {\n validate,\n resetFields,\n tableRef,\n })\n return {\n formProps,\n tableProps,\n buttonsProps,\n searchButtons,\n search,\n reset,\n tableRef,\n formRef,\n beforeSearch: async () => {\n if (!formRef.value) {\n await nextTick()\n }\n await validate()\n }\n }\n}\nconst useTable = (props: SearchListPageProps, config) => {\n const instanceName = 'tableRef'\n const tableRef = useTemplateRef<TableInstance>(instanceName)\n const tableHeight = ref(window.innerHeight)\n const tableProps = computed(() => {\n return {\n ref: instanceName,\n columns: props.columns,\n showPagination: true,\n height: tableHeight.value,\n showIndexCol: props.showIndexCol,\n showSelectionCol: props.showSelectionCol,\n showSingleSelectionCol: props.showSingleSelectionCol,\n actionButtons: props.actionButtons,\n formatColumns: props.formatColumns,\n api: props.api,\n reqAfter: props.reqAfter,\n reqBefore: props.reqBefore,\n reqData: props.formData,\n customColumnModule: props.customColumnModule,\n customColumnApi: props.customColumnApi,\n customColumnSaveApi: props.customColumnSaveApi,\n minWidth: props.minWidth,\n actionColWidth: props.actionColWidth,\n ...props.tableProps,\n }\n })\n const calcTableHeight = () => {\n setTimeout(() => {\n const topHeight = (document.getElementById('top') as HTMLElement)\n .offsetHeight\n const middleHeight = (document.getElementById('middle') as HTMLElement)\n .offsetHeight\n let paginationHeight = 0\n if (tableProps.value.showPagination) {\n paginationHeight =\n (document.querySelector('.el-pagination') as HTMLElement)\n .offsetHeight + 12\n }\n const frameDistance =\n window.parent.openMenuSelect || getEnv() !== 'local' ? 40 : 48 + 40\n\n tableHeight.value =\n window.innerHeight -\n topHeight -\n middleHeight -\n paginationHeight -\n frameDistance -\n props.offsetTop!\n }, 0)\n }\n\n onMounted(calcTableHeight)\n return {\n tableRef,\n tableProps,\n calcTableHeight,\n }\n}\nconst useForm = (props: SearchListPageProps, { calcTableHeight }) => {\n const instanceName = 'formRef'\n const formRef = useTemplateRef<FormInstance>(instanceName)\n const formProps = computed(() => {\n return {\n ref: instanceName,\n formItemList: props.formItemList,\n isShowFold: true,\n modelValue: props.formData,\n ...props.formProps,\n onToggleStatus: () => {\n calcTableHeight()\n },\n }\n })\n // 校验\n const validate = () => {\n return formRef.value!.validate()\n }\n // 重置校验\n const resetFields = (props: FormItemProp) => {\n return formRef.value!.resetFields(props)\n }\n // 清理某个字段的表单验证信息\n const clearValidate = (props: FormItemProp) => {\n return formRef.value!.clearValidate(props)\n }\n return {\n formProps,\n formRef,\n validate,\n resetFields,\n clearValidate,\n }\n}\nconst useButtons = (\n props: SearchListPageProps,\n { validate, resetFields, tableRef },\n) => {\n const { t } = useLocale()\n const defaultButtons: ButtonsProps['list'] = [\n {\n name: t('ep.searchListPage.add'),\n prop: 'add',\n permission: props.name ? `${props.name}:ADD` : '',\n show: () => {\n return !!props.add\n },\n onClick: () => {\n props.add?.()\n },\n },\n // {\n // name: t('ep.searchListPage.templateDownload'),\n // prop: 'templateDownload',\n // permission: props.name ? `${props.name}:TEMPLATEDOWNLOAD` : '',\n // show: !!props.templateDownloadApi,\n // },\n // {\n // name: t('ep.searchListPage.import'),\n // prop: 'import',\n // permission: props.name ? `${props.name}:IMPORT` : '',\n // show: !!props.importApi,\n // },\n // {\n // name: t('ep.searchListPage.export'),\n // prop: 'export',\n // permission: props.name ? `${props.name}:EXPORT` : '',\n // show: !!props.exportApi,\n // },\n ]\n const list = mergeListByKey(defaultButtons, props.leftButtons)\n if (props.customColumnModule) {\n list.push({\n name: t('ep.customColumn.columnSettings'),\n prop: 'customColumn',\n type: 'primary',\n onClick: () => {\n tableRef.value.openCustomColumnDialog()\n },\n })\n }\n list.forEach((item) => {\n if (item.onClick) {\n const clickFn = item.onClick\n item.onClick = () => {\n // 增加选中项\n const rows = tableRef.value.elTableRef.getSelectionRows()\n clickFn(rows)\n }\n }\n })\n\n const buttonsProps = computed(() => {\n return {\n list,\n ...props.buttonsProps,\n }\n })\n // 搜索\n const search = async (isInitSearch = false) => {\n // await validate()\n tableRef.value.search(isInitSearch)\n }\n // 清空\n const reset = async () => {\n resetFields()\n search(true)\n }\n const searchButtons: ButtonsProps['list'] = [\n {\n name: t('ep.searchListPage.search'),\n type: 'primary',\n onClick: search.bind(null, true),\n },\n {\n name: t('ep.searchListPage.clear'),\n onClick: reset,\n },\n ]\n return {\n buttonsProps,\n searchButtons,\n search,\n reset,\n }\n}\n"],"names":["props"],"mappings":";;;;;AASO,MAAM,iBAAA,GAAoB,CAAC,KAAA,EAA4B,MA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MAAA,GAAS,OAAO,YAAA,GAAe,KAAA,KAAU;AAE7C,IAAA,QAAA,CAAS,KAAA,CAAM,OAAO,YAAY,CAAA;AAAA,EACpC,CAAA;AAEA,EAAA,MAAM,QAAQ,YAAY;AACxB,IAAA,WAAA,EAAY;AACZ,IAAA,MAAA,CAAO,IAAI,CAAA;AAAA,EACb,CAAA;AACA,EAAA,MAAM,aAAA,GAAsC;AAAA,IAC1C;AAAA,MACE,IAAA,EAAM,EAAE,0BAA0B,CAAA;AAAA,MAClC,IAAA,EAAM,SAAA;AAAA,MACN,OAAA,EAAS,MAAA,CAAO,IAAA,CAAK,IAAA,EAAM,IAAI;AAAA,KACjC;AAAA,IACA;AAAA,MACE,IAAA,EAAM,EAAE,yBAAyB,CAAA;AAAA,MACjC,OAAA,EAAS;AAAA;AACX,GACF;AACA,EAAA,OAAO;AAAA,IACL,YAAA;AAAA,IACA,aAAA;AAAA,IACA,MAAA;AAAA,IACA;AAAA,GACF;AACF,CAAA;;;;"}
@@ -1,4 +1,4 @@
1
- import { useTemplateRef, ref, useAttrs, watch, getCurrentInstance, computed, reactive, nextTick, createVNode, createTextVNode, toRaw } from 'vue';
1
+ import { useTemplateRef, ref, useAttrs, watch, getCurrentInstance, computed, reactive, createVNode, createTextVNode, toRaw } from 'vue';
2
2
  import { useRequest } from '../../../hooks/use-request.mjs';
3
3
  import { merge, cloneDeep } from 'lodash-unified';
4
4
  import { prepareProps } from '../../../utils/props.mjs';
@@ -10,7 +10,9 @@ import { bus } from '../../../utils/mitt.mjs';
10
10
  const useTable = (props) => {
11
11
  const elFormRef = useTemplateRef("elFormRef");
12
12
  const elTableRef = useTemplateRef("elTableRef");
13
+ const allData = ref([]);
13
14
  const customData = ref([]);
15
+ const apiTotal = ref(0);
14
16
  const {
15
17
  loading,
16
18
  requestFn
@@ -25,15 +27,18 @@ const useTable = (props) => {
25
27
  hooks: {
26
28
  success(data) {
27
29
  if (Array.isArray(data)) {
28
- customData.value = data;
30
+ allData.value = data;
29
31
  } else if (data && typeof data === "object") {
30
32
  const rawData = data;
31
- customData.value = rawData?.list || rawData?.data || [];
33
+ allData.value = rawData?.list || rawData?.data || [];
32
34
  } else {
33
- customData.value = [];
35
+ allData.value = [];
34
36
  }
35
- if (props.showPagination) {
36
- pagination.total = (props.isFrontPage ? customData.value.length : data.total) || 0;
37
+ if (props.isFrontPage) {
38
+ frontPaginationHandler();
39
+ } else {
40
+ customData.value = allData.value;
41
+ apiTotal.value = data.total || 0;
37
42
  }
38
43
  },
39
44
  fail(error) {
@@ -46,21 +51,13 @@ const useTable = (props) => {
46
51
  const search = async (init = false, isPagination = false) => {
47
52
  const beforeSearch = attrs["before-search"];
48
53
  if (typeof beforeSearch === "function") {
49
- await nextTick();
50
54
  await beforeSearch?.();
51
55
  }
52
56
  if (init) {
53
57
  pagination.pageNo = 1;
54
58
  }
55
59
  if (isPagination && props.isFrontPage) {
56
- const {
57
- pageNo,
58
- pageSize
59
- } = pagination;
60
- const data = customData.value.filter((item, index) => {
61
- return index < pageNo * pageSize && index >= (pageNo - 1) * pageSize;
62
- });
63
- customData.value = data;
60
+ frontPaginationHandler();
64
61
  } else {
65
62
  if (props.api) {
66
63
  requestFn({
@@ -68,22 +65,36 @@ const useTable = (props) => {
68
65
  pageSize: pagination.pageSize,
69
66
  pageNum: pagination.pageNo
70
67
  });
71
- } else if (props.data?.length) {
72
- customData.value = props.data;
73
68
  }
74
69
  }
75
70
  };
71
+ const {
72
+ pagination,
73
+ paginationProps
74
+ } = usePagination(props, search, allData, apiTotal);
75
+ const frontPaginationHandler = () => {
76
+ const {
77
+ pageNo,
78
+ pageSize
79
+ } = pagination;
80
+ const data = allData.value.filter((item, index) => {
81
+ return index < pageNo * pageSize && index >= (pageNo - 1) * pageSize;
82
+ });
83
+ customData.value = data;
84
+ };
76
85
  if (!props.api) {
77
86
  watch(() => props.data, (newValue) => {
78
- customData.value = newValue;
87
+ allData.value = newValue;
88
+ if (props.isFrontPage) {
89
+ frontPaginationHandler();
90
+ } else {
91
+ customData.value = allData.value;
92
+ }
79
93
  }, {
80
- deep: true
94
+ deep: true,
95
+ immediate: true
81
96
  });
82
97
  }
83
- const {
84
- pagination,
85
- paginationProps
86
- } = usePagination(props, search);
87
98
  (async () => {
88
99
  if (props.isInitSearch) {
89
100
  if (props.customColumnModule) {
@@ -137,11 +148,13 @@ const useTable = (props) => {
137
148
  customColumns
138
149
  };
139
150
  };
140
- const usePagination = function(props, search) {
151
+ const usePagination = function(props, search, allData, apiTotal) {
141
152
  const defaultPaginationProps = props.paginationProps || {};
142
153
  const pageSizes = defaultPaginationProps.pageSizes || [20, 50, 100, 200];
143
154
  const pagination = reactive({
144
- total: 0,
155
+ total: computed(() => {
156
+ return !props.isFrontPage && props.api ? apiTotal.value : allData.value.length;
157
+ }),
145
158
  pageNo: 1,
146
159
  pageSize: pageSizes[0]
147
160
  });