Browse Source

哨卡管理 新增,唯一id获取异常bug

master
zhangyongzhangyong 6 years ago
parent
commit
cf71b1d6d1
  1. 51
      src/views/modules/custom/epidemicsentrypost-add-or-update.vue

51
src/views/modules/custom/epidemicsentrypost-add-or-update.vue

@ -1,7 +1,7 @@
<template> <template>
<el-dialog <el-dialog
:visible.sync="visible" :visible.sync="visible"
:title="!dataForm.sentryPostCode ? $t('add') : $t('update')" :title="!dataForm.id ? $t('add') : $t('add')"
:close-on-click-modal="false" :close-on-click-modal="false"
:close-on-press-escape="false" :close-on-press-escape="false"
:append-to-body="true" :append-to-body="true"
@ -16,13 +16,13 @@
<el-form-item label="哨卡编码" prop="sentryPostCode"> <el-form-item label="哨卡编码" prop="sentryPostCode">
<el-input v-model="dataForm.sentryPostCode" placeholder="哨卡编码(唯一性最长6位)" style="width: 800px"></el-input> <el-input v-model="dataForm.sentryPostCode" placeholder="哨卡编码(唯一性最长6位)" style="width: 800px"></el-input>
</el-form-item> </el-form-item>
<el-form-item label="哨卡名称" prop="sentryPostName"> <el-form-item label="哨卡名称" prop="id">
<el-select v-model="dataForm.sentryPostName" clearable filterable <el-select v-model="dataForm.id" clearable filterable
placeholder="请选择" style="width: 800px" @change="selectModel($event)"> placeholder="请选择" style="width: 800px" >
<el-option v-for="item in verifyOptions" <el-option v-for="item in verifyOptions"
:key="item.id" :key="item.id"
:label="item.sentryPostName" :label="item.sentryPostName"
:value="item.sentryPostName"> :value="item.id">
</el-option> </el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
@ -43,7 +43,6 @@ export default {
dataForm: { dataForm: {
id: '', id: '',
sentryPostCode: '', sentryPostCode: '',
sentryPostName: '',
gridId: '' gridId: ''
}, },
verifyOptions: [] verifyOptions: []
@ -59,7 +58,7 @@ export default {
trigger: 'blur' trigger: 'blur'
} }
], ],
sentryPostName: [ id: [
{ {
required: true, required: true,
message: this.$t('validate.required'), message: this.$t('validate.required'),
@ -76,7 +75,7 @@ export default {
this.$nextTick(() => { this.$nextTick(() => {
this.$refs['dataForm'].resetFields() this.$refs['dataForm'].resetFields()
if (this.dataForm.id) { if (this.dataForm.id) {
this.getInfo() // this.getInfo()
} }
}) })
}, },
@ -92,29 +91,21 @@ export default {
}) })
.catch(() => {}) .catch(() => {})
}, },
// value key
selectModel (sentryPostName) {
let obj = {}
obj = this.verifyOptions.find((dataForm) => {
return this.dataForm.sentryPostName === sentryPostName
})
this.dataForm.id = obj.id
},
// //
getInfo () { // getInfo () {
this.$http // this.$http
.get(`/news/epidemicSentryPost/${this.dataForm.id}`) // .get(`/news/epidemicSentryPost/${this.dataForm.id}`)
.then(({ data: res }) => { // .then(({ data: res }) => {
if (res.code !== 0) { // if (res.code !== 0) {
return this.$message.error(res.msg) // return this.$message.error(res.msg)
} // }
this.dataForm = { // this.dataForm = {
...this.dataForm, // ...this.dataForm,
...res.data // ...res.data
} // }
}) // })
.catch(() => {}) // .catch(() => {})
}, // },
// //
// sentryPostCodeIsRepeat () { // sentryPostCodeIsRepeat () {
// if (this.dataForm.sentryPostCode.replace(/\s+/g, '').length === 0) { // if (this.dataForm.sentryPostCode.replace(/\s+/g, '').length === 0) {

Loading…
Cancel
Save