123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056 |
- <style lang="scss" scoped>
- .search-bar {
- display: flex;
- align-items: center;
- }
- .search-box p {
- display: inline-block;
- border: 1px solid #f2f2f2;
- border-radius: 5px;
- margin-right: 10px;
- padding: 5px 10px;
- cursor: pointer;
- }
- </style>
- <style>
- /* .data-display-statistics .ant-card-body {
- padding: 0 15px;
- } */
- .data-display-statistics .ant-col-6 {
- margin: 10px 0;
- }
- .data-display-statistics .ant-col-6 .ant-card-body {
- display: flex;
- justify-content: center;
- }
- .data-display-statistics .ant-col-6 p,
- .data-display-statistics .ant-col-6 span {
- text-align: center;
- line-height: 40px;
- font-size: 30px;
- font-weight: 600;
- color: red;
- margin: 0;
- }
- .search-box .ant-card-body {
- padding: 5px 15px;
- }
- .data-display-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="data-display-statistics">
- <a-row class="image-list-heading vm-panel">
- <div class="panel-heading">{{ title }}</div>
- <a-row type="flex" align="middle" justify="space-between" class="panel-body">
- <div class="search-bar" style="width:100%">
- <a-select
- v-model="appId"
- showSearch
- allowClear
- mode="multiple"
- placeholder="请选择账户"
- optionFilterProp="children"
- style="width: 55%"
- @focus="handleFocus"
- @blur="handleBlur"
- @change="handleChange"
- :filterOption="true"
- @search="search"
- :maxTagCount="1"
- >
- <a-select-option
- v-for="appModel in options"
- :key="appModel.id+new Date().getTime()"
- :value="appModel.accountId"
- >
- {{appModel.advertiserName}}  {{appModel.accountId}}   {{appModel.authName}}  {{appModel.operationName}}
- <!-- <div v-if="show">
- <div
- style="width:220px;text-align:right;display:inline-block"
- >{{appModel.advertiserName}}</div>
- <div
- style="width:100px;text-align:center;display:inline-block;margin-right:30px"
- >{{appModel.accountId}}</div>
- <div style="width:150px;text-align:left;display:inline-block">{{appModel.authName}}</div>
- <div
- style="width:100px;text-align:center;display:inline-block"
- >{{appModel.operationName}}</div>
- </div>-->
- </a-select-option>
- </a-select>
- <a-input-number
- :min="1"
- :max="10"
- :step="0.1"
- v-model="discount"
- placeholder="请输入折扣"
- style="width:100px"
- />
- <a-button type="primary" style="margin:10px" @click="addUser">搜索</a-button>
- </div>
- </a-row>
- <a-row>
- <a-col :span="24">
- <a-card :bordered="false" class="search-box">
- <p :style="active==1?'color:cornflowerblue;background:#f2f2f2':''" @click="getAdd(1)">今天</p>
- <p :style="active==2?'color:cornflowerblue;background:#f2f2f2':''" @click="getAdd(2)">昨天</p>
- <p
- :style="active==3?'color:cornflowerblue;background:#f2f2f2':''"
- @click="getAdd(3)"
- >近一周</p>
- <p
- :style="active==4?'color:cornflowerblue;background:#f2f2f2':''"
- @click="getAdd(4)"
- >近十五天</p>
- <p
- :style="active==5?'color:cornflowerblue;background:#f2f2f2':''"
- @click="getAdd(5)"
- >近一月</p>
- <p
- :style="active==6?'color:cornflowerblue;background:#f2f2f2':''"
- @click="getAdd(6)"
- >近三月</p>
- <p
- :style="active==7?'color:cornflowerblue;background:#f2f2f2':''"
- @click="getAdd(7)"
- >近半年</p>
- <p :style="active==8?'color:cornflowerblue;background:#f2f2f2':''" @click="getAdd(8)">所有</p>
- <a-range-picker
- style="width:400px"
- :disabledDate="disabledDate"
- :showTime="{
- hideDisabledOptions: true,
- }"
- format="YYYY-MM-DD"
- v-model="startValue"
- @ok="getAdd(9)"
- />
- </a-card>
- </a-col>
- <!-- <a-col :span="24">
- <a-card :bordered="false" class="search-box">
- <p @click="visible = true">对比</p>
- </a-card>
- </a-col>-->
- </a-row>
- </a-row>
- <a-row :gutter="16" v-if="kuaishou">
- <a-col :span="6" style="width:20%">
- <lifting
- :kuaishou.sync="kuaishou"
- :active.sync="active"
- title="总消耗"
- typeName="cost"
- typeThan="costProportion"
- ></lifting>
- </a-col>
- <a-col :span="6" style="width:20%">
- <lifting
- :kuaishou.sync="kuaishou"
- :active.sync="active"
- title="折后消耗"
- typeName="discountCost"
- typeThan="discountCostProportion"
- ></lifting>
- </a-col>
- <a-col :span="6" style="width:20%">
- <lifting
- :kuaishou.sync="kuaishou"
- :active.sync="active"
- title="封面点击数"
- typeName="photoClick"
- typeThan="photoClickProportion"
- ></lifting>
- </a-col>
- <a-col :span="6" style="width:20%">
- <lifting
- :kuaishou.sync="kuaishou"
- :active.sync="active"
- title="封面曝光数"
- typeName="photoShow"
- typeThan="showProportion"
- ></lifting>
- </a-col>
- <a-col :span="6" style="width:20%">
- <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-row :gutter="10" style="margin-top:10px">
- <a-col :span="24">
- <a-card style="width:100%;">
- <div style="display:flex;margin-bottom:15px" v-show="active==1||active==2">
- <a-select
- style="width: 120px"
- v-model="statHour"
- placeholder="请选择账户"
- @change="getElseData"
- >
- <a-select-option v-for="item of 24" :key="item-1" :value="item-1">{{item-1}}</a-select-option>
- </a-select>
- <a-button type="primary" @click="exportExcel" style="margin-left:15px">导出</a-button>
- </div>
- <a-table :columns="columns" :dataSource="data" bordered id="outTable" :pagination="false"></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 countTo from 'vue-count-to'
- import moment from 'moment'
- import { getAdvertiserList, getReportList, getStatistics } from '@api/statistics'
- import axios from 'axios'
- import lifting from './components/lifting'
- // 引入基本模板
- 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')
- var length = 0
- var active = 1
- const columns = [
- {
- title: '时间',
- dataIndex: 'date',
- align: 'center',
- customRender: function(text, record, index) {
- const obj = {
- children: text,
- attrs: {}
- }
- for (let i = 0; i < length; i++) {
- if (index == 0 && i == 0) {
- obj.attrs.rowSpan = length
- } else {
- if (index == i) {
- obj.attrs.rowSpan = 0
- }
- }
- }
- return obj
- }
- },
- {
- title: '账户Id',
- dataIndex: 'accountId',
- align: 'center',
- customRender: function(text, record, index) {
- const obj = {
- children: text,
- attrs: {}
- }
- if (active == 1) {
- for (let i = 0; i < length; i++) {
- if (index >= length - 3) {
- obj.attrs.colSpan = 2
- }
- }
- }
- return obj
- }
- },
- {
- title: '账户名称',
- dataIndex: 'accountName',
- scopedSlots: { customRender: 'cost' },
- align: 'center',
- customRender: function(text, record, index) {
- const obj = {
- children: text,
- attrs: {}
- }
- if (active == 1) {
- for (let i = 0; i < length; i++) {
- if (index >= length - 3) {
- obj.attrs.colSpan = 0
- }
- }
- }
- return obj
- }
- },
- {
- title: '消耗',
- dataIndex: 'cost',
- scopedSlots: { customRender: 'cost' },
- align: 'center'
- },
- {
- title: '折后消耗',
- dataIndex: 'costY',
- align: 'center'
- },
- {
- title: '封面展示',
- dataIndex: 'photoShow',
- align: 'center'
- },
- {
- title: '封面点击',
- dataIndex: 'photoClick',
- align: 'center'
- },
- {
- title: '素材曝光数',
- dataIndex: 'aclick',
- align: 'center'
- },
- {
- title: '封面点击率',
- dataIndex: 'photoClickRatio',
- align: 'center'
- },
- {
- title: 'cvr',
- dataIndex: 'cvr',
- align: 'center'
- },
- {
- title: 'cpm',
- dataIndex: 'cpm',
- align: 'center'
- },
- {
- title: '行为数',
- dataIndex: 'bClick',
- align: 'center'
- },
- {
- title: '转化数',
- dataIndex: 'formCount',
- align: 'center'
- },
- {
- title: '转化单价',
- dataIndex: 'formPrice',
- align: 'center'
- },
- {
- title: '单价区间',
- dataIndex: 'price',
- align: 'center',
- customRender: function(text, record, index) {
- const obj = {
- children: text,
- attrs: {}
- }
- for (let i = 0; i < length; i++) {
- if (index == 0 && i == 0) {
- obj.attrs.rowSpan = length
- } else {
- if (index == i) {
- obj.attrs.rowSpan = 0
- }
- }
- }
- return obj
- }
- }
- ]
- export default {
- name: 'data-display-statistics',
- components: {
- ACol,
- ARow,
- countTo,
- lifting
- },
- data: function() {
- return {
- title: '账户数据展示',
- show: true,
- data: [],
- columns,
- options: [],
- list: [],
- appId: [],
- statHour: null,
- keyValue: null,
- keyValueData: [],
- active: 1,
- startValue: [],
- allValue: [],
- discount: 1,
- duration: 1000,
- kuaishou: {
- aclick: 0,
- aClickProportion: 0,
- cost: 0,
- costProportion: 0,
- photoClick: 0,
- photoClickroportion: 0,
- photoShow: 0,
- showProportion: 0,
- discountCost: 0,
- discountCostProportion: 0
- },
- dataDetail: [],
- tabListNoTitle: [
- {
- key: 'cost',
- tab: '总消耗'
- },
- {
- key: 'discountCost',
- tab: '折后总消耗'
- },
- {
- key: 'photoClick',
- tab: '封面点击数'
- },
- {
- key: 'photoShow',
- tab: '封面曝光数'
- },
- {
- key: 'aclick',
- tab: '素材曝光数'
- }
- ],
- noTitleKey: 'cost'
- }
- },
- filters: {
- formatDate: function(value) {
- let date = new Date(value)
- let y = date.getFullYear()
- let MM = date.getMonth() + 1
- MM = MM < 10 ? '0' + MM : MM
- let d = date.getDate()
- d = d < 10 ? '0' + d : d
- let h = date.getHours()
- h = h < 10 ? '0' + h : h
- let m = date.getMinutes()
- m = m < 10 ? '0' + m : m
- let s = date.getSeconds()
- s = s < 10 ? '0' + s : s
- return y + '-' + MM + '-' + d + ' ' + h + ':' + m + ':' + s
- }
- },
- methods: {
- moment,
- disabledDate(current) {
- return current && current > moment().endOf('day')
- },
- handleChange(value) {
- console.log(value)
- // this.appId = value
- },
- getElseData(value) {
- this.getStatistics()
- },
- handleBlur() {
- console.log('blur')
- },
- handleFocus() {
- console.log('focus')
- if (this.appId.length > 0) {
- this.options = []
- for (let i = 0; i < this.list.length; i++) {
- for (let j = 0; j < this.appId.length; j++) {
- if (this.list[i].accountId == this.appId[j]) {
- this.options.push(this.list[i])
- }
- }
- }
- } else {
- this.options = this.list
- }
- },
- search(value) {
- // console.log(value)
- this.options = []
- if (value != '') {
- this.options = this.list.filter(item => {
- var data = item.accountId + ' ' + item.authName + ' ' + item.advertiserName + ' ' + item.operationName
- return data.toLowerCase().indexOf(value.toLowerCase()) > -1
- })
- this.options = [...this.options]
- console.log(this.options)
- } else {
- if (this.appId.length > 0) {
- this.options = []
- for (let i = 0; i < this.list.length; i++) {
- for (let j = 0; j < this.appId.length; j++) {
- if (this.list[i].accountId == this.appId[j]) {
- this.options.push(this.list[i])
- }
- }
- }
- } else {
- this.options = this.list
- }
- }
- },
- addUser() {
- var that = this
- if (this.appId.length > 0) {
- var params = {}
- params.accountIds = JSON.stringify(that.appId)
- params.type = that.active
- params.discount = that.discount
- if (that.active == 9) {
- params.startDate = this.allValue[0]
- params.endDate = this.allValue[1]
- }
- getReportList(params).then(res => {
- if (res == '') {
- that.kuaishou.aclick = 0
- that.kuaishou.cost = 0
- that.kuaishou.photoClick = 0
- that.kuaishou.photoShow = 0
- that.kuaishou.discountCost = 0
- } else {
- that.kuaishou = res.summary
- that.dataDetail = res.trend
- that.drawPie(that.noTitleKey, res.trend)
- }
- })
- that.getStatistics()
- } else {
- this.$message.error('请选择账户')
- }
- },
- getStatistics() {
- var params = {}
- params.accountIds = JSON.stringify(this.appId)
- params.type = this.active
- params.statHour = this.statHour
- params.discount = this.discount
- if (this.active == 9) {
- params.startDate = this.allValue[0]
- params.endDate = this.allValue[1]
- }
- this.data = []
- getStatistics(params).then(res => {
- console.log(res)
- this.data = res.accountDetail.map((item, index) => {
- return {
- key: index,
- ...item,
- photoClickRatio: item.photoClickRatio ? (item.photoClickRatio * 100).toFixed(2) + '%' : 0 + '%',
- cpm: item.cpm ? '¥' + item.cpm.toFixed(2) : '¥' + 0,
- cost: '¥' + item.cost.toFixed(2),
- cvr: item.cvr ? (item.cvr * 100).toFixed(2) + '%' : 0 + '%',
- costY: '¥' + (item.cost / this.discount).toFixed(2),
- formPrice: item.formPrice
- ? '¥' + (item.formPrice / this.discount).toFixed(2)
- : item.activationPrice
- ? '¥' + (item.activationPrice / this.discount).toFixed(2)
- : '¥' + 0,
- date: this.statHour ? this.getDate() + ' ' + this.statHour : this.getDate(),
- formCount: item.formCount > 0 ? item.formCount : item.activationCount
- }
- })
- var index = this.data.length
- if (this.active == 1) {
- var allNow = {
- key: index + 1,
- ...res.now,
- photoClickRatio: res.now.photoClickRatio ? (res.now.photoClickRatio * 100).toFixed(2) + '%' : 0 + '%',
- cpm: res.now.cpm ? '¥' + res.now.cpm.toFixed(2) : '¥' + 0,
- cost: '¥' + res.now.cost.toFixed(2),
- cvr: res.now.cvr ? (res.now.cvr * 100).toFixed(2) + '%' : 0 + '%',
- costY: '¥' + (res.now.cost / this.discount).toFixed(2),
- accountId: '总计',
- formPrice: res.now.formPrice
- ? '¥' + (res.now.formPrice / this.discount).toFixed(2)
- : res.now.activationPrice
- ? '¥' + (res.now.activationPrice / this.discount).toFixed(2)
- : '¥' + 0,
- formCount: res.now.formCount > 0 ? res.now.formCount : res.now.activationCount
- }
- var allYesterday = {
- key: index + 2,
- ...res.yesterday,
- photoClickRatio: res.yesterday.photoClickRatio
- ? (res.yesterday.photoClickRatio * 100).toFixed(2) + '%'
- : 0 + '%',
- cpm: res.yesterday.cpm ? '¥' + res.yesterday.cpm.toFixed(2) : '¥' + 0,
- cost: '¥' + res.yesterday.cost.toFixed(2),
- cvr: res.yesterday.cvr ? (res.yesterday.cvr * 100).toFixed(2) + '%' : 0 + '%',
- costY: '¥' + (res.yesterday.cost / this.discount).toFixed(2),
- accountId: '昨日总计',
- formPrice: res.yesterday.formPrice
- ? '¥' + (res.yesterday.formPrice / this.discount).toFixed(2)
- : res.yesterday.activationPrice
- ? '¥' + (res.yesterday.activationPrice / this.discount).toFixed(2)
- : '¥' + 0,
- formCount: res.yesterday.formCount > 0 ? res.yesterday.formCount : res.yesterday.activationCount
- }
- var chainRatio = {
- key: index + 3,
- cost: (res.chainRatio.costProportion * 100).toFixed(2) + '%',
- photoShow: (res.chainRatio.showProportion * 100).toFixed(2) + '%',
- photoClick: (res.chainRatio.photoClickProportion * 100).toFixed(2) + '%',
- aclick: (res.chainRatio.aClickProportion * 100).toFixed(2) + '%',
- photoClickRatio: res.chainRatio.photoClickRatioProportion
- ? (res.chainRatio.photoClickRatioProportion * 100).toFixed(2) + '%'
- : 0 + '%',
- cvr: (res.chainRatio.cvrProportion * 100).toFixed(2) + '%',
- cpm: (res.chainRatio.cpmProportion * 100).toFixed(2) + '%',
- bClick: (res.chainRatio.bClickProportion * 100).toFixed(2) + '%',
- formCount: res.chainRatio.formCountProportion
- ? (res.chainRatio.formCountProportion * 100).toFixed(2) + '%'
- : res.chainRatio.activationCountProportion
- ? (res.chainRatio.activationCountProportion * 100).toFixed(2) + '%'
- : 0 + '%',
- formPrice: res.chainRatio.formPriceProportion
- ? (res.chainRatio.formPriceProportion * 100).toFixed(2) + '%'
- : res.chainRatio.activationPriceProportion
- ? (res.chainRatio.activationPriceProportion * 100).toFixed(2) + '%'
- : 0 + '%',
- costY: (res.chainRatio.costProportion * 100).toFixed(2) + '%',
- accountId: '环比'
- }
- this.data.push(allNow)
- this.data.push(allYesterday)
- this.data.push(chainRatio)
- }
- length = this.data.length
- })
- },
- 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
- active = checked
- this.addUser(checked)
- },
- onTabChange(key, type) {
- console.log(key, type)
- this[type] = key
- if (type == 'noTitleKey') {
- this.drawPie(key, this.dataDetail)
- }
- },
- drawPie(type, data) {
- console.log(type)
- var dataLegend = []
- var dataLength = []
- var dataElse = []
- var dataDate = []
- var that = this
- if (this.active == 1 || this.active == 2) {
- dataDate = data.map(item => {
- return item.statHour
- })
- } else {
- dataDate = data.map(item => {
- return item.statDate
- })
- }
- dataLength = data.map(item => {
- return item[type]
- })
- 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 }
- }
- })
- } else if (type == 'discountCost') {
- dataLegend = ['折后总消耗']
- dataElse = data.map(item => {
- if (item.now) {
- return { proportion: (item.now.discountCostProportion * 100).toFixed(2) + '%', statHour: item.statHour }
- } else {
- return { proportion: 0, statHour: item.statHour }
- }
- })
- dataLength = data.map(item => {
- return (item.cost / this.discount).toFixed(2)
- })
- }
- console.log(dataLength, 134123)
- 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()
- }
- },
- getDate() {
- let date = new Date()
- let y = date.getFullYear()
- let MM = date.getMonth() + 1
- MM = MM < 10 ? '0' + MM : MM
- let d = date.getDate()
- d = d < 10 ? '0' + d : d
- let h = date.getHours() - 1
- h = h < 10 ? '0' + h : h
- if (this.active == 1) {
- if (this.statHour) {
- return y + '-' + MM + '-' + d
- } else {
- return y + '-' + MM + '-' + d + ' ' + h
- }
- } else {
- return y + '-' + MM + '-' + (d - 1)
- }
- },
- exportExcel() {
- var title = ''
- if (this.active == 1) {
- if (this.statHour) {
- title = this.getDate() + ' ' + this.statHour + '时数据报表'
- } else {
- title = this.getDate() + '时数据报表'
- }
- } else {
- title = this.getDate() + '数据报表'
- }
- // var opt = {
- // rowIndex: 4
- // } //开头空4行
- var sheet = XLSX2.utils.table_to_sheet(document.getElementById('outTable'))
- sheet['A2'].s = {
- font: {
- name: '宋体',
- sz: 18,
- color: { rgb: 'ff0000' },
- bold: true
- // italic: false,
- // underline: false
- },
- alignment: {
- horizontal: 'center',
- vertical: 'center'
- }
- // fill: {
- // fgColor: {rgb: "008000"},
- // },
- }
- // sheet['A1'] = {
- // t: 's',
- // v: '表格导出'
- // } //给A1单元格赋值
- console.log(sheet)
- //["!merges"]这个属性是专门用来进行单元格合并的
- // sheet['!merges'].push({
- // //如果不为空push 为空 = 赋值
- // //合并单元格 index都从0开始
- // s: {
- // //s开始
- // c: 0, //开始列
- // r: 0 //开始行
- // },
- // e: {
- // //e结束
- // c: 12, //结束列
- // r: 3 //结束行
- // }
- // })
- sheet['!cols'] = [
- {
- wpx: 100
- },
- {
- wpx: 100
- },
- {
- wpx: 100
- },
- {
- wpx: 100
- },
- {
- wpx: 100
- },
- {
- wpx: 100
- },
- {
- wpx: 100
- },
- {
- wpx: 100
- },
- {
- wpx: 100
- },
- {
- wpx: 100
- },
- {
- wpx: 100
- },
- {
- wpx: 100
- },
- {
- wpx: 100
- },
- {
- wpx: 100
- },
- {
- wpx: 100
- }
- ] //单元格列宽
- openDownloadDialog(sheet2blob(sheet), title + '.xlsx')
- }
- },
- watch: {},
- distoryed() {},
- mounted: function() {
- this.$nextTick(() => {
- getAdvertiserList().then(res => {
- console.log(res)
- if (res.code == 0) {
- this.list = res.result
- this.options = res.result
- }
- })
- })
- }
- }
- </script>
|