hCxlz.vue 6.57 KB
<template>
    <el-dialog :close-on-click-modal="false" 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, index) in zrzList" :key="index" :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, index) in ljzList" :key="index" :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, index) in zdyList" :key="index" :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="close">取消</el-button>
        </div>
        <!-- <zd-query-data :isCxlz=true :centerDialogVisible="xzzdVisible" @close="xzzdClose" @getData="getZdxx"
            :isZdClose="true"></zd-query-data> -->
    </el-dialog>
</template>

<script>
// import zdQueryData from '@/components/zdQueryData/zdQueryData'
// import { zdXlcd, hzl } from '@api/zd'
import { Message } from 'element-ui'
export default {
    name: "hCxlz",
    // components: { zdQueryData },
    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;
                    this.xzzdClose();
                } else {
                    Message.error(res.message)
                }
            })
        },
        getZdxx: function (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;
        },
        save () {
            if (this.hcxlzData.zrzbsm === '') {
                Message.error("请选择自然幢");
                return;
            }
            hzl(this.hcxlzData).then(res => {
                if (res.success) {
                    this.$router.push({
                        path: '/zrz',
                        query: {
                            bsm: this.hcxlzData.zrzbsm,
                            source: 2,
                            auth: '0,1,2'
                        }
                    })
                } 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.zdbsm)
        }
    }
}
</script>

<style scoped lang="scss">
.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>