<template>
|
<div>
|
<el-row
|
v-for="(item, i) in FromCar"
|
:key="i"
|
>
|
<el-col :span="22">
|
<el-form ref="FromCar" :rules="rules" :inline="true" :model="FromCar[i]" label-width="100px">
|
<div class="add-lie">
|
<div>
|
<el-form-item label="所属小区">
|
<el-select :disabled="true" placeholder="" v-model="FromCar[i].villageId">
|
<el-option v-for="item in villageList" :key="item.value"
|
:label="item.label" :value="item.value"></el-option>
|
</el-select>
|
</el-form-item>
|
<el-form-item label="品牌型号">
|
<el-input :disabled="true" placeholder="" v-model="FromCar[i].brand" maxlength="20" show-word-limit></el-input>
|
</el-form-item>
|
<el-form-item label="车牌号" prop="plateNum">
|
<el-input :disabled="true" placeholder="" v-model="FromCar[i].plateNum" maxlength="20" show-word-limit></el-input>
|
</el-form-item>
|
<el-form-item label="车辆颜色">
|
<el-input :disabled="true" placeholder="" v-model="FromCar[i].color" maxlength="20" show-word-limit></el-input>
|
</el-form-item>
|
</div>
|
<!-- <el-form-item>
|
<el-button type="primary" @click="onSubmitcar(i)">保存</el-button>
|
</el-form-item> -->
|
</div>
|
</el-form>
|
</el-col>
|
<!-- <el-col :span="2">
|
<i
|
class="el-icon-circle-plus-outline"
|
type="danger"
|
v-if="i == 0"
|
style="font-size: 30px; color: #67c23a; margin-right: 5px"
|
@click="addItem"
|
></i>
|
<i
|
class="el-icon-remove-outline"
|
type="danger"
|
v-if="i != 0"
|
style="font-size: 30px; color: #f56c6c"
|
@click="del(i)"
|
></i>
|
</el-col> -->
|
</el-row>
|
</div>
|
</template>
|
|
<script>
|
export default {
|
props:['editId'],
|
data() {
|
return{
|
FromCar:[{
|
populationId:0,
|
plateNum:'',
|
color:'',
|
brand:'',
|
villageId:'',
|
communityId:''
|
}],
|
rules: {
|
plateNum: [
|
{ required: true, message: '请输入车牌号', trigger: 'blur' },
|
],
|
},
|
villageList:[],
|
communityId:''
|
}
|
},
|
|
watch:{
|
editId(val) {
|
if(val) {
|
this.FromCar.populationId =val;
|
}
|
}
|
},
|
|
mounted() {
|
/** populationId:获取人口ID */
|
if(this.$route.query.id) {
|
this.FromCar.populationId = this.$route.query.id;
|
this.communityId = this.$route.query.com;
|
this.getDetails();
|
} else {
|
this.communityId = this.$route.query.vi;
|
}
|
|
this.getvillage();
|
},
|
methods: {
|
/** 获取吸毒信息 populationId:人口id
|
* id:主键id 有id编辑 无id新增 */
|
getDetails() {
|
this.$api.get("population/car/list",{populationId:this.FromCar.populationId},e=> {
|
if(e.length) {
|
this.FromCar = e;
|
}
|
})
|
},
|
addItem() {
|
this.FromCar.push({
|
populationId:'',
|
plateNum:'',
|
color:'',
|
brand:'',
|
villageId:'',
|
communityId:''
|
});
|
},
|
// 删除
|
del(index) {
|
if(this.$route.query.id) {
|
this.$api.get("population/car/delete",{id:this.FromCar[index].id},e=> {
|
demo.toast("删除成功");
|
this.FromCar.splice(index, 1);
|
})
|
}else {
|
this.FromCar.splice(index, 1);
|
}
|
},
|
|
getvillage() {
|
this.$api.get("building/village/list",'',d=> {
|
this.villageList = d.map(e=> {
|
return {
|
label:e.name,
|
value:e.villageId.toString(),
|
}
|
})
|
})
|
|
},
|
|
onSubmitcar(i) {
|
if(!this.FromCar.populationId) {
|
return this.$message({
|
message: '请先填写完基础信息',
|
type: 'warning'
|
});
|
}
|
|
|
if(this.FromCar[i].id) {
|
//编辑
|
this.FromCar[i].communityId = this.communityId;
|
this.$api.post("population/car/edit",this.FromCar[i],e=> {
|
demo.toast("编辑成功")
|
})
|
} else {
|
//新增
|
this.FromCar[i].populationId = this.FromCar.populationId;
|
this.FromCar[i].communityId = this.communityId;
|
this.$api.post("population/car/add",this.FromCar[i],d=> {
|
this.$message({
|
message: '保存成功',
|
type: 'success'
|
});
|
});
|
}
|
|
},
|
}
|
}
|
</script>
|
|
<style>
|
|
</style>
|