Browse Source

删除基本信息功能

master
maochaoying 2 years ago
parent
commit
582d3a646f
  1. 2
      .env
  2. 30
      src/api/info.js
  3. 184
      src/components/Nuclear.vue

2
.env

@ -1 +1 @@
VITE_BASE_URL=http://127.0.0.1:8899
VITE_BASE_URL=http://192.168.1.111:8899

30
src/api/info.js

@ -13,3 +13,33 @@ export const coreListApi = () => {
method: 'GET', method: 'GET',
}) })
} }
export const addStationApi = data => {
return request({
url: '/station/add',
method: 'POST',
data,
})
}
export const addCoreApi = data => {
return request({
url: '/core/add',
method: 'POST',
data,
})
}
export const delStationApi = id => {
return request({
url: `/station/delete/${id}`,
method: 'POST',
})
}
export const delCoreApi = id => {
return request({
url: `/core/delete/${id}`,
method: 'POST',
})
}

184
src/components/Nuclear.vue

@ -16,7 +16,34 @@
:onClose="stationClose" :onClose="stationClose"
> >
<template v-slot:body> <template v-slot:body>
<div>这是使用插槽定义的对话框内容</div>
<t-form
:data="stationForm"
:rules="stationRules"
ref="form"
@reset="onStationReset"
@submit="onStationSubmit"
>
<t-form-item label="核电站名称" name="name">
<t-input
v-model="stationForm.name"
placeholder="请输入核电站名称"
></t-input>
</t-form-item>
<t-form-item label="核电站地址" name="address">
<t-input
v-model="stationForm.address"
placeholder="请输入核电站地址"
></t-input>
</t-form-item>
<t-form-item>
<t-space size="10px">
<t-button theme="primary" type="submit">提交</t-button>
<t-button theme="default" variant="base" type="reset"
>重置</t-button
>
</t-space>
</t-form-item>
</t-form>
</template> </template>
</t-dialog> </t-dialog>
@ -47,7 +74,52 @@
:onClose="coreClose" :onClose="coreClose"
> >
<template v-slot:body> <template v-slot:body>
<div>这是使用插槽定义的对话框内容</div>
<t-form
:data="coreForm"
:rules="coreRules"
ref="form"
@reset="onCoreReset"
@submit="onCoreSubmit"
>
<t-form-item label="名称" name="name">
<t-input
v-model="coreForm.name"
placeholder="请输入名称"
></t-input>
</t-form-item>
<t-form-item label="序列号" name="serialNumber">
<t-input
v-model="coreForm.serialNumber"
placeholder="请输入序列号"
></t-input>
</t-form-item>
<t-form-item label="所属核电站" name="stationId">
<t-select
v-model="coreForm.stationId"
class="demo-select-base"
clearable
filterable
placeholder="请选择所属核电站"
>
<t-option
v-for="item in stationList"
:value="item.id"
:label="item.name"
:key="item.id"
>
{{ item.name }}
</t-option>
</t-select>
</t-form-item>
<t-form-item>
<t-space size="10px">
<t-button theme="primary" type="submit">提交</t-button>
<t-button theme="default" variant="base" type="reset"
>重置</t-button
>
</t-space>
</t-form-item>
</t-form>
</template> </template>
</t-dialog> </t-dialog>
<t-table <t-table
@ -67,10 +139,54 @@
</template> </template>
<script lang="jsx"> <script lang="jsx">
import { stationListApi, coreListApi } from '@/api/info'
import {
stationListApi,
coreListApi,
addStationApi,
addCoreApi,
delStationApi,
delCoreApi,
} from '@/api/info'
export default { export default {
data() { data() {
return { return {
coreForm: {
name: '',
stationId: '',
serialNumber: '',
},
stationForm: {
name: '',
address: '',
},
stationRules: {
name: [
{
required: true,
message: '核电站名称必填',
type: 'error',
trigger: 'blur',
},
],
},
coreRules: {
name: [
{
required: true,
message: '名称必填',
type: 'error',
trigger: 'blur',
},
],
serialNumber: [
{
required: true,
message: '序列号必填',
type: 'error',
trigger: 'blur',
},
],
},
tabValue: 'first', tabValue: 'first',
stationVisible: false, stationVisible: false,
coreVisible: false, coreVisible: false,
@ -106,6 +222,10 @@ export default {
title: '序列号', title: '序列号',
}, },
{ {
colKey: 'stationId',
title: '所属核电站',
},
{
title: '操作', title: '操作',
cell: (h, { row }) => ( cell: (h, { row }) => (
<div> <div>
@ -119,8 +239,62 @@ export default {
} }
}, },
methods: { methods: {
delStation(id) {},
delCore(id) {},
onCoreReset() {
this.$message.success('重置成功')
},
async onCoreSubmit({ validateResult, firstError }) {
if (validateResult === true) {
const res = await addCoreApi(this.coreForm)
if (res?.code == 200) {
if (res?.data?.result) {
this.$message.success('提交成功')
this.coreVisible = false
this.getCoreList()
}
}
} else {
this.$message.warning(firstError)
}
},
onStationReset() {
this.$message.success('重置成功')
},
async onStationSubmit({ validateResult, firstError }) {
if (validateResult === true) {
const res = await addStationApi(this.stationForm)
if (res?.code == 200) {
if (res?.data?.result) {
this.$message.success('提交成功')
this.stationVisible = false
this.getStationList()
}
} else {
this.$message.error(res?.msg)
}
} else {
this.$message.warning(firstError)
}
},
async delStation(id) {
const res = await delStationApi(id)
if (res?.code == 200) {
if (res?.data?.result) {
this.$message.success('删除成功')
this.getStationList()
}
} else {
this.$message.error(res?.msg)
}
},
async delCore(id) {
const res = await delCoreApi(id)
if (res?.code == 200) {
if (res?.data?.result) {
this.$message.success('删除成功')
this.getCoreList()
}
}
},
stationClose() { stationClose() {
this.stationVisible = false this.stationVisible = false
}, },

Loading…
Cancel
Save