老产品前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

337 lines
9.2 KiB

4 years ago
<template>
<div>
<div>
<el-form :inline="false"
:model="dataForm"
:rules="dataRule"
:disabled="formType === 'detail'"
class="form">
<el-form-item label="所属楼栋"
label-width="150px"
style="display: block">
<span>{{ agencyObj.communityName }}{{agencyObj.label}}</span>
</el-form-item>
<el-form-item label="单元号"
prop="buildingUnitId"
label-width="150px"
style="display: block">
<el-select class="item_width_1"
v-model="dataForm.buildingUnitId"
placeholder="请选择"
clearable>
<el-option v-for="item in unitList"
:key="item.id"
:label="item.unitName"
:value="item.id">
</el-option>
</el-select>
</el-form-item>
<el-form-item label="门牌号"
prop="doorName"
label-width="150px"
style="display: block">
<el-input class="item_width_1"
placeholder="请输入门牌号"
v-model="dataForm.doorName">
</el-input>
</el-form-item>
<el-form-item label="房屋类型"
prop="houseType"
label-width="150px"
style="display: block">
4 years ago
<el-radio-group v-model="houseType">
4 years ago
<el-radio :label="'1'">楼房</el-radio>
<el-radio :label="'2'">平房</el-radio>
<el-radio :label="'3'">别墅</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="房屋用途"
prop="purpose"
label-width="150px"
style="display: block">
4 years ago
<el-radio-group v-model="purpose">
<el-radio :label="'1'">住宅</el-radio>
<el-radio :label="'2'">商业</el-radio>
<el-radio :label="'3'">办公</el-radio>
<el-radio :label="'4'">工业</el-radio>
<el-radio :label="'5'">仓储</el-radio>
<el-radio :label="'6'">商住混用</el-radio>
<el-radio :label="'7'">其他</el-radio>
4 years ago
</el-radio-group>
</el-form-item>
<el-form-item label="出租"
prop="rentFlag"
label-width="150px"
style="display: block">
4 years ago
<el-radio-group v-model="rentFlag">
4 years ago
<el-radio :label="0"></el-radio>
<el-radio :label="1"></el-radio>
4 years ago
</el-radio-group>
</el-form-item>
<el-form-item label="房主姓名"
prop="ownerName"
label-width="150px"
style="display: block">
<el-input class="item_width_1"
placeholder="请输入房主姓名"
v-model="dataForm.ownerName">
</el-input>
</el-form-item>
<el-form-item label="房主电话"
prop="ownerPhone"
label-width="150px"
style="display: block">
<el-input class="item_width_1"
type='number'
placeholder="请输入房主电话"
v-model="dataForm.ownerPhone">
</el-input>
</el-form-item>
<el-form-item label="房主身份证"
prop="ownerIdCard"
label-width="150px"
style="display: block">
<el-input class="item_width_1"
type='number'
placeholder="请输入房主身份证"
v-model="dataForm.ownerIdCard">
</el-input>
</el-form-item>
</el-form>
</div>
<div class="div_btn">
<el-button @click="handleCancle"> </el-button>
<el-button v-if="formType != 'detail'"
type="primary"
@click="handleComfirm"> </el-button>
</div>
</div>
</template>
<script>
import { mapGetters } from 'vuex'
import { Loading } from 'element-ui' // 引入Loading服务
import { requestPost } from '@/js/dai/request'
let loading // 加载动画
export default {
data () {
return {
formType: 'add', //表单操作类型 add新增,edit编辑,detail详情
unitList: [],
houseId: '', //房屋ID
4 years ago
houseType: '1',
purpose: '1',
rentFlag: false,
4 years ago
dataForm: {
neighborHoodId: '', // 所属小区ID
buildingId: '',//所属楼栋ID
buildingUnitId: '',//所属单元ID
doorName: '',//门牌号
4 years ago
houseType: '',//房屋类型【楼房,平房,别墅】
purpose: '',//房屋用途【住宅,商业,办公,工业,仓储,商住混用,其他】
4 years ago
rentFlag: 0,//是否出租【是:1,否:0】
ownerPhone: '', //房主电话
ownerName: '', //房主名字
ownerIdCard: '' //房主身份证
},
keyWords: '',
agencyObj: {},
}
},
components: {},
mounted () {
},
methods: {
async initForm (type, row, agencyObj) {
this.agencyObj = agencyObj
this.dataForm.neighborHoodId = agencyObj.communityId
this.dataForm.buildingId = agencyObj.id
this.formType = type
if (row) {
this.houseId = row.houseId
this.dataForm = row
4 years ago
this.dataForm.buildingUnitId = row.unitNumKey
this.houseType = row.houseTypeKey
this.purpose = row.purposeKey
if (row.rentFlagKey) {
this.rentFlag = 1
} else {
this.rentFlag = 0
}
4 years ago
}
4 years ago
console.log(row)
4 years ago
await this.loadUnitList()
},
//加载单元
async loadUnitList () {
const url = '/gov/org/building/buildingunitlist'
let params = {
buildingId: this.agencyObj.id
}
const { data, code, msg } = await requestPost(url, params)
if (code === 0) {
this.unitList = data
} else {
this.$message.error(msg)
}
},
async handleComfirm () {
let url = ''
4 years ago
if (this.formType === 'add') {
url = '/gov/org/house/houseadd'
} else {
url = '/gov/org/house/houseupdate'
this.dataForm.houseId = this.houseId
}
4 years ago
this.dataForm.houseType = this.houseType
this.dataForm.purpose = this.purpose
this.dataForm.rentFlag = this.rentFlag
4 years ago
const { data, code, msg } = await requestPost(url, this.dataForm)
if (code === 0) {
this.$message({
type: 'success',
message: '操作成功'
4 years ago
})
this.resetData()
this.$emit('dialogOk')
} else {
this.$message.error(msg)
}
},
handleCancle () {
this.resetData()
this.$emit('dialogCancle')
},
resetData () {
this.houseId = '' //房屋ID
this.dataForm = {
neighborHoodId: '', // 所属小区ID
buildingId: '',//所属楼栋ID
buildingUnitId: 0,//所属单元ID
doorName: 0,//门牌号
houseType: '1',//房屋类型【楼房,平房,别墅】
purpose: '1',//房屋用途【住宅,商业,办公,工业,仓储,商住混用,其他】
rentFlag: '1',//是否出租【是:1,否:0】
ownerPhone: '', //房主电话
ownerName: '', //房主名字
ownerIdCard: '' //房主身份证
}
},
// 开启加载动画
startLoading () {
loading = Loading.service({
lock: true, // 是否锁定
text: '正在加载……', // 加载中需要显示的文字
background: 'rgba(0,0,0,.7)' // 背景颜色
})
},
// 结束加载动画
endLoading () {
// clearTimeout(timer);
if (loading) {
loading.close()
}
}
},
computed: {
dataRule () {
return {
buildingUnitId: [
{ required: true, message: '所属单元不能为空', trigger: 'blur' },
],
doorName: [
{ required: true, message: '门牌号不能为空', trigger: 'blur' }
],
houseType: [
{ required: true, message: '房屋类型不能为空', trigger: 'blur' }
],
purpose: [
{ required: true, message: '房屋用途不能为空', trigger: 'blur' }
],
rentFlag: [
{ required: true, message: '是否出租不能为空', trigger: 'blur' }
],
ownerPhone: [
{ required: true, message: '房主电话不能为空', trigger: 'blur' }
],
ownerName: [
{ required: true, message: '房主姓名不能为空', trigger: 'blur' }
],
ownerIdCard: [
{ required: true, message: '房主身份证号不能为空', trigger: 'blur' }
],
}
},
},
props: {}
}
</script>
<style scoped>
.item_width_1 {
width: 500px;
}
.item_width_2 {
width: 400px;
}
.item_width_3 {
margin-left: 10px;
width: 200px;
}
.div_btn {
display: flex;
justify-content: flex-end;
}
.el-tabs {
margin: 0 20px;
}
.el-upload__tip {
color: rgb(155, 155, 155);
margin: 0;
}
.form {
margin-top: 30px;
}
</style>