StatusMonitoring.vue 30 KB

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