SpecialSituationMonitoring.vue 31 KB

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