城阳pc工作端前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

1073 lines
31 KiB

<template>
<div class="m-table">
<div class="u-table-btn2">
<div class="u-table-btn2-left">
<el-button v-if="agencyObj.level === 'building' || source !== 'search'"
v-show="btnAuths.ic_house_add"
class="diy-button--blue"
icon="el-icon-plus"
size="small"
@click="handleAdd">新增房屋</el-button>
<div class="u-btn-upload"
v-if="showImportBtn">
<el-popover popper-class="btn-popper"
placement="bottom"
width="20"
trigger="hover">
<div class="table-more-btn">
<el-upload ref="upload"
v-if="btnAuths.ic_house_import"
:multiple="false"
style="text-align: center"
:show-file-list="false"
:before-upload="beforeUpload"
action=""
accept=".xls,.xlsx"
:limit="1"
:on-exceed="handleExceed"
:http-request="uploadFile">
<el-button style=""
size="small"
type="text"
class="diy-button--other">导入房屋数据</el-button>
</el-upload>
</div>
<el-button size="small"
style="float:right"
class="diy-button--white"
slot="reference">导入<i class="el-icon-arrow-down el-icon--right"></i></el-button>
</el-popover>
</div>
<el-button style="float: left; margin-left: 10px"
v-if="btnAuths.ic_house_export"
class="diy-button--white"
size="small"
@click="handleExport">导出</el-button>
<el-button style="float: left; margin-left: 10px"
v-if="btnAuths.ic_house_batch_del"
class="diy-button--white"
size="small"
@click="deleteBatch">批量删除</el-button>
</div>
<div>
<el-popover popper-class="btn-popper"
placement="bottom"
style="margin-left: 10px"
width="20"
trigger="hover">
<div v-if="showImportBtn"
class="table-more-btn">
<el-button :headers="$getElUploadHeaders()"
v-if="btnAuths.ic_house_import"
class="diy-button--other"
size="small"
type="text"
@click="handleExportModule">下载房屋模板</el-button>
</div>
<div v-if="btnAuths.ic_house_export_yhyd"
class="table-more-btn">
<el-button style=""
class="diy-button--other"
size="small"
type="text"
:disabled="yihuyidangDisabled"
@click="handleExportYihuyidang()">导出一户一档</el-button>
</div>
<div v-if="btnAuths.ic_house_smart_import && displayedBaobiaoBtn"
class="table-more-btn">
<el-button size="small"
class="diy-button--other"
type="text"
@click="reportForm">智能填报</el-button>
</div>
<el-button size="small"
style="float:right"
class="diy-button--white"
slot="reference">更多<i class="el-icon-arrow-down el-icon--right"></i></el-button>
</el-popover>
</div>
</div>
<div class="m-table-item">
<el-table ref="ref_table"
:data="tableData"
v-loading="tableLoading"
@sort-change="handleSortOrderChange"
border
:height="tableHeight"
style="width: 100%"
@select-all="selectAll"
@selection-change="selectionChange">
<el-table-column type="selection"
:selectable="checkSelect"
width="55">
</el-table-column>
<!-- <el-table-column fixed="left"
width="70"
type="index"
label="序号"
header-align="center"
align="center"
:index="indexMethod">
</el-table-column> -->
<el-table-column prop="houseNameShow"
header-align="left"
align="left"
label="房屋名称"
fixed="left"
min-width="160">
</el-table-column>
<el-table-column prop="neighborHoodName"
label="所属小区"
header-align="left"
align="left"
min-width="150">
</el-table-column>
<el-table-column prop="buildingName"
label="所属楼栋"
header-align="left"
align="left"
width="90">
</el-table-column>
<el-table-column prop="unitNum"
label="单元号"
header-align="left"
align="left"
width="80">
</el-table-column>
<el-table-column prop="doorName"
label="门牌号"
header-align="left"
align="left"
width="80">
</el-table-column>
<el-table-column prop="houseType"
label="类型"
header-align="left"
align="left"
width="70">
</el-table-column>
<el-table-column prop="purpose"
label="用途"
header-align="left"
align="left"
width="70">
</el-table-column>
<el-table-column prop="rentFlag"
label="房屋状态"
header-align="left"
align="left"
width="90">
</el-table-column>
<el-table-column prop="ownerName"
label="房主姓名"
header-align="left"
align="left"
width="90">
</el-table-column>
<el-table-column prop="ownerPhone"
label="联系方式"
header-align="left"
align="left"
width="110">
</el-table-column>
<el-table-column prop="ownerIdCard"
label="证件号"
header-align="left"
align="left"
width="170">
</el-table-column>
<el-table-column prop="remark"
label="备注"
header-align="left"
align="left"
width="170">
</el-table-column>
<el-table-column prop="sort"
sortable="custom"
min-width="100"
header-align="left"
align="left"
label="排序">
<template slot-scope="scope">
<div @click="handleEditSort(scope.row)">
<span v-if="!scope.row.isChange">{{ scope.row.sort }}</span>
<el-input-number v-else
@change="handleChangeSort(scope.row)"
v-model="scope.row.sort"
class="item_width_4"
:precision="2"
size="small"
:min="0"
:max="9999"
label="描述文字"></el-input-number>
</div>
</template>
</el-table-column>
<el-table-column label="操作"
fixed="right"
width="220"
header-align="center"
align="center"
class="operate">
<template slot-scope="scope">
<el-button type="text"
v-if="btnAuths.ic_house_view"
class="div-table-button--blue"
size="small"
@click="handleDetail(scope.row)">查看</el-button>
<el-button v-if="btnAuths.ic_house_update && scope.row.showBtn"
type="text"
class="div-table-button--blue"
size="small"
@click="handleEdit(scope.row)">编辑</el-button>
<el-button v-if="btnAuths.ic_house_del && scope.row.showBtn"
type="text"
class="div-table-button--blue"
size="small"
@click="handleDelete(scope.row)">删除</el-button>
</template>
</el-table-column>
</el-table>
<div>
<el-pagination @size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page.sync="pageNo"
:page-sizes="[20, 50, 100, 200]"
:page-size="pageSize"
layout="sizes, prev, pager, next, total"
:total="total">
</el-pagination>
</div>
</div>
<!-- 修改弹出框 -->
<el-dialog :visible.sync="formShow"
:close-on-click-modal="false"
:close-on-press-escape="false"
:title="formTitle"
width="670px"
top="5vh"
class="dialog-h"
@closed="diaClose">
<room-form ref="ref_form"
:view_real_data="btnAuths.ic_house_view_real_data"
@dialogCancle="addFormCancle"
@dialogOk="addFormOk"></room-form>
</el-dialog>
<!-- 详情弹出框 -->
<el-dialog :visible.sync="detailShow"
:close-on-click-modal="false"
:close-on-press-escape="false"
:title="'查看房屋'"
width="820px"
top="5vh"
class="dialog-h"
@closed="detailFormCancle">
<room-detail ref="ref_form_detail"
:view_real_data="btnAuths.ic_house_view_real_data"
@diaDetailClose="detailFormCancle"></room-detail>
</el-dialog>
<baobiao ref="baobiao" />
</div>
</template>
<script>
import roomForm from "./roomForm";
import roomDetail from "./roomDetail";
import { requestPost } from "@/js/dai/request";
import { mapGetters } from "vuex";
import { Loading } from "element-ui"; // 引入Loading服务
import baobiao from "@/views/modules/cpts/baobiao";
let loading; // 加载动画
export default {
data () {
return {
searchHeight: 190,//搜索栏高度
source: "tree", //来源
importRoomLoading: false,
total: 0,
pageSize: 20,
pageNo: 0,
sortType: "asc", //asc:正,desc:倒
tableLoading: true,
// tableHeaderStyle: { background: 'linear-gradient(0deg, #005EB3 0%, #0083F0 100%)', color: '#FFFFFF', padding: '6px' },
// showImportBtn: false,//是否显示操作按钮,根据登录人所属组织判断
agencyObj: {}, //树所选的小区对象
agencyLevel: "", //树对应的level, grid neighborHood building agency
validTableDataNum: 0, //有效的数据数量,即有权限操作的数据数量
selection: [],
showDeletBtn: false,
tableData: [],
//form相关
formShow: false,
formTitle: "新增房屋",
detailShow: false,
rentList: [
{
value: "1",
label: "出租",
},
{
value: "2",
label: "闲置",
},
{
value: "0",
label: "自住",
},
],
yihuyidangDisabled: false,
displayedBaobiaoBtn: false,
btnAuths: {
ic_house_add: false, //新增
ic_house_import: false, //导入
ic_house_export: false, //导出
ic_house_batch_del: false, //批量删除
ic_house_export_yhyd: false, //导出一户一档
ic_house_smart_import: false, //智能填表
ic_house_del: false, //删除
ic_house_view: false, //查看
ic_house_update: false, //编辑
ic_house_view_real_data: false, //显示脱敏信息
},
};
},
components: {
baobiao,
roomForm,
roomDetail,
},
async mounted () {
this.updateBtnAuths();
// this.displayedBaobiaoBtn = await this.$refs.baobiao.existsTemplate({
// elseParams: {
// categoryKeys: ["house_info"],
// categoryKey: "house_info",
// },
// });
},
computed: {
tableHeight () {
console.log(this.searchHeight)
let height = this.searchHeight + 270
return this.$store.state.inIframe ? this.clientHeight - height + this.iframeHeight : this.clientHeight - height
},
...mapGetters(["clientHeight", "iframeHeight"]),
},
methods: {
// 更新按钮权限
updateBtnAuths () {
let rot = this.$route;
if (Array.isArray(rot.meta.btns)) {
rot.meta.btns.forEach((item) => {
this.btnAuths[item.permissions] = true;
});
}
},
reportForm () {
let paramMap = {
pageSize: this.pageSize,
pageNo: this.pageNo,
level: this.agencyLevel,
id: this.agencyObj.id,
ownerName: this.ownerName,
ownerPhone: this.ownerPhone,
rentFlag: this.rentFlag,
purpose: this.purpose,
remark: this.remark,
sortType: this.sortType,
updateStartDate: this.updateStartDate,
updateEndDate: this.updateEndDate,
neighborHoodId: this.neighborHoodId,
buildingId: this.buildingId,
buildingUnitId: this.buildingUnitId,
houseId: this.houseId,
};
this.$refs.baobiao.init({
elseParams: {
categoryKeys: ["house_info"],
categoryKey: "house_info",
paramMap,
},
});
},
indexMethod (index) {
return index + 1;
},
handleSortOrderChange (value) {
this.sortType = value.order === "ascending" ? "asc" : "desc";
this.loadTable();
},
handleSortChange (value) {
this.sortType = value.order === "ascending" ? "asc" : "desc";
this.loadTable();
},
handleEditSort (row) {
if (!row.isChange) {
row.isChange = true;
}
},
async handleChangeSort (row, index) {
// row.isChange = false
let params = {
id: row.houseId,
sort: row.sort,
type: "house",
};
let url = "/actual/base/communityHouse/updateHouseSort";
const { data, code, msg } = await requestPost(url, params);
if (code === 0) {
// this.$message({
// type: 'success',
// message: '修改成功'
// })
} else {
this.$message.error(msg);
}
},
checkSelect (row, index) {
let isChecked = false;
if (row.showBtn) {
// 判断里面是否存在某个参数
isChecked = true;
} else {
isChecked = false;
}
return isChecked;
},
loadTreeFromSearch () { },
async loadTable (source, treeObj) {
this.source = source;
this.tableLoading = true;
console.log(treeObj,'see');
if (source === "tree") {
//来源于tree,查询数据清空
this.sortType = "asc";
this.agencyObj = treeObj;
} else if (source === "search") {
//来源于查询
this.agencyObj = treeObj;
}
if (this.agencyObj.level === "grid") {
this.agencyLevel = "grid";
} else if (this.agencyObj.level === "neighborHood") {
this.agencyLevel = "neighborHood";
} else if (this.agencyObj.level === "building") {
this.agencyLevel = "building";
} else {
this.agencyLevel = "agency";
}
// if (fromTree) {
// this.agencyObj = treeObj
// }
let params = {
pageSize: this.pageSize,
pageNo: this.pageNo,
level: this.agencyLevel,
id: this.agencyObj.id,
ownerName: this.ownerName,
ownerPhone: this.ownerPhone,
rentFlag: this.rentFlag,
purpose: this.purpose,
remark: this.remark,
sortType: this.sortType,
updateStartDate: this.updateStartDate,
updateEndDate: this.updateEndDate,
neighborHoodId: this.neighborHoodId,
buildingId: this.buildingId,
buildingUnitId: this.buildingUnitId,
houseId: this.houseId,
};
const url = "/actual/base/communityHouse/listHouses";
const { data, code, msg } = await requestPost(url, params);
if (code === 0) {
this.total = data.total;
this.validTableDataNum = 0;
data.list.forEach((item) => {
item.sort = parseInt(item.sort) || 0;
item.sort = item.sort.toFixed(2);
item.isChange = false;
item.houseNameShow =
item.neighborHoodName +
item.buildingName +
item.unitNum +
item.doorName;
if (item.agencyId === this.staffAgencyId) {
item.showBtn = true;
this.validTableDataNum++;
} else {
item.showBtn = false;
}
});
this.tableData = data.list;
} else {
this.$message.error(msg);
}
this.tableLoading = false;
},
diaClose () {
this.$refs.ref_form.resetData();
this.formShow = false;
},
handleDetail (row) {
// this.formTitle = "房屋详情";
// this.formShow = true;
// this.$nextTick(() => {
// this.$refs.ref_form.initForm("detail", row, this.agencyObj);
// });
this.detailShow = true;
// const _data = await this.detail(row)
this.$nextTick(() => {
this.$refs.ref_form_detail.initForm(row, this.agencyObj);
});
},
detailFormCancle () {
// this.$refs.ref_form_detail.diaDestroy()
this.detailShow = false;
},
handleAdd () {
this.formTitle = "新增房屋";
this.formShow = true;
this.$nextTick(() => {
this.$refs.ref_form.initForm("add", null, this.agencyObj);
});
},
handleEdit (row) {
this.formTitle = "修改房屋";
this.formShow = true;
this.$nextTick(() => {
this.$refs.ref_form.initForm("edit", row, this.agencyObj);
});
},
addFormCancle () {
this.formShow = false;
},
addFormOk () {
this.formShow = false;
this.loadTable();
},
deleteBatch () {
if (this.selection.length > 0) {
this.$confirm("确认删除选择的房屋?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
})
.then(() => {
this.deleteCommunityBatch();
})
.catch((err) => {
if (err == "cancel") {
// this.$message({
// type: "info",
// message: "已取消删除"
// });
}
});
} else {
this.$message.warning("请先选择要删除的房屋");
}
},
selectAll (selection) {
this.selection = selection;
},
selectionChange (selection) {
this.selection = selection;
},
async handleDelete (row) {
this.$confirm("确认删除?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
})
.then(() => {
this.deleteRoom(row);
})
.catch((err) => {
if (err == "cancel") {
// this.$message({
// type: "info",
// message: "已取消删除"
// });
}
});
},
async deleteCommunityBatch () {
let ids = [];
this.selection.forEach((element) => {
ids.push(element.houseId);
});
const url = "/actual/base/communityHouse/deleteCommunityInfoByIds";
let params = {
type: "house",
ids: ids,
};
const { data, code, msg } = await requestPost(url, params);
if (code === 0) {
this.$message({
type: "success",
message: "删除成功",
});
this.$emit("refreshTree");
this.loadTable();
} else if (code > 8000) {
this.$message({
showClose: true,
message: msg,
duration: 0,
});
this.$emit("refreshTree");
this.loadTable();
} else {
this.$message.error(msg);
}
},
async deleteRoom (row) {
const url = "/actual/base/communityHouse/deleteHouse";
let params = {
houseId: row.houseId,
};
const { data, code, msg } = await requestPost(url, params);
if (code === 0) {
this.$message({
type: "success",
message: "删除成功",
});
this.$emit("refreshTree");
this.loadTable();
} else {
this.$message.error(msg);
}
},
//导出表格
async handleExport () {
let title = this.agencyObj.label;
title = title + "—房屋列表";
const url = "/actual/base/communityHouse/exporthouseinfo";
let params = {
ownerName: this.ownerName,
ownerPhone: this.ownerPhone,
rentFlag: this.rentFlag,
purpose: this.purpose,
remark: this.remark,
updateStartDate: this.updateStartDate,
updateEndDate: this.updateEndDate,
buildingId: this.agencyObj.id,
neighborHoodId: this.neighborHoodId,
buildingId: this.buildingId,
buildingUnitId: this.buildingUnitId,
houseId: this.houseId,
};
if (this.agencyObj.level === "grid") {
params.gridId = this.agencyObj.id;
params.agencyId = "";
params.buildingId = "";
params.neighborHoodId = "";
} else if (this.agencyObj.level === "neighborHood") {
params.neighborHoodId = this.agencyObj.id;
params.agencyId = "";
params.buildingId = "";
params.gridId = "";
} else if (this.agencyObj.level === "building") {
params.buildingId = this.agencyObj.id;
params.agencyId = "";
params.neighborHoodId = "";
params.gridId = "";
} else {
params.agencyId = this.agencyObj.id;
params.buildingId = "";
params.neighborHoodId = "";
params.gridId = "";
}
app.ajax.exportFilePost(
url,
params,
(data, rspMsg) => {
this.download(data, title + ".xls");
},
(rspMsg, data) => {
this.$message.error(rspMsg);
}
);
},
// 下载文件
download (data, fileName) {
if (!data) {
return;
}
var csvData = new Blob([data]);
if (window.navigator && window.navigator.msSaveOrOpenBlob) {
window.navigator.msSaveOrOpenBlob(csvData, fileName);
}
// for Non-IE (chrome, firefox etc.)
else {
var a = document.createElement("a");
document.body.appendChild(a);
a.style = "display: none";
var url = window.URL.createObjectURL(csvData);
a.href = url;
a.download = fileName;
a.click();
a.remove();
window.URL.revokeObjectURL(url);
}
},
handleExportModule () {
let title = "";
title = "房屋模板";
const url = "/gov/org/house/exporttemplate";
let params = {};
app.ajax.exportFilePost(
url,
params,
(data, rspMsg) => {
this.download(data, title + ".xls");
},
(rspMsg, data) => {
this.$message.error(rspMsg);
}
);
},
//导出一户一档
handleExportYihuyidang () {
this.yihuyidangDisabled = true;
let title = this.agencyObj.label;
title = title + "-一户一档";
let url = "/gov/org/house/exportHouseUser";
let params = {
agencyId: "",
gridId: "",
ownerName: this.ownerName,
ownerPhone: this.ownerPhone,
rentFlag: this.rentFlag,
purpose: this.purpose,
remark: this.remark,
updateStartDate: this.updateStartDate,
updateEndDate: this.updateEndDate,
neighborHoodId: this.neighborHoodId,
buildingId: this.buildingId,
buildingUnitId: this.buildingUnitId,
houseId: this.houseId,
buildingId: "",
neighborHoodId: "",
};
if (this.agencyObj.level === "grid") {
params.gridId = this.agencyObj.id;
params.agencyId = "";
params.buildingId = "";
params.neighborHoodId = "";
} else if (this.agencyObj.level === "neighborHood") {
params.neighborHoodId = this.agencyObj.id;
params.agencyId = "";
params.buildingId = "";
params.gridId = "";
} else if (this.agencyObj.level === "building") {
params.buildingId = this.agencyObj.id;
params.agencyId = "";
params.neighborHoodId = "";
params.gridId = "";
} else {
params.agencyId = this.agencyObj.id;
params.buildingId = "";
params.neighborHoodId = "";
params.gridId = "";
}
app.ajax.exportFilePost(
url,
params,
(data, rspMsg) => {
this.download(data, title + ".xls");
this.yihuyidangDisabled = false;
},
(rspMsg, data) => {
this.$message.error(rspMsg);
this.yihuyidangDisabled = false;
}
);
},
// 上传文件之前的钩子
beforeUpload (file) {
this.files = file;
const isText = file.type === "application/vnd.ms-excel";
const isTextComputer =
file.type ===
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
if (!isText && !isTextComputer) {
this.$message.error("请选择正确格式的文件");
return false;
} else {
this.fileName = file.name;
return true;
}
},
// 上传文件个数超过定义的数量
handleExceed (files, fileList) {
this.$message.warning(`当前限制选择 1 个文件,请删除后继续上传`);
},
async uploadFile () {
if (this.fileName == "") {
this.$message.warning("请选择要上传的文件!");
return false;
}
this.$message({
showClose: true,
message: "导入中,请到系统管理-导入记录中查看进度",
duration: 0,
});
//清空上传列表
this.$refs["upload"].clearFiles();
var url = "/actual/base/communityHouse/houseimport";
let fileFormData = new FormData();
fileFormData.append("file", this.files); //filename是键,file是值,就是要传的文件,test.zip是要传的文件名
fileFormData.append("orgId", this.agencyObj.id); //filename是键,file是值,就是要传的文件,test.zip是要传的文件名
fileFormData.append("orgType", this.agencyObj.level); //filename是键,file是值,就是要传的文件,test.zip是要传的文件名
this.importRoomLoading = true;
window.app.ajax.post2(
url,
fileFormData,
(data, rspMsg) => {
if (data.code === 0 && data.msg == "success") {
// this.$message.success('导入成功')
} else {
// this.$message({
// showClose: true,
// message: rspMsg,
// duration: 0,
// type: "error"
// })
// this.$message.error(rspMsg)
}
this.$emit("refreshTree");
this.loadTable();
this.importRoomLoading = false;
},
(rspMsg, data) => {
this.importRoomLoading = false;
},
{ headers: { "Content-Type": "multipart/form-data" } }
);
},
showMessage (msg) {
this.$alert(msg, "操作结果", {
confirmButtonText: "关闭",
callback: (action) => {
this.$emit("refreshTree");
this.loadTable();
},
});
},
handleSizeChange (val) {
this.pageSize = val;
this.pageNo = 1;
this.loadTable();
},
handleCurrentChange (val) {
this.pageNo = val;
this.loadTable();
},
// 开启加载动画
startLoading () {
loading = Loading.service({
lock: true, // 是否锁定
text: "正在加载……", // 加载中需要显示的文字
background: "rgba(0,0,0,.7)", // 背景颜色
});
},
// 结束加载动画
endLoading () {
// clearTimeout(timer);
if (loading) {
loading.close();
}
},
},
watch: {
selection (val) {
if (val.length > 0) {
this.showDeletBtn = true;
} else {
this.showDeletBtn = false;
}
},
'$store.state.sidebarFold': {
handler (newVal, oldVal) {
if (newVal) {//收起
this.searchHeight = 155
} else {
this.searchHeight = 190
}
},
deep: true
}
},
props: {
staffAgencyId: {
type: String,
default: "",
},
showImportBtn: {
type: Boolean,
default: false,
},
ownerName: {
type: String,
default: "",
},
ownerPhone: {
type: String,
default: "",
},
rentFlag: {
type: String,
default: "",
},
purpose: {
type: String,
default: "",
},
remark: {
type: String,
default: "",
},
updateStartDate: {
type: String,
default: "",
},
updateEndDate: {
type: String,
default: "",
},
neighborHoodId: {
type: String,
default: "",
},
buildingId: {
type: String,
default: "",
},
buildingUnitId: {
type: String,
default: "",
},
houseId: {
type: String,
default: "",
},
},
};
</script>
<style lang="scss" scoped >
@import "@/assets/scss/modules/visual/communityManage.scss";
@import "@/assets/scss/modules/management/list-main.scss";
</style>
<style lang="scss" scoped>
.item_width_4 {
width: 120px;
}
/deep/.el-input-number--medium .el-input-number__decrease,
/deep/.el-input-number--medium .el-input-number__increase {
width: 26px;
}
/deep/.el-input-number--medium .el-input__inner {
padding-left: 0px;
padding-right: 0px;
}
</style>