|
@@ -2,23 +2,13 @@
|
|
|
<view class="facility">
|
|
<view class="facility">
|
|
|
<wd-sticky :z-index="10">
|
|
<wd-sticky :z-index="10">
|
|
|
<view class="facility-top">
|
|
<view class="facility-top">
|
|
|
- <wd-search :placeholder-left="true" placeholder="请输入内容" v-model="state.text">
|
|
|
|
|
- <template #suffix>
|
|
|
|
|
- <view style="display: flex;align-items: center;margin: 0 20rpx;">
|
|
|
|
|
- <wd-button size="small" @click="onClickSearch">
|
|
|
|
|
- 搜索
|
|
|
|
|
- </wd-button>
|
|
|
|
|
- </view>
|
|
|
|
|
- </template>
|
|
|
|
|
- </wd-search>
|
|
|
|
|
- <wd-tabs slidable="always" v-model="state.tabValue" @change="onChangeTabs">
|
|
|
|
|
- <wd-tab v-for="(item, index) in state.tabList" :title="item.label" :name="item.value" :key="index" />
|
|
|
|
|
- </wd-tabs>
|
|
|
|
|
|
|
+ <wd-picker placeholder="请选择分类" :columns="state.columns" v-model="state.pickerValue"
|
|
|
|
|
+ :columnChange="onChangeClassify" @confirm="onClickConfirm" @clear="onClickClear" :clearable="true" />
|
|
|
</view>
|
|
</view>
|
|
|
</wd-sticky>
|
|
</wd-sticky>
|
|
|
<view class="facility-list">
|
|
<view class="facility-list">
|
|
|
<view class="facility-list-item" v-for="(item, index) in state.list" :key="index"
|
|
<view class="facility-list-item" v-for="(item, index) in state.list" :key="index"
|
|
|
- @click="onClickNavigate(item.id)">
|
|
|
|
|
|
|
+ @click="onClickNavigate(item.facilitiesId)">
|
|
|
<view class="facility-list-item-sign">
|
|
<view class="facility-list-item-sign">
|
|
|
{{ item.sign }}
|
|
{{ item.sign }}
|
|
|
</view>
|
|
</view>
|
|
@@ -42,14 +32,27 @@ import { onShow, onReachBottom } from '@dcloudio/uni-app';
|
|
|
import { apis } from '@/apis';
|
|
import { apis } from '@/apis';
|
|
|
|
|
|
|
|
interface State {
|
|
interface State {
|
|
|
- text?: string,
|
|
|
|
|
- tabList: {
|
|
|
|
|
- label: string,
|
|
|
|
|
- value: string,
|
|
|
|
|
|
|
+ facilitySearchList: {
|
|
|
|
|
+ positionId: string,
|
|
|
|
|
+ positionName: string,
|
|
|
|
|
+ communityId: string,
|
|
|
|
|
+ roomId: string,
|
|
|
|
|
+ regionList: {
|
|
|
|
|
+ regionId: string,
|
|
|
|
|
+ regionName: string,
|
|
|
|
|
+ positionId: string,
|
|
|
|
|
+ }[],
|
|
|
}[],
|
|
}[],
|
|
|
- tabValue?: string,
|
|
|
|
|
|
|
+ columns: any[],
|
|
|
|
|
+ pickerValue: string[],
|
|
|
|
|
+ query: Partial<{
|
|
|
|
|
+ positionId: string,
|
|
|
|
|
+ communityId: string,
|
|
|
|
|
+ roomId: string,
|
|
|
|
|
+ regionId: string,
|
|
|
|
|
+ }>,
|
|
|
list: {
|
|
list: {
|
|
|
- id: string,
|
|
|
|
|
|
|
+ facilitiesId: string,
|
|
|
url: string,
|
|
url: string,
|
|
|
sign: string,
|
|
sign: string,
|
|
|
title: string,
|
|
title: string,
|
|
@@ -63,9 +66,15 @@ interface State {
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
const state = reactive<State>({
|
|
const state = reactive<State>({
|
|
|
- text: undefined,
|
|
|
|
|
- tabList: [],
|
|
|
|
|
- tabValue: undefined,
|
|
|
|
|
|
|
+ facilitySearchList: [],
|
|
|
|
|
+ columns: [],
|
|
|
|
|
+ pickerValue: [],
|
|
|
|
|
+ query: {
|
|
|
|
|
+ positionId: undefined,
|
|
|
|
|
+ communityId: undefined,
|
|
|
|
|
+ roomId: undefined,
|
|
|
|
|
+ regionId: undefined,
|
|
|
|
|
+ },
|
|
|
list: [],
|
|
list: [],
|
|
|
page: {
|
|
page: {
|
|
|
pageNumber: 1,
|
|
pageNumber: 1,
|
|
@@ -75,21 +84,45 @@ const state = reactive<State>({
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
const api = {
|
|
const api = {
|
|
|
- // 获取区域列表
|
|
|
|
|
- fetchRegionList: async () => {
|
|
|
|
|
|
|
+ // 获取设施检索列表
|
|
|
|
|
+ fetchFacilitySearchList: async () => {
|
|
|
try {
|
|
try {
|
|
|
- const data = {
|
|
|
|
|
- dictType: 'region_type',
|
|
|
|
|
- };
|
|
|
|
|
- const res = await apis.fetchRegionList(data);
|
|
|
|
|
- const list = res.rows.map((item: any) => {
|
|
|
|
|
|
|
+ const res = await apis.fetchFacilitySearchList();
|
|
|
|
|
+ state.facilitySearchList = res.data.filter((item: any) => item.regionList);
|
|
|
|
|
+
|
|
|
|
|
+ const positionList = state.facilitySearchList.map(item => {
|
|
|
return {
|
|
return {
|
|
|
- label: item.dictLabel,
|
|
|
|
|
- value: item.dictValue,
|
|
|
|
|
|
|
+ label: item.positionName,
|
|
|
|
|
+ value: item.positionId,
|
|
|
|
|
+ communityId: item.communityId,
|
|
|
|
|
+ roomId: item.roomId,
|
|
|
|
|
+ regionList: item.regionList,
|
|
|
|
|
+ };
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ let regionList: { label: string, value: string }[] = [];
|
|
|
|
|
+
|
|
|
|
|
+ if (state.pickerValue) {
|
|
|
|
|
+ const positionId = state.pickerValue[0];
|
|
|
|
|
+ const item = positionList.find(item => item.value === positionId);
|
|
|
|
|
+ if (item) {
|
|
|
|
|
+ regionList = item.regionList.map(item => {
|
|
|
|
|
+ return {
|
|
|
|
|
+ label: item.regionName,
|
|
|
|
|
+ value: item.regionId,
|
|
|
|
|
+ };
|
|
|
|
|
+ });
|
|
|
}
|
|
}
|
|
|
- });
|
|
|
|
|
- state.tabList = list;
|
|
|
|
|
- state.tabValue = list.length ? list[0].value : undefined;
|
|
|
|
|
|
|
+ } else {
|
|
|
|
|
+ regionList = positionList[0].regionList.map(item => {
|
|
|
|
|
+ return {
|
|
|
|
|
+ label: item.regionName,
|
|
|
|
|
+ value: item.regionId,
|
|
|
|
|
+ };
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ state.columns = [positionList, regionList];
|
|
|
} catch (error: any) {
|
|
} catch (error: any) {
|
|
|
console.error(error);
|
|
console.error(error);
|
|
|
}
|
|
}
|
|
@@ -101,16 +134,15 @@ const api = {
|
|
|
});
|
|
});
|
|
|
try {
|
|
try {
|
|
|
const data = {
|
|
const data = {
|
|
|
- facilitiesTitle: state.text,
|
|
|
|
|
- dictType: state.tabValue,
|
|
|
|
|
|
|
+ ...state.query,
|
|
|
pageNum: state.page.pageNumber,
|
|
pageNum: state.page.pageNumber,
|
|
|
pageSize: state.page.pageSize,
|
|
pageSize: state.page.pageSize,
|
|
|
};
|
|
};
|
|
|
const res = await apis.fetchFacilityList(data);
|
|
const res = await apis.fetchFacilityList(data);
|
|
|
const list = res.rows.map((item: any) => {
|
|
const list = res.rows.map((item: any) => {
|
|
|
return {
|
|
return {
|
|
|
- id: item.facilitiesId,
|
|
|
|
|
- url: item.sysimg[0].url,
|
|
|
|
|
|
|
+ facilitiesId: item.facilitiesId,
|
|
|
|
|
+ url: item.sysimg ? item.sysimg[0].url : '',
|
|
|
sign: item.facilitiesName,
|
|
sign: item.facilitiesName,
|
|
|
title: item.facilitiesTitle,
|
|
title: item.facilitiesTitle,
|
|
|
description: item.facilitiesDesc,
|
|
description: item.facilitiesDesc,
|
|
@@ -130,39 +162,50 @@ const api = {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
const init = async () => {
|
|
const init = async () => {
|
|
|
- // 获取区域列表
|
|
|
|
|
- await api.fetchRegionList();
|
|
|
|
|
|
|
+ // 获取设施检索列表
|
|
|
|
|
+ await api.fetchFacilitySearchList();
|
|
|
// 获取设施列表
|
|
// 获取设施列表
|
|
|
await api.fetchFacilityList();
|
|
await api.fetchFacilityList();
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
onShow(() => {
|
|
onShow(() => {
|
|
|
|
|
+ const roomInfo = uni.getStorageSync('roomInfo');
|
|
|
|
|
+ if (roomInfo) {
|
|
|
|
|
+ state.pickerValue = [roomInfo.positionId, roomInfo.regionId];
|
|
|
|
|
+ state.query = roomInfo;
|
|
|
|
|
+ }
|
|
|
state.page = {
|
|
state.page = {
|
|
|
...state.page,
|
|
...state.page,
|
|
|
pageNumber: 1,
|
|
pageNumber: 1,
|
|
|
};
|
|
};
|
|
|
|
|
+ uni.removeStorageSync('roomInfo');
|
|
|
init();
|
|
init();
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
-// 更改分页
|
|
|
|
|
-const onChangePagination = async () => {
|
|
|
|
|
- const { pageNumber, pageSize, total } = state.page;
|
|
|
|
|
- if (total > pageNumber * pageSize) {
|
|
|
|
|
- state.page = {
|
|
|
|
|
- ...state.page,
|
|
|
|
|
- pageNumber: pageNumber + 1,
|
|
|
|
|
- }
|
|
|
|
|
- // 获取设施列表
|
|
|
|
|
- await api.fetchFacilityList(true);
|
|
|
|
|
|
|
+// 更改分类
|
|
|
|
|
+const onChangeClassify = (pickerView: any, value: any, columnIndex: number, resolve: Function) => {
|
|
|
|
|
+ if (columnIndex === 0) {// 修改定位时-更新区域
|
|
|
|
|
+ const regionList = value[columnIndex].regionList.map((item: any) => {
|
|
|
|
|
+ return {
|
|
|
|
|
+ label: item.regionName,
|
|
|
|
|
+ value: item.regionId,
|
|
|
|
|
+ };
|
|
|
|
|
+ })
|
|
|
|
|
+ pickerView.setColumnData(1, regionList);
|
|
|
}
|
|
}
|
|
|
|
|
+ resolve();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-onReachBottom(() => {
|
|
|
|
|
- onChangePagination();
|
|
|
|
|
-});
|
|
|
|
|
-
|
|
|
|
|
-// 点击搜索
|
|
|
|
|
-const onClickSearch = async () => {
|
|
|
|
|
|
|
+const onClickConfirm = async (value: any) => {
|
|
|
|
|
+ const list = value.selectedItems;
|
|
|
|
|
+ const { value: positionId, communityId, roomId } = list[0];
|
|
|
|
|
+ const { value: regionId } = list[1];
|
|
|
|
|
+ state.query = {
|
|
|
|
|
+ positionId: positionId,
|
|
|
|
|
+ communityId: communityId,
|
|
|
|
|
+ roomId: roomId,
|
|
|
|
|
+ regionId: regionId,
|
|
|
|
|
+ }
|
|
|
state.page = {
|
|
state.page = {
|
|
|
...state.page,
|
|
...state.page,
|
|
|
pageNumber: 1,
|
|
pageNumber: 1,
|
|
@@ -171,9 +214,13 @@ const onClickSearch = async () => {
|
|
|
await api.fetchFacilityList();
|
|
await api.fetchFacilityList();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// 更改标签页
|
|
|
|
|
-const onChangeTabs = async ({ name }: { name: string }) => {
|
|
|
|
|
- state.tabValue = name;
|
|
|
|
|
|
|
+const onClickClear = async () => {
|
|
|
|
|
+ state.query = {
|
|
|
|
|
+ positionId: undefined,
|
|
|
|
|
+ communityId: undefined,
|
|
|
|
|
+ roomId: undefined,
|
|
|
|
|
+ regionId: undefined,
|
|
|
|
|
+ }
|
|
|
state.page = {
|
|
state.page = {
|
|
|
...state.page,
|
|
...state.page,
|
|
|
pageNumber: 1,
|
|
pageNumber: 1,
|
|
@@ -182,10 +229,27 @@ const onChangeTabs = async ({ name }: { name: string }) => {
|
|
|
await api.fetchFacilityList();
|
|
await api.fetchFacilityList();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+// 更改分页
|
|
|
|
|
+const onChangePagination = async () => {
|
|
|
|
|
+ const { pageNumber, pageSize, total } = state.page;
|
|
|
|
|
+ if (total > pageNumber * pageSize) {
|
|
|
|
|
+ state.page = {
|
|
|
|
|
+ ...state.page,
|
|
|
|
|
+ pageNumber: pageNumber + 1,
|
|
|
|
|
+ }
|
|
|
|
|
+ // 获取设施列表
|
|
|
|
|
+ await api.fetchFacilityList(true);
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+onReachBottom(() => {
|
|
|
|
|
+ onChangePagination();
|
|
|
|
|
+});
|
|
|
|
|
+
|
|
|
// 点击跳转
|
|
// 点击跳转
|
|
|
-const onClickNavigate = (id: string) => {
|
|
|
|
|
|
|
+const onClickNavigate = (facilitiesId: string) => {
|
|
|
uni.navigateTo({
|
|
uni.navigateTo({
|
|
|
- url: `/pages/facility/facilityDetail/index?id=${id}`,
|
|
|
|
|
|
|
+ url: `/pages/facility/facilityDetail/index?facilitiesId=${facilitiesId}`,
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
</script>
|
|
</script>
|