KSAccountReport.vue 59 KB

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