<template>
|
<div class="notice">
|
<el-dialog
|
v-model="dialogVisible"
|
:title="title"
|
width="500px"
|
:before-close="handleClose"
|
>
|
<el-form :model="state.form" size="default" ref="areaRef" :rules="state.formRules" label-width="110px" >
|
<el-form-item>
|
<el-radio-group v-model="state.form.area" style="margin-left: -50px" >
|
<el-radio :label="1">地(市、州)</el-radio>
|
<el-radio :label="2">区县</el-radio>
|
</el-radio-group>
|
</el-form-item>
|
<el-form-item v-if="state.form.area === 1" style="margin-left: -50px" prop="stateName">
|
<el-input v-model.trim="state.form.stateName" placeholder="请输入地州名" ></el-input>
|
</el-form-item>
|
<div v-if="state.form.area === 2">
|
<el-form-item style="margin-left: -50px" prop="stateCode">
|
<el-select v-model="state.form.stateCode" class="m-2" placeholder="请选择所属地(市、州)" style="width: 100%">
|
<el-option
|
v-for="item in state.areaList"
|
:key="item.value"
|
:label="item.label"
|
:value="item.value"
|
/>
|
</el-select>
|
</el-form-item>
|
<el-form-item style="margin-left: -50px" prop="countyName">
|
<el-input v-model.trim="state.form.countyName" placeholder="请输入区县名"></el-input>
|
</el-form-item>
|
</div>
|
|
</el-form>
|
<template #footer>
|
<span class="dialog-footer">
|
<el-button @click="handleClose" size="default">取 消</el-button>
|
<el-button type="primary" @click="onSubmit" size="default">确认</el-button>
|
</span>
|
</template>
|
</el-dialog>
|
</div>
|
</template>
|
<script setup>
|
import {reactive, ref, toRefs} from 'vue'
|
import Editor from "@/components/Editor/index.vue";
|
import {ElMessage} from "element-plus";
|
|
const dialogVisible = ref(false);
|
const title = ref("");
|
const areaRef = ref();
|
const state = reactive({
|
form: {
|
area: 1,
|
stateCode: '',
|
stateName: '',
|
countyName: ''
|
},
|
formRules:{
|
stateName: [{ required: true, message: '请输入地州名', trigger: 'blur' }],
|
countyName: [{ required: true, message: '请输入区县名', trigger: 'blur' }],
|
stateCode: [{ required: true, message: '请选择所属地(市、州)', trigger: 'blur' }],
|
},
|
areaList: []
|
|
})
|
|
const openDialog = (type, value) => {
|
title.value = type === 'add' ? '新增' : type ==='edit' ? '编辑' : '查看' ;
|
if(type === 'edit') {
|
state.form = value;
|
}
|
dialogVisible.value = true;
|
}
|
|
const onSubmit = async () => {
|
const valid = await areaRef.value.validate();
|
if(valid){
|
areaRef.value.clearValidate();
|
reset();
|
dialogVisible.value = false;
|
|
}
|
}
|
|
const handleClose = () => {
|
areaRef.value.clearValidate();
|
reset();
|
dialogVisible.value = false;
|
|
}
|
const reset = () => {
|
state.form = {
|
area: 1,
|
state: '',
|
county: '',
|
stateCode: '',
|
}
|
}
|
defineExpose({
|
openDialog
|
});
|
|
</script>
|
|
<style scoped lang="scss">
|
.notice{
|
:deep(.el-form .el-form-item__label) {
|
font-size: 15px;
|
}
|
.file {
|
display: flex;
|
flex-direction: column;
|
align-items: flex-start;
|
}
|
}
|
</style>
|