|
@@ -36,9 +36,9 @@ const TopNavigator: React.FC<topNavigatorProps> = ({
|
|
|
}) => {
|
|
|
//存储的 搜索到空间的buildingId floorId
|
|
|
const { searchBuildId, searchFloorId } = useModel('searchInfo');
|
|
|
+ const { lastBuildId, lastFloorId, changeLastBuildId, changeLastFloorId } = useModel('buildFloor');
|
|
|
const [buildList, setBuildList] = useState<buildItem[]>([]);
|
|
|
const [currentBuild, setCurrentBuild] = useState<string>();
|
|
|
-
|
|
|
const [floorList, setFloorList] = useState<floorItem[]>([]);
|
|
|
const [currentFloor, setCurrentFloor] = useState<string>();
|
|
|
|
|
@@ -49,11 +49,14 @@ const TopNavigator: React.FC<topNavigatorProps> = ({
|
|
|
if (searchBuildId !== currentBuild) {
|
|
|
//如果搜索的buildId 改变
|
|
|
setCurrentBuild(searchBuildId);
|
|
|
+ //changeLastBuildId(searchBuildId);
|
|
|
} else {
|
|
|
+ //如果搜索的buildId 没改变 floorId 改变了
|
|
|
//为了 显示楼层选择
|
|
|
setCurrentFloor(searchFloorId);
|
|
|
+ changeLastFloorId(searchFloorId);
|
|
|
//父亲的floorId
|
|
|
- //这块 其实只想楼层id改变时调用 建筑id 改变时不调用
|
|
|
+ //这块 其实只有楼层id改变时调用 建筑id 改变时不调用
|
|
|
changeFloorId && changeFloorId(searchFloorId);
|
|
|
}
|
|
|
}
|
|
@@ -62,37 +65,35 @@ const TopNavigator: React.FC<topNavigatorProps> = ({
|
|
|
//请求建筑的接口
|
|
|
useEffect(() => {
|
|
|
//console.log('TopNavigator----getBuildingList');
|
|
|
- getBuildingList({
|
|
|
- criteria: {
|
|
|
- projectId: projectId,
|
|
|
- },
|
|
|
- orders: [
|
|
|
- {
|
|
|
- column: 'localId',
|
|
|
- asc: true,
|
|
|
+ if (buildList.length == 0) {
|
|
|
+ getBuildingList({
|
|
|
+ criteria: {
|
|
|
+ projectId: projectId,
|
|
|
},
|
|
|
- ],
|
|
|
- }).then((res) => {
|
|
|
- var resData = res.content || [];
|
|
|
- setBuildList(
|
|
|
- (resData || []).map((item) => {
|
|
|
- return { label: item.localName, value: item.id };
|
|
|
- }),
|
|
|
- );
|
|
|
- // var resData2 = [];
|
|
|
- // resData2.push(JSON.parse(JSON.stringify(resData[0])));
|
|
|
- // resData2.push(JSON.parse(JSON.stringify(resData[0])));
|
|
|
- // resData2[1].id = 'sdfsd';
|
|
|
- // resData2[1].localName = 'boruiÎ';
|
|
|
- setBuildList(
|
|
|
- (resData || []).map((item) => {
|
|
|
- return { label: item.localName, value: item.id };
|
|
|
- }),
|
|
|
- );
|
|
|
+ orders: [
|
|
|
+ {
|
|
|
+ column: 'localId',
|
|
|
+ asc: true,
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ }).then((res) => {
|
|
|
+ var resData = res.content || [];
|
|
|
+ setBuildList(
|
|
|
+ (resData || []).map((item) => {
|
|
|
+ return { label: item.localName, value: item.id };
|
|
|
+ }),
|
|
|
+ );
|
|
|
+ // var resData2 = [];
|
|
|
+ // resData2.push(JSON.parse(JSON.stringify(resData[0])));
|
|
|
+ // resData2.push(JSON.parse(JSON.stringify(resData[0])));
|
|
|
+ // resData2[1].id = 'sdfsd';
|
|
|
+ // resData2[1].localName = 'boruiÎ';
|
|
|
|
|
|
- setCurrentBuild((resData[0] || {}).id); //设置第一个建筑值
|
|
|
- changeBuildId && changeBuildId((resData[0] || {}).id);
|
|
|
- });
|
|
|
+ setCurrentBuild(lastBuildId || (resData[0] || {}).id); //设置第一个建筑值
|
|
|
+ //!lastBuildId && changeLastBuildId((resData[0] || {}).id);
|
|
|
+ changeBuildId && changeBuildId(lastBuildId || (resData[0] || {}).id);
|
|
|
+ });
|
|
|
+ }
|
|
|
}, []);
|
|
|
|
|
|
//请求楼层列表的接口
|
|
@@ -115,48 +116,54 @@ const TopNavigator: React.FC<topNavigatorProps> = ({
|
|
|
return { label: item.localName, value: item.id };
|
|
|
}),
|
|
|
);
|
|
|
- //为了 显示楼层选择
|
|
|
- setCurrentFloor(searchFloorId || (resData[0] || {}).id); //如果有搜索的楼层id 则用搜索的结果
|
|
|
- changeFloorId && changeFloorId(searchFloorId || (resData[0] || {}).id); //改变父组件的floorId的值
|
|
|
+ //如果最后选中的
|
|
|
+ var lastFilter = resData.filter((item) => {
|
|
|
+ return item.id == lastFloorId;
|
|
|
+ });
|
|
|
+
|
|
|
+ var lastFloorIdTemp = '';
|
|
|
+ if (lastFilter.length > 0) {
|
|
|
+ lastFloorIdTemp = lastFloorId;
|
|
|
+ }
|
|
|
+ setCurrentFloor(searchFloorId || lastFloorIdTemp || (resData[0] || {}).id); //如果有搜索的楼层id 则用搜索的结果
|
|
|
+ changeLastFloorId(searchFloorId || lastFloorIdTemp || (resData[0] || {}).id);
|
|
|
+
|
|
|
+ changeFloorId && changeFloorId(searchFloorId || lastFloorIdTemp || (resData[0] || {}).id); //改变父组件的floorId的值
|
|
|
}
|
|
|
if (currentBuild) {
|
|
|
+ changeLastBuildId(currentBuild);
|
|
|
asyncFunction();
|
|
|
}
|
|
|
-
|
|
|
- // if (currentBuild) {
|
|
|
- // getFloorList({
|
|
|
- // criteria: {
|
|
|
- // buildingId: currentBuild,
|
|
|
- // //buildingId: 'Bd1101080259317347f00d0811ebb06b1d2749356f83',
|
|
|
- // },
|
|
|
- // }).then((res) => {
|
|
|
- // var resData = res.content || [];
|
|
|
- // setFloorList(
|
|
|
- // (resData || []).map((item) => {
|
|
|
- // return { label: item.localName, value: item.id };
|
|
|
- // }),
|
|
|
- // );
|
|
|
-
|
|
|
- // setCurrentFloor(searchFloorId || (resData[0] || {}).id); //如果有搜索的楼层id 则用搜索的结果
|
|
|
- // changeFloorId && changeFloorId(searchFloorId || (resData[0] || {}).id); //改变父组件的floorId的值
|
|
|
- // });
|
|
|
- // }
|
|
|
}, [currentBuild]);
|
|
|
|
|
|
+ // useEffect(() => {
|
|
|
+ // //为了 显示楼层选择
|
|
|
+ // if (floorList.length > 0) {
|
|
|
+ // debugger;
|
|
|
+ // setCurrentFloor(searchFloorId || lastFloorId || (floorList[0] || {}).value); //如果有搜索的楼层id 则用搜索的结果
|
|
|
+ // changeLastFloorId(searchFloorId || lastFloorId || (floorList[0] || {}).value);
|
|
|
+
|
|
|
+ // changeFloorId && changeFloorId(searchFloorId || lastFloorId || (floorList[0] || {}).value); //改变父组件的floorId的值
|
|
|
+ // }
|
|
|
+ // }, [floorList]);
|
|
|
+
|
|
|
const changBuildHandle = useCallback((val) => {
|
|
|
//console.log('select-onChange', val);
|
|
|
|
|
|
//changeSearchFloorId('');
|
|
|
- //setShishi('fsdf');
|
|
|
+ changeLastFloorId('');
|
|
|
+
|
|
|
//显示的建筑改变
|
|
|
setCurrentBuild(val);
|
|
|
+ //changeLastBuildId(val);
|
|
|
+
|
|
|
//父亲的buildId改变
|
|
|
changeBuildId && changeBuildId(val);
|
|
|
}, []);
|
|
|
|
|
|
const changFloorHandle = useCallback((val) => {
|
|
|
setCurrentFloor(val);
|
|
|
-
|
|
|
+ changeLastFloorId(val);
|
|
|
changeFloorId && changeFloorId(val);
|
|
|
}, []);
|
|
|
|