accountReport.vue 55 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476
  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.discountCostLink={}
  623. this.photoShowLink={}
  624. this.photoClickLink={}
  625. this.costLink={}
  626. this.aClickLink={}
  627. this.loading=true;
  628. this.searchDisabled=true;
  629. this.tabCost={}
  630. this.tabClick={}
  631. this.tabShowNum={},
  632. this.tabDiscountCost={}
  633. this.tabconvertNum={}
  634. this.chartHttp({
  635. mediaId:this.mediaId,
  636. discount:this.discount,
  637. accountIds:this.accountId,
  638. startDate:this.dateValue[0].format('YYYY-MM-DD'),
  639. endDate:this.dateValue[1].format('YYYY-MM-DD')
  640. })
  641. if(this.accountId.length==1 && this.dateValue[0].format('YYYY.MM.DD')!=this.dateValue[1].format('YYYY.MM.DD')){
  642. this.target='stat_Datetime',
  643. this.order='asc'
  644. }else{
  645. this.target='cost',
  646. this.order='desc'
  647. }
  648. this.tableHttp();
  649. }else{
  650. this.$message.error('请选择账户后再查询!');
  651. }
  652. },
  653. //重置
  654. resetgetData(){
  655. this.loading=false;
  656. // this.resetDisabled=true;
  657. this.searchDisabled=false;
  658. this.refreshDisabled=false;
  659. this.treeValue=[];
  660. // this.treeData=[];
  661. this.discountSelect=1.0;
  662. this.discountDisabled=false;
  663. this.rebatePropDisabled=false;
  664. this.rebateProp=1.0
  665. this.treeChange([]);
  666. this.tabCost={}
  667. this.tabClick={}
  668. this.tabShowNum={},
  669. this.tabDiscountCost={}
  670. this.tabconvertNum={}
  671. this.tableData=[];
  672. this.discountCostLink={};
  673. this.showNumLink={};
  674. this.clickLink={};
  675. this.costLink={};
  676. this.convertNumLink={};
  677. this.myChart.clear()
  678. this.dateValue=[moment(),moment()]
  679. },
  680. //打开日期框
  681. opendate(){
  682. this.openOptions=!this.openOptions;
  683. // console.log(this.openOptions)
  684. },
  685. opendateClose(){
  686. this.openOptions=false;
  687. // console.log(this.openOptions)
  688. },
  689. //请求chart数据
  690. chartHttp(params){
  691. return new Promise((resolve, reject) => {
  692. postAction('/ctop/byteDance/dailyPage/report/chart', params).then(res => {
  693. // console.log(res)
  694. if (res.success) {
  695. this.loading = false
  696. this.refreshDisabled=false;
  697. this.resetDisabled=false;
  698. this.searchDisabled=false;
  699. this.cost = res.result.costWeekLink
  700. this.click = res.result.clickWeekLink
  701. this.showNum = res.result.showNumWeekLink;
  702. //展示的五个块的数据
  703. this.discountCostLink=res.result.sumData.Sum.discountCostLink
  704. this.showNumLink=res.result.sumData.Sum.showNumLink
  705. this.clickLink=res.result.sumData.Sum.clickLink
  706. this.costLink=res.result.sumData.Sum.costLink
  707. this.convertNumLink=res.result.sumData.Sum.convertNumLink
  708. //chart的数据
  709. this.tabCost=JSON.parse(JSON.stringify(initDay))
  710. this.tabClick=JSON.parse(JSON.stringify(initDay))
  711. this.tabShowNum=JSON.parse(JSON.stringify(initDay))
  712. this.tabDiscountCost=JSON.parse(JSON.stringify(initDay))
  713. this.tabconvertNum=JSON.parse(JSON.stringify(initDay))
  714. let chartData=res.result.chartData;
  715. chartData.map((item,index)=>{
  716. if(item.statHour || item.statHour==0){
  717. //说明是查询 天 数据;
  718. // console.log('day')
  719. item.statHour=item.statHour>=10?`${item.statHour}:00` : `0${item.statHour}:00`
  720. if(this.dateValue[0].format('YYYY-MM-DD')==moment().format('YYYY-MM-DD')){
  721. //说明是今天
  722. this.tabClick.yesterday.y.push(item.click)
  723. this.tabCost.yesterday.y.push(item.cost)
  724. this.tabShowNum.yesterday.y.push(item.showNum)
  725. this.tabDiscountCost.yesterday.y.push(item.discountCost)
  726. this.tabconvertNum.yesterday.y.push(item.convertNum);
  727. this.tabClick.x.push(item.statHour)
  728. this.tabCost.x.push(item.statHour)
  729. this.tabShowNum.x.push(item.statHour)
  730. this.tabDiscountCost.x.push(item.statHour)
  731. this.tabconvertNum.x.push(item.statHour);
  732. if(item.afterData){
  733. this.tabClick.today.y.push(item.afterData.click)
  734. this.tabCost.today.y.push(item.afterData.cost)
  735. this.tabShowNum.today.y.push(item.afterData.showNum)
  736. this.tabDiscountCost.today.y.push(item.afterData.discountCost)
  737. this.tabconvertNum.today.y.push(item.afterData.convertNum)
  738. //环比
  739. this.tabClick.huanbi.y.push(item.afterData.photoClickProportion)
  740. // console.log((item.afterData.photoClickProportion*100).toFixed(2)+'%')
  741. this.tabCost.huanbi.y.push(item.afterData.costProportion)
  742. this.tabShowNum.huanbi.y.push(item.afterData.showProportion)
  743. this.tabDiscountCost.huanbi.y.push(item.afterData.costProportion)
  744. this.tabconvertNum.huanbi.y.push(item.afterData.convertNumProportion)
  745. }else{
  746. this.tabClick.today.y.push(0)
  747. this.tabCost.today.y.push(0)
  748. this.tabShowNum.today.y.push(0)
  749. this.tabDiscountCost.today.y.push(0)
  750. this.tabconvertNum.today.y.push(0)
  751. this.tabClick.huanbi.y.push(0)
  752. this.tabCost.huanbi.y.push(0)
  753. this.tabShowNum.huanbi.y.push(0)
  754. this.tabDiscountCost.huanbi.y.push(0)
  755. this.tabconvertNum.huanbi.y.push(0)
  756. }
  757. }else{
  758. if(item.afterData){
  759. this.tabClick.yesterday.y.push(item.afterData.click)
  760. this.tabCost.yesterday.y.push(item.afterData.cost)
  761. this.tabShowNum.yesterday.y.push(item.afterData.showNum)
  762. this.tabDiscountCost.yesterday.y.push(item.afterData.discountCost)
  763. this.tabconvertNum.yesterday.y.push(item.afterData.convertNum);
  764. this.tabClick.x.push(item.afterData.statHour)
  765. this.tabCost.x.push(item.afterData.statHour)
  766. this.tabShowNum.x.push(item.afterData.statHour)
  767. this.tabDiscountCost.x.push(item.afterData.statHour)
  768. this.tabconvertNum.x.push(item.afterData.statHour);
  769. }
  770. }
  771. }else if(item.statDate){
  772. // console.log('date')
  773. this.tabClick.yesterday.y.push(item.click)
  774. this.tabCost.yesterday.y.push(item.cost)
  775. this.tabShowNum.yesterday.y.push(item.showNum)
  776. this.tabDiscountCost.yesterday.y.push(item.discountCost)
  777. this.tabconvertNum.yesterday.y.push(item.convertNum);
  778. this.tabClick.x.push(item.statDate)
  779. this.tabCost.x.push(item.statDate)
  780. this.tabShowNum.x.push(item.statDate)
  781. this.tabDiscountCost.x.push(item.statDate)
  782. this.tabconvertNum.x.push(item.statDate);
  783. }
  784. })
  785. }
  786. this.callback(this.tabKey)
  787. })
  788. })
  789. },
  790. //请求项目和账户内容
  791. accountHttp(){
  792. this.treeData=[];
  793. this.treeValue=[];
  794. getAction('/ctop/projectMember/getProjectAccountByUserId?mediaType=1', {}).then(res => {
  795. if(res.success){
  796. // console.log(res);
  797. if(res.result){
  798. res.result.forEach((element,index) => {
  799. if(element){
  800. this.treeData.push({});
  801. this.treeData[index].title=element.project.projectName +'_('+ element.project.advertiserName +')';
  802. this.treeData[index].value='project'+element.project.projectId;
  803. this.treeData[index].key=element.project.projectId;
  804. this.treeData[index].mediaId=element.project.mediaId;
  805. this.treeData[index].children=[];
  806. if(element.account.length){
  807. element.account.forEach((ele,i)=>{
  808. this.treeData[index].children.push({});
  809. this.treeData[index].children[i].title=ele.userName+'_'+ele.authName+'_('+(ele.accountStatus?'已停投':'投放中')+')';
  810. this.treeData[index].children[i].value=ele.accountId;
  811. this.treeData[index].children[i].key=ele.accountId;
  812. // this.treeData[index].children[i].accountStatus=ele.accountStatus;
  813. })
  814. }
  815. }
  816. });
  817. // console.log(this.treeData)
  818. }
  819. }
  820. })
  821. },
  822. //初始化echart
  823. getEchartData(idName, optionName) {
  824. const chart = this.$refs[idName]
  825. // console.log(chart)
  826. if (chart) {
  827. var myChart = echarts.init(document.getElementById(idName))
  828. myChart.clear()
  829. myChart.setOption(optionName)
  830. window.addEventListener('resize', function() {
  831. myChart.resize()
  832. })
  833. this.myChart=myChart
  834. }
  835. },
  836. //tab切换页的事件
  837. callback(key) {
  838. // console.log(key);
  839. this.tabKey=key;
  840. this.sectionOption=JSON.parse(JSON.stringify(sectionOption))
  841. if(key=='cost'){
  842. if(this.dateValue[0].format('YYYY-MM-DD')==moment().format('YYYY-MM-DD')){
  843. this.sectionOption.legend.data=['今天','昨天'];
  844. this.sectionOption.xAxis[0].data=this.tabCost.x;
  845. this.sectionOption.series[0].data=this.tabCost.today.y;
  846. this.sectionOption.series[0].name=this.tabCost.today.name;
  847. this.sectionOption.series[1].data=this.tabCost.yesterday.y;
  848. this.sectionOption.series[1].name=this.tabCost.yesterday.name;
  849. this.sectionOption.series[2].data=this.tabCost.huanbi.y;
  850. this.sectionOption.series[2].name=this.tabCost.huanbi.name;
  851. this.sectionOption.tooltip.formatter=(params)=>{
  852. // console.log(params)
  853. params[2].data=(params[2].data*100).toFixed(2)+'%'
  854. return `
  855. ${params[0].marker}今天:${params[0].data}<br />
  856. ${params[1].marker}昨天:${params[1].data}<br />
  857. ${params[2].marker}环比:${params[2].data}
  858. `
  859. }
  860. }else{
  861. this.sectionOption.legend.data=['总消耗'];
  862. this.sectionOption.xAxis[0].data=this.tabCost.x;
  863. this.sectionOption.series[0].data=this.tabCost.yesterday.y;
  864. this.sectionOption.series[0].name='总消耗';
  865. }
  866. }else if(key=='click'){
  867. if(this.dateValue[0].format('YYYY-MM-DD')==moment().format('YYYY-MM-DD')){
  868. this.sectionOption.legend.data=['今天','昨天'];
  869. this.sectionOption.xAxis[0].data=this.tabClick.x;
  870. this.sectionOption.series[0].data=this.tabClick.today.y;
  871. this.sectionOption.series[0].name=this.tabClick.today.name;
  872. this.sectionOption.series[1].data=this.tabClick.yesterday.y;
  873. this.sectionOption.series[1].name=this.tabClick.yesterday.name;
  874. this.sectionOption.series[2].data=this.tabClick.huanbi.y;
  875. this.sectionOption.series[2].name=this.tabClick.huanbi.name;
  876. this.sectionOption.tooltip.formatter=(params)=>{
  877. // console.log(params)
  878. params[2].data=(params[2].data*100).toFixed(2)+'%'
  879. return `
  880. ${params[0].marker}今天:${params[0].data}<br />
  881. ${params[1].marker}昨天:${params[1].data}<br />
  882. ${params[2].marker}环比:${params[2].data}
  883. `
  884. }
  885. }else{
  886. this.sectionOption.legend.data=['点击数'];
  887. this.sectionOption.xAxis[0].data=this.tabClick.x;
  888. this.sectionOption.series[0].data=this.tabClick.yesterday.y;
  889. this.sectionOption.series[0].name='点击数';
  890. }
  891. }else if(key=='showNum'){
  892. if(this.dateValue[0].format('YYYY-MM-DD')==moment().format('YYYY-MM-DD')){
  893. this.sectionOption.legend.data=['今天','昨天'];
  894. this.sectionOption.xAxis[0].data=this.tabShowNum.x;
  895. this.sectionOption.series[0].data=this.tabShowNum.today.y;
  896. this.sectionOption.series[0].name=this.tabShowNum.today.name;
  897. this.sectionOption.series[1].data=this.tabShowNum.yesterday.y;
  898. this.sectionOption.series[1].name=this.tabShowNum.yesterday.name;
  899. this.sectionOption.series[2].data=this.tabShowNum.huanbi.y;
  900. this.sectionOption.series[2].name=this.tabShowNum.huanbi.name;
  901. this.sectionOption.tooltip.formatter=(params)=>{
  902. // console.log(params)
  903. params[2].data=(params[2].data*100).toFixed(2)+'%'
  904. return `
  905. ${params[0].marker}今天:${params[0].data}<br />
  906. ${params[1].marker}昨天:${params[1].data}<br />
  907. ${params[2].marker}环比:${params[2].data}
  908. `
  909. }
  910. }else{
  911. this.sectionOption.legend.data=['展示数'];
  912. this.sectionOption.xAxis[0].data=this.tabShowNum.x;
  913. this.sectionOption.series[0].data=this.tabShowNum.yesterday.y;
  914. this.sectionOption.series[0].name='展示数';
  915. }
  916. }else if(key=='discountCost'){
  917. if(this.dateValue[0].format('YYYY-MM-DD')==moment().format('YYYY-MM-DD')){
  918. this.sectionOption.legend.data=['今天','昨天'];
  919. this.sectionOption.xAxis[0].data=this.tabDiscountCost.x;
  920. this.sectionOption.series[0].data=this.tabDiscountCost.today.y;
  921. this.sectionOption.series[0].name=this.tabDiscountCost.today.name;
  922. this.sectionOption.series[1].data=this.tabDiscountCost.yesterday.y;
  923. this.sectionOption.series[1].name=this.tabDiscountCost.yesterday.name;
  924. this.sectionOption.series[2].data=this.tabDiscountCost.huanbi.y;
  925. this.sectionOption.series[2].name=this.tabDiscountCost.huanbi.name;
  926. this.sectionOption.tooltip.formatter=(params)=>{
  927. // console.log(params)
  928. params[2].data=(params[2].data*100).toFixed(2)+'%'
  929. return `
  930. ${params[0].marker}今天:${params[0].data}<br />
  931. ${params[1].marker}昨天:${params[1].data}<br />
  932. ${params[2].marker}环比:${params[2].data}
  933. `
  934. }
  935. }else{
  936. this.sectionOption.legend.data=['折后消耗'];
  937. this.sectionOption.xAxis[0].data=this.tabDiscountCost.x;
  938. this.sectionOption.series[0].data=this.tabDiscountCost.yesterday.y;
  939. this.sectionOption.series[0].name='折后消耗';
  940. }
  941. }else{
  942. if(this.dateValue[0].format('YYYY-MM-DD')==moment().format('YYYY-MM-DD')){
  943. this.sectionOption.legend.data=['今天','昨天'];
  944. this.sectionOption.xAxis[0].data=this.tabconvertNum.x;
  945. this.sectionOption.series[0].data=this.tabconvertNum.today.y;
  946. this.sectionOption.series[0].name=this.tabconvertNum.today.name;
  947. this.sectionOption.series[1].data=this.tabconvertNum.yesterday.y;
  948. this.sectionOption.series[1].name=this.tabconvertNum.yesterday.name;
  949. this.sectionOption.series[2].data=this.tabconvertNum.huanbi.y;
  950. this.sectionOption.series[2].name=this.tabconvertNum.huanbi.name;
  951. this.sectionOption.tooltip.formatter=(params)=>{
  952. // console.log(params)
  953. params[2].data=(params[2].data*100).toFixed(2)+'%'
  954. return `
  955. ${params[0].marker}今天:${params[0].data}<br />
  956. ${params[1].marker}昨天:${params[1].data}<br />
  957. ${params[2].marker}环比:${params[2].data}
  958. `
  959. }
  960. }else{
  961. this.sectionOption.legend.data=['转化数'];
  962. this.sectionOption.xAxis[0].data=this.tabconvertNum.x;
  963. this.sectionOption.series[0].data=this.tabconvertNum.yesterday.y;
  964. this.sectionOption.series[0].name='转化数';
  965. }
  966. }
  967. this.getEchartData('sectionChart', this.sectionOption)
  968. },
  969. //请求table的数据
  970. tableHttp(params){
  971. this.loading=true;
  972. postAction('/ctop/byteDance/dailyPage/report/list', {
  973. mediaId:this.mediaId,
  974. discount:this.discount,
  975. accountIds:this.accountId,
  976. startDate:this.dateValue[0].format('YYYY-MM-DD'),
  977. endDate:this.dateValue[1].format('YYYY-MM-DD'),
  978. hour:this.timeSelectValue,
  979. target:this.target,
  980. order:this.order
  981. }).then(res => {
  982. if(res.success){
  983. this.loading=false;
  984. // console.log(res)
  985. res.result.forEach(element => {
  986. if(this.timeValueString){
  987. element.date=this.dateValue[0].format('YYYY.MM.DD')+'—'+this.timeValueString
  988. }else{
  989. if(this.accountId.length==1 && this.dateValue[0].format('YYYY.MM.DD')!=this.dateValue[1].format('YYYY.MM.DD')){
  990. element.date=element.statDate;
  991. }else{
  992. element.date=this.dateValue[0].format('YYYY.MM.DD')+"-"+this.dateValue[1].format('YYYY.MM.DD')
  993. }
  994. }
  995. });
  996. if(this.dateValue[0].format('YYYY-MM-DD')==this.dateValue[1].format('YYYY-MM-DD')){
  997. for(let i=res.result.length-1; i>res.result.length-4; i--){
  998. res.result[i].authName='-';
  999. res.result[i].accountId='-';
  1000. res.result[i].date='总计';
  1001. };
  1002. for(let key in res.result[res.result.length-1]){
  1003. if( res.result[res.result.length-1][key] < 1){
  1004. res.result[res.result.length-1][key]=(res.result[res.result.length-1][key]*100).toFixed(2)+'%'
  1005. }
  1006. }
  1007. res.result[res.result.length-1].date='环比';
  1008. res.result[res.result.length-2].date='昨日总计(相对)';
  1009. this.tableData=res.result
  1010. length =this.tableData.length-3;
  1011. }else{
  1012. res.result[res.result.length-1].date='总计';
  1013. res.result[res.result.length-1].authName='-';
  1014. res.result[res.result.length-1].accountId='-';
  1015. this.tableData=res.result
  1016. length =this.tableData.length-1;
  1017. }
  1018. }
  1019. })
  1020. },
  1021. //导出报表
  1022. exportExcel() {
  1023. let column = this.columns.map((item, index) => {
  1024. return item.dataIndex
  1025. })
  1026. let columns=column.splice(3)
  1027. console.log(columns)
  1028. downFilePost('/ctop/byteDance/dailyPage/report/excel', {
  1029. mediaId:this.mediaId,
  1030. discount:this.discount,
  1031. accountIds:this.accountId,
  1032. startDate:this.dateValue[0].format('YYYY-MM-DD'),
  1033. endDate:this.dateValue[1].format('YYYY-MM-DD'),
  1034. hour:this.timeSelectValue,
  1035. target:this.target,
  1036. order:this.order,
  1037. columns,
  1038. }).then(res => {
  1039. let blob = new Blob([res], {
  1040. type:'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
  1041. })
  1042. let downloadElement = document.createElement('a')
  1043. let href = window.URL.createObjectURL(blob) //创建下载的链接
  1044. downloadElement.href = href
  1045. downloadElement.download = moment().format('YYYY-MM-DD') + '账户报表.xlsx' //下载后文件名
  1046. document.body.appendChild(downloadElement)
  1047. downloadElement.click() //点击下载
  1048. document.body.removeChild(downloadElement) //下载完成移除元素
  1049. window.URL.revokeObjectURL(href) //释放掉blob对象
  1050. })
  1051. },
  1052. //弹出框打开,自定义列
  1053. customColumns() {
  1054. this.visible = true
  1055. this.listNum = [...this.columns]
  1056. },
  1057. //table选择时间函数
  1058. timeChange(value){
  1059. console.log(value);
  1060. this.timeSelectValue=value.key
  1061. this.timeValueString=value.label;
  1062. this.tableHttp()
  1063. },
  1064. //table 排序
  1065. sort(pagination, filters, sorter, { currentDataSource }){
  1066. console.log(pagination, filters, sorter)
  1067. if(sorter.order == 'ascend'){
  1068. this.order='asc'
  1069. this.target=sorter.columnKey;
  1070. }else if(sorter.order == 'descend'){
  1071. this.order='desc'
  1072. this.target=sorter.columnKey;
  1073. }else{
  1074. if(this.accountId.length==1 && this.dateValue[0].format('YYYY.MM.DD')!=this.dateValue[1].format('YYYY.MM.DD')){
  1075. this.target='stat_Datetime',
  1076. this.order='asc'
  1077. }else{
  1078. this.target='cost',
  1079. this.order='desc'
  1080. }
  1081. }
  1082. this.tableHttp();
  1083. },
  1084. closeCustomColumn(){
  1085. this.visible=false;
  1086. },
  1087. //
  1088. discountChange(){
  1089. console.log(this.discountSelect);
  1090. this.discount=this.discountSelect
  1091. },
  1092. rebatePropChange(){
  1093. console.log(this.rebateProp)
  1094. this.discount=this.rebateProp
  1095. },
  1096. //自定义之后修改父元素表头
  1097. changeColumn(val){
  1098. this.columns=[...val];
  1099. if(this.columns.length> this.columnsFixd.length){
  1100. this.scrollX=2000+200*(this.columns.length-this.columnsFixd.length)
  1101. }else{
  1102. this.scrollX=0
  1103. }
  1104. },
  1105. tableHandle() {
  1106. // this.listNum = [...this.columns]
  1107. // console.log(this.listNum.length, this.columns)
  1108. if (this.listNum.length >= 9 || this.columns.length >= 9) {
  1109. this.tableWidth = 160
  1110. this.scrollX = this.columns.length * 160
  1111. // console.log(this.scrollX)
  1112. } else {
  1113. this.scrollX = 0
  1114. }
  1115. },
  1116. },
  1117. mounted() {
  1118. this.accountHttp()
  1119. new Promise((resolve, reject) => {
  1120. this.getEchartData('sectionChart', this.sectionOption)
  1121. resolve()
  1122. }).then(()=>{
  1123. this.myChart.clear()
  1124. })
  1125. postAction('/toutiao/videoReportDaily/getColumnJson', {
  1126. columnType: 5
  1127. }).then(res => {
  1128. // console.log(res)
  1129. if (res.success) {
  1130. // console.log(JSON.parse(res.result))
  1131. if(res.result){
  1132. let columns = JSON.parse(res.result)
  1133. if (columns.length) {
  1134. if (columns.length >= columnsFixd.length) {
  1135. columns.map((item, index) => {
  1136. if (index > columnsFixd.length - 1) {
  1137. item.sorter = function(a, b) {
  1138. return a[item.dataIndex] - b[item.dataIndex]
  1139. }
  1140. }
  1141. })
  1142. columns = columns.slice(columnsFixd.length)
  1143. this.columns = [...columnsFixd, ...columns]
  1144. this.tableHandle()
  1145. }
  1146. // console.log(this.columns)
  1147. }
  1148. }
  1149. }
  1150. })
  1151. },
  1152. beforeDestroy() {
  1153. let arr = JSON.stringify(this.columns)
  1154. postAction('/toutiao/videoReportDaily/saveOrUpdateColumnJson', {
  1155. json: arr,
  1156. columnType: 5
  1157. }).then(res => {
  1158. // console.log(res)
  1159. })
  1160. },
  1161. filters: {
  1162. toPercentage(val) {
  1163. if(val){
  1164. if(typeof val != 'string'){
  1165. return (val * 100).toFixed(2) + '%'
  1166. }else{
  1167. return val
  1168. }
  1169. }else if(typeof val =='string'){
  1170. return val
  1171. }
  1172. else{
  1173. return 0
  1174. }
  1175. },
  1176. //保留两位小数并且变成货币格式
  1177. decimalsHandle(val){
  1178. if(val && typeof val !='string'){
  1179. if(val>=0){
  1180. val=parseFloat(val).toFixed(2);
  1181. let numberStr = val.toString()
  1182. let str = numberStr.split('.')
  1183. let str0=str[0].split('').reverse();
  1184. for (let i = 0; i < str0.length; i++) {
  1185. if ((i + 1) % 4 === 0) {
  1186. str0.splice(i, 0, ',')
  1187. }
  1188. }
  1189. str0.reverse()
  1190. let handleResult = ''
  1191. for (let j = 0; j < str0.length; j++) {
  1192. handleResult += str0[j]
  1193. }
  1194. return handleResult+'.'+str[1]
  1195. }else{
  1196. val=parseFloat(val).toFixed(2);
  1197. let numberStr = val.toString()
  1198. let str = numberStr.split('.')
  1199. let str0=str[0].substr(1).split('').reverse();
  1200. for (let i = 0; i < str0.length; i++) {
  1201. if ((i + 1) % 4 === 0) {
  1202. str0.splice(i, 0, ',')
  1203. }
  1204. }
  1205. str0.reverse()
  1206. let handleResult = ''
  1207. for (let j = 0; j < str0.length; j++) {
  1208. handleResult += str0[j]
  1209. }
  1210. return '-'+handleResult+'.'+str[1]
  1211. }
  1212. }else if(typeof val =='string'){
  1213. return val
  1214. }
  1215. else{
  1216. return 0
  1217. }
  1218. },
  1219. //变成货币格式
  1220. formatCurrency(val){
  1221. if((val||val==0)&& typeof val !='string'){
  1222. let numberStr = val.toString()
  1223. let str = numberStr.split('').reverse()
  1224. for (let i = 0; i < str.length; i++) {
  1225. if ((i + 1) % 4 === 0) {
  1226. str.splice(i, 0, ',')
  1227. }
  1228. }
  1229. str.reverse()
  1230. let handleResult = ''
  1231. for (let j = 0; j < str.length; j++) {
  1232. handleResult += str[j]
  1233. }
  1234. return handleResult
  1235. }else if(typeof val =='string'){
  1236. return val
  1237. }
  1238. else{
  1239. return '-'
  1240. }
  1241. }
  1242. }
  1243. }
  1244. </script>
  1245. <style lang="scss">
  1246. .ant-tooltip-inner,.ant-tooltip,.ant-tooltip-arrow::before{
  1247. background-color: #fff;
  1248. color: #333;
  1249. }
  1250. </style>
  1251. <style lang="scss" scoped>
  1252. .accountReport {
  1253. .circul{
  1254. width: 5px;
  1255. height: 5px;
  1256. border-radius: 50%;
  1257. background-color: #32CD32;;
  1258. }
  1259. .optionLine:hover{
  1260. box-shadow: 0 0 15px rgba(0,0,0,.15);
  1261. border-radius: 10px;
  1262. }
  1263. .optionLine {
  1264. box-sizing: border-box;
  1265. padding: 15px 15px;
  1266. position: relative;
  1267. // margin: 20px 15px 15px;
  1268. margin-bottom: 15px;
  1269. background-color: #fff;
  1270. // border: 1px solid #ccc;
  1271. .optionTow{
  1272. margin-top: 15px;
  1273. position: relative;
  1274. .optItem{
  1275. display: inline-block;
  1276. margin-right: 15px;
  1277. span {
  1278. display: inline-block;
  1279. padding: 0 3px;
  1280. }
  1281. }
  1282. }
  1283. .btn {
  1284. position: absolute;
  1285. right: 0px;
  1286. top: 0px;
  1287. .mybtn{
  1288. margin-left: 10px;
  1289. }
  1290. }
  1291. }
  1292. .show{
  1293. // background-color: #fff;
  1294. width: 100%;
  1295. display: flex;
  1296. justify-content: space-between;
  1297. // padding: 0px 15px;
  1298. box-sizing: border-box;
  1299. .showBox {
  1300. width: 19%;
  1301. box-sizing: border-box;
  1302. padding: 15px 15px;
  1303. background-color: #fff;
  1304. .title {
  1305. color: #999;
  1306. font-size: 16px;
  1307. position: relative;
  1308. text-align: center;
  1309. .infotitle{
  1310. padding: 8px 0;
  1311. }
  1312. span {
  1313. font-size: 1rem;
  1314. // color: #1890ff;
  1315. position: absolute;
  1316. top: 0;
  1317. right: 0;
  1318. cursor: pointer;
  1319. }
  1320. }
  1321. .infoNum{
  1322. padding:10px 0;
  1323. text-align: center;
  1324. font-weight: 600;
  1325. font-size: 20px;
  1326. span{
  1327. font-weight: 600;
  1328. font-size: 16px;
  1329. }
  1330. .red{
  1331. font-size: 20px;
  1332. font-weight: 600;
  1333. color: red;
  1334. }
  1335. .green{
  1336. display: block;
  1337. text-align: center;
  1338. margin-left: 0.2rem;
  1339. font-size: 14px;
  1340. font-weight: 700;
  1341. color: #32CD32;
  1342. .huanbi{
  1343. // color:#999;
  1344. font-weight: 400;
  1345. font-size: 14px;
  1346. }
  1347. }
  1348. }
  1349. }
  1350. }
  1351. .chartBox{
  1352. background-color: #fff;
  1353. margin: 15px 0px;
  1354. padding: 2px 10px 30px;
  1355. }
  1356. .tableBox{
  1357. background-color: #fff;
  1358. margin: 15px 0px;
  1359. padding: 15px 10px;
  1360. .tableTop{
  1361. position: relative;
  1362. padding-bottom: 15px;
  1363. border-bottom: 1px solid #e0e0e0;
  1364. .selectTime{
  1365. margin-right: 20px;
  1366. }
  1367. .add{
  1368. position: absolute;
  1369. top: 0;
  1370. right: 0;
  1371. }
  1372. }
  1373. }
  1374. }
  1375. </style>