accountReport.vue 54 KB

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