<template>
|
<div class="house-info">
|
<el-row class="add-button" v-if="addorupdate === '01'">
|
<el-col :span="24">
|
<el-button
|
type="primary"
|
size="small"
|
icon="el-icon-circle-plus-outline"
|
@click="handleAddCus"
|
class="add_btn"
|
>新增</el-button>
|
</el-col>
|
</el-row>
|
<ProTable
|
:pageInfo="pageInfo"
|
@doAction="doAction"
|
@handleCurrentChange="handleCurrentChange"
|
@handleSizeChange="handleSizeChange"
|
:isAutoIndex="true"
|
:list="records"
|
:header="tableHeader"
|
:loading="loading"
|
/>
|
<el-dialog
|
:title="dialogTitle"
|
v-if="dialogVisible"
|
:visible.sync="dialogVisible"
|
:close-on-click-modal="false"
|
:close-on-press-escape="false"
|
:destroy-on-close="true"
|
:show-close="false"
|
custom-class="stock_dialog"
|
width="890px"
|
center
|
>
|
<PropertyOwner
|
@closeDialog="closeDialog"
|
:addOrModify="addOrModify"
|
:customerId="customerId"
|
:tempRecord="tempRecord"
|
/>
|
</el-dialog>
|
<Dialog
|
v-model="isDelete"
|
title="房产信息删除确认"
|
:buttons="[{text: '取消'},{text: '确定', type: 'primary'}]"
|
@handleClick="clickDelete"
|
:contentText="`请确认是否需要删除${tempRecord.houseSerialno}房产的信息?`"
|
></Dialog>
|
</div>
|
</template>
|
|
<script>
|
import ProTable from "@/views/components/ProTable";
|
import Dialog from "../components/Dialog";
|
import PropertyOwner from "./PropertyOwner";
|
|
import { qryCusHouseList, delHouseInfo } from "@/http/api.js";
|
import { enterpriseCusOtherShareholder } from "../config/column.config";
|
export default {
|
components: {
|
ProTable,
|
Dialog,
|
PropertyOwner
|
},
|
props: {
|
tableHeader: {
|
type: [Object, Array],
|
default: () => {
|
return [];
|
}
|
},
|
addorupdate: {
|
type: [String],
|
default: ""
|
}
|
},
|
created() {
|
this.init();
|
},
|
data() {
|
return {
|
operateBtns: [{ label: "删除", type: "DELETE", value: true }],
|
columnConfig: [...enterpriseCusOtherShareholder],
|
loading: false,
|
pageInfo: {
|
currentPage: 1,
|
pageSize: 10,
|
total: 0
|
},
|
records: [],
|
dialogVisible: false,
|
dialogTitle: "",
|
objectNo: "", // 存储customerId
|
tempRecord: {},
|
addOrModify: "", // 0-新增 1-修改
|
isDelete: false,
|
customerId: ""
|
};
|
},
|
methods: {
|
async init() {
|
const { $route, pageInfo } = this;
|
const { query } = $route;
|
const { customerId } = query;
|
this.customerId = customerId;
|
const params = {
|
customerId,
|
...pageInfo
|
};
|
const { result } = await qryCusHouseList(params);
|
this.records = result.records.map(item => {
|
const newItem = { ...item };
|
newItem.operationOption = [
|
{ type: "delete", label: "删除", value: true },
|
{ type: "edit", label: "修改", value: true }
|
];
|
return newItem;
|
});
|
this.$set(this.pageInfo, "total", result.total);
|
},
|
handleAddCus() {
|
this.addOrModify = "0";
|
this.dialogTitle = this.addOrModify === "0" ? "新增" : "修改";
|
this.dialogVisible = true;
|
},
|
closeDialog(type) {
|
this.dialogVisible = false;
|
if (type === "add") {
|
this.init();
|
}
|
// tempRecord = {} 避免修改未做任何操作导致tempRecord对象仍然保存上一次的数据
|
this.tempRecord = {}
|
},
|
// 修改翻页条数
|
handleSizeChange(val) {
|
this.pageInfo.pageSize = val;
|
this.getBoardList();
|
},
|
// 修改翻页数
|
handleCurrentChange(val) {
|
this.pageInfo.currentPage = val;
|
this.getBoardList();
|
},
|
// 表单事件回调
|
doAction(name, item, { type }) {
|
this.tempRecord = item;
|
if (type === "delete") {
|
this.isDelete = true;
|
}
|
if (type === "edit") {
|
this.addOrModify = "1";
|
this.dialogTitle = "修改";
|
this.dialogVisible = true;
|
}
|
},
|
clickDelete(index) {
|
if (index === 0) {
|
this.isDelete = false;
|
} else {
|
this.toDelete();
|
}
|
},
|
async toDelete() {
|
const { tempRecord } = this;
|
const { houseSerialno } = tempRecord;
|
try {
|
await delHouseInfo({ houseSerialno });
|
this.$message.success("删除成功");
|
this.isDelete = false;
|
this.init();
|
} catch (error) {
|
this.$message.warning("删除失败");
|
this.isDelete = false;
|
}
|
this.tempRecord = {}
|
},
|
async handleClickRowBtn(type, item) {
|
// 编辑详情
|
// if (type === "EDIT") {
|
// this.$router.push({
|
// name: "clientsModify",
|
// query: { from: "edit", ...item }
|
// });
|
// }
|
// // 处理详情
|
// if (type === "DETAIL") {
|
// this.$router.push({
|
// name: "clientsDetail",
|
// query: { from: "edit", ...item }
|
// });
|
// }
|
// if (type === "DELETE") {
|
// const params = {
|
// dirno: item.dirno
|
// };
|
// const delRes = await delBusinessImageCatalog(params);
|
// if (delRes && delRes.code === "00") {
|
// this.$message.success("删除成功");
|
// this.$refs.imageTablelist.getTableList();
|
// }
|
// }
|
}
|
}
|
};
|
</script>
|
|
<style lang="less" scoped>
|
.house-info {
|
& .add-button {
|
margin-bottom: 20px;
|
}
|
}
|
</style>
|