Files
dvcp_v2_webapp/packages/conv/AppRiskArea/components/Add.vue
2022-05-10 20:02:37 +08:00

155 lines
3.9 KiB
Vue

<template>
<ai-detail class="content-add">
<template slot="title">
<ai-title :title="params.id ? '编辑风险区域' : '添加风险区域'" isShowBack isShowBottomBorder @onBackClick="cancel(false)">
</ai-title>
</template>
<template slot="content">
<ai-card title="基本信息">
<template #content>
<el-form class="ai-form" :model="form" label-width="120px" ref="form">
<el-form-item prop="areaId" style="width: 100%;" label="选择地区" :rules="[{required: true, message: '请选择地区', trigger: 'change'}]">
<ai-area-select clearable @fullname="v => form.areaName = v" always-show :instance="instance" v-model="form.areaId"></ai-area-select>
</el-form-item>
<el-form-item label="风险等级" style="width: 100%;" prop="level" :rules="[{required: true, message: '请选择风险等级', trigger: 'change'}]">
<ai-select
v-model="form.level"
clearable
placeholder="请选择风险等级"
:selectList="dict.getDict('epidemicDangerousAreaLevel')">
</ai-select>
</el-form-item>
</el-form>
</template>
</ai-card>
</template>
<template #footer>
<el-button @click="cancel">取消</el-button>
<el-button type="primary" @click="confirm">提交</el-button>
</template>
</ai-detail>
</template>
<script>
import { mapState } from 'vuex'
export default {
name: 'Add',
props: {
instance: Function,
dict: Object,
params: Object,
moduleName: String
},
data () {
return {
info: {},
form: {
level: '',
areaId: '',
areaName: ''
},
id: ''
}
},
computed: {
...mapState(['user'])
},
created () {
this.dict.load('epidemicDangerousAreaLevel').then(() => {
if (this.params && this.params.id) {
this.id = this.params.id
this.getInfo(this.params.id)
}
})
},
methods: {
getInfo (id) {
this.instance.post(`/app/appepidemicdangerousarea/queryDetailById?id=${id}`).then(res => {
if (res.code === 0) {
this.form = res.data
}
})
},
confirm () {
this.$refs.form.validate((valid) => {
if (valid) {
this.instance.post(`/app/appepidemicdangerousarea/addOrUpdate`, {
...this.form
}).then(res => {
if (res.code == 0) {
this.$message.success('提交成功')
setTimeout(() => {
this.cancel(true)
}, 600)
}
})
}
})
},
cancel (isRefresh) {
this.$emit('change', {
type: 'list',
isRefresh: !!isRefresh
})
}
}
}
</script>
<style scoped lang="scss">
.content-add {
.video {
width: 640px;
height: 360px;
border-radius: 4px;
border: 1px dashed #D0D4DC;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
.icon {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
span:nth-child(2) {
display: inline-block;
font-size: 16px;
color: #333333;
line-height: 30px;
}
.iconfont {
display: inline-block;
font-size: 40px;
color: #2266FF;
}
}
.tips {
display: inline-block;
font-size: 12px;
color: #999999;
line-height: 26px;
}
}
.video-com {
width: 640px;
height: 360px;
background: rgba(0, 0, 0, 0.5);
border-radius: 2px;
border: 1px solid #D0D4DC;
margin-top: -40px;
}
}
</style>