accountReport.vue 53 KB

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