|
@@ -1,14 +1,15 @@
|
|
|
-import { reactive, ref, Ref, unref } from 'vue';
|
|
|
-import { merge } from 'lodash-es';
|
|
|
-import { DynamicProps } from '/#/utils';
|
|
|
-import { BasicTableProps, TableActionType, useTable } from '/@/components/Table';
|
|
|
-import { ColEx } from '/@/components/Form/src/types';
|
|
|
-import { FormActionType } from '/@/components/Form';
|
|
|
-import { useMessage } from '/@/hooks/web/useMessage';
|
|
|
-import { useMethods } from '/@/hooks/system/useMethods';
|
|
|
-import { useDesign } from '/@/hooks/web/useDesign';
|
|
|
-import { filterObj } from '/@/utils/common/compUtils';
|
|
|
-const { handleExportXls, handleImportXls } = useMethods();
|
|
|
+import {reactive, ref, Ref, unref} from 'vue';
|
|
|
+import {merge} from 'lodash-es';
|
|
|
+import {DynamicProps} from '/#/utils';
|
|
|
+import {BasicTableProps, TableActionType, useTable} from '/@/components/Table';
|
|
|
+import {ColEx} from '/@/components/Form/src/types';
|
|
|
+import {FormActionType} from '/@/components/Form';
|
|
|
+import {useMessage} from '/@/hooks/web/useMessage';
|
|
|
+import {useMethods} from '/@/hooks/system/useMethods';
|
|
|
+import {useDesign} from '/@/hooks/web/useDesign';
|
|
|
+import {filterObj} from '/@/utils/common/compUtils';
|
|
|
+
|
|
|
+const {handleExportXls, handleImportXls} = useMethods();
|
|
|
|
|
|
// 定义 useListPage 方法所需参数
|
|
|
interface ListPageOptions {
|
|
@@ -57,32 +58,35 @@ export function useListPage(options: ListPageOptions) {
|
|
|
$design = useDesign(options.designScope);
|
|
|
}
|
|
|
|
|
|
+ // 全局将table list的分页数量设置为30
|
|
|
+ options.tableProps.pagination = Object.assign({}, options.tableProps.pagination, {pageSize: 30});
|
|
|
+
|
|
|
const tableContext = useListTable(options.tableProps);
|
|
|
|
|
|
- const [, { getForm, reload, setLoading }, { selectedRowKeys }] = tableContext;
|
|
|
+ const [, {getForm, reload, setLoading}, {selectedRowKeys}] = tableContext;
|
|
|
|
|
|
// 导出 excel
|
|
|
async function onExportXls() {
|
|
|
//update-begin---author:wangshuai ---date:20220411 for:导出新增自定义参数------------
|
|
|
- let { url, name, params } = options?.exportConfig ?? {};
|
|
|
+ let {url, name, params} = options?.exportConfig ?? {};
|
|
|
let realUrl = typeof url === 'function' ? url() : url;
|
|
|
if (realUrl) {
|
|
|
let title = typeof name === 'function' ? name() : name;
|
|
|
//update-begin-author:taoyan date:20220507 for: erp代码生成 子表 导出报错,原因未知-
|
|
|
- let paramsForm:any = {};
|
|
|
+ let paramsForm: any = {};
|
|
|
try {
|
|
|
paramsForm = await getForm().validate();
|
|
|
} catch (e) {
|
|
|
console.error(e);
|
|
|
}
|
|
|
//update-end-author:taoyan date:20220507 for: erp代码生成 子表 导出报错,原因未知-
|
|
|
-
|
|
|
+
|
|
|
//update-begin-author:liusq date:20230410 for:[/issues/409]导出功能没有按排序结果导出,设置导出默认排序,创建时间倒序
|
|
|
- if(!paramsForm?.column){
|
|
|
- Object.assign(paramsForm,{column:'createTime',order:'desc'});
|
|
|
+ if (!paramsForm?.column) {
|
|
|
+ Object.assign(paramsForm, {column: 'createTime', order: 'desc'});
|
|
|
}
|
|
|
//update-begin-author:liusq date:20230410 for: [/issues/409]导出功能没有按排序结果导出,设置导出默认排序,创建时间倒序
|
|
|
-
|
|
|
+
|
|
|
//如果参数不为空,则整合到一起
|
|
|
//update-begin-author:taoyan date:20220507 for: erp代码生成 子表 导出动态设置mainId
|
|
|
if (params) {
|
|
@@ -108,7 +112,7 @@ export function useListPage(options: ListPageOptions) {
|
|
|
|
|
|
// 导入 excel
|
|
|
function onImportXls(file) {
|
|
|
- let { url, success } = options?.importConfig ?? {};
|
|
|
+ let {url, success} = options?.importConfig ?? {};
|
|
|
//update-begin-author:taoyan date:20220507 for: erp代码生成 子表 导入地址是动态的
|
|
|
let realUrl = typeof url === 'function' ? url() : url;
|
|
|
if (realUrl) {
|
|
@@ -160,7 +164,7 @@ export function useListPage(options: ListPageOptions) {
|
|
|
|
|
|
/** 执行单个删除操作 */
|
|
|
function doDeleteRecord(api: () => Promise<any>) {
|
|
|
- return doRequest(api, { confirm: false, clearSelection: false });
|
|
|
+ return doRequest(api, {confirm: false, clearSelection: false});
|
|
|
}
|
|
|
|
|
|
return {
|
|
@@ -187,7 +191,7 @@ type UseTableMethod = TableActionType & {
|
|
|
*/
|
|
|
export function useListTable(tableProps: TableProps): [
|
|
|
(instance: TableActionType, formInstance: UseTableMethod) => void,
|
|
|
- TableActionType & {
|
|
|
+ TableActionType & {
|
|
|
getForm: () => FormActionType;
|
|
|
},
|
|
|
{
|
|
@@ -218,7 +222,7 @@ export function useListTable(tableProps: TableProps): [
|
|
|
// 按下回车后自动提交
|
|
|
autoSubmitOnEnter: true,
|
|
|
// 默认 row 配置
|
|
|
- rowProps: { gutter: 8 },
|
|
|
+ rowProps: {gutter: 8},
|
|
|
// 默认 col 配置
|
|
|
baseColProps: {
|
|
|
...adaptiveColProps,
|
|
@@ -239,7 +243,7 @@ export function useListTable(tableProps: TableProps): [
|
|
|
// 操作按钮配置
|
|
|
actionColOptions: {
|
|
|
...adaptiveColProps,
|
|
|
- style: { textAlign: 'left' },
|
|
|
+ style: {textAlign: 'left'},
|
|
|
},
|
|
|
},
|
|
|
// 斑马纹
|
|
@@ -271,13 +275,13 @@ export function useListTable(tableProps: TableProps): [
|
|
|
//是否锁定操作列取值 right ,left,false
|
|
|
fixed: false,
|
|
|
dataIndex: 'action',
|
|
|
- slots: { customRender: 'action' },
|
|
|
+ slots: {customRender: 'action'},
|
|
|
},
|
|
|
};
|
|
|
// 合并用户个性化配置
|
|
|
if (tableProps) {
|
|
|
//update-begin---author:wangshuai---date:2024-04-28---for:【issues/6180】前端代码配置表变查询条件显示列不生效---
|
|
|
- if(tableProps.formConfig){
|
|
|
+ if (tableProps.formConfig) {
|
|
|
setTableProps(tableProps.formConfig);
|
|
|
}
|
|
|
//update-end---author:wangshuai---date:2024-04-28---for:【issues/6180】前端代码配置表变查询条件显示列不生效---
|
|
@@ -288,11 +292,11 @@ export function useListTable(tableProps: TableProps): [
|
|
|
// 发送请求之前调用的方法
|
|
|
function beforeFetch(params) {
|
|
|
// 默认以 createTime 降序排序
|
|
|
- return Object.assign({ column: 'createTime', order: 'desc' }, params);
|
|
|
+ return Object.assign({column: 'createTime', order: 'desc'}, params);
|
|
|
}
|
|
|
|
|
|
// 合并方法
|
|
|
- Object.assign(defaultTableProps, { beforeFetch });
|
|
|
+ Object.assign(defaultTableProps, {beforeFetch});
|
|
|
if (typeof tableProps.beforeFetch === 'function') {
|
|
|
defaultTableProps.beforeFetch = function (params) {
|
|
|
params = beforeFetch(params);
|
|
@@ -332,11 +336,11 @@ export function useListTable(tableProps: TableProps): [
|
|
|
* @param formConfig
|
|
|
*/
|
|
|
function setTableProps(formConfig: any) {
|
|
|
- const replaceAttributeArray: string[] = ['baseColProps','labelCol'];
|
|
|
+ const replaceAttributeArray: string[] = ['baseColProps', 'labelCol'];
|
|
|
for (let item of replaceAttributeArray) {
|
|
|
- if(formConfig && formConfig[item]){
|
|
|
- if(defaultTableProps.formConfig){
|
|
|
- let defaultFormConfig:any = defaultTableProps.formConfig;
|
|
|
+ if (formConfig && formConfig[item]) {
|
|
|
+ if (defaultTableProps.formConfig) {
|
|
|
+ let defaultFormConfig: any = defaultTableProps.formConfig;
|
|
|
defaultFormConfig[item] = formConfig[item];
|
|
|
}
|
|
|
formConfig[item] = {};
|