Commit 4d5b2d635a5ef0ec2c9148587017d4ce7b1d6947

Authored by 杨泽宇
2 parents 23fe20ae 4b9bd0f9
src/views/community/housekeeper/index.vue
1 <script setup lang="ts"> 1 <script setup lang="ts">
2 import { reactive, onMounted, ref, getCurrentInstance, watchEffect } from "vue"; 2 import { reactive, onMounted, ref, getCurrentInstance, watchEffect } from "vue";
3 import { getTableList, deleteBuilding } from "@/api/community/housekeeper.ts"; 3 import { getTableList, deleteBuilding } from "@/api/community/housekeeper.ts";
  4 +import * as residence from "@/api/community/residence.ts";
4 import { parseTime } from "@/utils/tool.ts"; 5 import { parseTime } from "@/utils/tool.ts";
5 import HouseDetail from "./houseDetail.vue"; 6 import HouseDetail from "./houseDetail.vue";
6 import ChangeAdmin from "./changeAdmin.vue"; 7 import ChangeAdmin from "./changeAdmin.vue";
@@ -29,6 +30,7 @@ const data = reactive({ @@ -29,6 +30,7 @@ const data = reactive({
29 loading: false, 30 loading: false,
30 title: "新增楼宇", 31 title: "新增楼宇",
31 formObj: {}, 32 formObj: {},
  33 + communityList: [],
32 }); 34 });
33 // 更换楼管相关数据属性 35 // 更换楼管相关数据属性
34 const changeObj = reactive({ 36 const changeObj = reactive({
@@ -53,6 +55,17 @@ const search = (): void =&gt; { @@ -53,6 +55,17 @@ const search = (): void =&gt; {
53 data.loading = false; 55 data.loading = false;
54 }); 56 });
55 }; 57 };
  58 +
  59 +/**
  60 + * 小区下拉列表查询
  61 + */
  62 +const getSelectList = (): void => {
  63 + residence.getTableList({ page: 1, pageSize: 10000, type: 0 }).then((res) => {
  64 + console.log(res);
  65 + data.communityList = res.data.data.list;
  66 + });
  67 +};
  68 +
56 /** 69 /**
57 * 编辑 70 * 编辑
58 * @param { Object } 列表对象 71 * @param { Object } 列表对象
@@ -94,7 +107,6 @@ const changeData: void = () =&gt; { @@ -94,7 +107,6 @@ const changeData: void = () =&gt; {
94 * 弹框关闭 107 * 弹框关闭
95 */ 108 */
96 const dialogClose: void = () => { 109 const dialogClose: void = () => {
97 - console.log(111);  
98 data.title = "新增楼宇"; 110 data.title = "新增楼宇";
99 data.formObj = {}; 111 data.formObj = {};
100 houseDetailRef.value.resetForm(); 112 houseDetailRef.value.resetForm();
@@ -141,15 +153,34 @@ watchEffect(() =&gt; { @@ -141,15 +153,34 @@ watchEffect(() =&gt; {
141 search(); 153 search();
142 } 154 }
143 }); 155 });
  156 +
  157 +onMounted(() => {
  158 + getSelectList();
  159 +});
144 </script> 160 </script>
145 161
146 <template> 162 <template>
147 <div class="app-container"> 163 <div class="app-container">
148 <!-- 搜索 --> 164 <!-- 搜索 -->
149 <el-form :inline="true" :model="searchData" @submit.native.prevent> 165 <el-form :inline="true" :model="searchData" @submit.native.prevent>
  166 + <el-form-item prop="neighborhoodId">
  167 + <el-select
  168 + v-model="searchData.neighborhoodId"
  169 + placeholder="请选择所属小区"
  170 + clearable
  171 + >
  172 + <el-option
  173 + v-for="item in data.communityList"
  174 + :key="item.id"
  175 + :label="item.name"
  176 + :value="item.id"
  177 + >
  178 + </el-option>
  179 + </el-select>
  180 + </el-form-item>
150 <el-form-item> 181 <el-form-item>
151 <el-input 182 <el-input
152 - placeholder="请输入楼宇名称/楼管姓名" 183 + placeholder="请输入楼管姓名"
153 v-model="searchData.name" 184 v-model="searchData.name"
154 clearable 185 clearable
155 ></el-input> 186 ></el-input>
@@ -183,22 +214,44 @@ watchEffect(() =&gt; { @@ -183,22 +214,44 @@ watchEffect(() =&gt; {
183 <span>{{ scope.row.neighborhood.name }}</span></template 214 <span>{{ scope.row.neighborhood.name }}</span></template
184 > 215 >
185 </el-table-column> 216 </el-table-column>
186 - <el-table-column label="楼宇名称" prop="buildingName" align="center"></el-table-column>  
187 - <el-table-column label="单元数" prop="unitCount" align="center"></el-table-column>  
188 - <el-table-column label="总房屋数量" prop="houseCount" align="center"></el-table-column> 217 + <el-table-column
  218 + label="楼宇名称"
  219 + prop="buildingName"
  220 + align="center"
  221 + ></el-table-column>
  222 + <el-table-column
  223 + label="单元数"
  224 + prop="unitCount"
  225 + align="center"
  226 + ></el-table-column>
  227 + <el-table-column
  228 + label="总房屋数量"
  229 + prop="houseCount"
  230 + align="center"
  231 + ></el-table-column>
189 <el-table-column label="建成日期" prop="createTime"> 232 <el-table-column label="建成日期" prop="createTime">
190 <template #default="scope"> 233 <template #default="scope">
191 - <span>{{ parseTime(new Date(scope.row.createTime).getTime()).split(' ')[0].split('-')[0] }}</span> 234 + <span>{{
  235 + parseTime(new Date(scope.row.createTime).getTime())
  236 + .split(" ")[0]
  237 + .split("-")[0]
  238 + }}</span>
192 </template> 239 </template>
193 </el-table-column> 240 </el-table-column>
194 <el-table-column label="建筑面积" prop="grossArea" align="center"> 241 <el-table-column label="建筑面积" prop="grossArea" align="center">
195 - <template #default="scope">  
196 - <span>{{ [0,null].includes(scope.row.grossArea) ?'--':scope.row.grossArea }}</span> 242 + <template #default="scope">
  243 + <span>{{
  244 + [0, null].includes(scope.row.grossArea) ? "--" : scope.row.grossArea
  245 + }}</span>
197 </template> 246 </template>
198 </el-table-column> 247 </el-table-column>
199 <el-table-column label="使用面积" prop="employArea" align="center"> 248 <el-table-column label="使用面积" prop="employArea" align="center">
200 - <template #default="scope">  
201 - <span>{{ [0,null].includes(scope.row.employArea) ?'--':scope.row.employArea }}</span> 249 + <template #default="scope">
  250 + <span>{{
  251 + [0, null].includes(scope.row.employArea)
  252 + ? "--"
  253 + : scope.row.employArea
  254 + }}</span>
202 </template> 255 </template>
203 </el-table-column> 256 </el-table-column>
204 <el-table-column label="楼管姓名" align="center"> 257 <el-table-column label="楼管姓名" align="center">
@@ -214,7 +267,7 @@ watchEffect(() =&gt; { @@ -214,7 +267,7 @@ watchEffect(() =&gt; {
214 <router-link 267 <router-link
215 :to="{ 268 :to="{
216 name: 'houses', 269 name: 'houses',
217 - query: { buildingId: scope.row.id }, 270 + query: { buildingId: scope.row.id,neighborhoodId: scope.row.neighborhoodId},
218 }" 271 }"
219 > 272 >
220 <el-button type="text" size="mini" class="btn">房屋管理</el-button> 273 <el-button type="text" size="mini" class="btn">房屋管理</el-button>
src/views/community/houses/index.vue
1 <script setup lang="ts"> 1 <script setup lang="ts">
2 import { reactive, onMounted, getCurrentInstance, watchEffect } from "vue"; 2 import { reactive, onMounted, getCurrentInstance, watchEffect } from "vue";
3 import { getTableList, deleteHouse, getHouse } from "@/api/community/houses.ts"; 3 import { getTableList, deleteHouse, getHouse } from "@/api/community/houses.ts";
  4 +import * as residence from "@/api/community/residence.ts";
  5 +import * as housekeeper from "@/api/community/housekeeper.ts";
4 import { parseTime } from "@/utils/tool.ts"; 6 import { parseTime } from "@/utils/tool.ts";
5 import Detail from "./detail.vue"; 7 import Detail from "./detail.vue";
6 import BuildOwner from "./buildOwner.vue"; 8 import BuildOwner from "./buildOwner.vue";
@@ -18,6 +20,7 @@ const searchData = reactive({ @@ -18,6 +20,7 @@ const searchData = reactive({
18 roomNumber: null, 20 roomNumber: null,
19 page: 1, 21 page: 1,
20 pageSize: 10, 22 pageSize: 10,
  23 + neighborhoodId: null,
21 }); 24 });
22 // 展示 25 // 展示
23 const data = reactive({ 26 const data = reactive({
@@ -27,6 +30,8 @@ const data = reactive({ @@ -27,6 +30,8 @@ const data = reactive({
27 loading: false, 30 loading: false,
28 title: "房屋详情", 31 title: "房屋详情",
29 formObj: {}, 32 formObj: {},
  33 + communityList: [],
  34 + buildingList: [],
30 }); 35 });
31 // 绑定业主相关变量 36 // 绑定业主相关变量
32 const build = reactive({ 37 const build = reactive({
@@ -61,6 +66,37 @@ const search = (): void =&gt; { @@ -61,6 +66,37 @@ const search = (): void =&gt; {
61 data.loading = false; 66 data.loading = false;
62 }); 67 });
63 }; 68 };
  69 +
  70 +/**
  71 + * 小区下拉列表查询
  72 + */
  73 +const getSelectList = (): void => {
  74 + residence.getTableList({ page: 1, pageSize: 10000, type: 0 }).then((res) => {
  75 + data.communityList = res.data.data.list;
  76 + });
  77 +};
  78 +
  79 +/**
  80 + * 监听小区改变
  81 + */
  82 +const getHousekeeper = (event: Event): void => {
  83 + if (event) {
  84 + housekeeper
  85 + .getTableList({
  86 + page: 1,
  87 + pageSize: 10000,
  88 + type: 0,
  89 + neighborhoodId: event,
  90 + })
  91 + .then((res) => {
  92 + data.buildingList = res.data.data.list;
  93 + searchData.buildingId = data.buildingList[0].id;
  94 + });
  95 + } else {
  96 + data.buildingList = [];
  97 + searchData.buildingId = null;
  98 + }
  99 +};
64 /** 100 /**
65 * 详情 101 * 详情
66 * @param { number } houseId 房屋ID 102 * @param { number } houseId 房屋ID
@@ -118,15 +154,52 @@ const down = () =&gt; { @@ -118,15 +154,52 @@ const down = () =&gt; {
118 watchEffect(() => { 154 watchEffect(() => {
119 if (route.path == "/houses") { 155 if (route.path == "/houses") {
120 searchData.buildingId = route.query.buildingId ?? null; 156 searchData.buildingId = route.query.buildingId ?? null;
  157 + searchData.neighborhoodId = route.query.neighborhoodId?Number(route.query.neighborhoodId) : null;
  158 + getHousekeeper(route.query.neighborhoodId);
121 search(); 159 search();
122 } 160 }
123 }); 161 });
  162 +
  163 +onMounted(() => {
  164 + getSelectList();
  165 +});
124 </script> 166 </script>
125 167
126 <template> 168 <template>
127 <div class="app-container"> 169 <div class="app-container">
128 <!-- 搜索 --> 170 <!-- 搜索 -->
129 <el-form :inline="true" :model="searchData" @submit.native.prevent> 171 <el-form :inline="true" :model="searchData" @submit.native.prevent>
  172 + <el-form-item prop="neighborhoodId">
  173 + <el-select
  174 + v-model="searchData.neighborhoodId"
  175 + placeholder="请选择所属小区"
  176 + @change="getHousekeeper"
  177 + clearable
  178 + >
  179 + <el-option
  180 + v-for="item in data.communityList"
  181 + :key="item.id"
  182 + :label="item.name"
  183 + :value="item.id"
  184 + >
  185 + </el-option>
  186 + </el-select>
  187 + </el-form-item>
  188 + <el-form-item prop="buildingId">
  189 + <el-select
  190 + v-model="searchData.buildingId"
  191 + placeholder="请选择楼宇"
  192 + clearable
  193 + >
  194 + <el-option
  195 + v-for="item in data.buildingList"
  196 + :key="item.id"
  197 + :label="item.buildingName"
  198 + :value="item.id"
  199 + >
  200 + </el-option>
  201 + </el-select>
  202 + </el-form-item>
130 <el-form-item> 203 <el-form-item>
131 <el-input 204 <el-input
132 placeholder="请输入房间号" 205 placeholder="请输入房间号"
@@ -134,6 +207,7 @@ watchEffect(() =&gt; { @@ -134,6 +207,7 @@ watchEffect(() =&gt; {
134 clearable 207 clearable
135 ></el-input> 208 ></el-input>
136 </el-form-item> 209 </el-form-item>
  210 +
137 <el-form-item 211 <el-form-item
138 ><el-button type="primary" @click="search" 212 ><el-button type="primary" @click="search"
139 >查询</el-button 213 >查询</el-button
@@ -161,8 +235,16 @@ watchEffect(() =&gt; { @@ -161,8 +235,16 @@ watchEffect(() =&gt; {
161 <span>{{ scope.row.building?.buildingName }}</span></template 235 <span>{{ scope.row.building?.buildingName }}</span></template
162 > 236 >
163 </el-table-column> 237 </el-table-column>
164 - <el-table-column label="单元" prop="unitNumber" align="center"></el-table-column>  
165 - <el-table-column label="房间号" prop="roomNumber" align="center"></el-table-column> 238 + <el-table-column
  239 + label="单元"
  240 + prop="unitNumber"
  241 + align="center"
  242 + ></el-table-column>
  243 + <el-table-column
  244 + label="房间号"
  245 + prop="roomNumber"
  246 + align="center"
  247 + ></el-table-column>
166 <el-table-column label="建筑面积" prop="grossArea" align="center"> 248 <el-table-column label="建筑面积" prop="grossArea" align="center">
167 <template #default="scope"> 249 <template #default="scope">
168 <span>{{ 250 <span>{{