KSAccountReport.vue 58 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552
  1. <template>
  2. <div class="accountReport">
  3. <!-- 操作区间 -->
  4. <div class="optionLine">
  5. <span>项目选择:</span>
  6. <a-tree-select
  7. v-model="treeValue"
  8. show-search
  9. style="width: 600px;height:30px"
  10. :dropdownMatchSelectWidth='true'
  11. :dropdown-style="{ maxHeight: '400px', overflow: 'auto' }"
  12. tree-checkable
  13. searchPlaceholder='请输入账户关键字搜索'
  14. :show-checked-strategy="SHOW_PARENT"
  15. placeholder="请选择项目和账户或搜索账户关键字"
  16. treeNodeFilterProp="title"
  17. :allowClear="true"
  18. @change="treeChange"
  19. @search="treeSearch"
  20. @select="treeSelect"
  21. :maxTagCount='1'
  22. :tree-data="treeData"
  23. :filterOption='filterOption'
  24. >
  25. <!-- <a-tree-select-node v-for="(item) in treeData" :key="item.key" :value="item.value" :title="item.title">
  26. <a-tree-select-node v-for="(ele) in item.children" :key="ele.key" :value="ele.value" :title="ele.title" >
  27. </a-tree-select-node>
  28. </a-tree-select-node> -->
  29. </a-tree-select>
  30. <div style="float:right" @click="opendate">
  31. <DatePicker :openOptions='openOptions' :left=left :parentDate='dateValue' />
  32. </div>
  33. <div class="optionTow">
  34. <!-- <div class="optItem">
  35. <span>折扣:</span>
  36. <a-input-number :min="0" :max="10" :step="0.1" v-model="discountSelect" :disabled="discountDisabled" @change="discountChange" />
  37. </div> -->
  38. <div class="optItem">
  39. <span>返点比例:</span>
  40. <a-input-number :min="0.1" :max="10" :step="0.1" v-model="rebateProp" :disabled="rebatePropDisabled" @change="rebatePropChange" />
  41. </div>
  42. <div class="btn">
  43. <a-button type="primary" @click="searchgetData" :disabled='searchDisabled' class="mybtn">查询</a-button>
  44. <a-button type="primary" @click="resetgetData" :disabled='resetDisabled' class="mybtn">重置</a-button>
  45. </div>
  46. </div>
  47. </div>
  48. <!-- 五个块 -->
  49. <div class="show">
  50. <div class="showBox">
  51. <div class="title">
  52. <div class="infotitle">总消耗</div>
  53. <a-tooltip v-if="dateValue[0].format('YYYY-MM-DD')==dateValue[1].format('YYYY-MM-DD')">
  54. <template slot="title">{{dateValue[0].format('HH:00')}}点之前所有数据对比</template>
  55. <span class="icon">
  56. <a-icon type="exclamation-circle" />
  57. </span>
  58. </a-tooltip>
  59. </div>
  60. <div class="infoNum">¥
  61. <span class="red">{{costLink.cost | decimalsHandle}}</span>
  62. <span class="green" v-if="dateValue[0].format('YYYY-MM-DD')==dateValue[1].format('YYYY-MM-DD')" ><span class="huanbi">环比: </span> {{ costLink.CostSumLink|toPercentage }}</span>
  63. </div>
  64. </div>
  65. <div class="showBox">
  66. <div class="title">
  67. <div class="infotitle">折后消耗</div>
  68. <a-tooltip v-if="dateValue[0].format('YYYY-MM-DD')==dateValue[1].format('YYYY-MM-DD')">
  69. <template slot="title">{{dateValue[0].format('HH:00')}}点之前所有数据对比</template>
  70. <span class="icon">
  71. <a-icon type="exclamation-circle" />
  72. </span>
  73. </a-tooltip>
  74. </div>
  75. <div class="infoNum">¥
  76. <span class="red">{{discountCostLink.discountCost | decimalsHandle }}</span>
  77. <span class="green" v-if="dateValue[0].format('YYYY-MM-DD')==dateValue[1].format('YYYY-MM-DD')"><span class="huanbi">环比: </span> {{ discountCostLink.discountCostLink|toPercentage }}</span>
  78. </div>
  79. </div>
  80. <div class="showBox">
  81. <div class="title">
  82. <div class="infotitle">封面点击数</div>
  83. <a-tooltip v-if="dateValue[0].format('YYYY-MM-DD')==dateValue[1].format('YYYY-MM-DD')">
  84. <template slot="title">{{dateValue[0].format('HH:00')}}点之前所有数据对比</template>
  85. <span class="icon">
  86. <a-icon type="exclamation-circle" />
  87. </span>
  88. </a-tooltip>
  89. </div>
  90. <div class="infoNum">¥
  91. <span class="red">{{photoClickLink.photoClick | formatCurrency }}</span>
  92. <span class="green" v-if="dateValue[0].format('YYYY-MM-DD')==dateValue[1].format('YYYY-MM-DD')"><span class="huanbi">环比: </span> {{ photoClickLink.photoClickLink|toPercentage }}</span>
  93. </div>
  94. </div>
  95. <div class="showBox">
  96. <div class="title">
  97. <div class="infotitle">封面曝光数</div>
  98. <a-tooltip v-if="dateValue[0].format('YYYY-MM-DD')==dateValue[1].format('YYYY-MM-DD')">
  99. <template slot="title">{{dateValue[0].format('HH:00')}}点之前所有数据对比</template>
  100. <span class="icon">
  101. <a-icon type="exclamation-circle" />
  102. </span>
  103. </a-tooltip>
  104. </div>
  105. <div class="infoNum">¥
  106. <span class="red">{{photoShowLink.photoShow | formatCurrency }}</span>
  107. <span class="green" v-if="dateValue[0].format('YYYY-MM-DD')==dateValue[1].format('YYYY-MM-DD')"><span class="huanbi">环比: </span> {{ photoShowLink.photoShowLink|toPercentage }}</span>
  108. </div>
  109. </div>
  110. <div class="showBox">
  111. <div class="title">
  112. <div class="infotitle">素材曝光数</div>
  113. <a-tooltip v-if="dateValue[0].format('YYYY-MM-DD')==dateValue[1].format('YYYY-MM-DD')">
  114. <template slot="title">{{dateValue[0].format('HH:00')}}点之前所有数据对比</template>
  115. <span class="icon">
  116. <a-icon type="exclamation-circle" />
  117. </span>
  118. </a-tooltip>
  119. </div>
  120. <div class="infoNum">¥
  121. <span class="red">{{aClickLink.aClick | formatCurrency }}</span>
  122. <span class="green" v-if="dateValue[0].format('YYYY-MM-DD')==dateValue[1].format('YYYY-MM-DD')"><span class="huanbi">环比: </span> {{ aClickLink.aClickLink|toPercentage }}</span>
  123. </div>
  124. </div>
  125. </div>
  126. <!-- 图表区域 -->
  127. <div class="chartBox">
  128. <a-tabs default-active-key="cost" @change="callback" >
  129. <a-tab-pane key="cost" tab="总消耗">
  130. </a-tab-pane>
  131. <a-tab-pane key="discountCost" tab="折后消耗">
  132. </a-tab-pane>
  133. <a-tab-pane key="photoClick" tab="封面点击数" >
  134. </a-tab-pane>
  135. <a-tab-pane key="photoShow" tab="封面曝光数">
  136. </a-tab-pane>
  137. <a-tab-pane key="zhuanhua" tab="素材曝光数">
  138. </a-tab-pane>
  139. </a-tabs>
  140. <div id="sectionChart" style='width:100%;height:300px' ref="sectionChart" ></div>
  141. <!-- <div id="noData" v-else style='width:100%;height:300px'>暂无数据</div> -->
  142. </div>
  143. <!-- 报表区域 -->
  144. <div class="tableBox">
  145. <div class="tableTop">
  146. <a-tooltip>
  147. <template slot="title">
  148. 日期选择具体某一天之后,这里可以查看具体的时间段数据哦~
  149. </template>
  150. <a-select placeholder="请选择具体时间段" style="width: 160px" @change="timeChange" v-model='timeDefaultValue' label-in-value class="selectTime" v-show="dateValue[0].format('YYYY-MM-DD')==dateValue[1].format('YYYY-MM-DD')" :disabled='accountId.length==0'>
  151. <a-select-option v-for="(i,index) in 24 " :key="index" :value="index" >{{index>=10 ? `00:00-${index}:59` :`00:00-0${index}:59`}}</a-select-option>
  152. </a-select>
  153. </a-tooltip>
  154. <a-button type='primary' class="export" @click="exportExcel">导出报表</a-button>
  155. <a-button type='primary' class="add" @click="customColumns" >自定义列</a-button>
  156. </div>
  157. <a-table
  158. size="middle"
  159. :columns="columns"
  160. :dataSource="tableData"
  161. bordered
  162. id="outTable"
  163. :pagination="false"
  164. :scroll="{ x: scrollX }"
  165. :loading="loading"
  166. ref="accountTable"
  167. :width="tableWidth"
  168. @change="sort"
  169. style="word-break: break-all;font-size:16px;font-weight:600"
  170. >
  171. <span slot="ctr" slot-scope="ctr">{{ ctr | toPercentage }}</span>
  172. <span slot="cost" slot-scope="cost">{{ cost | decimalsHandle }}</span>
  173. <span slot="clickMaterial" slot-scope="clickMaterial">{{ clickMaterial | formatCurrency }}</span>
  174. <span slot="showMaterial" slot-scope="showMaterial">{{ showMaterial | formatCurrency }}</span>
  175. <span slot="convertMaterial" slot-scope="convertMaterial">{{ convertMaterial | formatCurrency }}</span>
  176. <span slot="play25FeedBreak" slot-scope="play25FeedBreak">{{ play25FeedBreak | formatCurrency }}</span>
  177. <span slot="play50FeedBreak" slot-scope="play50FeedBreak">{{ play50FeedBreak | formatCurrency }}</span>
  178. <span slot="play75FeedBreak" slot-scope="play75FeedBreak">{{ play75FeedBreak | formatCurrency }}</span>
  179. <span slot="play100FeedBreak" slot-scope="play100FeedBreak">{{ play100FeedBreak | formatCurrency }}</span>
  180. <span slot="nextDayOpen" slot-scope="nextDayOpen">{{ nextDayOpen | formatCurrency }}</span>
  181. <span slot="downloadFinish" slot-scope="downloadFinish">{{ downloadFinish | formatCurrency }}</span>
  182. <span slot="downloadStart" slot-scope="downloadStart">{{ downloadStart | formatCurrency }}</span>
  183. <span slot="likeMaterial" slot-scope="likeMaterial">{{ likeMaterial | formatCurrency }}</span>
  184. <span slot="shareMaterial" slot-scope="shareMaterial">{{ shareMaterial | formatCurrency }}</span>
  185. <span slot="register" slot-scope="register">{{ register | formatCurrency }}</span>
  186. <span slot="follow" slot-scope="follow">{{ follow | formatCurrency }}</span>
  187. <span slot="formCount" slot-scope="formCount">{{ formCount | formatCurrency }}</span>
  188. <span slot="formCountCost" slot-scope="formCountCost">{{ formCountCost | decimalsHandle }}</span>
  189. <span slot="aClick" slot-scope="aClick">{{ aClick | formatCurrency }}</span>
  190. <span slot="photoShow" slot-scope="photoShow">{{ photoShow | formatCurrency }}</span>
  191. <span slot="photoClick" slot-scope="photoClick">{{ photoClick | formatCurrency }}</span>
  192. <span slot="bClick" slot-scope="bClick">{{ bClick | formatCurrency }}</span>
  193. <span slot="active" slot-scope="active">{{ active | formatCurrency }}</span>
  194. <span slot="submit" slot-scope="submit">{{ submit | formatCurrency }}</span>
  195. <span slot="nextDayOpen" slot-scope="nextDayOpen">{{ nextDayOpen | formatCurrency }}</span>
  196. <span slot="eventCreditGrantLandingPage" slot-scope="eventCreditGrantLandingPage">{{ eventCreditGrantLandingPage | formatCurrency }}</span>
  197. <span slot="submitCost" slot-scope="submitCost">{{ submitCost | decimalsHandle }}</span>
  198. <span slot="eventCreditGrantLandingPageCost" slot-scope="eventCreditGrantLandingPageCost">{{ eventCreditGrantLandingPageCost | decimalsHandle }}</span>
  199. <span slot="submitRate" slot-scope="submitRate">{{ submitRate | toPercentage }}</span>
  200. <span slot="eventCreditGrantLandingPageRate" slot-scope="eventCreditGrantLandingPageRate">{{ eventCreditGrantLandingPageRate | toPercentage }}</span>
  201. <span
  202. slot="play25FeedBreakRate"
  203. slot-scope="play25FeedBreakRate"
  204. >{{ play25FeedBreakRate | toPercentage }}</span>
  205. <span slot="playOverRate" slot-scope="playOverRate">{{ playOverRate | toPercentage }}</span>
  206. <!-- 新加数据 -->
  207. <span slot="convertRate" slot-scope="convertRate">{{ convertRate | toPercentage }}</span>
  208. <span slot="nextDayOpenRate" slot-scope="nextDayOpenRate">{{ nextDayOpenRate | toPercentage }}</span>
  209. <span slot="ctr" slot-scope="ctr">{{ ctr | toPercentage }}</span>
  210. <span slot="cpc" slot-scope="cpc">{{ cpc | decimalsHandle }}</span>
  211. <span slot="cpm" slot-scope="cpm">{{ cpm | decimalsHandle }}</span>
  212. <span slot="activeRate" slot-scope="activeRate">{{ activeRate | toPercentage }}</span>
  213. <span
  214. slot="installFinishRate"
  215. slot-scope="installFinishRate"
  216. >{{ installFinishRate | toPercentage }}</span>
  217. <span slot="validPlayRate" slot-scope="validPlayRate">{{ validPlayRate | toPercentage }}</span>
  218. <span slot="activePayCost" slot-scope="activePayCost">{{ activePayCost | decimalsHandle }}</span>
  219. <span slot="nextDayOpenCost" slot-scope="nextDayOpenCost">{{ nextDayOpenCost | decimalsHandle }}</span>
  220. <span slot="validPlayCost" slot-scope="validPlayCost">{{ validPlayCost | decimalsHandle }}</span>
  221. <span slot="activeCost" slot-scope="activeCost">{{ activeCost | decimalsHandle }}</span>
  222. <span slot="nextDayOpenCost" slot-scope="nextDayOpenCost">{{ nextDayOpenCost | decimalsHandle }}</span>
  223. <span
  224. slot="gameAddictionCost"
  225. slot-scope="gameAddictionCost"
  226. >{{ gameAddictionCost | decimalsHandle }}</span>
  227. <span
  228. slot="downloadFinishCost"
  229. slot-scope="downloadFinishCost"
  230. >{{ downloadFinishCost | decimalsHandle }}</span>
  231. <span
  232. slot="downloadStartCost"
  233. slot-scope="downloadStartCost"
  234. >{{ downloadStartCost | decimalsHandle }}</span>
  235. <span
  236. slot="installFinishCost"
  237. slot-scope="installFinishCost"
  238. >{{ installFinishCost | decimalsHandle }}</span>
  239. <span slot="convertCost" slot-scope="convertCost">{{ convertCost | decimalsHandle }}</span>
  240. <!-- -->
  241. <span
  242. slot="downloadStartRate"
  243. slot-scope="downloadStartRate"
  244. >{{ downloadStartRate | toPercentage }}</span>
  245. <span
  246. slot="downloadFinishRate"
  247. slot-scope="downloadFinishRate"
  248. >{{ downloadFinishRate | toPercentage }}</span>
  249. <span slot="activeRate" slot-scope="activeRate">{{ activeRate | toPercentage }}</span>
  250. <span
  251. slot="activeRegisterRate"
  252. slot-scope="activeRegisterRate"
  253. >{{ activeRegisterRate | toPercentage }}</span>
  254. <span
  255. slot="gameAddictionRate"
  256. slot-scope="gameAddictionRate"
  257. >{{ gameAddictionRate | toPercentage }}</span>
  258. <span slot="nextDayOpenRate" slot-scope="nextDayOpenRate">{{ nextDayOpenRate | toPercentage }}</span>
  259. <!-- <span slot="nextDayOpenRate" slot-scope="nextDayOpenRate">{{ nextDayOpenRate | toPercentage }}</span> -->
  260. </a-table>
  261. </div>
  262. <customColumn :visible='visible' :listNum='listNum' :fiexColumn='columnsFixd' :mediaType='2' @closeCustomColumn='closeCustomColumn' @changeColumn='changeColumn' />
  263. </div>
  264. </template>
  265. <script>
  266. import moment from 'moment';
  267. import { getAction, postAction, downFile, downFilePost } from '@/api/manage';
  268. import { TreeSelect } from 'ant-design-vue';
  269. const SHOW_PARENT = TreeSelect.SHOW_PARENT;
  270. // const SHOW_PARENT = TreeSelect.SHOW_ALL;
  271. import DatePicker from '@/components/DatePicker.vue'
  272. import customColumn from './components/customColumn.vue'
  273. // 引入基本模板
  274. var echarts = require('echarts')
  275. // 引入柱状图组件
  276. require('echarts/lib/chart/bar')
  277. require('echarts/lib/chart/pie')
  278. require('echarts/lib/chart/line')
  279. // 引入提示框和title组件
  280. require('echarts/lib/component/tooltip')
  281. require('echarts/lib/component/title')
  282. require('echarts/lib/component/graphic')
  283. require('echarts/lib/component/toolbox')
  284. require('echarts/lib/component/legend')
  285. let sectionOption={
  286. tooltip: {
  287. trigger: 'axis',
  288. axisPointer: {
  289. // 坐标轴指示器,坐标轴触发有效
  290. type: 'line', // 默认为直线,可选为:'line' | 'shadow',
  291. }, 
  292. },
  293. legend: {
  294. data: []
  295. },
  296. grid: {
  297. left: '2%',
  298. right: '2%',
  299. bottom: '0%',
  300. top: '12%',
  301. containLabel: true
  302. },
  303. xAxis: [
  304. {
  305. type: 'category',
  306. data: [],
  307. axisTick: {
  308. alignWithLabel: true
  309. }
  310. }
  311. ],
  312. yAxis: [
  313. {
  314. type: 'value',
  315. show: true
  316. }
  317. ],
  318. series: [
  319. {
  320. name: '',
  321. type: 'line',
  322. smooth: true,
  323. data: [],
  324. color:'#32CD32'
  325. },
  326. {
  327. name: '',
  328. type: 'line',
  329. smooth: true,
  330. data: [],
  331. color:'#8A2BE2'
  332. },
  333. {
  334. name: '环比',
  335. type: 'line',
  336. smooth: true,
  337. data: [],
  338. color:'rgba(0,0,0,0)'
  339. }
  340. ]
  341. }
  342. let length=0
  343. const columnsFixd = [
  344. {
  345. title: '时间',
  346. dataIndex: 'date',
  347. scopedSlots: { customRender: 'date' },
  348. align: 'center',
  349. key:'date',
  350. width:150,
  351. fixed:'left',
  352. // customRender: (value, row, index) => {
  353. // const obj = {
  354. // children: value,
  355. // attrs: {}
  356. // }
  357. // if(length){
  358. // // console.log(length)
  359. // if (index == 0) {
  360. // obj.attrs.rowSpan = length
  361. // } else if(index>0&&index<length){
  362. // obj.attrs.rowSpan = 0
  363. // }
  364. // }
  365. // return obj
  366. // }
  367. },
  368. {
  369. title: '账户ID',
  370. dataIndex: 'accountId',
  371. align: 'center',
  372. width: 150,
  373. fixed:'left',
  374. scopedSlots: { customRender: 'accountId' }
  375. },
  376. {
  377. title: '账户昵称',
  378. dataIndex: 'authName',
  379. align: 'center',
  380. width: 250,
  381. fixed:'left',
  382. },
  383. {
  384. title: '消耗(元)',
  385. dataIndex: 'cost',
  386. width:150,
  387. tip: '广告在投放期间的花费总额',
  388. align: 'center',
  389. scopedSlots: { customRender: 'cost' },
  390. sorter: () => {}
  391. },
  392. // {
  393. // title: '折后消耗(元)',
  394. // dataIndex: 'discountCost',
  395. // width:150,
  396. // tip: '广告在投放期间的花费总额',
  397. // align: 'center',
  398. // scopedSlots: { customRender: 'discountCost' },
  399. // sorter: () => {}
  400. // },
  401. {
  402. title: '封面曝光数',
  403. dataIndex: 'photoShow',
  404. tip: '广告在瀑布流被观看次数',
  405. align: 'center',
  406. scopedSlots: { customRender: 'photoShow' },
  407. sorter:() => {}
  408. },
  409. {
  410. title: '封面点击数',
  411. dataIndex: 'photoClick',
  412. tip: '用户点击封面进入视频播放页的次数(数据会进行反作弊去重)',
  413. align: 'center',
  414. scopedSlots: { customRender: 'photoClick' },
  415. sorter: () => {}
  416. },
  417. {
  418. title: '封面点击率',
  419. dataIndex: 'clickRate',
  420. tip: '封面点击数占封面展示数百分比',
  421. align: 'center',
  422. scopedSlots: { customRender: 'clickRate' },
  423. sorter:() => {}
  424. },
  425. {
  426. title: '素材曝光数',
  427. dataIndex: 'aClick',
  428. tip: '用户进入视频播放页观看的次数(数据会进行反作弊去重)',
  429. align: 'center',
  430. scopedSlots: { customRender: 'aClick' },
  431. sorter:() => {}
  432. },
  433. // {
  434. // title: '行为数',
  435. // dataIndex: 'bClick',
  436. // tip: '用户在视频播放页单击转化按钮的次数/展示数*100%',
  437. // align: 'center',
  438. // scopedSlots: { customRender: 'bClick' },
  439. // sorter:() => {}
  440. // },
  441. // {
  442. // title: '行为率',
  443. // dataIndex: 'bClickRate',
  444. // tip: '行为数占素材曝光数百分比',
  445. // align: 'center',
  446. // scopedSlots: { customRender: 'bClickRate' },
  447. // sorter:() => {}
  448. // },
  449. // {
  450. // title: '平均千次封面曝光花费(元)',
  451. // dataIndex: 'cpm',
  452. // tip: '花费/封面曝光数*1000',
  453. // align: 'center',
  454. // scopedSlots: { customRender: 'cpm' },
  455. // sorter:() => {}
  456. // },
  457. // {
  458. // title: '平均封面点击单价(元)',
  459. // dataIndex: 'cpc',
  460. // tip: '花费/封面点击数',
  461. // align: 'center',
  462. // scopedSlots: { customRender: 'cpc' },
  463. // sorter:() => {}
  464. // },
  465. // {
  466. // title: '平均行为单价(元)',
  467. // dataIndex: 'cpb',
  468. // tip: '总花费/行为数',
  469. // align: 'center',
  470. // scopedSlots: { customRender: 'cpb' },
  471. // sorter:() => {}
  472. // },
  473. ]
  474. let initDay ={
  475. x:[],
  476. today:{
  477. y:[],
  478. name:'今天'
  479. },
  480. yesterday:{
  481. y:[],
  482. name:'昨天'
  483. },
  484. huanbi:{
  485. name:'环比',
  486. y:[]
  487. }
  488. }
  489. export default {
  490. components:{
  491. DatePicker,
  492. customColumn,
  493. },
  494. data() {
  495. return {
  496. moment,
  497. //账户的数据
  498. accountId:[],
  499. mediaId:'',//媒体类型
  500. //折扣数值
  501. discountSelect:1.0,
  502. discountDisabled:false,
  503. //返点比例
  504. rebateProp:1.0,
  505. rebatePropDisabled:false,
  506. discount:1,
  507. left:0,
  508. //treeselect的参数
  509. treeValue: [],
  510. treeData: [],
  511. SHOW_PARENT,
  512. //top区域数据
  513. discountCostLink:{},
  514. photoShowLink:{},
  515. photoClickLink:{},
  516. costLink:{},
  517. aClickLink:{},
  518. //日期矿打开
  519. openOptions:false,
  520. //子元素的数据存储
  521. type:1, //这个没用但是不能删 请求类型
  522. dateValue:[moment(),moment()],
  523. //处理按钮禁用
  524. searchDisabled:false,
  525. refreshDisabled:false,
  526. resetDisabled:false,
  527. //echart区域的tab
  528. tabKey:'cost',
  529. sectionOption:JSON.parse(JSON.stringify(sectionOption)),
  530. tabCost:{},
  531. tabPhotoClick:{},//封面点击数
  532. tabPhotoShow:{},
  533. tabDiscountCost:{},
  534. tabAClick:{},
  535. //table的数据
  536. timeSelectValue:23,//table上选择时间
  537. timeValueString:'',
  538. timeDefaultValue:undefined,
  539. visible:false,//自定义页面的打开
  540. columns:JSON.parse(JSON.stringify(columnsFixd)) ,//table的表头
  541. columnsFixd,
  542. tableData:[],
  543. scrollX:1000,
  544. tableWidth: '',//设置表格的列宽
  545. loading:false,
  546. target:'cost',//默认消耗排序
  547. order:'desc',//默认降序
  548. listNum:[],
  549. myChart:{},
  550. chartData:[],
  551. }
  552. },
  553. watch:{
  554. type(n,o){
  555. },
  556. dateValue(newName,oldName){
  557. // console.log(newName,oldName)
  558. this.timeValueString=undefined;
  559. this.timeSelectValue=23;
  560. this.timeDefaultValue =''
  561. if(newName[0].format('YYYY-MM-DD')==oldName[0].format('YYYY-MM-DD') || newName[0].format('YYYY-MM-DD')==moment().format('YYYY-MM-DD')){
  562. }else{
  563. this.searchgetData();
  564. }
  565. },
  566. },
  567. methods: {
  568. treeSearch(){
  569. console.log(arguments);
  570. },
  571. treeSelect(){
  572. // console.log(arguments);
  573. // this.treeValue=arguments[0].value
  574. },
  575. //项目改变后的事件
  576. treeChange(val) {
  577. // console.log(this.treeData)
  578. console.log(val)
  579. this.accountId = [];
  580. //选择一个后禁用其他
  581. if(val.length==1){
  582. if(val[0]*1){
  583. let selectindex=0
  584. this.treeData.forEach((ele,index)=>{
  585. if(ele.children){
  586. ele.children.map((item,ind)=>{
  587. if(item.value==val[0]){
  588. selectindex=index;
  589. this.mediaId=ele.mediaId
  590. }
  591. })
  592. }
  593. });
  594. // console.log(selectindex)
  595. if(selectindex ||selectindex==0){
  596. this.treeData.forEach((ele,index)=>{
  597. if(index!=selectindex){
  598. ele.disableCheckbox = true;
  599. if(ele.children){
  600. ele.children.map((item,ind)=>{
  601. item.disableCheckbox = true;
  602. })
  603. }
  604. }
  605. })
  606. }
  607. }else{
  608. // console.log(1)
  609. this.treeData.forEach((ele,index)=>{
  610. if(ele.value!=val[0]){
  611. ele.disableCheckbox = true;
  612. if(ele.children){
  613. ele.children.forEach((item,ind)=>{
  614. item.disableCheckbox = true;
  615. })
  616. }
  617. }
  618. if(ele.value==val[0]){
  619. this.mediaId=ele.mediaId
  620. }
  621. })
  622. }
  623. // console.log(this.mediaId)
  624. // if(this.mediaId=='2'){
  625. // this.discountDisabled=true;
  626. // this.rebatePropDisabled=false;
  627. // this.discount=this.rebateProp;
  628. // }else{
  629. // this.rebatePropDisabled=true;
  630. // this.discountDisabled=false;
  631. // this.discount=this.discountSelect;
  632. // }
  633. }
  634. if(val.length==0){
  635. this.treeData.forEach((ele,index)=>{
  636. ele.disableCheckbox = false;
  637. this.mediaId=ele.mediaId;
  638. if(ele.children){
  639. ele.children.forEach((item,ind)=>{
  640. item.disableCheckbox = false;
  641. })
  642. }
  643. });
  644. this.rebatePropDisabled=false;
  645. this.discountDisabled=false;
  646. this.discount=1.0
  647. }
  648. if(val){
  649. val.forEach((ele,index)=>{
  650. if(ele*1){
  651. this.accountId.push(ele)
  652. }else{
  653. let projectArr=this.treeData.filter((item)=>{
  654. return item.value==ele
  655. });
  656. // console.log(projectArr)
  657. projectArr[0].children.forEach((element)=>{
  658. this.accountId.push(element.value)
  659. })
  660. }
  661. })
  662. }
  663. console.log(this.accountId)
  664. },
  665. disabledDate(current) {
  666. // console.log(current)
  667. return current && current > moment().subtract(1, 'day')
  668. },
  669. filterOption(input, option){
  670. console.log(input, option)
  671. return (
  672. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  673. );
  674. },
  675. //查询按钮的事件
  676. searchgetData(){
  677. this.myChart.clear()
  678. if(this.accountId.length>0){
  679. // console.log();
  680. this.loading=true;
  681. this.searchDisabled=true;
  682. this.discountCostLink={}
  683. this.photoShowLink={}
  684. this.photoClickLink={}
  685. this.costLink={}
  686. this.aClickLink={}
  687. this.tabCost={}
  688. this.tabPhotoClick={}
  689. this.tabPhotoShow={},
  690. this.tabDiscountCost={}
  691. this.tabAClick={}
  692. this.chartHttp({
  693. mediaId:this.mediaId,
  694. discount:this.discount,
  695. accountIds:this.accountId,
  696. startDate:this.dateValue[0].format('YYYY-MM-DD'),
  697. endDate:this.dateValue[1].format('YYYY-MM-DD')
  698. })
  699. if(this.accountId.length==1 && this.dateValue[0].format('YYYY.MM.DD')!=this.dateValue[1].format('YYYY.MM.DD')){
  700. this.target='stat_Datetime',
  701. this.order='asc'
  702. }else{
  703. this.target='cost',
  704. this.order='desc'
  705. }
  706. this.tableHttp();
  707. }else{
  708. this.$message.error('请选择账户后再查询!');
  709. }
  710. },
  711. //重置
  712. resetgetData(){
  713. this.loading=false;
  714. // this.resetDisabled=true;
  715. this.searchDisabled=false;
  716. this.refreshDisabled=false;
  717. this.treeValue=[];
  718. // this.treeData=[];
  719. this.discountSelect=1.0;
  720. this.discountDisabled=false;
  721. this.rebatePropDisabled=false;
  722. this.rebateProp=1.0
  723. this.treeChange([]);
  724. this.tabCost={}
  725. this.tabPhotoClick={}
  726. this.tabPhotoShow={},
  727. this.tabDiscountCost={}
  728. this.tabAClick={}
  729. this.tableData=[];
  730. this.discountCostLink={};
  731. this.photoShowLink={};
  732. this.photoClickLink={};
  733. this.costLink={};
  734. this.aClickLink={};
  735. this.myChart.clear()
  736. this.dateValue=[moment(),moment()]
  737. },
  738. //打开日期框
  739. opendate(){
  740. this.openOptions=!this.openOptions;
  741. // console.log(this.openOptions)
  742. },
  743. opendateClose(){
  744. this.openOptions=false;
  745. // console.log(this.openOptions)
  746. },
  747. //请求chart数据
  748. chartHttp(params){
  749. return new Promise((resolve, reject) => {
  750. postAction('/ctop/kuaishou/dailyPage/report/chart', params).then(res => {
  751. // console.log(res)
  752. if (res.success) {
  753. this.loading = false
  754. this.refreshDisabled=false;
  755. this.resetDisabled=false;
  756. this.searchDisabled=false;
  757. // 待处理问题
  758. this.cost = res.result.costWeekLink
  759. this.click = res.result.clickWeekLink
  760. this.showNum = res.result.showNumWeekLink;
  761. //展示的五个块的数据
  762. this.discountCostLink=res.result.sumData.Sum.discountCostLink
  763. this.photoShowLink=res.result.sumData.Sum.photoShowLink
  764. this.photoClickLink=res.result.sumData.Sum.photoClickLink
  765. this.costLink=res.result.sumData.Sum.costLink
  766. this.aClickLink=res.result.sumData.Sum.aClickLink
  767. //chart的数据
  768. this.tabCost=JSON.parse(JSON.stringify(initDay))
  769. this.tabPhotoClick=JSON.parse(JSON.stringify(initDay))
  770. this.tabPhotoShow=JSON.parse(JSON.stringify(initDay))
  771. this.tabDiscountCost=JSON.parse(JSON.stringify(initDay))
  772. this.tabAClick=JSON.parse(JSON.stringify(initDay))
  773. let chartData=res.result.chartData;
  774. chartData.map((item,index)=>{
  775. if(item.statHour || item.statHour==0){
  776. //说明是查询 天 数据;
  777. // console.log('day')
  778. item.statHour=item.statHour>=10?`${item.statHour}:00` : `0${item.statHour}:00`
  779. if(this.dateValue[0].format('YYYY-MM-DD')==moment().format('YYYY-MM-DD')){
  780. //说明是今天
  781. this.tabPhotoClick.yesterday.y.push(item.photoClick)
  782. this.tabCost.yesterday.y.push(item.cost)
  783. this.tabPhotoShow.yesterday.y.push(item.photoShow)
  784. this.tabDiscountCost.yesterday.y.push(item.discountCost)
  785. this.tabAClick.yesterday.y.push(item.aClick);
  786. this.tabPhotoClick.x.push(item.statHour)
  787. this.tabCost.x.push(item.statHour)
  788. this.tabPhotoShow.x.push(item.statHour)
  789. this.tabDiscountCost.x.push(item.statHour)
  790. this.tabAClick.x.push(item.statHour);
  791. if(item.afterData){
  792. this.tabPhotoClick.today.y.push(item.afterData.photoClick)
  793. this.tabCost.today.y.push(item.afterData.cost)
  794. this.tabPhotoShow.today.y.push(item.afterData.photoShow)
  795. this.tabDiscountCost.today.y.push(item.afterData.discountCost)
  796. this.tabAClick.today.y.push(item.afterData.aClick)
  797. //环比
  798. this.tabPhotoClick.huanbi.y.push(item.afterData.photoClickProportion)
  799. // console.log((item.afterData.photoClickProportion*100).toFixed(2)+'%')
  800. this.tabCost.huanbi.y.push(item.afterData.costProportion)
  801. this.tabPhotoShow.huanbi.y.push(item.afterData.photoShowProportion)
  802. this.tabDiscountCost.huanbi.y.push(item.afterData.costProportion)
  803. this.tabAClick.huanbi.y.push(item.afterData.aClickProportion)
  804. }else{
  805. this.tabPhotoClick.today.y.push(0)
  806. this.tabCost.today.y.push(0)
  807. this.tabPhotoShow.today.y.push(0)
  808. this.tabDiscountCost.today.y.push(0)
  809. this.tabAClick.today.y.push(0)
  810. this.tabPhotoClick.huanbi.y.push(0)
  811. this.tabCost.huanbi.y.push(0)
  812. this.tabPhotoShow.huanbi.y.push(0)
  813. this.tabDiscountCost.huanbi.y.push(0)
  814. this.tabAClick.huanbi.y.push(0)
  815. }
  816. }else{
  817. if(item.afterData){
  818. this.tabPhotoClick.yesterday.y.push(item.afterData.photoClick)
  819. this.tabCost.yesterday.y.push(item.afterData.cost)
  820. this.tabPhotoShow.yesterday.y.push(item.afterData.photoShow)
  821. this.tabDiscountCost.yesterday.y.push(item.afterData.discountCost)
  822. this.tabAClick.yesterday.y.push(item.afterData.aClick);
  823. this.tabPhotoClick.x.push(item.afterData.statHour)
  824. this.tabCost.x.push(item.afterData.statHour)
  825. this.tabPhotoShow.x.push(item.afterData.statHour)
  826. this.tabDiscountCost.x.push(item.afterData.statHour)
  827. this.tabAClick.x.push(item.afterData.statHour);
  828. }
  829. }
  830. }else if(item.statDate){
  831. // console.log('date')
  832. this.tabPhotoClick.yesterday.y.push(item.photoClick)
  833. this.tabCost.yesterday.y.push(item.cost)
  834. this.tabPhotoShow.yesterday.y.push(item.photoShow)
  835. this.tabDiscountCost.yesterday.y.push(item.discountCost)
  836. this.tabAClick.yesterday.y.push(item.aClick);
  837. this.tabPhotoClick.x.push(item.statDate)
  838. this.tabCost.x.push(item.statDate)
  839. this.tabPhotoShow.x.push(item.statDate)
  840. this.tabDiscountCost.x.push(item.statDate)
  841. this.tabAClick.x.push(item.statDate);
  842. }
  843. })
  844. }
  845. this.callback(this.tabKey)
  846. })
  847. })
  848. },
  849. //请求项目和账户内容
  850. accountHttp(){
  851. this.treeData=[];
  852. this.treeValue=[];
  853. getAction('/ctop/projectMember/getProjectAccountByUserId?mediaType=2', {}).then(res => {
  854. if(res.success){
  855. // console.log(res);
  856. if(res.result){
  857. res.result.forEach((element,index) => {
  858. if(element){
  859. this.treeData.push({});
  860. this.treeData[index].title=element.project.projectName +'_('+ element.project.advertiserName +')';
  861. this.treeData[index].value='project'+element.project.projectId;
  862. this.treeData[index].key=element.project.projectId;
  863. this.treeData[index].mediaId=element.project.mediaId;
  864. this.treeData[index].children=[];
  865. if(element.account.length){
  866. element.account.forEach((ele,i)=>{
  867. this.treeData[index].children.push({});
  868. this.treeData[index].children[i].title=ele.userName+'_'+ele.authName+'_('+(ele.accountStatus?'已停投':'投放中')+')';
  869. this.treeData[index].children[i].value=ele.accountId;
  870. this.treeData[index].children[i].key=ele.accountId;
  871. this.treeData[index].children[i].accountStatus=ele.accountStatus;
  872. })
  873. }
  874. }
  875. });
  876. // console.log(this.treeData)
  877. }
  878. }
  879. })
  880. },
  881. //初始化echart
  882. getEchartData(idName, optionName) {
  883. const chart = this.$refs[idName]
  884. // console.log(chart)
  885. if (chart) {
  886. var myChart = echarts.init(document.getElementById(idName))
  887. myChart.clear()
  888. myChart.setOption(optionName)
  889. window.addEventListener('resize', function() {
  890. myChart.resize()
  891. })
  892. this.myChart=myChart
  893. }
  894. },
  895. //tab切换页的事件
  896. callback(key) {
  897. // console.log(key);
  898. this.tabKey=key;
  899. this.sectionOption=JSON.parse(JSON.stringify(sectionOption))
  900. if(key=='cost'){
  901. if(this.dateValue[0].format('YYYY-MM-DD')==moment().format('YYYY-MM-DD')){
  902. this.sectionOption.legend.data=['今天','昨天'];
  903. this.sectionOption.xAxis[0].data=this.tabCost.x;
  904. this.sectionOption.series[0].data=this.tabCost.today.y;
  905. this.sectionOption.series[0].name=this.tabCost.today.name;
  906. this.sectionOption.series[1].data=this.tabCost.yesterday.y;
  907. this.sectionOption.series[1].name=this.tabCost.yesterday.name;
  908. this.sectionOption.series[2].data=this.tabCost.huanbi.y;
  909. this.sectionOption.series[2].name=this.tabCost.huanbi.name;
  910. this.sectionOption.tooltip.formatter=(params)=>{
  911. // console.log(params)
  912. params[2].data=(params[2].data*100).toFixed(2)+'%'
  913. return `
  914. ${params[0].marker}今天:${params[0].data}<br />
  915. ${params[1].marker}昨天:${params[1].data}<br />
  916. ${params[2].marker}环比:${params[2].data}
  917. `
  918. }
  919. }else{
  920. this.sectionOption.legend.data=['总消耗'];
  921. this.sectionOption.xAxis[0].data=this.tabCost.x;
  922. this.sectionOption.series[0].data=this.tabCost.yesterday.y;
  923. this.sectionOption.series[0].name='总消耗';
  924. }
  925. }else if(key=='photoClick'){
  926. if(this.dateValue[0].format('YYYY-MM-DD')==moment().format('YYYY-MM-DD')){
  927. this.sectionOption.legend.data=['今天','昨天'];
  928. this.sectionOption.xAxis[0].data=this.tabPhotoClick.x;
  929. this.sectionOption.series[0].data=this.tabPhotoClick.today.y;
  930. this.sectionOption.series[0].name=this.tabPhotoClick.today.name;
  931. this.sectionOption.series[1].data=this.tabPhotoClick.yesterday.y;
  932. this.sectionOption.series[1].name=this.tabPhotoClick.yesterday.name;
  933. this.sectionOption.series[2].data=this.tabPhotoClick.huanbi.y;
  934. this.sectionOption.series[2].name=this.tabPhotoClick.huanbi.name;
  935. this.sectionOption.tooltip.formatter=(params)=>{
  936. // console.log(params)
  937. params[2].data=(params[2].data*100).toFixed(2)+'%'
  938. return `
  939. ${params[0].marker}今天:${params[0].data}<br />
  940. ${params[1].marker}昨天:${params[1].data}<br />
  941. ${params[2].marker}环比:${params[2].data}
  942. `
  943. }
  944. }else{
  945. this.sectionOption.legend.data=['封面点击数'];
  946. this.sectionOption.xAxis[0].data=this.tabPhotoClick.x;
  947. this.sectionOption.series[0].data=this.tabPhotoClick.yesterday.y;
  948. this.sectionOption.series[0].name='封面点击数';
  949. }
  950. }else if(key=='photoShow'){
  951. if(this.dateValue[0].format('YYYY-MM-DD')==moment().format('YYYY-MM-DD')){
  952. this.sectionOption.legend.data=['今天','昨天'];
  953. this.sectionOption.xAxis[0].data=this.tabPhotoShow.x;
  954. this.sectionOption.series[0].data=this.tabPhotoShow.today.y;
  955. this.sectionOption.series[0].name=this.tabPhotoShow.today.name;
  956. this.sectionOption.series[1].data=this.tabPhotoShow.yesterday.y;
  957. this.sectionOption.series[1].name=this.tabPhotoShow.yesterday.name;
  958. this.sectionOption.series[2].data=this.tabPhotoShow.huanbi.y;
  959. this.sectionOption.series[2].name=this.tabPhotoShow.huanbi.name;
  960. this.sectionOption.tooltip.formatter=(params)=>{
  961. // console.log(params)
  962. params[2].data=(params[2].data*100).toFixed(2)+'%'
  963. return `
  964. ${params[0].marker}今天:${params[0].data}<br />
  965. ${params[1].marker}昨天:${params[1].data}<br />
  966. ${params[2].marker}环比:${params[2].data}
  967. `
  968. }
  969. }else{
  970. this.sectionOption.legend.data=['封面曝光数'];
  971. this.sectionOption.xAxis[0].data=this.tabPhotoShow.x;
  972. this.sectionOption.series[0].data=this.tabPhotoShow.yesterday.y;
  973. this.sectionOption.series[0].name='封面曝光数';
  974. }
  975. }else if(key=='discountCost'){
  976. if(this.dateValue[0].format('YYYY-MM-DD')==moment().format('YYYY-MM-DD')){
  977. this.sectionOption.legend.data=['今天','昨天'];
  978. this.sectionOption.xAxis[0].data=this.tabDiscountCost.x;
  979. this.sectionOption.series[0].data=this.tabDiscountCost.today.y;
  980. this.sectionOption.series[0].name=this.tabDiscountCost.today.name;
  981. this.sectionOption.series[1].data=this.tabDiscountCost.yesterday.y;
  982. this.sectionOption.series[1].name=this.tabDiscountCost.yesterday.name;
  983. this.sectionOption.series[2].data=this.tabDiscountCost.huanbi.y;
  984. this.sectionOption.series[2].name=this.tabDiscountCost.huanbi.name;
  985. this.sectionOption.tooltip.formatter=(params)=>{
  986. // console.log(params)
  987. params[2].data=(params[2].data*100).toFixed(2)+'%'
  988. return `
  989. ${params[0].marker}今天:${params[0].data}<br />
  990. ${params[1].marker}昨天:${params[1].data}<br />
  991. ${params[2].marker}环比:${params[2].data}
  992. `
  993. }
  994. }else{
  995. this.sectionOption.legend.data=['折后消耗'];
  996. this.sectionOption.xAxis[0].data=this.tabDiscountCost.x;
  997. this.sectionOption.series[0].data=this.tabDiscountCost.yesterday.y;
  998. this.sectionOption.series[0].name='折后消耗';
  999. }
  1000. }else{
  1001. if(this.dateValue[0].format('YYYY-MM-DD')==moment().format('YYYY-MM-DD')){
  1002. this.sectionOption.legend.data=['今天','昨天'];
  1003. this.sectionOption.xAxis[0].data=this.tabAClick.x;
  1004. this.sectionOption.series[0].data=this.tabAClick.today.y;
  1005. this.sectionOption.series[0].name=this.tabAClick.today.name;
  1006. this.sectionOption.series[1].data=this.tabAClick.yesterday.y;
  1007. this.sectionOption.series[1].name=this.tabAClick.yesterday.name;
  1008. this.sectionOption.series[2].data=this.tabAClick.huanbi.y;
  1009. this.sectionOption.series[2].name=this.tabAClick.huanbi.name;
  1010. this.sectionOption.tooltip.formatter=(params)=>{
  1011. // console.log(params)
  1012. params[2].data=(params[2].data*100).toFixed(2)+'%'
  1013. return `
  1014. ${params[0].marker}今天:${params[0].data}<br />
  1015. ${params[1].marker}昨天:${params[1].data}<br />
  1016. ${params[2].marker}环比:${params[2].data}
  1017. `
  1018. }
  1019. }else{
  1020. this.sectionOption.legend.data=['素材曝光数'];
  1021. this.sectionOption.xAxis[0].data=this.tabAClick.x;
  1022. this.sectionOption.series[0].data=this.tabAClick.yesterday.y;
  1023. this.sectionOption.series[0].name='素材曝光数';
  1024. }
  1025. }
  1026. this.getEchartData('sectionChart', this.sectionOption)
  1027. },
  1028. //请求table的数据
  1029. tableHttp(params){
  1030. this.loading=true;
  1031. postAction('/ctop/kuaishou/dailyPage/report/list', {
  1032. mediaId:this.mediaId,
  1033. discount:this.discount,
  1034. accountIds:this.accountId,
  1035. startDate:this.dateValue[0].format('YYYY-MM-DD'),
  1036. endDate:this.dateValue[1].format('YYYY-MM-DD'),
  1037. hour:this.timeSelectValue,
  1038. target:this.target,
  1039. order:this.order
  1040. }).then(res => {
  1041. if(res.success){
  1042. this.loading=false;
  1043. // console.log(res)
  1044. res.result.forEach(element => {
  1045. if(this.timeValueString){
  1046. element.date=this.dateValue[0].format('YYYY.MM.DD')+'—'+this.timeValueString
  1047. }else{
  1048. if(this.accountId.length==1 && this.dateValue[0].format('YYYY.MM.DD')!=this.dateValue[1].format('YYYY.MM.DD')){
  1049. element.date=element.statDate;
  1050. }else{
  1051. element.date=this.dateValue[0].format('YYYY.MM.DD')+"-"+this.dateValue[1].format('YYYY.MM.DD')
  1052. }
  1053. }
  1054. });
  1055. if(this.dateValue[0].format('YYYY-MM-DD')==this.dateValue[1].format('YYYY-MM-DD')){
  1056. for(let i=res.result.length-1; i>res.result.length-4; i--){
  1057. res.result[i].authName='-';
  1058. res.result[i].accountId='-';
  1059. res.result[i].date='总计';
  1060. };
  1061. for(let key in res.result[res.result.length-1]){
  1062. if( res.result[res.result.length-1][key] < 1){
  1063. res.result[res.result.length-1][key]=(res.result[res.result.length-1][key]*100).toFixed(2)+'%'
  1064. }
  1065. }
  1066. res.result[res.result.length-1].date='环比';
  1067. res.result[res.result.length-2].date='昨日总计(相对)';
  1068. this.tableData=res.result
  1069. length =this.tableData.length-3;
  1070. }else{
  1071. res.result[res.result.length-1].date='总计';
  1072. res.result[res.result.length-1].authName='-';
  1073. res.result[res.result.length-1].accountId='-';
  1074. this.tableData=res.result
  1075. length =this.tableData.length-1;
  1076. }
  1077. }
  1078. })
  1079. },
  1080. //导出报表
  1081. exportExcel() {
  1082. let column = this.columns.map((item, index) => {
  1083. return item.dataIndex
  1084. })
  1085. let columns=column.splice(3)
  1086. // console.log(columns)
  1087. downFilePost('/ctop/kuaishou/dailyPage/report/excel', {
  1088. mediaId:this.mediaId,
  1089. discount:this.discount,
  1090. accountIds:this.accountId,
  1091. startDate:this.dateValue[0].format('YYYY-MM-DD'),
  1092. endDate:this.dateValue[1].format('YYYY-MM-DD'),
  1093. hour:this.timeSelectValue,
  1094. target:this.target,
  1095. order:this.order,
  1096. columns,
  1097. }).then(res => {
  1098. let blob = new Blob([res], {
  1099. type:'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
  1100. })
  1101. let downloadElement = document.createElement('a')
  1102. let href = window.URL.createObjectURL(blob) //创建下载的链接
  1103. downloadElement.href = href
  1104. downloadElement.download = moment().format('YYYY-MM-DD') + '账户报表.xlsx' //下载后文件名
  1105. document.body.appendChild(downloadElement)
  1106. downloadElement.click() //点击下载
  1107. document.body.removeChild(downloadElement) //下载完成移除元素
  1108. window.URL.revokeObjectURL(href) //释放掉blob对象
  1109. })
  1110. },
  1111. //弹出框打开,自定义列
  1112. customColumns() {
  1113. this.visible = true
  1114. this.listNum = [...this.columns]
  1115. },
  1116. //table选择时间函数
  1117. timeChange(value){
  1118. console.log(value);
  1119. this.timeSelectValue=value.key
  1120. this.timeValueString=value.label;
  1121. this.tableHttp()
  1122. },
  1123. //table 排序
  1124. sort(pagination, filters, sorter, { currentDataSource }){
  1125. console.log(pagination, filters, sorter)
  1126. if(this.accountId.length){
  1127. if(sorter.order == 'ascend'){
  1128. this.order='asc'
  1129. this.target=sorter.columnKey;
  1130. }else if(sorter.order == 'descend'){
  1131. this.order='desc'
  1132. this.target=sorter.columnKey;
  1133. }else{
  1134. if(this.accountId.length==1 && this.dateValue[0].format('YYYY.MM.DD')!=this.dateValue[1].format('YYYY.MM.DD')){
  1135. this.target='stat_Datetime',
  1136. this.order='asc'
  1137. }else{
  1138. this.target='cost',
  1139. this.order='desc'
  1140. }
  1141. }
  1142. this.tableHttp();
  1143. }
  1144. },
  1145. closeCustomColumn(){
  1146. this.visible=false;
  1147. },
  1148. //
  1149. discountChange(){
  1150. // console.log(this.discountSelect);
  1151. this.discount=this.discountSelect
  1152. },
  1153. rebatePropChange(){
  1154. // console.log(this.rebateProp)
  1155. this.discount=this.rebateProp
  1156. },
  1157. //自定义之后修改父元素表头
  1158. changeColumn(val){
  1159. this.columns=[...val];
  1160. if(this.columns.length> this.columnsFixd.length){
  1161. this.scrollX=2000+200*(this.columns.length-this.columnsFixd.length)
  1162. }else{
  1163. this.scrollX=2000
  1164. }
  1165. },
  1166. tableHandle() {
  1167. // this.listNum = [...this.columns]
  1168. // console.log(this.listNum.length, this.columns)
  1169. if (this.listNum.length >= 9 || this.columns.length >= 9) {
  1170. this.tableWidth = 160
  1171. this.scrollX = this.columns.length * 160
  1172. // console.log(this.scrollX)
  1173. } else {
  1174. this.scrollX = 2000
  1175. }
  1176. },
  1177. },
  1178. mounted() {
  1179. this.accountHttp()
  1180. new Promise((resolve, reject) => {
  1181. this.getEchartData('sectionChart', this.sectionOption)
  1182. resolve()
  1183. }).then(()=>{
  1184. this.myChart.clear()
  1185. })
  1186. postAction('/toutiao/videoReportDaily/getColumnJson', {
  1187. columnType: 6
  1188. }).then(res => {
  1189. // console.log(res)
  1190. if (res.success) {
  1191. // console.log(JSON.parse(res.result))
  1192. if(res.result){
  1193. let columns = JSON.parse(res.result)
  1194. if (columns.length) {
  1195. if (columns.length >= columnsFixd.length) {
  1196. columns.map((item, index) => {
  1197. if (index > columnsFixd.length - 1) {
  1198. item.sorter = function(a, b) {
  1199. return a[item.dataIndex] - b[item.dataIndex]
  1200. }
  1201. }
  1202. })
  1203. columns = columns.slice(columnsFixd.length)
  1204. this.columns = [...columnsFixd, ...columns]
  1205. this.tableHandle()
  1206. }
  1207. // console.log(this.columns)
  1208. }
  1209. }
  1210. }
  1211. })
  1212. },
  1213. beforeDestroy() {
  1214. let arr = JSON.stringify(this.columns)
  1215. postAction('/toutiao/videoReportDaily/saveOrUpdateColumnJson', {
  1216. json: arr,
  1217. columnType: 6
  1218. }).then(res => {
  1219. // console.log(res)
  1220. })
  1221. },
  1222. filters: {
  1223. toPercentage(val) {
  1224. if(val){
  1225. if(typeof val != 'string'){
  1226. return (val * 100).toFixed(2) + '%'
  1227. }else{
  1228. return val
  1229. }
  1230. }else if(typeof val =='string'){
  1231. return val
  1232. }
  1233. else{
  1234. return 0
  1235. }
  1236. },
  1237. //保留两位小数并且变成货币格式
  1238. decimalsHandle(val){
  1239. if(val && typeof val !='string'){
  1240. if(val>=0){
  1241. val=parseFloat(val).toFixed(2);
  1242. let numberStr = val.toString()
  1243. let str = numberStr.split('.')
  1244. let str0=str[0].split('').reverse();
  1245. for (let i = 0; i < str0.length; i++) {
  1246. if ((i + 1) % 4 === 0) {
  1247. str0.splice(i, 0, ',')
  1248. }
  1249. }
  1250. str0.reverse()
  1251. let handleResult = ''
  1252. for (let j = 0; j < str0.length; j++) {
  1253. handleResult += str0[j]
  1254. }
  1255. return handleResult+'.'+str[1]
  1256. }else{
  1257. val=parseFloat(val).toFixed(2);
  1258. let numberStr = val.toString()
  1259. let str = numberStr.split('.')
  1260. let str0=str[0].substr(1).split('').reverse();
  1261. for (let i = 0; i < str0.length; i++) {
  1262. if ((i + 1) % 4 === 0) {
  1263. str0.splice(i, 0, ',')
  1264. }
  1265. }
  1266. str0.reverse()
  1267. let handleResult = ''
  1268. for (let j = 0; j < str0.length; j++) {
  1269. handleResult += str0[j]
  1270. }
  1271. return '-'+handleResult+'.'+str[1]
  1272. }
  1273. }else if(typeof val =='string'){
  1274. return val
  1275. }
  1276. else{
  1277. return 0
  1278. }
  1279. },
  1280. //变成货币格式
  1281. formatCurrency(val){
  1282. if((val||val==0)&& typeof val !='string'){
  1283. let numberStr = val.toString()
  1284. let str = numberStr.split('').reverse()
  1285. for (let i = 0; i < str.length; i++) {
  1286. if ((i + 1) % 4 === 0) {
  1287. str.splice(i, 0, ',')
  1288. }
  1289. }
  1290. str.reverse()
  1291. let handleResult = ''
  1292. for (let j = 0; j < str.length; j++) {
  1293. handleResult += str[j]
  1294. }
  1295. return handleResult
  1296. }else if(typeof val =='string'){
  1297. return val
  1298. }
  1299. else{
  1300. return '-'
  1301. }
  1302. }
  1303. }
  1304. }
  1305. </script>
  1306. <style lang="scss">
  1307. .ant-tooltip-inner,.ant-tooltip,.ant-tooltip-arrow::before{
  1308. background-color: #fff;
  1309. color: #333;
  1310. }
  1311. </style>
  1312. <style lang="scss" scoped>
  1313. .accountReport {
  1314. .circul{
  1315. width: 5px;
  1316. height: 5px;
  1317. border-radius: 50%;
  1318. background-color: #32CD32;;
  1319. }
  1320. .optionLine:hover{
  1321. box-shadow: 0 0 15px rgba(0,0,0,.15);
  1322. border-radius: 10px;
  1323. }
  1324. .optionLine {
  1325. box-sizing: border-box;
  1326. padding: 15px 15px;
  1327. position: relative;
  1328. // margin: 20px 10px 15px;
  1329. margin-bottom: 15px;
  1330. background-color: #fff;
  1331. // border: 1px solid #ccc;
  1332. .optionTow{
  1333. margin-top: 15px;
  1334. position: relative;
  1335. .optItem{
  1336. display: inline-block;
  1337. margin-right: 15px;
  1338. span {
  1339. display: inline-block;
  1340. padding: 0 3px;
  1341. }
  1342. }
  1343. }
  1344. .btn {
  1345. position: absolute;
  1346. right: 0px;
  1347. top: 0px;
  1348. .mybtn{
  1349. margin-left: 10px;
  1350. }
  1351. }
  1352. }
  1353. .show{
  1354. // background-color: #fff;
  1355. width: 100%;
  1356. display: flex;
  1357. justify-content: space-between;
  1358. // padding: 0px 15px;
  1359. box-sizing: border-box;
  1360. .showBox {
  1361. width: 19%;
  1362. box-sizing: border-box;
  1363. padding: 15px 15px;
  1364. background-color: #fff;
  1365. .title {
  1366. color: #999;
  1367. font-size: 16px;
  1368. position: relative;
  1369. text-align: center;
  1370. .infotitle{
  1371. padding: 8px 0;
  1372. }
  1373. span {
  1374. font-size: 1rem;
  1375. // color: #1890ff;
  1376. position: absolute;
  1377. top: 0;
  1378. right: 0;
  1379. cursor: pointer;
  1380. }
  1381. }
  1382. .infoNum{
  1383. padding:10px 0;
  1384. text-align: center;
  1385. font-weight: 600;
  1386. font-size: 20px;
  1387. span{
  1388. font-weight: 600;
  1389. font-size: 16px;
  1390. }
  1391. .red{
  1392. font-size: 20px;
  1393. font-weight: 600;
  1394. color: red;
  1395. }
  1396. .green{
  1397. display: block;
  1398. text-align: center;
  1399. margin-left: 0.2rem;
  1400. font-size: 14px;
  1401. font-weight: 700;
  1402. color: #32CD32;
  1403. .huanbi{
  1404. // color:#999;
  1405. font-weight: 400;
  1406. font-size: 14px;
  1407. }
  1408. }
  1409. }
  1410. }
  1411. }
  1412. .chartBox{
  1413. background-color: #fff;
  1414. margin: 15px 0px;
  1415. padding: 2px 10px 30px;
  1416. }
  1417. .tableBox{
  1418. background-color: #fff;
  1419. margin: 15px 0px;
  1420. padding: 15px 10px;
  1421. .tableTop{
  1422. position: relative;
  1423. padding-bottom: 15px;
  1424. border-bottom: 1px solid #e0e0e0;
  1425. .selectTime{
  1426. margin-right: 20px;
  1427. }
  1428. .add{
  1429. position: absolute;
  1430. top: 0;
  1431. right: 0;
  1432. }
  1433. }
  1434. }
  1435. }
  1436. </style>