DataAnalysis.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. <template>
  2. <DashboardLayout>
  3. <!-- 天气 -->
  4. <template #header-left>
  5. <WeatherWidget />
  6. </template>
  7. <!-- 日期 -->
  8. <template #header-right>
  9. <DateTimeWidget />
  10. </template>
  11. <template #left>
  12. <!-- 左侧Tab菜单栏 -->
  13. <TechTabs v-model="activeLeftTab" type="underline">
  14. <TechTabPane label="总览" name="overview" class="menu-scroll-view">
  15. <MenuItem theme="tech" v-for="item in menuData" :key="item.id" :node="item" :level="0"
  16. @node-click="handleMenuClick" />
  17. </TechTabPane>
  18. <TechTabPane label="路口" name="crossing" class="menu-scroll-view">
  19. <MenuItem theme="tech" v-for="item in menuData" :key="item.id" :node="item" :level="0"
  20. @node-click="handleMenuClick" />
  21. </TechTabPane>
  22. <TechTabPane label="干线" name="trunkLine" class="menu-scroll-view">
  23. <MenuItem v-for="item in menuData" :key="item.id" :node="item" :level="0"
  24. @node-click="handleMenuClick" />
  25. </TechTabPane>
  26. <TechTabPane label="特勤" name="specialDuty" class="menu-scroll-view">
  27. <MenuItem v-for="item in menuData" :key="item.id" :node="item" :level="0"
  28. @node-click="handleMenuClick" />
  29. </TechTabPane>
  30. </TechTabs>
  31. </template>
  32. <template #right>
  33. </template>
  34. <template #center>
  35. <!-- 地图 -->
  36. <TongzhouTrafficMap amapKey="db2da7e3e248c3b2077d53fc809be63f"
  37. securityJsCode="a7413c674852c5eaf01d90813c5b7ef6" />
  38. </template>
  39. <template #dialogs>
  40. <SmartDialog ref="dialogs" v-for="dialog in activeDialogs" :key="dialog.id" :id="dialog.id" :visible.sync="dialog.visible"
  41. :title="dialog.title" :defaultWidth="dialog.width || 400" :defaultHeight="dialog.height || 300"
  42. :center="dialog.center !== false" :position="dialog.position" :showClose="dialog.showClose"
  43. @close="handleDialogClose(dialog.id)">
  44. <component :is="dialog.componentName" v-bind="dialog.data"></component>
  45. </SmartDialog>
  46. </template>
  47. </DashboardLayout>
  48. </template>
  49. <script>
  50. import DashboardLayout from '@/layouts/DashboardLayout.vue';
  51. import WeatherWidget from '@/components/ui/WeatherWidget.vue';
  52. import DateTimeWidget from '@/components/ui/DateTimeWidget.vue';
  53. import TechTabs from '@/components/ui/TechTabs.vue';
  54. import TechTabPane from '@/components/ui/TechTabPane.vue';
  55. import TongzhouTrafficMap from '@/components/TongzhouTrafficMap.vue';
  56. import SmartDialog from '@/components/ui/SmartDialog.vue';
  57. import MenuItem from '@/components/ui/MenuItem.vue';
  58. import TrafficTimeSpace from '@/components/ui/TrafficTimeSpace.vue';
  59. import { makeTrafficTimeSpaceData } from '@/mock/data';
  60. export default {
  61. name: "HomePage",
  62. components: {
  63. DashboardLayout,
  64. WeatherWidget,
  65. DateTimeWidget,
  66. TechTabs,
  67. TechTabPane,
  68. SmartDialog,
  69. TongzhouTrafficMap,
  70. MenuItem,
  71. TrafficTimeSpace
  72. },
  73. data() {
  74. return {
  75. // 弹窗相关数据
  76. activeDialogs: [],
  77. // 左侧边栏数据
  78. activeLeftTab: 'overview',
  79. menuData: [
  80. {
  81. id: 'root-1',
  82. label: '主控中心',
  83. icon: 'el-icon-monitor', // 这里可以替换为你项目用的图标类名,比如 iconfont
  84. children: [
  85. {
  86. id: 'team-1',
  87. label: '北京市交警总队',
  88. children:
  89. [
  90. {
  91. id: 'dist-1',
  92. label: '通州区',
  93. children: [
  94. {
  95. id: 'street-1',
  96. label: '中仓街道',
  97. children: [
  98. { id: 'node-1', label: '新华东街 - 新华南路' },
  99. { id: 'node-2', label: '玉带河东街 - 车站路' },
  100. { id: 'node-3', label: '赵登禹大街 - 新华东街' }
  101. ]
  102. },
  103. {
  104. id: 'street-2',
  105. label: '新华街道',
  106. children: [
  107. { id: 'node-4', label: '新华南北街交叉口' },
  108. { id: 'node-5', label: '通胡大街 - 紫运中路' },
  109. { id: 'node-6', label: '芙蓉东路 - 通胡大街' }
  110. ]
  111. },
  112. {
  113. id: 'street-3',
  114. label: '北苑街道',
  115. children: [
  116. { id: 'node-7', label: '北苑路口' },
  117. { id: 'node-8', label: '新华西街 - 北苑南路' },
  118. { id: 'node-9', label: '新城南街 - 新华西街' }
  119. ]
  120. },
  121. {
  122. id: 'street-4',
  123. label: '玉桥街道',
  124. children: [
  125. { id: 'node-10', label: '玉桥西路 - 玉桥西里中街' },
  126. { id: 'node-11', label: '运河西大街 - 玉桥中路' },
  127. { id: 'node-12', label: '梨园南街 - 运河西大街' }
  128. ]
  129. },
  130. {
  131. id: 'street-5',
  132. label: '杨庄街道',
  133. children: [
  134. { id: 'node-13', label: '怡乐中街 - 九棵树西路' },
  135. { id: 'node-14', label: '翠屏西路 - 怡乐中街' },
  136. { id: 'node-15', label: '杨庄路 - 新华西街' }
  137. ]
  138. },
  139. {
  140. id: 'street-6',
  141. label: '九棵树街道',
  142. children: [
  143. { id: 'node-16', label: '九棵树东路 - 九棵树西路' },
  144. { id: 'node-17', label: '云景东路 - 九棵树东路' },
  145. { id: 'node-18', label: '群芳南街 - 云景东路' }
  146. ]
  147. },
  148. {
  149. id: 'street-7',
  150. label: '临河里街道',
  151. children: [
  152. { id: 'node-19', label: '梨园中街 - 九棵树东路' },
  153. { id: 'node-20', label: '临河里路 - 梨园中街' },
  154. { id: 'node-21', label: '万盛南街 - 临河里路' }
  155. ]
  156. },
  157. {
  158. id: 'street-8',
  159. label: '潞邑街道',
  160. children: [
  161. { id: 'node-22', label: '潞苑北大街 - 潞邑西路' },
  162. { id: 'node-23', label: '潞苑南大街 - 潞邑三路' },
  163. { id: 'node-24', label: '东六环 - 潞苑北大街' }
  164. ]
  165. },
  166. {
  167. id: 'street-9',
  168. label: '通运街道',
  169. children: [
  170. { id: 'node-25', label: '通胡大街 - 东六环' },
  171. { id: 'node-26', label: '运河东大街 - 通胡大街' },
  172. { id: 'node-27', label: '紫运中路 - 运河东大街' }
  173. ]
  174. },
  175. {
  176. id: 'street-10',
  177. label: '潞源街道',
  178. children: [
  179. { id: 'node-28', label: '宋梁路 - 运河东大街' },
  180. { id: 'node-29', label: '东六环 - 运河东大街' },
  181. { id: 'node-30', label: '潞源北街 - 宋梁路' }
  182. ]
  183. },
  184. {
  185. id: 'street-11',
  186. label: '文景街道',
  187. children: [
  188. { id: 'node-31', label: '环球大道 - 九棵树东路' },
  189. { id: 'node-32', label: '颐瑞东路 - 环球大道' },
  190. { id: 'node-33', label: '万盛南街 - 颐瑞东路' }
  191. ]
  192. }
  193. ]
  194. }
  195. ]
  196. }
  197. ]
  198. }
  199. ]
  200. };
  201. },
  202. created() {
  203. },
  204. mounted() {
  205. },
  206. methods: {
  207. handleMenuClick(nodeData) {
  208. console.log('父组件接收到了最底层路口点击事件:', nodeData);
  209. // 这里可以根据 nodeData 的经纬度来控制地图组件的视角
  210. this.testOpenSecurityRoute(nodeData);
  211. },
  212. openDialog(config) {
  213. // 1. 检查这个弹窗是否已经在数组中了
  214. const existingDialog = this.activeDialogs.find(
  215. d => String(d.id) === String(config.id)
  216. );
  217. if (existingDialog) {
  218. existingDialog.visible = true;
  219. this.$nextTick(() => {
  220. if (this.$refs.dialogs) {
  221. const dialogRefs = Array.isArray(this.$refs.dialogs)
  222. ? this.$refs.dialogs
  223. : [this.$refs.dialogs];
  224. const targetComponent = dialogRefs.find(
  225. vm => String(vm.id) === String(config.id)
  226. );
  227. if (targetComponent) {
  228. targetComponent.bringToFront();
  229. if (typeof targetComponent.playShake === 'function') {
  230. targetComponent.playShake();
  231. }
  232. } else {
  233. console.warn('没找到对应弹窗:', config.id);
  234. }
  235. }
  236. });
  237. return;
  238. }
  239. // 2. 如果不存在,则 push 一个新的弹窗对象进去
  240. this.activeDialogs.push({
  241. id: config.id, // 唯一标识 (例如路口ID 'node-101')
  242. title: config.title, // 弹窗左上角标题
  243. componentName: config.component, // 要加载的内部组件名
  244. visible: true, // 默认可见
  245. width: config.width || 450, // 自定义宽度
  246. height: config.height || 300, // 自定义高度
  247. center: config.center !== false, // 是否居中显示
  248. position: config.position || null, // 自定义坐标 {x, y}
  249. showClose: config.showClose !== false, // 是否显示关闭按钮
  250. data: config.data || {} // 传给内部组件的业务数据
  251. });
  252. window.dispatchEvent(new Event('resize'));
  253. },
  254. /**
  255. * 关闭弹窗的回调
  256. */
  257. handleDialogClose(dialogId) {
  258. // 性能优化:当用户点击 ✕ 关闭弹窗时,将其从数组中彻底移除,销毁内部组件释放内存
  259. this.activeDialogs = this.activeDialogs.filter(d => d.id !== dialogId);
  260. },
  261. // ================= 测试用例:模拟各种点击行为 =================
  262. // 模拟 1:打开特勤安保路线面板
  263. testOpenSecurityRoute(data) {
  264. this.openDialog({
  265. id: data.id, // 这里的 ID 可以根据实际业务场景动态生成,例如 'dev-security-route' 代表特勤安保路线弹窗
  266. title: data.label,
  267. component: 'TrafficTimeSpace',
  268. width: 1000,
  269. height: 500,
  270. center: true,
  271. showClose: true,
  272. // position: { x: 400, y: 450 },
  273. data: makeTrafficTimeSpaceData(),
  274. });
  275. },
  276. }
  277. }
  278. </script>
  279. <style scoped></style>