hysy.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407
  1. <template>
  2. <div class="hysy">
  3. <div class="title">
  4. <div class="icon"></div>
  5. <span>重点用地监管</span>
  6. </div>
  7. <div class="hysy_box">
  8. <DialWatch class="hysy_dial_watch" :dial_watch_info="dial_watch_info" ref="hysy_dial_watch" />
  9. <BarGraph3D class="hysy_bar_graph" ref="hysy_bar_graph" />
  10. </div>
  11. </div>
  12. </template>
  13. <script>
  14. //这里可以导入其他文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
  15. import { QueryOne, QueryList } from "../../api/cockpitNew";
  16. import BarGraph3D from './common/BarGraph3D.vue';
  17. import DialWatch from './common/DialWatch.vue';
  18. export default {
  19. components: { BarGraph3D, DialWatch },
  20. data() {
  21. return {
  22. legendData: ['计划收储', '完成收储'],
  23. xdata: ['居民用地', '公共管理用地', '商业商服用地', '工矿用地', '工矿用地仓储用地', "交通运输用地"],
  24. result: [
  25. { name: '计划收储', data: [...new Array(5)].map((item, i) => +(Math.random(0, 10) * 1000).toFixed(0)) },
  26. { name: '完成收储', data: [...new Array(5)].map((item, i) => +(Math.random(0, 0.5) * 1000).toFixed(0)) },
  27. ],
  28. dial_watch_info: {
  29. lt: {
  30. key: '计划出让海域',
  31. value: 0,
  32. unit: "公顷",
  33. }, lb: {
  34. key: "完成出让海域",
  35. value: 0,
  36. unit: "公顷",
  37. }, rt: {
  38. key: "计划出让项目",
  39. value: 0,
  40. unit: "个",
  41. }, rb: {
  42. key: "完成出让项目",
  43. value: 0,
  44. unit: "个",
  45. },
  46. },
  47. };
  48. },
  49. //监听属性 类似于data概念
  50. computed: {},
  51. //监控data中的数据变化
  52. watch: {},
  53. //方法集合
  54. beforeCreate() { }, //生命周期 - 创建之前
  55. created() {
  56. }, //生命周期 - 创建完成(可以访问当前this实例)
  57. beforeMount() { }, //生命周期 - 挂载之前
  58. methods: {
  59. init_hysyEchart() {
  60. var dom = document.getElementById("hysyEchart");
  61. var myChart = window.echarts.init(dom);
  62. var myChart = window.echarts.init(dom);
  63. // Mock数据
  64. const mockData = {
  65. xdata: store.state.cockpit_hysy.echart.xdata,
  66. result: store.state.cockpit_hysy.echart.result
  67. }
  68. const color = [
  69. [{ 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)' }],
  70. [{ 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)' }],
  71. ]
  72. const color2 = ['rgba(34, 129, 209, 0.8)', 'rgba(34, 129, 209, 0.8)',]
  73. // tooltip
  74. const tooltip = {
  75. trigger: "axis",
  76. textStyle: { fontSize: '100%' },
  77. formatter: params => {
  78. let rander = params.map(item => `<div>${item.seriesName}: ${item.value}公顷</div>`).join('')
  79. return rander
  80. }
  81. }
  82. const legend = {
  83. data: ['计划出让', '完成出让'], //图例名称
  84. textStyle: { fontSize: 12, color: '#fff' },
  85. itemWidth: 24,
  86. itemHeight: 15,
  87. itemGap: 15,
  88. top: '-4%',
  89. right: '2%',
  90. selectedMode: false
  91. }
  92. const grid = { top: '20%', left: '12%', right: '2%', bottom: '25%' }
  93. // xAxis
  94. const xAxis = {
  95. axisTick: { show: false },
  96. axisLine: { lineStyle: { color: '#BCD3E5' } },
  97. axisLabel: {
  98. textStyle: { fontSize: 12, color: '#BCD3E5' },
  99. },
  100. axisLabel: {
  101. interval: 0,
  102. formatter: function (value) {
  103. // 当文字长度大于2时,使用slice方法截取字符串并拼接省略号;否则直接返回原文字
  104. if (value.length > 4) {
  105. return `${value.slice(0, 4)}...`;
  106. } else {
  107. return value;
  108. }
  109. },
  110. },
  111. data: mockData.xdata,
  112. }
  113. // yAxis
  114. const yAxis = [
  115. {
  116. min: 0,
  117. name: '公顷',
  118. type: 'value',
  119. axisLine: {
  120. show: false,
  121. lineStyle: {
  122. color: '#BCD3E5'
  123. }
  124. },
  125. splitLine: {
  126. show: true,
  127. lineStyle: {
  128. type: "dashed",
  129. color: "rgba(255,255,255,0.1)"
  130. },
  131. },
  132. axisTick: {
  133. show: false
  134. },
  135. axisLabel: {
  136. show: true,
  137. fontSize: 12,
  138. },
  139. boundaryGap: ['20%', '20%']
  140. },]
  141. // const yAxis = [{
  142. // axisTick: { show: false },
  143. // axisLine: { show: false },
  144. // splitLine: { lineStyle: { color: 'rgba(255,255,255, .05)' } },
  145. // axisLabel: { show: false, textStyle: { fontSize: 14, color: '#fff' } }
  146. // }, {
  147. // show: false,
  148. // splitLine: { show: false },
  149. // axisLine: { show: false },
  150. // axisTick: { show: false },
  151. // }]
  152. // const diamondData = mockData.result.reduce((pre, cur, index) => {
  153. // pre[index] = cur.data.map((el, id) => el + (pre[index - 1] ? pre[index - 1][id] : 0))
  154. // return pre
  155. // }, [])
  156. let series = mockData.result.reduce((p, c, i, array) => {
  157. p.push({
  158. z: i + 1,
  159. stack: '总量',
  160. type: 'bar',
  161. name: c.name,
  162. barGap: 18,
  163. barWidth: 18,
  164. data: c.data,
  165. itemStyle: { color: { type: 'linear', x: 0, x2: 1, y: 0, y2: 0, colorStops: color[i] } },
  166. }, {
  167. z: i + 10,
  168. type: 'pictorialBar',
  169. symbolPosition: 'end',
  170. symbol: 'diamond',
  171. symbolOffset: [0, '-50%'],
  172. symbolSize: [18, 12],
  173. data: mockData.result[i],
  174. itemStyle: { color: color2[i] },
  175. tooltip: { show: false },
  176. })
  177. // 是否最后一个了?
  178. if (p.length === (array.length) * 2) {
  179. p.push({
  180. z: array.length * 2,
  181. type: "pictorialBar",
  182. symbolPosition: "start",
  183. data: mockData.result[0].data,
  184. symbol: "diamond",
  185. symbolOffset: ["0%", "50%"],
  186. symbolSize: [18, 10],
  187. itemStyle: { color: { type: 'linear', x: 0, x2: 1, y: 0, y2: 0, colorStops: color[0] } },
  188. tooltip: { show: false },
  189. })
  190. return p
  191. }
  192. return p
  193. }, [])
  194. const dataZoom = [{
  195. show: false,
  196. type: 'slider',
  197. startValue: 0,
  198. endValue: 7,
  199. moveOnMouseWheel: true,
  200. moveOnMouseMove: true,
  201. zoomOnMouseWheel: false,
  202. }]
  203. let option = {
  204. tooltip, legend, xAxis, yAxis, series, grid, dataZoom, backgroundColor: 'rgba(0, 0, 0, 0)'
  205. }
  206. myChart.setOption(option);
  207. },
  208. async init_info(params) {
  209. const that = this;
  210. let obj = {
  211. jscType: 'jsc_hysyq_ztsh',
  212. beginTime: params ? params.beginTime : store.state.cockpit_date[0],
  213. endTime: params ? params.endTime : store.state.cockpit_date[1],
  214. id: params ? params.id : '4602'
  215. };
  216. let data = await QueryList(obj);
  217. that.dial_watch_info = {
  218. lt: {
  219. key: '计划出让海域',
  220. value: data.data[0].jh_mj,
  221. unit: "公顷",
  222. }, lb: {
  223. key: "完成出让海域",
  224. value: data.data[0].sj_mj,
  225. unit: "公顷",
  226. }, rt: {
  227. key: "计划出让项目",
  228. value: data.data[0].jh_number,
  229. unit: "个",
  230. }, rb: {
  231. key: "完成出让项目",
  232. value: data.data[0].sj_number,
  233. unit: "个",
  234. },
  235. }
  236. let echart_data = 0;
  237. if (data.data[0].sj_mj == 0) {
  238. echart_data = 0
  239. } else if (data.data[0].jh_mj == 0 && data.data[0].sj_mj > 0) {
  240. echart_data = 100
  241. } else {
  242. echart_data = (data.data[0].sj_mj / data.data[0].jh_mj * 100).toFixed(2)
  243. }
  244. that.$refs.hysy_dial_watch.init_dial_watch(echart_data);
  245. // store.state.cockpit_hysy.info = data.data[0]
  246. },
  247. async init_echart_data(params) {
  248. const that = this;
  249. let obj = {
  250. jscType: 'jsc_hysyq_yelx',
  251. beginTime: params ? params.beginTime : store.state.cockpit_date[0],
  252. endTime: params ? params.endTime : store.state.cockpit_date[1],
  253. id: params ? params.id : '4602'
  254. };
  255. let data = await QueryList(obj);
  256. let xdata = [];
  257. let result = [
  258. {
  259. name: "计划出让",
  260. data: []
  261. },
  262. {
  263. name: "完成出让",
  264. data: []
  265. }
  266. ];
  267. data.data.forEach((res) => {
  268. xdata.push(res.yhlx_name);
  269. result[0].data.push(res.jh_mj);
  270. result[1].data.push(res.sj_mj);
  271. })
  272. that.xdata = xdata;
  273. that.result = result;
  274. that.legendData = ['计划出让', '完成出让'];
  275. this.$refs.hysy_bar_graph.setOptions(this.legendData, this.xdata, this.result);
  276. }
  277. },
  278. mounted() {
  279. const that = this;
  280. this.$nextTick((res) => {
  281. this.init_info();
  282. this.init_echart_data();
  283. })
  284. },
  285. beforeUpdate() { }, //生命周期 - 更新之前
  286. updated() { }, //生命周期 - 更新之后
  287. beforeDestroy() { }, //生命周期 - 销毁之前
  288. destroy() { },//生命周期 - 销毁完成
  289. activated() { }, //若组件实例是 <KeepAlive> 缓存树的一部分,当组件被插入到 DOM 中时调用。
  290. deactivated() { } //若组件实例是 <KeepAlive> 缓存树的一部分,当组件从 DOM 中被移除时调用。
  291. };
  292. </script>
  293. <style lang="scss" scoped>
  294. .hysy {
  295. display: none;
  296. position: relative;
  297. top: 18rem;
  298. left: 48rem;
  299. width: 373px;
  300. z-index: 100;
  301. }
  302. .title {
  303. border-width: 0px;
  304. width: 100%;
  305. height: 36px;
  306. background: no-repeat;
  307. background-size: 100% 100%;
  308. background-image: url("/static/images/overview/titlebox.gif");
  309. // background-size: 100% 100%;
  310. display: flex;
  311. justify-content: space-between;
  312. position: relative;
  313. span {
  314. color: #fff;
  315. font-size: 14px;
  316. font-weight: bold;
  317. position: relative;
  318. top: 0.3rem;
  319. left: -18rem;
  320. }
  321. }
  322. .text {
  323. display: inline-block;
  324. width: 100px;
  325. // margin-top: 10px;
  326. margin-left: 15px;
  327. margin-top: 3px;
  328. p {
  329. font-kerning: normal;
  330. font-family: "Arial Negreta", "Arial Normal", "Arial";
  331. font-weight: 500;
  332. font-style: normal;
  333. font-size: 12px;
  334. color: #ffffff;
  335. // margin-bottom: ;
  336. }
  337. span {
  338. font-family: "Arial Negreta", "Arial Normal", "Arial";
  339. font-weight: 700;
  340. font-style: normal;
  341. color: #68f4fb;
  342. }
  343. }
  344. .hysy_bar_graph {
  345. margin-left: 5rem;
  346. left: -5rem !important;
  347. top: -12rem !important;
  348. height: 10rem !important;
  349. }
  350. .hysy_dial_watch {
  351. position: relative;
  352. top: -2.5rem;
  353. }
  354. </style>