index.vue 12 KB

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