SpecialSituationMonitoring.vue 32 KB

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