5 changed files with 243 additions and 7 deletions
@ -0,0 +1,238 @@ |
|||
<template> |
|||
<div class="app-container"> |
|||
<el-form :inline="true" :model="queryParams" class="demo-form-inline"> |
|||
<el-form-item label="小区公寓" prop="deptId"> |
|||
<treeselect |
|||
v-model="queryParams.apartmentId" |
|||
:options="deptOptions" |
|||
:show-count="true" |
|||
:normalizer="normalizer" |
|||
placeholder="请选择所在区域" |
|||
style="width: 220px" |
|||
@select="handleTreeSelect" |
|||
:disable-branch-nodes="true" |
|||
/> |
|||
</el-form-item> |
|||
<!-- 楼号 --> |
|||
<el-form-item label="楼栋" prop="building"> |
|||
<el-select |
|||
v-model="queryParams.buildingId" |
|||
placeholder="请选择楼栋" |
|||
@change="handleChangeBuildingId" |
|||
> |
|||
<el-option |
|||
v-for="item in buildingOptions" |
|||
:key="item.id" |
|||
:label="item.name" |
|||
:value="item.id" |
|||
/> |
|||
</el-select> |
|||
</el-form-item> |
|||
<!-- 单元 --> |
|||
<el-form-item label="单元" prop="unit"> |
|||
<el-select |
|||
v-model="queryParams.unitId" |
|||
placeholder="请选择单元" |
|||
@change="handleChangeUnitId" |
|||
> |
|||
<el-option |
|||
v-for="item in unitOptions" |
|||
:key="item.id" |
|||
:label="item.name" |
|||
:value="item.id" |
|||
/> |
|||
</el-select> |
|||
</el-form-item> |
|||
<!-- 状态 --> |
|||
<el-form-item label="入住情况" prop="status"> |
|||
<el-select v-model="queryParams.status" placeholder="请选择状态"> |
|||
<el-option label="未入住" value="0" /> |
|||
<el-option label="已入住" value="1" /> |
|||
</el-select> |
|||
</el-form-item> |
|||
<el-form-item> |
|||
<el-button |
|||
type="primary" |
|||
icon="el-icon-search" |
|||
size="mini" |
|||
@click="handleQuery" |
|||
>搜索</el-button |
|||
> |
|||
</el-form-item> |
|||
</el-form> |
|||
<div class="flex"> |
|||
<div |
|||
:class="{ idle: item.state === 0, flex_item: true }" |
|||
v-for="(item, index) in list" |
|||
:key="index" |
|||
> |
|||
<el-tooltip |
|||
placement="top" |
|||
:content=" |
|||
item.apartmentName + ' ' + item.buildingName + ' ' + item.unitName |
|||
" |
|||
> |
|||
<template #content> |
|||
{{ item.apartmentName }} {{ item.buildingName }} {{ item.unitName }} |
|||
</template> |
|||
<div class="top"> |
|||
{{ item.apartmentName }} {{ item.buildingName }} {{ item.unitName }} |
|||
</div> |
|||
</el-tooltip> |
|||
<div class="center"> |
|||
<span class="num">{{ item.houseName }}</span> |
|||
<span>{{ item.typeName }}</span> |
|||
</div> |
|||
<div>{{ item.stateName }} {{ item.limitName }}</div> |
|||
</div> |
|||
</div> |
|||
<pagination |
|||
v-show="total > 0" |
|||
:total="total" |
|||
:page.sync="queryParams.pageNum" |
|||
:limit.sync="queryParams.pageSize" |
|||
@pagination="getList" |
|||
:layout="'prev,pager,next'" |
|||
/> |
|||
</div> |
|||
</template> |
|||
<script> |
|||
import { listHouseLive } from "@/api/mz/house"; |
|||
import { listDept } from "@/api/system/dept"; |
|||
import { queryDeptDropdownList } from "@/api/mz/rec"; |
|||
import Treeselect from "@riophae/vue-treeselect"; |
|||
import "@riophae/vue-treeselect/dist/vue-treeselect.css"; |
|||
export default { |
|||
name: "realTimeHousingResources", |
|||
data() { |
|||
return { |
|||
list: [], |
|||
total: 0, |
|||
queryParams: { |
|||
pageNum: 1, |
|||
pageSize: 35, |
|||
apartmentId: null, // 小区 |
|||
buildingId: "", // 楼栋 |
|||
unitId: "", // 单元 |
|||
status: "", // 状态 |
|||
}, |
|||
buildingOptions: [], // 楼栋 |
|||
unitOptions: [], // 单元 |
|||
deptOptions: [], // 小区 |
|||
}; |
|||
}, |
|||
components: { |
|||
Treeselect, |
|||
}, |
|||
created() { |
|||
this.getList(); |
|||
this.getDeptTree(); |
|||
}, |
|||
methods: { |
|||
getList() { |
|||
listHouseLive(this.queryParams).then((res) => { |
|||
this.list = res.rows; |
|||
this.total = res.total; |
|||
}); |
|||
}, |
|||
async handleTreeSelect(val) { |
|||
this.queryParams.apartmentId = val.deptId; |
|||
this.queryParams.buildingId = null; |
|||
this.queryParams.unitId = null; |
|||
this.houseOptions = []; |
|||
this.buildingOptions = await this.getListByParentId("2", val.deptId); |
|||
}, |
|||
async handleChangeBuildingId(val) { |
|||
this.queryParams.buildingId = val; |
|||
this.queryParams.unitId = null; |
|||
this.houseOptions = []; |
|||
this.unitOptions = await this.getListByParentId(3, val); |
|||
}, |
|||
async handleChangeUnitId(val) { |
|||
this.queryParams.unitId = val; |
|||
}, |
|||
// 三级联动通用接口 |
|||
getListByParentId(type, id) { |
|||
return new Promise((resolve, reject) => { |
|||
queryDeptDropdownList({ type, id }).then((res) => { |
|||
resolve(res.data); |
|||
}); |
|||
}); |
|||
}, |
|||
/** 查询公寓下拉树结构 */ |
|||
getDeptTree() { |
|||
listDept().then((response) => { |
|||
this.deptOptions = this.handleTree( |
|||
response.data, |
|||
"deptId", |
|||
"parentId", |
|||
"children", |
|||
3 |
|||
); |
|||
}); |
|||
}, |
|||
handleQuery() { |
|||
this.queryParams.pageNum = 1; |
|||
this.getList(); |
|||
}, |
|||
/** 转换公寓数据结构 */ |
|||
normalizer(node) { |
|||
if (node.children && !node.children.length) { |
|||
delete node.children; |
|||
} |
|||
return { |
|||
id: node.deptId, |
|||
label: node.deptName, |
|||
children: node.children, |
|||
}; |
|||
}, |
|||
}, |
|||
watch:{ |
|||
'queryParams.apartmentId': { |
|||
handler(newVal, oldVal) { |
|||
console.log('newVal',newVal); |
|||
if(!newVal) |
|||
this.queryParams.buildingId = null; |
|||
this.queryParams.unitId = null; |
|||
this.apartmentOptions = []; |
|||
this.buildingOptions = []; |
|||
this.unitOptions = []; |
|||
}, |
|||
deep: true, |
|||
immediate: true |
|||
} |
|||
} |
|||
}; |
|||
</script> |
|||
<style lang="scss" scoped> |
|||
.flex { |
|||
gap: 10px; |
|||
flex-wrap: wrap; |
|||
.flex_item { |
|||
padding: 10px; |
|||
background: #ececec; |
|||
text-align: center; |
|||
.top { |
|||
width: 210px; |
|||
overflow: hidden; |
|||
text-overflow: ellipsis; |
|||
white-space: nowrap; |
|||
} |
|||
.center { |
|||
margin: 10px 0; |
|||
font-size: 20px; |
|||
display: flex; |
|||
justify-content: center; |
|||
.num { |
|||
font-size: 28px; |
|||
font-weight: bold; |
|||
margin-right: 5px; |
|||
} |
|||
} |
|||
} |
|||
.idle { |
|||
background: #1684ff; |
|||
color: #fff; |
|||
} |
|||
} |
|||
</style> |
Loading…
Reference in new issue