index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524
  1. <template>
  2. <div>
  3. <el-container>
  4. <el-main>
  5. <el-row>
  6. <el-col span="12" offset="6" style="border: #b11116 solid 1px;padding: 15px">
  7. <el-row>
  8. <el-col span="24" style="text-align: center">
  9. <h3>中国招投标公共服务平台爬虫</h3>
  10. <h5>https://ctbpsp.com/</h5>
  11. </el-col>
  12. <el-col span="8" style="text-align: center">
  13. 爬取总数: <span v-html="allCount"></span>
  14. <div id="allCount"></div>
  15. </el-col>
  16. <el-col span="8" style="text-align: center">
  17. 招标公告:<span v-html="zbCount"></span>
  18. <div id="ZBCount"></div>
  19. </el-col>
  20. <el-col span="8" style="text-align: center">
  21. 招标公告:<span v-html="jgCount"></span>
  22. <div id="JGCount"></div>
  23. </el-col>
  24. <el-col span="24">
  25. <h6>每月份招标公告和中标结果公示分析</h6>
  26. <div id="ZBandJGByMon"></div>
  27. </el-col>
  28. <el-col span="24">
  29. <h6>招标公告中招标人分析</h6>
  30. <div id="depByMon"></div>
  31. </el-col>
  32. <el-col span="24">
  33. <h6>中标结果公示每月金额分析</h6>
  34. <div id="priceByMon"></div>
  35. </el-col>
  36. <el-col span="24">
  37. <div id="echarts">
  38. <div id="myChart"></div>
  39. <div id="myChart2"></div>
  40. </div>
  41. </el-col>
  42. </el-row>
  43. </el-col>
  44. </el-row>
  45. </el-main>
  46. </el-container>
  47. </div>
  48. </template>
  49. <script type="text/javascript">
  50. import {getAllCount,selectAllSumPriceByMon,getCleanCake,getTypeByMon,getCountByDepType} from "../../static/js/api/echarts"
  51. export default {
  52. name: 'Echarts',
  53. data () {
  54. return {
  55. allCount:0,
  56. zbCount:0,
  57. jgCount:0
  58. }
  59. },
  60. methods: {
  61. echartsInit () {
  62. // 找到容器
  63. let myChart = this.$echarts.init(document.getElementById('myChart'))
  64. // 开始渲染
  65. myChart.setOption({
  66. title: {text: '在Vue中使用echarts'},
  67. tooltip: {},
  68. xAxis: {
  69. data: ['衬衫', '羊毛衫', '雪纺衫', '裤子', '高跟鞋', '袜子']
  70. },
  71. yAxis: {},
  72. series: [{
  73. name: '销量',
  74. type: 'bar',
  75. data: [5, 20, 36, 10, 10, 20]
  76. }]
  77. })
  78. },
  79. echartsInit1 () {
  80. let that=this
  81. getAllCount().then(res=>{
  82. that.allCount=res.data.clean;
  83. let myChart = this.$echarts.init(document.getElementById('allCount'))
  84. myChart.setOption({
  85. // title: {text: 'echarts 饼图'},
  86. tooltip: {
  87. trigger: 'item'
  88. },
  89. legend: {
  90. orient: 'vertical',
  91. left: 'left'
  92. },
  93. series: [
  94. {
  95. name: '访问来源',
  96. type: 'pie',
  97. radius: '55%',
  98. data: [
  99. {value: (res.data.clean-res.data.noClean), name: '已清洗'},
  100. {value: res.data.noClean, name: '未清洗'},
  101. ]
  102. }
  103. ]
  104. })
  105. })
  106. },
  107. echartsInit2 () {
  108. let that=this
  109. getCleanCake().then(res=>{
  110. that.zbCount=res.data[0].count;
  111. that.jgCount=res.data[1].count;
  112. let myChart1 = this.$echarts.init(document.getElementById('ZBCount'))
  113. myChart1.setOption({
  114. // title: {text: 'echarts 饼图'},
  115. tooltip: {
  116. trigger: 'item'
  117. },
  118. legend: {
  119. orient: 'vertical',
  120. left: 'left'
  121. },
  122. series: [
  123. {
  124. name: '访问来源',
  125. type: 'pie',
  126. radius: '55%',
  127. data: [
  128. {value: (res.data[0].count-res.data[2].count), name: '已清洗'},
  129. {value: res.data[2].count, name: '未清洗'},
  130. ]
  131. }
  132. ]
  133. })
  134. let myChart2 = this.$echarts.init(document.getElementById('JGCount'))
  135. myChart2.setOption({
  136. // title: {text: 'echarts 饼图'},
  137. tooltip: {
  138. trigger: 'item'
  139. },
  140. legend: {
  141. orient: 'vertical',
  142. left: 'left'
  143. },
  144. series: [
  145. {
  146. name: '访问来源',
  147. type: 'pie',
  148. radius: '55%',
  149. data: [
  150. {value: (res.data[1].count-res.data[3].count), name: '已清洗'},
  151. {value: res.data[3].count, name: '未清洗'},
  152. ]
  153. }
  154. ]
  155. })
  156. })
  157. },
  158. echartsInit3 () {
  159. },
  160. echartsInit4 () {
  161. getTypeByMon().then(res=>{
  162. var data1=['招标公告'];
  163. var data2=['中标结果公示'];
  164. var data3=['日期'];
  165. for(let i=0;i<res.data.gg.length;i++){
  166. data3.push(res.data.gg[i].mon)
  167. }
  168. for(let i=0;i<res.data.gg.length;i++){
  169. data1.push(res.data.gg[i].count)
  170. }
  171. for(let i=0;i<res.data.jg.length;i++){
  172. data2.push(res.data.jg[i].count)
  173. }
  174. var chartDom = document.getElementById('ZBandJGByMon');
  175. var myChart = this.$echarts.init(chartDom);
  176. var option;
  177. setTimeout(function () {
  178. option = {
  179. legend: {},
  180. tooltip: {
  181. trigger: 'axis',
  182. showContent: false
  183. },
  184. dataset: {
  185. source: [
  186. data3,data1,data2,
  187. ]
  188. },
  189. xAxis: { type: 'category' },
  190. yAxis: { gridIndex: 0 },
  191. grid: { top: '55%' },
  192. series: [
  193. {
  194. type: 'line',
  195. smooth: true,
  196. seriesLayoutBy: 'row',
  197. emphasis: { focus: 'series' }
  198. },
  199. {
  200. type: 'line',
  201. smooth: true,
  202. seriesLayoutBy: 'row',
  203. emphasis: { focus: 'series' }
  204. },
  205. {
  206. type: 'line',
  207. smooth: true,
  208. seriesLayoutBy: 'row',
  209. emphasis: { focus: 'series' }
  210. },
  211. {
  212. type: 'line',
  213. smooth: true,
  214. seriesLayoutBy: 'row',
  215. emphasis: { focus: 'series' }
  216. },
  217. {
  218. type: 'pie',
  219. id: 'pie',
  220. radius: '30%',
  221. center: ['50%', '25%'],
  222. emphasis: {
  223. focus: 'self'
  224. },
  225. label: {
  226. formatter: '{b}: {@2012} ({d}%)'
  227. },
  228. encode: {
  229. itemName: 'product',
  230. value: '2012',
  231. tooltip: '2012'
  232. }
  233. }
  234. ]
  235. };
  236. myChart.on('updateAxisPointer', function (event) {
  237. const xAxisInfo = event.axesInfo[0];
  238. if (xAxisInfo) {
  239. const dimension = xAxisInfo.value + 1;
  240. myChart.setOption({
  241. series: {
  242. id: 'pie',
  243. label: {
  244. formatter: '{b}: {@[' + dimension + ']} ({d}%)'
  245. },
  246. encode: {
  247. value: dimension,
  248. tooltip: dimension
  249. }
  250. }
  251. });
  252. }
  253. });
  254. myChart.setOption(option);
  255. });
  256. option && myChart.setOption(option);
  257. })
  258. },
  259. echartsInit5 () {
  260. getCountByDepType().then(res=>{
  261. var data1=[];
  262. var data2=[];
  263. var data3=[];
  264. for(let i=0;i<res.data.dw.length;i++){
  265. data3.push(res.data.dw[i].mon)
  266. }
  267. for(let i=0;i<res.data.dw.length;i++){
  268. data1.push(res.data.dw[i].count)
  269. }
  270. for(let i=0;i<res.data.gs.length;i++){
  271. data2.push(res.data.gs[i].count)
  272. }
  273. var chartDom = document.getElementById('depByMon');
  274. var myChart = this.$echarts.init(chartDom);
  275. var option;
  276. option = {
  277. title: {
  278. // text: '招标公告中招标人成分分析'
  279. },
  280. tooltip: {
  281. trigger: 'axis',
  282. axisPointer: {
  283. type: 'cross',
  284. label: {
  285. backgroundColor: '#6a7985'
  286. }
  287. }
  288. },
  289. legend: {
  290. data: ['公司', '单位']
  291. },
  292. toolbox: {
  293. feature: {
  294. saveAsImage: {}
  295. }
  296. },
  297. grid: {
  298. left: '3%',
  299. right: '4%',
  300. bottom: '3%',
  301. containLabel: true
  302. },
  303. xAxis: [
  304. {
  305. type: 'category',
  306. boundaryGap: false,
  307. data: data3
  308. }
  309. ],
  310. yAxis: [
  311. {
  312. type: 'value'
  313. }
  314. ],
  315. series: [
  316. {
  317. name: '公司',
  318. type: 'line',
  319. stack: 'Total',
  320. areaStyle: {},
  321. emphasis: {
  322. focus: 'series'
  323. },
  324. data: data2
  325. },
  326. {
  327. name: '单位',
  328. type: 'line',
  329. stack: 'Total',
  330. areaStyle: {},
  331. emphasis: {
  332. focus: 'series'
  333. },
  334. data: data1
  335. },
  336. ]
  337. };
  338. option && myChart.setOption(option);
  339. })
  340. },
  341. echartsInit6 () {
  342. selectAllSumPriceByMon().then(res=>{
  343. var data1=[];
  344. var data2=[];
  345. for(let i=0;i<res.data.length;i++){
  346. data1.push(res.data[i].mon)
  347. }
  348. for(let i=0;i<res.data.length;i++){
  349. data2.push(res.data[i].price)
  350. }
  351. var chartDom = document.getElementById('priceByMon');
  352. var myChart = this.$echarts.init(chartDom);
  353. var option;
  354. option = {
  355. tooltip: {
  356. trigger: 'item'
  357. },
  358. legend: {
  359. orient: 'vertical',
  360. left: 'top'
  361. },
  362. xAxis: {
  363. type: 'category',
  364. data: data1
  365. },
  366. yAxis: {
  367. type: 'value'
  368. },
  369. series: [
  370. {
  371. data: data2,
  372. type: 'bar'
  373. }
  374. ],
  375. dataZoom: [
  376. {
  377. show: true,
  378. start: 74,
  379. end: 100
  380. },
  381. {
  382. type: 'inside',
  383. start: 94,
  384. end: 100
  385. },
  386. {
  387. show: true,
  388. yAxisIndex: 0,
  389. filterMode: 'empty',
  390. width: 30,
  391. height: '80%',
  392. showDataShadow: false,
  393. left: '93%'
  394. }
  395. ],
  396. };
  397. option && myChart.setOption(option);
  398. })
  399. },
  400. },
  401. mounted () {
  402. this.echartsInit()
  403. this.echartsInit1()
  404. this.echartsInit2()
  405. this.echartsInit3()
  406. this.echartsInit4()
  407. this.echartsInit5()
  408. this.echartsInit6()
  409. }
  410. }
  411. </script>
  412. <style scoped >
  413. h6{
  414. text-align: center;
  415. }
  416. #ZBCount{
  417. width: 100%;
  418. height: 300px;
  419. margin-left: auto;
  420. margin-right: auto;
  421. float: left;
  422. }
  423. #JGCount{
  424. width: 100%;
  425. height: 300px;
  426. margin-left: auto;
  427. margin-right: auto;
  428. float: right;
  429. }
  430. #allCount{
  431. width: 100%;
  432. height: 300px;
  433. margin-left: auto;
  434. margin-right: auto;
  435. float: right;
  436. }
  437. #ZBandJGByMon{
  438. width: 100%;
  439. height: 700px;
  440. margin-left: auto;
  441. margin-right: auto;
  442. float: right;
  443. }
  444. #depByMon{
  445. width: 100%;
  446. height: 700px;
  447. margin-left: auto;
  448. margin-right: auto;
  449. float: right;
  450. }
  451. #priceByMon{
  452. width: 100%;
  453. height: 500px;
  454. margin-left: auto;
  455. margin-right: auto;
  456. float: right;
  457. }
  458. h6{
  459. font-size: 18px;
  460. margin-top: 25px;
  461. text-align: center;
  462. }
  463. </style>