lin
2024-03-11 18b8c4bc2f30fc59a47134cd7dae2fd35ce21294
src/views/userHouse/components/retalInfo.vue
@@ -7,13 +7,12 @@
                </avue-form>
                <!-- <box-title class="m10" :classVal="9" :title="'租客信息'"></box-title>
                <avue-crud :option="placeOption" :table-loading="loading" :data="placeExt" ref="crud"
                    v-model="houseHoldForm" :permission="permissionList" @row-del="houseHoldRowDel"
                    @row-update="houseHoldRowUpdate" @row-save="houseHoldRowSave" :page.sync="holdPage"
                    @current-change="holdCurrentChange" @size-change="holdSizeChange"
                    @refresh-change="refreshHoldChange" @on-load="holdOnLoad">
                </avue-crud> -->
                <box-title class="m10" :classVal="9" :title="'租客信息'"></box-title>
                <avue-crud :option="placeOption" :data="houseRental" ref="tenantForm" v-model="houseHoldForm"
                    :permission="permissionList" @row-del="houseHoldRowDel" @row-update="houseHoldRowUpdate"
                    @row-save="houseHoldRowSave" :page.sync="holdPage" @current-change="holdCurrentChange"
                    @size-change="holdSizeChange" @refresh-change="refreshHoldChange">
                </avue-crud>
            </div>
            <div class="footer-btn-box">
@@ -44,13 +43,21 @@
import {
    getList as getHouseList,
    getDetatil as getHouseDetail
    getDetatil as getHouseDetail
} from "@/api/userHouse/list/house.js"
import {
    getDetatil,
    update
    updateInfo,
    add as addHouseRental
} from "@/api/userHouse/list/houseRental.js"
import {
    getList as getHouseholdList,
} from "@/api/userHouse/list/houseHold.js"
import boxTitle from "./boxTitle"
@@ -133,7 +140,7 @@
                            data
                        }, callback) => {
                            //首次加载去查询对应的值
                            if (value) {
                            if (value && this.isEdit) {
                                getHouseDetail({
                                    houseCode: value
                                }).then(res => {
@@ -143,7 +150,7 @@
                                    return
                                })
                            }
                            if (page) {
                            if (page && this.isEdit) {
                                this.loading = true
                                getHouseList(page.currentPage, page.pageSize, Object.assign(data)).then(res => {
                                    const resData = res.data.data
@@ -400,6 +407,11 @@
                    prop: "name",
                    // search: true,
                    searchSpan: 4,
                    rules: [{
                        required: true,
                        message: "请输入姓名",
                        trigger: "blur",
                    },],
                },
                {
                    label: "电话",
@@ -414,52 +426,59 @@
                    width: 160,
                    // search: true,
                    searchSpan: 4,
                },
                {
                    label: "性别",
                    prop: "gender",
                    type: "select",
                    dicData: [{
                        label: "男",
                        value: 1
                    },
                    {
                        label: "女",
                        value: 0
                    },
                    {
                        label: "未知",
                        value: 1
                    }
                    rules: [
                        {
                            required: true,
                            message: "请输身份证号",
                            trigger: "blur",
                        }
                    ],
                },
                {
                    label: "关系",
                    prop: "relationship",
                    type: "select",
                    dicUrl: "/api/blade-system/dict-biz/dictionary?code=roleRelation",
                    dataType: "number",
                    props: {
                        label: "dictValue",
                        value: "dictKey",
                    },
                    display: false
                },
                // {
                //     label: "性别",
                //     prop: "gender",
                //     type: "select",
                //     dicData: [{
                //         label: "男",
                //         value: 1
                //     },
                //     {
                //         label: "女",
                //         value: 0
                //     },
                //     {
                //         label: "未知",
                //         value: 1
                //     }
                //     ],
                // },
                // {
                //     label: "关系",
                //     prop: "relationship",
                //     type: "select",
                //     dicUrl: "/api/blade-system/dict-biz/dictionary?code=roleRelation",
                //     dataType: "number",
                //     props: {
                //         label: "dictValue",
                //         value: "dictKey",
                //     },
                //     display: false
                // },
                {
                    width: 220,
                    overHidden: true,
                    label: '小区名称',
                    prop: "aoiName",
                    // overHidden: true,
                    label: '工作单位',
                    prop: "employer",
                    // search: true,
                    searchSpan: 4,
                    display: false
                },
                {
                    label: "地址",
                    prop: "address",
                    label: "户籍地址",
                    prop: "hukouRegistration",
                    minWidth: 160,
                    overHidden: true,
                    display: false
                    // overHidden: true,
                },
                ]
            },
@@ -469,6 +488,13 @@
                total: 0,
            },
            houseHoldForm: {},
            houseRental: [],
            holdPage: {
                pageSize: 100,
                currentPage: 1,
                total: 0,
            },
            idEdit: false
        }
    },
@@ -478,44 +504,17 @@
    inject: ["placeElement"],
    watch: {
        'form.isNine': {
            handler(newData) {
                if (newData) {
                    let nineTypeColumn = this.findObject(
                        this.option.column,
                        'nineType'
                    )
                    if (newData == 1) {
                        nineTypeColumn.display = true
                    } else {
                        nineTypeColumn.display = false
                    }
                }
            },
        },
        'form.isFront': {
            handler(newData) {
                if (newData) {
                    let frontTypeColumn = this.findObject(
                        this.option.column,
                        'frontType'
                    )
                    if (newData == 1) {
                        frontTypeColumn.display = true
                    } else {
                        frontTypeColumn.display = false
                    }
                }
            },
        }
    },
    methods: {
        initOpen(newData) {
        initOpen(type, newData) {
            if (type == 2) {
                this.isEdit = true;
                this.getInfo(newData);
                this.onLoadHouseHold(newData);
            } else {
                this.houseRental = [];
                this.houseHoldForm = {};
            }
            this.getInfo(newData);
            this.roleBox = true
            this.baseShow = true
            this.restShow = false
@@ -528,85 +527,12 @@
            this.form = {}
            this.placeForm = {}
            const that = this
            that.$axios
                .all([getPlace(newData["id"]), getPlaceExt({
                    placeId: newData["id"]
                }), getPlaceList()])
                .then(
                    that.$axios.spread(function (baseInfo, restInfo) {
                        that.form = baseInfo.data.data
                        that.form.location = [
                            that.form.lng,
                            that.form.lat,
                            that.form.location,
                        ].join(",")
                        if (that.form.imageUrls && that.form.imageUrls.length) {
                            that.form.imageUrls = that.form.imageUrls
                                .split(",")
                                .filter((item) => item != "")
                                .map((item) => website.minioUrl + item)
                                .join(",")
                        }
                        if (
                            that.form.placePoiLabelVOList &&
                            that.form.placePoiLabelVOList.length
                        ) {
                            let lebelTwo = that.form.placePoiLabelVOList.find((item) => {
                                return item.type == 2
                            })
                            if (lebelTwo) that.form.label = String(lebelTwo.poiCode)
                            let lebelThree = that.form.placePoiLabelVOList.find((item) => {
                                return item.type == 3
                            })
                            if (lebelThree) that.form.smallLabel = String(lebelThree.poiCode)
                        }
                        that.baseShow = true
                        const data = restInfo.data.data
                        if (data) {
                            let imageUrls = data.imageUrls
                            let planImageUrls = data.planImageUrls
                            if (imageUrls && imageUrls.length) {
                                imageUrls = imageUrls
                                    .split(",")
                                    .filter((item) => item != "")
                                    .map((item) => website.minioUrl + item)
                                    .join(",")
                            }
                            if (planImageUrls && planImageUrls.length) {
                                planImageUrls = planImageUrls
                                    .split(",")
                                    .filter((item) => item != "")
                                    .map((item) => website.minioUrl + item)
                                    .join(",")
                            }
                            that.placeForm = {
                                ...data,
                                imageUrls,
                                planImageUrls,
                            }
                        }
                        that.restShow = true
                    })
                )
        },
        getInfo(id) {
            getDetatil(id).then(res => {
                this.form = res.data.data
                this.form = res.data.data
                if (this.form.fileUrls.length > 0) {
                    var urls = []
                    var names = this.form.fileUrls.split(",")
@@ -617,6 +543,18 @@
                }
            })
        },
        onLoadHouseHold(id) {
            let params = {
                housingRentalId: id
            }
            getHouseholdList(this.holdPage.currentPage, this.holdPage.pageSize, Object.assign(params)).then(res => {
                const data = res.data.data
                this.houseRental = data.records
                this.loading = false
            })
        },
        locationDispose(data) {
@@ -636,6 +574,12 @@
        },
        houseHoldRowUpdate(row, index, done, loading) {
            let item = this.houseRental[index];
            item = row
            this.$set(this.houseRental, index, item)
            // this.houseRental[index] = row
            done();
            return;
            holdUpdate(row).then(
                () => {
                    this.holdOnLoad(this.holdPage)
@@ -652,26 +596,39 @@
            )
        },
        houseHoldRowDel(row) {
        houseHoldRowDel(row, index) {
            this.$confirm("确定将选择数据删除?", {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                type: "warning",
            })
                .then(() => {
                    return holdRemove(row.id)
                    // return holdRemove(row.id)
                    this.houseRental.splice(index, 1);
                })
                .then(() => {
                    this.holdOnLoad(this.holdPage)
                    this.$message({
                        type: "success",
                        message: "操作成功!",
                    })
                })
            // .then(() => {
            //     this.holdOnLoad(this.holdPage)
            //     this.$message({
            //         type: "success",
            //         message: "操作成功!",
            //     })
            // })
        },
        houseHoldRowSave(row, done, loading) {
        houseHoldRowSave(row) {
            console.log("===>", row)
            this.$refs.tenantForm.validate((valid, done, msg) => {
                if (valid) {
                    this.houseRental.push(row);
                    done();
                }
            })
            return;
            holdAdd({
                ...row,
                placeId: this.curRow.id,
@@ -746,14 +703,56 @@
            this.$refs.baseForm.validate((valid, done, msg) => {
                if (valid) {
                    if (this.form.fileUrls.length > 0) {
                var urls = []
                var split = this.form.fileUrls.split(",")
                split.forEach(url => {
                    var names = url.split("jczz/")
                    urls.push(names[1])
                        var urls = []
                        var split = this.form.fileUrls.split(",")
                        split.forEach(url => {
                            var names = url.split("jczz/")
                            urls.push(names[1])
                        })
                        this.form.fileUrls = urls.join(",")
                    }
                    this.form.householdVOList = this.houseRental;
                    console.log("=====>", this.form);
                    updateInfo(this.form).then(() => {
                        this.$message({
                            type: "success",
                            message: "操作成功!"
                        })
                        this.getInfo(this.form.id);
                        done()
                        this.roleBoxClose()
                    }, error => {
                        window.console.log(error)
                        loading()
                    })
                } else {
                    console.log("error submit!!")
                    return false
                }
            })
        },
        addRequest() {
            addHouseRental(this.form).then(() => {
                this.$message({
                    type: "success",
                    message: "操作成功!"
                })
                this.form.fileUrls = urls.join(",")
            }
                this.getInfo(this.form.id);
                done()
                this.roleBoxClose()
            }, error => {
                window.console.log(error)
                loading()
            })
        },
        updateRequest() {
            update(this.form).then(() => {
                this.$message({
                    type: "success",
@@ -762,23 +761,21 @@
                this.getInfo(this.form.id);
                done()
                this.roleBoxClose()
            }, error => {
                window.console.log(error)
                loading()
            })
                } else {
                    console.log("error submit!!")
                    return false
                }
            })
        },
        roleBoxClose() {
            this.form = {}
            this.placeForm = {}
            this.houseHoldForm = {}
            this.$refs.baseForm && this.$refs.baseForm.resetForm()
            this.$refs.restForm && this.$refs.restForm.resetForm()
            this.$refs.tenantForm && this.$refs.tenantForm.resetForm()
            this.baseShow = false
            this.restShow = false
            this.roleBox = false