index.vue 37 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222
  1. <template>
  2. <div class="menu-content">
  3. <div class="gradient-text title">实时标绘</div>
  4. <div v-show="collaboration" style="display: flex; align-items: center; justify-content: flex-end; height: 90px">
  5. <div class="btn2" style="margin-left: 10px" @click="handleCloseCollaboration">关闭协同</div>
  6. <div class="btn2" style="margin-left: 10px" @click="handleSaveCollaboration">保存</div>
  7. </div>
  8. <div class="line">
  9. <div class="tabs1">
  10. <div v-for="(item, index) in menu" :key="index" :class="menuActive1 === index ? 'tab tab_active' : 'tab'" @click="clickTab(index)">
  11. {{ item.name }}
  12. </div>
  13. </div>
  14. <div class="btn-box">
  15. <div class="btn1" @click="handleScreenshot">
  16. <div class="icon1"></div>
  17. 当前地图截图导出
  18. </div>
  19. <div v-show="!collaboration" class="btn2" @click="handleShare('1')">协同标绘</div>
  20. <div v-show="collaboration" class="btn2" @click="handleShowLayer">查看图层</div>
  21. </div>
  22. </div>
  23. <div v-if="menuActive1 === 0" class="content">
  24. <div class="box1">
  25. <div class="box-item">
  26. <div class="btn" @click="handleUndo">
  27. <div class="revoke-icon"></div>
  28. 撤回
  29. </div>
  30. <div class="line2"></div>
  31. <div class="btn">
  32. <div class="delete-icon"></div>
  33. 删除
  34. </div>
  35. <div class="line2"></div>
  36. <div class="btn" @click="handleShowDialog">
  37. <div class="save-icon"></div>
  38. 保存
  39. </div>
  40. </div>
  41. <div class="btn">
  42. <div class="setting-icon"></div>
  43. 设置
  44. </div>
  45. </div>
  46. <div class="tab-content">
  47. <div class="tabs2">
  48. <div
  49. v-for="(item, index) in menu[menuActive1].children"
  50. :key="index"
  51. :class="menuActive2 === index ? 'tab tab_active' : 'tab'"
  52. @click="clickTab2(index)"
  53. >
  54. {{ item.name }}
  55. </div>
  56. </div>
  57. <div class="tab-content2">
  58. <div v-show="menuActive2 === 0" class="line3">
  59. <LineWidthSelect v-model="mouseToolState.lineWidth" :options="lineWidthOptions" />
  60. <div class="color-container">
  61. <el-color-picker v-model="mouseToolState.color" popper-class="custom-color-picker" show-alpha />
  62. </div>
  63. </div>
  64. <div class="tab-list">
  65. <div
  66. v-for="(item, index) in menu[menuActive1].children[menuActive2].children"
  67. :key="index"
  68. :class="menuActive3 === index ? 'tab tab_active' : 'tab'"
  69. @click="clickTab3(item, index)"
  70. >
  71. <div :class="menuActive3 === index ? 'checked2' : 'checked1'"></div>
  72. <img :src="item.image" class="icon" />
  73. {{ item.name }}
  74. </div>
  75. </div>
  76. </div>
  77. </div>
  78. </div>
  79. <div v-else-if="menuActive1 === 1" class="tab-content3">
  80. <!-- <div class="box1">-->
  81. <!-- <div class="box-item">-->
  82. <!-- <div class="btn">-->
  83. <!-- <div class="merge-icon"></div>-->
  84. <!-- 合并-->
  85. <!-- </div>-->
  86. <!-- </div>-->
  87. <!-- </div>-->
  88. <div class="params-box">
  89. <el-input v-model="queryParams.pattern_name" class="custom-input" placeholder="请输入" @input="handleQuery">
  90. <template #prefix>
  91. <el-icon class="el-input__icon"><search /></el-icon>
  92. </template>
  93. </el-input>
  94. </div>
  95. <div class="custom-table">
  96. <div class="table-header">
  97. <div class="th">预案名称</div>
  98. <div class="th">操作</div>
  99. </div>
  100. <div v-for="(item, index) in patternList" :key="index" class="tr">
  101. <div class="td">
  102. <div>{{ item.pattern_name }}</div>
  103. </div>
  104. <div class="td td2">
  105. <div class="btn" @click="handleDelete(item.id)">
  106. <div class="delete-icon"></div>
  107. 删除
  108. </div>
  109. <div class="line2"></div>
  110. <div class="btn" @click="handleEdit(item.id)">
  111. <div class="edit-icon"></div>
  112. 编辑
  113. </div>
  114. <div class="line2"></div>
  115. <div class="btn" @click="handleShare('2', item.id)">
  116. <div class="share-icon"></div>
  117. 分享
  118. </div>
  119. </div>
  120. </div>
  121. <div class="footer">
  122. <el-pagination
  123. background
  124. :hide-on-single-page="true"
  125. layout="total, prev, pager, next"
  126. :total="total"
  127. :page-size="queryParams.pageSize"
  128. :current-page="queryParams.page"
  129. @current-change="getList"
  130. />
  131. </div>
  132. </div>
  133. </div>
  134. </div>
  135. <!--添加文字-->
  136. <TextEdit v-model="showTextEdit" @add-text="addText" />
  137. <!--绘制提示信息-->
  138. <div v-show="tipTitle !== ''" class="tipTitle">{{ tipTitle }}</div>
  139. <!--保存修改弹窗-->
  140. <EditDialog v-if="showEdit" v-model="showEdit" :edit-data="editData" @submit="handleSubmit" />
  141. <Contact v-if="shareState.showShare" v-model="shareState.showShare" @close="handleCloseShare" @confirm="handleShareConfirm" />
  142. <Dialog v-model="showForm" title="协同标绘" type="xs" @confirm="handleSendForm">
  143. <div style="display: flex; align-items: center">
  144. <div style="font-size: 36px">预案名称</div>
  145. <el-input v-model="form.pattern_name" class="custom-input" placeholder="请输入" style="flex: 1" />
  146. </div>
  147. </Dialog>
  148. <LayerDetail v-if="showLayer" v-model="showLayer" :pattern-id="patternId" />
  149. </template>
  150. <script lang="ts" setup name="OnlinePlotting">
  151. import { nanoid } from 'nanoid';
  152. import { deepClone } from '@/utils';
  153. import { useHistory } from '@/hooks/useHistory';
  154. import { closeCollaboration, createCollaboration, deletePatternById, getPatternInfo, getPatternList } from '@/api/globalMap/onlinePlotting';
  155. import TextEdit from '@/views/globalMap/RightMenu/OnlinePlotting/TextEdit.vue';
  156. import EditDialog from '@/views/globalMap/RightMenu/OnlinePlotting/EditDialog.vue';
  157. import { Search } from '@element-plus/icons-vue';
  158. import html2canvas from 'html2canvas';
  159. import LayerDetail from './LayerDetail.vue';
  160. import { createWebSocket } from '@/utils/websocket';
  161. const { proxy } = getCurrentInstance() as ComponentInternalInstance;
  162. const getDrawTool = inject('getDrawTool');
  163. const getMap = inject('getMap');
  164. const getMapUtils = inject('getMapUtils');
  165. const containerScale = inject('containerScale');
  166. const { currentState, commit, undo, history, future } = useHistory();
  167. const emits = defineEmits(['getCollaborationData']);
  168. const getImageUrl = (name) => {
  169. return new URL(`../../../../assets/images/map/rightMenu/onlinePlotting/icon/${name}.png`, import.meta.url).href;
  170. };
  171. let drawing = ref(false);
  172. const mouseToolState = ref<MouseTool>({
  173. color: 'rgba(248, 1, 2, 1)',
  174. lineWidth: '1',
  175. graphicsType: ''
  176. });
  177. const menuActive1 = ref<string | number>(0);
  178. const menuActive2 = ref<string | number>(0);
  179. const menuActive3 = ref<string | number>('');
  180. const menu = ref([
  181. {
  182. name: '标绘工具',
  183. children: [
  184. {
  185. name: '基本工具',
  186. value: 'basicTools',
  187. children: [
  188. // {
  189. // name: '直箭头',
  190. // value: 'straightArrow',
  191. // image: getImageUrl('straightArrow')
  192. // },
  193. {
  194. name: '矩形',
  195. value: 'rectangle',
  196. image: getImageUrl('rectangle')
  197. },
  198. {
  199. name: '任意面',
  200. value: 'polygon',
  201. image: getImageUrl('polygon')
  202. },
  203. // {
  204. // name: '任意线',
  205. // value: 'anyLine',
  206. // image: getImageUrl('anyLine')
  207. // },
  208. {
  209. name: '圆',
  210. value: 'circle',
  211. image: getImageUrl('circle')
  212. },
  213. {
  214. name: '直线',
  215. value: 'straightLine',
  216. image: getImageUrl('straightLine')
  217. },
  218. {
  219. name: '文字',
  220. value: 'text',
  221. image: getImageUrl('text')
  222. },
  223. {
  224. name: '面积',
  225. value: 'measureArea',
  226. image: getImageUrl('measureArea')
  227. }
  228. ]
  229. },
  230. {
  231. name: '火点',
  232. value: 'firePoint',
  233. children: [
  234. { name: '起火点', value: 'marker', image: getImageUrl('firePoint'), icon: getImageUrl('firePoint'), size: [48, 32] },
  235. { name: '烟点', value: 'marker', image: getImageUrl('smokePoint'), icon: getImageUrl('smokePoint'), size: [48, 32] },
  236. { name: '已灭火点', value: 'marker', image: getImageUrl('extinguishedPoint'), icon: getImageUrl('extinguishedPoint'), size: [48, 32] }
  237. ]
  238. },
  239. {
  240. name: '火线',
  241. value: 'firewire',
  242. children: [
  243. { name: '火线', value: 'marker', image: getImageUrl('firewire'), icon: getImageUrl('firewire'), size: [48, 32] },
  244. { name: '受控火线', value: 'marker', image: getImageUrl('controlledfireline'), icon: getImageUrl('controlledfireline'), size: [48, 32] },
  245. { name: '已灭火线', value: 'marker', image: getImageUrl('extinguishedline'), icon: getImageUrl('extinguishedline'), size: [48, 32] },
  246. { name: '强火线', value: 'marker', image: getImageUrl('StrongFrontline'), icon: getImageUrl('StrongFrontline'), size: [48, 32] },
  247. { name: '中火线', value: 'marker', image: getImageUrl('ZhongxianLine'), icon: getImageUrl('ZhongxianLine'), size: [48, 32] },
  248. { name: '弱火线', value: 'marker', image: getImageUrl('WeakFrontline'), icon: getImageUrl('WeakFrontline'), size: [48, 32] }
  249. ]
  250. },
  251. {
  252. name: '火场',
  253. value: 'fireGround',
  254. children: [
  255. { name: '火场', value: 'marker', image: getImageUrl('fireground'), icon: getImageUrl('fireground'), size: [48, 32] },
  256. {
  257. name: '受控火场',
  258. value: 'marker',
  259. image: getImageUrl('controlledfireground'),
  260. icon: getImageUrl('controlledfireground'),
  261. size: [48, 32]
  262. },
  263. {
  264. name: '已灭火场',
  265. value: 'marker',
  266. image: getImageUrl('extinguishedfireground'),
  267. icon: getImageUrl('extinguishedfireground'),
  268. size: [48, 32]
  269. }
  270. ]
  271. },
  272. {
  273. name: '箭头',
  274. value: 'arrow',
  275. children: [
  276. { name: '曲箭头', value: 'marker', image: getImageUrl('curvedarrow'), icon: getImageUrl('curvedarrow'), size: [48, 32] },
  277. { name: '直箭头', value: 'marker', image: getImageUrl('straightarrow1'), icon: getImageUrl('straightarrow1'), size: [48, 32] },
  278. { name: '细箭头', value: 'marker', image: getImageUrl('thinarrow'), icon: getImageUrl('thinarrow'), size: [48, 32] }
  279. ]
  280. },
  281. // {
  282. // name: '导航',
  283. // value: 'navigation',
  284. // children: [
  285. // { name: '导航', value: 'marker', image: getImageUrl('navigation'), icon: getImageUrl('navigation'), size: [166, 88] }
  286. // ]
  287. // },
  288. {
  289. name: '扑救队伍',
  290. value: 'firefightingTeam',
  291. children: [
  292. { name: '指挥中心', value: 'marker', image: getImageUrl('commandcentre'), icon: getImageUrl('commandcentre'), size: [48, 32] },
  293. { name: '分指中心', value: 'marker', image: getImageUrl('dividingcenter'), icon: getImageUrl('dividingcenter'), size: [48, 32] },
  294. { name: '集结地', value: 'marker', image: getImageUrl('rendezvous'), icon: getImageUrl('rendezvous'), size: [48, 32] },
  295. { name: '军队', value: 'marker', image: getImageUrl('army'), icon: getImageUrl('army'), size: [48, 32] },
  296. { name: '武警', value: 'marker', image: getImageUrl('armedpolice'), icon: getImageUrl('armedpolice'), size: [48, 32] },
  297. { name: '森林警察', value: 'marker', image: getImageUrl('forestpoliceman'), icon: getImageUrl('forestpoliceman'), size: [48, 32] },
  298. { name: '扑火队伍', value: 'marker', image: getImageUrl('firefightingteam'), icon: getImageUrl('firefightingteam'), size: [48, 32] }
  299. // { name: '扑火队伍路线', value: 'marker', image: getImageUrl('Firefightingteamroute'), icon: getImageUrl('Firefightingteamroute'), size: [48, 32] }
  300. ]
  301. },
  302. {
  303. name: '飞机车辆',
  304. value: 'aircraftVehicles',
  305. children: [
  306. { name: '固定翼', value: 'marker', image: getImageUrl('fixedwing'), icon: getImageUrl('fixedwing'), size: [48, 32] },
  307. { name: '直升机', value: 'marker', image: getImageUrl('helicopter'), icon: getImageUrl('helicopter'), size: [48, 32] },
  308. { name: '无人机', value: 'marker', image: getImageUrl('UAV'), icon: getImageUrl('UAV'), size: [48, 32] },
  309. { name: '指挥车', value: 'marker', image: getImageUrl('commandvehicle'), icon: getImageUrl('commandvehicle'), size: [48, 32] },
  310. {
  311. name: '飞机航线设置',
  312. value: 'marker',
  313. image: getImageUrl('aircraftroutesetting'),
  314. icon: getImageUrl('aircraftroutesetting'),
  315. size: [48, 32]
  316. },
  317. {
  318. name: '直升机航线设置',
  319. value: 'marker',
  320. image: getImageUrl('helicopterroutesetting'),
  321. icon: getImageUrl('helicopterroutesetting'),
  322. size: [48, 32]
  323. }
  324. ]
  325. },
  326. {
  327. name: '基础设置',
  328. value: 'basicSetting',
  329. children: [
  330. { name: '航站', value: 'marker', image: getImageUrl('terminal'), icon: getImageUrl('terminal'), size: [48, 32] },
  331. {
  332. name: '起降点',
  333. value: 'marker',
  334. image: getImageUrl('takeoffandlandingpoint'),
  335. icon: getImageUrl('takeoffandlandingpoint'),
  336. size: [48, 32]
  337. },
  338. { name: '取水点', value: 'marker', image: getImageUrl('waterpoint'), icon: getImageUrl('waterpoint'), size: [48, 32] },
  339. { name: '瞭望塔', value: 'marker', image: getImageUrl('watchtower'), icon: getImageUrl('watchtower'), size: [48, 32] },
  340. { name: '物资库', value: 'marker', image: getImageUrl('materialwarehouse'), icon: getImageUrl('materialwarehouse'), size: [48, 32] }
  341. ]
  342. }
  343. // {
  344. // name: '其他',
  345. // value: 'other',
  346. // children: [
  347. // { name: '危险区域', value: 'marker', image: getImageUrl('dangerousarea'), icon: getImageUrl('dangerousarea'), size: [166, 88] },
  348. // { name: '隔离带开采', value: 'marker', image: getImageUrl('Isolationzonemining'), icon: getImageUrl('Isolationzonemining'), size: [166, 88] },
  349. // { name: '应急庇护场所', value: 'marker', image: getImageUrl('emergencyshelter'), icon: getImageUrl('emergencyshelter'), size: [166, 88] },
  350. // { name: '风力风向', value: 'marker', image: getImageUrl('windspeedanddirection'), icon: getImageUrl('windspeedanddirection'), size: [166, 88] },
  351. // { name: '测距', value: 'marker', image: getImageUrl('ranging'), icon: getImageUrl('ranging'), size: [166, 88] },
  352. // { name: '大风', value: 'marker', image: getImageUrl('strongwind'), icon: getImageUrl('strongwind'), size: [166, 88] },
  353. // { name: '人工降雨', value: 'marker', image: getImageUrl('artificialrainfall'), icon: getImageUrl('artificialrainfall'), size: [166, 88] },
  354. // { name: '台风', value: 'marker', image: getImageUrl('typhoon'), icon: getImageUrl('typhoon'), size: [166, 88] }
  355. // ]
  356. // }
  357. ]
  358. },
  359. {
  360. name: '历史预案',
  361. children: []
  362. }
  363. ]);
  364. const lineWidthOptions = reactive([
  365. { name: '1像素', value: '1' },
  366. { name: '2像素', value: '2' },
  367. { name: '3像素', value: '3' }
  368. ]);
  369. let showTextEdit = ref();
  370. let lnglat = ref([]);
  371. // 协同
  372. let collaboration = ref(false);
  373. // 分享
  374. let shareState = reactive({
  375. type: '',
  376. showShare: false,
  377. id: ''
  378. });
  379. let patternId = ref('');
  380. let shareId = ref('');
  381. const overlays = [];
  382. const overlaysData = [];
  383. watch(
  384. () => drawing,
  385. () => {
  386. if (!drawing.value) {
  387. menuActive3.value = '';
  388. }
  389. }
  390. );
  391. const tipTitle = computed(() => {
  392. let res = '';
  393. if (
  394. menu.value[menuActive1.value] &&
  395. menu.value[menuActive1.value].children &&
  396. menu.value[menuActive1.value].children[menuActive2.value] &&
  397. menu.value[menuActive1.value].children[menuActive2.value].children &&
  398. menu.value[menuActive1.value].children[menuActive2.value].children[menuActive3.value]
  399. ) {
  400. const data = menu.value[menuActive1.value].children[menuActive2.value].children[menuActive3.value];
  401. if (data.value === 'straightArrow') {
  402. res = '单击开始、单击结束';
  403. } else if (['rectangle', 'polygon', 'anyLine', 'circle'].includes(data.value)) {
  404. res = '鼠标按住拖曳,松开鼠标结束标绘';
  405. } else if (['straightLine', 'measureArea'].includes(data.value)) {
  406. res = '单击开始,移动,单击改变方向,双击结束';
  407. }
  408. }
  409. return res;
  410. });
  411. // 点击一级菜单
  412. const clickTab = (value: number) => {
  413. menuActive1.value = value;
  414. };
  415. // 点击二级菜单
  416. const clickTab2 = (value: number) => {
  417. menuActive2.value = value;
  418. };
  419. // 点击三级菜单
  420. const clickTab3 = (item, index) => {
  421. const type = item.value;
  422. if (mouseToolState.value.graphicsType !== type || (mouseToolState.value.graphicsType === 'marker' && mouseToolState.value.title !== item.name)) {
  423. if (type === 'text') {
  424. mouseToolState.value.graphicsType = type;
  425. handleTextEdit();
  426. } else if (type === 'marker') {
  427. const data = {
  428. graphicsType: type,
  429. lineWidth: mouseToolState.value.lineWidth,
  430. color: mouseToolState.value.color,
  431. icon: item.icon,
  432. size: item.size,
  433. title: item.name
  434. };
  435. drawing.value = true;
  436. mouseToolState.value = data;
  437. } else {
  438. showTextEdit.value = false;
  439. drawing.value = true;
  440. mouseToolState.value.graphicsType = type;
  441. }
  442. const drawTool = getDrawTool();
  443. const newOptions = drawTool.drawGraphics(mouseToolState.value);
  444. if (newOptions.graphicsType !== 'text') {
  445. // 绘制完成事件
  446. initDrawMethod(newOptions);
  447. }
  448. menuActive3.value = index;
  449. } else {
  450. showTextEdit.value = false;
  451. drawing.value = false;
  452. mouseToolState.value.graphicsType = '';
  453. menuActive3.value = '';
  454. }
  455. };
  456. const handleTextEdit = () => {
  457. const drawTool = getDrawTool();
  458. const map = drawTool.getMap();
  459. drawTool.closeDraw();
  460. // 监听地图点击事件
  461. map.on('click', handleClickMap);
  462. };
  463. const handleClickMap = (e) => {
  464. // 获取点击位置的经纬度
  465. lnglat.value = [e.lnglat.lng, e.lnglat.lat];
  466. showTextEdit.value = true;
  467. };
  468. const addText = (textEditState) => {
  469. const data = {
  470. graphicsType: 'text',
  471. lineWidth: mouseToolState.value.lineWidth,
  472. color: mouseToolState.value.color,
  473. text: textEditState.text,
  474. fontColor: textEditState.fontColor,
  475. fontSize: textEditState.fontSize,
  476. lnglat: lnglat.value
  477. };
  478. showTextEdit.value = false;
  479. drawing.value = true;
  480. mouseToolState.value = data;
  481. // 绘制完成事件
  482. const drawTool = getDrawTool();
  483. const res = drawTool.drawGraphics(mouseToolState.value);
  484. overlays.push(res.text);
  485. overlaysData.push(res.data);
  486. commit(deepClone(overlaysData));
  487. res.text.on('rightclick', handleRightClick);
  488. const map = drawTool.getMap();
  489. // 监听地图点击事件
  490. map.off('click', handleClickMap);
  491. close();
  492. };
  493. // watch(
  494. // () => mouseToolState.value.graphicsType,
  495. // (value) => {
  496. // if (value) {
  497. // const map = getMap();
  498. // map.off('click', handleClickMap);
  499. // }
  500. // }
  501. // );
  502. const changeDrawing = () => {
  503. drawing.value = !drawing.value;
  504. };
  505. const close = () => {
  506. const drawTool = getDrawTool();
  507. drawTool.closeDraw();
  508. drawing.value = false;
  509. menuActive3.value = '';
  510. mouseToolState.value.graphicsType = '';
  511. };
  512. // 初始化绘制完成回调
  513. const initDrawMethod = (options) => {
  514. const drawTool = getDrawTool();
  515. const mouseTool = drawTool.getMouseTool();
  516. const onDraw = (event) => {
  517. mouseTool.off('draw', onDraw);
  518. close();
  519. const obj = event.obj;
  520. const id = nanoid();
  521. obj._opts.extData = {
  522. id: id
  523. };
  524. const data: any = deepClone(options);
  525. data.id = id;
  526. if (options.type == 'marker') {
  527. const position = obj.getPosition();
  528. data.lnglat = [position.lng, position.lat];
  529. data.latitude = position.lat;
  530. data.longitude = position.lng;
  531. data.image = data.icon;
  532. data.image = data.icon;
  533. data.imageHover = data.icon;
  534. } else {
  535. const path = obj.getPath();
  536. // 将AMap.LngLat对象数组转换为经纬度数组
  537. const pathArr = path.map((lngLat) => {
  538. // 返回经度和纬度的数组
  539. return [lngLat.lng, lngLat.lat];
  540. });
  541. if (options.type !== 'straightLine') {
  542. pathArr.push(pathArr[0]);
  543. }
  544. data.path = pathArr;
  545. if (options.type == 'circle') {
  546. data.center = [obj.getCenter().lng, obj.getCenter().lat];
  547. data.radius = obj.getRadius();
  548. }
  549. }
  550. if (options.type == 'measureArea') {
  551. const AMap = getDrawTool().getAMap();
  552. const map = getMap();
  553. // 计算区域面积
  554. const area = Math.round(AMap.GeometryUtil.ringArea(data.path));
  555. const text = new AMap.Text({
  556. position: data.path[data.path.length - 1],
  557. text: '区域面积' + area + '平方米',
  558. offset: new AMap.Pixel(-20, -20)
  559. });
  560. data.area = area;
  561. map.add(text);
  562. overlays.push([obj, text]);
  563. overlaysData.push(data);
  564. commit(deepClone(overlaysData));
  565. } else {
  566. overlays.push(obj);
  567. overlaysData.push(data);
  568. commit(deepClone(overlaysData));
  569. console.log(overlaysData);
  570. }
  571. // 右击进入编辑
  572. obj.on('rightclick', handleRightClick);
  573. };
  574. mouseTool.on('draw', onDraw);
  575. };
  576. // 图形右击事件
  577. let rightClickObj;
  578. let initContextMenu = false;
  579. const handleRightClick = (event) => {
  580. rightClickObj = event.target;
  581. const contextMenu = getDrawTool().getContextMenu();
  582. if (!initContextMenu) {
  583. // 右键删除按钮
  584. contextMenu.addItem(
  585. '删除',
  586. function () {
  587. contextMenu.close();
  588. deleteGraphics();
  589. },
  590. 0
  591. );
  592. initContextMenu = true;
  593. }
  594. contextMenu.open(getMap(), event.lnglat);
  595. };
  596. // 删除图形
  597. const deleteGraphics = () => {
  598. const id = rightClickObj.getExtData()?.id;
  599. if (id) {
  600. for (let i = 0; i < overlays.length; i++) {
  601. const overlay = Array.isArray(overlays[i]) ? overlays[i][0] : overlays[i];
  602. if (overlay?.getExtData().id === id) {
  603. removeOverlayByIndex(i);
  604. commit(deepClone(overlaysData));
  605. rightClickObj = null;
  606. }
  607. }
  608. }
  609. };
  610. // 撤销绘制
  611. const handleUndo = () => {
  612. // drawing.value = false;
  613. const previous = history.value[history.value.length - 2];
  614. if (history.value.length > 1) {
  615. if (currentState.value.length > previous.length) {
  616. // 撤销新增
  617. removeOverlayByIndex(currentState.value.length - 1);
  618. } else {
  619. let restoreData;
  620. for (let i = 0; i < previous.length; i++) {
  621. let index = 0;
  622. for (let k = 0; k < currentState.value.length; k++) {
  623. if (previous[i].id !== currentState.value[k].id) {
  624. index++;
  625. } else {
  626. break;
  627. }
  628. }
  629. if (index === previous.length - 1) {
  630. restoreData = previous[i];
  631. break;
  632. }
  633. }
  634. if (restoreData) {
  635. const obj = getDrawTool().createGraphics(restoreData);
  636. overlays.push(obj);
  637. }
  638. }
  639. undo();
  640. console.log(history.value, future.value, currentState.value);
  641. }
  642. };
  643. // 根据索引移除覆盖物
  644. const removeOverlayByIndex = (index: number) => {
  645. const map = getMap();
  646. if (Array.isArray(overlays[index])) {
  647. overlays[index].forEach((overlay) => {
  648. // 移除地图上覆盖物
  649. map.remove(overlay);
  650. });
  651. } else {
  652. // 移除地图上覆盖物
  653. map.remove(overlays[index]);
  654. }
  655. overlays.splice(index, 1);
  656. overlaysData.splice(index, 1);
  657. };
  658. // 历史预案
  659. const queryParams = reactive({
  660. page: 1,
  661. pageSize: 9,
  662. pattern_name: ''
  663. });
  664. const patternList = ref([]);
  665. let total = ref(0);
  666. let editData = ref({
  667. id: '',
  668. pattern_name: '',
  669. content: {}
  670. });
  671. let showEdit = ref(false);
  672. const handleSubmit = () => {
  673. showEdit.value = false;
  674. editData.value = {
  675. id: '',
  676. pattern_name: '',
  677. content: {}
  678. };
  679. getList();
  680. };
  681. const handleQuery = () => {
  682. queryParams.page = 1;
  683. getList();
  684. };
  685. const getList = () => {
  686. // if (menuActive1.value === 1 && menu.value[menuActive1.value].name == '历史预案') {
  687. getPatternList(queryParams).then((res) => {
  688. patternList.value = res.data;
  689. total.value = res.total;
  690. });
  691. // }
  692. };
  693. const handleDelete = (id: number) => {
  694. proxy?.$modal.confirm('是否确认删除选择的数据项?').then(() => {
  695. deletePatternById(id).then(() => {
  696. getList();
  697. });
  698. });
  699. };
  700. const handleEdit = (id) => {
  701. getPatternInfo(id).then((res) => {
  702. editData.value = res.data;
  703. editData.value.id = id;
  704. });
  705. showEdit.value = true;
  706. };
  707. const handleShare = (type, id?: string) => {
  708. shareState.type = type;
  709. shareState.id = id;
  710. shareState.showShare = true;
  711. };
  712. const handleCloseShare = () => {
  713. shareState.type = '';
  714. shareState.id = '';
  715. };
  716. const handleCloseCollaboration = () => {
  717. closeCollaboration({ pattern_id: patternId.value }).then(() => {
  718. collaboration.value = false;
  719. });
  720. };
  721. const handleSaveCollaboration = () => {
  722. };
  723. let showForm = ref(false);
  724. let form = ref({
  725. pattern_id: '',
  726. user_id_list: [],
  727. name: '',
  728. pattern_name: '',
  729. visible: 'false',
  730. content: ''
  731. });
  732. const handleShareConfirm = (data) => {
  733. if (shareState.type === '1') {
  734. // 协同标绘
  735. const userIdList = [];
  736. data.forEach((item) => {
  737. userIdList.push(item.userId);
  738. });
  739. let content = currentState.value.length > 0 ? JSON.stringify(currentState.value[currentState.value.length - 1]) : '';
  740. form.value = {
  741. pattern_id: nanoid(),
  742. user_id_list: userIdList,
  743. name: '',
  744. pattern_name: '',
  745. visible: 'false',
  746. content: content
  747. };
  748. showForm.value = true;
  749. } else {
  750. // 分享
  751. }
  752. shareState.type = '';
  753. shareState.id = '';
  754. };
  755. const getWebSocketData = (data) => {
  756. console.log('接收数据', data);
  757. };
  758. const handleSendForm = () => {
  759. // createWebSocket('v7fUAuygwZUs24Nx3RDnL', getWebSocketData);
  760. // patternId.value = 'v7fUAuygwZUs24Nx3RDnL';
  761. createCollaboration(form.value).then(() => {
  762. patternId.value = form.value.pattern_id;
  763. createWebSocket(form.value.pattern_id, getWebSocketData);
  764. });
  765. collaboration.value = true;
  766. };
  767. const handleShowDialog = () => {
  768. editData.value = {
  769. id: '',
  770. pattern_name: '',
  771. content: currentState.value
  772. };
  773. showEdit.value = true;
  774. };
  775. let dataURL = ref('');
  776. // 页面元素转图片
  777. const handleScreenshot = () => {
  778. const canvasBox = getMap().Iv;
  779. // 手动创建一个 canvas 标签
  780. const canvas = document.createElement('canvas');
  781. if (canvasBox) {
  782. // 获取父级的宽高
  783. const width = parseInt(window.getComputedStyle(canvasBox).width) / containerScale().scaleX;
  784. const height = parseInt(window.getComputedStyle(canvasBox).height) / containerScale().scaleX;
  785. canvas.style.width = width + 'px';
  786. canvas.style.height = height + 'px';
  787. const options = {
  788. backgroundColor: null, // 设置背景色为透明
  789. useCORS: true, //是否尝试使用CORS从服务器加载图像,解决跨域问题
  790. tainttest: true, // 是否在渲染前测试图片
  791. logging: false // 不启动日志调试
  792. };
  793. // canvasBox是要截图的元素,options是一些相关配置
  794. html2canvas(canvasBox, options).then((canvas) => {
  795. // toDataURL 图片格式转成 base64
  796. dataURL.value = canvas.toDataURL('image/png');
  797. // 新建一个a标签
  798. var oA = document.createElement('a');
  799. oA.download = '截图'; // 设置下载的文件名
  800. oA.href = dataURL.value;
  801. document.body.appendChild(oA);
  802. oA.click(); // 模拟点击a标签
  803. oA.remove(); // 下载之后把创建的元素删除
  804. });
  805. }
  806. };
  807. let showLayer = ref(false);
  808. let handleShowLayer = () => {
  809. showLayer.value = true;
  810. };
  811. onMounted(() => {
  812. getList();
  813. });
  814. </script>
  815. <style lang="scss" scoped>
  816. .menu-content {
  817. width: 1584px;
  818. height: 1772px;
  819. background: url('@/assets/images/map/rightMenu/onlinePlotting/dialog.png') no-repeat;
  820. padding: 130px 45px 20px 50px;
  821. font-size: 36px;
  822. position: relative;
  823. color: #ffffff;
  824. }
  825. .title {
  826. font-size: 60px;
  827. position: absolute;
  828. top: 30px;
  829. left: 140px;
  830. }
  831. :deep(.el-color-dropdown__link-btn) {
  832. display: none;
  833. }
  834. .line {
  835. display: flex;
  836. justify-content: space-between;
  837. align-items: center;
  838. }
  839. .tabs1 {
  840. margin-top: 45px;
  841. display: flex;
  842. .tab {
  843. width: 316px;
  844. height: 77px;
  845. line-height: 77px;
  846. background: url('@/assets/images/map/rightMenu/onlinePlotting/tab.png') no-repeat;
  847. cursor: pointer;
  848. font-size: 44px;
  849. color: #b7c1d5;
  850. font-family: YouSheBiaoTiHei;
  851. padding-left: 60px;
  852. &:hover {
  853. width: 317px;
  854. height: 83px;
  855. color: #ffffff;
  856. background: url('@/assets/images/map/rightMenu/onlinePlotting/tabActive.png') no-repeat;
  857. }
  858. }
  859. .tab_active {
  860. width: 317px;
  861. height: 83px;
  862. color: #ffffff;
  863. background: url('@/assets/images/map/rightMenu/onlinePlotting/tabActive.png') no-repeat;
  864. }
  865. }
  866. .btn1 {
  867. width: 440px;
  868. height: 150px;
  869. background: url('@/assets/images/map/rightMenu/onlinePlotting/btn1.png') no-repeat;
  870. background-size: 100% 100%;
  871. display: flex;
  872. justify-content: center;
  873. align-items: center;
  874. cursor: pointer;
  875. font-size: 32px;
  876. color: #edfaff;
  877. margin-bottom: -55px;
  878. .icon1 {
  879. width: 42px;
  880. height: 42px;
  881. background: url('@/assets/images/map/rightMenu/onlinePlotting/screenshot.png') no-repeat;
  882. margin-right: 12px;
  883. }
  884. }
  885. .btn2 {
  886. width: 278px;
  887. height: 78px;
  888. background: url('@/assets/images/map/rightMenu/btn.png') no-repeat;
  889. display: flex;
  890. justify-content: center;
  891. align-items: center;
  892. cursor: pointer;
  893. font-size: 32px;
  894. color: #edfaff;
  895. margin-bottom: -57px;
  896. .icon1 {
  897. width: 42px;
  898. height: 42px;
  899. background: url('@/assets/images/map/rightMenu/onlinePlotting/screenshot.png') no-repeat;
  900. margin-right: 12px;
  901. }
  902. }
  903. .box1 {
  904. margin-top: 20px;
  905. display: flex;
  906. justify-content: space-between;
  907. align-items: center;
  908. width: 1490px;
  909. height: 96px;
  910. background: url('@/assets/images/map/rightMenu/onlinePlotting/box1.png') no-repeat;
  911. padding: 25px 30px;
  912. .box-item {
  913. display: flex;
  914. align-items: center;
  915. }
  916. }
  917. .btn {
  918. display: flex;
  919. align-items: center;
  920. cursor: pointer;
  921. .revoke-icon {
  922. width: 48px;
  923. height: 50px;
  924. margin-right: 10px;
  925. background: url('@/assets/images/map/rightMenu/onlinePlotting/revoke.png') no-repeat;
  926. }
  927. .delete-icon {
  928. width: 50px;
  929. height: 50px;
  930. margin-right: 10px;
  931. background: url('@/assets/images/map/rightMenu/onlinePlotting/delete.png') no-repeat;
  932. }
  933. .edit-icon {
  934. width: 46px;
  935. height: 46px;
  936. margin-right: 10px;
  937. background: url('@/assets/images/map/rightMenu/onlinePlotting/edit.png') no-repeat;
  938. }
  939. .cancel-icon {
  940. width: 50px;
  941. height: 50px;
  942. margin-right: 10px;
  943. background: url('@/assets/images/map/rightMenu/onlinePlotting/cancel.png') no-repeat;
  944. }
  945. .save-icon {
  946. width: 46px;
  947. height: 46px;
  948. margin-right: 10px;
  949. background: url('@/assets/images/map/rightMenu/onlinePlotting/save.png') no-repeat;
  950. }
  951. .share-icon {
  952. width: 46px;
  953. height: 48px;
  954. margin-right: 10px;
  955. background: url('@/assets/images/map/rightMenu/onlinePlotting/share.png') no-repeat;
  956. }
  957. .setting-icon {
  958. width: 48px;
  959. height: 50px;
  960. margin-right: 10px;
  961. background: url('@/assets/images/map/rightMenu/onlinePlotting/setting.png') no-repeat;
  962. }
  963. .merge-icon {
  964. width: 52px;
  965. height: 52px;
  966. margin-right: 10px;
  967. background: url('@/assets/images/map/rightMenu/onlinePlotting/merge.png') no-repeat;
  968. }
  969. }
  970. .line2 {
  971. width: 3px;
  972. height: 24px;
  973. background-color: #a7ccdf;
  974. margin: 0 38px;
  975. }
  976. .tabs2 {
  977. width: 300px;
  978. min-width: 300px;
  979. height: 1240px;
  980. background: url('@/assets/images/map/rightMenu/onlinePlotting/tabBg.png') no-repeat;
  981. background-size: 300px 1188px;
  982. overflow-y: auto;
  983. padding: 30px 0;
  984. .tab {
  985. width: 100%;
  986. height: 99px;
  987. cursor: pointer;
  988. color: #eaf3fc;
  989. font-size: 38px;
  990. padding: 0 60px;
  991. display: flex;
  992. align-items: center;
  993. &:hover {
  994. background: url('@/assets/images/map/rightMenu/onlinePlotting/tabActive2.png') no-repeat;
  995. }
  996. }
  997. .tab_active {
  998. background: url('@/assets/images/map/rightMenu/onlinePlotting/tabActive2.png') no-repeat;
  999. }
  1000. }
  1001. .tab-content {
  1002. display: flex;
  1003. margin-top: 20px;
  1004. .tab-content2 {
  1005. padding: 20px 45px;
  1006. display: flex;
  1007. flex-direction: column;
  1008. .line {
  1009. height: 100px;
  1010. }
  1011. .line3 {
  1012. display: flex;
  1013. }
  1014. .tab-list {
  1015. width: 100%;
  1016. flex: 1;
  1017. overflow-y: auto;
  1018. display: flex;
  1019. flex-wrap: wrap;
  1020. align-content: baseline;
  1021. .icon {
  1022. width: 160px;
  1023. height: 88px;
  1024. margin-bottom: 20px;
  1025. }
  1026. .tab {
  1027. &:nth-child(3n-1) {
  1028. margin: 40px 50px 0;
  1029. }
  1030. }
  1031. }
  1032. .tab {
  1033. width: 333px;
  1034. height: 235px;
  1035. background: url('@/assets/images/map/rightMenu/onlinePlotting/box2.png') no-repeat;
  1036. padding: 27px;
  1037. cursor: pointer;
  1038. position: relative;
  1039. font-size: 38px;
  1040. color: #eaf3fc;
  1041. display: flex;
  1042. flex-direction: column;
  1043. justify-content: center;
  1044. align-items: center;
  1045. margin-top: 40px;
  1046. &:hover {
  1047. background: url('@/assets/images/map/rightMenu/onlinePlotting/boxHover2.png') no-repeat;
  1048. }
  1049. .checked1 {
  1050. position: absolute;
  1051. top: 30px;
  1052. right: 30px;
  1053. width: 32px;
  1054. height: 32px;
  1055. background: url('@/assets/images/map/rightMenu/onlinePlotting/checked1.png') no-repeat;
  1056. }
  1057. .checked2 {
  1058. position: absolute;
  1059. top: 30px;
  1060. right: 30px;
  1061. width: 36px;
  1062. height: 36px;
  1063. background: url('@/assets/images/map/rightMenu/onlinePlotting/checked2.png') no-repeat;
  1064. }
  1065. }
  1066. .tab_active {
  1067. background: url('@/assets/images/map/rightMenu/onlinePlotting/boxActive2.png') no-repeat;
  1068. }
  1069. }
  1070. }
  1071. .tipTitle {
  1072. position: absolute;
  1073. top: 0;
  1074. left: -2745px;
  1075. z-index: 2;
  1076. padding: 10px 30px;
  1077. font-size: 38px;
  1078. color: #fff;
  1079. background-color: rgba(0, 0, 0, 0.4);
  1080. border-radius: 10px;
  1081. }
  1082. .tab-content3 {
  1083. .custom-table {
  1084. width: 100%;
  1085. color: #000;
  1086. .table-header {
  1087. display: flex;
  1088. font-size: 38px;
  1089. width: 100%;
  1090. background-color: #194ba0;
  1091. .th {
  1092. padding: 25px 30px;
  1093. flex: 1;
  1094. color: #edfaff;
  1095. &:last-child {
  1096. flex: unset;
  1097. width: 620px;
  1098. }
  1099. }
  1100. }
  1101. .tr {
  1102. display: flex;
  1103. font-size: 38px;
  1104. width: 1487px;
  1105. background: url('@/assets/images/map/rightMenu/onlinePlotting/tr.png') no-repeat;
  1106. background-size: 100% 100%;
  1107. margin-top: 10px;
  1108. &:hover {
  1109. background: url('@/assets/images/map/rightMenu/onlinePlotting/trActive.png') no-repeat;
  1110. }
  1111. .td {
  1112. padding: 25px 30px;
  1113. color: #edfaff;
  1114. flex: 1;
  1115. .icon {
  1116. margin: 0 10px;
  1117. cursor: pointer;
  1118. }
  1119. }
  1120. .td2 {
  1121. flex: unset;
  1122. width: 620px;
  1123. display: flex;
  1124. justify-content: center;
  1125. align-items: center;
  1126. }
  1127. }
  1128. }
  1129. }
  1130. .color-container {
  1131. width: 80px;
  1132. height: 50px;
  1133. display: flex;
  1134. justify-content: center;
  1135. align-items: center;
  1136. position: relative;
  1137. background-color: #0d3980;
  1138. border: 4px solid #0b5fbb;
  1139. margin-left: 20px;
  1140. :deep(.el-color-picker) {
  1141. height: 60px !important;
  1142. }
  1143. &::before {
  1144. content: '';
  1145. position: absolute;
  1146. top: 0;
  1147. left: 0;
  1148. width: 12px;
  1149. height: 12px;
  1150. background: url('@/assets/images/inputIcon1.png') no-repeat;
  1151. }
  1152. &::after {
  1153. content: '';
  1154. position: absolute;
  1155. right: 0;
  1156. bottom: 0;
  1157. width: 12px;
  1158. height: 12px;
  1159. background: url('@/assets/images/inputIcon2.png') no-repeat;
  1160. }
  1161. }
  1162. .params-box {
  1163. margin: 30px 0;
  1164. }
  1165. .footer {
  1166. display: flex;
  1167. justify-content: flex-end;
  1168. margin-top: 30px;
  1169. padding-right: 40px;
  1170. :deep(.el-pagination__total) {
  1171. color: #a7ccdf;
  1172. font-size: 32px;
  1173. }
  1174. :deep(.el-pagination) {
  1175. .btn-next,
  1176. .btn-prev {
  1177. background-color: transparent;
  1178. border: none;
  1179. .el-icon {
  1180. font-size: 22px;
  1181. color: #a7ccdf;
  1182. }
  1183. }
  1184. .el-pager li {
  1185. width: 64px;
  1186. height: 64px;
  1187. line-height: 64px;
  1188. text-align: center;
  1189. font-size: 32px;
  1190. color: #a7ccdf;
  1191. background-color: #0e3064;
  1192. border: 1px solid #0c57a7;
  1193. margin: 0 6px;
  1194. &:hover {
  1195. background-color: #038dff;
  1196. border: 1px solid #038dff;
  1197. }
  1198. }
  1199. .el-pager li.is-active {
  1200. background-color: #038dff;
  1201. border: 1px solid #038dff;
  1202. }
  1203. }
  1204. }
  1205. .btn-box {
  1206. display: flex;
  1207. align-items: center;
  1208. }
  1209. </style>