officehome.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513
  1. import $http from '@/common/request.js'
  2. import config from '@/config'
  3. import store from '@/store/index.js'
  4. import { user } from '@/store/user.js'
  5. function storeUser() {
  6. let userInfo = store.state.user.userInfo
  7. return {
  8. userId: userInfo.userId,
  9. phone: userInfo.phone,
  10. userName: userInfo.name
  11. }
  12. }
  13. function getProjectId() {
  14. let userInfo = store.state.user.userInfo
  15. return userInfo.projectId
  16. }
  17. function commonParams() {
  18. return `openid=${storeUser().userId}&pubname=${
  19. config.brsgServer.pubname
  20. }&projectId=${getProjectId()}&userName=${storeUser().userName}&userPhone=${
  21. storeUser().phone
  22. }&userId=${storeUser().userId}`
  23. }
  24. // 获取地暖
  25. function querySapceFloorHeating(params) {
  26. return $http({
  27. serverSp: config.brsgServer.duoduoUrl,
  28. isNotShowErrorToast: true,
  29. url: `/duoduo-service/duoduoenv-service/ctrl/querySapceFloorHeating?${commonParams()}&spaceId=${params.spaceId}`,
  30. errorSave: true,
  31. method: 'get'
  32. })
  33. }
  34. // 设置设备
  35. function setEquipeHttp(params) {
  36. return $http({
  37. serverSp: config.brsgServer.duoduoUrl,
  38. url: `/server/object/eqp/infocode/set?${commonParams()}`,
  39. method: 'POST',
  40. isNotShowErrorToast: true,
  41. errorSave: true,
  42. data: JSON.stringify(params)
  43. })
  44. }
  45. // 获取设备
  46. function getObjectDataEqpGroupHttp(params) {
  47. return $http({
  48. serverSp: config.brsgServer.duoduoUrl,
  49. url: `/server/object/objectDataEqpGroup/query?${commonParams()}`,
  50. method: 'POST',
  51. isNotShowErrorToast: true,
  52. errorSave: true,
  53. data: JSON.stringify({ ...params })
  54. })
  55. }
  56. // 改变场景
  57. function switchoverSceneHttp(params) {
  58. return $http({
  59. serverSp: config.brsgServer.duoduoUrl,
  60. url: `/server/meeting/room/scene/switchover?${commonParams()}`,
  61. method: 'POST',
  62. isNotShowErrorToast: true,
  63. errorSave: true,
  64. data: JSON.stringify({ ...params, projectId: getProjectId() })
  65. })
  66. }
  67. // 获得空间当前会议室场景
  68. function getMeetingSceneHttp(params) {
  69. return $http({
  70. serverSp: config.brsgServer.duoduoUrl,
  71. url: `/server/meeting/room/scene/getMeetingScene/V2?${commonParams()}&spaceId=${
  72. params.spaceId
  73. }`,
  74. isNotShowErrorToast: true,
  75. errorSave: true,
  76. method: 'get'
  77. })
  78. }
  79. // 获得空间场景
  80. function querySpaceSceneConfigHttp(params) {
  81. return $http({
  82. serverSp: config.brsgServer.duoduoUrl,
  83. url: `/duoduo-service/setup-service/scene/querySpaceSceneConfig?${commonParams()}&spaceId=${
  84. params.spaceId
  85. }`,
  86. isNotShowErrorToast: true,
  87. errorSave: true,
  88. method: 'get'
  89. })
  90. }
  91. // 设备
  92. function getEquipmentListHttp(params) {
  93. return $http({
  94. serverSp: config.brsgServer.duoduoUrl,
  95. url: `/server/object/equipment/findForServe?${commonParams()}&spaceId=${
  96. params.spaceId
  97. }`,
  98. isNotShowErrorToast: true,
  99. errorSave: true,
  100. method: 'POST'
  101. })
  102. }
  103. // set 设备
  104. function setEquipmentHttp(params) {
  105. return $http({
  106. serverSp: config.brsgServer.duoduoUrl,
  107. url: `/server/object/equipment/setRunStatus?${commonParams()}`,
  108. isNotShowErrorToast: true,
  109. errorSave: true,
  110. method: 'POST',
  111. data: JSON.stringify({ ...params, projectId: getProjectId() })
  112. })
  113. }
  114. // 详情页 面积图
  115. function getChartListHTTP(params) {
  116. return $http({
  117. serverSp: config.brsgServer.duoduoUrl,
  118. isNotShowErrorToast: true,
  119. errorSave: true,
  120. url: `/server/spaceAdjust/queryPropertyData?${commonParams()}&spaceId=${
  121. params.spaceId
  122. }&funcid=${params.funcid}`,
  123. method: 'get'
  124. })
  125. }
  126. // 办公空间
  127. function getSpaceAdjustList(params) {
  128. return $http({
  129. serverSp: config.brsgServer.duoduoUrl,
  130. // serverSp: 'http://192.168.0.47:52009',
  131. url: `/server/space/property?${commonParams()}`,
  132. method: 'POST',
  133. isNotShowErrorToast: true,
  134. errorSave: true,
  135. data: JSON.stringify({
  136. ...params,
  137. criteria: { ...params.criteria, projectId: getProjectId() }
  138. })
  139. })
  140. }
  141. // 温度上下限
  142. function getTempRangeHttp() {
  143. return $http({
  144. serverSp: config.brsgServer.duoduoUrl,
  145. url: `/server/space/getTempRange?${commonParams()}`,
  146. isNotShowErrorToast: true,
  147. errorSave: true,
  148. method: 'get'
  149. })
  150. }
  151. // 天气预报
  152. function getWeather() {
  153. return $http({
  154. serverSp: config.brsgServer.duoduoUrl,
  155. isNotShowErrorToast: true,
  156. url: `/duoduo-service/object-service/weather/getCurrentWeather?${commonParams()}`,
  157. errorSave: true,
  158. method: 'get'
  159. })
  160. }
  161. // 空调 - 调节文案/空调信息
  162. function getFeedbackDocumentsHttp(params) {
  163. return $http({
  164. serverSp: config.brsgServer.duoduoUrl,
  165. url: `/server/custom/feedback/documents?${commonParams()}`,
  166. isNotShowErrorToast: true,
  167. errorSave: true,
  168. method: 'POST',
  169. data: JSON.stringify(params)
  170. })
  171. }
  172. // 空调 调节
  173. function changeTempHttp(params) {
  174. return $http({
  175. serverSp: config.brsgServer.duoduoUrl,
  176. url: `/server/custom/feedbackCreate/v2?${commonParams()}`,
  177. method: 'POST',
  178. isNotShowErrorToast: true,
  179. errorSave: true,
  180. data: JSON.stringify({ ...params, projectId: getProjectId() })
  181. })
  182. }
  183. // 手动控制 下发指令
  184. function changeManualTempHttp(params) {
  185. return $http({
  186. serverSp: config.brsgServer.duoduoUrl,
  187. url: `/server/ctrl/set?${commonParams()}`,
  188. method: 'POST',
  189. isNotShowErrorToast: true,
  190. errorSave: true,
  191. data: JSON.stringify(params)
  192. })
  193. }
  194. // 查询空间空调信息
  195. function querySpaceConditioners(params) {
  196. return $http({
  197. serverSp: config.brsgServer.duoduoUrl,
  198. // serverSp: 'http://192.168.0.47:52009',
  199. url: `/server/ctrl/querySpaceConditioners?projectId=${params.projectId}&spaceId=${
  200. params.spaceId
  201. }`,
  202. isNotShowErrorToast: true,
  203. errorSave: true,
  204. method: 'GET'
  205. })
  206. }
  207. // // 空调 调节
  208. // function changeTempHttp(params) {
  209. // return $http({
  210. // serverSp: config.brsgServer.duoduoUrl,
  211. // url: `/server/custom/feedbackCreate?pubname=${config.brsgServer.pubname}&openid=${config.brsgServer.openid}&userName=${storeUser().userName}&userPhone=${storeUser().phone}`,
  212. // method: 'POST',
  213. // data: JSON.stringify(params)
  214. // });
  215. // }
  216. /* 灯的接口 */
  217. // 查询定制时间
  218. function getSetTimeHttp(params) {
  219. return $http({
  220. serverSp: config.brsgServer.duoduoUrl,
  221. url: `/server/customScene/queryCustom?${commonParams()}&spaceId=${
  222. params.spaceId
  223. }`,
  224. isNotShowErrorToast: true,
  225. errorSave: true,
  226. method: 'GET'
  227. })
  228. }
  229. // 更改 定制时间
  230. function changeSetTimeHttp(params) {
  231. params = { ...params, projectId: getProjectId() }
  232. return $http({
  233. serverSp: config.brsgServer.duoduoUrl,
  234. url: `/server/customScene/create?${commonParams()}`,
  235. method: 'POST',
  236. isNotShowErrorToast: true,
  237. errorSave: true,
  238. data: JSON.stringify(params)
  239. })
  240. }
  241. // 灯的状态
  242. function getLampHttp(params) {
  243. return $http({
  244. serverSp: config.brsgServer.duoduoUrl,
  245. url: `/server/light/status/query?${commonParams()}&spaceId=${
  246. params.spaceId
  247. }`,
  248. isNotShowErrorToast: true,
  249. errorSave: true,
  250. method: 'GET'
  251. })
  252. }
  253. // 批量 开关灯
  254. function setallLampHttp(params) {
  255. return $http({
  256. serverSp: config.brsgServer.duoduoUrl,
  257. url: `/server/light/onoff/set?${commonParams()}`,
  258. method: 'POST',
  259. isNotShowErrorToast: true,
  260. errorSave: true,
  261. data: JSON.stringify(params)
  262. })
  263. }
  264. // 全部关闭 关灯 走廊的灯 晚关
  265. function specialLightSetHttp(params) {
  266. return $http({
  267. serverSp: config.brsgServer.duoduoUrl,
  268. url: `/server/light/onoff/specialSet?${commonParams()}`,
  269. method: 'POST',
  270. isNotShowErrorToast: true,
  271. errorSave: true,
  272. data: JSON.stringify(params)
  273. })
  274. }
  275. // 开关失败时 定时查询灯状态
  276. function getStatusHttp(params) {
  277. return $http({
  278. serverSp: config.brsgServer.duoduoUrl,
  279. url: `/server/light/onoff/setSatus?${commonParams()}`,
  280. method: 'POST',
  281. isNotShowErrorToast: true,
  282. errorSave: true,
  283. data: JSON.stringify(params)
  284. })
  285. }
  286. // 插座-列表
  287. function getSocketHttp(params) {
  288. return $http({
  289. serverSp: config.brsgServer.duoduoUrl,
  290. url: `/duoduo-service/duoduoenv-service/ctrl/queryEquipmentStatusInfo?${commonParams()}&spaceId=${
  291. params.spaceId
  292. }&equipType=socket`,
  293. isNotShowErrorToast: true,
  294. errorSave: true,
  295. method: 'GET'
  296. })
  297. }
  298. // 插座-控制
  299. function setSocketHttp(params) {
  300. return $http({
  301. serverSp: config.brsgServer.duoduoUrl,
  302. url: `/duoduo-service/duoduoenv-service/ctrl/set?${commonParams()}`,
  303. method: 'POST',
  304. isNotShowErrorToast: true,
  305. errorSave: true,
  306. data: JSON.stringify(params)
  307. })
  308. }
  309. // 查询是否是过渡季
  310. function getSeasonType(params) {
  311. return $http({
  312. serverSp: config.brsgServer.duoduoUrl,
  313. url: `/duoduo-service/custom-service/custom/getSeasonType?projectId=${params.projectId}&date=${params.date}`,
  314. isNotShowErrorToast: true,
  315. errorSave: true,
  316. method: 'GET'
  317. })
  318. }
  319. // 查询所有空间设备
  320. function queryEquipStatistics(params) {
  321. return $http({
  322. serverSp: config.brsgServer.duoduoUrl,
  323. url: `/duoduo-service/object-service/object/equipment/queryEquipStatistics?projectId=${params.projectId}&floorId=${params.floorId}`,
  324. isNotShowErrorToast: true,
  325. errorSave: true,
  326. method: 'GET'
  327. })
  328. }
  329. // 批量空调 调节
  330. function changeAllAirHttp(params) {
  331. /// duoduoenv.sagacloud.cn/server/custom/feedbackCreate/v2Batch
  332. return $http({
  333. serverSp: config.brsgServer.duoduoUrl,
  334. url: `/server/custom/feedbackCreate/v2Batch?${commonParams()}`,
  335. method: 'POST',
  336. isNotShowErrorToast: true,
  337. errorSave: true,
  338. data: JSON.stringify(params)
  339. })
  340. }
  341. // 批量取消和申请加班
  342. function saveBatchCustomScene(params) {
  343. let paramsArr = JSON.parse(JSON.stringify(params.historyBookList))
  344. paramsArr.find((item) => {
  345. item.customSceneEqType = 'ALL'
  346. if (!item.sceneEquipList) item.sceneEquipList = []
  347. })
  348. if (params.type !== 'workOff' && params.type !== 'delete') {
  349. if (
  350. params.newBooklist &&
  351. params.newBooklist.startTime &&
  352. params.newBooklist.startTime !== ''
  353. ) {
  354. params.newBooklist.projectId = getProjectId()
  355. params.newBooklist.sourceType = config.brsgServer.pubname
  356. params.newBooklist.userId = storeUser().userId
  357. params.newBooklist.userPhone = storeUser().phone
  358. params.newBooklist.userName = storeUser().userName
  359. }
  360. if (paramsArr.length > 0) {
  361. paramsArr.find((item) => {
  362. item.startDate = item.startDate.replace(/-/g, '')
  363. item.endDate = item.startDate
  364. })
  365. }
  366. params.newBooklist && paramsArr.push(params.newBooklist)
  367. }
  368. if (params.type === 'delete') {
  369. paramsArr.find((item) => {
  370. item.startDate = item.startDate.replace(/-/g, '')
  371. item.endDate = item.startDate
  372. item.customSceneEqType = 'ALL'
  373. item.projectId = getProjectId()
  374. item.sourceType = config.brsgServer.pubname
  375. item.userId = storeUser().userId
  376. item.userPhone = storeUser().phone
  377. item.userName = storeUser().userName
  378. })
  379. }
  380. console.log(paramsArr, 'paramsArrparamsArr')
  381. return $http({
  382. serverSp: config.brsgServer.duoduoUrl,
  383. url: `/server/customScene/saveBatchCustomScene?${commonParams()}`,
  384. method: 'POST',
  385. isNotShowErrorToast: true,
  386. errorSave: true,
  387. data: JSON.stringify(paramsArr)
  388. })
  389. }
  390. // 查询加班记录
  391. function queryCustomAndScence(params) {
  392. return $http({
  393. serverSp: config.brsgServer.duoduoUrl,
  394. url: `/server/customScene/queryCustomAndScence?${commonParams()}&spaceId=${
  395. params.spaceId
  396. }`,
  397. method: 'GET',
  398. isNotShowErrorToast: true,
  399. errorSave: true
  400. })
  401. }
  402. // 设置常驻工区
  403. function changeDefaultSpace(params) {
  404. return $http({
  405. serverSp: config.brsgServer.duoduoUrl,
  406. url: `/duoduo-service/setup-service/controlSpaceUser/savePermanentSpace?spaceId=${params}&userId=${storeUser().userId}`,
  407. method: 'GET',
  408. isNotShowErrorToast: true,
  409. errorSave: true
  410. })
  411. }
  412. // 设备运行配置
  413. function queryEquipmentRunConfig(params) {
  414. return $http({
  415. serverSp: config.brsgServer.duoduoUrl,
  416. url: `/duoduo-service/custom-service/equipmentRun/queryEquipmentRunConfig?projectId=${getProjectId()}&spaceId=${params}`,
  417. method: 'GET',
  418. isNotShowErrorToast: true,
  419. errorSave: true
  420. })
  421. }
  422. // ---权限控制---
  423. // 项目控制权限
  424. function queryProjectConfig() {
  425. return $http({
  426. serverSp: config.brsgServer.duoduoUrl,
  427. url: `/duoduo-service/duoduoenv-service/user/permissions/queryProjectConfig?projectId=${getProjectId()}`,
  428. method: 'GET',
  429. isNotShowErrorToast: true,
  430. errorSave: true
  431. })
  432. }
  433. // 空间控制权限
  434. function queryUserControlInfo() {
  435. return $http({
  436. serverSp: config.brsgServer.duoduoUrl,
  437. url: `/duoduo-service/duoduoenv-service/user/permissions/queryUserControlInfo?${commonParams()}`,
  438. method: 'GET',
  439. isNotShowErrorToast: true,
  440. errorSave: true
  441. })
  442. }
  443. // 会议室控制权限
  444. function querySpaceMeetingInfo(params) {
  445. return $http({
  446. serverSp: config.brsgServer.duoduoUrl,
  447. url: `/duoduo-service/duoduoenv-service/meeting/querySpaceMeetingInfo?${commonParams()}`,
  448. method: 'POST',
  449. isNotShowErrorToast: true,
  450. errorSave: true,
  451. data: JSON.stringify(params)
  452. })
  453. }
  454. export {
  455. querySapceFloorHeating,
  456. querySpaceMeetingInfo,
  457. queryUserControlInfo,
  458. queryProjectConfig,
  459. queryEquipmentRunConfig,
  460. setSocketHttp,
  461. getSocketHttp,
  462. queryCustomAndScence,
  463. saveBatchCustomScene,
  464. setEquipeHttp,
  465. getObjectDataEqpGroupHttp,
  466. getFeedbackDocumentsHttp,
  467. getTempRangeHttp,
  468. getStatusHttp,
  469. setallLampHttp,
  470. specialLightSetHttp,
  471. getLampHttp,
  472. changeSetTimeHttp,
  473. getSetTimeHttp,
  474. getSpaceAdjustList,
  475. getWeather,
  476. changeTempHttp,
  477. getChartListHTTP,
  478. getEquipmentListHttp,
  479. setEquipmentHttp,
  480. getMeetingSceneHttp,
  481. querySpaceSceneConfigHttp,
  482. switchoverSceneHttp,
  483. getSeasonType,
  484. queryEquipStatistics,
  485. changeAllAirHttp,
  486. querySpaceConditioners,
  487. changeManualTempHttp,
  488. changeDefaultSpace
  489. }