accountReport.vue 52 KB

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