TrunkCoordination.vue 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820
  1. <template>
  2. <DashboardLayout ref="layout" layoutClass="special-situation-monitoring">
  3. <template #header-left>
  4. </template>
  5. <template #header-right>
  6. <!-- 日期 -->
  7. <DateTimeWidget />
  8. </template>
  9. <template #map>
  10. <!-- 路口列表 -->
  11. <div v-if="currentView === 'list-mode' && activeLeftTab === 'crossing'" class="list-mode-panel">
  12. <CrossingListPanel :onViewDetail="handleCrossingViewDetail"/>
  13. </div>
  14. <!-- 地图 -->
  15. <TongzhouTrafficMap v-else ref="trafficMapRef"
  16. :mode="activeLeftTab === 'crossing' ? '路口' : activeLeftTab === 'trunkLine' ? '干线' : activeLeftTab === 'specialDuty' ? '特勤' : ''"
  17. :search-offset-right="570"
  18. @map-crossing-click="handleMapCrossingClick"
  19. @map-crossing-mouseover="handleMapCrossingMouseover"
  20. @map-crossing-mouseout="handleMapCrossingMouseout"
  21. @bindTrunkMenuTree="handleTrunkMenuUpdate"
  22. />
  23. </template>
  24. <template #left>
  25. <div class="left-sidebar-wrap">
  26. <div class="left-sidebar-title">干线协调</div>
  27. <div class="left-sidebar-body">
  28. <div v-if="trunkLineMenuData.length === 0" class="sidebar-loading">加载中...</div>
  29. <template v-else>
  30. <MenuItem v-for="item in trunkLineMenuData" :key="item.id" :node="item" :level="0"
  31. @node-click="handleTrunkLineClick">
  32. <template #label="{ node }">
  33. <span v-if="node.children && node.children.length > 0">{{ node.label }}</span>
  34. <span v-else>{{ node.label }} 绿波带</span>
  35. </template>
  36. </MenuItem>
  37. </template>
  38. </div>
  39. </div>
  40. </template>
  41. <template #right>
  42. <!-- 模式切换按钮组 -->
  43. <div class="mode-switch" v-if="activeLeftTab === 'crossing'">
  44. <ButtonGroup v-model="currentView" :options="viewOptions" @select="onViewSelect" />
  45. </div>
  46. </template>
  47. <template #center>
  48. <!-- 顶部常驻图表区域(替代弹窗) -->
  49. <div class="top-charts-bar" v-if="currentView !== 'list-mode'">
  50. <!-- 总览Tab -->
  51. <template v-if="activeLeftTab === 'overview'">
  52. <div class="top-chart-box overview-chart-box">
  53. <OnlineStatusTabs :deviceData="onlineStatusData" />
  54. </div>
  55. <div class="top-chart-box overview-chart-box">
  56. <DeviceStatusTabs :statusData="deviceFaultData" />
  57. </div>
  58. </template>
  59. <!-- 路口Tab -->
  60. <template v-if="activeLeftTab === 'crossing'">
  61. <div class="top-chart-box overview-chart-box">
  62. <OnlineStatusTabs :deviceData="onlineStatusData" />
  63. </div>
  64. <div class="top-chart-box overview-chart-box">
  65. <DeviceStatusTabs :statusData="deviceFaultData" />
  66. </div>
  67. </template>
  68. </div>
  69. </template>
  70. </DashboardLayout>
  71. </template>
  72. <script>
  73. import DashboardLayout from '@/layouts/DashboardLayout.vue';
  74. import DateTimeWidget from '@/components/ui/DateTimeWidget.vue';
  75. import TongzhouTrafficMap from '@/components/TongzhouTrafficMap.vue';
  76. import MenuItem from '@/components/ui/MenuItem.vue';
  77. import ButtonGroup from '@/components/ui/ButtonGroup.vue';
  78. import CrossingListPanel from '@/components/ui/CrossingListPanel.vue';
  79. import OnlineStatusTabs from '@/components/ui/OnlineStatusTabs.vue';
  80. import DeviceStatusTabs from '@/components/ui/DeviceStatusTabs.vue';
  81. import { apiGetTongzhouMenuTree, apiGetTasks, apiGetTrafficTimeSpace, apiGetCrossingTopCharts, apiGetSpecialTaskMonitorData, apiGetCrossingDetailData, apiGetDeviceStatus, apiGetDeviceFaultStatus } from '@/api';
  82. export default {
  83. name: "TrunkCoordination",
  84. components: {
  85. DashboardLayout,
  86. DateTimeWidget,
  87. TongzhouTrafficMap,
  88. MenuItem,
  89. ButtonGroup,
  90. CrossingListPanel,
  91. OnlineStatusTabs,
  92. DeviceStatusTabs,
  93. },
  94. data() {
  95. return {
  96. // 左侧边栏数据
  97. activeLeftTab: 'trunkLine', // 默认选中干线Tab
  98. menuData: [],
  99. trunkLineMenuData: [],
  100. // 地图模式切换数据
  101. currentView: 'map-mode',
  102. viewOptions: [
  103. { label: '列表模式', value: 'list-mode' },
  104. { label: '地图模式', value: 'map-mode' },
  105. ],
  106. // 特勤表头
  107. tableColumns: [
  108. { label: '序号', key: 'id', width: '10%' },
  109. { label: '名称', key: 'name', width: '30%' },
  110. { label: '执行人', key: 'executor', width: '15%' },
  111. { label: '等级', key: 'level', width: '12%' },
  112. { label: '状态', key: 'status', width: '13%' },
  113. { label: '操作', key: 'action', width: '20%' }
  114. ],
  115. tableData: [],
  116. // 路口顶部图表数据
  117. crossingTopCharts: {},
  118. // 路口多选分屏
  119. crossingSelections: [],
  120. maxCrossingSlots: 4,
  121. // 在线状态 & 设备状态数据
  122. onlineStatusData: null,
  123. deviceFaultData: null,
  124. };
  125. },
  126. watch: {
  127. // 监听路由参数变化(解决多次从首页点击不同数据跳转过来,页面不刷新的问题)
  128. '$route.query': {
  129. handler() {
  130. this.checkRouteParams();
  131. },
  132. deep: true
  133. }
  134. },
  135. created() {
  136. },
  137. async mounted() {
  138. // 加载菜单和任务数据
  139. const [menuData, taskData, onlineData, faultData] = await Promise.all([
  140. apiGetTongzhouMenuTree(),
  141. apiGetTasks({ pageSize: 5 }),
  142. apiGetDeviceStatus(),
  143. apiGetDeviceFaultStatus(),
  144. ]);
  145. this.menuData = menuData || [];
  146. this.trunkLineMenuData = [];
  147. this.tableData = taskData?.list || taskData || [];
  148. this.onlineStatusData = onlineData || null;
  149. this.deviceFaultData = faultData || null;
  150. // 组件挂载时检查路由
  151. this.checkRouteParams();
  152. },
  153. methods: {
  154. // 处理地图鼠标滑入事件
  155. handleMapCrossingMouseover(mapData, lnglat, pixel) {
  156. console.log('父组件接收到了地图路口鼠标滑入事件:', mapData);
  157. // 组装模拟数据
  158. const scale = window.innerWidth / 1920;
  159. let nodeData = {
  160. id: mapData.id || (mapData.position[0] + mapData.position[1]),
  161. label: mapData.road,
  162. pixelX: pixel ? Math.round(pixel.x / scale) : 950,
  163. pixelY: pixel ? Math.round(pixel.y / scale) : 430,
  164. }
  165. // 离线/降级/故障:显示小弹窗提示状态
  166. const abnormalNames = ['离线', '降级', '故障'];
  167. if (abnormalNames.includes(mapData.statusLabel || mapData.name)) {
  168. const statusText = mapData.statusLabel || mapData.name;
  169. this.$refs.layout.openDialog({
  170. id: 'offline_tip_' + nodeData.id,
  171. title: nodeData.label,
  172. component: 'OfflineTip',
  173. width: 260,
  174. height: 100,
  175. center: false,
  176. showClose: false,
  177. noPadding: false,
  178. draggable: false,
  179. resizable: false,
  180. position: { x: (nodeData.pixelX || 950) + 10, y: nodeData.pixelY || 430 },
  181. data: { status: statusText, road: nodeData.label },
  182. });
  183. return;
  184. }
  185. console.log(nodeData);
  186. if (this.activeLeftTab === 'overview') { // 总览
  187. this.showOverviewDalogs(nodeData);
  188. } else if (this.activeLeftTab === 'crossing') { // 路口
  189. this.showOverviewDalogs(nodeData);
  190. }
  191. },
  192. // 处理地图鼠标滑出事件
  193. handleMapCrossingMouseout(mapData) {
  194. console.log('父组件接收到了地图路口鼠标滑出事件:', mapData);
  195. if (!mapData) return;
  196. const id = mapData.id || (mapData.position[0] + mapData.position[1]);
  197. this.$refs.layout.handleDialogClose('offline_tip_' + id);
  198. if (this.activeLeftTab === 'overview') { // 总览
  199. this.$refs.layout.handleDialogClose('crossing3_' + id);
  200. } else if (this.activeLeftTab === 'crossing') { // 路口
  201. this.$refs.layout.handleDialogClose('crossing3_' + id);
  202. }
  203. },
  204. // 处理地图点击事件
  205. handleMapCrossingClick(mapData, lnglat, pixel) {
  206. console.log('父组件接收到了地图路口点击事件:', mapData);
  207. // 离线/降级/故障状态不弹详情
  208. const abnormalNames = ['离线', '降级', '故障'];
  209. if (abnormalNames.includes(mapData.statusLabel || mapData.name)) {
  210. this.$msg({
  211. title: '提示',
  212. message: `路口「${mapData.road || mapData.id}」设备${mapData.statusLabel || mapData.name},无法查看详情`,
  213. duration: 3000,
  214. });
  215. return;
  216. }
  217. // 组装模拟数据
  218. const scale = window.innerWidth / 1920;
  219. let nodeData = {
  220. id: mapData.id || (mapData.position[0] + mapData.position[1]),
  221. label: mapData.road,
  222. // 反算为设计稿坐标(SmartDialog 内部会再乘 scale)
  223. pixelX: pixel ? Math.round(pixel.x / scale) : 950,
  224. pixelY: pixel ? Math.round(pixel.y / scale) : 430,
  225. }
  226. // 干线marker点击时,从菜单数据中匹配对应干线
  227. if (this.activeLeftTab === 'trunkLine' && mapData.id) {
  228. const matched = this.findTrunkMenuNode(mapData.id);
  229. if (matched) {
  230. nodeData.id = matched.id;
  231. nodeData.label = matched.label;
  232. nodeData.intersections = matched.intersections;
  233. nodeData.distances = matched.distances;
  234. }
  235. }
  236. console.log(nodeData);
  237. if (this.activeLeftTab === 'overview') { // 总览
  238. this.showCrossingDetailDialogs(nodeData);
  239. } else if (this.activeLeftTab === 'crossing') { // 路口
  240. this.showCrossingDalogs(nodeData);
  241. } else if (this.activeLeftTab === 'trunkLine') { // 干线
  242. this.showTrunkLineDalogs(nodeData);
  243. } else if (this.activeLeftTab === 'specialDuty') { // 特勤
  244. if (mapData.taskId) {
  245. nodeData.id = mapData.taskId;
  246. }
  247. this.showSpecialDutyDalogs(nodeData);
  248. }
  249. },
  250. // 列表模式Tab切换
  251. onListTabSelect(tabName) {
  252. if (tabName !== 'crossing') {
  253. this.currentView = 'map-mode';
  254. }
  255. this.handleTabClick(tabName);
  256. },
  257. // 模式切换
  258. onViewSelect(item) {
  259. console.log('你点击了:', item.label);
  260. this.currentView = item.value;
  261. this.$refs.layout.clearDialogs(); // 清空全部弹窗
  262. this.crossingSelections = [];
  263. // 列表模式弹窗
  264. if (this.currentView === 'list-mode') {
  265. // this.$refs.layout.openDialog({
  266. // id: 'crossing-list', // 这里的 ID 可以根据实际业务场景动态生成
  267. // title: '',
  268. // component: 'CrossingListPanel',
  269. // width: 1920,
  270. // height: 750,
  271. // center: false,
  272. // showClose: true,
  273. // noPadding: false,
  274. // enableDblclickExpand: false,
  275. // position: { x: 100, y: 150 },
  276. // data: {
  277. // onViewDetail: (rowData) => this.handleCrossingViewDetail(rowData)
  278. // }
  279. // });
  280. } else {
  281. this.loadCrossingTopCharts();
  282. }
  283. },
  284. // 处理tab点击
  285. handleTabClick(tabName) {
  286. console.log('父组件接收到了tab点击事件:', tabName);
  287. this.$refs.layout.clearDialogs(); // 清空全部弹窗
  288. this.crossingSelections = [];
  289. this.showTopChartDalogs(); // 根据当前Tab显示对应的顶部常驻图表
  290. },
  291. // 处理菜单folder标题点击:计算子区路口中心坐标,移动地图
  292. handleFolderClick(nodeData) {
  293. console.log('父组件接收到了文件夹点击事件:', nodeData);
  294. const leaves = [];
  295. const collect = (nodes) => {
  296. if (!Array.isArray(nodes)) return;
  297. for (const n of nodes) {
  298. if (n.children) collect(n.children);
  299. else if (n.lng && n.lat) leaves.push(n);
  300. }
  301. };
  302. collect(nodeData.children || []);
  303. if (leaves.length === 0 || !this.$refs.trafficMapRef) return;
  304. const avgLng = leaves.reduce((s, n) => s + n.lng, 0) / leaves.length;
  305. const avgLat = leaves.reduce((s, n) => s + n.lat, 0) / leaves.length;
  306. const zoom = leaves.length <= 6 ? 15 : 14;
  307. const map = this.$refs.trafficMapRef.map;
  308. if (map) map.setZoomAndCenter(zoom, [avgLng, avgLat], false, 500);
  309. },
  310. // 处理菜单点击
  311. handleMenuClick(nodeData) {
  312. console.log('父组件接收到了最底层路口点击事件:', nodeData);
  313. // 通过地图组件获取像素坐标(如果有经纬度的话)
  314. // if (nodeData.lng && nodeData.lat && this.$refs.trafficMapRef) {
  315. // // 地图联动
  316. // this.$refs.trafficMapRef.focusByLocation([nodeData.lng, nodeData.lat]);
  317. // const pixel = this.$refs.trafficMapRef.lngLatToPixel(nodeData.lng, nodeData.lat);
  318. // if (pixel) {
  319. // const scale = window.innerWidth / 1920;
  320. // nodeData.pixelX = Math.round(pixel.x / scale) + 20;
  321. // nodeData.pixelY = Math.round(pixel.y / scale);
  322. // }
  323. // }
  324. // 根据Tab来显示不同的弹窗内容
  325. if (this.activeLeftTab === 'overview') { // 总览
  326. // 临时逻辑,有真实接口后可以删除
  327. const index = Math.floor(Math.random() * 10);
  328. const position = localStorage.getItem(`pos${index + 1}`).split(',');
  329. // 地图联动
  330. this.$refs.trafficMapRef.focusByLocation([Number(position[0]), Number(position[1])]);
  331. this.showOverviewDalogs(nodeData);
  332. } else if (this.activeLeftTab === 'crossing') { // 路口
  333. this.showCrossingDalogs(nodeData);
  334. } else if (this.activeLeftTab === 'trunkLine') { // 干线
  335. this.showTrunkLineDalogs(nodeData);
  336. } else if (this.activeLeftTab === 'specialDuty') { // 特勤
  337. this.showSpecialDutyDalogs(nodeData);
  338. }
  339. },
  340. // 处理弹窗双击展开(通过 onExpand 回调从 Layout 传入)
  341. handleDoubleClickExpend(nodeData) {
  342. console.log('处理弹窗双击事件', nodeData);
  343. if (this.activeLeftTab === 'crossing' || this.activeLeftTab === 'overview') {
  344. this.showCrossingDetailDialogs(nodeData);
  345. }
  346. },
  347. // 显示顶部常驻图表(根据当前Tab状态)
  348. showTopChartDalogs() {
  349. if (this.activeLeftTab === 'crossing') {
  350. this.loadCrossingTopCharts();
  351. }
  352. },
  353. // 显示总览弹窗组
  354. showOverviewDalogs(nodeData) {
  355. console.log('显示总览弹窗组', nodeData.id, nodeData.label);
  356. // 路口弹窗
  357. this.$refs.layout.openDialog({
  358. id: 'crossing3_' + nodeData.id, // 这里的 ID 可以根据实际业务场景动态生成
  359. title: nodeData.label,
  360. component: 'CrossingPanel',
  361. width: 260,
  362. height: 260,
  363. center: false,
  364. showClose: true,
  365. position: { x: (nodeData.pixelX || 950) + 20, y: nodeData.pixelY || 430 },
  366. noPadding: false,
  367. data: {
  368. ...nodeData,
  369. onExpand: (data) => this.handleDoubleClickExpend(data)
  370. },
  371. onClose: () => {
  372. // this.$refs.layout.handleDialogClose('top-chart-crossing-1');
  373. // this.$refs.layout.handleDialogClose('top-chart-crossing-2');
  374. }
  375. });
  376. },
  377. async loadCrossingTopCharts() {
  378. try {
  379. this.crossingTopCharts = await apiGetCrossingTopCharts();
  380. } catch (e) { /* ignore */ }
  381. },
  382. // 显示路口弹窗组(多选分屏)
  383. async showCrossingDalogs(nodeData) {
  384. console.log('路口多选', nodeData.id, nodeData.label);
  385. // 0. 离线检查
  386. const detailData = await apiGetCrossingDetailData(nodeData.id, { iconMode: 'simple' });
  387. if (detailData?.intersectionData?.status !== '在线') {
  388. this.$msg({
  389. title: '提示',
  390. message: `路口「${nodeData.label || nodeData.id}」设备离线,无法查看详情`,
  391. duration: 3000,
  392. });
  393. return;
  394. }
  395. // 1. 已选中 → 不重复操作
  396. const existIndex = this.crossingSelections.findIndex(c => c.id === nodeData.id);
  397. if (existIndex !== -1) {
  398. return;
  399. }
  400. // 2. 已满 → 先进先出
  401. if (this.crossingSelections.length >= this.maxCrossingSlots) {
  402. this.crossingSelections.shift();
  403. }
  404. // 3. 追加选中,带上预加载数据避免重复请求
  405. this.crossingSelections.push({ ...nodeData, _preloadedData: detailData });
  406. // 4. 打开或更新弹窗
  407. this.openCrossingMultiView();
  408. },
  409. openCrossingMultiView() {
  410. this.$refs.layout.openDialog({
  411. id: 'crossing-multi-view',
  412. title: '',
  413. component: 'CrossingMultiView',
  414. width: 1400,
  415. height: 700,
  416. center: false,
  417. position: { x: 500, y: 150 },
  418. showClose: false,
  419. noPadding: true,
  420. enableDblclickExpand: false,
  421. draggable: false,
  422. data: {
  423. crossings: [...this.crossingSelections],
  424. maxSlots: this.maxCrossingSlots,
  425. onRemove: (id) => this.handleCrossingRemove(id),
  426. onReorder: (newOrder) => {
  427. this.crossingSelections = newOrder;
  428. }
  429. },
  430. onClose: () => {
  431. this.crossingSelections = [];
  432. }
  433. });
  434. },
  435. handleCrossingRemove(id) {
  436. this.crossingSelections = this.crossingSelections.filter(c => c.id !== id);
  437. if (this.crossingSelections.length === 0) {
  438. this.$refs.layout.handleDialogClose('crossing-multi-view');
  439. } else {
  440. this.openCrossingMultiView();
  441. }
  442. },
  443. // 单个路口详情弹窗(总览双击展开等场景使用)
  444. async showCrossingDetailDialogs(nodeData) {
  445. console.log('显示路口详情弹窗组', nodeData.id, nodeData.label);
  446. const detailData = await apiGetCrossingDetailData(nodeData.id, { iconMode: 'simple' });
  447. if (detailData?.intersectionData?.status !== '在线') {
  448. this.$msg({
  449. title: '提示',
  450. message: `路口「${nodeData.label || nodeData.id}」设备离线,无法查看详情`,
  451. duration: 3000,
  452. });
  453. return;
  454. }
  455. const dialogId = 'crossing_detail' + nodeData.id;
  456. this.$refs.layout.openDialog({
  457. id: dialogId,
  458. title: ' ',
  459. component: 'CrossingDetailPanel',
  460. width: 1315,
  461. height: 682,
  462. center: false,
  463. showClose: true,
  464. position: { x: 500, y: 170 },
  465. noPadding: false,
  466. enableDblclickExpand: false,
  467. data: { ...nodeData, preloadedData: detailData },
  468. headerComponent: 'CrossingDetailHeader',
  469. headerProps: {
  470. currentRoute: { ...(detailData?.currentRoute || {}), name: nodeData.label || detailData?.currentRoute?.name },
  471. intersectionData: detailData?.intersectionData || {},
  472. cycleLength: detailData?.cycleLength || 0,
  473. }
  474. });
  475. },
  476. // 路口列表模式下弹窗
  477. handleCrossingViewDetail(rowData) {
  478. console.log('显示路口列表查看', rowData);
  479. this.showCrossingDetailDialogs(rowData);
  480. },
  481. // 显示干线弹窗组
  482. // 干线菜单叶子节点点击
  483. handleTrunkLineClick(nodeData) {
  484. console.log('干线菜单点击:', nodeData);
  485. this.showTrunkLineDalogs(nodeData);
  486. },
  487. findTrunkMenuNode(markerId) {
  488. // 从 marker ID(如 trunk_1_point_3)提取干线编号(trunk_1)
  489. const trunkId = String(markerId).replace(/_point_\d+$/, '');
  490. const leaves = [];
  491. const walk = (nodes) => {
  492. if (!Array.isArray(nodes)) return;
  493. for (const n of nodes) {
  494. if (n.children && n.children.length > 0) walk(n.children);
  495. else leaves.push(n);
  496. }
  497. };
  498. walk(this.trunkLineMenuData);
  499. return leaves.find(n => n.id === trunkId) || null;
  500. },
  501. handleTrunkMenuUpdate(segments) {
  502. this.trunkLineMenuData = [{
  503. id: 'trunk_root',
  504. label: '主控中心',
  505. icon: 'icon-control',
  506. isOpen: true,
  507. children: [{
  508. id: 'trunk_beijing',
  509. label: '北京市交警总队',
  510. icon: 'icon-police',
  511. isOpen: true,
  512. children: [{
  513. id: 'trunk_tongzhou',
  514. label: '通州区',
  515. icon: 'icon-district',
  516. isOpen: true,
  517. children: (() => {
  518. const list = segments.slice(0, 6);
  519. if (list[5]) list[5] = { ...list[5], label: '张台路与湖亦路路口' };
  520. return list;
  521. })()
  522. }]
  523. }]
  524. }];
  525. },
  526. async showTrunkLineDalogs(nodeData) {
  527. console.log('显示干线弹窗组', nodeData.id, nodeData.label);
  528. // 优先使用菜单节点自带的路口和距离数据
  529. let tsData;
  530. if (nodeData.intersections && nodeData.distances) {
  531. tsData = await apiGetTrafficTimeSpace({
  532. label: nodeData.label,
  533. intersections: nodeData.intersections,
  534. distances: nodeData.distances,
  535. });
  536. } else {
  537. tsData = await apiGetTrafficTimeSpace({ label: nodeData.label });
  538. }
  539. this.$refs.layout.openDialog({
  540. id: nodeData.id,
  541. title: nodeData.label + ' 绿波带',
  542. component: 'TrafficTimeSpace',
  543. width: 1200,
  544. height: 700,
  545. center: false,
  546. position: { x: 500, y: 150 },
  547. showClose: true,
  548. noPadding: false,
  549. data: tsData,
  550. });
  551. },
  552. // 显示特勤弹窗组
  553. showSpecialDutyDalogs(nodeData) {
  554. console.log('显示特勤弹窗组', nodeData.id, nodeData.label);
  555. this.openDutyDetailDialog(nodeData);
  556. },
  557. // === 解析路由参数并执行对应操作 ===
  558. checkRouteParams() {
  559. // 统一参数接收:特勤接收 id,路口接收 intersectionName 和 plan
  560. const { tab, action, id, } = this.$route.query;
  561. if (!tab) return; // 如果没有传递 tab 参数,说明是正常访问,不处理
  562. // 1. 处理“特勤线路”跳转
  563. if (tab === 'specialDuty') {
  564. this.activeLeftTab = 'specialDuty'; // 切换到左侧【特勤】Tab
  565. this.handleTabClick('specialDuty'); // 手动触发 Tab 切换事件,更新顶部图表
  566. // 这里判断的条件改为 id
  567. if (action === 'open-dialog' && id) {
  568. this.$nextTick(() => {
  569. this.openDutyDetailDialog({id: id, label: '特勤路口'}); // 打开特勤弹窗
  570. });
  571. }
  572. }
  573. // 2. 处理“关键路口”跳转
  574. else if (tab === 'crossing') {
  575. this.activeLeftTab = 'crossing'; // 切换到左侧【路口】Tab
  576. this.handleTabClick('crossing'); // 手动触发 Tab 切换事件,更新顶部图表
  577. if (action === 'open-dialog') {
  578. this.$nextTick(() => {
  579. // 构造一个假的 nodeData 传给详情弹窗方法
  580. this.showCrossingDetailDialogs({
  581. id: 'route_' + new Date().getTime(), // 动态生成一个ID防重复
  582. label: '路口详情',
  583. });
  584. });
  585. }
  586. }
  587. },
  588. // === 特勤详情弹窗 (你需要根据实际组件名替换) ===
  589. async openDutyDetailDialog(nodeData) {
  590. console.log('准备打开特勤线路详情:', nodeData);
  591. // 1. 获取数据
  592. const panelData = await apiGetSpecialTaskMonitorData(nodeData.id);
  593. const id = 'special-task-dialog' + new Date().getTime();
  594. // 2. 呼出弹窗
  595. this.$refs.layout.openDialog({
  596. id: id,
  597. title: ' ', // 留空以隐藏默认标题,使用自定义 Header
  598. width: 1400, // 弹窗宽一点,容纳 3 列
  599. height: 700,
  600. center: false,
  601. showClose: true,
  602. noPadding: true, // 去除默认内边距,让内部组件自己控制
  603. position: {x: 200, y: 150},
  604. // 挂载主体组件和数据
  605. component: 'SpecialTaskMonitorPanel',
  606. data: { panelData: panelData },
  607. // 挂载自定义 Header 和数据
  608. headerComponent: 'TaskMonitorHeader',
  609. headerProps: {
  610. taskData: panelData.taskInfo,
  611. onStartTask: () => {
  612. console.log('点击了立即执行');
  613. panelData.taskInfo.status = '进行中';
  614. const tableRow = this.tableData.find(r => r.id === nodeData.id);
  615. if (tableRow) tableRow.status = '进行中';
  616. },
  617. onEndTask: () => {
  618. console.log('点击了立即结束');
  619. panelData.taskInfo.status = '已完成';
  620. const tableRow = this.tableData.find(r => r.id === nodeData.id);
  621. if (tableRow) tableRow.status = '已完成';
  622. }
  623. }
  624. });
  625. return panelData;
  626. },
  627. handleSpecialTaskView(row) {
  628. console.log('查看特勤线路,当前数据:', row);
  629. this.openDutyDetailDialog(row);
  630. },
  631. async handleSpecialTaskStart(row) {
  632. console.log('立即执行特勤任务:', row);
  633. const panelData = await this.openDutyDetailDialog(row);
  634. this.$msg({
  635. title: '操作确认',
  636. message: `确认立即执行任务「${row.name}」?`,
  637. duration: 0,
  638. showConfirm: true,
  639. showCancel: true,
  640. confirmText: '确认执行',
  641. noBackdrop: true,
  642. onConfirm: () => { row.status = '进行中'; panelData.taskInfo.status = '进行中'; }
  643. });
  644. },
  645. async handleSpecialTaskEnd(row) {
  646. console.log('立即结束特勤任务:', row);
  647. const panelData = await this.openDutyDetailDialog(row);
  648. this.$msg({
  649. title: '操作确认',
  650. message: `确认立即结束任务「${row.name}」?`,
  651. duration: 0,
  652. showConfirm: true,
  653. showCancel: true,
  654. confirmText: '确认结束',
  655. noBackdrop: true,
  656. onConfirm: () => { row.status = '已完成'; panelData.taskInfo.status = '已完成'; }
  657. });
  658. },
  659. async handleSpecialTaskRestart(row) {
  660. console.log('重新开始特勤任务:', row);
  661. const panelData = await this.openDutyDetailDialog(row);
  662. this.$msg({
  663. title: '操作确认',
  664. message: `确认重新开始任务「${row.name}」?`,
  665. duration: 0,
  666. showConfirm: true,
  667. showCancel: true,
  668. confirmText: '确认开始',
  669. noBackdrop: true,
  670. onConfirm: () => { row.status = '进行中'; panelData.taskInfo.status = '进行中'; }
  671. });
  672. },
  673. }
  674. }
  675. </script>
  676. <style scoped>
  677. .mode-switch {
  678. display: flex;
  679. flex-direction: row;
  680. justify-content: flex-end;
  681. }
  682. .mode-switch>div {
  683. width: 200px;
  684. }
  685. .left-sidebar-wrap {
  686. display: flex;
  687. flex-direction: column;
  688. max-width: 400px;
  689. }
  690. .left-sidebar-title {
  691. font-size: clamp(14px, 1.04vw, 20px);
  692. font-weight: bold;
  693. color: #e0e8f0;
  694. padding: 12px 0;
  695. letter-spacing: 2px;
  696. }
  697. .left-sidebar-body {
  698. background: rgba(17, 36, 70, 0.9);
  699. outline: 2px solid #3760A9;
  700. outline-offset: -2px;
  701. height: 700px;
  702. overflow: auto;
  703. }
  704. .sidebar-loading {
  705. display: flex;
  706. align-items: center;
  707. justify-content: center;
  708. height: 120px;
  709. color: #758599;
  710. font-size: 14px;
  711. }
  712. .duty-table {
  713. margin-top: 10px;
  714. }
  715. .action-btn {
  716. cursor: pointer;
  717. color: #4da8ff;
  718. margin-right: 10px;
  719. }
  720. .action-btn:hover {
  721. text-decoration: underline;
  722. }
  723. .action-start {
  724. color: #67c23a;
  725. }
  726. .action-end {
  727. color: #f56c6c;
  728. }
  729. .top-charts-bar {
  730. display: flex;
  731. justify-content: center;
  732. gap: clamp(10px, 1.04vw, 20px);
  733. pointer-events: none;
  734. }
  735. .top-chart-box {
  736. pointer-events: auto;
  737. flex-shrink: 0;
  738. background: radial-gradient(circle at 20% 0%, rgba(40,120,200,0.5) 0%, rgba(20,60,130,0.7) 70%);
  739. box-shadow: inset 0px 0px 0.625rem 0px rgba(88, 146, 255, 0.4), inset 1.25rem 0px 1.875rem -0.625rem rgba(88, 146, 255, 0.15);
  740. border: 1px solid rgba(255, 255, 255, 0.15);
  741. border-radius: clamp(6px, 0.625vw, 12px);
  742. overflow: hidden;
  743. }
  744. /* --- 总览Tab图表尺寸适配 (原 300x160) --- */
  745. .overview-chart-box {
  746. /* clamp(最小值, 理想值(1920下比例), 最大值) */
  747. width: clamp(200px, 15.625vw, 300px);
  748. height: clamp(106px, 8.333vw, 160px);
  749. }
  750. /* --- 路口Tab图表尺寸适配 (原 228x124) --- */
  751. .crossing-chart-box {
  752. width: clamp(152px, 11.875vw, 228px);
  753. height: clamp(82px, 6.458vw, 124px);
  754. }
  755. ::v-deep .list-mode-panel {
  756. position: absolute;
  757. inset: 0;
  758. padding: 150px 30px 30px 30px;
  759. box-sizing: border-box;
  760. display: flex;
  761. flex-direction: column;
  762. overflow: hidden;
  763. }
  764. .list-mode-tabs {
  765. flex-shrink: 0;
  766. max-width: 400px;
  767. }
  768. .duty-name {
  769. display: inline-block;
  770. max-width: 8em;
  771. overflow: hidden;
  772. text-overflow: ellipsis;
  773. white-space: nowrap;
  774. vertical-align: middle;
  775. }
  776. /* 针对特勤 Tab 单独剥离背景和边框 */
  777. ::v-deep .special-duty-pane {
  778. padding: 10px 20px;
  779. }
  780. </style>