Statistics.vue 44 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402
  1. <style>
  2. .statistics .ant-col-6 {
  3. margin: 10px 0;
  4. }
  5. .statistics .ant-col-6 .ant-card-body {
  6. display: flex;
  7. justify-content: center;
  8. }
  9. .statistics .ant-col-6 p,
  10. .statistics .ant-col-6 span {
  11. text-align: center;
  12. line-height: 40px;
  13. font-size: 30px;
  14. font-weight: 600;
  15. color: red;
  16. margin: 0;
  17. }
  18. .search-box .ant-card-body {
  19. padding: 5px 15px;
  20. }
  21. .search-box p {
  22. display: inline-block;
  23. border: 1px solid #f2f2f2;
  24. border-radius: 5px;
  25. margin-right: 10px;
  26. padding: 5px 10px;
  27. cursor: pointer;
  28. }
  29. .statistics .ant-col-6 .ant-card-body .styleElse {
  30. line-height: 60px;
  31. height: 40px;
  32. font-size: 16px;
  33. font-weight: 400;
  34. margin-left: 10px;
  35. }
  36. .ant-modal-wrap .yincang .ant-modal-content .ant-modal-footer {
  37. display: none !important;
  38. }
  39. .yincang .ant-col-6 p {
  40. text-align: left;
  41. color: red;
  42. font-size: 16px;
  43. font-weight: 500;
  44. }
  45. .ant-table-thead div {
  46. font-weight: 700;
  47. }
  48. .tool-tip {
  49. position: absolute;
  50. top: 65px;
  51. right: 10px;
  52. }
  53. </style>
  54. <template>
  55. <div class="statistics">
  56. <a-row class="image-list-heading vm-panel">
  57. <a-row>
  58. <div class="panel-heading">{{ title }}</div>
  59. </a-row>
  60. </a-row>
  61. <a-row>
  62. <a-col :span="24">
  63. <a-card :bordered="false" class="search-box">
  64. <p :style="active==1?'color:cornflowerblue;background:#f2f2f2':''" @click="getAdd(1)">今天</p>
  65. <p :style="active==2?'color:cornflowerblue;background:#f2f2f2':''" @click="getAdd(2)">昨天</p>
  66. <p :style="active==3?'color:cornflowerblue;background:#f2f2f2':''" @click="getAdd(3)">近一周</p>
  67. <p :style="active==4?'color:cornflowerblue;background:#f2f2f2':''" @click="getAdd(4)">近十五天</p>
  68. <p :style="active==5?'color:cornflowerblue;background:#f2f2f2':''" @click="getAdd(5)">近一月</p>
  69. <p :style="active==6?'color:cornflowerblue;background:#f2f2f2':''" @click="getAdd(6)">近三月</p>
  70. <p :style="active==7?'color:cornflowerblue;background:#f2f2f2':''" @click="getAdd(7)">近半年</p>
  71. <p :style="active==8?'color:cornflowerblue;background:#f2f2f2':''" @click="getAdd(8)">所有</p>
  72. <a-range-picker
  73. style="width:400px"
  74. :disabledDate="disabledDate"
  75. :showTime="{
  76. hideDisabledOptions: true,
  77. }"
  78. format="YYYY-MM-DD"
  79. v-model="startValue"
  80. @ok="getAdd(9)"
  81. />
  82. </a-card>
  83. </a-col>
  84. <a-col :span="24">
  85. <a-card :bordered="false" class="search-box">
  86. <p @click="visible = true">对比</p>
  87. </a-card>
  88. </a-col>
  89. </a-row>
  90. <a-row :gutter="16" v-if="kuaishou">
  91. <a-col :span="6">
  92. <lifting
  93. :kuaishou.sync="kuaishou"
  94. :active.sync="active"
  95. title="总消耗"
  96. typeName="cost"
  97. typeThan="costProportion"
  98. ></lifting>
  99. </a-col>
  100. <a-col :span="6">
  101. <lifting
  102. :kuaishou.sync="kuaishou"
  103. :active.sync="active"
  104. title="封面点击数"
  105. typeName="photoClick"
  106. typeThan="photoClickProportion"
  107. ></lifting>
  108. </a-col>
  109. <a-col :span="6">
  110. <lifting
  111. :kuaishou.sync="kuaishou"
  112. :active.sync="active"
  113. title="封面曝光数"
  114. typeName="photoShow"
  115. typeThan="showProportion"
  116. ></lifting>
  117. </a-col>
  118. <a-col :span="6">
  119. <lifting
  120. :kuaishou.sync="kuaishou"
  121. :active.sync="active"
  122. title="素材曝光数"
  123. typeName="aclick"
  124. typeThan="aClickProportion"
  125. ></lifting>
  126. </a-col>
  127. </a-row>
  128. <a-row :gutter="10">
  129. <a-col :span="24">
  130. <a-card
  131. style="width:100%"
  132. :tabList="tabListNoTitle"
  133. :activeTabKey="noTitleKey"
  134. @tabChange="key => onTabChange(key, 'noTitleKey')"
  135. >
  136. <div id="chart" style="width:100%;height:500px"></div>
  137. </a-card>
  138. </a-col>
  139. </a-row>
  140. <a-modal title="数据对比" v-model="visible" width="80%" class="yincang">
  141. <a-radio-group v-model="value" style="margin-bottom:10px" @change="clear">
  142. <a-radio-button value="month">对比月</a-radio-button>
  143. <a-radio-button value="day">对比天</a-radio-button>
  144. </a-radio-group>
  145. <br />
  146. <div style="display:flex">
  147. <div v-if="value == 'month'" style="width:400px">
  148. <a-month-picker placeholder="请选择对比月份" v-model="oneMonth" style="width:50%" />
  149. <a-month-picker placeholder="请选择对比月份" v-model="twoMonth" style="width:50%" />
  150. </div>
  151. <a-range-picker
  152. v-else
  153. style="width:400px"
  154. :disabledDate="disabledDate"
  155. :showTime="{
  156. hideDisabledOptions: true,
  157. }"
  158. format="YYYY-MM-DD"
  159. v-model="contrastValue"
  160. />
  161. <a-button type="primary" style="margin-left:5px" @click="search">查询</a-button>
  162. </div>
  163. <a-row :gutter="15" style="margin-bottom:15px;margin-top:15px" v-if="contrastDataAll">
  164. <a-col :span="6">
  165. <a-card title="总消耗对比">
  166. <p>{{contrastDataAll.beCompared.statDate}}:{{contrastDataAll.beCompared.cost}}</p>
  167. <p>
  168. {{contrastDataAll.compared.statDate}}:{{contrastDataAll.compared.cost}}
  169. <a-icon
  170. v-if="contrastDataAll.compared.costProportion>0"
  171. type="rise"
  172. class="styleElse"
  173. style="color:red;"
  174. />
  175. <a-icon
  176. v-else-if="contrastDataAll.compared.costProportion<0"
  177. type="fall"
  178. class="styleElse"
  179. style="color:#0bcd74;"
  180. />
  181. <a-icon
  182. v-else-if="contrastDataAll.compared.costProportion==0"
  183. type="minus"
  184. class="styleElse"
  185. style="color:#0bcd74"
  186. />
  187. <span
  188. :style="contrastDataAll.compared.costProportion>0?'color:red':'color:#0bcd74'"
  189. class="styleElse"
  190. style=" margin-left:0"
  191. >{{Math.abs(contrastDataAll.compared.costProportion).toFixed(2)+'%'}}</span>
  192. </p>
  193. </a-card>
  194. </a-col>
  195. <a-col :span="6">
  196. <a-card title="封面点击数对比">
  197. <p>{{contrastDataAll.beCompared.statDate}}:{{contrastDataAll.beCompared.photoClick}}</p>
  198. <p>
  199. {{contrastDataAll.compared.statDate}}:{{contrastDataAll.compared.photoClick}}
  200. <a-icon
  201. v-if="contrastDataAll.compared.photoClickProportion>0"
  202. type="rise"
  203. class="styleElse"
  204. style="color:red;"
  205. />
  206. <a-icon
  207. v-else-if="contrastDataAll.compared.photoClickProportion<0"
  208. type="fall"
  209. class="styleElse"
  210. style="color:#0bcd74;"
  211. />
  212. <a-icon
  213. v-else-if="contrastDataAll.compared.photoClickProportion==0"
  214. type="minus"
  215. class="styleElse"
  216. style="color:#0bcd74"
  217. />
  218. <span
  219. :style="contrastDataAll.compared.photoClickProportion>0?'color:red':'color:#0bcd74'"
  220. class="styleElse"
  221. style=" margin-left:0"
  222. >{{Math.abs(contrastDataAll.compared.photoClickProportion).toFixed(2)+'%'}}</span>
  223. </p>
  224. </a-card>
  225. </a-col>
  226. <a-col :span="6">
  227. <a-card title="封面曝光数对比">
  228. <p>{{contrastDataAll.beCompared.statDate}}:{{contrastDataAll.beCompared.photoShow}}</p>
  229. <p>
  230. {{contrastDataAll.compared.statDate}}:{{contrastDataAll.compared.photoShow}}
  231. <a-icon
  232. v-if="contrastDataAll.compared.showProportion>0"
  233. type="rise"
  234. class="styleElse"
  235. style="color:red;"
  236. />
  237. <a-icon
  238. v-else-if="contrastDataAll.compared.showProportion<0"
  239. type="fall"
  240. class="styleElse"
  241. style="color:#0bcd74;"
  242. />
  243. <a-icon
  244. v-else-if="contrastDataAll.compared.showProportion==0"
  245. type="minus"
  246. class="styleElse"
  247. style="color:#0bcd74"
  248. />
  249. <span
  250. :style="contrastDataAll.compared.showProportion>0?'color:red':'color:#0bcd74'"
  251. class="styleElse"
  252. style=" margin-left:0"
  253. >{{Math.abs(contrastDataAll.compared.showProportion).toFixed(2)+'%'}}</span>
  254. </p>
  255. </a-card>
  256. </a-col>
  257. <a-col :span="6">
  258. <a-card title="素材曝光数对比">
  259. <p>{{contrastDataAll.beCompared.statDate}}:{{contrastDataAll.beCompared.aclick}}</p>
  260. <p>
  261. {{contrastDataAll.compared.statDate}}:{{contrastDataAll.compared.aclick}}
  262. <a-icon
  263. v-if="contrastDataAll.compared.comparedAclick>0"
  264. type="rise"
  265. class="styleElse"
  266. style="color:red;"
  267. />
  268. <a-icon
  269. v-else-if="contrastDataAll.compared.comparedAclick<0"
  270. type="fall"
  271. class="styleElse"
  272. style="color:#0bcd74;"
  273. />
  274. <a-icon
  275. v-else-if="contrastDataAll.compared.comparedAclick==0"
  276. type="minus"
  277. class="styleElse"
  278. style="color:#0bcd74"
  279. />
  280. <span
  281. :style="contrastDataAll.compared.comparedAclick>0?'color:red':'color:#0bcd74'"
  282. class="styleElse"
  283. style=" margin-left:0"
  284. >{{Math.abs(contrastDataAll.compared.comparedAclick).toFixed(2)+'%'}}</span>
  285. </p>
  286. </a-card>
  287. </a-col>
  288. </a-row>
  289. <a-row v-else>
  290. <a-col :span="24" style="text-align:center;height:186px;line-height:186px">暂无数据</a-col>
  291. </a-row>
  292. <a-row :gutter="10">
  293. <a-col :span="24">
  294. <a-card
  295. style="width:100%"
  296. :tabList="tabListNoTitle"
  297. :activeTabKey="noTitleKeyTwo"
  298. @tabChange="key => onTabChange(key, 'noTitleKeyTwo')"
  299. >
  300. <div id="chart1" style="width:100%;height:500px"></div>
  301. </a-card>
  302. </a-col>
  303. </a-row>
  304. <a-row style="margin-bottom:15px;margin-top:15px" v-if="dataTableTwo.length>0">
  305. <a-col :span="24">
  306. <a-card
  307. :tabList="tableCard"
  308. :activeTabKey="noTitleKeyTableTwo"
  309. @tabChange="key => onTabChange(key, 'noTitleKeyTableTwo')"
  310. >
  311. <a-table :columns="columnsDb" :dataSource="dataTableTwo" :pagination="false" bordered></a-table>
  312. </a-card>
  313. </a-col>
  314. </a-row>
  315. </a-modal>
  316. <a-row style="margin-bottom:15px;margin-top:15px">
  317. <a-col :span="24">
  318. <a-card
  319. :tabList="tableNowCard"
  320. :activeTabKey="noTitleKeyTable"
  321. @tabChange="key => onTabChange(key, 'noTitleKeyTable')"
  322. >
  323. <a-table
  324. :columns="columns"
  325. :dataSource="dataTable"
  326. :pagination="false"
  327. :loading="loading"
  328. bordered
  329. ></a-table>
  330. </a-card>
  331. </a-col>
  332. </a-row>
  333. </div>
  334. </template>
  335. <script>
  336. import ARow from 'ant-design-vue/es/grid/Row'
  337. import ACol from 'ant-design-vue/es/grid/Col'
  338. import moment from 'moment'
  339. import countTo from 'vue-count-to'
  340. import lifting from './components/lifting'
  341. import { getAccountReport, getKsAccountReport, getKsDetail, getReportList } from '@api/video.js'
  342. import { getAction, postAction } from '@/api/manage'
  343. var upDate
  344. // 引入基本模板
  345. let echarts = require('echarts/lib/echarts')
  346. // 引入柱状图组件
  347. require('echarts/lib/chart/bar')
  348. require('echarts/lib/chart/pie')
  349. require('echarts/lib/chart/line')
  350. // 引入提示框和title组件
  351. require('echarts/lib/component/tooltip')
  352. require('echarts/lib/component/title')
  353. require('echarts/lib/component/graphic')
  354. require('echarts/lib/component/toolbox')
  355. require('echarts/lib/component/legend')
  356. export default {
  357. name: 'statistics',
  358. components: {
  359. ACol,
  360. ARow,
  361. countTo,
  362. lifting
  363. },
  364. data: function() {
  365. return {
  366. loading: true,
  367. columns: [
  368. { title: '时间', dataIndex: 'statDate', align: 'center' },
  369. {
  370. title: '总消耗环比',
  371. dataIndex: 'yesCost',
  372. scopedSlots: { customRender: 'yesCost' },
  373. align: 'center'
  374. },
  375. { title: '总消耗', dataIndex: 'cost', align: 'center' },
  376. {
  377. title: '封面点击数环比',
  378. dataIndex: 'yesPhotoClick',
  379. scopedSlots: { customRender: 'photoClickProportion' },
  380. align: 'center'
  381. },
  382. { title: '封面点击数', dataIndex: 'photoClick', align: 'center' },
  383. {
  384. title: '封面曝光数环比',
  385. dataIndex: 'yesPhotoShow',
  386. scopedSlots: { customRender: 'photoShowProportion' },
  387. align: 'center'
  388. },
  389. { title: '封面曝光数', dataIndex: 'photoShow', align: 'center' },
  390. {
  391. title: '素材曝光数环比',
  392. dataIndex: 'yesAclick',
  393. scopedSlots: { customRender: 'aclickProportion' },
  394. align: 'center'
  395. },
  396. { title: '素材曝光数', dataIndex: 'aclick', align: 'center' }
  397. ],
  398. columnsDb: [
  399. { title: '时间', dataIndex: 'statDate', align: 'center' },
  400. { title: '总消耗', dataIndex: 'cost', align: 'center' },
  401. { title: '封面点击数', dataIndex: 'photoClick', align: 'center' },
  402. { title: '封面曝光数', dataIndex: 'photoShow', align: 'center' },
  403. { title: '素材曝光数', dataIndex: 'aclick', align: 'center' }
  404. ],
  405. dataTable: [],
  406. dataTableTwo: [],
  407. dataAllTableTwo: null,
  408. dataAllTable: null,
  409. dataAllTableYester: null,
  410. title: '快手大盘',
  411. visible: false,
  412. statistics: [],
  413. showData: null,
  414. startValue: [],
  415. contrastValue: [],
  416. contrastDataAll: null,
  417. allValue: ['', ''],
  418. value: 'month',
  419. oneMonth: null,
  420. twoMonth: null,
  421. kuaishou: {
  422. aclick: 0,
  423. aClickProportion: 0,
  424. cost: 0,
  425. costProportion: 0,
  426. photoClick: 0,
  427. photoClickroportion: 0,
  428. photoShow: 0,
  429. showProportion: 0
  430. },
  431. tabListNoTitle: [
  432. {
  433. key: 'cost',
  434. tab: '总消耗'
  435. },
  436. {
  437. key: 'photoClick',
  438. tab: '封面点击数'
  439. },
  440. {
  441. key: 'photoShow',
  442. tab: '封面曝光数'
  443. },
  444. {
  445. key: 'aclick',
  446. tab: '素材曝光数'
  447. }
  448. ],
  449. tableCard: [
  450. {
  451. key: 'small',
  452. tab: '前'
  453. },
  454. {
  455. key: 'big',
  456. tab: '后'
  457. }
  458. ],
  459. tableNowCard: [
  460. {
  461. key: 'now',
  462. tab: '今天'
  463. },
  464. {
  465. key: 'yesterday',
  466. tab: '昨天'
  467. }
  468. ],
  469. noTitleKeyTableTwo: 'small',
  470. noTitleKey: 'cost',
  471. noTitleKeyTwo: 'cost',
  472. noTitleKeyTable: 'now',
  473. chart: null,
  474. chart1: null,
  475. active: 1,
  476. duration: 1000,
  477. dataDetail: null,
  478. contrastDataList: []
  479. }
  480. },
  481. methods: {
  482. a(item) {
  483. console.log(item)
  484. },
  485. moment,
  486. clear() {
  487. this.twoMonth = null
  488. this.oneMonth = null
  489. this.contrastDataAll = null
  490. this.contrastDataList = null
  491. this.contrastValue = []
  492. this.dataTableTwo = []
  493. this.dataAllTableTwo = null
  494. if (this.chart) {
  495. this.chart.clear()
  496. }
  497. },
  498. search() {
  499. var params = {}
  500. params.type = 10
  501. params.sign = this.value
  502. if (this.value == 'month') {
  503. if (this.twoMonth && this.oneMonth) {
  504. params.bigDate = moment(this.twoMonth._d).format('YYYY-MM')
  505. params.smallDate = moment(this.oneMonth._d).format('YYYY-MM')
  506. } else {
  507. this.$message.error('请选择两个需要对比的数据')
  508. }
  509. } else if (this.value == 'day') {
  510. params.smallDate = moment(this.contrastValue[0]._d).format('YYYY-MM-DD')
  511. params.bigDate = moment(this.contrastValue[1]._d).format('YYYY-MM-DD')
  512. }
  513. getKsAccountReport(params).then(res => {
  514. if (res.compared) {
  515. this.contrastDataAll = res
  516. // this.drawPieAll(res)
  517. } else {
  518. this.contrastDataAll = null
  519. }
  520. })
  521. getKsDetail(params).then(res => {
  522. this.contrastDataList = res
  523. this.drawSearchLine(this.noTitleKeyTwo, res)
  524. })
  525. getReportList(params).then(res => {
  526. this.tableCard = [
  527. {
  528. key: 'small',
  529. tab: res[0].beStatDate
  530. },
  531. {
  532. key: 'big',
  533. tab: res[0].statDate
  534. }
  535. ]
  536. this.noTitleKeyTableTwo = 'small'
  537. if (this.value == 'day') {
  538. this.dataAllTableTwo = res[0]
  539. this.dataTableTwo = res[0].beComparedDetail.map((item, index) => {
  540. return {
  541. ...item,
  542. statDate: item.statDate + ' ' + item.statHour + '时',
  543. key: index
  544. }
  545. })
  546. } else {
  547. this.dataAllTableTwo = res[0]
  548. this.dataTableTwo = res[0].beComparedDetail
  549. }
  550. })
  551. },
  552. getReportList(checked, dateValue) {
  553. let params = {}
  554. params.type = checked
  555. if (this.active == 9) {
  556. params.startDate = dateValue[0]
  557. params.endDate = dateValue[1]
  558. }
  559. // proportion
  560. this.loading = true
  561. if (this.active == 1) {
  562. getReportList(params).then(res => {
  563. if (res[0].now.length > 0) {
  564. for (let i = 0; i < res[0].now.length; i++) {
  565. for (let j = 0; j < res[0].yesterday.length; j++) {
  566. if (res[0].now[i].statHour == res[0].yesterday[j].statHour) {
  567. res[0].now[i].yesCost =
  568. (((res[0].now[i].cost - res[0].yesterday[j].cost) / res[0].yesterday[j].cost) * 100).toFixed(2) +
  569. '%'
  570. res[0].now[i].yesPhotoClick =
  571. (
  572. ((res[0].now[i].photoClick - res[0].yesterday[j].photoClick) / res[0].yesterday[j].photoClick) *
  573. 100
  574. ).toFixed(2) + '%'
  575. res[0].now[i].yesPhotoShow =
  576. (
  577. ((res[0].now[i].photoShow - res[0].yesterday[j].photoShow) / res[0].yesterday[j].photoShow) *
  578. 100
  579. ).toFixed(2) + '%'
  580. res[0].now[i].yesAclick =
  581. (((res[0].now[i].aclick - res[0].yesterday[j].aclick) / res[0].yesterday[j].aclick) * 100).toFixed(
  582. 2
  583. ) + '%'
  584. }
  585. }
  586. }
  587. this.dataTable = res[0].now.map((item, index) => {
  588. return {
  589. key: index,
  590. ...item,
  591. statDate:
  592. this.active == 1 || this.active == 2 ? item.statDate + ' ' + item.statHour + '时' : item.statDate
  593. }
  594. })
  595. this.dataAllTableYester = res[0].yesterday.map((item, index) => {
  596. return {
  597. key: index,
  598. ...item,
  599. statDate:
  600. this.active == 1 || this.active == 2 ? item.statDate + ' ' + item.statHour + '时' : item.statDate
  601. }
  602. })
  603. this.dataAllTable = this.dataTable
  604. this.loading = false
  605. } else {
  606. this.dataAllTable = null
  607. this.dataTable = []
  608. this.dataAllTableYester = res[0].yesterday
  609. this.loading = false
  610. }
  611. })
  612. } else {
  613. getReportList(params).then(res => {
  614. this.dataTable = res.map((item, index) => {
  615. return {
  616. key: index,
  617. ...item,
  618. statDate:
  619. this.active == 1 || this.active == 2 ? item.statDate + ' ' + item.statHour + '时' : item.statDate
  620. }
  621. })
  622. this.loading = false
  623. })
  624. }
  625. },
  626. drawPieAll(data) {
  627. var colorList = ['#afa3f5', '#00d488', '#3feed4', '#3bafff', '#f1bb4c', 'rgba(250,250,250,0.5)']
  628. var option = {
  629. tooltip: {
  630. trigger: 'item',
  631. formatter: '{a} <br/>{b} : {c}'
  632. },
  633. series: [
  634. {
  635. name: '总消耗对比',
  636. type: 'pie',
  637. radius: '35%',
  638. center: ['50%', '50%'],
  639. data: [{ value: 944332, name: '2019-09' }, { value: 6839241.89, name: '2019-10' }],
  640. itemStyle: {
  641. normal: {
  642. color: function(params) {
  643. return colorList[params.dataIndex]
  644. }
  645. }
  646. }
  647. }
  648. ]
  649. }
  650. var chart = echarts.init(document.getElementById('chart3'))
  651. chart.clear()
  652. chart.setOption(option, true)
  653. },
  654. drawSearchLine(type, data) {
  655. var dataLegend = []
  656. var dataLength = [] //小月份数据
  657. var dataLengthBig = [] //大月份数据
  658. var dataElse = []
  659. var dataDate = []
  660. var that = this
  661. var showName = null
  662. if (data) {
  663. if (this.value == 'month') {
  664. dataLegend = [moment(this.oneMonth._d).format('YYYY-MM'), moment(this.twoMonth._d).format('YYYY-MM')]
  665. dataDate = data.map(item => {
  666. return item.statDate.substring(item.statDate.length - 2, item.statDate.length)
  667. })
  668. } else if (this.value == 'day') {
  669. dataLegend = [
  670. moment(this.contrastValue[0]._d).format('YYYY-MM-DD'),
  671. moment(this.contrastValue[1]._d).format('YYYY-MM-DD')
  672. ]
  673. dataDate = data.map(item => {
  674. return item.statHour
  675. })
  676. }
  677. if (type == 'cost') {
  678. showName = '总消耗'
  679. dataLength = data.map(item => {
  680. return item.beComparedCost
  681. })
  682. dataLengthBig = data.map(item => {
  683. return item.cost
  684. })
  685. dataElse = data.map(item => {
  686. if (this.value == 'month') {
  687. return { proportion: (item.costProportion * 100).toFixed(2) + '%', statHour: item.beComparedDate }
  688. } else {
  689. return { proportion: (item.costProportion * 100).toFixed(2) + '%', statHour: item.statHour }
  690. }
  691. })
  692. } else if (type == 'photoClick') {
  693. showName = '封面点击数'
  694. dataLength = data.map(item => {
  695. return item.beComparedPhotoClick
  696. })
  697. dataLengthBig = data.map(item => {
  698. return item.photoClick
  699. })
  700. dataElse = data.map(item => {
  701. if (this.value == 'month') {
  702. return { proportion: (item.photoClickProportion * 100).toFixed(2) + '%', statHour: item.beComparedDate }
  703. } else {
  704. return { proportion: (item.photoClickProportion * 100).toFixed(2) + '%', statHour: item.statHour }
  705. }
  706. })
  707. } else if (type == 'photoShow') {
  708. showName = '封面曝光数'
  709. dataLength = data.map(item => {
  710. return item.beComparedPhotoShow
  711. })
  712. dataLengthBig = data.map(item => {
  713. return item.photoShow
  714. })
  715. dataElse = data.map(item => {
  716. if (this.value == 'month') {
  717. return { proportion: (item.showProportion * 100).toFixed(2) + '%', statHour: item.beComparedDate }
  718. } else {
  719. return { proportion: (item.showProportion * 100).toFixed(2) + '%', statHour: item.statHour }
  720. }
  721. })
  722. } else if (type == 'aclick') {
  723. showName = '素材曝光数'
  724. dataLength = data.map(item => {
  725. return item.beComparedAClick
  726. })
  727. dataLengthBig = data.map(item => {
  728. return item.aClick
  729. })
  730. dataElse = data.map(item => {
  731. if (this.value == 'month') {
  732. return { proportion: (item.comparedAclick * 100).toFixed(2) + '%', statHour: item.beComparedDate }
  733. } else {
  734. return { proportion: (item.comparedAclick * 100).toFixed(2) + '%', statHour: item.statHour }
  735. }
  736. })
  737. }
  738. }
  739. var option = {
  740. backgroundColor: '#fff',
  741. tooltip: {
  742. trigger: 'axis',
  743. formatter: function(params) {
  744. var index
  745. if (that.value == 'month') {
  746. index = dataElse.findIndex(
  747. v => v.statHour.substring(v.statHour.length - 2, v.statHour.length) == params[0].name
  748. )
  749. } else {
  750. index = dataElse.findIndex(
  751. v => v.statHour.substring(v.statHour.length - 2, v.statHour.length) == params[0].name
  752. )
  753. }
  754. var da = null
  755. if (index >= 0) {
  756. da = dataElse[index].proportion
  757. }
  758. if (that.value == 'month') {
  759. return `${params[0].marker}时间:${params[0].seriesName}-${params[0].name}:${showName}:${params[0].data} <br/>
  760. ${params[1].marker}时间:${params[1].seriesName}-${params[0].name}:${showName}:${params[1].data} <br/>
  761. 环比:${da}<br/> `
  762. } else {
  763. return `${params[0].marker}时间:${params[0].seriesName}:${showName}:${params[0].data} <br/>
  764. ${params[1].marker}时间:${params[1].seriesName}:${showName}:${params[1].data} <br/>
  765. 环比:${da}<br/> `
  766. }
  767. }
  768. },
  769. legend: {
  770. data: dataLegend
  771. },
  772. grid: {
  773. left: '2%',
  774. right: '2%',
  775. bottom: '2%',
  776. containLabel: true
  777. },
  778. xAxis: {
  779. type: 'category',
  780. data: dataDate,
  781. boundaryGap: false,
  782. // 坐标轴线
  783. axisLine: {
  784. show: false,
  785. lineStyle: {
  786. color: '#999'
  787. }
  788. },
  789. // 分割线
  790. splitLine: {
  791. show: true,
  792. lineStyle: {
  793. type: 'dashed',
  794. color: '#e5e5e5'
  795. }
  796. }
  797. },
  798. yAxis: {
  799. type: 'value',
  800. axisLine: {
  801. show: false,
  802. lineStyle: {
  803. color: '#999'
  804. }
  805. },
  806. splitLine: {
  807. lineStyle: {
  808. type: 'dashed',
  809. color: '#e5e5e5'
  810. }
  811. }
  812. },
  813. series: [
  814. {
  815. name: dataLegend[0],
  816. type: 'line',
  817. color: '#0bcd74',
  818. smooth: true,
  819. symbol: 'circle',
  820. symbolSize: 1,
  821. lineStyle: {
  822. normal: {
  823. width: 2,
  824. color: '#0bcd74'
  825. }
  826. },
  827. itemStyle: {
  828. borderColor: '#ffffff',
  829. borderWidth: 3
  830. },
  831. data: dataLength
  832. },
  833. {
  834. name: dataLegend[1],
  835. type: 'line',
  836. color: '#9933ff',
  837. smooth: true,
  838. symbol: 'circle',
  839. symbolSize: 1,
  840. lineStyle: {
  841. normal: {
  842. width: 2,
  843. color: '#9933ff'
  844. }
  845. },
  846. itemStyle: {
  847. borderColor: '#ffffff',
  848. borderWidth: 3
  849. },
  850. data: dataLengthBig
  851. }
  852. ]
  853. }
  854. this.chart = echarts.init(document.getElementById('chart1'))
  855. this.chart.clear()
  856. this.chart.setOption(option, true)
  857. // window.onresize = function() {
  858. // chart.resize()
  859. // }
  860. },
  861. disabledDate(current) {
  862. // Can not select days before today and today
  863. return current && current > moment().endOf('day')
  864. },
  865. onTabChange(key, type) {
  866. console.log(key, type)
  867. this[type] = key
  868. if (type == 'noTitleKey') {
  869. this.drawPie(key, this.dataDetail)
  870. } else if (type == 'noTitleKeyTable') {
  871. this.dataTable = []
  872. if (key == 'now') {
  873. this.columns = [
  874. { title: '时间', dataIndex: 'statDate', align: 'center' },
  875. {
  876. title: '总消耗环比',
  877. dataIndex: 'yesCost',
  878. scopedSlots: { customRender: 'yesCost' },
  879. align: 'center'
  880. },
  881. { title: '总消耗', dataIndex: 'cost', align: 'center' },
  882. {
  883. title: '封面点击数环比',
  884. dataIndex: 'yesPhotoClick',
  885. scopedSlots: { customRender: 'photoClickProportion' },
  886. align: 'center'
  887. },
  888. { title: '封面点击数', dataIndex: 'photoClick', align: 'center' },
  889. {
  890. title: '封面曝光数环比',
  891. dataIndex: 'yesPhotoShow',
  892. scopedSlots: { customRender: 'photoShowProportion' },
  893. align: 'center'
  894. },
  895. { title: '封面曝光数', dataIndex: 'photoShow', align: 'center' },
  896. {
  897. title: '素材曝光数环比',
  898. dataIndex: 'yesAclick',
  899. scopedSlots: { customRender: 'aclickProportion' },
  900. align: 'center'
  901. },
  902. { title: '素材曝光数', dataIndex: 'aclick', align: 'center' }
  903. ]
  904. this.dataTable = this.dataAllTable
  905. } else {
  906. this.columns = [
  907. { title: '时间', dataIndex: 'statDate', align: 'center' },
  908. { title: '总消耗', dataIndex: 'cost', align: 'center' },
  909. { title: '封面点击数', dataIndex: 'photoClick', align: 'center' },
  910. { title: '封面曝光数', dataIndex: 'photoShow', align: 'center' },
  911. { title: '素材曝光数', dataIndex: 'aclick', align: 'center' }
  912. ]
  913. this.dataTable = this.dataAllTableYester.map((item, index) => {
  914. return {
  915. key: index,
  916. ...item,
  917. statDate: item.statDate
  918. }
  919. })
  920. }
  921. } else if (type == 'noTitleKeyTableTwo') {
  922. this.dataTableTwo = []
  923. if (key == 'small') {
  924. if (this.value == 'day') {
  925. this.dataTableTwo = this.dataAllTableTwo.beComparedDetail.map(item => {
  926. return {
  927. ...item,
  928. statDate: item.statDate + ' ' + item.statHour + '时'
  929. }
  930. })
  931. } else {
  932. this.dataTableTwo = this.dataAllTableTwo.beComparedDetail
  933. }
  934. } else {
  935. if (this.value == 'day') {
  936. this.dataTableTwo = this.dataAllTableTwo.comparedDetail.map(item => {
  937. return {
  938. ...item,
  939. statDate: item.statDate + ' ' + item.statHour + '时'
  940. }
  941. })
  942. } else {
  943. this.dataTableTwo = this.dataAllTableTwo.comparedDetail
  944. }
  945. }
  946. } else {
  947. this.drawSearchLine(key, this.contrastDataList)
  948. }
  949. },
  950. getAdd(checked) {
  951. if (checked == 9) {
  952. if (this.startValue.length > 0 && this.startValue[0]) {
  953. this.allValue[1] = moment(this.startValue[0]._d).format('YYYY-MM-DD')
  954. this.allValue[0] = moment(this.startValue[1]._d).format('YYYY-MM-DD')
  955. }
  956. } else {
  957. this.startValue = []
  958. this.allValue = []
  959. }
  960. this.active = checked
  961. var arr = [
  962. {
  963. key: 'now',
  964. tab: '今天'
  965. },
  966. {
  967. key: 'yesterday',
  968. tab: '昨天'
  969. }
  970. ]
  971. if (checked == 1) {
  972. this.columns = [
  973. { title: '时间', dataIndex: 'statDate', align: 'center' },
  974. {
  975. title: '总消耗环比',
  976. dataIndex: 'yesCost',
  977. scopedSlots: { customRender: 'yesCost' },
  978. align: 'center'
  979. },
  980. { title: '总消耗', dataIndex: 'cost', align: 'center' },
  981. {
  982. title: '封面点击数环比',
  983. dataIndex: 'yesPhotoClick',
  984. scopedSlots: { customRender: 'photoClickProportion' },
  985. align: 'center'
  986. },
  987. { title: '封面点击数', dataIndex: 'photoClick', align: 'center' },
  988. {
  989. title: '封面曝光数环比',
  990. dataIndex: 'yesPhotoShow',
  991. scopedSlots: { customRender: 'photoShowProportion' },
  992. align: 'center'
  993. },
  994. { title: '封面曝光数', dataIndex: 'photoShow', align: 'center' },
  995. {
  996. title: '素材曝光数环比',
  997. dataIndex: 'yesAclick',
  998. scopedSlots: { customRender: 'aclickProportion' },
  999. align: 'center'
  1000. },
  1001. { title: '素材曝光数', dataIndex: 'aclick', align: 'center' }
  1002. ]
  1003. } else {
  1004. this.columns = [
  1005. { title: '时间', dataIndex: 'statDate', align: 'center' },
  1006. { title: '总消耗', dataIndex: 'cost', align: 'center' },
  1007. { title: '封面点击数', dataIndex: 'photoClick', align: 'center' },
  1008. { title: '封面曝光数', dataIndex: 'photoShow', align: 'center' },
  1009. { title: '素材曝光数', dataIndex: 'aclick', align: 'center' }
  1010. ]
  1011. }
  1012. switch (checked) {
  1013. case 1:
  1014. arr = [
  1015. {
  1016. key: 'now',
  1017. tab: '今天'
  1018. },
  1019. {
  1020. key: 'yesterday',
  1021. tab: '昨天'
  1022. }
  1023. ]
  1024. break
  1025. case 2:
  1026. arr = [
  1027. {
  1028. key: 'yesterday',
  1029. tab: '昨天'
  1030. }
  1031. ]
  1032. break
  1033. case 3:
  1034. arr = [
  1035. {
  1036. key: 'yesterday',
  1037. tab: '近一周'
  1038. }
  1039. ]
  1040. break
  1041. case 4:
  1042. arr = [
  1043. {
  1044. key: 'yesterday',
  1045. tab: '近十五天'
  1046. }
  1047. ]
  1048. break
  1049. case 5:
  1050. arr = [
  1051. {
  1052. key: 'yesterday',
  1053. tab: '近一月'
  1054. }
  1055. ]
  1056. break
  1057. case 6:
  1058. arr = [
  1059. {
  1060. key: 'yesterday',
  1061. tab: '近三月'
  1062. }
  1063. ]
  1064. break
  1065. case 7:
  1066. arr = [
  1067. {
  1068. key: 'yesterday',
  1069. tab: '近半年'
  1070. }
  1071. ]
  1072. break
  1073. case 8:
  1074. arr = [
  1075. {
  1076. key: 'yesterday',
  1077. tab: '所有'
  1078. }
  1079. ]
  1080. break
  1081. case 9:
  1082. arr = [
  1083. {
  1084. key: 'yesterday',
  1085. tab: this.allValue[1] + ' ~ ' + this.allValue[0]
  1086. }
  1087. ]
  1088. break
  1089. }
  1090. this.tableNowCard = arr
  1091. this.getReportList(checked, this.allValue)
  1092. this.drawLine(checked, this.allValue)
  1093. this.getKsDetail(checked, this.allValue).then(res => {
  1094. this.drawPie(this.noTitleKey, res)
  1095. })
  1096. },
  1097. getKsDetail(type, dateValue) {
  1098. var that = this
  1099. return new Promise(function(resolve) {
  1100. let params = {}
  1101. params.type = type
  1102. if (that.active == 9) {
  1103. params.startDate = dateValue[0]
  1104. params.endDate = dateValue[1]
  1105. }
  1106. getKsDetail(params).then(res => {
  1107. that.dataDetail = res
  1108. resolve(res)
  1109. })
  1110. })
  1111. },
  1112. drawLine(type, dateValue) {
  1113. var that = this
  1114. return new Promise(function(resolve) {
  1115. let params = {}
  1116. params.type = type
  1117. if (that.active == 9) {
  1118. params.startDate = dateValue[0]
  1119. params.endDate = dateValue[1]
  1120. }
  1121. getKsAccountReport(params).then(res => {
  1122. var dataNew = []
  1123. var dataX = []
  1124. if (res == '') {
  1125. that.kuaishou.aclick = 0
  1126. that.kuaishou.cost = 0
  1127. that.kuaishou.photoClick = 0
  1128. that.kuaishou.photoShow = 0
  1129. } else {
  1130. that.kuaishou = res
  1131. }
  1132. resolve()
  1133. })
  1134. })
  1135. },
  1136. drawPie(type, data) {
  1137. var dataLegend = []
  1138. var dataLength = []
  1139. var dataElse = []
  1140. var dataDate = []
  1141. var that = this
  1142. if (this.active == 1 || this.active == 2) {
  1143. // data.sort(function(a, b) {
  1144. // return a.statHour - b.statHour
  1145. // })
  1146. dataDate = data.map(item => {
  1147. return item.statHour
  1148. })
  1149. } else {
  1150. // data.sort(function(a, b) {
  1151. // return a.statDate - b.statDate
  1152. // })
  1153. dataDate = data.map(item => {
  1154. return item.statDate
  1155. })
  1156. }
  1157. if (type == 'cost') {
  1158. dataLegend = ['总消耗']
  1159. dataElse = data.map(item => {
  1160. if (item.now) {
  1161. return { proportion: (item.now.costProportion * 100).toFixed(2) + '%', statHour: item.statHour }
  1162. } else {
  1163. return { proportion: 0, statHour: item.statHour }
  1164. }
  1165. })
  1166. } else if (type == 'photoClick') {
  1167. dataLegend = ['封面点击数']
  1168. dataElse = data.map(item => {
  1169. if (item.now) {
  1170. return { proportion: (item.now.photoClickProportion * 100).toFixed(2) + '%', statHour: item.statHour }
  1171. } else {
  1172. return { proportion: 0, statHour: item.statHour }
  1173. }
  1174. })
  1175. } else if (type == 'photoShow') {
  1176. dataLegend = ['封面曝光数']
  1177. dataElse = data.map(item => {
  1178. if (item.now) {
  1179. return { proportion: (item.now.showProportion * 100).toFixed(2) + '%', statHour: item.statHour }
  1180. } else {
  1181. return { proportion: 0, statHour: item.statHour }
  1182. }
  1183. })
  1184. } else if (type == 'aclick') {
  1185. dataLegend = ['素材曝光数']
  1186. dataElse = data.map(item => {
  1187. if (item.now) {
  1188. return { proportion: (item.now.aClickProportion * 100).toFixed(2) + '%', statHour: item.statHour }
  1189. } else {
  1190. return { proportion: 0, statHour: item.statHour }
  1191. }
  1192. })
  1193. }
  1194. dataLength = data.map(item => {
  1195. return item[type]
  1196. })
  1197. var series
  1198. if (this.active == 1) {
  1199. dataLegend = ['今天', '昨天']
  1200. series = [
  1201. {
  1202. name: dataLegend[0],
  1203. type: 'line',
  1204. color: '#9933ff',
  1205. smooth: true,
  1206. symbol: 'circle',
  1207. symbolSize: 1,
  1208. lineStyle: {
  1209. normal: {
  1210. width: 2,
  1211. color: '#9933ff'
  1212. }
  1213. },
  1214. itemStyle: {
  1215. borderColor: '#ffffff',
  1216. borderWidth: 3
  1217. },
  1218. data: data.map(item => {
  1219. if (item.now) {
  1220. return item.now[type]
  1221. } else {
  1222. return 0
  1223. }
  1224. })
  1225. },
  1226. {
  1227. name: dataLegend[1],
  1228. type: 'line',
  1229. color: '#0bcd74',
  1230. smooth: true,
  1231. symbol: 'circle',
  1232. symbolSize: 1,
  1233. lineStyle: {
  1234. normal: {
  1235. width: 2,
  1236. color: '#0bcd74'
  1237. }
  1238. },
  1239. itemStyle: {
  1240. borderColor: '#ffffff',
  1241. borderWidth: 3
  1242. },
  1243. data: dataLength
  1244. }
  1245. ]
  1246. } else {
  1247. series = [
  1248. {
  1249. name: dataLegend[0],
  1250. type: 'line',
  1251. color: '#0bcd74',
  1252. smooth: true,
  1253. symbol: 'circle',
  1254. symbolSize: 1,
  1255. lineStyle: {
  1256. normal: {
  1257. width: 2,
  1258. color: '#0bcd74'
  1259. }
  1260. },
  1261. itemStyle: {
  1262. borderColor: '#ffffff',
  1263. borderWidth: 3
  1264. },
  1265. data: dataLength
  1266. }
  1267. ]
  1268. }
  1269. var option = {
  1270. backgroundColor: '#fff',
  1271. toolbox: {
  1272. show: true,
  1273. feature: {
  1274. dataView: { readOnly: false }
  1275. }
  1276. },
  1277. tooltip: {
  1278. trigger: 'axis',
  1279. formatter: function(params) {
  1280. var index = dataElse.findIndex(v => v.statHour == params[0].name)
  1281. var da = null
  1282. if (index >= 0) {
  1283. da = dataElse[index].proportion
  1284. }
  1285. if (that.active == 1) {
  1286. if (params.length > 1) {
  1287. return `${params[0].marker}今天${params[0].name}时:${params[0].data} <br/>
  1288. ${params[1].marker}昨天${params[1].name}时:${params[1].data} <br/>
  1289. 环比:${da} <br/> `
  1290. } else {
  1291. return `${params[0].marker}时间:${params[0].name} <br/>
  1292. 数值:${params[0].data} `
  1293. }
  1294. } else {
  1295. return `${params[0].marker}时间:${params[0].name} <br/>
  1296. 数值:${params[0].data} `
  1297. }
  1298. }
  1299. },
  1300. legend: {
  1301. data: dataLegend
  1302. },
  1303. grid: {
  1304. left: '2%',
  1305. right: '2%',
  1306. bottom: '2%',
  1307. containLabel: true
  1308. },
  1309. xAxis: {
  1310. type: 'category',
  1311. data: dataDate,
  1312. boundaryGap: false,
  1313. // 坐标轴线
  1314. axisLine: {
  1315. show: false,
  1316. lineStyle: {
  1317. color: '#999'
  1318. }
  1319. },
  1320. // 分割线
  1321. splitLine: {
  1322. show: true,
  1323. lineStyle: {
  1324. type: 'dashed',
  1325. color: '#e5e5e5'
  1326. }
  1327. }
  1328. },
  1329. yAxis: {
  1330. type: 'value',
  1331. axisLine: {
  1332. show: false,
  1333. lineStyle: {
  1334. color: '#999'
  1335. }
  1336. },
  1337. splitLine: {
  1338. lineStyle: {
  1339. type: 'dashed',
  1340. color: '#e5e5e5'
  1341. }
  1342. }
  1343. },
  1344. series: series
  1345. }
  1346. var chart = echarts.init(document.getElementById('chart'))
  1347. chart.clear()
  1348. chart.setOption(option, true)
  1349. window.onresize = function() {
  1350. chart.resize()
  1351. }
  1352. // this.chart.on('click', param => {
  1353. // if (param.name == '总展示') {
  1354. // alert(123)
  1355. // }
  1356. // })
  1357. }
  1358. },
  1359. watch: {},
  1360. computed: {
  1361. newDate() {
  1362. var myDate = new Date()
  1363. myDate.getYear() //获取当前年份(2位)
  1364. var n = myDate.getFullYear() //获取完整的年份(4位,1970-????)
  1365. var m = myDate.getMonth() //获取当前月份(0-11,0代表1月)
  1366. var d = myDate.getDate() //获取当前日(1-31)
  1367. var day = myDate.getHours()
  1368. return day
  1369. }
  1370. },
  1371. activated: function() {
  1372. this.$nextTick(() => {
  1373. var that = this
  1374. that.drawLine(1)
  1375. that.getKsDetail(1).then(res => {
  1376. that.drawPie('cost', res)
  1377. })
  1378. that.getReportList(1, that.allValue)
  1379. upDate = window.setInterval(() => {
  1380. setTimeout(() => {
  1381. that.drawLine(1)
  1382. that.getKsDetail(that.active).then(res => {
  1383. that.drawPie('cost', res)
  1384. })
  1385. that.getReportList(that.active, that.allValue)
  1386. }, 0)
  1387. }, 120000)
  1388. })
  1389. },
  1390. deactivated() {
  1391. window.clearTimeout(upDate)
  1392. }
  1393. }
  1394. </script>