1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612 |
- <style lang='less'>
- .ant-card-head .ant-tabs-bar{
- padding: 0;
- }
- .search-box .ant-card-body {
- padding: 5px 15px;
- }
- .search-box{
- padding: 15px 10px;
- }
- .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;
- }
- .statistics{
- .ant-card-bordered {
- border: none;
- }
- .ant-card-head .ant-tabs {
- clear: both;
- margin-bottom: -13px;
- color: rgba(0, 0, 0, 0.65);
- font-weight: normal;
- font-size: 14px;
- }
- .duibi{
- position: absolute;
- right: 24px;
- top: 15px;
- }
- p{
- margin-bottom: 0;
- }
- }
- </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>对比</p> -->
- </a-card>
- </a-col>
- </a-row>
- <a-row :gutter="16" v-if="kuaishou">
- <a-col :sm="24" :md="6" :xl="6" :xxl="6">
- <lifting
- :kuaishou.sync="kuaishou"
- :active.sync="active"
- title="总消耗"
- typeName="cost"
- typeThan="costProportion"
- ></lifting>
- </a-col>
- <a-col :sm="24" :md="6" :xl="6" :xxl="6">
- <lifting
- :kuaishou.sync="kuaishou"
- :active.sync="active"
- title="封面点击数"
- typeName="photoClick"
- typeThan="photoClickProportion"
- ></lifting>
- </a-col>
- <a-col :sm="24" :md="6" :xl="6" :xxl="6">
- <lifting
- :kuaishou.sync="kuaishou"
- :active.sync="active"
- title="封面曝光数"
- typeName="photoShow"
- typeThan="showProportion"
- ></lifting>
- </a-col>
- <a-col :sm="24" :md="6" :xl="6" :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%;position:relative"
- :tabList="tabListNoTitle"
- :activeTabKey="noTitleKey"
- @tabChange="key => onTabChange(key, 'noTitleKey')"
- >
- <div id="chart" style="width:100%;height:500px"></div>
- <a-button class="duibi" type='primary' @click="visible = true">数据对比</a-button>
- </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)*100).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)*100).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)*100).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)*100).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:12px">
- <a-col :span="24">
- <a-card
- :tabList="tableNowCard"
- :activeTabKey="noTitleKeyTable"
- @tabChange="key => onTabChange(key, 'noTitleKeyTable')"
- style="word-break: break-all;font-size:16px;font-weight:600"
- >
- <a-table :columns="columns" :dataSource="dataTable" :pagination="false" :loading="loading" bordered>
- <!-- <span slot="cost" slot-scope="cost">{{ cost | decimalsHandle }}</span> -->
- <span slot="cost" slot-scope="cost">{{ cost | decimalsHandle }}</span>
- <span slot="photoClick" slot-scope="photoClick">{{ photoClick | formatCurrency }}</span>
- <span slot="photoShow" slot-scope="photoShow">{{ photoShow | formatCurrency }}</span>
- <span slot="aclick" slot-scope="aclick">{{ aclick | formatCurrency }}</span>
- </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' , scopedSlots: { customRender: 'cost' },},
- {
- title: '封面点击数环比',
- dataIndex: 'yesPhotoClick',
- scopedSlots: { customRender: 'photoClickProportion' },
- align: 'center'
- },
- { title: '封面点击数', dataIndex: 'photoClick', align: 'center', scopedSlots: { customRender: 'photoClick' }, },
- {
- title: '封面曝光数环比',
- dataIndex: 'yesPhotoShow',
- scopedSlots: { customRender: 'photoShowProportion' },
- align: 'center'
- },
- { title: '封面曝光数', dataIndex: 'photoShow', align: 'center' , scopedSlots: { customRender: 'photoShow' },},
- {
- title: '素材曝光数环比',
- dataIndex: 'yesAclick',
- scopedSlots: { customRender: 'aclickProportion' },
- align: 'center'
- },
- { title: '素材曝光数', dataIndex: 'aclick', align: 'center', scopedSlots: { customRender: 'aclick' }, }
- ],
- columnsDb: [
- { title: '时间', dataIndex: 'statDate', align: 'center' },
- { title: '总消耗', dataIndex: 'cost', align: 'center' , scopedSlots: { customRender: 'cost' },},
- { title: '封面点击数', dataIndex: 'photoClick', align: 'center', scopedSlots: { customRender: 'photoClick' }, },
- { title: '封面曝光数', dataIndex: 'photoShow', align: 'center', scopedSlots: { customRender: 'photoShow' }, },
- { title: '素材曝光数', dataIndex: 'aclick', align: 'center', scopedSlots: { customRender: 'aclick' }, }
- ],
- 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.aclick?res.result:{aclick: 0,cost: 0, photoClick: 0,photoShow: 0,}
- // 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(() => {
- postAction('/v1/api/file/getFileListByPage',{page: 1,size: 10}).then(res=>{
- console.log(res)
- })
- 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)
- },
- filters: {
- toPercentage(val) {
- if(typeof val != 'string'){
- return (val * 100).toFixed(2) + '%'
- }else{
- return val
- }
-
- },
- //保留两位小数并且变成货币格式
- decimalsHandle(val){
-
- if(val && typeof val !='string'){
- if(val>=0){
- val=parseFloat(val).toFixed(2);
- let numberStr = val.toString()
- let str = numberStr.split('.')
-
- let str0=str[0].split('').reverse();
- for (let i = 0; i < str0.length; i++) {
- if ((i + 1) % 4 === 0) {
- str0.splice(i, 0, ',')
- }
- }
- str0.reverse()
- let handleResult = ''
- for (let j = 0; j < str0.length; j++) {
- handleResult += str0[j]
- }
-
- return handleResult+'.'+str[1]
- }else{
- val=parseFloat(val).toFixed(2);
- let numberStr = val.toString()
- let str = numberStr.split('.')
-
- let str0=str[0].substr(1).split('').reverse();
- for (let i = 0; i < str0.length; i++) {
- if ((i + 1) % 4 === 0) {
- str0.splice(i, 0, ',')
- }
- }
- str0.reverse()
- let handleResult = ''
- for (let j = 0; j < str0.length; j++) {
- handleResult += str0[j]
- }
-
- return '-'+handleResult+'.'+str[1]
- }
-
- }else if(typeof val =='string'){
- return val
- }
- else{
- return 0
- }
- },
- //变成货币格式
- formatCurrency(val){
- if(val){
- let numberStr = val.toString()
- let str = numberStr.split('').reverse()
- for (let i = 0; i < str.length; i++) {
- if ((i + 1) % 4 === 0) {
- str.splice(i, 0, ',')
- }
- }
- str.reverse()
- let handleResult = ''
- for (let j = 0; j < str.length; j++) {
- handleResult += str[j]
- }
- return handleResult
- }
-
- }
- }
- }
- </script>
|