123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494 |
- <style>
- .search-box .ant-card-body {
- padding: 5px 15px;
- }
- .search-box p {
- display: inline-block;
- border: 1px solid #f2f2f2;
- border-radius: 5px;
- margin-right: 10px;
- padding: 5px 10px;
- cursor: pointer;
- }
- .statistics .ant-col-6 .ant-card-body .styleElse {
- line-height: 60px;
- height: 40px;
- font-size: 16px;
- font-weight: 400;
- margin-left: 10px;
- }
- .ant-modal-wrap .yincang .ant-modal-content .ant-modal-footer {
- display: none !important;
- }
- .yincang .ant-col-6 p {
- text-align: left;
- color: red;
- font-size: 16px;
- font-weight: 500;
- }
- .ant-table-thead div {
- font-weight: 700;
- }
- .tool-tip {
- position: absolute;
- top: 65px;
- right: 10px;
- }
- </style>
- <template>
- <div class="statistics">
- <a-row>
- <a-col :span="24">
- <a-card :bordered="false" class="search-box">
- <time-check @getAdd="getAdd" :startValue.sync="startValue"></time-check>
- <p @click="visible = true">对比</p>
- </a-card>
- </a-col>
- </a-row>
- <a-row :gutter="16" v-if="kuaishou">
- <a-col :sm="24" :md="12" :xl="12" :xxl="6">
- <lifting
- :kuaishou.sync="kuaishou"
- :active.sync="active"
- title="总消耗"
- typeName="cost"
- typeThan="costProportion"
- ></lifting>
- </a-col>
- <a-col :sm="24" :md="12" :xl="12" :xxl="6">
- <lifting
- :kuaishou.sync="kuaishou"
- :active.sync="active"
- title="封面点击数"
- typeName="photoClick"
- typeThan="photoClickProportion"
- ></lifting>
- </a-col>
- <a-col :sm="24" :md="12" :xl="12" :xxl="6">
- <lifting
- :kuaishou.sync="kuaishou"
- :active.sync="active"
- title="封面曝光数"
- typeName="photoShow"
- typeThan="showProportion"
- ></lifting>
- </a-col>
- <a-col :sm="24" :md="12" :xl="12" :xxl="6">
- <lifting
- :kuaishou.sync="kuaishou"
- :active.sync="active"
- title="素材曝光数"
- typeName="aclick"
- typeThan="aClickProportion"
- ></lifting>
- </a-col>
- </a-row>
- <a-row :gutter="10">
- <a-col :span="24">
- <a-card
- style="width:100%"
- :tabList="tabListNoTitle"
- :activeTabKey="noTitleKey"
- @tabChange="key => onTabChange(key, 'noTitleKey')"
- >
- <div id="chart" style="width:100%;height:500px"></div>
- </a-card>
- </a-col>
- </a-row>
- <a-modal title="数据对比" v-model="visible" width="80%" class="yincang">
- <a-radio-group v-model="value" style="margin-bottom:10px" @change="clear">
- <a-radio-button value="month">对比月</a-radio-button>
- <a-radio-button value="day">对比天</a-radio-button>
- </a-radio-group>
- <br />
- <div style="display:flex">
- <div v-if="value == 'month'" style="width:400px">
- <a-month-picker placeholder="请选择对比月份" v-model="oneMonth" style="width:50%" />
- <a-month-picker placeholder="请选择对比月份" v-model="twoMonth" style="width:50%" />
- </div>
- <a-range-picker
- v-else
- style="width:400px"
- :disabledDate="disabledDate"
- :showTime="{
- hideDisabledOptions: true
- }"
- format="YYYY-MM-DD"
- v-model="contrastValue"
- />
- <a-button type="primary" style="margin-left:5px" @click="search">查询</a-button>
- </div>
- <a-row :gutter="15" style="margin-bottom:15px;margin-top:15px" v-if="contrastDataAll">
- <a-col :span="6">
- <a-card title="总消耗对比">
- <p>{{ contrastDataAll.beCompared.statDate }}:{{ contrastDataAll.beCompared.cost }}</p>
- <p>
- {{ contrastDataAll.compared.statDate }}:{{ contrastDataAll.compared.cost }}
- <a-icon
- v-if="contrastDataAll.compared.costProportion > 0"
- type="rise"
- class="styleElse"
- style="color:red;"
- />
- <a-icon
- v-else-if="contrastDataAll.compared.costProportion < 0"
- type="fall"
- class="styleElse"
- style="color:#0bcd74;"
- />
- <a-icon
- v-else-if="contrastDataAll.compared.costProportion == 0"
- type="minus"
- class="styleElse"
- style="color:#0bcd74"
- />
- <span
- :style="contrastDataAll.compared.costProportion > 0 ? 'color:red' : 'color:#0bcd74'"
- class="styleElse"
- style=" margin-left:0"
- >{{ Math.abs(contrastDataAll.compared.costProportion).toFixed(2) + '%' }}</span
- >
- </p>
- </a-card>
- </a-col>
- <a-col :span="6">
- <a-card title="封面点击数对比">
- <p>{{ contrastDataAll.beCompared.statDate }}:{{ contrastDataAll.beCompared.photoClick }}</p>
- <p>
- {{ contrastDataAll.compared.statDate }}:{{ contrastDataAll.compared.photoClick }}
- <a-icon
- v-if="contrastDataAll.compared.photoClickProportion > 0"
- type="rise"
- class="styleElse"
- style="color:red;"
- />
- <a-icon
- v-else-if="contrastDataAll.compared.photoClickProportion < 0"
- type="fall"
- class="styleElse"
- style="color:#0bcd74;"
- />
- <a-icon
- v-else-if="contrastDataAll.compared.photoClickProportion == 0"
- type="minus"
- class="styleElse"
- style="color:#0bcd74"
- />
- <span
- :style="contrastDataAll.compared.photoClickProportion > 0 ? 'color:red' : 'color:#0bcd74'"
- class="styleElse"
- style=" margin-left:0"
- >{{ Math.abs(contrastDataAll.compared.photoClickProportion).toFixed(2) + '%' }}</span
- >
- </p>
- </a-card>
- </a-col>
- <a-col :span="6">
- <a-card title="封面曝光数对比">
- <p>{{ contrastDataAll.beCompared.statDate }}:{{ contrastDataAll.beCompared.photoShow }}</p>
- <p>
- {{ contrastDataAll.compared.statDate }}:{{ contrastDataAll.compared.photoShow }}
- <a-icon
- v-if="contrastDataAll.compared.showProportion > 0"
- type="rise"
- class="styleElse"
- style="color:red;"
- />
- <a-icon
- v-else-if="contrastDataAll.compared.showProportion < 0"
- type="fall"
- class="styleElse"
- style="color:#0bcd74;"
- />
- <a-icon
- v-else-if="contrastDataAll.compared.showProportion == 0"
- type="minus"
- class="styleElse"
- style="color:#0bcd74"
- />
- <span
- :style="contrastDataAll.compared.showProportion > 0 ? 'color:red' : 'color:#0bcd74'"
- class="styleElse"
- style=" margin-left:0"
- >{{ Math.abs(contrastDataAll.compared.showProportion).toFixed(2) + '%' }}</span
- >
- </p>
- </a-card>
- </a-col>
- <a-col :span="6">
- <a-card title="素材曝光数对比">
- <p>{{ contrastDataAll.beCompared.statDate }}:{{ contrastDataAll.beCompared.aclick }}</p>
- <p>
- {{ contrastDataAll.compared.statDate }}:{{ contrastDataAll.compared.aclick }}
- <a-icon
- v-if="contrastDataAll.compared.comparedAclick > 0"
- type="rise"
- class="styleElse"
- style="color:red;"
- />
- <a-icon
- v-else-if="contrastDataAll.compared.comparedAclick < 0"
- type="fall"
- class="styleElse"
- style="color:#0bcd74;"
- />
- <a-icon
- v-else-if="contrastDataAll.compared.comparedAclick == 0"
- type="minus"
- class="styleElse"
- style="color:#0bcd74"
- />
- <span
- :style="contrastDataAll.compared.comparedAclick > 0 ? 'color:red' : 'color:#0bcd74'"
- class="styleElse"
- style=" margin-left:0"
- >{{ Math.abs(contrastDataAll.compared.comparedAclick).toFixed(2) + '%' }}</span
- >
- </p>
- </a-card>
- </a-col>
- </a-row>
- <a-row v-else>
- <a-col :span="24" style="text-align:center;height:186px;line-height:186px">暂无数据</a-col>
- </a-row>
- <a-row :gutter="10">
- <a-col :span="24">
- <a-card
- style="width:100%"
- :tabList="tabListNoTitle"
- :activeTabKey="noTitleKeyTwo"
- @tabChange="key => onTabChange(key, 'noTitleKeyTwo')"
- >
- <div id="chart1" style="width:100%;height:500px"></div>
- </a-card>
- </a-col>
- </a-row>
- <a-row style="margin-bottom:15px;margin-top:15px" v-if="dataTableTwo.length > 0">
- <a-col :span="24">
- <a-card
- :tabList="tableCard"
- :activeTabKey="noTitleKeyTableTwo"
- @tabChange="key => onTabChange(key, 'noTitleKeyTableTwo')"
- >
- <a-table :columns="columnsDb" :dataSource="dataTableTwo" :pagination="false" bordered></a-table>
- </a-card>
- </a-col>
- </a-row>
- </a-modal>
- <a-row style="margin-bottom:15px;margin-top:15px">
- <a-col :span="24">
- <a-card
- :tabList="tableNowCard"
- :activeTabKey="noTitleKeyTable"
- @tabChange="key => onTabChange(key, 'noTitleKeyTable')"
- >
- <a-table :columns="columns" :dataSource="dataTable" :pagination="false" :loading="loading" bordered></a-table>
- </a-card>
- </a-col>
- </a-row>
- </div>
- </template>
- <script>
- import ARow from 'ant-design-vue/es/grid/Row'
- import ACol from 'ant-design-vue/es/grid/Col'
- import moment from 'moment'
- import countTo from 'vue-count-to'
- import lifting from './components/lifting'
- import { getKsAccountReport, getKsDetail, getReportList } from '@api/video.js'
- import { getAction, postAction } from '@/api/manage'
- import timeCheck from './components/timeCheck'
- var upDate
- // 引入基本模板
- let echarts = require('echarts/lib/echarts')
- // 引入柱状图组件
- require('echarts/lib/chart/bar')
- require('echarts/lib/chart/pie')
- require('echarts/lib/chart/line')
- // 引入提示框和title组件
- require('echarts/lib/component/tooltip')
- require('echarts/lib/component/title')
- require('echarts/lib/component/graphic')
- require('echarts/lib/component/toolbox')
- require('echarts/lib/component/legend')
- export default {
- name: 'statistics',
- components: {
- ACol,
- ARow,
- countTo,
- lifting,
- timeCheck
- },
- data: function() {
- return {
- loading: true,
- columns: [
- { title: '时间', dataIndex: 'statDate', align: 'center' },
- {
- title: '总消耗环比',
- dataIndex: 'yesCost',
- scopedSlots: { customRender: 'yesCost' },
- align: 'center'
- },
- { title: '总消耗', dataIndex: 'cost', align: 'center' },
- {
- title: '封面点击数环比',
- dataIndex: 'yesPhotoClick',
- scopedSlots: { customRender: 'photoClickProportion' },
- align: 'center'
- },
- { title: '封面点击数', dataIndex: 'photoClick', align: 'center' },
- {
- title: '封面曝光数环比',
- dataIndex: 'yesPhotoShow',
- scopedSlots: { customRender: 'photoShowProportion' },
- align: 'center'
- },
- { title: '封面曝光数', dataIndex: 'photoShow', align: 'center' },
- {
- title: '素材曝光数环比',
- dataIndex: 'yesAclick',
- scopedSlots: { customRender: 'aclickProportion' },
- align: 'center'
- },
- { title: '素材曝光数', dataIndex: 'aclick', align: 'center' }
- ],
- columnsDb: [
- { title: '时间', dataIndex: 'statDate', align: 'center' },
- { title: '总消耗', dataIndex: 'cost', align: 'center' },
- { title: '封面点击数', dataIndex: 'photoClick', align: 'center' },
- { title: '封面曝光数', dataIndex: 'photoShow', align: 'center' },
- { title: '素材曝光数', dataIndex: 'aclick', align: 'center' }
- ],
- dataTable: [],
- dataTableTwo: [],
- dataAllTableTwo: null,
- dataAllTable: null,
- dataAllTableYester: null,
- title: '快手大盘',
- visible: false,
- statistics: [],
- showData: null,
- startValue: [],
- contrastValue: [],
- contrastDataAll: null,
- allValue: ['', ''],
- value: 'month',
- oneMonth: null,
- twoMonth: null,
- kuaishou: {
- aclick: 0,
- aClickProportion: 0,
- cost: 0,
- costProportion: 0,
- photoClick: 0,
- photoClickroportion: 0,
- photoShow: 0,
- showProportion: 0
- },
- tabListNoTitle: [
- {
- key: 'cost',
- tab: '总消耗'
- },
- {
- key: 'photoClick',
- tab: '封面点击数'
- },
- {
- key: 'photoShow',
- tab: '封面曝光数'
- },
- {
- key: 'aclick',
- tab: '素材曝光数'
- }
- ],
- tableCard: [
- {
- key: 'small',
- tab: '前'
- },
- {
- key: 'big',
- tab: '后'
- }
- ],
- tableNowCard: [
- {
- key: 'now',
- tab: '今天'
- },
- {
- key: 'yesterday',
- tab: '昨天'
- }
- ],
- noTitleKeyTableTwo: 'small',
- noTitleKey: 'cost',
- noTitleKeyTwo: 'cost',
- noTitleKeyTable: 'now',
- chart: null,
- chart1: null,
- active: 1,
- duration: 1000,
- dataDetail: null,
- contrastDataList: []
- }
- },
- methods: {
- a(item) {
- console.log(item)
- },
- moment,
- clear() {
- this.twoMonth = null
- this.oneMonth = null
- this.contrastDataAll = null
- this.contrastDataList = null
- this.contrastValue = []
- this.dataTableTwo = []
- this.dataAllTableTwo = null
- if (this.chart) {
- this.chart.clear()
- }
- },
- search() {
- var params = {}
- params.type = 10
- params.sign = this.value
- if (this.value == 'month') {
- if (this.twoMonth && this.oneMonth) {
- params.bigDate = moment(this.twoMonth._d).format('YYYY-MM')
- params.smallDate = moment(this.oneMonth._d).format('YYYY-MM')
- } else {
- this.$message.error('请选择两个需要对比的数据')
- }
- } else if (this.value == 'day') {
- params.smallDate = moment(this.contrastValue[0]._d).format('YYYY-MM-DD')
- params.bigDate = moment(this.contrastValue[1]._d).format('YYYY-MM-DD')
- }
- this.columnsDb = [
- { title: '时间', dataIndex: 'statDate', align: 'center' },
- { title: '总消耗', dataIndex: 'cost', align: 'center' },
- { title: '封面点击数', dataIndex: 'photoClick', align: 'center' },
- { title: '封面曝光数', dataIndex: 'photoShow', align: 'center' },
- { title: '素材曝光数', dataIndex: 'aclick', align: 'center' }
- ]
- getKsAccountReport(params).then(res => {
- if (res.success) {
- if (res.result.compared) {
- this.contrastDataAll = res.result
- // this.drawPieAll(res)
- } else {
- this.contrastDataAll = null
- }
- }
- })
- getKsDetail(params).then(res => {
- this.contrastDataList = res.result
- this.drawSearchLine(this.noTitleKeyTwo, res.result)
- })
- getReportList(params).then(res => {
- if (res.success) {
- this.tableCard = [
- {
- key: 'small',
- tab: res.result[0].beStatDate
- },
- {
- key: 'big',
- tab: res.result[0].statDate
- }
- ]
- this.noTitleKeyTableTwo = 'small'
- if (this.value == 'day') {
- this.dataAllTableTwo = res.result[0]
- this.dataTableTwo = res.result[0].beComparedDetail.map((item, index) => {
- return {
- ...item,
- statDate: item.statDate + ' ' + item.statHour + '时',
- key: index
- }
- })
- } else {
- this.dataAllTableTwo = res.result[0]
- this.dataTableTwo = res.result[0].beComparedDetail.map((item, index) => {
- return {
- ...item,
- key: index
- }
- })
- }
- }
- })
- },
- getReportList(checked, dateValue) {
- let params = {}
- params.type = checked
- if (this.active == 9) {
- params.startDate = dateValue[0]
- params.endDate = dateValue[1]
- }
- // proportion
- this.loading = true
- if (this.active == 1) {
- getReportList(params).then(res => {
- if (res.result[0].now.length > 0) {
- for (let i = 0; i < res.result[0].now.length; i++) {
- for (let j = 0; j < res.result[0].yesterday.length; j++) {
- if (res.result[0].now[i].statHour == res.result[0].yesterday[j].statHour) {
- res.result[0].now[i].yesCost =
- (((res.result[0].now[i].cost - res.result[0].yesterday[j].cost) / res.result[0].yesterday[j].cost) * 100).toFixed(2) +
- '%'
- res.result[0].now[i].yesPhotoClick =
- (
- ((res.result[0].now[i].photoClick - res.result[0].yesterday[j].photoClick) / res.result[0].yesterday[j].photoClick) *
- 100
- ).toFixed(2) + '%'
- res.result[0].now[i].yesPhotoShow =
- (
- ((res.result[0].now[i].photoShow - res.result[0].yesterday[j].photoShow) / res.result[0].yesterday[j].photoShow) *
- 100
- ).toFixed(2) + '%'
- res.result[0].now[i].yesAclick =
- (((res.result[0].now[i].aclick - res.result[0].yesterday[j].aclick) / res.result[0].yesterday[j].aclick) * 100).toFixed(
- 2
- ) + '%'
- }
- }
- }
- this.dataTable = res.result[0].now.map((item, index) => {
- return {
- key: index,
- ...item,
- statDate:
- this.active == 1 || this.active == 2 ? item.statDate + ' ' + item.statHour + '时' : item.statDate
- }
- })
- this.dataAllTableYester = res.result[0].yesterday.map((item, index) => {
- return {
- key: index,
- ...item,
- statDate:
- this.active == 1 || this.active == 2 ? item.statDate + ' ' + item.statHour + '时' : item.statDate
- }
- })
- this.dataAllTable = this.dataTable
- this.loading = false
- } else {
- this.dataAllTable = null
- this.dataTable = []
- this.dataAllTableYester = res.result[0].yesterday
- this.loading = false
- }
- })
- } else {
- getReportList(params).then(res => {
- this.dataTable = res.result.map((item, index) => {
- return {
- key: index,
- ...item,
- statDate:
- this.active == 1 || this.active == 2 ? item.statDate + ' ' + item.statHour + '时' : item.statDate
- }
- })
- this.loading = false
- })
- }
- },
- drawPieAll(data) {
- var colorList = ['#afa3f5', '#00d488', '#3feed4', '#3bafff', '#f1bb4c', 'rgba(250,250,250,0.5)']
- var option = {
- tooltip: {
- trigger: 'item',
- formatter: '{a} <br/>{b} : {c}'
- },
- series: [
- {
- name: '总消耗对比',
- type: 'pie',
- radius: '35%',
- center: ['50%', '50%'],
- data: [
- { value: 944332, name: '2019-09' },
- { value: 6839241.89, name: '2019-10' }
- ],
- itemStyle: {
- normal: {
- color: function(params) {
- return colorList[params.dataIndex]
- }
- }
- }
- }
- ]
- }
- var chart = echarts.init(document.getElementById('chart3'))
- chart.clear()
- chart.setOption(option, true)
- },
- drawSearchLine(type, data) {
- var dataLegend = []
- var dataLength = [] //小月份数据
- var dataLengthBig = [] //大月份数据
- var dataElse = []
- var dataDate = []
- var that = this
- var showName = null
- if (data) {
- if (this.value == 'month') {
- dataLegend = [moment(this.oneMonth._d).format('YYYY-MM'), moment(this.twoMonth._d).format('YYYY-MM')]
- dataDate = data.map(item => {
- return item.statDate.substring(item.statDate.length - 2, item.statDate.length)
- })
- } else if (this.value == 'day') {
- dataLegend = [
- moment(this.contrastValue[0]._d).format('YYYY-MM-DD'),
- moment(this.contrastValue[1]._d).format('YYYY-MM-DD')
- ]
- dataDate = data.map(item => {
- return item.statHour
- })
- }
- if (type == 'cost') {
- showName = '总消耗'
- dataLength = data.map(item => {
- return item.beComparedCost
- })
- dataLengthBig = data.map(item => {
- return item.cost
- })
- dataElse = data.map(item => {
- if (this.value == 'month') {
- return { proportion: (item.costProportion * 100).toFixed(2) + '%', statHour: item.beComparedDate }
- } else {
- return { proportion: (item.costProportion * 100).toFixed(2) + '%', statHour: item.statHour }
- }
- })
- } else if (type == 'photoClick') {
- showName = '封面点击数'
- dataLength = data.map(item => {
- return item.beComparedPhotoClick
- })
- dataLengthBig = data.map(item => {
- return item.photoClick
- })
- dataElse = data.map(item => {
- if (this.value == 'month') {
- return { proportion: (item.photoClickProportion * 100).toFixed(2) + '%', statHour: item.beComparedDate }
- } else {
- return { proportion: (item.photoClickProportion * 100).toFixed(2) + '%', statHour: item.statHour }
- }
- })
- } else if (type == 'photoShow') {
- showName = '封面曝光数'
- dataLength = data.map(item => {
- return item.beComparedPhotoShow
- })
- dataLengthBig = data.map(item => {
- return item.photoShow
- })
- dataElse = data.map(item => {
- if (this.value == 'month') {
- return { proportion: (item.showProportion * 100).toFixed(2) + '%', statHour: item.beComparedDate }
- } else {
- return { proportion: (item.showProportion * 100).toFixed(2) + '%', statHour: item.statHour }
- }
- })
- } else if (type == 'aclick') {
- showName = '素材曝光数'
- dataLength = data.map(item => {
- return item.beComparedAClick
- })
- dataLengthBig = data.map(item => {
- return item.aClick
- })
- dataElse = data.map(item => {
- if (this.value == 'month') {
- return { proportion: (item.comparedAclick * 100).toFixed(2) + '%', statHour: item.beComparedDate }
- } else {
- return { proportion: (item.comparedAclick * 100).toFixed(2) + '%', statHour: item.statHour }
- }
- })
- }
- }
- var option = {
- backgroundColor: '#fff',
- tooltip: {
- trigger: 'axis',
- formatter: function(params) {
- var index
- if (that.value == 'month') {
- index = dataElse.findIndex(
- v => v.statHour.substring(v.statHour.length - 2, v.statHour.length) == params[0].name
- )
- } else {
- index = dataElse.findIndex(
- v => v.statHour.substring(v.statHour.length - 2, v.statHour.length) == params[0].name
- )
- }
- var da = null
- if (index >= 0) {
- da = dataElse[index].proportion
- }
- if (that.value == 'month') {
- return `${params[0].marker}时间:${params[0].seriesName}-${params[0].name}:${showName}:${params[0].data} <br/>
- ${params[1].marker}时间:${params[1].seriesName}-${params[0].name}:${showName}:${params[1].data} <br/>
- 环比:${da}<br/> `
- } else {
- return `${params[0].marker}时间:${params[0].seriesName}:${showName}:${params[0].data} <br/>
- ${params[1].marker}时间:${params[1].seriesName}:${showName}:${params[1].data} <br/>
- 环比:${da}<br/> `
- }
- }
- },
- legend: {
- data: dataLegend
- },
- grid: {
- left: '2%',
- right: '2%',
- bottom: '2%',
- containLabel: true
- },
- xAxis: {
- type: 'category',
- data: dataDate,
- boundaryGap: false,
- // 坐标轴线
- axisLine: {
- show: false,
- lineStyle: {
- color: '#999'
- }
- },
- // 分割线
- splitLine: {
- show: true,
- lineStyle: {
- type: 'dashed',
- color: '#e5e5e5'
- }
- }
- },
- yAxis: {
- type: 'value',
- axisLine: {
- show: false,
- lineStyle: {
- color: '#999'
- }
- },
- splitLine: {
- lineStyle: {
- type: 'dashed',
- color: '#e5e5e5'
- }
- }
- },
- series: [
- {
- name: dataLegend[0],
- type: 'line',
- color: '#0bcd74',
- smooth: true,
- symbol: 'circle',
- symbolSize: 1,
- lineStyle: {
- normal: {
- width: 2,
- color: '#0bcd74'
- }
- },
- itemStyle: {
- borderColor: '#ffffff',
- borderWidth: 3
- },
- data: dataLength
- },
- {
- name: dataLegend[1],
- type: 'line',
- color: '#9933ff',
- smooth: true,
- symbol: 'circle',
- symbolSize: 1,
- lineStyle: {
- normal: {
- width: 2,
- color: '#9933ff'
- }
- },
- itemStyle: {
- borderColor: '#ffffff',
- borderWidth: 3
- },
- data: dataLengthBig
- }
- ]
- }
- this.chart = echarts.init(document.getElementById('chart1'))
- this.chart.clear()
- this.chart.setOption(option, true)
- // window.onresize = function() {
- // chart.resize()
- // }
- },
- disabledDate(current) {
- // Can not select days before today and today
- return current && current > moment().endOf('day')
- },
- onTabChange(key, type) {
- console.log(key, type)
- this[type] = key
- if (type == 'noTitleKey') {
- this.drawPie(key, this.dataDetail)
- } else if (type == 'noTitleKeyTable') {
- this.dataTable = []
- if (key == 'now') {
- this.columns = [
- { title: '时间', dataIndex: 'statDate', align: 'center' },
- {
- title: '总消耗环比',
- dataIndex: 'yesCost',
- scopedSlots: { customRender: 'yesCost' },
- align: 'center'
- },
- { title: '总消耗', dataIndex: 'cost', align: 'center' },
- {
- title: '封面点击数环比',
- dataIndex: 'yesPhotoClick',
- scopedSlots: { customRender: 'photoClickProportion' },
- align: 'center'
- },
- { title: '封面点击数', dataIndex: 'photoClick', align: 'center' },
- {
- title: '封面曝光数环比',
- dataIndex: 'yesPhotoShow',
- scopedSlots: { customRender: 'photoShowProportion' },
- align: 'center'
- },
- { title: '封面曝光数', dataIndex: 'photoShow', align: 'center' },
- {
- title: '素材曝光数环比',
- dataIndex: 'yesAclick',
- scopedSlots: { customRender: 'aclickProportion' },
- align: 'center'
- },
- { title: '素材曝光数', dataIndex: 'aclick', align: 'center' }
- ]
- this.dataTable = this.dataAllTable
- } else {
- this.columns = [
- { title: '时间', dataIndex: 'statDate', align: 'center' },
- { title: '总消耗', dataIndex: 'cost', align: 'center' },
- { title: '封面点击数', dataIndex: 'photoClick', align: 'center' },
- { title: '封面曝光数', dataIndex: 'photoShow', align: 'center' },
- { title: '素材曝光数', dataIndex: 'aclick', align: 'center' }
- ]
- this.dataTable = this.dataAllTableYester.map((item, index) => {
- return {
- key: index,
- ...item,
- statDate: item.statDate
- }
- })
- }
- } else if (type == 'noTitleKeyTableTwo') {
- this.dataTableTwo = []
- if (key == 'small') {
- this.columnsDb = [
- { title: '时间', dataIndex: 'statDate', align: 'center' },
- { title: '总消耗', dataIndex: 'cost', align: 'center' },
- { title: '封面点击数', dataIndex: 'photoClick', align: 'center' },
- { title: '封面曝光数', dataIndex: 'photoShow', align: 'center' },
- { title: '素材曝光数', dataIndex: 'aclick', align: 'center' }
- ]
- if (this.value == 'day') {
- this.dataTableTwo = this.dataAllTableTwo.beComparedDetail.map((item, index) => {
- return {
- key: index,
- ...item,
- statDate: item.statDate + ' ' + item.statHour + '时'
- }
- })
- } else {
- this.dataTableTwo = this.dataAllTableTwo.beComparedDetail.map((item, index) => {
- return {
- key: index,
- ...item
- }
- })
- }
- } else {
- this.columnsDb = [
- { title: '时间', dataIndex: 'statDate', align: 'center' },
- {
- title: '总消耗环比',
- dataIndex: 'yesCost',
- scopedSlots: { customRender: 'yesCost' },
- align: 'center'
- },
- { title: '总消耗', dataIndex: 'cost', align: 'center' },
- {
- title: '封面点击数环比',
- dataIndex: 'yesPhotoClick',
- scopedSlots: { customRender: 'photoClickProportion' },
- align: 'center'
- },
- { title: '封面点击数', dataIndex: 'photoClick', align: 'center' },
- {
- title: '封面曝光数环比',
- dataIndex: 'yesPhotoShow',
- scopedSlots: { customRender: 'photoShowProportion' },
- align: 'center'
- },
- { title: '封面曝光数', dataIndex: 'photoShow', align: 'center' },
- {
- title: '素材曝光数环比',
- dataIndex: 'yesAclick',
- scopedSlots: { customRender: 'aclickProportion' },
- align: 'center'
- },
- { title: '素材曝光数', dataIndex: 'aclick', align: 'center' }
- ]
- if (this.value == 'day') {
- for (let i = 0; i < this.dataAllTableTwo.comparedDetail.length; i++) {
- this.dataTableTwo.push({
- key: i,
- statDate:
- this.dataAllTableTwo.comparedDetail[i].statDate +
- ' ' +
- this.dataAllTableTwo.comparedDetail[i].statHour +
- '时',
- yesCost:
- (
- this.dataAllTableTwo.comparedDetail[i].cost / this.dataAllTableTwo.beComparedDetail[i].cost -
- 1
- ).toFixed(2) + '%',
- cost: this.dataAllTableTwo.comparedDetail[i].cost,
- yesPhotoClick:
- (
- this.dataAllTableTwo.comparedDetail[i].photoClick /
- this.dataAllTableTwo.beComparedDetail[i].photoClick -
- 1
- ).toFixed(2) + '%',
- photoClick: this.dataAllTableTwo.comparedDetail[i].photoClick,
- yesPhotoShow:
- (
- this.dataAllTableTwo.comparedDetail[i].photoShow /
- this.dataAllTableTwo.beComparedDetail[i].photoShow -
- 1
- ).toFixed(2) + '%',
- photoShow: this.dataAllTableTwo.comparedDetail[i].photoShow,
- yesAclick:
- (
- this.dataAllTableTwo.comparedDetail[i].aclick / this.dataAllTableTwo.beComparedDetail[i].aclick -
- 1
- ).toFixed(2) + '%',
- aclick: this.dataAllTableTwo.comparedDetail[i].aclick
- })
- }
- // this.dataTableTwo = this.dataAllTableTwo.comparedDetail.map(item => {
- // return {
- // ...item,
- // statDate: item.statDate + ' ' + item.statHour + '时'
- // }
- // })
- } else {
- this.dataTableTwo = []
- for (let i = 0; i < this.dataAllTableTwo.comparedDetail.length; i++) {
- this.dataTableTwo.push({
- key: i,
- statDate: this.dataAllTableTwo.comparedDetail[i].statDate,
- yesCost:
- (
- this.dataAllTableTwo.comparedDetail[i].cost / this.dataAllTableTwo.beComparedDetail[i].cost -
- 1
- ).toFixed(2) + '%',
- cost: this.dataAllTableTwo.comparedDetail[i].cost,
- yesPhotoClick:
- (
- this.dataAllTableTwo.comparedDetail[i].photoClick /
- this.dataAllTableTwo.beComparedDetail[i].photoClick -
- 1
- ).toFixed(2) + '%',
- photoClick: this.dataAllTableTwo.comparedDetail[i].photoClick,
- yesPhotoShow:
- (
- this.dataAllTableTwo.comparedDetail[i].photoShow /
- this.dataAllTableTwo.beComparedDetail[i].photoShow -
- 1
- ).toFixed(2) + '%',
- photoShow: this.dataAllTableTwo.comparedDetail[i].photoShow,
- yesAclick:
- (
- this.dataAllTableTwo.comparedDetail[i].aclick / this.dataAllTableTwo.beComparedDetail[i].aclick -
- 1
- ).toFixed(2) + '%',
- aclick: this.dataAllTableTwo.comparedDetail[i].aclick
- })
- }
- console.log(this.dataTableTwo)
- }
- }
- } else {
- this.drawSearchLine(key, this.contrastDataList)
- }
- },
- getAdd(checked) {
- if (checked == 9) {
- if (this.startValue.length > 0 && this.startValue[0]) {
- this.allValue[1] = moment(this.startValue[0]._d).format('YYYY-MM-DD')
- this.allValue[0] = moment(this.startValue[1]._d).format('YYYY-MM-DD')
- }
- } else {
- this.startValue = []
- this.allValue = []
- }
- this.active = checked
- var arr = [
- {
- key: 'now',
- tab: '今天'
- },
- {
- key: 'yesterday',
- tab: '昨天'
- }
- ]
- if (checked == 1) {
- this.columns = [
- { title: '时间', dataIndex: 'statDate', align: 'center' },
- {
- title: '总消耗环比',
- dataIndex: 'yesCost',
- scopedSlots: { customRender: 'yesCost' },
- align: 'center'
- },
- { title: '总消耗', dataIndex: 'cost', align: 'center' },
- {
- title: '封面点击数环比',
- dataIndex: 'yesPhotoClick',
- scopedSlots: { customRender: 'photoClickProportion' },
- align: 'center'
- },
- { title: '封面点击数', dataIndex: 'photoClick', align: 'center' },
- {
- title: '封面曝光数环比',
- dataIndex: 'yesPhotoShow',
- scopedSlots: { customRender: 'photoShowProportion' },
- align: 'center'
- },
- { title: '封面曝光数', dataIndex: 'photoShow', align: 'center' },
- {
- title: '素材曝光数环比',
- dataIndex: 'yesAclick',
- scopedSlots: { customRender: 'aclickProportion' },
- align: 'center'
- },
- { title: '素材曝光数', dataIndex: 'aclick', align: 'center' }
- ]
- } else {
- this.columns = [
- { title: '时间', dataIndex: 'statDate', align: 'center' },
- { title: '总消耗', dataIndex: 'cost', align: 'center' },
- { title: '封面点击数', dataIndex: 'photoClick', align: 'center' },
- { title: '封面曝光数', dataIndex: 'photoShow', align: 'center' },
- { title: '素材曝光数', dataIndex: 'aclick', align: 'center' }
- ]
- }
- switch (checked) {
- case 1:
- arr = [
- {
- key: 'now',
- tab: '今天'
- },
- {
- key: 'yesterday',
- tab: '昨天'
- }
- ]
- break
- case 2:
- arr = [
- {
- key: 'yesterday',
- tab: '昨天'
- }
- ]
- break
- case 3:
- arr = [
- {
- key: 'yesterday',
- tab: '近一周'
- }
- ]
- break
- case 4:
- arr = [
- {
- key: 'yesterday',
- tab: '近十五天'
- }
- ]
- break
- case 5:
- arr = [
- {
- key: 'yesterday',
- tab: '近一月'
- }
- ]
- break
- case 6:
- arr = [
- {
- key: 'yesterday',
- tab: '近三月'
- }
- ]
- break
- case 7:
- arr = [
- {
- key: 'yesterday',
- tab: '近半年'
- }
- ]
- break
- case 8:
- arr = [
- {
- key: 'yesterday',
- tab: '所有'
- }
- ]
- break
- case 9:
- arr = [
- {
- key: 'yesterday',
- tab: this.allValue[1] + ' ~ ' + this.allValue[0]
- }
- ]
- break
- }
- this.tableNowCard = arr
- this.getReportList(checked, this.allValue)
- this.drawLine(checked, this.allValue)
- this.getKsDetail(checked, this.allValue).then(res => {
- this.drawPie(this.noTitleKey, res.result)
- })
- },
- getKsDetail(type, dateValue) {
- var that = this
- return new Promise(function(resolve) {
- let params = {}
- params.type = type
- if (that.active == 9) {
- params.startDate = dateValue[0]
- params.endDate = dateValue[1]
- }
- getKsDetail(params).then(res => {
- that.dataDetail = res.result
- resolve(res)
- })
- })
- },
- drawLine(type, dateValue) {
- var that = this
- return new Promise(function(resolve) {
- let params = {}
- params.type = type
- if (that.active == 9) {
- params.startDate = dateValue[0]
- params.endDate = dateValue[1]
- }
- getKsAccountReport(params).then(res => {
- var dataNew = []
- var dataX = []
- if (res.success) {
- that.kuaishou = res.result
- // this.drawPieAll(res)
- } else {
- that.kuaishou.aclick = 0
- that.kuaishou.cost = 0
- that.kuaishou.photoClick = 0
- that.kuaishou.photoShow = 0
- }
- resolve()
- })
- })
- },
- drawPie(type, data) {
- var dataLegend = []
- var dataLength = []
- var dataElse = []
- var dataDate = []
- var that = this
- if (this.active == 1 || this.active == 2) {
- // data.sort(function(a, b) {
- // return a.statHour - b.statHour
- // })
- dataDate = data.map(item => {
- return item.statHour
- })
- } else {
- // data.sort(function(a, b) {
- // return a.statDate - b.statDate
- // })
- dataDate = data.map(item => {
- return item.statDate
- })
- }
- if (type == 'cost') {
- dataLegend = ['总消耗']
- dataElse = data.map(item => {
- if (item.now) {
- return { proportion: (item.now.costProportion * 100).toFixed(2) + '%', statHour: item.statHour }
- } else {
- return { proportion: 0, statHour: item.statHour }
- }
- })
- } else if (type == 'photoClick') {
- dataLegend = ['封面点击数']
- dataElse = data.map(item => {
- if (item.now) {
- return { proportion: (item.now.photoClickProportion * 100).toFixed(2) + '%', statHour: item.statHour }
- } else {
- return { proportion: 0, statHour: item.statHour }
- }
- })
- } else if (type == 'photoShow') {
- dataLegend = ['封面曝光数']
- dataElse = data.map(item => {
- if (item.now) {
- return { proportion: (item.now.showProportion * 100).toFixed(2) + '%', statHour: item.statHour }
- } else {
- return { proportion: 0, statHour: item.statHour }
- }
- })
- } else if (type == 'aclick') {
- dataLegend = ['素材曝光数']
- dataElse = data.map(item => {
- if (item.now) {
- return { proportion: (item.now.aClickProportion * 100).toFixed(2) + '%', statHour: item.statHour }
- } else {
- return { proportion: 0, statHour: item.statHour }
- }
- })
- }
- dataLength = data.map(item => {
- return item[type]
- })
- var series
- if (this.active == 1) {
- dataLegend = ['今天', '昨天']
- series = [
- {
- name: dataLegend[0],
- type: 'line',
- color: '#9933ff',
- smooth: true,
- symbol: 'circle',
- symbolSize: 1,
- lineStyle: {
- normal: {
- width: 2,
- color: '#9933ff'
- }
- },
- itemStyle: {
- borderColor: '#ffffff',
- borderWidth: 3
- },
- data: data.map(item => {
- if (item.now) {
- return item.now[type]
- } else {
- return 0
- }
- })
- },
- {
- name: dataLegend[1],
- type: 'line',
- color: '#0bcd74',
- smooth: true,
- symbol: 'circle',
- symbolSize: 1,
- lineStyle: {
- normal: {
- width: 2,
- color: '#0bcd74'
- }
- },
- itemStyle: {
- borderColor: '#ffffff',
- borderWidth: 3
- },
- data: dataLength
- }
- ]
- } else {
- series = [
- {
- name: dataLegend[0],
- type: 'line',
- color: '#0bcd74',
- smooth: true,
- symbol: 'circle',
- symbolSize: 1,
- lineStyle: {
- normal: {
- width: 2,
- color: '#0bcd74'
- }
- },
- itemStyle: {
- borderColor: '#ffffff',
- borderWidth: 3
- },
- data: dataLength
- }
- ]
- }
- var option = {
- backgroundColor: '#fff',
- // toolbox: {
- // show: true,
- // feature: {
- // dataView: { readOnly: false }
- // }
- // },
- tooltip: {
- trigger: 'axis',
- formatter: function(params) {
- var index = dataElse.findIndex(v => v.statHour == params[0].name)
- var da = null
- if (index >= 0) {
- da = dataElse[index].proportion
- }
- if (that.active == 1) {
- if (params.length > 1) {
- return `${params[0].marker}今天${params[0].name}时:${params[0].data} <br/>
- ${params[1].marker}昨天${params[1].name}时:${params[1].data} <br/>
- 环比:${da} <br/> `
- } else {
- return `${params[0].marker}时间:${params[0].name} <br/>
- 数值:${params[0].data} `
- }
- } else {
- return `${params[0].marker}时间:${params[0].name} <br/>
- 数值:${params[0].data} `
- }
- }
- },
- legend: {
- data: dataLegend
- },
- grid: {
- left: '2%',
- right: '2%',
- bottom: '2%',
- containLabel: true
- },
- xAxis: {
- type: 'category',
- data: dataDate,
- boundaryGap: false,
- // 坐标轴线
- axisLine: {
- show: false,
- lineStyle: {
- color: '#999'
- }
- },
- // 分割线
- splitLine: {
- show: true,
- lineStyle: {
- type: 'dashed',
- color: '#e5e5e5'
- }
- }
- },
- yAxis: {
- type: 'value',
- axisLine: {
- show: false,
- lineStyle: {
- color: '#999'
- }
- },
- splitLine: {
- lineStyle: {
- type: 'dashed',
- color: '#e5e5e5'
- }
- }
- },
- series: series
- }
- var chart = echarts.init(document.getElementById('chart'))
- chart.clear()
- chart.setOption(option, true)
- window.onresize = function() {
- chart.resize()
- }
- // this.chart.on('click', param => {
- // if (param.name == '总展示') {
- // alert(123)
- // }
- // })
- }
- },
- watch: {},
- computed: {
- newDate() {
- var myDate = new Date()
- myDate.getYear() //获取当前年份(2位)
- var n = myDate.getFullYear() //获取完整的年份(4位,1970-????)
- var m = myDate.getMonth() //获取当前月份(0-11,0代表1月)
- var d = myDate.getDate() //获取当前日(1-31)
- var day = myDate.getHours()
- return day
- }
- },
- activated: function() {
- this.$nextTick(() => {
- var that = this
- that.drawLine(1)
- that.getKsDetail(1).then(res => {
- that.drawPie('cost', res.result)
- })
- that.getReportList(1, that.allValue)
- upDate = window.setInterval(() => {
- setTimeout(() => {
- that.drawLine(that.active)
- that.getKsDetail(that.active).then(res => {
- that.drawPie('cost', res.result)
- })
- that.getReportList(that.active, that.allValue)
- }, 0)
- }, 120000)
- })
- },
- deactivated() {
- window.clearTimeout(upDate)
- }
- }
- </script>
|