hCxlz.vue 6.7 KB
<template>
    <div class="main">
        <el-dialog
                title="户重新落宗"
                :visible.sync="isVisible"
                width="50%"
                @close="close"
                :modal-append-to-body="false"
        >
            <div class="content">
                <el-form :label-position="right">
                    <el-form-item label="宗地:">
                        <el-input
                                placeholder="请选择宗地" v-model="zdxx" :disabled="true"
                        />
                        <div @click="xzzdVisible = true">选择宗地</div>
                       <!-- <el-button type="primary" @click="xzzdVisible = true">选择宗地</el-button>-->
                    </el-form-item>
                    <el-form-item label="自然幢:">
                        <el-select v-model="hcxlzData.zrzbsm" filterable placeholder="请选择" @change="zrzChange">
                            <el-option
                                    v-for="item in zrzList"
                                    :key="item.xmmc"
                                    :label="item.label"
                                    :value="item.bsm">
                            </el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item label="逻辑幢:">
                        <el-select v-model="hcxlzData.ljzbsm" filterable placeholder="请选择" @change="ljzChange">
                            <el-option
                                    v-for="item in ljzList"
                                    :key="item.bsm"
                                    :label="item.ljzmc"
                                    :value="item.bsm">
                            </el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item label="幢单元:">
                        <el-select v-model="hcxlzData.zdybsm" filterable placeholder="请选择">
                            <el-option
                                    v-for="item in zdyList"
                                    :key="item.bsm"
                                    :label="item.zdymc"
                                    :value="item.bsm">
                            </el-option>
                        </el-select>
                    </el-form-item>
                </el-form>
            </div>
            <div class="footer">
                <el-button type="primary" @click="save">保存</el-button>
                <el-button type="primary" @click="cancel">取消</el-button>
            </div>
            <query-data :centerDialogVisible="xzzdVisible" @close="xzzdClose" @getData="getZdxx"></query-data>
        </el-dialog>
    </div>
</template>

<script>
    import queryData from './../../components/queryData/queryData'
    import {zdXlcd, hzl} from './../../api/zd'
    import {Message} from 'element-ui'

    export default {
        name: "hCxlz",
        components: {queryData},
        data() {
            return {
                zd: {},
                zrz: {},
                ljz: {},
                zdy: {},
                xzzdVisible: false,
                isVisible: false,
                zdxx: '',    // 宗地信息
                hcxlzData: {
                    bsms: [],
                    zrzbsm: '',
                    ljzbsm: '',
                    zdybsm: ''
                },
                total: 1,
                zrzList: [],
                ljzList: [],
                zdyList: []
            }
        },
        props: {
            hCxlzVisble: {
                type: Boolean,
                default: false
            },
            bsms: {
                type: Array
            }
        },
        mounted() {
            this.hcxlzData.bsms = this.bsms;
        },
        methods: {
            ljzChange: function () {
                const item = this.ljzList.find(i => i.bsm == this.hcxlzData.ljzbsm)
                this.hcxlzData.zdybsm = ''
                this.zdyList = item.list;
                this.zdyList.push({
                    zdymc: '空',
                    bsm: ''
                })
            },
            zrzChange: function () {
                const item = this.zrzList.find(i => i.bsm == this.hcxlzData.zrzbsm);
                this.hcxlzData.ljzbsm = ''
                this.hcxlzData.zdybsm = ''
                this.ljzList = item.ljzList;
                this.ljzList.push({
                    ljzmc: '空',
                    bsm: ''
                })
                this.zdyList = item.zdyList;
                this.zdyList.push({
                    zdymc: '空',
                    bsm: ''
                })
            },
            getZrz: function (bsm) {
                zdXlcd(bsm).then(res => {
                    this.zrzList = res.result;
                })
            },
            getZdxx: function (val) {
                console.log(val, "宗地信息")
                this.zd = val
                this.zdxx = val.xmmc + "(" + val.zddm + ")";
            },
            xzzdClose: function () {
                this.xzzdVisible = false;
            },
            result: function () {
                this.hcxlzData = {
                    zrzbsm: '',
                    ljzbsm: '',
                    zdybsm: ''
                };
                this.hcxlzData.bsms = this.bsms;
            },
            cancel() {
                console.log("cancel......")
                this.close();
            },
            save() {
                console.log("save.......")
                if (this.hcxlzData.zrzbsm == '') {
                    Message.error("请选择自然幢")
                    return;
                }
                hzl(this.hcxlzData).then(res => {
                    if (res.success) {
                        this.close();
                    } else {
                        Message.error(res.message)
                    }
                });
            },
            close() {
                this.$emit('close', false);
                this.result();
            },
        },
        watch: {
            hCxlzVisble: function (val) {
                this.isVisible = val
            },
            zd: function (val) {
                this.hcxlzData.zrzbsm = ''
                this.hcxlzData.zdybsm = ''
                this.hcxlzData.ljzbsm = ''
                this.getZrz(val.glbsm)
            }
        }
    }
</script>

<style scoped lang="less">
    .input-suffix {
        input {
            width: 210px;
            height: 30px;
            border-radius: 3px;
            border-color: #BBB;
        }
    }

    .content {
        text-align: center;
    }

    .footer {
        margin-top: 20px;
        text-align: center;
    }
</style>