hCxlz.vue 7.72 KB
<template>
    <div class="main">
        <el-dialog
                title="户重新落宗"
                :visible.sync="isVisible"
                width="50%"
                @close="close"
                :modal-append-to-body="false"
        >
            <div class="content">
                <table>
                    <tr>
                        <td class="label">宗地:</td>
                        <td class="input">
                            <el-input
                                    placeholder="请选择宗地" v-model="zdxx" :disabled="true"
                            ></el-input>
                        </td>
                        <td>
                            <el-button type="primary" @click="xzzdVisible = true">选择宗地</el-button>
                        </td>
                    </tr>
                    <tr>
                        <td class="label">自然幢:</td>
                        <td class="input">
                            <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>
                        </td>
                    </tr>
                    <tr>
                        <td class="label">逻辑幢:</td>
                        <td class="input">
                            <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>
                        </td>
                    </tr>
                    <tr>
                        <td class="label">幢单元:</td>
                        <td class="input">
                            <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>
                        </td>
                    </tr>
                </table>
            </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"
                        :isZdClose="true"></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 => {
                    if (res.success){
                        this.zrzList = res.result;
                    } else {
                        Message.error(res.message)
                    }
                })
            },
            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;
    }

    table {
        border-collapse: separate;
        border-spacing: 10px;
        display: inline-block;
        text-align: center;
        .label {
            width: 60px;
            font-size: 15px;
            text-align: justify;
            text-align-last: justify
        }
        .input {
            width: 300px;
            .el-select {
                width: 300px;
            }
        }
    }

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