ljlong_2630
7 months ago
14 changed files with 1492 additions and 7 deletions
@ -0,0 +1,60 @@ |
|||||
|
import request from '@/config/axios' |
||||
|
|
||||
|
export interface MessageSetVO { |
||||
|
id: number |
||||
|
tableName: string |
||||
|
action: number |
||||
|
available: string |
||||
|
remark: string |
||||
|
deletionTime: Date |
||||
|
deleterId: string |
||||
|
extraProperties: string |
||||
|
concurrencyStamp: number |
||||
|
siteId: string |
||||
|
} |
||||
|
|
||||
|
// 查询消息设置列表
|
||||
|
export const getMessageSetPage = async (params) => { |
||||
|
if (params.isSearch) { |
||||
|
delete params.isSearch |
||||
|
const data = {...params} |
||||
|
return await request.post({ url: '/system/message-set/senior', data }) |
||||
|
} else { |
||||
|
return await request.get({ url: `/system/message-set/page`, params }) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// 查询消息设置详情
|
||||
|
export const getMessageSet = async (id: number) => { |
||||
|
return await request.get({ url: `/system/message-set/get?id=` + id }) |
||||
|
} |
||||
|
|
||||
|
// 新增消息设置
|
||||
|
export const createMessageSet = async (data: MessageSetVO) => { |
||||
|
return await request.post({ url: `/system/message-set/create`, data }) |
||||
|
} |
||||
|
|
||||
|
// 修改消息设置
|
||||
|
export const updateMessageSet = async (data: MessageSetVO) => { |
||||
|
return await request.put({ url: `/system/message-set/update`, data }) |
||||
|
} |
||||
|
|
||||
|
// 删除消息设置
|
||||
|
export const deleteMessageSet = async (id: number) => { |
||||
|
return await request.delete({ url: `/system/message-set/delete?id=` + id }) |
||||
|
} |
||||
|
|
||||
|
// 导出消息设置 Excel
|
||||
|
export const exportMessageSet = async (params) => { |
||||
|
return await request.download({ url: `/system/message-set/export-excel`, params }) |
||||
|
} |
||||
|
|
||||
|
// 下载用户导入模板
|
||||
|
export const importTemplate = () => { |
||||
|
return request.download({ url: '/system/message-set/get-import-template' }) |
||||
|
} |
||||
|
|
||||
|
// 查询消息设置列表不分页
|
||||
|
export const getMessageSetNoPage = async (params) => { |
||||
|
return await request.get({ url: `/system/message-set/noPage`, params }) |
||||
|
} |
@ -0,0 +1,64 @@ |
|||||
|
import request from '@/config/axios' |
||||
|
|
||||
|
export interface TableActionRelVO { |
||||
|
id: number |
||||
|
tableName: string |
||||
|
action: number |
||||
|
type: number |
||||
|
name: string |
||||
|
available: string |
||||
|
activeTime: Date |
||||
|
expireTime: Date |
||||
|
remark: string |
||||
|
deletionTime: Date |
||||
|
deleterId: string |
||||
|
extraProperties: string |
||||
|
concurrencyStamp: number |
||||
|
siteId: string |
||||
|
} |
||||
|
|
||||
|
// 查询表名动作关系列表
|
||||
|
export const getTableActionRelPage = async (params) => { |
||||
|
if (params.isSearch) { |
||||
|
delete params.isSearch |
||||
|
const data = {...params} |
||||
|
return await request.post({ url: '/system/table-action-rel/senior', data }) |
||||
|
} else { |
||||
|
return await request.get({ url: `/system/table-action-rel/page`, params }) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// 查询表名动作关系详情
|
||||
|
export const getTableActionRel = async (id: number) => { |
||||
|
return await request.get({ url: `/system/table-action-rel/get?id=` + id }) |
||||
|
} |
||||
|
|
||||
|
// 新增表名动作关系
|
||||
|
export const createTableActionRel = async (data: TableActionRelVO) => { |
||||
|
return await request.post({ url: `/system/table-action-rel/create`, data }) |
||||
|
} |
||||
|
|
||||
|
// 修改表名动作关系
|
||||
|
export const updateTableActionRel = async (data: TableActionRelVO) => { |
||||
|
return await request.put({ url: `/system/table-action-rel/update`, data }) |
||||
|
} |
||||
|
|
||||
|
// 删除表名动作关系
|
||||
|
export const deleteTableActionRel = async (id: number) => { |
||||
|
return await request.delete({ url: `/system/table-action-rel/delete?id=` + id }) |
||||
|
} |
||||
|
|
||||
|
// 导出表名动作关系 Excel
|
||||
|
export const exportTableActionRel = async (params) => { |
||||
|
return await request.download({ url: `/system/table-action-rel/export-excel`, params }) |
||||
|
} |
||||
|
|
||||
|
// 下载用户导入模板
|
||||
|
export const importTemplate = () => { |
||||
|
return request.download({ url: '/system/table-action-rel/get-import-template' }) |
||||
|
} |
||||
|
|
||||
|
// 查询表名动作关系列表
|
||||
|
export const getTableActionRelNoPage = async (params) => { |
||||
|
return await request.get({ url: `/system/table-action-rel/noPage`, params }) |
||||
|
} |
@ -0,0 +1,276 @@ |
|||||
|
<template> |
||||
|
<ContentWrap> |
||||
|
<!-- 搜索工作栏 --> |
||||
|
<Search :schema="MessageSet.allSchemas.searchSchema" @search="setSearchParams" @reset="setSearchParams" /> |
||||
|
</ContentWrap> |
||||
|
|
||||
|
<!-- 列表头部 --> |
||||
|
<TableHead |
||||
|
:HeadButttondata="HeadButttondata" |
||||
|
@button-base-click="buttonBaseClick" |
||||
|
:routeName="routeName" |
||||
|
@updataTableColumns="updataTableColumns" |
||||
|
@searchFormClick="searchFormClick" |
||||
|
:allSchemas="MessageSet.allSchemas" |
||||
|
/> |
||||
|
|
||||
|
<!-- 列表 --> |
||||
|
<ContentWrap> |
||||
|
<Table |
||||
|
:columns="tableColumns" |
||||
|
:data="tableObject.tableList" |
||||
|
:loading="tableObject.loading" |
||||
|
:pagination="{ |
||||
|
total: tableObject.total |
||||
|
}" |
||||
|
v-model:pageSize="tableObject.pageSize" |
||||
|
v-model:currentPage="tableObject.currentPage" |
||||
|
v-model:sort="tableObject.sort" |
||||
|
> |
||||
|
<template #code="{row}"> |
||||
|
<el-button type="primary" link @click="openDetail(row, '代码', row.code)"> |
||||
|
<span>{{ row.code }}</span> |
||||
|
</el-button> |
||||
|
</template> |
||||
|
<template #action="{ row }"> |
||||
|
<ButtonBase :Butttondata="butttondata" @button-base-click="buttonTableClick($event,row)" /> |
||||
|
</template> |
||||
|
</Table> |
||||
|
</ContentWrap> |
||||
|
|
||||
|
<!-- 表单弹窗:添加/修改 --> |
||||
|
<BasicForm |
||||
|
ref="basicFormRef" |
||||
|
@success="formsSuccess" |
||||
|
:rules="MessageSetRules" |
||||
|
:formAllSchemas="MessageSet.allSchemas" |
||||
|
:apiUpdate="MessageSetApi.updateMessageSet" |
||||
|
:apiCreate="MessageSetApi.createMessageSet" |
||||
|
@searchTableSuccess="searchTableSuccess" |
||||
|
:isBusiness="false" |
||||
|
@onChange="onChange" |
||||
|
/> |
||||
|
|
||||
|
<!-- 详情 --> |
||||
|
<Detail ref="detailRef" :isBasic="true" :allSchemas="MessageSet.allSchemas" /> |
||||
|
|
||||
|
<!-- 导入 --> |
||||
|
<ImportForm ref="importFormRef" url="/system/message-set/import" :importTemplateData="importTemplateData" @success="importSuccess" /> |
||||
|
</template> |
||||
|
|
||||
|
<script setup lang="ts"> |
||||
|
import download from '@/utils/download' |
||||
|
import { MessageSet,MessageSetRules } from './messageSet.data' |
||||
|
import * as MessageSetApi from '@/api/system/messageSet' |
||||
|
import * as defaultButtons from '@/utils/disposition/defaultButtons' |
||||
|
import TableHead from '@/components/TableHead/src/TableHead.vue' |
||||
|
import ImportForm from '@/components/ImportForm/src/ImportForm.vue' |
||||
|
import Detail from '@/components/Detail/src/Detail.vue' |
||||
|
import * as TableActionRelApi from '@/api/system/tableActionRel' |
||||
|
|
||||
|
defineOptions({ name: 'MessageSet' }) |
||||
|
|
||||
|
const message = useMessage() // 消息弹窗 |
||||
|
const { t } = useI18n() // 国际化 |
||||
|
|
||||
|
const route = useRoute() // 路由信息 |
||||
|
const routeName = ref() |
||||
|
routeName.value = route.name |
||||
|
const tableColumns = ref(MessageSet.allSchemas.tableColumns) |
||||
|
|
||||
|
// 查询页面返回 |
||||
|
const searchTableSuccess = (formField, searchField, val, formRef) => { |
||||
|
nextTick(() => { |
||||
|
const setV = {} |
||||
|
setV[formField] = val[0][searchField] |
||||
|
formRef.setValues(setV) |
||||
|
}) |
||||
|
} |
||||
|
|
||||
|
// 字段设置 更新主列表字段 |
||||
|
const updataTableColumns = (val) => { |
||||
|
tableColumns.value = val |
||||
|
} |
||||
|
|
||||
|
const { tableObject, tableMethods } = useTable({ |
||||
|
getListApi: MessageSetApi.getMessageSetPage // 分页接口 |
||||
|
}) |
||||
|
|
||||
|
// 获得表格的各种操作 |
||||
|
const { getList, setSearchParams } = tableMethods |
||||
|
|
||||
|
// 列表头部按钮 |
||||
|
const HeadButttondata = [ |
||||
|
defaultButtons.defaultAddBtn({hasPermi:'system:message-set:create'}), // 新增 |
||||
|
defaultButtons.defaultImportBtn({hasPermi:'system:message-set:import'}), // 导入 |
||||
|
defaultButtons.defaultExportBtn({hasPermi:'system:message-set:export'}), // 导出 |
||||
|
defaultButtons.defaultFreshBtn(null), // 刷新 |
||||
|
defaultButtons.defaultFilterBtn(null), // 筛选 |
||||
|
defaultButtons.defaultSetBtn(null), // 设置 |
||||
|
// { |
||||
|
// label: '自定义扩展按钮', |
||||
|
// name: 'zdy', |
||||
|
// hide: false, |
||||
|
// type: 'primary', |
||||
|
// icon: 'Select', |
||||
|
// color: '' |
||||
|
// }, |
||||
|
] |
||||
|
|
||||
|
// 头部按钮事件 |
||||
|
const buttonBaseClick = (val, item) => { |
||||
|
if (val == 'add') { // 新增 |
||||
|
openForm('create') |
||||
|
} else if (val == 'import') { // 导入 |
||||
|
handleImport() |
||||
|
} else if (val == 'export') { // 导出 |
||||
|
handleExport() |
||||
|
} else if (val == 'refresh') { // 刷新 |
||||
|
getList() |
||||
|
} else if (val == 'filtrate') { // 筛选 |
||||
|
} else { // 其他按钮 |
||||
|
console.log('其他按钮', item) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// 列表-操作按钮 |
||||
|
const butttondata = [ |
||||
|
defaultButtons.mainListEditBtn({hasPermi:'system:message-set:update'}), // 编辑 |
||||
|
defaultButtons.mainListDeleteBtn({hasPermi:'system:message-set:delete'}), // 删除 |
||||
|
] |
||||
|
|
||||
|
// 列表-操作按钮事件 |
||||
|
const buttonTableClick = async (val, row) => { |
||||
|
if (val == 'edit') { // 编辑 |
||||
|
openForm('update', row) |
||||
|
} else if (val == 'delete') { // 删除 |
||||
|
handleDelete(row.id) |
||||
|
} |
||||
|
} |
||||
|
const tableActionRef = ref() |
||||
|
const alreadySelectedActionList = ref() |
||||
|
/** 添加/修改操作 */ |
||||
|
const basicFormRef = ref() |
||||
|
const openForm = (type: string, row?: any) => { |
||||
|
TableActionRelApi.getTableActionRelNoPage({}).then(res=>{ |
||||
|
tableActionRef.value = res |
||||
|
}); |
||||
|
MessageSetApi.getMessageSetNoPage({}).then(res=>{ |
||||
|
alreadySelectedActionList.value = res |
||||
|
}); |
||||
|
basicFormRef.value.open(type, row) |
||||
|
} |
||||
|
|
||||
|
// form表单提交 |
||||
|
const formsSuccess = async (formType,data) => { |
||||
|
var isHave =MessageSet.allSchemas.formSchema.some(function (item) { |
||||
|
return item.field === 'activeTime' || item.field === 'expireTime'; |
||||
|
}); |
||||
|
if(isHave){ |
||||
|
if(data.activeTime && data.expireTime && data.activeTime >=data.expireTime){ |
||||
|
message.error('失效时间要大于生效时间') |
||||
|
return; |
||||
|
} |
||||
|
} |
||||
|
if(data.activeTime==0)data.activeTime = null; |
||||
|
if(data.expireTime==0)data.expireTime = null; |
||||
|
if (formType === 'create') { |
||||
|
await MessageSetApi.createMessageSet(data) |
||||
|
message.success(t('common.createSuccess')) |
||||
|
} else { |
||||
|
await MessageSetApi.updateMessageSet(data) |
||||
|
message.success(t('common.updateSuccess')) |
||||
|
} |
||||
|
basicFormRef.value.dialogVisible = false |
||||
|
getList() |
||||
|
} |
||||
|
|
||||
|
/** 详情操作 */ |
||||
|
const detailRef = ref() |
||||
|
const openDetail = (row: any, titleName: any, titleValue: any) => { |
||||
|
detailRef.value.openDetail(row, titleName, titleValue, 'basicMessageSet') |
||||
|
} |
||||
|
|
||||
|
/** 删除按钮操作 */ |
||||
|
const handleDelete = async (id: number) => { |
||||
|
try { |
||||
|
// 删除的二次确认 |
||||
|
await message.delConfirm() |
||||
|
// 发起删除 |
||||
|
await MessageSetApi.deleteMessageSet(id) |
||||
|
message.success(t('common.delSuccess')) |
||||
|
// 刷新列表 |
||||
|
await getList() |
||||
|
} catch {} |
||||
|
} |
||||
|
|
||||
|
/** 导出按钮操作 */ |
||||
|
const exportLoading = ref(false) // 导出的加载中 |
||||
|
const handleExport = async () => { |
||||
|
try { |
||||
|
// 导出的二次确认 |
||||
|
await message.exportConfirm() |
||||
|
// 发起导出 |
||||
|
exportLoading.value = true |
||||
|
const data = await MessageSetApi.exportMessageSet(tableObject.params) |
||||
|
download.excel(data, '消息设置.xlsx') |
||||
|
} catch { |
||||
|
} finally { |
||||
|
exportLoading.value = false |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/** 导入 */ |
||||
|
const importFormRef = ref() |
||||
|
const handleImport = () => { |
||||
|
importFormRef.value.open() |
||||
|
} |
||||
|
// 导入附件弹窗所需的参数 |
||||
|
const importTemplateData = reactive({ |
||||
|
templateUrl: '', |
||||
|
templateTitle: '消息设置导入模版.xlsx' |
||||
|
}) |
||||
|
// 导入成功之后 |
||||
|
const importSuccess = () => { |
||||
|
getList() |
||||
|
} |
||||
|
|
||||
|
// 筛选提交 |
||||
|
const searchFormClick = (searchData) => { |
||||
|
tableObject.params = { |
||||
|
isSearch: true, |
||||
|
filters: searchData.filters |
||||
|
} |
||||
|
getList() // 刷新当前列表 |
||||
|
} |
||||
|
|
||||
|
const onChange = (field, cur) => { |
||||
|
if (field == 'tableName') { |
||||
|
// 首先,根据cur筛选出actionList |
||||
|
let actionList = tableActionRef.value.filter(element => element.tableName === cur); |
||||
|
|
||||
|
// 接着,从actionList中筛除掉已经存在于alreadySelectedActionList中的项 |
||||
|
actionList = actionList.filter(element => |
||||
|
!alreadySelectedActionList.value.some(elementA => |
||||
|
element.tableName == elementA.tableName && element.act == elementA.act |
||||
|
) |
||||
|
); |
||||
|
|
||||
|
// 更新MessageSet.allSchemas.formSchema中对应元素的componentProps.options |
||||
|
const formItem = MessageSet.allSchemas.formSchema.find(element => element.field == 'act'); |
||||
|
if (formItem && formItem.componentProps) { |
||||
|
formItem.componentProps.options = actionList; |
||||
|
formItem.componentProps.optionsAlias = { valueField: 'act', labelField: 'name' }; |
||||
|
} |
||||
|
} |
||||
|
}; |
||||
|
|
||||
|
|
||||
|
|
||||
|
/** 初始化 **/ |
||||
|
onMounted(async () => { |
||||
|
getList() |
||||
|
importTemplateData.templateUrl = await MessageSetApi.importTemplate() |
||||
|
}) |
||||
|
|
||||
|
</script> |
@ -0,0 +1,156 @@ |
|||||
|
import type { CrudSchema } from '@/hooks/web/useCrudSchemas' |
||||
|
import { dateFormatter } from '@/utils/formatTime' |
||||
|
import * as TableActionRelApi from '@/api/system/tableActionRel' |
||||
|
import { getStrDictOptions } from '@/utils/dict' |
||||
|
|
||||
|
|
||||
|
// 假设这是TableActionRelApi.getTableActionRelNoPage({})的返回类型
|
||||
|
interface Table { |
||||
|
tableName: string; |
||||
|
tableLabel: string; |
||||
|
// 可以添加其他字段
|
||||
|
} |
||||
|
|
||||
|
// 假设的异步调用,这里假定返回类型为Table[]
|
||||
|
const tableList: Table[] = await TableActionRelApi.getTableActionRelNoPage({}); |
||||
|
const noticeTableList = getStrDictOptions(DICT_TYPE.MESSAGE_NOTICE_TABLE); |
||||
|
const noticeActionList = getStrDictOptions(DICT_TYPE.NOTICE_ACTION_TYPE); |
||||
|
// 使用Set记录已经出现过的tableName
|
||||
|
const seen = new Set<string>(); |
||||
|
|
||||
|
// 使用filter方法去重
|
||||
|
const uniqueTableList: Table[] = tableList.filter(table => { |
||||
|
if (seen.has(table.tableName)) { |
||||
|
// 如果seen中已经有了tableName,表示这个tableName已经处理过,应该被过滤掉
|
||||
|
return false; |
||||
|
} else { |
||||
|
// 如果seen中没有tableName,将其添加到seen中,并保留在结果数组中
|
||||
|
seen.add(table.tableName); |
||||
|
return true; |
||||
|
} |
||||
|
}); |
||||
|
|
||||
|
// 此时,uniqueTableList应该是去重后的结果
|
||||
|
uniqueTableList.forEach(table => { |
||||
|
// 在noticeActionList中查找与当前table.tableName匹配的value
|
||||
|
const matchingAction = noticeTableList.find(action => action.value === table.tableName); |
||||
|
// 如果找到了匹配项,就将其label值赋给table的tableLabel字段
|
||||
|
if (matchingAction) { |
||||
|
table.tableLabel = matchingAction.label; |
||||
|
} else { |
||||
|
// 如果没有找到匹配项,可以根据需要决定是否给tableLabel赋一个默认值
|
||||
|
table.tableLabel = ''; // 或者可以选择不赋值
|
||||
|
} |
||||
|
}); |
||||
|
|
||||
|
|
||||
|
const actionList = ref(tableList) |
||||
|
|
||||
|
// 表单校验
|
||||
|
export const MessageSetRules = reactive({ |
||||
|
tableName: [required], |
||||
|
act: [required], |
||||
|
available: [required], |
||||
|
}) |
||||
|
|
||||
|
export const MessageSet = useCrudSchemas(reactive<CrudSchema[]>([ |
||||
|
// {
|
||||
|
// label: 'id',
|
||||
|
// field: 'id',
|
||||
|
// sort: 'custom',
|
||||
|
// isForm: false,
|
||||
|
// isSearch: false,
|
||||
|
// isDetail: false,
|
||||
|
// isTable: false,
|
||||
|
// isTableForm: false,
|
||||
|
// fixed: 'left'
|
||||
|
// },
|
||||
|
{ |
||||
|
label: '表名', |
||||
|
field: 'tableName', |
||||
|
sort: 'custom', |
||||
|
isSearch: true, |
||||
|
formatter: (_: Recordable, __: TableColumn, cellValue: number) => { |
||||
|
return uniqueTableList.find(item=>cellValue==item.tableName).tableLabel |
||||
|
}, |
||||
|
form: { |
||||
|
component: 'Select', |
||||
|
componentProps: { |
||||
|
options: uniqueTableList, |
||||
|
optionsAlias:{ |
||||
|
labelField: 'tableLabel', |
||||
|
valueField: 'tableName' |
||||
|
} |
||||
|
} |
||||
|
}, |
||||
|
search: { |
||||
|
component: 'Select', |
||||
|
componentProps: { |
||||
|
options: uniqueTableList, |
||||
|
optionsAlias:{ |
||||
|
labelField: 'tableLabel', |
||||
|
valueField: 'tableName' |
||||
|
}, |
||||
|
onChange: (val) => {{ |
||||
|
actionList.value = tableList.filter(item=>item.tableName==val) |
||||
|
}} |
||||
|
}, |
||||
|
|
||||
|
} |
||||
|
}, |
||||
|
{ |
||||
|
label: '动作', |
||||
|
field: 'act', |
||||
|
sort: 'custom', |
||||
|
isSearch: true, |
||||
|
formatter: (_: Recordable, __: TableColumn, cellValue: number) => { |
||||
|
return noticeActionList.find(item=>cellValue==item.value).label |
||||
|
}, |
||||
|
form: { |
||||
|
component: 'Select', |
||||
|
componentProps: { |
||||
|
options: noticeActionList, |
||||
|
optionsAlias: { |
||||
|
valueField: 'value', |
||||
|
labelField: 'label' |
||||
|
} |
||||
|
} |
||||
|
}, |
||||
|
search: { |
||||
|
component: 'Select', |
||||
|
componentProps: { |
||||
|
options: actionList.value, |
||||
|
optionsAlias: { |
||||
|
valueField: 'act', |
||||
|
labelField: 'name' |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
}, |
||||
|
{ |
||||
|
label: '是否可用', |
||||
|
field: 'available', |
||||
|
sort: 'custom', |
||||
|
isSearch: true, |
||||
|
dictType: DICT_TYPE.FALSE_OR_TRUE, |
||||
|
dictClass: 'string', // 默认都是字符串类型其他暂不考虑
|
||||
|
form: { |
||||
|
component: 'SelectV2', |
||||
|
} |
||||
|
}, |
||||
|
{ |
||||
|
label: '备注', |
||||
|
field: 'remark', |
||||
|
sort: 'custom', |
||||
|
isSearch: true |
||||
|
}, |
||||
|
{ |
||||
|
label: '操作', |
||||
|
field: 'action', |
||||
|
isForm: false, |
||||
|
table: { |
||||
|
width: 150, |
||||
|
fixed: 'right' |
||||
|
} |
||||
|
} |
||||
|
])) |
@ -0,0 +1,275 @@ |
|||||
|
<template> |
||||
|
<ContentWrap> |
||||
|
<!-- 搜索工作栏 --> |
||||
|
<Search :schema="TableActionRel.allSchemas.searchSchema" @search="setSearchParams" @reset="setSearchParams" /> |
||||
|
</ContentWrap> |
||||
|
|
||||
|
<!-- 列表头部 --> |
||||
|
<TableHead |
||||
|
:HeadButttondata="HeadButttondata" |
||||
|
@button-base-click="buttonBaseClick" |
||||
|
:routeName="routeName" |
||||
|
@updataTableColumns="updataTableColumns" |
||||
|
@searchFormClick="searchFormClick" |
||||
|
:allSchemas="TableActionRel.allSchemas" |
||||
|
/> |
||||
|
|
||||
|
<!-- 列表 --> |
||||
|
<ContentWrap> |
||||
|
<Table |
||||
|
:columns="tableColumns" |
||||
|
:data="tableObject.tableList" |
||||
|
:loading="tableObject.loading" |
||||
|
:pagination="{ |
||||
|
total: tableObject.total |
||||
|
}" |
||||
|
v-model:pageSize="tableObject.pageSize" |
||||
|
v-model:currentPage="tableObject.currentPage" |
||||
|
v-model:sort="tableObject.sort" |
||||
|
> |
||||
|
<template #code="{row}"> |
||||
|
<el-button type="primary" link @click="openDetail(row, '代码', row.code)"> |
||||
|
<span>{{ row.code }}</span> |
||||
|
</el-button> |
||||
|
</template> |
||||
|
<template #action="{ row }"> |
||||
|
<ButtonBase :Butttondata="butttondata" @button-base-click="buttonTableClick($event,row)" /> |
||||
|
</template> |
||||
|
</Table> |
||||
|
</ContentWrap> |
||||
|
|
||||
|
<!-- 表单弹窗:添加/修改 --> |
||||
|
<BasicForm |
||||
|
ref="basicFormRef" |
||||
|
@success="formsSuccess" |
||||
|
:rules="TableActionRelRules" |
||||
|
:formAllSchemas="TableActionRel.allSchemas" |
||||
|
:apiUpdate="TableActionRelApi.updateTableActionRel" |
||||
|
:apiCreate="TableActionRelApi.createTableActionRel" |
||||
|
@searchTableSuccess="searchTableSuccess" |
||||
|
:isBusiness="false" |
||||
|
@onChange="onChange" |
||||
|
/> |
||||
|
|
||||
|
<!-- 详情 --> |
||||
|
<Detail ref="detailRef" :isBasic="true" :allSchemas="TableActionRel.allSchemas" /> |
||||
|
|
||||
|
<!-- 导入 --> |
||||
|
<ImportForm ref="importFormRef" url="/system/table-action-rel/import" :importTemplateData="importTemplateData" @success="importSuccess" /> |
||||
|
</template> |
||||
|
|
||||
|
<script setup lang="ts"> |
||||
|
import download from '@/utils/download' |
||||
|
import { TableActionRel,TableActionRelRules } from './tableActionRel.data' |
||||
|
import * as TableActionRelApi from '@/api/system/tableActionRel' |
||||
|
import * as defaultButtons from '@/utils/disposition/defaultButtons' |
||||
|
import TableHead from '@/components/TableHead/src/TableHead.vue' |
||||
|
import ImportForm from '@/components/ImportForm/src/ImportForm.vue' |
||||
|
import Detail from '@/components/Detail/src/Detail.vue' |
||||
|
import { getStrDictOptions } from '@/utils/dict' |
||||
|
defineOptions({ name: 'TableActionRel' }) |
||||
|
|
||||
|
const message = useMessage() // 消息弹窗 |
||||
|
const { t } = useI18n() // 国际化 |
||||
|
|
||||
|
const route = useRoute() // 路由信息 |
||||
|
const routeName = ref() |
||||
|
routeName.value = route.name |
||||
|
const tableColumns = ref(TableActionRel.allSchemas.tableColumns) |
||||
|
|
||||
|
const noticeActionList = getStrDictOptions(DICT_TYPE.NOTICE_ACTION_TYPE) |
||||
|
const noticeActionListA = getStrDictOptions(DICT_TYPE.NOTICE_ACTION_TYPE) |
||||
|
// 查询页面返回 |
||||
|
const searchTableSuccess = (formField, searchField, val, formRef) => { |
||||
|
nextTick(() => { |
||||
|
const setV = {} |
||||
|
setV[formField] = val[0][searchField] |
||||
|
formRef.setValues(setV) |
||||
|
}) |
||||
|
} |
||||
|
|
||||
|
// 字段设置 更新主列表字段 |
||||
|
const updataTableColumns = (val) => { |
||||
|
tableColumns.value = val |
||||
|
} |
||||
|
|
||||
|
const { tableObject, tableMethods } = useTable({ |
||||
|
getListApi: TableActionRelApi.getTableActionRelPage // 分页接口 |
||||
|
}) |
||||
|
|
||||
|
// 获得表格的各种操作 |
||||
|
const { getList, setSearchParams } = tableMethods |
||||
|
|
||||
|
// 列表头部按钮 |
||||
|
const HeadButttondata = [ |
||||
|
defaultButtons.defaultAddBtn({hasPermi:'system:table-action-rel:create'}), // 新增 |
||||
|
defaultButtons.defaultImportBtn({hasPermi:'system:table-action-rel:import'}), // 导入 |
||||
|
defaultButtons.defaultExportBtn({hasPermi:'system:table-action-rel:export'}), // 导出 |
||||
|
defaultButtons.defaultFreshBtn(null), // 刷新 |
||||
|
defaultButtons.defaultFilterBtn(null), // 筛选 |
||||
|
defaultButtons.defaultSetBtn(null), // 设置 |
||||
|
// { |
||||
|
// label: '自定义扩展按钮', |
||||
|
// name: 'zdy', |
||||
|
// hide: false, |
||||
|
// type: 'primary', |
||||
|
// icon: 'Select', |
||||
|
// color: '' |
||||
|
// }, |
||||
|
] |
||||
|
|
||||
|
// 头部按钮事件 |
||||
|
const buttonBaseClick = (val, item) => { |
||||
|
if (val == 'add') { // 新增 |
||||
|
openForm('create') |
||||
|
} else if (val == 'import') { // 导入 |
||||
|
handleImport() |
||||
|
} else if (val == 'export') { // 导出 |
||||
|
handleExport() |
||||
|
} else if (val == 'refresh') { // 刷新 |
||||
|
getList() |
||||
|
} else if (val == 'filtrate') { // 筛选 |
||||
|
} else { // 其他按钮 |
||||
|
console.log('其他按钮', item) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// 列表-操作按钮 |
||||
|
const butttondata = [ |
||||
|
defaultButtons.mainListEditBtn({hasPermi:'system:table-action-rel:update'}), // 编辑 |
||||
|
defaultButtons.mainListDeleteBtn({hasPermi:'system:table-action-rel:delete'}), // 删除 |
||||
|
] |
||||
|
|
||||
|
// 列表-操作按钮事件 |
||||
|
const buttonTableClick = async (val, row) => { |
||||
|
if (val == 'edit') { // 编辑 |
||||
|
openForm('update', row) |
||||
|
} else if (val == 'delete') { // 删除 |
||||
|
handleDelete(row.id) |
||||
|
} |
||||
|
} |
||||
|
const tableActionRef = ref() |
||||
|
/** 添加/修改操作 */ |
||||
|
const basicFormRef = ref() |
||||
|
const openForm = (type: string, row?: any) => { |
||||
|
TableActionRelApi.getTableActionRelNoPage({}).then(res=>{ |
||||
|
tableActionRef.value = res |
||||
|
}); |
||||
|
basicFormRef.value.open(type, row) |
||||
|
} |
||||
|
|
||||
|
// form表单提交 |
||||
|
const formsSuccess = async (formType,data) => { |
||||
|
var isHave =TableActionRel.allSchemas.formSchema.some(function (item) { |
||||
|
return item.field === 'activeTime' || item.field === 'expireTime'; |
||||
|
}); |
||||
|
if(isHave){ |
||||
|
if(data.activeTime && data.expireTime && data.activeTime >=data.expireTime){ |
||||
|
message.error('失效时间要大于生效时间') |
||||
|
return; |
||||
|
} |
||||
|
} |
||||
|
if(data.activeTime==0)data.activeTime = null; |
||||
|
if(data.expireTime==0)data.expireTime = null; |
||||
|
if (formType === 'create') { |
||||
|
await TableActionRelApi.createTableActionRel(data) |
||||
|
message.success(t('common.createSuccess')) |
||||
|
} else { |
||||
|
await TableActionRelApi.updateTableActionRel(data) |
||||
|
message.success(t('common.updateSuccess')) |
||||
|
} |
||||
|
basicFormRef.value.dialogVisible = false |
||||
|
getList() |
||||
|
} |
||||
|
|
||||
|
/** 详情操作 */ |
||||
|
const detailRef = ref() |
||||
|
const openDetail = (row: any, titleName: any, titleValue: any) => { |
||||
|
detailRef.value.openDetail(row, titleName, titleValue, 'basicTableActionRel') |
||||
|
} |
||||
|
|
||||
|
/** 删除按钮操作 */ |
||||
|
const handleDelete = async (id: number) => { |
||||
|
try { |
||||
|
// 删除的二次确认 |
||||
|
await message.delConfirm() |
||||
|
// 发起删除 |
||||
|
await TableActionRelApi.deleteTableActionRel(id) |
||||
|
message.success(t('common.delSuccess')) |
||||
|
// 刷新列表 |
||||
|
await getList() |
||||
|
} catch {} |
||||
|
} |
||||
|
|
||||
|
/** 导出按钮操作 */ |
||||
|
const exportLoading = ref(false) // 导出的加载中 |
||||
|
const handleExport = async () => { |
||||
|
try { |
||||
|
// 导出的二次确认 |
||||
|
await message.exportConfirm() |
||||
|
// 发起导出 |
||||
|
exportLoading.value = true |
||||
|
const data = await TableActionRelApi.exportTableActionRel(tableObject.params) |
||||
|
download.excel(data, '表名动作关系.xlsx') |
||||
|
} catch { |
||||
|
} finally { |
||||
|
exportLoading.value = false |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/** 导入 */ |
||||
|
const importFormRef = ref() |
||||
|
const handleImport = () => { |
||||
|
importFormRef.value.open() |
||||
|
} |
||||
|
// 导入附件弹窗所需的参数 |
||||
|
const importTemplateData = reactive({ |
||||
|
templateUrl: '', |
||||
|
templateTitle: '表名动作关系导入模版.xlsx' |
||||
|
}) |
||||
|
// 导入成功之后 |
||||
|
const importSuccess = () => { |
||||
|
getList() |
||||
|
} |
||||
|
|
||||
|
// 筛选提交 |
||||
|
const searchFormClick = (searchData) => { |
||||
|
tableObject.params = { |
||||
|
isSearch: true, |
||||
|
filters: searchData.filters |
||||
|
} |
||||
|
getList() // 刷新当前列表 |
||||
|
} |
||||
|
|
||||
|
const onChange = (field,cur,item)=>{ |
||||
|
if(field == 'act'){ |
||||
|
nextTick(() => { |
||||
|
const actName = noticeActionList.find(item=>item.value == cur)?.label |
||||
|
const setV = {} |
||||
|
setV['name'] = actName |
||||
|
item.value.setValues(setV) |
||||
|
}) |
||||
|
} |
||||
|
if(field == 'tableName'){ |
||||
|
// 接着,从actionList中筛除掉已经存在于alreadySelectedActionList中的项 |
||||
|
let actionList = noticeActionListA.filter(element => |
||||
|
!tableActionRef.value.some(elementA => |
||||
|
cur == elementA.tableName && element.value == elementA.act |
||||
|
) |
||||
|
); |
||||
|
|
||||
|
// 更新MessageSet.allSchemas.formSchema中对应元素的componentProps.options |
||||
|
const formItem = TableActionRel.allSchemas.formSchema.find(element => element.field == 'act'); |
||||
|
if (formItem && formItem.componentProps) { |
||||
|
formItem.componentProps.options = actionList; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/** 初始化 **/ |
||||
|
onMounted(async () => { |
||||
|
getList() |
||||
|
importTemplateData.templateUrl = await TableActionRelApi.importTemplate() |
||||
|
}) |
||||
|
|
||||
|
</script> |
@ -0,0 +1,144 @@ |
|||||
|
import type { CrudSchema } from '@/hooks/web/useCrudSchemas' |
||||
|
import { dateFormatter } from '@/utils/formatTime' |
||||
|
|
||||
|
// 表单校验
|
||||
|
export const TableActionRelRules = reactive({ |
||||
|
tableName: [required], |
||||
|
available: [required], |
||||
|
concurrencyStamp: [required] |
||||
|
}) |
||||
|
|
||||
|
export const TableActionRel = useCrudSchemas(reactive<CrudSchema[]>([ |
||||
|
// {
|
||||
|
// label: 'id',
|
||||
|
// field: 'id',
|
||||
|
// sort: 'custom',
|
||||
|
// isForm: false,
|
||||
|
// isSearch: false,
|
||||
|
// isDetail: false,
|
||||
|
// isTable: false,
|
||||
|
// isTableForm: false,
|
||||
|
// fixed: 'left'
|
||||
|
// },
|
||||
|
{ |
||||
|
label: '表名', |
||||
|
field: 'tableName', |
||||
|
sort: 'custom', |
||||
|
dictType: DICT_TYPE.MESSAGE_NOTICE_TABLE, |
||||
|
dictClass: 'string', // 默认都是字符串类型其他暂不考虑
|
||||
|
isSearch: true, |
||||
|
form: { |
||||
|
component: 'SelectV2', |
||||
|
componentProps: { |
||||
|
filterable: true, |
||||
|
} |
||||
|
}, |
||||
|
search: { |
||||
|
component: 'SelectV2', |
||||
|
componentProps: { |
||||
|
filterable: true, |
||||
|
} |
||||
|
} |
||||
|
}, |
||||
|
{ |
||||
|
label: '动作', |
||||
|
field: 'act', |
||||
|
sort: 'custom', |
||||
|
isSearch: true, |
||||
|
isDetail: false, |
||||
|
dictType: DICT_TYPE.NOTICE_ACTION_TYPE, |
||||
|
dictClass: 'string', // 默认都是字符串类型其他暂不考虑
|
||||
|
form: { |
||||
|
component: 'SelectV2', |
||||
|
componentProps: { |
||||
|
filterable: true, |
||||
|
} |
||||
|
}, |
||||
|
search: { |
||||
|
component: 'SelectV2', |
||||
|
componentProps: { |
||||
|
filterable: true, |
||||
|
} |
||||
|
} |
||||
|
}, |
||||
|
{ |
||||
|
label: '动作', |
||||
|
field: 'name', |
||||
|
sort: 'custom', |
||||
|
isForm: false, |
||||
|
isSearch: false, |
||||
|
isDetail: true, |
||||
|
isTable: false, |
||||
|
isTableForm: false, |
||||
|
}, |
||||
|
{ |
||||
|
label: '是否可用', |
||||
|
field: 'available', |
||||
|
sort: 'custom', |
||||
|
isSearch: true, |
||||
|
dictType: DICT_TYPE.FALSE_OR_TRUE, |
||||
|
dictClass: 'string', // 默认都是字符串类型其他暂不考虑
|
||||
|
form: { |
||||
|
component: 'SelectV2', |
||||
|
} |
||||
|
}, |
||||
|
{ |
||||
|
label: '生效时间', |
||||
|
field: 'activeTime', |
||||
|
sort: 'custom', |
||||
|
formatter: dateFormatter, |
||||
|
isSearch: true, |
||||
|
search: { |
||||
|
component: 'DatePicker', |
||||
|
componentProps: { |
||||
|
valueFormat: 'YYYY-MM-DD HH:mm:ss', |
||||
|
type: 'daterange', |
||||
|
defaultTime: [new Date('1 00:00:00'), new Date('1 23:59:59')] |
||||
|
} |
||||
|
}, |
||||
|
form: { |
||||
|
component: 'DatePicker', |
||||
|
componentProps: { |
||||
|
type: 'datetime', |
||||
|
valueFormat: 'x' |
||||
|
} |
||||
|
} |
||||
|
}, |
||||
|
{ |
||||
|
label: '失效时间', |
||||
|
field: 'expireTime', |
||||
|
sort: 'custom', |
||||
|
formatter: dateFormatter, |
||||
|
isSearch: true, |
||||
|
search: { |
||||
|
component: 'DatePicker', |
||||
|
componentProps: { |
||||
|
valueFormat: 'YYYY-MM-DD HH:mm:ss', |
||||
|
type: 'daterange', |
||||
|
defaultTime: [new Date('1 00:00:00'), new Date('1 23:59:59')] |
||||
|
} |
||||
|
}, |
||||
|
form: { |
||||
|
component: 'DatePicker', |
||||
|
componentProps: { |
||||
|
type: 'datetime', |
||||
|
valueFormat: 'x' |
||||
|
} |
||||
|
} |
||||
|
}, |
||||
|
{ |
||||
|
label: '备注', |
||||
|
field: 'remark', |
||||
|
sort: 'custom', |
||||
|
isSearch: true |
||||
|
}, |
||||
|
{ |
||||
|
label: '操作', |
||||
|
field: 'action', |
||||
|
isForm: false, |
||||
|
table: { |
||||
|
width: 150, |
||||
|
fixed: 'right' |
||||
|
} |
||||
|
} |
||||
|
])) |
Loading…
Reference in new issue