el-plus 0.0.80 → 0.0.82
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/CHANGELOG.md +12 -0
- package/dist/index.full.js +61 -38
- package/dist/index.full.min.js +4 -4
- package/dist/index.full.min.js.map +1 -1
- package/dist/index.full.min.mjs +4 -4
- package/dist/index.full.min.mjs.map +1 -1
- package/dist/index.full.mjs +61 -38
- package/es/components/header/index.d.ts +0 -6
- package/es/components/header/src/header.d.ts +0 -1
- package/es/components/header/src/header.mjs +1 -2
- package/es/components/header/src/header.mjs.map +1 -1
- package/es/components/header/src/header.vue.d.ts +0 -3
- package/es/components/header/src/use-header.mjs +3 -1
- package/es/components/header/src/use-header.mjs.map +1 -1
- package/es/components/search-list-page/src/use-search-list-page.d.ts +4 -3
- package/es/components/search-list-page/src/use-search-list-page.mjs +7 -2
- package/es/components/search-list-page/src/use-search-list-page.mjs.map +1 -1
- package/es/components/table/src/use-table.mjs +38 -25
- package/es/components/table/src/use-table.mjs.map +1 -1
- package/es/hooks/use-request.mjs +13 -8
- package/es/hooks/use-request.mjs.map +1 -1
- package/es/package.json.mjs +1 -1
- package/lib/components/header/index.d.ts +0 -6
- package/lib/components/header/src/header.d.ts +0 -1
- package/lib/components/header/src/header.js +1 -2
- package/lib/components/header/src/header.js.map +1 -1
- package/lib/components/header/src/header.vue.d.ts +0 -3
- package/lib/components/header/src/use-header.js +3 -1
- package/lib/components/header/src/use-header.js.map +1 -1
- package/lib/components/search-list-page/src/use-search-list-page.d.ts +4 -3
- package/lib/components/search-list-page/src/use-search-list-page.js +6 -1
- package/lib/components/search-list-page/src/use-search-list-page.js.map +1 -1
- package/lib/components/table/src/use-table.js +37 -24
- package/lib/components/table/src/use-table.js.map +1 -1
- package/lib/hooks/use-request.js +13 -8
- package/lib/hooks/use-request.js.map +1 -1
- package/lib/package.json.js +1 -1
- package/package.json +1 -1
package/dist/index.full.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! ElPlus v0.0.
|
|
1
|
+
/*! ElPlus v0.0.82 */
|
|
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';
|
|
@@ -1483,11 +1483,6 @@ const useRequest = ({
|
|
|
1483
1483
|
const config = {
|
|
1484
1484
|
method
|
|
1485
1485
|
};
|
|
1486
|
-
if (cancelToken) {
|
|
1487
|
-
config.cancelRequest = (cancel) => {
|
|
1488
|
-
cancelRequest = cancel;
|
|
1489
|
-
};
|
|
1490
|
-
}
|
|
1491
1486
|
apiFn = (data = {}, params) => {
|
|
1492
1487
|
if (config.method === "get") {
|
|
1493
1488
|
config.params = data;
|
|
@@ -1511,29 +1506,38 @@ const useRequest = ({
|
|
|
1511
1506
|
if (reqBefore) {
|
|
1512
1507
|
reqBefore(config);
|
|
1513
1508
|
}
|
|
1509
|
+
if (cancelToken) {
|
|
1510
|
+
config.cancelToken = new axios.CancelToken(function(cancel) {
|
|
1511
|
+
cancelRequest = cancel;
|
|
1512
|
+
});
|
|
1513
|
+
}
|
|
1514
1514
|
return http.request(api, config);
|
|
1515
1515
|
};
|
|
1516
1516
|
} else {
|
|
1517
1517
|
apiFn = api;
|
|
1518
1518
|
}
|
|
1519
|
-
const requestFn = async (data = {}) => {
|
|
1519
|
+
const requestFn = async (data = {}, params) => {
|
|
1520
1520
|
if (loading.value && !cancelToken) return;
|
|
1521
1521
|
loading.value = true;
|
|
1522
1522
|
try {
|
|
1523
1523
|
cancelRequest && cancelRequest();
|
|
1524
|
-
const res = await apiFn(data);
|
|
1524
|
+
const res = await apiFn(data, params);
|
|
1525
1525
|
if (reqAfter) {
|
|
1526
1526
|
reqAfter(res);
|
|
1527
1527
|
}
|
|
1528
1528
|
if (hooks?.success) {
|
|
1529
1529
|
hooks.success(typeof api === "function" ? res : res.data);
|
|
1530
1530
|
}
|
|
1531
|
+
loading.value = false;
|
|
1531
1532
|
} catch (error) {
|
|
1532
1533
|
if (hooks?.fail) {
|
|
1533
1534
|
hooks.fail(error);
|
|
1534
1535
|
}
|
|
1535
|
-
|
|
1536
|
+
if (axios.isCancel(error)) {
|
|
1537
|
+
return;
|
|
1538
|
+
}
|
|
1536
1539
|
loading.value = false;
|
|
1540
|
+
} finally {
|
|
1537
1541
|
}
|
|
1538
1542
|
};
|
|
1539
1543
|
return {
|
|
@@ -1979,7 +1983,9 @@ const useFormDialog = (options = {}) => {
|
|
|
1979
1983
|
const useTable$1 = (props) => {
|
|
1980
1984
|
const elFormRef = useTemplateRef("elFormRef");
|
|
1981
1985
|
const elTableRef = useTemplateRef("elTableRef");
|
|
1986
|
+
const allData = ref([]);
|
|
1982
1987
|
const customData = ref([]);
|
|
1988
|
+
const apiTotal = ref(0);
|
|
1983
1989
|
const {
|
|
1984
1990
|
loading,
|
|
1985
1991
|
requestFn
|
|
@@ -1994,15 +2000,18 @@ const useTable$1 = (props) => {
|
|
|
1994
2000
|
hooks: {
|
|
1995
2001
|
success(data) {
|
|
1996
2002
|
if (Array.isArray(data)) {
|
|
1997
|
-
|
|
2003
|
+
allData.value = data;
|
|
1998
2004
|
} else if (data && typeof data === "object") {
|
|
1999
2005
|
const rawData = data;
|
|
2000
|
-
|
|
2006
|
+
allData.value = rawData?.list || rawData?.data || [];
|
|
2001
2007
|
} else {
|
|
2002
|
-
|
|
2008
|
+
allData.value = [];
|
|
2003
2009
|
}
|
|
2004
|
-
if (props.
|
|
2005
|
-
|
|
2010
|
+
if (props.isFrontPage) {
|
|
2011
|
+
frontPaginationHandler();
|
|
2012
|
+
} else {
|
|
2013
|
+
customData.value = allData.value;
|
|
2014
|
+
apiTotal.value = data.total || 0;
|
|
2006
2015
|
}
|
|
2007
2016
|
},
|
|
2008
2017
|
fail(error) {
|
|
@@ -2015,21 +2024,13 @@ const useTable$1 = (props) => {
|
|
|
2015
2024
|
const search = async (init = false, isPagination = false) => {
|
|
2016
2025
|
const beforeSearch = attrs["before-search"];
|
|
2017
2026
|
if (typeof beforeSearch === "function") {
|
|
2018
|
-
await nextTick();
|
|
2019
2027
|
await beforeSearch?.();
|
|
2020
2028
|
}
|
|
2021
2029
|
if (init) {
|
|
2022
2030
|
pagination.pageNo = 1;
|
|
2023
2031
|
}
|
|
2024
2032
|
if (isPagination && props.isFrontPage) {
|
|
2025
|
-
|
|
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;
|
|
2033
|
+
frontPaginationHandler();
|
|
2033
2034
|
} else {
|
|
2034
2035
|
if (props.api) {
|
|
2035
2036
|
requestFn({
|
|
@@ -2037,22 +2038,36 @@ const useTable$1 = (props) => {
|
|
|
2037
2038
|
pageSize: pagination.pageSize,
|
|
2038
2039
|
pageNum: pagination.pageNo
|
|
2039
2040
|
});
|
|
2040
|
-
} else if (props.data?.length) {
|
|
2041
|
-
customData.value = props.data;
|
|
2042
2041
|
}
|
|
2043
2042
|
}
|
|
2044
2043
|
};
|
|
2044
|
+
const {
|
|
2045
|
+
pagination,
|
|
2046
|
+
paginationProps
|
|
2047
|
+
} = usePagination(props, search, allData, apiTotal);
|
|
2048
|
+
const frontPaginationHandler = () => {
|
|
2049
|
+
const {
|
|
2050
|
+
pageNo,
|
|
2051
|
+
pageSize
|
|
2052
|
+
} = pagination;
|
|
2053
|
+
const data = allData.value.filter((item, index) => {
|
|
2054
|
+
return index < pageNo * pageSize && index >= (pageNo - 1) * pageSize;
|
|
2055
|
+
});
|
|
2056
|
+
customData.value = data;
|
|
2057
|
+
};
|
|
2045
2058
|
if (!props.api) {
|
|
2046
2059
|
watch(() => props.data, (newValue) => {
|
|
2047
|
-
|
|
2060
|
+
allData.value = newValue;
|
|
2061
|
+
if (props.isFrontPage) {
|
|
2062
|
+
frontPaginationHandler();
|
|
2063
|
+
} else {
|
|
2064
|
+
customData.value = allData.value;
|
|
2065
|
+
}
|
|
2048
2066
|
}, {
|
|
2049
|
-
deep: true
|
|
2067
|
+
deep: true,
|
|
2068
|
+
immediate: true
|
|
2050
2069
|
});
|
|
2051
2070
|
}
|
|
2052
|
-
const {
|
|
2053
|
-
pagination,
|
|
2054
|
-
paginationProps
|
|
2055
|
-
} = usePagination(props, search);
|
|
2056
2071
|
(async () => {
|
|
2057
2072
|
if (props.isInitSearch) {
|
|
2058
2073
|
if (props.customColumnModule) {
|
|
@@ -2106,11 +2121,13 @@ const useTable$1 = (props) => {
|
|
|
2106
2121
|
customColumns
|
|
2107
2122
|
};
|
|
2108
2123
|
};
|
|
2109
|
-
const usePagination = function(props, search) {
|
|
2124
|
+
const usePagination = function(props, search, allData, apiTotal) {
|
|
2110
2125
|
const defaultPaginationProps = props.paginationProps || {};
|
|
2111
2126
|
const pageSizes = defaultPaginationProps.pageSizes || [20, 50, 100, 200];
|
|
2112
2127
|
const pagination = reactive({
|
|
2113
|
-
total:
|
|
2128
|
+
total: computed(() => {
|
|
2129
|
+
return !props.isFrontPage && props.api ? apiTotal.value : allData.value.length;
|
|
2130
|
+
}),
|
|
2114
2131
|
pageNo: 1,
|
|
2115
2132
|
pageSize: pageSizes[0]
|
|
2116
2133
|
});
|
|
@@ -2599,7 +2616,12 @@ const useSearchListPage = (props, config = {}) => {
|
|
|
2599
2616
|
reset,
|
|
2600
2617
|
tableRef,
|
|
2601
2618
|
formRef,
|
|
2602
|
-
beforeSearch:
|
|
2619
|
+
beforeSearch: async () => {
|
|
2620
|
+
if (!formRef.value) {
|
|
2621
|
+
await nextTick();
|
|
2622
|
+
}
|
|
2623
|
+
await validate();
|
|
2624
|
+
}
|
|
2603
2625
|
};
|
|
2604
2626
|
};
|
|
2605
2627
|
const useTable = (props, config) => {
|
|
@@ -3175,8 +3197,7 @@ const headerProps = {
|
|
|
3175
3197
|
// 权限前缀
|
|
3176
3198
|
// 要展示的默认按钮
|
|
3177
3199
|
defaultButtons: {
|
|
3178
|
-
type: Array
|
|
3179
|
-
default: () => []
|
|
3200
|
+
type: Array
|
|
3180
3201
|
},
|
|
3181
3202
|
// 工作流id
|
|
3182
3203
|
workflowId: String,
|
|
@@ -3355,10 +3376,12 @@ const useButtons = (props, emit) => {
|
|
|
3355
3376
|
gotoTaskTrace(props.workflowId);
|
|
3356
3377
|
}
|
|
3357
3378
|
}];
|
|
3358
|
-
if (props.defaultButtons
|
|
3379
|
+
if (props.defaultButtons?.length) {
|
|
3359
3380
|
defaultButtons = defaultButtons.filter((item) => {
|
|
3360
3381
|
return props.defaultButtons.some((item1) => item1 === item.prop);
|
|
3361
3382
|
});
|
|
3383
|
+
} else if (props.defaultButtons?.length === 0) {
|
|
3384
|
+
defaultButtons = [];
|
|
3362
3385
|
}
|
|
3363
3386
|
const buttons = mergeListByKey(defaultButtons, props.buttons);
|
|
3364
3387
|
return {
|
|
@@ -4273,7 +4296,7 @@ var components = [
|
|
|
4273
4296
|
EpUniVue
|
|
4274
4297
|
];
|
|
4275
4298
|
|
|
4276
|
-
var version = "0.0.
|
|
4299
|
+
var version = "0.0.82";
|
|
4277
4300
|
|
|
4278
4301
|
var globalProperties = {
|
|
4279
4302
|
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: {
|
|
@@ -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
|
|
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
|
|
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
|
|
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,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,EA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EAAGpB,KAAAA,CAAMoB,IAAI,CAAA,YAAA,CAAA,GAAiB,EAAA;AAAA,IACvDI,MAAMA,MAAM;AACV,MAAA,OAAO,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,gBAAgBS,MAAAA,EAAQ;AAChCT,IAAAA,cAAAA,GAAiBA,cAAAA,CAAeU,OAAQC,CAAAA,IAAAA,KAAS;AAC/C,MAAA,OAAO9B,MAAMmB,cAAAA,CAAgBY,IAAAA,CAAMC,CAAAA,KAAAA,KAAUA,KAAAA,KAAUF,KAAKT,IAAI,CAAA;AAAA,IAClE,CAAC,CAAA;AAAA,EACH,CAAA,MAAA,IAASrB,KAAAA,CAAMmB,cAAAA,EAAgBS,MAAAA,KAAS,CAAA,EAAE;AACxCT,IAAAA,cAAAA,GAAiB,EAAA;AAAA,EACnB;AACA,EAAA,MAAMc,OAAAA,GAAUC,cAAAA,CAAef,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
|
|
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
|
|
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: () =>
|
|
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:
|
|
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,KAAA,EAA4B,MAAA,GAAS,EAAC,KAAM;AAC5E,EAAA,MAAM,EAAE,eAAA,EAAiB,UAAA,EAAY,UAAS,GAAI,QAAA,CAAS,KAAa,CAAA;AACxE,EAAA,MAAM,EAAE,SAAA,EAAW,QAAA,EAAU,aAAa,OAAA,EAAQ,GAAI,QAAQ,KAAA,EA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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,MAAA,GAAS,EAAC,KAAM;AAC5E,EAAA,MAAM,EAAE,eAAA,EAAiB,UAAA,EAAY,UAAS,GAAI,QAAA,CAAS,KAAa,CAAA;AACxE,EAAA,MAAM,EAAE,SAAA,EAAW,QAAA,EAAU,aAAa,OAAA,EAAQ,GAAI,QAAQ,KAAA,EAAO;AAAA,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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,
|
|
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
|
-
|
|
30
|
+
allData.value = data;
|
|
29
31
|
} else if (data && typeof data === "object") {
|
|
30
32
|
const rawData = data;
|
|
31
|
-
|
|
33
|
+
allData.value = rawData?.list || rawData?.data || [];
|
|
32
34
|
} else {
|
|
33
|
-
|
|
35
|
+
allData.value = [];
|
|
34
36
|
}
|
|
35
|
-
if (props.
|
|
36
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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:
|
|
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
|
});
|