保障环境数据库

This commit is contained in:
liaoboping 2025-08-25 11:22:28 +08:00
parent f02595a8ad
commit 4a6ca044ad
3 changed files with 242 additions and 251 deletions

View File

@ -76,19 +76,16 @@ export default {
display: flex;
flex-direction: column;
}
.flex-1 {
flex: 1;
}
.flex-cr {
display: flex;
flex-direction: column-reverse;
}
.flex-1 {
flex: 1;
}
.ai-fs {
align-items: flex-start;
}
.ai-s {
align-items: stretch;
}
.ai-fe {
align-items: flex-end;
}

View File

@ -354,7 +354,7 @@ export default {
async queryTable() {
this.tableLoading = true
try {
let res = []
let res = { data: [] }
if (this.tableConfig.query && typeof this.tableConfig.query === 'function') {
res = await this.tableConfig.query(this.queryParams)
}
@ -369,8 +369,8 @@ export default {
return
}
// ---- ----
this.tableData = res.data || []
this.total = res.totalCount || 0
this.tableData = res?.data?.data || []
this.total = res?.data?.totalCount || 0
if (this.tableData.length === 0 && this.total > 0) {
this.pageParams.pageNum = Math.ceil(this.total / this.pageParams.pageSize)
this.queryTable()

View File

@ -1,177 +1,153 @@
<template>
<page-header-wrapper>
<Grid :columns="['400px', 1]">
<a-card :bordered="false">
<a-list :loading="listLoading" item-layout="horizontal" :data-source="scenarioList">
<a-list-item slot="renderItem" slot-scope="item" @click="handleClickScenario(item)">
<a-list-item-meta :description="item.author">
<span slot="title">{{ item.name }}</span>
<a-checkbox slot="avatar" :checked="item.id === queryParam.id"></a-checkbox>
</a-list-item-meta>
</a-list-item>
</a-list>
<Grid :columns="['400px', 1]" :rows="gridRows">
<a-card
title="想定列表"
class="my-card my-card-has-title"
:bordered="false"
v-loading="xd.loading"
style="grid-row: 1 / 3"
>
<template #extra>
<a-icon type="sync" style="font-size: 30px" @click="getXdListData()" />
</template>
<a-tree
:treeData="xd.listData"
:replaceFields="{ title: 'name', key: 'id' }"
:selectedKeys.sync="xd.selectedKeys"
@select="handleChangeXdSelected"
>
</a-tree>
</a-card>
<a-card :bordered="false">
<div class="table-page-search-wrapper">
<a-form layout="inline">
<a-row :gutter="48">
<a-col :xl="8" :lg="8">
<a-radio-group v-model="queryParam.type" button-style="solid" @change="getList()">
<a-radio-button value="weather"> 气象环境 </a-radio-button>
<a-radio-button value="ebe"> 电磁环境 </a-radio-button>
<!-- <a-radio-button value="dl"> 地理环境 </a-radio-button> -->
</a-radio-group>
</a-col>
<a-col :xl="8" :lg="8">
<a-form-item label="区域">
<a-input placeholder="请输入" v-model="queryParam.area" />
</a-form-item>
</a-col>
<a-col :xl="5" :lg="5">
<span class="table-page-search-submitButtons">
<a-button type="primary" @click="getList">查询</a-button>
<a-button style="margin-left: 8px" @click="resetList">重置</a-button>
</span>
</a-col>
<a-col :xl="3" :lg="3">
<a-button type="primary" icon="plus" style="float: right" @click="handleAdd">新建</a-button>
</a-col>
</a-row>
</a-form>
</div>
<a-table
bordered
rowKey="id"
size="small"
:columns="columns"
:dataSource="loadData"
:pagination="paginationProps"
:loading="loadingTable"
@change="handleTableChange"
<a-card title="气象环境" class="my-card my-card-has-title" :bordered="false">
<template #extra>
<a-button type="primary" style="margin-right: 20px" @click="handleOpenAddQxhjModal">新增</a-button>
<a-icon
v-if="layoutRight === 'qxhj'"
type="fullscreen-exit"
style="font-size: 32px"
@click="layoutRight = 'auto'"
/>
<a-icon v-else type="fullscreen" style="font-size: 32px" @click="layoutRight = 'qxhj'" />
</template>
<AntQueryTable
ref="qxhj-table"
height="100%"
:queryConfig="qxhj.queryConfig"
:tableConfig="qxhj.tableConfig"
:pageConfig="qxhj.pageConfig"
:showTool="qxhj.showTool"
>
<span slot="action" slot-scope="text, record">
<a @click="handleEdit(record)"> <a-icon type="form" /></a>
<a-divider type="vertical" />
<a-popconfirm
:title="`确定要删除该${typeMapLabel}吗?`"
ok-text="确定"
cancel-text="取消"
@confirm="handleDelete(record)"
<template #tablecell-action="{ record }">
<a-button type="text-primary" icon="edit" @click="handleOpenEditQxhjModal(record)"></a-button>
</template>
</AntQueryTable>
</a-card>
<a-card title="电磁环境" class="my-card my-card-has-title" :bordered="false">
<template #extra>
<a-button type="primary" style="margin-right: 20px" @click="handleOpenAddDchjModal">新增</a-button>
<a-icon
v-if="layoutRight === 'dchj'"
type="fullscreen-exit"
style="font-size: 32px"
@click="layoutRight = 'auto'"
/>
<a-icon v-else type="fullscreen" style="font-size: 32px" @click="layoutRight = 'dchj'" />
</template>
<AntQueryTable
ref="dchj-table"
height="100%"
:queryConfig="dchj.queryConfig"
:tableConfig="dchj.tableConfig"
:pageConfig="dchj.pageConfig"
:showTool="dchj.showTool"
>
<a href="javascript:;"><a-icon type="delete" /></a>
</a-popconfirm>
</span>
</a-table>
<template #tablecell-action="{ record }">
<a-button type="text-primary" icon="edit" @click="handleOpenEditDchjModal(record)"></a-button>
</template>
</AntQueryTable>
</a-card>
</Grid>
<h-modal
:title="AEModal.title"
:width="640"
:visible="AEModal.visible"
:destroyOnClose="true"
@cancel="() => this.handleClose()"
@ok="() => this.handleOk()"
switch-fullscreen
:fullscreen.sync="AEModal.fullscreen"
>
<a-spin :spinning="AEModal.spinning">
<a-form-model
ref="form"
:model="AEModal.form"
:rules="AEModal.rules"
:label-col="AEModal.labelCol"
:wrapper-col="AEModal.wrapperCol"
>
<a-form-model-item v-for="item in formItems" :key="item.prop" v-bind="item">
<span v-if="item.customRender">{{ item.customRender(AEModal.form[item.prop]) }}</span>
<component
v-else
:is="item.component || 'a-input'"
v-model="AEModal.form[item.prop]"
v-bind="item.options"
v-on="item.listeners"
/>
</a-form-model-item>
</a-form-model>
</a-spin>
</h-modal>
<AntFormModal
:visible.sync="qxhjModal.visible"
:title="qxhjModal.title"
:formItems="qxhjModal.formItems"
:formRules="qxhjModal.formRules"
:formData="qxhjModal.formData"
:onSubmit="handleSubmitQxhj"
@success="handleSubmitQxhjSuccess"
></AntFormModal>
<AntFormModal
:visible.sync="dchjModal.visible"
:title="dchjModal.title"
:formItems="dchjModal.formItems"
:formRules="dchjModal.formRules"
:formData="dchjModal.formData"
:onSubmit="handleSubmitDchj"
@success="handleSubmitDchjSuccess"
></AntFormModal>
</page-header-wrapper>
</template>
<script>
//
export default {
name: 'Bzhjsjk',
data() {
return {
listLoading: false,
scenarioList: [],
queryParam: { id: '', type: 'weather' },
weatherColumns: [
{ title: '#', dataIndex: 'id' },
{ title: '区域', dataIndex: 'area', align: 'left' },
{ title: '日期', dataIndex: 'date', align: 'center' },
{ title: '天气', dataIndex: 'weather', align: 'center' },
{ title: '大气压', dataIndex: 'airPressure', align: 'center' },
{ title: '空气质量', dataIndex: 'airQuality', align: 'center' },
{ title: '湿度', dataIndex: 'humidity', align: 'center' },
{ title: '降水量', dataIndex: 'precipitation', align: 'center' },
{ title: '能见度', dataIndex: 'visibility', align: 'center' },
{ title: '风向', dataIndex: 'windDirection', align: 'center' },
{ title: '风力', dataIndex: 'windPower', align: 'center' },
{ title: '风速', dataIndex: 'windSpeed', align: 'center' },
{ title: '操作', width: 100, dataIndex: 'action', align: 'center', scopedSlots: { customRender: 'action' } },
],
ebeColumns: [
{ title: '#', dataIndex: 'id' },
{ title: '区域', dataIndex: 'area', align: 'left' },
{ title: '持续时间', dataIndex: 'duration', align: 'left' },
{ title: '环境变化趋势', dataIndex: 'environmentalChangeTrends', align: 'left' },
{ title: '环境复杂度', dataIndex: 'environmentalComplexity', align: 'left' },
{ title: '磁场强度', dataIndex: 'fieldStrength', align: 'left' },
{ title: '频率', dataIndex: 'frequency', align: 'left' },
{ title: '频率区间', dataIndex: 'frequencyRang', align: 'left' },
{ title: '干扰幅度', dataIndex: 'interferenceAmplitude', align: 'left' },
{ title: '干扰源', dataIndex: 'interferenceSource', align: 'left' },
{ title: '干扰类型', dataIndex: 'interferenceType', align: 'left' },
{ title: '波型', dataIndex: 'waveType', align: 'left' },
{ title: '操作', width: 100, dataIndex: 'action', align: 'center', scopedSlots: { customRender: 'action' } },
],
dlColumns: [
{ title: '#', dataIndex: 'id' },
{ title: '操作', width: 100, dataIndex: 'action', align: 'center', scopedSlots: { customRender: 'action' } },
],
loadData: [], // Promise
loadingTable: false,
paginationProps: {
defaultPageSize: 10,
showSizeChanger: true,
showQuickJumper: true,
showTotal: (total) => {
return `${total}`
},
total: 0,
onShowSizeChange: (current, pageSize) => (this.pageSize = pageSize),
layoutRight: 'auto',
xd: {
loading: false,
listData: [],
selectedKeys: [],
},
AEModal: {
title: '',
qxhj: {
queryConfig: false,
tableConfig: {
table: {},
immediate: false,
query: () =>
this.$http({
url: `/environment/weather/list`,
method: 'get',
params: { id: this.xd.selectedKeys[0] },
}),
columns: [
{ dataIndex: 'serial' },
{ title: '区域', dataIndex: 'area' },
{ title: '日期', dataIndex: 'date' },
{ title: '天气', dataIndex: 'weather' },
{ title: '大气压', dataIndex: 'airPressure' },
{ title: '空气质量', dataIndex: 'airQuality' },
{ title: '湿度', dataIndex: 'humidity' },
{ title: '降水量', dataIndex: 'precipitation' },
{ title: '能见度', dataIndex: 'visibility' },
{ title: '风向', dataIndex: 'windDirection' },
{ title: '风力', dataIndex: 'windPower' },
{ title: '风速', dataIndex: 'windSpeed' },
{ dataIndex: 'action', width: 100 },
],
},
pageConfig: true,
showTool: false,
},
qxhjModal: {
visible: false,
editStatus: false,
fullscreen: false,
spinning: false,
form: {},
weatherFormItems: [
title: '',
mode: '',
formItems: [
{
label: '区域',
prop: 'area',
component: 'AntOriginSelect',
options: { dataSource: () => this.$http({ url: `/system/area/getTreeSelect`, method: 'get' }) },
},
{ label: '日期', prop: 'date', component: 'a-date-picker', options: { valueFormat: 'YYYY/MM/DD' } },
{
label: '日期',
prop: 'date',
component: 'a-date-picker',
options: { format: 'YYYY/MM/DD', valueFormat: 'YYYY/MM/DD' },
},
{ label: '天气', prop: 'weather' },
{ label: '大气压', prop: 'airPressure' },
{ label: '空气质量', prop: 'airQuality' },
@ -182,8 +158,51 @@ export default {
{ label: '风力', prop: 'windPower' },
{ label: '风速', prop: 'windSpeed' },
],
ebeFormItems: [
{ label: '区域', prop: 'area' },
formRules: {},
formData: {},
},
dchj: {
queryConfig: false,
tableConfig: {
table: {},
immediate: false,
query: () =>
this.$http({
url: `/environment/ebe/list`,
method: 'get',
params: { id: this.xd.selectedKeys[0] },
}),
columns: [
{ dataIndex: 'serial' },
{ title: '区域', dataIndex: 'area' },
{ title: '持续时间', dataIndex: 'duration' },
{ title: '环境变化趋势', dataIndex: 'environmentalChangeTrends' },
{ title: '环境复杂度', dataIndex: 'environmentalComplexity' },
{ title: '磁场强度', dataIndex: 'fieldStrength' },
{ title: '频率', dataIndex: 'frequency' },
{ title: '频率区间', dataIndex: 'frequencyRang' },
{ title: '干扰幅度', dataIndex: 'interferenceAmplitude' },
{ title: '干扰源', dataIndex: 'interferenceSource' },
{ title: '干扰类型', dataIndex: 'interferenceType' },
{ title: '波型', dataIndex: 'waveType' },
{ dataIndex: 'action', width: 100 },
],
},
pageConfig: true,
showTool: false,
},
dchjModal: {
visible: false,
title: '',
mode: '',
formItems: [
{
label: '区域',
prop: 'area',
component: 'AntOriginSelect',
options: { dataSource: () => this.$http({ url: `/system/area/getTreeSelect`, method: 'get' }) },
},
{ label: '持续时间', prop: 'duration' },
{ label: '环境变化趋势', prop: 'environmentalChangeTrends' },
{ label: '环境复杂度', prop: 'environmentalComplexity' },
@ -195,132 +214,107 @@ export default {
{ label: '干扰类型', prop: 'interferenceType' },
{ label: '波型', prop: 'waveType' },
],
dlFormItems: [],
rules: {
name: [{ required: true, message: '请输入想定名称!', trigger: 'blur' }],
},
labelCol: { xs: { span: 24 }, sm: { span: 7 } },
wrapperCol: { xs: { span: 24 }, sm: { span: 13 } },
formRules: {},
formData: {},
},
}
},
computed: {
columns() {
return this[`${this.queryParam.type}Columns`]
},
formItems() {
return this.AEModal[`${this.queryParam.type}FormItems`]
},
typeMapLabel() {
gridRows() {
return {
weather: '气象环境',
ebe: '电磁环境',
dl: '地理环境',
}[this.queryParam.type]
auto: [1, 1],
qxhj: [1, '56px'],
dchj: ['56px', 1],
}[this.layoutRight]
},
},
created() {
this.getScenarioList()
this.getXdListData()
},
methods: {
async getScenarioList() {
async getXdListData() {
try {
this.listLoading = true
this.xd.loading = true
const res = await this.$http({
url: `/baseData/scenario/all`,
method: 'get',
})
this.scenarioList = res.data
this.queryParam.id = this.scenarioList[0].id
this.getList()
this.xd.listData = res.data
if (this.xd.selectedKeys.length === 0) {
this.xd.selectedKeys = [this.xd.listData[0].id]
this.handleChangeXdSelected()
}
} catch (error) {
console.log(error)
} finally {
this.listLoading = false
this.xd.loading = false
}
},
handleClickScenario(item) {
this.queryParam.id = item.id
this.getList()
handleChangeXdSelected() {
this.$refs['qxhj-table'].commitAction('query')
this.$refs['dchj-table'].commitAction('query')
},
resetList() {
this.queryParam.area = ''
this.getList()
handleOpenAddQxhjModal() {
this.qxhjModal.title = '新建气象环境'
this.qxhjModal.mode = 'add'
this.qxhjModal.formData = { sceneId: this.xd.selectedKeys[0] }
this.qxhjModal.visible = true
},
async getList(parameter = {}) {
try {
this.loadingTable = true
const res = await this.$http({
url: `/environment/${this.queryParam.type}/list`,
method: 'get',
params: { ...parameter, ...this.queryParam },
})
this.loadData = res.data.data
this.paginationProps.total = res.data.totalCount
} catch (error) {
console.log(error)
} finally {
this.loadingTable = false
}
},
handleTableChange(pagination) {
const parameter = {}
parameter.pageSize = pagination.pageSize
parameter.pageNum = pagination.current
this.getList(parameter)
},
handleAdd() {
this.AEModal.form = {}
this.AEModal.title = `添加${this.typeMapLabel}`
this.AEModal.editStatus = false
this.AEModal.visible = true
},
async handleEdit(record) {
async handleOpenEditQxhjModal(record) {
try {
const res = await this.$http({
url: `/environment/${this.queryParam.type}/${record.id}`,
url: `/environment/weather/${record.id}`,
method: 'get',
})
this.AEModal.form = res.data
this.AEModal.title = `编辑${this.typeMapLabel}`
this.AEModal.editStatus = true
this.AEModal.visible = true
this.qxhjModal.title = `编辑气象环境`
this.qxhjModal.mode = 'edit'
this.qxhjModal.formData = { ...res.data }
this.qxhjModal.visible = true
} catch (error) {
console.log(error)
}
},
handleClose() {
this.AEModal.visible = false
this.AEModal.form = {}
},
async handleOk() {
try {
await this.$refs.form.validate()
const params = { ...this.AEModal.form }
await this.$http({
url: `/environment/${this.queryParam.type}/save`,
handleSubmitQxhj(formData) {
return this.$http({
url: `/environment/weather/save`,
method: 'post',
data: params,
data: formData,
})
this.$message.success(`${this.AEModal.title}成功!`)
this.getList()
this.handleClose()
},
handleSubmitQxhjSuccess() {
this.$refs['qxhj-table'].commitAction('query')
},
handleOpenAddDchjModal() {
this.dchjModal.title = '新建电磁环境'
this.dchjModal.mode = 'add'
this.dchjModal.formData = { sceneId: this.xd.selectedKeys[0] }
this.dchjModal.visible = true
},
async handleOpenEditDchjModal(record) {
try {
const res = await this.$http({
url: `/environment/ebe/${record.id}`,
method: 'get',
})
this.dchjModal.title = `编辑电磁环境`
this.dchjModal.mode = 'edit'
this.dchjModal.formData = { ...res.data }
this.dchjModal.visible = true
} catch (error) {
console.log(error)
}
},
async handleDelete(record) {
try {
await this.$http({
url: `/environment/${this.queryParam.type}/remove/${record.id}`,
method: 'get',
handleSubmitDchj(formData) {
return this.$http({
url: `/environment/ebe/save`,
method: 'post',
data: formData,
})
this.$message.success(`删除${this.typeMapLabel}成功`)
this.getList()
} catch (error) {
console.log(error)
this.$message.error(`删除${this.typeMapLabel}失败`)
}
},
handleSubmitDchjSuccess() {
this.$refs['dchj-table'].commitAction('query')
},
},
}