12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442 |
- <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;
- }
- .tableTop{
- position: relative;
- padding-bottom: 15px;
- border-bottom: 1px solid #e0e0e0;
- .selectTime{
- margin-right: 20px;
- }
- .add{
- position: absolute;
- top: 0;
- right: 0;
- }
- }
- </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;
- }
- th div {
- white-space: nowrap;
- }
- </style>
- <template>
- <div class="data-statistics">
- <a-row class="image-list-heading vm-panel">
- <a-row type="flex" align="middle" justify="space-between" class="panel-body">
- <div class="search-bar" style="width:100%">
- <span>账户选择:</span>
- <treeselect :appId.sync="appId" />
- <span style="margin-left:10px">返点比例:</span>
- <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>
- <a-button
- type="primary"
- icon="reload"
- @click="getDataReset"
- style="background-color:#67c23a;border-color:#67c23a"
- >刷新</a-button
- >
- <a-button type="primary" @click="getDataResetAll" style="color:white;margin-left:10px">重置</a-button>
- </div>
- </a-row>
- <a-row>
- <a-col :span="24">
- <a-card :bordered="false" class="search-box">
- <time-check
- @getAdd="getAdd"
- :startValue.sync="startValue"
- ref="timeCheck"
- ></time-check>
- </a-card>
- </a-col>
- </a-row>
- </a-row>
- <a-row :gutter="16" v-if="kuaishou">
- <a-col :sm="24" :md="12" :xl="12" :xxl="5">
- <lifting
- :kuaishou.sync="kuaishou"
- :active.sync="active"
- title="总消耗"
- typeName="cost"
- typeThan="costProportion"
- ></lifting>
- </a-col>
- <a-col :sm="24" :md="12" :xl="12" :xxl="5">
- <lifting
- :kuaishou.sync="kuaishou"
- :active.sync="active"
- title="折后消耗"
- typeName="discountCost"
- typeThan="discountCostProportion"
- ></lifting>
- </a-col>
- <a-col :sm="24" :md="12" :xl="12" :xxl="5">
- <lifting
- :kuaishou.sync="kuaishou"
- :active.sync="active"
- title="封面点击数"
- typeName="photoClick"
- typeThan="photoClickProportion"
- ></lifting>
- </a-col>
- <a-col :sm="24" :md="12" :xl="12" :xxl="5">
- <lifting
- :kuaishou.sync="kuaishou"
- :active.sync="active"
- title="封面曝光数"
- typeName="photoShow"
- typeThan="showProportion"
- ></lifting>
- </a-col>
- <a-col :sm="24" :md="12" :xl="12" :xxl="4">
- <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 class="tableTop"
- style="display:flex;margin-bottom:15px"
- v-show="
- role.roleCode == 'operator' ||
- role.roleCode == 'kuaishouOperationManager' ||
- role.roleCode == 'admin' ||
- role.roleCode == 'operationAssistant' ||
- role.roleCode == 'touTiaoOperationManager'
- "
- >
- <a-select
- style="width: 120px"
- v-model="statHour"
- @change="getElseData"
- allowClear
- v-if="active == 1 || active == 2"
- >
- <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>
- <!-- <a-button type='primary' class="add" @click="customColumns" >自定义列</a-button> -->
- </div>
- <a-table
- :columns="columns"
- :dataSource="data"
- bordered
- id="outTable"
- :pagination="false"
- :scroll="{ x: 2500 }"
- ></a-table>
- <!-- <customColumn :visible='visible' :listNum='listNum' :fiexColumn='columnsFixd' @closeCustomColumn='closeCustomColumn' @changeColumn='changeColumn' /> -->
- </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'
- import timeCheck from './components/timeCheck'
- import Treeselect from './components/Treeselect.vue'
- import { getAction, postAction, postFile } from '@/api/manage'
- import { mapGetters } from 'vuex'
- import customColumn from './components/customColumn.vue'
- // 引入基本模板
- 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',
- width: 150,
- fixed:'left',
- 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',
- width: 250,
- fixed:'left',
- 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
- }
- }
- } else {
- for (let i = 0; i < length; i++) {
- if (index >= length - 1) {
- obj.attrs.colSpan = 2
- }
- }
- }
- return obj
- }
- },
- {
- title: '账户昵称',
- dataIndex: 'accountName',
- scopedSlots: { customRender: 'cost' },
- align: 'center',
- width: 250,
- fixed:'left',
- 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
- }
- }
- } else {
- for (let i = 0; i < length; i++) {
- if (index >= length - 1) {
- obj.attrs.colSpan = 0
- }
- }
- }
- return obj
- }
- },
- {
- title: '消耗(¥)',
- dataIndex: 'cost',
- scopedSlots: { customRender: 'cost' },
- align: 'center'
- },
- {
- title: '折后消耗(¥)',
- dataIndex: 'costY',
- align: 'center'
- },
- {
- title: '次留数',
- dataIndex: 'eventNextDayStay',
- scopedSlots: { customRender: 'eventNextDayStay' },
- align: 'center'
- },
- {
- title: '次留率',
- dataIndex: 'eventNextDayStayRatio',
- 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: 'beforeFormPrice',
- align: 'center'
- },
- {
- title: '折后转化单价(¥)',
- dataIndex: 'afterFormPrice',
- align: 'center'
- },
- {
- title: '注册数',
- dataIndex: 'eventRegister',
- align: 'center'
- },
- {
- title: '注册成本(¥)',
- dataIndex: 'eventRegisterCost',
- 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
- }
- }
- ]
- const columnsWu = [
- {
- title: '时间',
- dataIndex: 'date',
- align: 'center',
- width: 150,
- fixed:'left',
- 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',
- width: 200,
- fixed:'left',
- 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
- }
- }
- } else {
- for (let i = 0; i < length; i++) {
- if (index >= length - 1) {
- obj.attrs.colSpan = 2
- }
- }
- }
- return obj
- }
- },
- {
- title: '账户昵称',
- dataIndex: 'accountName',
- scopedSlots: { customRender: 'cost' },
- align: 'center',
- width: 200,
- fixed:'left',
- 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
- }
- }
- } else {
- for (let i = 0; i < length; i++) {
- if (index >= length - 1) {
- 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: 'beforeFormPrice',
- align: 'center'
- },
- {
- title: '折后转化单价(¥)',
- dataIndex: 'afterFormPrice',
- align: 'center'
- },
- {
- title: '注册数',
- dataIndex: 'eventRegister',
- align: 'center'
- },
- {
- title: '注册成本(¥)',
- dataIndex: 'eventRegisterCost',
- 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,
- timeCheck,
- Treeselect,
- customColumn,
- },
- data: function() {
- return {
- title: '账户数据展示',
- show: true,
- data: [],
- columns:columnsWu,
- 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
- },
- timeList: [
- //{ label: '今天', value: 1, show: true },
- { label: '昨天', value: 2, show: true },
- { label: '近一周', value: 3, show: true },
- { label: '近十五天', value: 4, show: true },
- { label: '近一月', value: 5, show: true },
- { label: '近三月', value: 6, show: true },
- { label: '近半年', value: 7, show: true },
- { label: '所有', value: 8, show: true }
- ],
- dataDetail: [],
- tabListNoTitle: [
- {
- key: 'cost',
- tab: '总消耗'
- },
- {
- key: 'discountCost',
- tab: '折后总消耗'
- },
- {
- key: 'photoClick',
- tab: '封面点击数'
- },
- {
- key: 'photoShow',
- tab: '封面曝光数'
- },
- {
- key: 'aclick',
- tab: '素材曝光数'
- }
- ],
- noTitleKey: 'cost',
- role: { roleCode: '' },
- statDate: '',
- visible:false,//自定义页面的打开
- listNum:[],
- scrollX:0,
- }
- },
- 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: {
- ...mapGetters(['nickname', 'avatar', 'userInfo']),
- moment,
- //弹出框打开,自定义列
- customColumns() {
- this.visible = true
- this.listNum = [...this.columns]
- },
- closeCustomColumn(){
- this.visible=false;
- },
- //自定义之后修改父元素表头
- changeColumn(val){
- this.columns=[...val];
- if(this.columns.length> this.columnsFixd.length){
- this.scrollX=200*(this.columns.length-this.columnsFixd.length)
- }else{
- this.scrollX=0
- }
- },
- tableHandle() {
- // this.listNum = [...this.columns]
- // console.log(this.listNum.length, this.columns)
- if (this.listNum.length >= 9 || this.columns.length >= 9) {
- this.tableWidth = 120
- this.scrollX = this.columns.length * 120
- // console.log(this.scrollX)
- } else {
- this.scrollX = 0
- }
- },
-
- disabledDate(current) {
- return current && current > moment().endOf('day')
- },
- handleChange(value) {
- console.log(value)
- // this.appId = value
- },
- getElseData(value) {
- if(value){
- this.columns = columnsWu
- }else{
- this.columns = columns
- }
- 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.lista
- }
- },
- 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
- }
- }
- },
- getDataReset() {
- this.active = 1
- this.allValue = []
- this.$refs.timeCheck.active = 1
- this.addUser()
- },
- getDataResetAll() {
- this.active = 1
- this.allValue = []
- this.$refs.timeCheck.active = 1
- var that = this
- that.kuaishou.aclick = 0
- that.kuaishou.cost = 0
- that.kuaishou.photoClick = 0
- that.kuaishou.photoShow = 0
- that.kuaishou.discountCost = 0
- this.data = []
- this.appId = []
- this.drawPie(1, [])
- },
- addUser() {
- var that = this
- if (this.appId.length > 0) {
- if(that.active == 1){
- that.columns = columnsWu
- }else{
- that.columns = columns
- }
- 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.success) {
- if (res.result) {
- that.kuaishou = res.result.summary.aclick?res.result.summary:{aclick:0,cost:0,photoClick:0,photoShow:0,discountCost:0}
- that.dataDetail = res.result.trend
- that.drawPie(that.noTitleKey, res.result.trend)
- } else {
- that.kuaishou.aclick = 0
- that.kuaishou.cost = 0
- that.kuaishou.photoClick = 0
- that.kuaishou.photoShow = 0
- that.kuaishou.discountCost = 0
- }
- }
- })
- 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)
- if (res.success) {
- if (res.result.accountDetail) {
- this.statDate = res.result.statDate
- this.data = res.result.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),
- beforeFormPrice: item.formPrice
- ? item.formPrice.toFixed(2)
- : item.activationPrice
- ? item.activationPrice.toFixed(2)
- : 0,
- afterFormPrice: item.formPrice
- ? (item.formPrice / this.discount).toFixed(2)
- : item.activationPrice
- ? (item.activationPrice / this.discount).toFixed(2)
- : 0,
- date: this.statHour ? res.result.statDate + ' ' + this.statHour : res.result.statDate,
- formCount: item.formCount > 0 ? item.formCount : item.activationCount,
- eventRegister: item.eventRegister,
- eventRegisterCost: item.eventRegisterCost.toFixed(2),
- eventNextDayStayRatio:item.eventNextDayStayRatio?(item.eventNextDayStayRatio*100).toFixed(2) + '%' : 0 + '%'
- }
- })
- var index = this.data.length
- if (this.active == 1) {
- var allNow = {
- key: index + 1,
- ...res.result.now,
- photoClickRatio: res.result.now.photoClickRatio
- ? (res.result.now.photoClickRatio * 100).toFixed(2) + '%'
- : 0 + '%',
- cpm: res.result.now.cpm ? res.result.now.cpm.toFixed(2) : 0,
- cost: res.result.now.cost.toFixed(2),
- cvr: res.result.now.cvr ? (res.result.now.cvr * 100).toFixed(2) + '%' : 0 + '%',
- costY: (res.result.now.cost / this.discount).toFixed(2),
- accountId: '总计',
- beforeFormPrice: res.result.now.formPrice
- ? res.result.now.formPrice.toFixed(2)
- : res.result.now.activationPrice
- ? res.result.now.activationPrice.toFixed(2)
- : 0,
- afterFormPrice: res.result.now.formPrice
- ? (res.result.now.formPrice / this.discount).toFixed(2)
- : res.result.now.activationPrice
- ? (res.result.now.activationPrice / this.discount).toFixed(2)
- : 0,
- formCount: res.result.now.conversionNum,
- eventRegister: res.result.now.eventRegister,
- eventRegisterCost: res.result.now.eventRegisterCost.toFixed(2)
- }
- var allYesterday = {
- key: index + 2,
- ...res.result.yesterday,
- photoClickRatio: res.result.yesterday.photoClickRatio
- ? (res.result.yesterday.photoClickRatio * 100).toFixed(2) + '%'
- : 0 + '%',
- cpm: res.result.yesterday.cpm ? res.result.yesterday.cpm.toFixed(2) : 0,
- cost: res.result.yesterday.cost.toFixed(2),
- cvr: res.result.yesterday.cvr ? (res.result.yesterday.cvr * 100).toFixed(2) + '%' : 0 + '%',
- costY: (res.result.yesterday.cost / this.discount).toFixed(2),
- accountId: '昨日总计',
- beforeFormPrice: res.result.yesterday.formPrice
- ? res.result.yesterday.formPrice.toFixed(2)
- : res.result.yesterday.activationPrice
- ? res.result.yesterday.activationPrice.toFixed(2)
- : 0,
- afterFormPrice: res.result.yesterday.formPrice
- ? (res.result.yesterday.formPrice / this.discount).toFixed(2)
- : res.result.yesterday.activationPrice
- ? (res.result.yesterday.activationPrice / this.discount).toFixed(2)
- : 0,
- formCount:res.result.yesterday.conversionNum,
- eventRegister: res.result.yesterday.eventRegister,
- eventRegisterCost: res.result.yesterday.eventRegisterCost.toFixed(2)
- }
- var chainRatio = {
- key: index + 3,
- cost: (res.result.chainRatio.costProportion * 100).toFixed(2) + '%',
- photoShow: (res.result.chainRatio.showProportion * 100).toFixed(2) + '%',
- photoClick: (res.result.chainRatio.photoClickProportion * 100).toFixed(2) + '%',
- aclick: (res.result.chainRatio.aClickProportion * 100).toFixed(2) + '%',
- photoClickRatio: res.result.chainRatio.photoClickRatioProportion
- ? (res.result.chainRatio.photoClickRatioProportion * 100).toFixed(2) + '%'
- : 0.0 + '%',
- cvr: (res.result.chainRatio.cvrProportion * 100).toFixed(2) + '%',
- cpm: (res.result.chainRatio.cpmProportion * 100).toFixed(2) + '%',
- bClick: (res.result.chainRatio.bClickProportion * 100).toFixed(2) + '%',
- formCount: (res.result.chainRatio.nowConversionNumProportion* 100).toFixed(2) + '%',
- beforeFormPrice: (res.result.chainRatio.beforeConversionPriceProportion*100).toFixed(2) + '%',
- afterFormPrice: (res.result.chainRatio.afterConversionPriceProportion*100).toFixed(2) + '%',
- costY: (res.result.chainRatio.costProportion * 100).toFixed(2) + '%',
- eventRegister: (res.result.chainRatio.eventRegisterProportion * 100).toFixed(2) + '%',
- eventRegisterCost: (res.result.chainRatio.eventRegisterCostProportion * 100).toFixed(2) + '%',
- accountId: '环比'
- }
- this.data.push(allNow)
- this.data.push(allYesterday)
- this.data.push(chainRatio)
- } else {
- var allNow = {
- key: index + 1,
- ...res.result.ratioJson,
- photoClickRatio: res.result.ratioJson.photoClickRatio
- ? (res.result.ratioJson.photoClickRatio * 100).toFixed(2) + '%'
- : 0 + '%',
- cpm: res.result.ratioJson.cpm ? res.result.ratioJson.cpm.toFixed(2) : 0,
- cost: res.result.ratioJson.cost?res.result.ratioJson.cost.toFixed(2):0,
- cvr: res.result.ratioJson.cvr ? (res.result.ratioJson.cvr * 100).toFixed(2) + '%' : 0 + '%',
- costY: (res.result.ratioJson.cost / this.discount).toFixed(2),
- accountId: '总计',
- beforeFormPrice: res.result.ratioJson.formPrice
- ? res.result.ratioJson.formPrice.toFixed(2)
- : res.result.ratioJson.activationPrice
- ? res.result.ratioJson.activationPrice.toFixed(2)
- : 0,
- afterFormPrice: res.result.ratioJson.formPrice
- ? (res.result.ratioJson.formPrice / this.discount).toFixed(2)
- : res.result.ratioJson.activationPrice
- ? (res.result.ratioJson.activationPrice / this.discount).toFixed(2)
- : 0,
- formCount: res.result.ratioJson.conversions,
- beforeFormPrice: res.result.ratioJson.conversionPrice.toFixed(2),
- afterFormPrice: res.result.ratioJson.discountConversionPrice.toFixed(2),
- eventRegister: res.result.ratioJson.eventRegister,
- eventRegisterCost: res.result.ratioJson.eventRegisterCost.toFixed(2),
- eventNextDayStayRatio:res.result.ratioJson.eventNextDayStayRatio?(res.result.ratioJson.eventNextDayStayRatio*100).toFixed(2) + '%' : 0 + '%'
- }
- this.data.push(allNow)
- this.statDate = res.result.statDate
- }
- length = this.data.length
- } else {
- this.$message.error('暂无数据')
- }
- }
- })
- },
- 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
- if(this.active == 1){
- this.columns = columnsWu
- }else{
- this.columns = columns
- }
- 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 if (this.active == 2) {
- title = this.getDate() + '数据报表'
- } else {
- title = this.statDate + '数据报表'
- }
- const borderAll = {
- //单元格外侧框线
- top: {
- style: 'thin'
- },
- bottom: {
- style: 'thin'
- },
- left: {
- style: 'thin'
- },
- right: {
- style: 'thin'
- }
- }
- // var opt = {
- // rowIndex: 4
- // } //开头空4行
- var sheet = XLSX2.utils.table_to_sheet(document.getElementById('outTable'))
- var sheetName = ['D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O']
- // sheet['A2'].s = {
- // alignment: {
- // horizontal: 'center',
- // vertical: 'center'
- // }
- // // fill: {
- // // fgColor: {rgb: "008000"},
- // // },
- // }
- // for (let i = 0; i < 3; i++) {
- // sheet['B' + (length + 1 - i)].s = {
- // alignment: {
- // horizontal: 'center',
- // vertical: 'center'
- // }
- // }
- // }
- // for (let i = 0; i < sheetName.length; i++) {
- // for (let j = 2; j < length + 2; j++) {
- // console.log(sheetName[i] + j + '')
- // var a = sheetName[i] + j + ''
- // console.log(a)
- // sheet[a].t = 'n'
- // }
- // }
- for (var i in sheet) {
- if (i == '!ref' || i == '!merges' || i == '!cols') {
- } else {
- sheet[i + ''].s = {
- border: borderAll,
- alignment: {
- horizontal: 'center',
- vertical: 'center'
- }
- // fill: {
- // fgColor: { rgb: 'FFFF00' }
- // }
- }
- sheet[i + ''].t = 'n'
- }
- }
- //["!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
- },
- {
- wpx: 100
- }
- ] //单元格列宽
- openDownloadDialog(sheet2blob(sheet), title + '.xlsx')
- }
- },
- watch: {},
- distoryed() {},
- mounted: function() {
- this.$nextTick(() => {
- getAction('/sys/user/getRoleInfo', { userId: this.userInfo().id }).then(res => {
- this.role = res
- })
- })
- }
- }
- </script>
|