bigScreen.ts 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. import { appconfig } from '@/config/bigScreenConfig'
  2. import { GetUserInitData } from '@/api/APIs'
  3. const initConfig = JSON.parse(JSON.stringify(appconfig.bigScreenMapSettings.gisResource))
  4. const groupPageInfo = () => {
  5. return {
  6. //集团、分公司信息
  7. groupProject: [],
  8. groupName: null,
  9. groupCodeValue: null,
  10. isShowGroupPage: null,
  11. //头部
  12. projectTreeData: null,
  13. currentMenuItem: null,//下拉切换
  14. }
  15. }
  16. const projectInfo = () => {
  17. return {
  18. //初始范围
  19. initView: {
  20. destination: { x: -2002099.8064685483, y: 5125053.48587751, z: 3240386.7848629407 },
  21. orientation: {
  22. heading: 6.241173904929705,
  23. pitch: -0.3248275425737035,
  24. roll: 6.283185307179586
  25. }
  26. },
  27. //三维图层
  28. sceneLayerList: [
  29. 'NETWORK_SJ_PSWS@sxgk#1',
  30. 'NETWORK_SJ_PSYS@sxgk#1',
  31. 'NETWORK_SJ_PSWS_Node@sxgk#1',
  32. 'NETWORK_SJ_PSYS_Node@sxgk#1',
  33. 'TF_SJ_PSYS_JG_B_3D@sxgk#1',
  34. 'TF_SJ_PSYS_JG_B_3D@sxgk#2',
  35. 'TF_SJ_PSWS_JG_B_3D@sxgk#2',
  36. 'TF_SJ_PSWS_JG_B_3D@sxgk#1'
  37. ],
  38. //解决点击冲突
  39. isClickingPipe: false,
  40. //地图配置信息
  41. tdttoken: '75293e320524bb2be0a5f14fa887e46f',
  42. mapConfig: null,
  43. isInitViewer: false,//三维场景是否初始化
  44. mapContainerId: '',//地图容器Id
  45. //项目级信息
  46. currentPrjId: null,
  47. currentProjectInfo: null,//当前项目信息
  48. currentProjectCode: null,
  49. currentActive: null,//项目当前激活模块
  50. customToolList: [],//自定义工具激活集合
  51. currentTool: '',//当前激活工具
  52. currentPipeInfo: null,//部件查看当前部件信息
  53. isShowPipeSpeedInfoCheck: false,//显示进度查看弹窗
  54. monitorTreeCheckHistory: null,//设备监测树历史记录
  55. currentDeviceShow: null,//当前查看设备
  56. isShowExcavationAnalysis: false,//显示开挖分析窗体
  57. isShowSearchBox: false,//显示搜索栏
  58. //-->统计分析模块
  59. currentStatisticalActive: null,
  60. statisticalAnalysisInfo: null,
  61. //-->智慧预警模块
  62. wisdomWarningInfo: null
  63. }
  64. }
  65. const state = { ...groupPageInfo(), ...projectInfo() }
  66. //检查是否存在已有数据方法
  67. function some(arr, str) {
  68. const result = arr.some((item) => {
  69. if (item.name === str) {
  70. return true
  71. }
  72. })
  73. return result
  74. }
  75. function delOne(arr, str) {
  76. return arr.filter(item => item.name !== str)
  77. }
  78. const mutations = {
  79. //地图资源设置
  80. SET_GISSOURCE: (state, payload) => {
  81. state.mapConfig = payload
  82. },
  83. //项目信息设置
  84. SET_PROJECTTREEDATA: (state, payload) => {
  85. state.projectTreeData = payload
  86. state.currentMenuItem = payload[0]
  87. },
  88. //部件查看设置
  89. Active_PipeUnitInfo: (state, data) => {
  90. },
  91. Deactive_PipeUnitInfo: (state, data) => {
  92. },
  93. //项目级工具集设置
  94. SET_TOOL: (state, data) => {
  95. state.currentTool = data.name
  96. if (!some(state.customToolList, data.name)) {
  97. state.customToolList.push(data)
  98. } else {
  99. state.customToolList = state.customToolList.slice()
  100. }
  101. },
  102. DEL_TOOL: (state, data) => {
  103. state.customToolList = delOne(state.customToolList, data)
  104. if (state.customToolList.length > 0) {
  105. state.currentTool = state.customToolList[state.customToolList.length - 1].name
  106. }
  107. },
  108. DEL_ALLTOOL: (state) => {
  109. state.customToolList = []
  110. },
  111. RESET_Project: (state) => {
  112. Object.assign(state, projectInfo())
  113. },
  114. RESET_ALL: (state) => {
  115. Object.assign(state, { ...groupPageInfo(), ...projectInfo() })
  116. }
  117. }
  118. function isEmpty(obj) {
  119. if (Object.keys(obj).length === 0) return true
  120. else return false
  121. }
  122. function short(key) {
  123. return key.substring(key.indexOf("_") + 1, key.length)
  124. }
  125. const actions = {
  126. //数据服务资源替换
  127. initGISResource({ commit, state }) {
  128. return new Promise((resolve, reject) => {
  129. GetUserInitData({ platform: 1 }).then(res => {
  130. debugger
  131. //重置GIS资源值
  132. Object.keys(appconfig.bigScreenMapSettings.gisResource).forEach(item => appconfig.bigScreenMapSettings.gisResource[item].config = {})
  133. const result = res.result.progisresource.find(e => e.code == `groupPageMapService_${state.currentProjectCode}`)
  134. if (!result) {
  135. commit('SET_GISSOURCE', appconfig.bigScreenMapSettings);
  136. return resolve(appconfig.bigScreenMapSettings);
  137. }
  138. let mapSource = appconfig.bigScreenMapSettings.gisResource
  139. let terrain = {}, img = {}, scenes = {}, maps = {},
  140. tiplayers = {}, geometry = {}, theme = {}
  141. result.config.forEach(item => {
  142. if (item.key.indexOf('terrain') != -1) terrain[short(item.key)] = { "name": item.name, "url": item.url }
  143. if (item.key.indexOf('tiled') != -1) img[short(item.key)] = { "name": item.name, "url": item.url }
  144. if (item.key.indexOf('scene') != -1) scenes[short(item.key)] = { "name": item.name, "url": item.url, ...item }
  145. if (item.key.indexOf('map') != -1) maps[short(item.key)] = { "name": item.name, "url": item.url }
  146. if (item.key.indexOf('data') != -1) tiplayers[short(item.key)] = { "name": item.name, "url": item.url }
  147. if (item.key.indexOf('spatialanalyst') != -1) geometry[short(item.key)] = { "name": item.name, "url": item.url }
  148. if (item.key.indexOf('theme') != -1) theme[short(item.key)] = { "name": item.name, "url": item.url, ...item }
  149. });
  150. Object.keys(mapSource).forEach(item => {
  151. switch (mapSource[item].type) {
  152. case "terrain": if (!isEmpty(terrain)) mapSource[item].config = terrain; break;
  153. case "tiled": if (!isEmpty(img)) mapSource[item].config = img; break;
  154. case "scene": if (!isEmpty(scenes)) mapSource[item].config = scenes; break;
  155. case "map": if (!isEmpty(maps)) mapSource[item].config = maps; break;
  156. case "data": if (!isEmpty(tiplayers)) mapSource[item].config = tiplayers; break;
  157. case "spatialanalyst": if (!isEmpty(geometry)) mapSource[item].config = geometry; break;
  158. case "theme": if (!isEmpty(theme)) mapSource[item].config = theme; break;
  159. }
  160. })
  161. appconfig.bigScreenMapSettings.gisResource = mapSource
  162. commit('SET_GISSOURCE', appconfig.bigScreenMapSettings);
  163. resolve(appconfig.bigScreenMapSettings);
  164. }).catch(err => {
  165. reject(err)
  166. })
  167. })
  168. },
  169. //设置项目列表
  170. setProjectTreeData({ commit }, value) {
  171. commit('SET_PROJECTTREEDATA', value)
  172. },
  173. //部件查看使用时功能启动
  174. activePipeUnitInfo({ commit, state }) {
  175. },
  176. //部件查看使用时功能结束
  177. deactivePipeUnitInfo({ commit, state }) {
  178. },
  179. // 添加工具集
  180. changeToolList({ commit, state }, value) {
  181. commit('SET_TOOL', value)
  182. },
  183. //移除工具集
  184. removeSingleTool({ commit, state }, value) {
  185. commit('DEL_TOOL', value)
  186. },
  187. //移除所有工具
  188. removeAllTool({ commit, state }, value) {
  189. commit('DEL_ALLTOOL', value)
  190. },
  191. //重置项目state数据
  192. resetProjectState({ commit, state }, value) {
  193. commit('RESET_Project', value)
  194. },
  195. //重置state数据
  196. resetState({ commit, state }, value) {
  197. commit('RESET_ALL', value)
  198. },
  199. }
  200. export default {
  201. namespaced: true,
  202. state,
  203. mutations,
  204. actions
  205. }