|
|
@ -46,16 +46,7 @@ |
|
|
|
</AFormItem> |
|
|
|
</AFormItem> |
|
|
|
</AForm> |
|
|
|
</AForm> |
|
|
|
<ATable ref="tableElRef" |
|
|
|
<ATable ref="tableElRef" |
|
|
|
v-bind="state.tableProps" |
|
|
|
v-bind="getBindValues" |
|
|
|
:loading="state.loading" |
|
|
|
|
|
|
|
:size="state.selectedKeys[0]" |
|
|
|
|
|
|
|
:dataSource="state.dataSource" |
|
|
|
|
|
|
|
:columns="columns" |
|
|
|
|
|
|
|
:bordered="true" |
|
|
|
|
|
|
|
:scroll="getScrollRef" |
|
|
|
|
|
|
|
:rowClassName="getRowClassName" |
|
|
|
|
|
|
|
:rowSelection="getRowSelectionRef" |
|
|
|
|
|
|
|
:pagination="getPaginationInfo" |
|
|
|
|
|
|
|
@change="handleTablePaginationChange" |
|
|
|
@change="handleTablePaginationChange" |
|
|
|
> |
|
|
|
> |
|
|
|
<template #title> |
|
|
|
<template #title> |
|
|
@ -160,7 +151,7 @@ |
|
|
|
import { Table, Form, Row, Col, Divider, Tooltip, Dropdown, Menu, Select, DatePicker, Alert } from 'ant-design-vue'; |
|
|
|
import { Table, Form, Row, Col, Divider, Tooltip, Dropdown, Menu, Select, DatePicker, Alert } from 'ant-design-vue'; |
|
|
|
import {BasicColumn, BasicTableProps, PaginationProps, SizeType, SorterResult} from '/@/components/Table'; |
|
|
|
import {BasicColumn, BasicTableProps, PaginationProps, SizeType, SorterResult} from '/@/components/Table'; |
|
|
|
import { listConfig, delConfig } from '/@/api/platform/system/controller/config'; |
|
|
|
import { listConfig, delConfig } from '/@/api/platform/system/controller/config'; |
|
|
|
import ConfigModal from './ConfigModal.vue'; |
|
|
|
//import ConfigModal from './ConfigModal.vue'; |
|
|
|
import { columns } from './config.data'; |
|
|
|
import { columns } from './config.data'; |
|
|
|
import { useMessage } from '/@/hooks/web/useMessage'; |
|
|
|
import { useMessage } from '/@/hooks/web/useMessage'; |
|
|
|
import { reactive, toRaw, unref } from 'vue'; |
|
|
|
import { reactive, toRaw, unref } from 'vue'; |
|
|
@ -176,13 +167,13 @@ |
|
|
|
import {usePagination} from "/@/components/Table/src/hooks/usePagination"; |
|
|
|
import {usePagination} from "/@/components/Table/src/hooks/usePagination"; |
|
|
|
import {useTableStyle} from "/@/components/Table/src/hooks/useTableStyle"; |
|
|
|
import {useTableStyle} from "/@/components/Table/src/hooks/useTableStyle"; |
|
|
|
import {useTableScroll} from "/@/components/Table/src/hooks/useTableScroll"; |
|
|
|
import {useTableScroll} from "/@/components/Table/src/hooks/useTableScroll"; |
|
|
|
|
|
|
|
import expandIcon from "/@/components/Table/src/components/ExpandIcon"; |
|
|
|
|
|
|
|
import {omit} from "lodash-es"; |
|
|
|
|
|
|
|
|
|
|
|
/** 类型规范统一声明定义区域 */ |
|
|
|
/** 类型规范统一声明定义区域 */ |
|
|
|
interface TableState { |
|
|
|
interface TableState { |
|
|
|
loading: boolean; |
|
|
|
|
|
|
|
single: boolean; |
|
|
|
single: boolean; |
|
|
|
multiple: boolean; |
|
|
|
multiple: boolean; |
|
|
|
tableHeight: number; |
|
|
|
|
|
|
|
tableInstance: ComponentRef; |
|
|
|
tableInstance: ComponentRef; |
|
|
|
queryFormInstance: ComponentRef | any; |
|
|
|
queryFormInstance: ComponentRef | any; |
|
|
|
selectedKeys: SizeType[]; |
|
|
|
selectedKeys: SizeType[]; |
|
|
@ -191,7 +182,6 @@ |
|
|
|
key: string | undefined; |
|
|
|
key: string | undefined; |
|
|
|
isSys: string | undefined; |
|
|
|
isSys: string | undefined; |
|
|
|
}; |
|
|
|
}; |
|
|
|
dataSource: any[]; |
|
|
|
|
|
|
|
dateRange: string[]; |
|
|
|
dateRange: string[]; |
|
|
|
tableProps: Recordable; |
|
|
|
tableProps: Recordable; |
|
|
|
} |
|
|
|
} |
|
|
@ -220,18 +210,13 @@ |
|
|
|
const queryFormElRef = ref(null); |
|
|
|
const queryFormElRef = ref(null); |
|
|
|
const { createConfirm } = useMessage(); |
|
|
|
const { createConfirm } = useMessage(); |
|
|
|
const { createMessage } = useMessage(); |
|
|
|
const { createMessage } = useMessage(); |
|
|
|
|
|
|
|
|
|
|
|
const { toggle, isFullscreen } = useFullscreen(wrapRef); |
|
|
|
const { toggle, isFullscreen } = useFullscreen(wrapRef); |
|
|
|
const [registerModal, { openModal }] = useModal(); |
|
|
|
const [registerModal, { openModal }] = useModal(); |
|
|
|
const state = reactive<TableState>({ |
|
|
|
const state = reactive<TableState>({ |
|
|
|
// 遮罩层 |
|
|
|
|
|
|
|
loading: true, |
|
|
|
|
|
|
|
// 非单个禁用 |
|
|
|
// 非单个禁用 |
|
|
|
single: true, |
|
|
|
single: true, |
|
|
|
// 非多个禁用 |
|
|
|
// 非多个禁用 |
|
|
|
multiple: true, |
|
|
|
multiple: true, |
|
|
|
// 手动设置表格高度 |
|
|
|
|
|
|
|
tableHeight: 588, |
|
|
|
|
|
|
|
// a-table表格实例 |
|
|
|
// a-table表格实例 |
|
|
|
tableInstance: null, |
|
|
|
tableInstance: null, |
|
|
|
// a-form表单实例 |
|
|
|
// a-form表单实例 |
|
|
@ -244,24 +229,25 @@ |
|
|
|
key: undefined, |
|
|
|
key: undefined, |
|
|
|
isSys: undefined |
|
|
|
isSys: undefined |
|
|
|
}, |
|
|
|
}, |
|
|
|
// 数据列表 |
|
|
|
|
|
|
|
dataSource: [], |
|
|
|
|
|
|
|
// 日期范围 |
|
|
|
// 日期范围 |
|
|
|
dateRange: [], |
|
|
|
dateRange: [], |
|
|
|
// 表格api |
|
|
|
// 表格api |
|
|
|
tableProps: { |
|
|
|
tableProps: { |
|
|
|
// 表格ID |
|
|
|
// 表格ID |
|
|
|
rowKey: 'id', |
|
|
|
rowKey: 'id', |
|
|
|
|
|
|
|
// 遮罩层 |
|
|
|
|
|
|
|
loading: false, |
|
|
|
|
|
|
|
// 数据列表 |
|
|
|
|
|
|
|
dataSource: [], |
|
|
|
// 表格行配置 |
|
|
|
// 表格行配置 |
|
|
|
rowSelection: { type: 'checkbox' } |
|
|
|
rowSelection: { type: 'checkbox' }, |
|
|
|
|
|
|
|
// 是否展示外边框和列边框 |
|
|
|
|
|
|
|
bordered: true |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
// 基于vben-table扩展rowSelection,实现勾选数据自主可控 |
|
|
|
// 基于vben-table扩展rowSelection,实现勾选数据自主可控 |
|
|
|
const basicTableProps = computed(() => { |
|
|
|
const basicTableProps = computed(() => { |
|
|
|
return { |
|
|
|
return { ...basicProps, ...state.tableProps } as unknown as BasicTableProps; |
|
|
|
...basicProps, |
|
|
|
|
|
|
|
...state.tableProps |
|
|
|
|
|
|
|
} as unknown as BasicTableProps; |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
const { |
|
|
|
const { |
|
|
|
getRowSelection, |
|
|
|
getRowSelection, |
|
|
@ -271,7 +257,7 @@ |
|
|
|
getSelectRowKeys, |
|
|
|
getSelectRowKeys, |
|
|
|
deleteSelectRowByKey, |
|
|
|
deleteSelectRowByKey, |
|
|
|
setSelectedRowKeys |
|
|
|
setSelectedRowKeys |
|
|
|
} = useRowSelection(basicTableProps, ref(state.dataSource), noop); |
|
|
|
} = useRowSelection(basicTableProps, ref(state.tableProps.dataSource), noop); |
|
|
|
// 基于vben-table扩展分页 |
|
|
|
// 基于vben-table扩展分页 |
|
|
|
const { |
|
|
|
const { |
|
|
|
getPaginationInfo, |
|
|
|
getPaginationInfo, |
|
|
@ -283,7 +269,23 @@ |
|
|
|
// 使用vben-table行斑马线 |
|
|
|
// 使用vben-table行斑马线 |
|
|
|
const { getRowClassName } = useTableStyle(basicTableProps, prefixCls); |
|
|
|
const { getRowClassName } = useTableStyle(basicTableProps, prefixCls); |
|
|
|
// 使用vben-table自动计算表格高度跟在指定区域显示滚动条 |
|
|
|
// 使用vben-table自动计算表格高度跟在指定区域显示滚动条 |
|
|
|
const { getScrollRef, redoHeight } = useTableScroll(basicTableProps, tableElRef, columns as any, getRowSelectionRef, state.dataSource as any); |
|
|
|
const { getScrollRef, redoHeight } = useTableScroll(basicTableProps, tableElRef, columns as any, getRowSelectionRef, state.tableProps.dataSource as any); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 绑定table元素 |
|
|
|
|
|
|
|
const getBindValues = computed(() => { |
|
|
|
|
|
|
|
debugger |
|
|
|
|
|
|
|
const propsData: Recordable = { |
|
|
|
|
|
|
|
...state.tableProps, |
|
|
|
|
|
|
|
tableLayout: 'fixed', |
|
|
|
|
|
|
|
columns: columns, |
|
|
|
|
|
|
|
size: state.selectedKeys[0], |
|
|
|
|
|
|
|
scroll: unref(getScrollRef), |
|
|
|
|
|
|
|
rowClassName: unref(getRowClassName), |
|
|
|
|
|
|
|
rowSelection: unref(getRowSelectionRef), |
|
|
|
|
|
|
|
pagination: toRaw(unref(getPaginationInfo)), |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
return propsData; |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
/** 生命周期钩子回调处理区域 */ |
|
|
|
/** 生命周期钩子回调处理区域 */ |
|
|
|
onMounted(() => { |
|
|
|
onMounted(() => { |
|
|
@ -291,10 +293,6 @@ |
|
|
|
state.queryFormInstance = unref(queryFormElRef); |
|
|
|
state.queryFormInstance = unref(queryFormElRef); |
|
|
|
useTimeoutFn(() => getList() , 16); |
|
|
|
useTimeoutFn(() => getList() , 16); |
|
|
|
}); |
|
|
|
}); |
|
|
|
watchEffect(() => { |
|
|
|
|
|
|
|
// 当数据不存在时清理表格高度 |
|
|
|
|
|
|
|
handleTableHeightSetting(state.dataSource.length > 0 ? false : true); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
watch(getRowSelectionRef, ()=> { |
|
|
|
watch(getRowSelectionRef, ()=> { |
|
|
|
handleSelectionChange(getSelectRowKeys()); |
|
|
|
handleSelectionChange(getSelectRowKeys()); |
|
|
|
},{ |
|
|
|
},{ |
|
|
@ -302,22 +300,19 @@ |
|
|
|
deep: true |
|
|
|
deep: true |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
/** 处理表格高度设置 */ |
|
|
|
|
|
|
|
function handleTableHeightSetting(clean?: boolean) { |
|
|
|
|
|
|
|
if (!state.tableInstance?.$el) return; |
|
|
|
|
|
|
|
const bodyEl: HTMLElement | null = state.tableInstance.$el.querySelector('.ant-table-body'); |
|
|
|
|
|
|
|
bodyEl && (bodyEl.style.height = `${ clean ? 'unset' : state.tableHeight+'px' }`); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** 查询列表数据 */ |
|
|
|
/** 查询列表数据 */ |
|
|
|
function getList() { |
|
|
|
async function getList() { |
|
|
|
state.loading = true; |
|
|
|
try { |
|
|
|
|
|
|
|
state.tableProps.loading = true; |
|
|
|
const { current = 1, pageSize = 10 } = getPagination() as PaginationProps; |
|
|
|
const { current = 1, pageSize = 10 } = getPagination() as PaginationProps; |
|
|
|
listConfig(convertDateRange({ ...state.queryParams, current, size: pageSize }, state.dateRange)).then(response => { |
|
|
|
const result = await listConfig(convertDateRange({ ...state.queryParams, current, size: pageSize }, state.dateRange)); |
|
|
|
state.dataSource = response.data; |
|
|
|
if (result) { |
|
|
|
setPagination({ total: response.total }); |
|
|
|
state.tableProps.dataSource = result.data; |
|
|
|
state.loading = false; |
|
|
|
setPagination({ total: result.total }); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
} finally { |
|
|
|
|
|
|
|
state.tableProps.loading = false; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** 搜索按钮操作 */ |
|
|
|
/** 搜索按钮操作 */ |
|
|
@ -348,20 +343,23 @@ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** 新增按钮操作,行内新增与工具栏局域新增通用 */ |
|
|
|
/** 新增按钮操作,行内新增与工具栏局域新增通用 */ |
|
|
|
function handleAdd() { |
|
|
|
function handleAdd() { |
|
|
|
openModal(true,{isUpdate: false }); |
|
|
|
/*openModal(true,{isUpdate: false });*/ |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** 编辑按钮操作,行内编辑 */ |
|
|
|
/** 编辑按钮操作,行内编辑 */ |
|
|
|
function handleEdit(record?: Recordable) { |
|
|
|
function handleEdit(record?: Recordable) { |
|
|
|
record = record || { id: toRaw(state.ids) }; |
|
|
|
/*record = record || { id: toRaw(state.ids) }; |
|
|
|
openModal(true, { isUpdate: true, record }); |
|
|
|
openModal(true, { isUpdate: true, record });*/ |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** 删除按钮操作,行内删除 */ |
|
|
|
/** 删除按钮操作,行内删除 */ |
|
|
|
async function handleDel(record?: Recordable) { |
|
|
|
async function handleDel(record?: Recordable) { |
|
|
|
const ids = record?.id || toRaw(state.ids); |
|
|
|
/*const ids = record?.id || toRaw(state.ids); |
|
|
|
createConfirm({ |
|
|
|
createConfirm({ |
|
|
|
iconType: 'warning', |
|
|
|
iconType: 'warning', |
|
|
|
title: '警告', |
|
|
|
title: '警告', |
|
|
@ -371,7 +369,7 @@ |
|
|
|
createMessage.success('删除成功!'); |
|
|
|
createMessage.success('删除成功!'); |
|
|
|
handleSuccess(); |
|
|
|
handleSuccess(); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
});*/ |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
</script> |
|
|
|
</script> |
|
|
|