bjxm.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550
  1. <template>
  2. <div class="bjxm">
  3. <div class="title">
  4. <Title :title="'报健项目'"></Title>
  5. <div class="selectTab">
  6. <el-select v-model="left_value" placeholder="请选择" :popper-append-to-body="false" @change="changeChartsLeft">
  7. <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value">
  8. </el-option>
  9. </el-select>
  10. </div>
  11. </div>
  12. <div class="content">
  13. <div class="item">
  14. <div class="icon">
  15. <div class="icon_zxkg"></div>
  16. </div>
  17. <div class="text">
  18. <p>报建数量</p>
  19. <span>{{ left_value == 'csbj' ? sdata.sj_number : 0 }}</span>个
  20. </div>
  21. </div>
  22. <div class="item">
  23. <div class="icon">
  24. <div class="icon_zxkg"></div>
  25. </div>
  26. <div class="text">
  27. <p>用地面积</p>
  28. <span>0</span>平方千米
  29. </div>
  30. </div>
  31. <div id="bjxm_echart"></div>
  32. </div>
  33. </div>
  34. </template>
  35. <script>
  36. //这里可以导入其他文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
  37. import { QueryOne, QueryList } from "../../api/cockpitNew";
  38. import Title from './common/Title.vue';
  39. export default {
  40. components: { Title },
  41. data() {
  42. return {
  43. sdata: {},
  44. left_value: 'csbj',
  45. options: [
  46. { value: "csbj", label: "城市报建" },
  47. { value: "szbj", label: "私宅报建" },
  48. ],
  49. };
  50. },
  51. //监听属性 类似于data概念
  52. computed: {},
  53. //监控data中的数据变化
  54. watch: {},
  55. //方法集合
  56. methods: {
  57. changeChartsLeft() {
  58. this.init_bjxm_echart_info();
  59. },
  60. async init_info(params) {
  61. const that = this;
  62. let obj = {
  63. jscType: 'jsc_bjxm_csbj_hz',
  64. beginTime: params ? params.beginTime : store.state.cockpit_date[0],
  65. endTime: params ? params.endTime : store.state.cockpit_date[1],
  66. id: params ? params.id : '4602'
  67. };
  68. let res = await QueryOne(obj);
  69. this.sdata = res.data;
  70. },
  71. async init_bjxm_echart_info(params) {
  72. const that = this;
  73. let obj = {
  74. jscType: 'jsc_bjxm_csbj_yffl',
  75. beginTime: params ? params.beginTime : store.state.cockpit_date[0],
  76. endTime: params ? params.endTime : store.state.cockpit_date[1],
  77. id: params ? params.id : '4602'
  78. };
  79. let data = await QueryList(obj);
  80. let xAxis = [];
  81. let bat_data = [];
  82. let line_data = [];
  83. data.data.forEach(element => {
  84. xAxis.push(element.yf);
  85. bat_data.push(element.sj_mj);
  86. line_data.push(element.sj_number);
  87. });
  88. store.state.cockpit_bjxm.csbj.csbj_echart = {
  89. xAxis: xAxis,
  90. bat_data: bat_data,
  91. line_data: line_data,
  92. }
  93. this.init_bjxm_echart();
  94. },
  95. init_bjxm_echart() {
  96. var myChart = echarts.init(document.getElementById("bjxm_echart"));
  97. // 柱状图的宽度,y是x的一半
  98. const offsetX = 10
  99. const offsetY = 5
  100. // 绘制左侧面
  101. const CubeLeft = echarts.graphic.extendShape({
  102. shape: {
  103. x: 0,
  104. y: 0
  105. },
  106. buildPath: function (ctx, shape) {
  107. const xAxisPoint = shape.xAxisPoint
  108. const c0 = [shape.x, shape.y]
  109. const c1 = [shape.x - offsetX, shape.y - offsetY]
  110. const c2 = [xAxisPoint[0] - offsetX, xAxisPoint[1] - offsetY]
  111. const c3 = [xAxisPoint[0], xAxisPoint[1]]
  112. ctx.moveTo(c0[0], c0[1]).lineTo(c1[0], c1[1]).lineTo(c2[0], c2[1]).lineTo(c3[0], c3[1]).closePath()
  113. }
  114. })
  115. // 绘制右侧面
  116. const CubeRight = echarts.graphic.extendShape({
  117. shape: {
  118. x: 0,
  119. y: 0
  120. },
  121. buildPath: function (ctx, shape) {
  122. const xAxisPoint = shape.xAxisPoint
  123. const c1 = [shape.x, shape.y]
  124. const c2 = [xAxisPoint[0], xAxisPoint[1]]
  125. const c3 = [xAxisPoint[0] + offsetX, xAxisPoint[1] - offsetY]
  126. const c4 = [shape.x + offsetX, shape.y - offsetY]
  127. ctx.moveTo(c1[0], c1[1]).lineTo(c2[0], c2[1]).lineTo(c3[0], c3[1]).lineTo(c4[0], c4[1]).closePath()
  128. }
  129. })
  130. // 绘制顶面
  131. const CubeTop = echarts.graphic.extendShape({
  132. shape: {
  133. x: 0,
  134. y: 0,
  135. },
  136. buildPath: function (ctx, shape) {
  137. const c1 = [shape.x, shape.y]
  138. const c2 = [shape.x + offsetX, shape.y - offsetY]
  139. const c3 = [shape.x, shape.y - offsetX]
  140. const c4 = [shape.x - offsetX, shape.y - offsetY]
  141. ctx.moveTo(c1[0], c1[1]).lineTo(c2[0], c2[1]).lineTo(c3[0], c3[1]).lineTo(c4[0], c4[1]).closePath()
  142. }
  143. })
  144. // 注册三个面图形
  145. echarts.graphic.registerShape('CubeLeft', CubeLeft)
  146. echarts.graphic.registerShape('CubeRight', CubeRight)
  147. echarts.graphic.registerShape('CubeTop', CubeTop)
  148. // 数据
  149. const xAxis = store.state.cockpit_bjxm.csbj.csbj_echart.xAxis
  150. const bat_data = store.state.cockpit_bjxm.csbj.csbj_echart.bat_data
  151. const line_data = this.left_value == 'csbj' ? store.state.cockpit_bjxm.csbj.csbj_echart.line_data : [0, 0, 0, 0, 0, 0]
  152. let option = {
  153. //你的代码
  154. backgroundColor: 'rgba(17, 42, 62, 0)',//"#012366",
  155. tooltip: {
  156. show:false,
  157. trigger: 'axis',
  158. axisPointer: {
  159. type: 'shadow'
  160. },
  161. // formatter: function (params) {
  162. // const item = params[1]
  163. // return item.name + "\n" + item.value;
  164. // }
  165. },
  166. grid: {
  167. left: '1%',
  168. right: '10%',
  169. bottom: 10,
  170. top: 10,
  171. containLabel: true
  172. },
  173. xAxis: {
  174. name: '月',
  175. nameGap: 2,
  176. type: 'category',
  177. data: xAxis,
  178. axisLine: {
  179. lineStyle: {
  180. color: '#BCD3E5'
  181. }
  182. },
  183. // offset: 25,
  184. axisTick: {
  185. show: false,
  186. length: 9,
  187. alignWithLabel: true,
  188. lineStyle: {
  189. color: '#BCD3E5'
  190. }
  191. },
  192. axisLabel: {
  193. show: true,
  194. fontSize: 12,
  195. },
  196. },
  197. yAxis: [
  198. // {
  199. // min: 0,
  200. // max: 20,
  201. // interval: 5,
  202. // type: 'value',
  203. // name: '用地面积(km2)',
  204. // axisLine: {
  205. // show: false,
  206. // lineStyle: {
  207. // color: '#BCD3E5'
  208. // }
  209. // },
  210. // splitLine: {
  211. // show: false,
  212. // lineStyle: {
  213. // type: "dashed",
  214. // color: "rgba(255,255,255,0.1)"
  215. // },
  216. // },
  217. // axisTick: {
  218. // show: false
  219. // },
  220. // axisLabel: {
  221. // show: true,
  222. // fontSize: 12,
  223. // },
  224. // boundaryGap: ['20%', '20%']
  225. // },
  226. {
  227. min: 0,
  228. max: 20,
  229. interval: 5,
  230. name: '项目数(个)',
  231. type: 'value',
  232. axisLine: {
  233. show: false,
  234. lineStyle: {
  235. color: '#BCD3E5'
  236. }
  237. },
  238. splitLine: {
  239. show: true,
  240. lineStyle: {
  241. type: "dashed",
  242. color: "rgba(255,255,255,0.1)"
  243. },
  244. },
  245. axisTick: {
  246. show: false
  247. },
  248. axisLabel: {
  249. show: true,
  250. fontSize: 12,
  251. },
  252. boundaryGap: ['20%', '20%']
  253. },],
  254. series: [
  255. // {
  256. // type: 'custom',
  257. // renderItem: (params, api) => {
  258. // const location = api.coord([api.value(0), api.value(1)])
  259. // var color = api.value(1) > 10000 ? 'red' : new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
  260. // offset: 0,
  261. // color: 'rgba(33,101,140,0.5)'
  262. // },
  263. // {
  264. // offset: 0.8,
  265. // color: 'rgba(33,101,140,0.5)'
  266. // }
  267. // ])
  268. // return {
  269. // type: 'group',
  270. // children: [
  271. // {
  272. // type: 'CubeLeft',
  273. // shape: {
  274. // api,
  275. // xValue: api.value(0),
  276. // yValue: api.value(1),
  277. // x: location[0],
  278. // y: location[1],
  279. // xAxisPoint: api.coord([api.value(0), 0])
  280. // },
  281. // style: {
  282. // fill: color = api.value(1) > 10000 ? 'red' : new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
  283. // offset: 0,
  284. // color: 'rgba(34, 129, 209, 0.8)'
  285. // },
  286. // {
  287. // offset: 0.8,
  288. // color: 'rgba(34, 129, 209, 0.8)'
  289. // }
  290. // ])
  291. // }
  292. // },
  293. // {
  294. // type: 'CubeRight',
  295. // shape: {
  296. // api,
  297. // xValue: api.value(0),
  298. // yValue: api.value(1),
  299. // x: location[0],
  300. // y: location[1],
  301. // xAxisPoint: api.coord([api.value(0), 0])
  302. // },
  303. // style: {
  304. // fill: color = api.value(1) > 10000 ? 'red' : new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
  305. // offset: 0,
  306. // color: 'rgba(97, 173, 237, 0.8)'
  307. // },
  308. // {
  309. // offset: 0.8,
  310. // color: 'rgba(97, 173, 237, 0.8)'
  311. // }
  312. // ])
  313. // }
  314. // }, {
  315. // type: 'CubeTop',
  316. // shape: {
  317. // api,
  318. // xValue: api.value(0),
  319. // yValue: api.value(1),
  320. // x: location[0],
  321. // y: location[1],
  322. // xAxisPoint: api.coord([api.value(0), 0])
  323. // },
  324. // style: {
  325. // fill: color = api.value(1) > 10000 ? 'red' : new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
  326. // offset: 0,
  327. // color: 'rgba(60, 167, 255, 1)'
  328. // },
  329. // {
  330. // offset: 1,
  331. // color: 'rgba(135, 200, 255, 1)'
  332. // }
  333. // ])
  334. // }
  335. // }]
  336. // }
  337. // },
  338. // data: bat_data
  339. // },
  340. {
  341. type: 'line',
  342. smooth: true,
  343. itemStyle: {
  344. normal: {
  345. color: '#FFCC64' // 折线的颜色
  346. }
  347. },
  348. data: line_data,
  349. },
  350. ]
  351. };
  352. myChart.setOption(option);
  353. },
  354. },
  355. beforeCreate() { }, //生命周期 - 创建之前
  356. created() { }, //生命周期 - 创建完成(可以访问当前this实例)
  357. beforeMount() { }, //生命周期 - 挂载之前
  358. mounted() {
  359. this.$nextTick((res) => {
  360. this.init_info()
  361. this.init_bjxm_echart_info();
  362. })
  363. }, //生命周期 - 挂在完成
  364. beforeUpdate() { }, //生命周期 - 更新之前
  365. updated() { }, //生命周期 - 更新之后
  366. beforeDestroy() { }, //生命周期 - 销毁之前
  367. destroy() { }, //生命周期 - 销毁完成
  368. activated() { }, //若组件实例是 <KeepAlive> 缓存树的一部分,当组件被插入到 DOM 中时调用。
  369. deactivated() { }, //若组件实例是 <KeepAlive> 缓存树的一部分,当组件从 DOM 中被移除时调用。
  370. };
  371. </script>
  372. <style lang="scss" scoped>
  373. .bjxm {
  374. position: absolute;
  375. width: 22vw;
  376. border: 1px solid red;
  377. height: 17rem;
  378. top: 38.5rem;
  379. left: 27.5vw;
  380. border-radius: 0px;
  381. -webkit-box-shadow: none;
  382. box-shadow: none;
  383. z-index: 100;
  384. }
  385. .selectTab {
  386. position: absolute;
  387. top: 3px;
  388. right: 22px;
  389. z-index: 100;
  390. /deep/ .el-input__inner {
  391. // padding-right: 30px;
  392. width: 128px !important;
  393. height: 24px !important;
  394. line-height: 24px;
  395. padding-left: 22px;
  396. padding-right: 0px;
  397. font-size: 12px;
  398. color: #bcd3e5;
  399. border: none;
  400. // background: url("/static/images/overview/selectBg.png") no-repeat !important;
  401. background-color: rgba(0, 0, 0, 0) !important;
  402. background-size: 100% 100%;
  403. }
  404. /deep/ .el-input__icon {
  405. line-height: 1;
  406. }
  407. /deep/ .el-input__suffix {
  408. right: -2px;
  409. }
  410. /deep/ .el-select-dropdown__list {
  411. color: #bcd3e5 !important;
  412. background: linear-gradient(180deg,
  413. rgba(3, 115, 177, 0) 11%,
  414. rgba(3, 115, 177, 0.48) 100%);
  415. border-image: linear-gradient(360deg,
  416. rgba(75, 185, 250, 0.2),
  417. rgba(75, 185, 250, 0.05)) 1 1 !important;
  418. border: none;
  419. }
  420. /deep/ .el-select-dropdown__item.hover,
  421. .el-select-dropdown__item:hover {
  422. background-color: rgba(87, 163, 226, 0.5);
  423. }
  424. /deep/ .el-select-dropdown__item {
  425. color: #ecf6ff;
  426. }
  427. }
  428. /deep/ {
  429. .el-select-dropdown__item.selected {
  430. color: #409eff;
  431. }
  432. }
  433. /deep/ .el-popper[x-placement^="bottom"] {
  434. margin-top: 12px;
  435. background: #163253;
  436. }
  437. /deep/ .el-select-dropdown {
  438. border: none;
  439. }
  440. /deep/ .el-popper[x-placement^="bottom"] .popper__arrow::after {
  441. border-bottom-color: #163253;
  442. top: 0;
  443. }
  444. .content {
  445. position: absolute;
  446. left: 5%;
  447. width: 400px;
  448. height: 220px;
  449. top: 13%;
  450. }
  451. .item {
  452. width: 45%;
  453. height: 30%;
  454. display: inline-block;
  455. }
  456. .icon {
  457. width: 50px;
  458. padding: 1.5%;
  459. border-radius: 8px;
  460. display: inline-block;
  461. height: 50px;
  462. }
  463. .icon_zxkg {
  464. background: no-repeat 50%;
  465. background-image: url("/static/images/overview/icongdbh0.png");
  466. /* border: #00FFFF 1px solid; */
  467. width: 45px;
  468. height: 45px;
  469. display: inline-block;
  470. }
  471. .text {
  472. display: inline-block;
  473. // border: #00FFFF 1px solid;
  474. width: 100px;
  475. p {
  476. font-kerning: normal;
  477. font-family: "Arial Negreta", "Arial Normal", "Arial";
  478. font-weight: 700;
  479. font-style: normal;
  480. font-size: 14px;
  481. color: #ffffff;
  482. }
  483. span {
  484. font-family: "Arial Negreta", "Arial Normal", "Arial";
  485. font-weight: 700;
  486. font-style: normal;
  487. color: #68f4fb;
  488. }
  489. }
  490. .value {
  491. display: inline-block;
  492. // border: #00FFFF 1px solid;
  493. width: 50px;
  494. }
  495. #bjxm_echart {
  496. position: relative;
  497. top: 0;
  498. width: 20.5rem;
  499. height: 10rem;
  500. }
  501. .title {
  502. width: 22vw;
  503. background-size: 100% 89%;
  504. }
  505. </style>