wpjg.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678
  1. <template>
  2. <borderTemplate titleName="卫片监管" class="wpjg">
  3. <template v-slot:title>
  4. <!-- #content="row" -->
  5. </template>
  6. <div class="stacontent">
  7. <div class="item">
  8. <span class="dlabel">图斑面积:</span>
  9. <span class="dvalue">{{ (title.tb_mj / 1000).toFixed(2) || 0 }}k㎡</span>
  10. </div>
  11. <div class="item cursor" @click="draw_vector">
  12. <span class="dlabel"> 图斑个数:</span>
  13. <span class="dvalue">{{ title.tb_num || 0 }}个</span>
  14. <i style="pointer-events:all" :class="{ 'el-icon-view': true }"></i>
  15. </div>
  16. <div class="item">
  17. <span class="dlabel">违法占地:</span>
  18. <span class="dvalue">{{ wf_mj_computed }}</span>
  19. </div>
  20. <div class="item">
  21. <span class="dlabel"> 违法率:</span>
  22. <span class="dvalue">{{ wfl_computed }}</span>
  23. </div>
  24. </div>
  25. <div id="wpjg_echart" v-show="xzqh_flag"></div>
  26. <div id="wpjg_echart_xzqh" v-show="!xzqh_flag">
  27. </div>
  28. </borderTemplate>
  29. </template>
  30. <script>
  31. import borderTemplate from "./borderTemplate.vue";
  32. //这里可以导入其他文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
  33. import { QueryOne, QueryList } from "../../api/cockpitNew";
  34. export default {
  35. components: { borderTemplate },
  36. data() {
  37. return {
  38. sdata: {},
  39. title: {},
  40. zData: [],
  41. active_xzqh: [],
  42. xData: [],
  43. xData1: [],//检测板块
  44. xData2: [],//占用耕地
  45. xData3: [],//占用永久基本农田
  46. xData4: [],//违法占地
  47. xzqh_flag: true
  48. };
  49. },
  50. //监控data中的数据变化
  51. watch: {},
  52. methods: {
  53. draw_vector() {
  54. store.setViewerFlagb(false);
  55. store.setToolBarShow(false);
  56. store.setXzqh_flag(false);
  57. store.setCockpit_vector({
  58. title: '卫片监管完成项目',
  59. word: "年份权属名称",
  60. tableData: [],
  61. tablejscType: 'jsc_vpjg_zbmx',
  62. columns: ['图斑分类', '图斑来源', '图斑编号', '审核调查', '年份权属名称', '时间', '是否核查', '行政区划名称', '面积', '占用基本农田保护面积', '占用耕地面积'],
  63. })
  64. },
  65. switch_xzqh(value) {
  66. if (value.id == '4602') {
  67. this.xzqh_flag = true
  68. } else {
  69. this.xzqh_flag = false
  70. }
  71. this.zData.forEach((res) => {
  72. if (res.name == value.name) {
  73. this.active_xzqh = [];
  74. this.active_xzqh.push((res.tb_mj / 1000).toFixed(2), (res.zygdmj / 1000).toFixed(2), (res.zyjbntmj / 1000).toFixed(2), (res.wf_mj / 1000).toFixed(2),);
  75. }
  76. })
  77. this.init_wpjg_echart_xzqh(this.active_xzqh)
  78. },
  79. init_wpjg_echart_xzqh(data) {
  80. var dom = document.getElementById("wpjg_echart_xzqh");
  81. var myChart = window.echarts.init(dom);
  82. let barTopColor = ["#CBB835", "#33C6E2", '#157FFE', '#8F48F0'];
  83. let barBottomColor = ["#D09311", "#279AB0", '#154AD2', '#670BFF'];
  84. let option = {
  85. backgroundColor: 'rgba(0,0,0,0)',
  86. title: {
  87. show: false,
  88. text: '一行动一活动开展情况',
  89. top: 20,
  90. left: 'center',
  91. textStyle: {
  92. color: '#00eaff',
  93. fontSize: 18,
  94. fontWeight: 'normal'
  95. }
  96. },
  97. tooltip: {
  98. show: false,
  99. trigger: 'axis',
  100. formatter: '一行动一活动开展情况<br>{b}:{c}',
  101. backgroundColor: 'rgba(18, 57, 60, .8)', //设置背景颜色
  102. textStyle: {
  103. color: '#fff'
  104. },
  105. borderColor: "rgba(18, 57, 60, .8)",
  106. axisPointer: {
  107. type: 'shadow',
  108. shadowStyle: {
  109. color: 'rgba(0, 11, 34, .4)',
  110. }
  111. }
  112. },
  113. grid: {
  114. top: '14%',
  115. bottom: '1%',
  116. left: '0%',
  117. right: '30%',
  118. containLabel: true
  119. },
  120. xAxis: {
  121. axisTick: {
  122. show: false
  123. },
  124. axisLine: {
  125. show: false,
  126. lineStyle: {
  127. color: '#1C82C5'
  128. }
  129. },
  130. axisLabel: {
  131. show: false,
  132. rotate: 20,
  133. margin: 30,
  134. textStyle: {
  135. fontSize: 14,
  136. color: '#DEEBFF',
  137. align: 'center'
  138. }
  139. },
  140. interval: 0
  141. },
  142. yAxis: {
  143. data: ['监测图斑', '占用耕地', '占用永久...', '违法占地'],
  144. splitLine: {
  145. show: false,
  146. lineStyle: {
  147. color: 'rgba(28, 130, 197, .3)'
  148. }
  149. },
  150. axisTick: {
  151. show: false
  152. },
  153. axisLine: {
  154. show: false,
  155. lineStyle: {
  156. color: '#1C82C5'
  157. }
  158. },
  159. axisLabel: {
  160. show: true,
  161. margin: 10,
  162. textStyle: {
  163. fontSize: 12,
  164. color: '#DEEBFF',
  165. }
  166. },
  167. },
  168. series: [
  169. {
  170. name: '一行动一活动开展情况',
  171. type: 'pictorialBar',
  172. symbolSize: [8, 14],
  173. symbolOffset: [4, 0],
  174. z: 12,
  175. itemStyle: {
  176. normal: {
  177. color: function (params) {
  178. return barBottomColor[params.dataIndex];
  179. }
  180. }
  181. },
  182. label: {
  183. textStyle: {
  184. rich: {
  185. name: {
  186. color: "#fff", //#BCD3E5
  187. fontSize: 14,
  188. },
  189. value: {
  190. color: "#64DAFF",
  191. fontSize: 14,
  192. },
  193. unit: {
  194. color: "#fff", //#BCD3E5
  195. fontSize: 14,
  196. },
  197. },
  198. },
  199. show: true,
  200. position: 'right',
  201. fontSize: 16,
  202. formatter: function (params) {
  203. return `{value|${params.value}} {unit|k㎡}`;
  204. }
  205. },
  206. symbolPosition: 'end',
  207. data: data,
  208. }, {
  209. name: '一行动一活动开展情况',
  210. type: 'pictorialBar',
  211. symbolOffset: [-3, 0],
  212. symbolSize: [8, 14],
  213. z: 12,
  214. itemStyle: {
  215. normal: {
  216. color: function (params) {
  217. return barTopColor[params.dataIndex];
  218. }
  219. }
  220. },
  221. data: [22, 23, 18, 14],
  222. }, {
  223. type: 'bar',
  224. itemStyle: {
  225. normal: {
  226. color: function (params) {
  227. return new echarts.graphic.LinearGradient(
  228. 0, 0, 0, 1,
  229. [{
  230. offset: 1,
  231. color: barTopColor[params.dataIndex]
  232. },
  233. {
  234. offset: 0,
  235. color: barBottomColor[params.dataIndex]
  236. }
  237. ]
  238. );
  239. },
  240. opacity: .9
  241. }
  242. },
  243. z: 16,
  244. silent: true,
  245. barWidth: 15,
  246. barCategoryGap: '100%',
  247. data: data,
  248. }]
  249. };
  250. myChart.setOption(option);
  251. },
  252. init_wpjg_echart() {
  253. const that = this;
  254. var tdsc_my_chart = window.echarts.init(document.getElementById('wpjg_echart'));
  255. tdsc_my_chart.getZr().on('click', (params) => {
  256. // 这个部分照抄,你想通过点击拿到的当前柱条的数据,都可以在下面这些属性中拿到,如果我注释没有你想要的,需要console一下charts.getOption()查找对应的属性名
  257. // let pointInPixel = [params.offsetX, params.offsetY]
  258. // if (tdsc_my_chart.containPixel('grid', pointInPixel)) {
  259. // let xIndex = tdsc_my_chart.convertFromPixel({ seriesIndex: 0 }, [params.offsetX, params.offsetY])[0]
  260. // console.log(xIndex)
  261. // }
  262. const actionObj = params.topTarget
  263. console.log('actionObj', actionObj)
  264. const myKey = Object.keys(actionObj).sort().filter(_ => _.indexOf('ec_inner') !== -1)[0]
  265. console.log('myKey', myKey)
  266. const res = actionObj[myKey]
  267. console.log(`当前点击了第${res.dataIndex}组数据中的第${res.seriesIndex}个柱子`)
  268. var pointInPixel = [params.offsetX, params.offsetY];
  269. if (tdsc_my_chart.containPixel('grid', pointInPixel)) {
  270. /*此处添加具体执行代码*/
  271. var pointInGrid = tdsc_my_chart.convertFromPixel({ seriesIndex: 0 }, pointInPixel);
  272. //X轴序号
  273. var xIndex = pointInGrid[0];
  274. console.log('点击了横纵坐标', pointInPixel)
  275. console.log('【点击了第几组数据,纵坐标】', pointInGrid)
  276. //获取当前图表的option
  277. var op = tdsc_my_chart.getOption();
  278. console.log('数据信息', op)
  279. //获得图表中我们想要的数据---下面就不简写了,默认说我们的折现有2条吧
  280. var xValue = op.xAxis[0].data[xIndex];
  281. console.log('x轴所对应的名字', xValue)
  282. }
  283. });
  284. const legendType = 'center'
  285. let option = {
  286. backgroundColor: 'rgba(0,0,0,0)',
  287. grid: {
  288. containLabel: true,
  289. bottom: '1%',
  290. top: '40%',
  291. left: '5%',
  292. right: legendType === 'center' ? '5%' : '25%',
  293. },
  294. tooltip: {
  295. show: false,
  296. trigger: 'axis',
  297. axisPointer: {
  298. type: 'shadow',
  299. },
  300. },
  301. legend: {
  302. orient: legendType === 'center' ? '' : 'vertical',
  303. bottom: "80%",
  304. right: legendType === 'center' ? 'center' : '2%',
  305. // data: ['监测图斑', '占用耕地', '占用永久基本农田', '违法占地'],
  306. itemWidth: 12,
  307. itemHeight: 12,
  308. itemGap: 20,
  309. icon: "rect",
  310. textStyle: {
  311. fontSize: 12,
  312. color: '#fff',
  313. padding: [5, 0, 0, 2],
  314. rich: {
  315. a: {
  316. verticalAlign: 'middle',
  317. },
  318. },
  319. },
  320. },
  321. xAxis: {
  322. triggerEvent: true,
  323. data: that.xData,
  324. axisLabel: {
  325. show: true,
  326. fontSize: 12,
  327. color: '#fff',
  328. align: 'center',
  329. verticalAlign: 'top',
  330. },
  331. axisLine: {
  332. show: true,
  333. lineStyle: {
  334. width: 1,
  335. color: 'rgba(239, 247, 253, .7)'
  336. }
  337. },
  338. axisTick: {
  339. show: false,
  340. },
  341. },
  342. yAxis: [
  343. {
  344. name: "单位/k㎡",
  345. nameTextStyle: {
  346. color: "#fff",
  347. fontSize: 12,
  348. padding: [0, 0, 4, 0], //name文字位置 对应 上右下左
  349. },
  350. axisLabel: {
  351. interval: 0,
  352. show: true,
  353. fontSize: 10,
  354. color: '#fff',
  355. },
  356. axisLine: {
  357. show: false,
  358. },
  359. axisTick: {
  360. show: false,
  361. },
  362. splitLine: {
  363. show: true,
  364. lineStyle: {
  365. color: 'rgba(239, 247, 253, .1)'
  366. }
  367. },
  368. },
  369. ],
  370. series: [
  371. {
  372. name: '监测图斑',
  373. type: 'bar',
  374. barWidth: 12,
  375. silent: true,
  376. itemStyle: {
  377. normal: {
  378. color: function (params) {
  379. let colorItem = ['#3b93e3', '#186bb8'];
  380. return new echarts.graphic.LinearGradient(0, 0, 0, 1, //y->y2
  381. [
  382. {
  383. offset: 0,
  384. color: colorItem[0]
  385. },
  386. {
  387. offset: 1,
  388. color: colorItem[1]
  389. }
  390. ],
  391. false
  392. );
  393. }
  394. }
  395. },
  396. data: this.xData1,
  397. },
  398. {
  399. name: '占用耕地',
  400. type: 'bar',
  401. barWidth: 12,
  402. silent: true,
  403. itemStyle: {
  404. normal: {
  405. color: function (params) {
  406. let colorItem = ['#efc943', '#ec9a1b'];
  407. return new echarts.graphic.LinearGradient(0, 0, 0, 1, //y->y2
  408. [
  409. {
  410. offset: 0,
  411. color: colorItem[0]
  412. },
  413. {
  414. offset: 1,
  415. color: colorItem[1]
  416. }
  417. ],
  418. false
  419. );
  420. }
  421. }
  422. },
  423. data: this.xData2,
  424. },
  425. {
  426. name: '占用永久基本农田',
  427. type: 'bar',
  428. barWidth: 12,
  429. silent: true,
  430. itemStyle: {
  431. normal: {
  432. color: function (params) {
  433. let colorItem = ['#4ee1ac', '#12a972'];
  434. return new echarts.graphic.LinearGradient(0, 0, 0, 1, //y->y2
  435. [
  436. {
  437. offset: 0,
  438. color: colorItem[0]
  439. },
  440. {
  441. offset: 1,
  442. color: colorItem[1]
  443. }
  444. ],
  445. false
  446. );
  447. }
  448. }
  449. },
  450. data: this.xData3,
  451. }, {
  452. name: '违法占地',
  453. type: 'bar',
  454. barWidth: 12,
  455. silent: true,
  456. itemStyle: {
  457. normal: {
  458. color: function (params) {
  459. let colorItem = ['rgb(236,128,141)', 'rgb(236,128,141)'];
  460. return new echarts.graphic.LinearGradient(0, 0, 0, 1, //y->y2
  461. [
  462. {
  463. offset: 0,
  464. color: colorItem[0]
  465. },
  466. {
  467. offset: 1,
  468. color: colorItem[1]
  469. }
  470. ],
  471. false
  472. );
  473. }
  474. }
  475. },
  476. data: this.xData4,
  477. }
  478. ],
  479. }
  480. tdsc_my_chart.setOption(option);
  481. },
  482. async init_wpjg_title(params) {
  483. const that = this;
  484. let obj = {
  485. jscType: 'jsc_vpjg_hz',
  486. id: params ? params.id : '4602',
  487. beginTime: params ? params.beginTime : store.state.cockpit_date[0],
  488. endTime: params ? params.endTime : store.state.cockpit_date[1],
  489. };
  490. let data = await QueryOne(obj);
  491. this.title = data.data
  492. },
  493. async init_wpjg_echart_data(params) {
  494. const that = this;
  495. let obj = {
  496. jscType: 'jsc_vpjg_qxxf',
  497. id: params ? params.id : '4602',
  498. beginTime: params ? params.beginTime : store.state.cockpit_date[0],
  499. endTime: params ? params.endTime : store.state.cockpit_date[1],
  500. };
  501. let data = await QueryList(obj);
  502. that.zData = data.data;
  503. data.data.forEach((res) => {
  504. this.xData.push(res.name);
  505. this.xData1.push((res.tb_mj / 1000).toFixed(2));
  506. this.xData2.push((res.zygdmj / 1000).toFixed(2));
  507. this.xData3.push((res.zyjbntmj / 1000).toFixed(2));
  508. this.xData4.push((res.wf_mj / 1000).toFixed(2));
  509. })
  510. this.init_wpjg_echart();
  511. },
  512. setData(datas) {
  513. this.GetQueryListztsh(datas);
  514. this.getQueryListyelx(datas);
  515. },
  516. getQueryListyelx(datas) {
  517. let data = [];
  518. let links = [];
  519. let params = {
  520. ...datas,
  521. jscType: "jsc_wpjc_yelx",
  522. };
  523. QueryList(params).then((res) => {
  524. res.data.forEach((edata) => {
  525. if (edata.qlx_type_name && edata.hlx_type_name) {
  526. links.push({
  527. source: edata.qlx_type_name,
  528. target: edata.hlx_type_name,
  529. value: edata.xzqdm_num,
  530. });
  531. if (data.findIndex((a) => a.name == edata.qlx_type_name) < 0)
  532. data.push({
  533. name: edata.qlx_type_name,
  534. itemStyle: { color: colors[Math.floor(Math.random() * 12)] },
  535. });
  536. if (data.findIndex((a) => a.name == edata.hlx_type_name) < 0)
  537. data.push({
  538. name: edata.hlx_type_name,
  539. itemStyle: { color: colors[Math.floor(Math.random() * 12)] },
  540. });
  541. this.$nextTick(() => {
  542. this.$refs.echartRef.setOptions(data, links);
  543. });
  544. }
  545. });
  546. });
  547. },
  548. GetQueryListztsh(datas) {
  549. let params = {
  550. ...datas,
  551. jscType: "jsc_wpjc_ztsh",
  552. };
  553. QueryList(params).then((res) => {
  554. this.sdata = res.data && res.data.length > 0 ? res.data[0] : {};
  555. });
  556. },
  557. },
  558. computed: {
  559. // 计算属性的 getter
  560. wfl_computed: function () {
  561. // `this` 指向 vm 实例
  562. if (this.title.wfl != 0) {
  563. return this.title.wfl + '%'
  564. } else {
  565. return '暂无'
  566. }
  567. },
  568. wf_mj_computed: function () {
  569. // `this` 指向 vm 实例
  570. if ((this.title.wf_mj / 1000).toFixed(2) > 0) {
  571. return (this.title.wf_mj / 1000).toFixed(2) + 'k㎡'
  572. } else {
  573. return '暂无'
  574. }
  575. }
  576. },
  577. mounted() {
  578. this.$nextTick((res) => {
  579. this.init_wpjg_title();
  580. this.init_wpjg_echart_data();
  581. })
  582. },
  583. };
  584. </script>
  585. <style lang="scss" scoped>
  586. .wpjg {
  587. top: 38rem !important;
  588. .stacontent {
  589. width: 100%;
  590. height: 24px;
  591. margin-top: 0.5rem;
  592. margin-bottom: 1.5rem;
  593. }
  594. .item {
  595. width: 49%;
  596. height: 30%;
  597. display: inline-block;
  598. // border: #00FFFF 1px solid;
  599. }
  600. .cursor {
  601. cursor: pointer;
  602. }
  603. .dlabel {
  604. font-family: HarmonyOS Sans Naskh Arabic UI, HarmonyOS Sans Naskh Arabic UI;
  605. font-weight: 400;
  606. font-size: 14px;
  607. color: #bcd3e5;
  608. line-height: 24px;
  609. text-align: left;
  610. }
  611. .dvalue {
  612. font-family: HarmonyOS Sans SC, HarmonyOS Sans SC;
  613. font-weight: bold;
  614. color: #64daff;
  615. line-height: 16px;
  616. text-align: left;
  617. font-size: 12px;
  618. }
  619. }
  620. #wpjg_echart {
  621. left: -1rem;
  622. top: -0.9rem;
  623. width: 26rem;
  624. height: 12rem;
  625. }
  626. #wpjg_echart_xzqh {
  627. left: 1rem;
  628. width: 26rem;
  629. height: 12rem;
  630. }
  631. </style>