SpecialSituationMonitoring.vue 31 KB

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