hysy.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613
  1. <template>
  2. <div class="hysy">
  3. <div class="title">
  4. <div class="icon"></div>
  5. <span>海域使用权出让</span>
  6. </div>
  7. <div class="content_hysy">
  8. <div class="space">
  9. <div class="lt_box box">
  10. <div class="text">
  11. <p>计划出让海域</p>
  12. <span>{{ store.state.cockpit_hysy.info.jh_mj }}</span>公顷
  13. </div>
  14. </div>
  15. <div class="lb_box box">
  16. <div class="text">
  17. <p>完成出让海域</p>
  18. <span>{{ store.state.cockpit_hysy.info.sj_mj }}</span>公顷
  19. </div>
  20. </div>
  21. <div id="dial_watch_hysy">
  22. </div>
  23. <div class="rt_box box">
  24. <div class="text">
  25. <p>计划出让项目</p>
  26. <span>{{ store.state.cockpit_hysy.info.jh_number }}</span>个
  27. </div>
  28. </div>
  29. <div class="rb_box box">
  30. <div class="text">
  31. <p>完成出让项目</p>
  32. <span>{{ store.state.cockpit_hysy.info.sj_number }}</span>个
  33. </div>
  34. </div>
  35. </div>
  36. <div id="hysyEchart">
  37. </div>
  38. </div>
  39. </div>
  40. </template>
  41. <script>
  42. //这里可以导入其他文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
  43. import { QueryOne, QueryList } from "../../api/cockpitNew";
  44. export default {
  45. components: {},
  46. data() {
  47. return {
  48. };
  49. },
  50. //监听属性 类似于data概念
  51. computed: {},
  52. //监控data中的数据变化
  53. watch: {},
  54. //方法集合
  55. beforeCreate() { }, //生命周期 - 创建之前
  56. created() {
  57. }, //生命周期 - 创建完成(可以访问当前this实例)
  58. beforeMount() { }, //生命周期 - 挂载之前
  59. methods: {
  60. init_hysyEchart() {
  61. var dom = document.getElementById("hysyEchart");
  62. var myChart = window.echarts.init(dom);
  63. var myChart = window.echarts.init(dom);
  64. // Mock数据
  65. const mockData = {
  66. xdata: store.state.cockpit_hysy.echart.xdata,
  67. result: store.state.cockpit_hysy.echart.result
  68. }
  69. const color = [
  70. [{ offset: 0, color: 'rgba(183, 117, 12, 0.8)' }, { offset: 0.5, color: 'rgba(183, 117, 12, 0.8)' }, { offset: 0.5, color: 'rgba(249, 180, 71, 0.8)' }, { offset: 1, color: 'rgba(249, 180, 71, 0.8)' }],
  71. [{ offset: 0, color: 'rgba(34, 129, 209, 0.8)' }, { offset: 0.5, color: 'rgba(34, 129, 209, 0.8)' }, { offset: 0.5, color: 'rgba(97, 173, 237, 0.8)' }, { offset: 1, color: 'rgba(97, 173, 237, 0.8)' }],
  72. ]
  73. const color2 = ['rgba(34, 129, 209, 0.8)', 'rgba(34, 129, 209, 0.8)',]
  74. // tooltip
  75. const tooltip = {
  76. trigger: "axis",
  77. textStyle: { fontSize: '100%' },
  78. formatter: params => {
  79. let rander = params.map(item => `<div>${item.seriesName}: ${item.value}</div>`).join('')
  80. return rander
  81. }
  82. }
  83. const legend = {
  84. data: ['计划出让', '完成出让'], //图例名称
  85. textStyle: { fontSize: 12, color: '#fff' },
  86. itemWidth: 24,
  87. itemHeight: 15,
  88. itemGap: 15,
  89. top: '-4%',
  90. right: '2%',
  91. selectedMode: false
  92. }
  93. const grid = { top: '15%', left: '12%', right: '2%', bottom: '25%' }
  94. // xAxis
  95. const xAxis = {
  96. axisTick: { show: false },
  97. axisLine: { lineStyle: { color: '#BCD3E5' } },
  98. axisLabel: {
  99. textStyle: { fontSize: 12, color: '#BCD3E5' },
  100. },
  101. axisLabel: {
  102. interval: 0,
  103. formatter: function (value) {
  104. // 当文字长度大于2时,使用slice方法截取字符串并拼接省略号;否则直接返回原文字
  105. if (value.length > 4) {
  106. return `${value.slice(0, 4)}...`;
  107. } else {
  108. return value;
  109. }
  110. },
  111. },
  112. data: mockData.xdata,
  113. }
  114. // yAxis
  115. const yAxis = [{
  116. axisTick: { show: false },
  117. axisLine: { show: false },
  118. splitLine: { lineStyle: { color: 'rgba(255,255,255, .05)' } },
  119. axisLabel: { show: false, textStyle: { fontSize: 14, color: '#fff' } }
  120. }, {
  121. show: false,
  122. splitLine: { show: false },
  123. axisLine: { show: false },
  124. axisTick: { show: false },
  125. }]
  126. // const diamondData = mockData.result.reduce((pre, cur, index) => {
  127. // pre[index] = cur.data.map((el, id) => el + (pre[index - 1] ? pre[index - 1][id] : 0))
  128. // return pre
  129. // }, [])
  130. let series = mockData.result.reduce((p, c, i, array) => {
  131. p.push({
  132. z: i + 1,
  133. stack: '总量',
  134. type: 'bar',
  135. name: c.name,
  136. barGap: 18,
  137. barWidth: 18,
  138. data: c.data,
  139. itemStyle: { color: { type: 'linear', x: 0, x2: 1, y: 0, y2: 0, colorStops: color[i] } },
  140. }, {
  141. z: i + 10,
  142. type: 'pictorialBar',
  143. symbolPosition: 'end',
  144. symbol: 'diamond',
  145. symbolOffset: [0, '-50%'],
  146. symbolSize: [18, 12],
  147. data: mockData.result[i],
  148. itemStyle: { color: color2[i] },
  149. tooltip: { show: false },
  150. })
  151. // 是否最后一个了?
  152. if (p.length === (array.length) * 2) {
  153. p.push({
  154. z: array.length * 2,
  155. type: "pictorialBar",
  156. symbolPosition: "start",
  157. data: mockData.result[0].data,
  158. symbol: "diamond",
  159. symbolOffset: ["0%", "50%"],
  160. symbolSize: [18, 10],
  161. itemStyle: { color: { type: 'linear', x: 0, x2: 1, y: 0, y2: 0, colorStops: color[0] } },
  162. tooltip: { show: false },
  163. })
  164. return p
  165. }
  166. return p
  167. }, [])
  168. const dataZoom = [{
  169. show: false,
  170. type: 'slider',
  171. startValue: 0,
  172. endValue: 7,
  173. moveOnMouseWheel: true,
  174. moveOnMouseMove: true,
  175. zoomOnMouseWheel: false,
  176. }]
  177. let option = {
  178. tooltip, legend, xAxis, yAxis, series, grid, dataZoom, backgroundColor: 'rgba(0, 0, 0, 0)'
  179. }
  180. myChart.setOption(option);
  181. },
  182. init_dial_watch_hysy() {
  183. var dom = document.getElementById("dial_watch_hysy");
  184. var myChart = window.echarts.init(dom);
  185. var demoData = {
  186. name: '城镇化率',
  187. value: 60,
  188. };
  189. let option = {
  190. backgroundColor: 'rgba(0,0,0,0)',
  191. title: {
  192. text: `{num|${demoData.value}%} ` + '\n' + `{label|完成率}`,
  193. x: '49%',
  194. y: '70%',
  195. textAlign: 'center',
  196. textStyle: {
  197. rich: {
  198. num: {
  199. fontWeight: '600',
  200. color: 'rgba(249, 180, 71, 1)',
  201. fontFamily: '微软雅黑',
  202. fontSize: 14,
  203. }, label: {
  204. color: "#fff",
  205. fontSize: 12,
  206. },
  207. },
  208. },
  209. },
  210. grid: { top: '0%', left: '0%' },
  211. series: [
  212. {
  213. type: 'gauge',
  214. radius: '90%', // 1行3个
  215. center: ['50%', '70%'],
  216. splitNumber: 10,
  217. // min: 0,
  218. max: 100,
  219. startAngle: 220,
  220. endAngle: -44,
  221. z: 99,
  222. // 线
  223. axisLine: {
  224. lineStyle: {
  225. width: 1,
  226. color: [[1, 'rgba(255,255,255,0)']],
  227. },
  228. detail: {
  229. formatter: '{value}',
  230. },
  231. data: [
  232. {
  233. value: 50,
  234. name: 'SCORE',
  235. },
  236. ],
  237. },
  238. //刻度标签。
  239. axisTick: {
  240. show: true,
  241. splitNumber: 6, //刻度的段落数
  242. lineStyle: {
  243. color: '#ccc',
  244. width: 1, //刻度的宽度
  245. shadowColor: 'RGBA(60, 139, 232, 0)',
  246. shadowBlur: 2,
  247. },
  248. length: 3, //刻度的长度
  249. },
  250. splitLine: {
  251. //文字和刻度的偏移量
  252. show: true,
  253. length: 1, //长度
  254. lineStyle: {
  255. color: '#ccc',
  256. width: 1,
  257. },
  258. },
  259. // //刻度线文字
  260. axisLabel: {
  261. show: false,
  262. color: '#ccc',
  263. fontSize: 1,
  264. distance: -30,
  265. },
  266. data: [
  267. {
  268. value: demoData.value,
  269. name: 'SCORE',
  270. itemStyle: {
  271. color: 'rgba(73, 148, 236, 1)',
  272. },
  273. },
  274. ],
  275. pointer: {
  276. show: true,
  277. length: '40%',
  278. radius: '50%',
  279. width: 5, //指针粗细
  280. offsetCenter: [0, -10]
  281. },
  282. detail: {
  283. show: false
  284. },
  285. title: {
  286. // 仪表盘标题。
  287. show: false,
  288. },
  289. },
  290. {
  291. name: demoData.name,
  292. type: 'pie',
  293. radius: ['65%', '50%'],
  294. center: ['50%', '70%'],
  295. startAngle: 220,
  296. endAngle: -10,
  297. color: [
  298. {
  299. type: 'linear',
  300. x: 1,
  301. y: 0,
  302. x2: 0,
  303. y2: 0,
  304. colorStops: [
  305. {
  306. offset: 0,
  307. color: 'rgba(62, 147, 244, 0.3)', // 0% 处的颜色
  308. },
  309. {
  310. offset: 1,
  311. color: 'rgba(62, 147, 244, 1)', // 100% 处的颜色
  312. },
  313. ],
  314. },
  315. 'transparent',
  316. ],
  317. hoverAnimation: true,
  318. legendHoverLink: false,
  319. z: 10,
  320. labelLine: {
  321. normal: {
  322. show: false,
  323. },
  324. },
  325. data: [
  326. {
  327. value: 60,
  328. },
  329. {
  330. value: 20,
  331. },
  332. ],
  333. },
  334. {
  335. type: 'pie',
  336. hoverAnimation: false,
  337. label: {
  338. show: false,
  339. },
  340. center: ['50%', '70%'],
  341. radius: ['0%', '60%'],
  342. startAngle: 230,
  343. data: [
  344. {
  345. value: 100,
  346. itemStyle: {
  347. normal: {
  348. color: {
  349. type: 'radial',
  350. x: 0.5,
  351. y: 0.5,
  352. r: 0.5,
  353. colorStops: [
  354. { offset: 0, color: 'rgba(0,0,0,0)' },
  355. { offset: 1, color: 'rgba(0,0,0,0)' },
  356. ],
  357. },
  358. opacity: 0.2,
  359. },
  360. },
  361. },
  362. {
  363. value: 100,
  364. color: 'transparent',
  365. },
  366. ],
  367. },
  368. ],
  369. };
  370. myChart.setOption(option);
  371. },
  372. async init_info(params) {
  373. const that = this;
  374. let obj = {
  375. jscType: 'jsc_hysyq_ztsh',
  376. beginTime: params ? params.beginTime : store.state.cockpit_date[0],
  377. endTime: params ? params.endTime : store.state.cockpit_date[1],
  378. id: params ? params.id : '4602'
  379. };
  380. let data = await QueryList(obj);
  381. store.state.cockpit_hysy.info = data.data[0]
  382. },
  383. async init_echart_data(params) {
  384. const that = this;
  385. let obj = {
  386. jscType: 'jsc_hysyq_yelx',
  387. beginTime: params ? params.beginTime : store.state.cockpit_date[0],
  388. endTime: params ? params.endTime : store.state.cockpit_date[1],
  389. id: params ? params.id : '4602'
  390. };
  391. let data = await QueryList(obj);
  392. console.log('data: ', data);
  393. let xdata = [];
  394. let result = [
  395. {
  396. name: "计划出让",
  397. data: []
  398. },
  399. {
  400. name: "完成出让",
  401. data: []
  402. }
  403. ];
  404. data.data.forEach((res) => {
  405. xdata.push(res.yhlx_name);
  406. result[0].data.push(res.jh_mj);
  407. result[1].data.push(res.sj_mj);
  408. })
  409. store.state.cockpit_hysy.echart.xdata = xdata
  410. store.state.cockpit_hysy.echart.result = result
  411. that.init_hysyEchart();
  412. }
  413. },
  414. mounted() {
  415. const that = this;
  416. this.$nextTick((res) => {
  417. that.init_dial_watch_hysy();
  418. this.init_info();
  419. this.init_echart_data();
  420. })
  421. },
  422. beforeUpdate() { }, //生命周期 - 更新之前
  423. updated() { }, //生命周期 - 更新之后
  424. beforeDestroy() { }, //生命周期 - 销毁之前
  425. destroy() { },//生命周期 - 销毁完成
  426. activated() { }, //若组件实例是 <KeepAlive> 缓存树的一部分,当组件被插入到 DOM 中时调用。
  427. deactivated() { } //若组件实例是 <KeepAlive> 缓存树的一部分,当组件从 DOM 中被移除时调用。
  428. };
  429. </script>
  430. <style lang="scss" scoped>
  431. .hysy {
  432. border-width: 0px;
  433. position: absolute;
  434. left: 55rem;
  435. top: 35.3rem;
  436. width: 559px;
  437. height: 270px;
  438. display: -webkit-box;
  439. display: -ms-flexbox;
  440. display: flex;
  441. z-index: 100;
  442. }
  443. .title {
  444. width: 1071rem;
  445. height: 40px;
  446. background: no-repeat;
  447. background-size: 116% 100%;
  448. background-image: url("/static/images/overview/标题框.png");
  449. .icon {
  450. background: no-repeat;
  451. background-image: url("/static/images/overview/icon_标题框装饰.png");
  452. display: inline-block;
  453. width: 30px;
  454. height: 30px;
  455. background-position: 14px 7px;
  456. }
  457. span {
  458. color: #fff;
  459. font-size: 14px;
  460. font-weight: bold;
  461. position: relative;
  462. bottom: 0.5rem;
  463. }
  464. }
  465. .content_hysy {
  466. position: fixed;
  467. top: 40rem;
  468. #dial_watch_hysy {
  469. // border: 1px red solid;
  470. width: 26rem;
  471. height: 8.5rem;
  472. position: relative;
  473. left: 3rem;
  474. bottom: 1rem;
  475. }
  476. #hysyEchart {
  477. // border: 1px red solid;
  478. width: 34rem;
  479. height: 9rem;
  480. }
  481. .box {
  482. width: 10rem;
  483. height: 5rem;
  484. position: absolute;
  485. }
  486. .lt_box {
  487. position: fixed;
  488. background: no-repeat;
  489. background-size: 101% 50%;
  490. background-image: url("/static/images/overview/ltback.png");
  491. left: 57rem;
  492. top: 41.5rem;
  493. }
  494. .lb_box {
  495. position: fixed;
  496. background: no-repeat;
  497. background-size: 101% 50%;
  498. background-image: url("/static/images/overview/lbback.png");
  499. left: 57rem;
  500. top: 44.5rem;
  501. }
  502. .rt_box {
  503. position: fixed;
  504. background: no-repeat;
  505. background-size: 101% 50%;
  506. background-image: url("/static/images/overview/rtback.png");
  507. left: 76rem;
  508. top: 41.5rem;
  509. .text {
  510. margin-left: 4rem;
  511. }
  512. }
  513. .rb_box {
  514. position: fixed;
  515. background: no-repeat;
  516. background-size: 101% 50%;
  517. background-image: url("/static/images/overview/rbback.png");
  518. left: 76rem;
  519. top: 44.5rem;
  520. z-index: 100;
  521. .text {
  522. margin-left: 4rem;
  523. }
  524. }
  525. }
  526. .text {
  527. display: inline-block;
  528. width: 100px;
  529. // margin-top: 10px;
  530. margin-left: 15px;
  531. margin-top: 3px;
  532. p {
  533. font-kerning: normal;
  534. font-family: "Arial Negreta", "Arial Normal", "Arial";
  535. font-weight: 500;
  536. font-style: normal;
  537. font-size: 12px;
  538. color: #ffffff;
  539. // margin-bottom: ;
  540. }
  541. span {
  542. font-family: "Arial Negreta", "Arial Normal", "Arial";
  543. font-weight: 700;
  544. font-style: normal;
  545. color: #68f4fb;
  546. }
  547. }
  548. </style>