import React, { useEffect, useMemo, useState, useCallback } from 'react'; import { getSpaceAdjustArray } from '@/services/sagacare_service/environment'; import { projectObj } from '@/config/api'; export default function () { const allFunc = { office: ['140', '311', '312', '310'], work: ['300', '314', '313', '315', '921', '922', '923', '924', '925', '926'], meeting: ['321', '322', '323'], rest: ['170', '331', '931', '932', '933', '934', '935', '936', '937', '938'], //休闲 device: [ '211', '212', '221', '222', '223', '231', '232', '233', '234', '235', '236', '237', '241', '242', '243', '244', '245', '251', '252', '253', '254', ], //设备 washroom: ['111', '112'], //卫生间 lift: ['130', '120'], //电梯 stair: ['140'], //楼梯 dining: ['441', '442', '443', '451', '452', '453', '461', '462', '471', '472'], //用餐 public: ['100', '1A0', '0'], //公共 sport: ['690', '932', '934'], //运动 swim: ['933', '6A0'], reception: ['331', '160'], //接待 book: ['935'], //图书馆 activity: ['936', '937', '938', '915'], //活动 学生活动室等 experiment: ['921', '922', '923', '920', '926', '924', '925'], //实验室 cloth: ['112'], //更衣室 control: ['243', '332'], //中控 值班室 }; //获取房间类型 来显示相应的图片 const getSpaceFunc = useCallback((spaceCode: any) => { //var nowkey = 'device'; var flag = false; for (var key in allFunc) { var codeArr = allFunc[key]; if (codeArr.indexOf(spaceCode) > -1) { flag = true; return key; } } return ''; }, []); const [hasPersonList, setHasPersonList] = useState([]); const querySpaceAdjustList = useCallback((selFloorId) => { getSpaceAdjustArray( { criteria: { projectId: projectObj.projectId, floorId: selFloorId, }, }, {}, ).then(function (res) { var resList = res.content || []; setHasPersonList(resList); }); }, []); return { getSpaceFunc, hasPersonList, querySpaceAdjustList, }; }