officehome.js 13 KB

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