|
|
@ -1,6 +1,5 @@ |
|
|
|
<template> |
|
|
|
<template> |
|
|
|
<div> |
|
|
|
<div ref="wrapRef" :class="[prefixCls, [`${prefixCls}-form-container`]]"> |
|
|
|
<div :class="[prefixCls, [`${prefixCls}-form-container`]]"> |
|
|
|
|
|
|
|
<AForm ref="formElRef" |
|
|
|
<AForm ref="formElRef" |
|
|
|
layout="inline" |
|
|
|
layout="inline" |
|
|
|
:colon="false" |
|
|
|
:colon="false" |
|
|
@ -23,7 +22,25 @@ |
|
|
|
class="mr-2">重置</a-button> |
|
|
|
class="mr-2">重置</a-button> |
|
|
|
</AFormItem> |
|
|
|
</AFormItem> |
|
|
|
</AForm> |
|
|
|
</AForm> |
|
|
|
<ATable :dataSource="dataSource" :columns="columns"> |
|
|
|
<ATable ref="tableElRef" |
|
|
|
|
|
|
|
:size="state.selectedKeys[0]" |
|
|
|
|
|
|
|
:dataSource="state.dataSource" |
|
|
|
|
|
|
|
:columns="columns" |
|
|
|
|
|
|
|
:scroll="{ |
|
|
|
|
|
|
|
x: '100%', |
|
|
|
|
|
|
|
y: state.tableHeight, |
|
|
|
|
|
|
|
scrollToFirstRowOnChange: true |
|
|
|
|
|
|
|
}" |
|
|
|
|
|
|
|
:pagination="{ |
|
|
|
|
|
|
|
current: 1, |
|
|
|
|
|
|
|
pageSize: 10, |
|
|
|
|
|
|
|
size: 'small', |
|
|
|
|
|
|
|
defaultPageSize: 10, |
|
|
|
|
|
|
|
showTotal: (total) => t('component.table.total', { total }), |
|
|
|
|
|
|
|
showSizeChanger: true, |
|
|
|
|
|
|
|
showQuickJumper: true, |
|
|
|
|
|
|
|
}" |
|
|
|
|
|
|
|
> |
|
|
|
<template #title> |
|
|
|
<template #title> |
|
|
|
<div style="width: 100%"> |
|
|
|
<div style="width: 100%"> |
|
|
|
<div class="flex items-center"> |
|
|
|
<div class="flex items-center"> |
|
|
@ -31,45 +48,49 @@ |
|
|
|
<div :class="`${headerPrefixCls}__toolbar`"> |
|
|
|
<div :class="`${headerPrefixCls}__toolbar`"> |
|
|
|
<a-button type="primary">新增</a-button> |
|
|
|
<a-button type="primary">新增</a-button> |
|
|
|
<a-button type="primary">编辑</a-button> |
|
|
|
<a-button type="primary">编辑</a-button> |
|
|
|
<Divider type="vertical"/> |
|
|
|
<a-button type="primary">删除</a-button> |
|
|
|
|
|
|
|
<ADivider type="vertical"/> |
|
|
|
<div class="table-settings"> |
|
|
|
<div class="table-settings"> |
|
|
|
<!--重做--> |
|
|
|
<!--重做--> |
|
|
|
<Tooltip placement="top"> |
|
|
|
<ATooltip placement="top"> |
|
|
|
<template #title> |
|
|
|
<template #title> |
|
|
|
<span>{{ t('common.redo') }}</span> |
|
|
|
<span>{{ t('common.redo') }}</span> |
|
|
|
</template> |
|
|
|
</template> |
|
|
|
<RedoOutlined @click="() => { console.log(1) }"/> |
|
|
|
<RedoOutlined @click="handleQuery"/> |
|
|
|
</Tooltip> |
|
|
|
</ATooltip> |
|
|
|
<!--尺寸--> |
|
|
|
<!--尺寸--> |
|
|
|
<Tooltip placement="top"> |
|
|
|
<ATooltip placement="top"> |
|
|
|
<template #title> |
|
|
|
<template #title> |
|
|
|
<span>{{ t('component.table.settingDens') }}</span> |
|
|
|
<span>{{ t('component.table.settingDens') }}</span> |
|
|
|
</template> |
|
|
|
</template> |
|
|
|
<Dropdown placement="bottomCenter" :trigger="['click']" :getPopupContainer="getPopupContainer"> |
|
|
|
<ADropdown :trigger="['click']" |
|
|
|
|
|
|
|
:getPopupContainer="getPopupContainer" |
|
|
|
|
|
|
|
placement="bottomCenter" |
|
|
|
|
|
|
|
> |
|
|
|
<ColumnHeightOutlined/> |
|
|
|
<ColumnHeightOutlined/> |
|
|
|
<template #overlay> |
|
|
|
<template #overlay> |
|
|
|
<Menu @click="()=>{console.log(2)}" selectable :selectedKeys="[]"> |
|
|
|
<AMenu v-model:selectedKeys="state.selectedKeys" selectable> |
|
|
|
<MenuItem key="default"> |
|
|
|
<AMenuItem key="default"> |
|
|
|
<span>{{ t('component.table.settingDensDefault') }}</span> |
|
|
|
<span>{{ t('component.table.settingDensDefault') }}</span> |
|
|
|
</MenuItem> |
|
|
|
</AMenuItem> |
|
|
|
<MenuItem key="middle"> |
|
|
|
<AMenuItem key="middle"> |
|
|
|
<span>{{ t('component.table.settingDensMiddle') }}</span> |
|
|
|
<span>{{ t('component.table.settingDensMiddle') }}</span> |
|
|
|
</MenuItem> |
|
|
|
</AMenuItem> |
|
|
|
<MenuItem key="small"> |
|
|
|
<AMenuItem key="small"> |
|
|
|
<span>{{ t('component.table.settingDensSmall') }}</span> |
|
|
|
<span>{{ t('component.table.settingDensSmall') }}</span> |
|
|
|
</MenuItem> |
|
|
|
</AMenuItem> |
|
|
|
</Menu> |
|
|
|
</AMenu> |
|
|
|
</template> |
|
|
|
</template> |
|
|
|
</Dropdown> |
|
|
|
</ADropdown> |
|
|
|
</Tooltip> |
|
|
|
</ATooltip> |
|
|
|
<!--全屏--> |
|
|
|
<!--全屏--> |
|
|
|
<Tooltip placement="top"> |
|
|
|
<ATooltip placement="top"> |
|
|
|
<template #title> |
|
|
|
<template #title> |
|
|
|
<span>{{ t('component.table.settingFullScreen') }}</span> |
|
|
|
<span>{{ t('component.table.settingFullScreen') }}</span> |
|
|
|
</template> |
|
|
|
</template> |
|
|
|
<FullscreenOutlined @click="() => {console.log(3)}" /> |
|
|
|
<FullscreenOutlined v-if="!isFullscreen" @click="toggle"/> |
|
|
|
<!--<FullscreenExitOutlined @click="toggle" v-else />--> |
|
|
|
<FullscreenExitOutlined v-else @click="toggle"/> |
|
|
|
</Tooltip> |
|
|
|
</ATooltip> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
@ -77,110 +98,87 @@ |
|
|
|
</template> |
|
|
|
</template> |
|
|
|
</ATable> |
|
|
|
</ATable> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
|
|
|
|
</template> |
|
|
|
</template> |
|
|
|
<script lang="ts" setup> |
|
|
|
<script lang="ts" setup> |
|
|
|
/** |
|
|
|
/** |
|
|
|
* 提供模板规范代码参考,请尽量保证编写代码风格跟模板规范代码一致 |
|
|
|
* 提供模板规范代码参考,请尽量保证编写代码风格跟模板规范代码一致 |
|
|
|
* 采用ant-design-vue表格表单组件编写,采用 setup 写法 |
|
|
|
* 采用ant-design-vue表格表单组件编写,采用 setup 写法 |
|
|
|
|
|
|
|
* 当vben的BasicTable跟BasicForm组件不能满足一些特殊需求时,需要写原生ant-design-vue组件时,请严格参考此处代码 |
|
|
|
|
|
|
|
* 当前原生ant-design-vue表格表单组件模板,目前已经与系统项目配置高度集成,系统配置发生修改时组件也会产生对应的变化 |
|
|
|
|
|
|
|
* 目前是基于vben的BasicTable跟BasicForm组件重写出一套ant-design-vue原生表格表单组件模板 |
|
|
|
* Copyright © 2020-2022 <a href="http://www.entfrm.com/">entfrm</a> All rights reserved. |
|
|
|
* Copyright © 2020-2022 <a href="http://www.entfrm.com/">entfrm</a> All rights reserved. |
|
|
|
* author entfrm开发团队-王翔 |
|
|
|
* author entfrm开发团队-王翔 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
import { BasicTitle } from '/@/components/Basic'; |
|
|
|
import { BasicTitle } from '/@/components/Basic'; |
|
|
|
import { RedoOutlined, ColumnHeightOutlined, FullscreenOutlined, FullscreenExitOutlined } from '@ant-design/icons-vue'; |
|
|
|
import { RedoOutlined, ColumnHeightOutlined, FullscreenOutlined, FullscreenExitOutlined, LeftOutlined, RightOutlined } from '@ant-design/icons-vue'; |
|
|
|
import { computed, ComputedRef, ref, useSlots } from 'vue'; |
|
|
|
import { ref, onMounted } from 'vue'; |
|
|
|
import { Table, Form, Row, Col, Divider, Tooltip, Dropdown, Menu } from 'ant-design-vue'; |
|
|
|
import { Table, Form, Row, Col, Divider, Tooltip, Dropdown, Menu } from 'ant-design-vue'; |
|
|
|
const MenuItem = Menu.Item; |
|
|
|
import { SizeType } from '/@/components/Table'; |
|
|
|
import { default as TableTitle } from '/@/components/Table/src/components/TableTitle.vue'; |
|
|
|
import { listConfig, delConfig } from '/@/api/platform/system/controller/config'; |
|
|
|
import { |
|
|
|
|
|
|
|
BasicTable, |
|
|
|
|
|
|
|
useTable, |
|
|
|
|
|
|
|
TableAction, |
|
|
|
|
|
|
|
InnerHandlers, |
|
|
|
|
|
|
|
ColumnChangeParam, |
|
|
|
|
|
|
|
BasicTableProps, |
|
|
|
|
|
|
|
} from '/@/components/Table'; |
|
|
|
|
|
|
|
import { getPopupContainer } from '/@/utils'; |
|
|
|
|
|
|
|
//import { list, remove } from '/@/api/platform/system/controller/config'; |
|
|
|
|
|
|
|
import ConfigModal from './ConfigModal.vue'; |
|
|
|
import ConfigModal from './ConfigModal.vue'; |
|
|
|
import { searchFormSchema } 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'; |
|
|
|
import {useModal} from "/@/components/Modal"; |
|
|
|
import {useModal} from "/@/components/Modal"; |
|
|
|
import {useDesign} from "/@/hooks/web/useDesign"; |
|
|
|
import {useDesign} from "/@/hooks/web/useDesign"; |
|
|
|
import { t } from '/@/hooks/web/useI18n'; |
|
|
|
import { useI18n } from '/@/hooks/web/useI18n'; |
|
|
|
import { createFormContext } from "/@/components/Form/src/hooks/useFormContext"; |
|
|
|
import { createFormContext } from "/@/components/Form/src/hooks/useFormContext"; |
|
|
|
import {useTableHeader} from "/@/components/Table/src/hooks/useTableHeader"; |
|
|
|
import {useTableHeader} from "/@/components/Table/src/hooks/useTableHeader"; |
|
|
|
import {basicProps} from "/@/components/Table/src/props"; |
|
|
|
import {basicProps} from "/@/components/Table/src/props"; |
|
|
|
|
|
|
|
import { convertDateRange } from "/@/utils/dateUtil"; |
|
|
|
|
|
|
|
|
|
|
|
const { createConfirm } = useMessage(); |
|
|
|
import { useFullscreen } from "@vueuse/core"; |
|
|
|
const { createMessage } = useMessage(); |
|
|
|
import { getPopupContainer } from '/@/utils'; |
|
|
|
const { prefixCls } = useDesign('basic-table'); |
|
|
|
import {useTimeoutFn} from "/@/hooks/core/useTimeout"; |
|
|
|
const { prefixCls: headerPrefixCls } = useDesign('basic-table-header'); |
|
|
|
|
|
|
|
|
|
|
|
interface ItemRender { |
|
|
|
|
|
|
|
page: number; |
|
|
|
|
|
|
|
type: 'page' | 'prev' | 'next'; |
|
|
|
|
|
|
|
originalElement: any; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** 类型规范统一声明定义区域 */ |
|
|
|
|
|
|
|
interface TableState { |
|
|
|
|
|
|
|
ids: string[]; |
|
|
|
|
|
|
|
single: boolean; |
|
|
|
|
|
|
|
multiple: boolean; |
|
|
|
|
|
|
|
total: number; |
|
|
|
|
|
|
|
tableHeight: number; |
|
|
|
|
|
|
|
tableInstance: ComponentRef; |
|
|
|
|
|
|
|
selectedKeys: SizeType[]; |
|
|
|
|
|
|
|
queryParams: Recordable; |
|
|
|
|
|
|
|
dataSource: any[]; |
|
|
|
|
|
|
|
dateRange: string[]; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** 通用变量统一声明区域 */ |
|
|
|
const ATable = Table; |
|
|
|
const ATable = Table; |
|
|
|
const AForm = Form; |
|
|
|
const AForm = Form; |
|
|
|
|
|
|
|
const AMenu = Menu; |
|
|
|
const AFormItem = Form.Item; |
|
|
|
const AFormItem = Form.Item; |
|
|
|
const ACol = Col; |
|
|
|
const AMenuItem = Menu.Item; |
|
|
|
|
|
|
|
const ADivider = Divider; |
|
|
|
|
|
|
|
const ATooltip = Tooltip; |
|
|
|
|
|
|
|
const ADropdown = Dropdown; |
|
|
|
const ARow = Row; |
|
|
|
const ARow = Row; |
|
|
|
|
|
|
|
const ACol = Col; |
|
|
|
|
|
|
|
|
|
|
|
const handlers: InnerHandlers = { |
|
|
|
const { t } = useI18n(); |
|
|
|
onColumnsChange: (data: ColumnChangeParam[]) => { |
|
|
|
const wrapRef = ref(null); |
|
|
|
console.log(1111); |
|
|
|
const tableElRef = ref<ComponentRef>(null); |
|
|
|
}, |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const dataSource = [ |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
key: '1', |
|
|
|
|
|
|
|
name: '胡彦斌', |
|
|
|
|
|
|
|
age: 32, |
|
|
|
|
|
|
|
address: '西湖区湖底公园1号', |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
key: '2', |
|
|
|
|
|
|
|
name: '胡彦祖', |
|
|
|
|
|
|
|
age: 42, |
|
|
|
|
|
|
|
address: '西湖区湖底公园1号', |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const columns = [ |
|
|
|
const { createConfirm } = useMessage(); |
|
|
|
{ |
|
|
|
const { createMessage } = useMessage(); |
|
|
|
title: '姓名', |
|
|
|
|
|
|
|
dataIndex: 'name', |
|
|
|
|
|
|
|
key: 'name', |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
title: '年龄', |
|
|
|
|
|
|
|
dataIndex: 'age', |
|
|
|
|
|
|
|
key: 'age', |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
title: '住址', |
|
|
|
|
|
|
|
dataIndex: 'address', |
|
|
|
|
|
|
|
key: 'address', |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const state = reactive({ |
|
|
|
const { prefixCls } = useDesign('basic-table'); |
|
|
|
// 选中数组 |
|
|
|
const { prefixCls: headerPrefixCls } = useDesign('basic-table-header'); |
|
|
|
ids: [], |
|
|
|
|
|
|
|
// 非单个禁用 |
|
|
|
|
|
|
|
single: true, |
|
|
|
|
|
|
|
// 非多个禁用 |
|
|
|
|
|
|
|
multiple: true |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const { toggle, isFullscreen } = useFullscreen(wrapRef); |
|
|
|
const [registerModal, { openModal }] = useModal(); |
|
|
|
const [registerModal, { openModal }] = useModal(); |
|
|
|
const [registerTable, { reload }] = useTable({ |
|
|
|
/*const [registerTable, { reload }] = useTable({ |
|
|
|
title: '角色列表', |
|
|
|
title: '角色列表', |
|
|
|
//api: list, |
|
|
|
//api: list, |
|
|
|
columns, |
|
|
|
columns, |
|
|
|
formConfig: { |
|
|
|
|
|
|
|
labelWidth: 120, |
|
|
|
|
|
|
|
schemas: searchFormSchema |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
useSearchForm: true, |
|
|
|
useSearchForm: true, |
|
|
|
showTableSetting: true, |
|
|
|
showTableSetting: true, |
|
|
|
bordered: true, |
|
|
|
bordered: true, |
|
|
@ -194,8 +192,59 @@ |
|
|
|
slots: { customRender: 'action' }, |
|
|
|
slots: { customRender: 'action' }, |
|
|
|
fixed: false |
|
|
|
fixed: false |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
});*/ |
|
|
|
|
|
|
|
const state = reactive<TableState>({ |
|
|
|
|
|
|
|
// 选中数组 |
|
|
|
|
|
|
|
ids: [], |
|
|
|
|
|
|
|
// 非单个禁用 |
|
|
|
|
|
|
|
single: true, |
|
|
|
|
|
|
|
// 非多个禁用 |
|
|
|
|
|
|
|
multiple: true, |
|
|
|
|
|
|
|
// 总条数 |
|
|
|
|
|
|
|
total: 0, |
|
|
|
|
|
|
|
// 手动设置表格高度 |
|
|
|
|
|
|
|
tableHeight: 650, |
|
|
|
|
|
|
|
// a-table表格实例 |
|
|
|
|
|
|
|
tableInstance: null, |
|
|
|
|
|
|
|
// 尺寸大小选择 |
|
|
|
|
|
|
|
selectedKeys: [ 'middle' ], |
|
|
|
|
|
|
|
// 查询参数 |
|
|
|
|
|
|
|
queryParams: { |
|
|
|
|
|
|
|
current: 1, |
|
|
|
|
|
|
|
size: 10 |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
// 数据列表 |
|
|
|
|
|
|
|
dataSource: [], |
|
|
|
|
|
|
|
// 日期范围 |
|
|
|
|
|
|
|
dateRange: [] |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** 生命周期钩子回调处理区域 */ |
|
|
|
|
|
|
|
onMounted(() => { |
|
|
|
|
|
|
|
state.tableInstance = unref(tableElRef); |
|
|
|
|
|
|
|
if (! state.tableInstance?.$el) return; |
|
|
|
|
|
|
|
// 设置表格高度,BasicTable内部采用ref元素动态计算,降低复杂度,由手动设置 |
|
|
|
|
|
|
|
const bodyEl: HTMLElement | null = state.tableInstance.$el.querySelector('.ant-table-body'); |
|
|
|
|
|
|
|
bodyEl && (bodyEl.style.height = `${state.tableHeight}px`); |
|
|
|
|
|
|
|
useTimeoutFn(() => getList() , 16); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** 搜索按钮操作 */ |
|
|
|
|
|
|
|
function handleQuery() { |
|
|
|
|
|
|
|
state.queryParams.current = 1; |
|
|
|
|
|
|
|
getList(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** 查询列表数据 */ |
|
|
|
|
|
|
|
function getList() { |
|
|
|
|
|
|
|
listConfig(convertDateRange(state.queryParams, state.dateRange)).then(response => { |
|
|
|
|
|
|
|
state.dataSource = response.data; |
|
|
|
|
|
|
|
state.total = response.total; |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** 处理多选框选中数据 */ |
|
|
|
/** 处理多选框选中数据 */ |
|
|
|
function handleSelectionChange(selection?: Recordable) { |
|
|
|
function handleSelectionChange(selection?: Recordable) { |
|
|
|
const rawRows = toRaw(selection?.rows) || []; |
|
|
|
const rawRows = toRaw(selection?.rows) || []; |
|
|
|