|
@@ -4,9 +4,11 @@ import cx from 'classnames';
|
|
|
import { Select } from 'antd';
|
|
|
|
|
|
import type { navigatorItem } from '@/pages/Environment/index';
|
|
|
-import { getBuildingList, getFloorList } from '@/services/ant-design-pro/environment';
|
|
|
-import { projectId } from '@/config/api.js';
|
|
|
+import { getBuildingList, getFloorList } from '@/services/sagacare_service/environment';
|
|
|
+import { projectObj } from '@/config/api.js';
|
|
|
import { useModel } from 'umi';
|
|
|
+import UserStorage from '@/config/sagacare_user';
|
|
|
+
|
|
|
export type topNavigatorProps = {
|
|
|
navigatorList?: navigatorItem[];
|
|
|
type: string;
|
|
@@ -35,14 +37,14 @@ const TopNavigator: React.FC<topNavigatorProps> = ({
|
|
|
selParamObj,
|
|
|
}) => {
|
|
|
//存储的 搜索到空间的buildingId floorId
|
|
|
- const { searchBuildId, searchFloorId } = useModel('searchInfo');
|
|
|
+ const { searchBuildId, searchFloorId } = useModel('sagacare_searchInfo');
|
|
|
+ const { lastBuildId, lastFloorId, changeLastBuildId, changeLastFloorId } =
|
|
|
+ useModel('sagacare_buildFloor');
|
|
|
const [buildList, setBuildList] = useState<buildItem[]>([]);
|
|
|
const [currentBuild, setCurrentBuild] = useState<string>();
|
|
|
-
|
|
|
const [floorList, setFloorList] = useState<floorItem[]>([]);
|
|
|
const [currentFloor, setCurrentFloor] = useState<string>();
|
|
|
|
|
|
- //const [shishi, setShishi] = useState<string>('22');
|
|
|
//则监听searchBuildId的改变 如果buildingId改变 请求楼层列表
|
|
|
useEffect(() => {
|
|
|
if (searchBuildId && searchFloorId) {
|
|
@@ -50,10 +52,11 @@ const TopNavigator: React.FC<topNavigatorProps> = ({
|
|
|
//如果搜索的buildId 改变
|
|
|
setCurrentBuild(searchBuildId);
|
|
|
} else {
|
|
|
- //显示
|
|
|
+ //如果搜索的buildId 没改变 floorId 改变了
|
|
|
+ //为了 显示楼层选择
|
|
|
setCurrentFloor(searchFloorId);
|
|
|
//父亲的floorId
|
|
|
- //这块 其实只想楼层id改变时调用 建筑id 改变时不调用
|
|
|
+ //这块 其实只有楼层id改变时调用 建筑id 改变时不调用
|
|
|
changeFloorId && changeFloorId(searchFloorId);
|
|
|
}
|
|
|
}
|
|
@@ -61,38 +64,31 @@ const TopNavigator: React.FC<topNavigatorProps> = ({
|
|
|
|
|
|
//请求建筑的接口
|
|
|
useEffect(() => {
|
|
|
- //console.log('TopNavigator----getBuildingList');
|
|
|
- getBuildingList({
|
|
|
- criteria: {
|
|
|
- projectId: projectId,
|
|
|
- },
|
|
|
- orders: [
|
|
|
- {
|
|
|
- column: 'localId',
|
|
|
- asc: true,
|
|
|
+ var userObj = UserStorage.getInstance();
|
|
|
+ const user = userObj.getUser();
|
|
|
+ console.log('TopNavigator----getBuildingList', user, projectObj.projectId);
|
|
|
+ if (buildList.length == 0) {
|
|
|
+ getBuildingList({
|
|
|
+ criteria: {
|
|
|
+ projectId: projectObj.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 };
|
|
|
- }),
|
|
|
- );
|
|
|
-
|
|
|
- setCurrentBuild((resData[0] || {}).id); //设置第一个建筑值
|
|
|
- changeBuildId && changeBuildId((resData[0] || {}).id);
|
|
|
- });
|
|
|
+ orders: [
|
|
|
+ {
|
|
|
+ column: 'localId',
|
|
|
+ asc: true,
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ }).then((res) => {
|
|
|
+ var resData = res.content || [];
|
|
|
+ setBuildList(
|
|
|
+ (resData || []).map((item) => {
|
|
|
+ return { label: item.localName, value: item.id };
|
|
|
+ }),
|
|
|
+ );
|
|
|
+ setCurrentBuild(lastBuildId || (resData[0] || {}).id); //设置第一个建筑值
|
|
|
+ //changeBuildId && changeBuildId(lastBuildId || (resData[0] || {}).id);
|
|
|
+ });
|
|
|
+ }
|
|
|
}, []);
|
|
|
|
|
|
//请求楼层列表的接口
|
|
@@ -115,47 +111,47 @@ const TopNavigator: React.FC<topNavigatorProps> = ({
|
|
|
return { label: item.localName, value: item.id };
|
|
|
}),
|
|
|
);
|
|
|
+ //如果最后选中的
|
|
|
+ var lastFilter = resData.filter((item) => {
|
|
|
+ return item.id == lastFloorId;
|
|
|
+ });
|
|
|
|
|
|
- setCurrentFloor(searchFloorId || (resData[0] || {}).id); //如果有搜索的楼层id 则用搜索的结果
|
|
|
- changeFloorId && changeFloorId(searchFloorId || (resData[0] || {}).id); //改变父组件的floorId的值
|
|
|
+ var lastFloorIdTemp = '';
|
|
|
+ if (lastFilter.length > 0) {
|
|
|
+ lastFloorIdTemp = lastFloorId;
|
|
|
+ }
|
|
|
+ setCurrentFloor(searchFloorId || lastFloorIdTemp || (resData[0] || {}).id); //如果有搜索的楼层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的值
|
|
|
- // });
|
|
|
- // }
|
|
|
+ //console.log('currentBuild22', currentBuild);
|
|
|
+ return () => {
|
|
|
+ //console.log('currentBuild111', currentBuild);
|
|
|
+ };
|
|
|
}, [currentBuild]);
|
|
|
|
|
|
- const changBuildHandle = useCallback((val) => {
|
|
|
- //console.log('select-onChange', val);
|
|
|
+ // useEffect(() => {
|
|
|
+ // //为了 显示楼层选择
|
|
|
+ // if (floorList.length > 0) {
|
|
|
+ // debugger;
|
|
|
+ // setCurrentFloor(searchFloorId || lastFloorId || (floorList[0] || {}).value); //如果有搜索的楼层id 则用搜索的结果
|
|
|
+ // changeFloorId && changeFloorId(searchFloorId || lastFloorId || (floorList[0] || {}).value); //改变父组件的floorId的值
|
|
|
+ // }
|
|
|
+ // }, [floorList]);
|
|
|
|
|
|
- //changeSearchFloorId('');
|
|
|
- //setShishi('fsdf');
|
|
|
+ const changBuildHandle = useCallback((val) => {
|
|
|
//显示的建筑改变
|
|
|
setCurrentBuild(val);
|
|
|
//父亲的buildId改变
|
|
|
- changeBuildId && changeBuildId(val);
|
|
|
+ //changeBuildId && changeBuildId(val);
|
|
|
}, []);
|
|
|
+
|
|
|
const changFloorHandle = useCallback((val) => {
|
|
|
setCurrentFloor(val);
|
|
|
-
|
|
|
changeFloorId && changeFloorId(val);
|
|
|
}, []);
|
|
|
|
|
@@ -200,7 +196,7 @@ const TopNavigator: React.FC<topNavigatorProps> = ({
|
|
|
className={cx(styles.navItem, { [styles.sel]: item.id === selParamObj.id })}
|
|
|
style={{
|
|
|
borderBottom:
|
|
|
- item.id === selParamObj.id ? `3px solid ${item.color}` : '3px solid #ffffff',
|
|
|
+ item.id === selParamObj.id ? `3px solid ${item.color}` : '3px solid #fff',
|
|
|
}}
|
|
|
key={'nav' + index}
|
|
|
onClick={() => {
|