LSSE-front/src/views/simulationScene/database/xdsjk.vue

134 lines
3.8 KiB
Vue
Raw Normal View History

2025-08-12 18:15:16 +08:00
<template>
<page-header-wrapper>
2025-08-27 15:19:10 +08:00
<Grid>
<a-card class="my-card">
<AntQueryTable
height="100%"
ref="xd-table"
:queryConfig="xdTable.queryConfig"
:tableConfig="xdTable.tableConfig"
:pageConfig="xdTable.pageConfig"
:showTool="xdTable.showTool"
2025-08-12 18:15:16 +08:00
>
2025-08-27 15:19:10 +08:00
<template #toolbar-left>
<a-button type="primary" icon="plus" @click="handleOpenAddModal">新增</a-button>
</template>
<template #tablecell-action="{ record }">
<a-button type="text-primary" icon="form" @click="handleOpenEditModal(record)"></a-button>
<a-divider type="vertical" />
<a-popconfirm
title="确定要删除该想定吗?"
ok-text="确定"
cancel-text="取消"
@confirm="handleDelete(record)"
>
<a-button type="text-primary" icon="delete"></a-button>
</a-popconfirm>
</template>
</AntQueryTable>
</a-card>
</Grid>
<AntFormModal
:visible.sync="AEModal.visible"
:title="AEModal.title"
:formItems="AEModal.formItems"
:formRules="AEModal.formRules"
:formData="AEModal.formData"
:onSubmit="handleSubmitAE"
@success="handleSubmitAESuccess"
></AntFormModal>
2025-08-12 18:15:16 +08:00
</page-header-wrapper>
</template>
<script>
export default {
name: 'Xdsjk',
data() {
return {
2025-08-27 15:19:10 +08:00
xdTable: {
queryConfig: {
items: [{ label: '想定名称', prop: 'name' }],
2025-08-12 18:15:16 +08:00
},
2025-08-27 15:19:10 +08:00
tableConfig: {
query: (params) =>
this.$http({
url: '/baseData/scenario/list',
method: 'get',
params: params,
}),
columns: [
{ dataIndex: 'serial' },
{ title: '想定名称', align: 'left', dataIndex: 'name', ellipsis: true, width: 'auto' },
{ title: '作者', dataIndex: 'author', align: 'left', width: 'auto' },
{
title: '创建时间',
dataIndex: 'createTime',
customRender: (t) => t?.replace('T', ' '),
align: 'left',
width: 'auto',
},
{ dataIndex: 'action' },
],
2025-08-12 18:15:16 +08:00
},
2025-08-27 15:19:10 +08:00
pageConfig: true,
showTool: true,
2025-08-12 18:15:16 +08:00
},
AEModal: {
visible: false,
2025-08-27 15:19:10 +08:00
title: '新增想定',
formItems: [{ label: '想定名称', prop: 'name' }],
formRules: {
2025-08-12 18:15:16 +08:00
name: [{ required: true, message: '请输入想定名称!', trigger: 'blur' }],
},
2025-08-27 15:19:10 +08:00
formData: {},
2025-08-12 18:15:16 +08:00
},
}
},
methods: {
2025-08-27 15:19:10 +08:00
handleOpenAddModal() {
this.AEModal.formData = {}
this.AEModal.title = '新增想定'
2025-08-12 18:15:16 +08:00
this.AEModal.visible = true
},
2025-08-27 15:19:10 +08:00
async handleOpenEditModal(record) {
2025-08-12 18:15:16 +08:00
try {
const res = await this.$http({
url: `/baseData/scenario/${record.id}`,
method: 'get',
})
2025-08-27 15:19:10 +08:00
this.AEModal.formData = res.data
2025-08-12 18:15:16 +08:00
this.AEModal.title = '编辑想定'
this.AEModal.visible = true
} catch (error) {
console.log(error)
}
},
2025-08-27 15:19:10 +08:00
handleSubmitAE(formData) {
return this.$http({
url: `/baseData/scenario/save`,
method: 'post',
data: formData,
})
2025-08-12 18:15:16 +08:00
},
2025-08-27 15:19:10 +08:00
handleSubmitAESuccess() {
this.$refs['xd-table'].commitAction('query')
2025-08-12 18:15:16 +08:00
},
async handleDelete(record) {
try {
await this.$http({
url: `/baseData/scenario/remove/${record.id}`,
method: 'get',
})
2025-08-27 15:19:10 +08:00
this.$message.success('删除想定成功')
this.$refs['xd-table'].commitAction('query')
2025-08-12 18:15:16 +08:00
} catch (error) {
console.log(error)
2025-08-27 15:19:10 +08:00
this.$message.error('删除想定失败')
2025-08-12 18:15:16 +08:00
}
},
},
}
</script>
<style lang="less" scoped></style>