2026-03-02 12:29:23 +00:00
|
|
|
<template>
|
|
|
|
|
<div class="region-add">
|
|
|
|
|
<el-card>
|
|
|
|
|
<template slot="header">
|
|
|
|
|
<div class="card-header">
|
|
|
|
|
<span>添加区域</span>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
2026-03-05 16:42:43 +00:00
|
|
|
<el-form :model="regionForm" :rules="rules" ref="regionForm" label-width="100px" class="form-content">
|
2026-03-02 12:29:23 +00:00
|
|
|
<el-form-item label="区域名称" prop="name">
|
|
|
|
|
<el-input v-model="regionForm.name" placeholder="请输入区域名称"></el-input>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item label="区域描述" prop="description">
|
2026-03-05 16:42:43 +00:00
|
|
|
<el-input type="textarea" v-model="regionForm.description" placeholder="请输入区域描述" rows="4"></el-input>
|
2026-03-02 12:29:23 +00:00
|
|
|
</el-form-item>
|
2026-03-05 16:42:43 +00:00
|
|
|
<el-form-item class="form-actions">
|
2026-03-02 12:29:23 +00:00
|
|
|
<el-button type="primary" @click="submitForm">提交</el-button>
|
|
|
|
|
<el-button @click="resetForm">重置</el-button>
|
|
|
|
|
<el-button @click="goBack">返回</el-button>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-form>
|
|
|
|
|
</el-card>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
import { regionApi } from '../../api/api'
|
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
name: 'RegionAdd',
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
regionForm: {
|
|
|
|
|
name: '',
|
|
|
|
|
description: ''
|
|
|
|
|
},
|
|
|
|
|
rules: {
|
|
|
|
|
name: [
|
2026-03-05 15:34:34 +00:00
|
|
|
{ required: true, message: '请输入区域名称', trigger: 'blur' }
|
2026-03-02 12:29:23 +00:00
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
async submitForm() {
|
|
|
|
|
this.$refs.regionForm.validate(async (valid) => {
|
|
|
|
|
if (valid) {
|
|
|
|
|
try {
|
|
|
|
|
await regionApi.create(this.regionForm)
|
|
|
|
|
this.$message.success('添加成功')
|
|
|
|
|
this.$router.push('/region/list')
|
|
|
|
|
} catch (error) {
|
|
|
|
|
this.$message.error('添加失败')
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
resetForm() {
|
|
|
|
|
this.$refs.regionForm.resetFields()
|
|
|
|
|
},
|
|
|
|
|
goBack() {
|
|
|
|
|
this.$router.push('/region/list')
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
.region-add {
|
2026-03-05 16:42:43 +00:00
|
|
|
padding: 0;
|
2026-03-02 12:29:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.card-header {
|
|
|
|
|
display: flex;
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
align-items: center;
|
|
|
|
|
}
|
2026-03-05 16:42:43 +00:00
|
|
|
|
|
|
|
|
.form-content {
|
|
|
|
|
max-width: 600px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.form-actions {
|
|
|
|
|
margin-top: 30px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* 移动端适配 */
|
|
|
|
|
@media screen and (max-width: 768px) {
|
|
|
|
|
.form-content {
|
|
|
|
|
max-width: 100%;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.form-content .el-form-item__label {
|
|
|
|
|
float: none;
|
|
|
|
|
display: block;
|
|
|
|
|
text-align: left;
|
|
|
|
|
margin-bottom: 5px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.form-content .el-form-item__content {
|
|
|
|
|
margin-left: 0 !important;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.form-actions {
|
|
|
|
|
text-align: center;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.form-actions .el-button {
|
|
|
|
|
margin-bottom: 10px;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</style>
|