pestdistribute.vue 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909
  1. <!-- -->
  2. <template>
  3. <div
  4. class="pestbox"
  5. v-loading="pestboxloading"
  6. element-loading-text="拼命加载中"
  7. element-loading-spinner="el-icon-loading"
  8. element-loading-background="rgba(0, 0, 0, 0.8)"
  9. >
  10. <!-- <div
  11. :style="{ height: '100%', width: '100%' }"
  12. id="mychart"
  13. ref="mychart"
  14. ></div> -->
  15. <div class="amap-demo" id="mapContainer2"></div>
  16. <div class="searchbox">
  17. <el-select
  18. v-model="wornvalue"
  19. placeholder="请选择害虫名称"
  20. size="mini"
  21. @change="search"
  22. >
  23. <el-option
  24. v-for="item in wornoptions"
  25. :key="item.point_id"
  26. :label="item.point_name"
  27. :value="item.point_id"
  28. >
  29. </el-option>
  30. </el-select>
  31. <el-select
  32. v-model="inoffvalue"
  33. placeholder="请选择所在监测点"
  34. size="mini"
  35. @change="search"
  36. >
  37. <el-option
  38. v-for="item in inoffoptions"
  39. :key="item.point_name"
  40. :label="item.point_name"
  41. :value="item.point_name"
  42. >
  43. </el-option>
  44. </el-select>
  45. <el-select
  46. v-model="versionsvalue2"
  47. placeholder="请选择隶属组织"
  48. size="mini"
  49. @change="search"
  50. >
  51. <el-option
  52. v-for="item in versionsoptions2"
  53. :key="item.org_name"
  54. :label="item.org_name"
  55. :value="item.org_name"
  56. >
  57. </el-option>
  58. </el-select>
  59. <el-date-picker
  60. v-model="timevalue"
  61. type="daterange"
  62. range-separator="至"
  63. start-placeholder="开始日期"
  64. end-placeholder="结束日期"
  65. @change="oickchange"
  66. size="mini"
  67. :editable="false"
  68. >
  69. </el-date-picker>
  70. <el-button type="info" @click="search" size="mini">搜索</el-button>
  71. <el-button @click="reset" size="mini">重置</el-button>
  72. <el-button type="warning" @click="dialogVisible = true" size="mini"
  73. >设置</el-button
  74. >
  75. </div>
  76. <div class="piebox">
  77. <p
  78. :class="
  79. pietf ? 'iconbox el-icon-arrow-right' : 'iconbox el-icon-arrow-left'
  80. "
  81. @click="pietf = !pietf"
  82. style="cursor: pointer"
  83. ></p>
  84. <div
  85. :style="{
  86. height: '500px',
  87. width: width,
  88. transition: 'all 1s ease',
  89. borderRadius: '10px',
  90. }"
  91. id="mychartpie"
  92. ref="mychartpie"
  93. v-loading="loading"
  94. element-loading-text="拼命加载中"
  95. element-loading-spinner="el-icon-loading"
  96. element-loading-background="rgba(0, 0, 0, 0.8)"
  97. ></div>
  98. </div>
  99. <div class="measurebox">
  100. <div
  101. :class="
  102. measure_index == 1 ? 'measurebox_item selmea' : 'measurebox_item'
  103. "
  104. @click="measure_distance"
  105. >
  106. <i class="iconfont icon-ceju"></i>
  107. <p>测距</p>
  108. </div>
  109. <p class="measurebox_line"></p>
  110. <div
  111. :class="
  112. measure_index == 2 ? 'measurebox_item selmea' : 'measurebox_item'
  113. "
  114. @click="measure_area"
  115. >
  116. <i class="iconfont icon-mianji"></i>
  117. <p>侧面</p>
  118. </div>
  119. </div>
  120. <el-dialog
  121. title="设置"
  122. :visible.sync="dialogVisible"
  123. width="500px"
  124. :close-on-click-modal="false"
  125. >
  126. <div class="shezhibox">
  127. <el-form
  128. :model="ruleForm"
  129. :rules="rules"
  130. ref="ruleForm"
  131. class="demo-ruleForm"
  132. >
  133. <el-form-item label="最大害虫数量设置可标红" prop="threshold">
  134. <el-input v-model="ruleForm.threshold" size="mini"></el-input>
  135. </el-form-item>
  136. </el-form>
  137. </div>
  138. <span slot="footer" class="dialog-footer">
  139. <el-button @click="resetForm('ruleForm')" size="mini">取 消</el-button>
  140. <el-button type="primary" @click="submitForm('ruleForm')" size="mini"
  141. >确 定</el-button
  142. >
  143. </span>
  144. </el-dialog>
  145. </div>
  146. </template>
  147. <script>
  148. //这里可以导入其他文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
  149. import * as echarts from "echarts";
  150. import { map, time } from "highcharts";
  151. export default {
  152. //import引入的组件需要注入到对象中才能使用
  153. components: {},
  154. data() {
  155. //这里存放数据
  156. var checklnglat = (rule, value, callback) => {
  157. if (isNaN(value)) {
  158. callback(new Error("请输入数字"));
  159. } else {
  160. callback();
  161. }
  162. };
  163. return {
  164. pietf: true,
  165. width: "500px",
  166. wornvalue: "", //有害生物名称 选择
  167. wornoptions: [], //有害生物列表
  168. inoffvalue: "", //监测点 选择
  169. inoffoptions: [], //监测点列表
  170. versionsvalue2: "", //隶属组织选择
  171. versionsoptions2: [], //隶属组织列表
  172. timevalue: "",
  173. start_time: "",
  174. end_time: "",
  175. loading: false,
  176. dialogVisible: false,
  177. ruleForm: {
  178. threshold: "100", //阈值
  179. },
  180. rules: {
  181. name: [
  182. { required: true, message: "请输入值", trigger: "blur" },
  183. { validator: checklnglat, trigger: "blur" },
  184. ],
  185. },
  186. pestboxloading: true,
  187. center: [114.052758, 22.545817],
  188. measure_index:0,
  189. mouseTool:null
  190. };
  191. },
  192. //监听属性 类似于data概念
  193. computed: {},
  194. //监控data中的数据变化
  195. watch: {
  196. pietf: function (val) {
  197. // console.log(this.width)
  198. if (val) {
  199. this.width = "500px";
  200. } else {
  201. this.width = "0";
  202. }
  203. // console.log(this.width)
  204. },
  205. },
  206. //方法集合
  207. methods: {
  208. ToDigital(lnglat) {
  209. // console.log(lnglat);
  210. if (!isNaN(lnglat)) {
  211. return lnglat;
  212. }
  213. lnglat = lnglat.toString();
  214. var strDu, strFen, strMiao;
  215. var duindex = lnglat.indexOf("°"); //字符度的下标
  216. var fenindex = lnglat.indexOf("′"); //字符分的下标
  217. var miaoindex = lnglat.indexOf("″"); //字符秒的下标
  218. strDu = lnglat.slice(0, duindex);
  219. strFen = lnglat.slice(duindex + 1, fenindex);
  220. strMiao = lnglat.slice(fenindex + 1, miaoindex);
  221. // len = len > 6 || typeof len == "undefined" ? 6 : len; //精确到小数点后最多六位
  222. strDu =
  223. typeof strDu == "undefined" || strDu == "" ? 0 : parseFloat(strDu);
  224. strFen =
  225. typeof strFen == "undefined" || strFen == ""
  226. ? 0
  227. : parseFloat(strFen) / 60;
  228. strMiao =
  229. typeof strMiao == "undefined" || strMiao == ""
  230. ? 0
  231. : parseFloat(strMiao) / 3600;
  232. var digital = strDu + strFen + strMiao;
  233. if (digital == 0) {
  234. return "";
  235. } else {
  236. return digital.toFixed(6);
  237. }
  238. },
  239. initmap() {
  240. var map = new AMap.Map(document.getElementById("mapContainer2"), {
  241. center: this.center,
  242. resizeEnable: true,
  243. zoom: 11,
  244. lang: "en",
  245. mapStyle: "amap://styles/fresh",
  246. layers: [],
  247. });
  248. //new AMap.TileLayer.Satellite(),new AMap.TileLayer.RoadNet()
  249. AMap.plugin(["AMap.ToolBar", "AMap.Geocoder"], () => {
  250. map.addControl(new AMap.ToolBar());
  251. this.geocoder = new AMap.Geocoder({
  252. city: "全国",
  253. radius: 1000,
  254. });
  255. });
  256. AMap.plugin(["AMap.MouseTool"], () => {
  257. this.mouseTool = new AMap.MouseTool(map);
  258. });
  259. this.map = map;
  260. this.getwornlist();
  261. },
  262. initpie(data) {
  263. var data = data;
  264. var placeHolderStyle = {
  265. normal: {
  266. label: {
  267. show: false,
  268. },
  269. labelLine: {
  270. show: false,
  271. },
  272. color: "rgba(0, 0, 0, 0)",
  273. borderColor: "rgba(0, 0, 0, 0)",
  274. borderWidth: 0,
  275. },
  276. };
  277. var data1 = [];
  278. var data2 = [];
  279. var colorIn = [
  280. "rgb(33, 166, 161)",
  281. "rgb(102,113,209)",
  282. "rgb(230,144,78)",
  283. "rgb(38,185,211)",
  284. "rgb(82,125,12)",
  285. "rgb(35,70,209)",
  286. ];
  287. var colorOut = [
  288. "rgba(33, 166, 161, 0.5)",
  289. "rgba(102,113,209, 0.5)",
  290. "rgba(230,144,78, 0.5)",
  291. "rgba(38,185,211, 0.5)",
  292. "rgb(82,125,12,0.5)",
  293. "rgb(35,70,209,0.5)",
  294. ];
  295. for (var i = 0; i < data.length; i++) {
  296. data1.push({
  297. data: data[i].value,
  298. value: data[i].value,
  299. name: data[i].name,
  300. itemStyle: {
  301. normal: {
  302. color: colorOut[i],
  303. },
  304. },
  305. });
  306. data2.push({
  307. data: data[i].value,
  308. value: data[i].value,
  309. name: data[i].name,
  310. itemStyle: {
  311. normal: {
  312. color: colorIn[i],
  313. },
  314. },
  315. });
  316. }
  317. var dataArr = [];
  318. for (var i = 0; i < 100; i++) {
  319. if (i % 2 === 0) {
  320. dataArr.push({
  321. name: (i + 1).toString(),
  322. value: 25,
  323. itemStyle: {
  324. normal: {
  325. color: "#2ac9e1",
  326. borderWidth: 0,
  327. borderColor: "rgba(0,0,0,0)",
  328. },
  329. },
  330. });
  331. } else {
  332. dataArr.push({
  333. name: (i + 1).toString(),
  334. value: 20,
  335. itemStyle: {
  336. normal: {
  337. color: "rgba(0,0,0,0)",
  338. borderWidth: 0,
  339. borderColor: "rgba(0,0,0,0)",
  340. },
  341. },
  342. });
  343. }
  344. }
  345. var option = {
  346. title: {
  347. text: "有害生物占比",
  348. subtext: "",
  349. sublink: "",
  350. left: "center",
  351. textStyle: {
  352. color: "#222222",
  353. },
  354. top: "5%",
  355. },
  356. backgroundColor: "#ffffff",
  357. tooltip: {
  358. title: "详情",
  359. trigger: "item",
  360. formatter: "{a} <br/>{b}: {c} ({d}%)",
  361. },
  362. legend: {
  363. orient: "horizontal",
  364. top: "90%",
  365. itemWidth: 10,
  366. itemHeight: 10,
  367. x: "center",
  368. textStyle: {
  369. color: "#222222",
  370. fontSize: 12,
  371. },
  372. show: true,
  373. // data: data,
  374. type: "scroll", //分页类型
  375. data: (function () {
  376. var list = [];
  377. for (var i = 0; i < data.length; i++) {
  378. list.push(data[i]);
  379. }
  380. return list;
  381. })(),
  382. pageIconColor: "#ff781f", //翻页箭头颜色
  383. pageTextStyle: {
  384. color: "#999", //翻页数字颜色
  385. }, //翻页数字设置
  386. pageIconSize: 13,
  387. itemHeight: 10,
  388. itemWidth: 15,
  389. },
  390. series: [
  391. {
  392. type: "pie",
  393. zlevel: 3,
  394. silent: true,
  395. // center: ['50%', '40%'],
  396. radius: ["43%", "45%"],
  397. label: {
  398. normal: {
  399. show: false,
  400. },
  401. },
  402. labelLine: {
  403. normal: {
  404. show: false,
  405. },
  406. },
  407. data: dataArr,
  408. },
  409. {
  410. name: "详情",
  411. type: "pie",
  412. selectedMode: "single",
  413. radius: [0, "40%"],
  414. label: {
  415. formatter: "",
  416. position: "inner",
  417. },
  418. data: data2,
  419. },
  420. {
  421. name: "详情",
  422. type: "pie",
  423. radius: ["48%", "50%"],
  424. labelLine: {
  425. normal: {
  426. length: 10,
  427. length2: 14,
  428. },
  429. },
  430. label: {
  431. show: true,
  432. position: "outer",
  433. alignTo: "labelLine",
  434. // ·圆点
  435. backgroundColor: "auto",
  436. height: 0,
  437. width: 0,
  438. lineHeight: 0,
  439. distanceToLabelLine: 0,
  440. borderRadius: 2.5,
  441. padding: [2.5, -2.5, 2.5, -2.5],
  442. formatter: "{a|{b} }",
  443. rich: {
  444. a: {
  445. padding: [0, 0, 0, 10],
  446. color: "#151515",
  447. fontSize: 14,
  448. },
  449. b: {
  450. padding: [0, 10, 0, 0],
  451. fontSize: 14,
  452. },
  453. },
  454. },
  455. data: data1,
  456. },
  457. ],
  458. };
  459. echarts.init(document.getElementById("mychartpie")).setOption(option);
  460. },
  461. getwornlist() {
  462. this.loading = true;
  463. this.$axios({
  464. method: "POST",
  465. url: "/api/api_gateway?method=monitor_manage.home_map.pest_distribute_new",
  466. data: this.qs.stringify({
  467. pest_name: this.wornvalue, // 非必传(string) 有害生物名称 搜索项
  468. point_name: this.inoffvalue, // 非必传(string) 设备所属监测点 搜索项
  469. org_name: this.versionsvalue2, // 非必传(string) 设备所属组织 搜索项
  470. start_time: this.start_time, // 非必传(string) 开始时间 搜索项 2022-01-20
  471. end_time: this.end_time, // 非必传(string) 结束时间 搜索项 2022-01-23
  472. }),
  473. }).then((res) => {
  474. // console.log(res.data.data);
  475. this.map.clearMap();
  476. var resdata = res.data.data;
  477. this.loading = false;
  478. var pest_count = res.data.data.pest_count;
  479. var arr = [];
  480. for (var i = 0; i < pest_count.length; i++) {
  481. var obj = {
  482. value: pest_count[i].sum,
  483. name: pest_count[i].pest_name,
  484. };
  485. arr.push(obj);
  486. }
  487. var capitals = [];
  488. if (resdata.huizhou) {
  489. for (var i = 0; i < resdata.huizhou.length; i++) {
  490. var obj = {
  491. device_id: resdata.huizhou[i].device_id,
  492. pest_data: resdata.huizhou[i].pest_data,
  493. pest_total: resdata.huizhou[i].pest_total,
  494. name: "北京",
  495. center: [
  496. this.ToDigital(resdata.huizhou[i].lng),
  497. this.ToDigital(resdata.huizhou[i].lat),
  498. ],
  499. };
  500. capitals.push(obj);
  501. }
  502. }
  503. if (resdata.shenzhen) {
  504. for (var i = 0; i < resdata.shenzhen.length; i++) {
  505. var obj = {
  506. device_id: resdata.shenzhen[i].device_id,
  507. pest_data: resdata.shenzhen[i].pest_data,
  508. pest_total: resdata.shenzhen[i].pest_total,
  509. center: [
  510. this.ToDigital(resdata.shenzhen[i].lng),
  511. this.ToDigital(resdata.shenzhen[i].lat),
  512. ],
  513. };
  514. capitals.push(obj);
  515. }
  516. }
  517. if (resdata.shanwei) {
  518. for (var i = 0; i < resdata.shanwei.length; i++) {
  519. var obj = {
  520. device_id: resdata.shanwei[i].device_id,
  521. pest_data: resdata.shanwei[i].pest_data,
  522. pest_total: resdata.shanwei[i].pest_total,
  523. center: [
  524. this.ToDigital(resdata.shanwei[i].lng),
  525. this.ToDigital(resdata.shanwei[i].lat),
  526. ],
  527. };
  528. capitals.push(obj);
  529. }
  530. }
  531. var maxnum = 0;
  532. for (var i = 0; i < capitals.length; i += 1) {
  533. if (capitals[i].pest_total > maxnum) {
  534. console.log();
  535. maxnum = capitals[i].pest_total;
  536. }
  537. }
  538. for (var i = 0; i < capitals.length; i += 1) {
  539. var color = "";
  540. if (capitals[i].pest_total > Math.floor(maxnum * 0.8)) {
  541. color = "#ff0202";
  542. } else if (capitals[i].pest_total > Math.floor(maxnum * 0.6)) {
  543. color = "#ff4902";
  544. } else if (capitals[i].pest_total > Math.floor(maxnum * 0.4)) {
  545. color = "#ffe402";
  546. } else if (capitals[i].pest_total > Math.floor(maxnum * 0.2)) {
  547. color = "#ff00ba";
  548. } else {
  549. color = "#0cff00";
  550. }
  551. var center = capitals[i].center;
  552. var device_id = capitals[i].device_id;
  553. var pest_data = capitals[i].pest_data;
  554. var pest_total = capitals[i].pest_total;
  555. var circleMarker = new AMap.CircleMarker({
  556. center: center,
  557. device_id: device_id,
  558. pest_data: pest_data,
  559. pest_total: pest_total,
  560. radius: 8, //3D视图下,CircleMarker半径不要超过64px
  561. strokeColor: "white",
  562. strokeWeight: 2,
  563. strokeOpacity: 0.5,
  564. fillColor: color,
  565. fillOpacity: 0.8,
  566. zIndex: 10,
  567. bubble: true,
  568. cursor: "pointer",
  569. clickable: true,
  570. });
  571. circleMarker.setMap(this.map);
  572. circleMarker.on("click", (e) => {
  573. // console.log(e.target);
  574. this.openInfo(e.target._opts);
  575. });
  576. }
  577. this.initpie(arr);
  578. this.pestboxloading = false;
  579. });
  580. },
  581. openInfo(info) {
  582. //构建信息窗体中显示的内容
  583. var str = ``;
  584. for (var i = 0; i < info.pest_data.length; i++) {
  585. str +=
  586. `<p>` +
  587. info.pest_data[i].pest_name +
  588. ` :` +
  589. info.pest_data[i].sum +
  590. ` 只</p>`;
  591. }
  592. var infoWindow = new AMap.InfoWindow({
  593. content:
  594. `<div style="height:100px;overflow-y: auto;"><p>设备id :` +
  595. info.device_id +
  596. `</p>` +
  597. str +
  598. `</div>`, //使用默认信息窗体框样式,显示信息内容
  599. });
  600. infoWindow.open(this.map, [info.center.lng, info.center.lat]);
  601. },
  602. getwornlistflex() {
  603. this.$axios({
  604. method: "POST",
  605. url: "/api/api_gateway?method=monitor_manage.home_map.pest_name_list",
  606. }).then((res) => {
  607. // console.log(res.data.data);
  608. this.wornoptions = [];
  609. var pest_list = res.data.data;
  610. for (var i = 0; i < pest_list.length; i++) {
  611. var obj2 = {
  612. point_id: pest_list[i].pest_name,
  613. point_name: pest_list[i].pest_name,
  614. };
  615. this.wornoptions.push(obj2);
  616. }
  617. });
  618. },
  619. tabtime(times) {
  620. //时间转换
  621. var years = times.getFullYear();
  622. var month = times.getMonth() + 1;
  623. var date = times.getDate();
  624. return years + "-" + month + "-" + date;
  625. },
  626. oickchange(e) {
  627. if (e) {
  628. this.start_time = this.tabtime(e[0]);
  629. this.end_time = this.tabtime(e[1]);
  630. } else {
  631. this.start_time = "";
  632. this.end_time = "";
  633. }
  634. },
  635. search() {
  636. this.getwornlist();
  637. },
  638. reset() {
  639. this.wornvalue = "";
  640. this.inoffvalue = "";
  641. this.versionsvalue2 = "";
  642. this.timevalue = "";
  643. this.getwornlist();
  644. },
  645. getmon2() {
  646. this.$axios({
  647. method: "POST",
  648. url: "/api/api_gateway?method=monitor_manage.trap_manage.pest_trap_org",
  649. }).then((res) => {
  650. // console.log(res.data.data);
  651. this.versionsoptions2 = [];
  652. var org_list = res.data.data.org_list;
  653. for (var i = 0; i < org_list.length; i++) {
  654. if (org_list[i].org_name != "") {
  655. this.versionsoptions2.push(org_list[i]);
  656. }
  657. }
  658. // this.versionsoptions2 = res.data.data.org_list;
  659. this.inoffoptions = res.data.data.point_data;
  660. this.initmap();
  661. });
  662. },
  663. submitForm(formName) {
  664. this.$refs[formName].validate((valid) => {
  665. if (valid) {
  666. this.$axios({
  667. method: "POST",
  668. url: "/api/api_gateway?method=monitor_manage.home_map.pest_distribute_threshold",
  669. data: this.qs.stringify({
  670. threshold: this.ruleForm.threshold,
  671. }),
  672. }).then((res) => {
  673. if (res.data.data) {
  674. this.dialogVisible = false;
  675. if (document.getElementsByClassName("el-message").length == 0) {
  676. this.$message({
  677. showClose: true,
  678. message: "设置成功",
  679. type: "success",
  680. });
  681. }
  682. this.getwornlist();
  683. } else {
  684. if (document.getElementsByClassName("el-message").length == 0) {
  685. this.$message({
  686. showClose: true,
  687. message: "设置失败",
  688. type: "success",
  689. });
  690. }
  691. }
  692. });
  693. } else {
  694. if (document.getElementsByClassName("el-message").length == 0) {
  695. this.$message({
  696. showClose: true,
  697. message: "设置失败" + res.data.message,
  698. type: "warning",
  699. });
  700. }
  701. // return false;
  702. }
  703. });
  704. },
  705. resetForm(formName) {
  706. this.dialogVisible = false;
  707. this.$refs[formName].resetFields();
  708. },
  709. //距离测量
  710. measure_distance() {
  711. this.measure_index = 1;
  712. this.draw("rule");
  713. window.addEventListener("dblclick", () => {
  714. this.measure_index = 0;
  715. this.mouseTool.close();
  716. });
  717. window.addEventListener("contextmenu", () => {
  718. this.measure_index = 0;
  719. this.mouseTool.close();
  720. });
  721. },
  722. //面积测量
  723. measure_area() {
  724. this.measure_index = 2;
  725. this.draw("measureArea");
  726. window.addEventListener("dblclick", () => {
  727. this.measure_index = 0;
  728. this.mouseTool.close();
  729. });
  730. window.addEventListener("contextmenu", () => {
  731. this.measure_index = 0;
  732. this.mouseTool.close();
  733. });
  734. },
  735. measure_close() {
  736. this.measure_index = 0;
  737. this.mouseTool.close(true);
  738. },
  739. draw(type) {
  740. console.log(type);
  741. // this.mouseTool.close(true);
  742. var mouseTool = this.mouseTool;
  743. switch (type) {
  744. case "rule": {
  745. mouseTool.rule({
  746. startMarkerOptions: {
  747. //可缺省
  748. icon: new AMap.Icon({
  749. size: new AMap.Size(19, 31), //图标大小
  750. imageSize: new AMap.Size(19, 31),
  751. image: "//webapi.amap.com/theme/v1.3/markers/b/start.png",
  752. }),
  753. offset: new AMap.Pixel(-9, -31),
  754. },
  755. endMarkerOptions: {
  756. //可缺省
  757. icon: new AMap.Icon({
  758. size: new AMap.Size(19, 31), //图标大小
  759. imageSize: new AMap.Size(19, 31),
  760. image: "//webapi.amap.com/theme/v1.3/markers/b/end.png",
  761. }),
  762. offset: new AMap.Pixel(-9, -31),
  763. },
  764. midMarkerOptions: {
  765. //可缺省
  766. icon: new AMap.Icon({
  767. size: new AMap.Size(19, 31), //图标大小
  768. imageSize: new AMap.Size(19, 31),
  769. image: "//webapi.amap.com/theme/v1.3/markers/b/mid.png",
  770. }),
  771. offset: new AMap.Pixel(-9, -31),
  772. },
  773. lineOptions: {
  774. //可缺省
  775. strokeStyle: "solid",
  776. strokeColor: "#FF33FF",
  777. strokeOpacity: 1,
  778. strokeWeight: 2,
  779. },
  780. //同 RangingTool 的 自定义 设置,缺省为默认样式
  781. });
  782. break;
  783. }
  784. case "measureArea": {
  785. mouseTool.measureArea({
  786. strokeColor: "#80d8ff",
  787. fillColor: "#80d8ff",
  788. fillOpacity: 0.3,
  789. //同 Polygon 的 Option 设置
  790. });
  791. break;
  792. }
  793. }
  794. },
  795. },
  796. beforeCreate() {}, //生命周期 - 创建之前
  797. //生命周期 - 创建完成(可以访问当前this实例)
  798. created() {},
  799. beforeMount() {}, //生命周期 - 挂载之前
  800. //生命周期 - 挂载完成(可以访问DOM元素)
  801. mounted() {
  802. this.getmon2();
  803. this.getwornlistflex();
  804. // this.getmon();
  805. },
  806. beforeUpdate() {}, //生命周期 - 更新之前
  807. updated() {}, //生命周期 - 更新之后
  808. beforeDestroy() {}, //生命周期 - 销毁之前
  809. destroyed() {}, //生命周期 - 销毁完成
  810. activated() {}, //如果页面有keep-alive缓存功能,这个函数会触发
  811. };
  812. </script>
  813. <style lang="less" scoped>
  814. .pestbox {
  815. width: 100%;
  816. height: 97%;
  817. position: relative;
  818. overflow: hidden;
  819. #mapContainer2 {
  820. width: 100%;
  821. height: 100%;
  822. /deep/.amap-logo {
  823. display: none !important;
  824. }
  825. /deep/.amap-copyright {
  826. display: none !important;
  827. }
  828. }
  829. .searchbox {
  830. position: absolute;
  831. top: 10px;
  832. left: 15px;
  833. /deep/.el-select {
  834. margin-right: 10px;
  835. }
  836. /deep/.el-date-editor {
  837. margin-right: 10px;
  838. }
  839. /deep/.el-button--info {
  840. background-color: #409eff;
  841. border-color: #409eff;
  842. }
  843. }
  844. .piebox {
  845. position: absolute;
  846. top: 0;
  847. right: 0;
  848. display: flex;
  849. height: 100%;
  850. transition: width 1s ease;
  851. .iconbox {
  852. width: 30px;
  853. height: 50px;
  854. background-color: chocolate;
  855. color: #fff;
  856. line-height: 50px;
  857. text-align: center;
  858. font-size: 25px;
  859. }
  860. /deep/canvas {
  861. border-radius: 10px;
  862. }
  863. #mychartpie {
  864. // background-color: #04243e;
  865. background-color: #fff;
  866. border-radius: 10px;
  867. }
  868. }
  869. .measurebox {
  870. position: absolute;
  871. right: 20px;
  872. bottom: 20px;
  873. background-color: #fff;
  874. border-radius: 4px;
  875. box-shadow: 0 0 3px rgb(0 0 0 / 50%);
  876. padding: 10px 5px;
  877. .measurebox_item {
  878. text-align: center;
  879. font-size: 14px;
  880. }
  881. .measurebox_line {
  882. margin: 10px 0;
  883. border-bottom: 1px solid;
  884. }
  885. .selmea {
  886. color: #409eff;
  887. }
  888. }
  889. }
  890. /deep/.el-dialog__body {
  891. padding-bottom: 0;
  892. }
  893. .shezhibox {
  894. /deep/.el-input {
  895. width: 50%;
  896. }
  897. }
  898. /deep/.el-date-editor {
  899. cursor: pointer;
  900. .el-range-input {
  901. cursor: pointer;
  902. }
  903. }
  904. /deep/.amap-controls {
  905. display: none !important;
  906. }
  907. </style>