dayStatistics.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660
  1. <style lang="scss" scoped>
  2. .search-bar {
  3. display: flex;
  4. align-items: center;
  5. }
  6. .search-box p {
  7. display: inline-block;
  8. border: 1px solid #f2f2f2;
  9. border-radius: 5px;
  10. margin-right: 10px;
  11. padding: 5px 10px;
  12. cursor: pointer;
  13. }
  14. </style>
  15. <style>
  16. /* .data-display-statistics .ant-card-body {
  17. padding: 0 15px;
  18. } */
  19. .data-display-statistics .ant-col-6 {
  20. margin: 10px 0;
  21. }
  22. .data-display-statistics .ant-col-6 .ant-card-body {
  23. display: flex;
  24. justify-content: center;
  25. }
  26. .data-display-statistics .ant-col-6 p,
  27. .data-display-statistics .ant-col-6 span {
  28. text-align: center;
  29. line-height: 40px;
  30. font-size: 30px;
  31. font-weight: 600;
  32. color: red;
  33. margin: 0;
  34. }
  35. .search-box .ant-card-body {
  36. padding: 5px 15px;
  37. }
  38. .data-display-statistics .ant-col-6 .ant-card-body .styleElse {
  39. line-height: 60px;
  40. height: 40px;
  41. font-size: 16px;
  42. font-weight: 400;
  43. margin-left: 10px;
  44. }
  45. .ant-modal-wrap .yincang .ant-modal-content .ant-modal-footer {
  46. display: none !important;
  47. }
  48. .yincang .ant-col-6 p {
  49. text-align: left;
  50. color: red;
  51. font-size: 16px;
  52. font-weight: 500;
  53. }
  54. .ant-table-thead div {
  55. font-weight: 700;
  56. }
  57. .tool-tip {
  58. position: absolute;
  59. top: 65px;
  60. right: 10px;
  61. }
  62. th div {
  63. white-space: nowrap;
  64. }
  65. </style>
  66. <template>
  67. <div class="data-statistics">
  68. <a-row class="image-list-heading vm-panel">
  69. <a-row type="flex" align="middle" justify="space-between" class="panel-body">
  70. <div class="search-bar" style="width:100%">
  71. <span>账户选择:</span>
  72. <a-select
  73. v-model="projectId"
  74. style="width:500px"
  75. showSearch
  76. optionFilterProp="children"
  77. :filterOption="filterOption"
  78. >
  79. <a-select-option :value="item.projectId" v-for="item of dataElse" :key="item.projectId">
  80. {{ item.projectName }}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{{ item.advertiserName }}
  81. </a-select-option>
  82. </a-select>
  83. <span style="margin-left:10px">日期选择:</span>
  84. <a-date-picker v-model="statDate" format="YYYY-MM-DD" :defaultValue="moment().subtract(1, 'days')" />
  85. <span style="margin-left:10px">返点比例:</span>
  86. <a-input-number
  87. :min="1"
  88. :max="10"
  89. :step="0.01"
  90. v-model="discount"
  91. placeholder="请输入折扣"
  92. style="width:100px"
  93. />
  94. <a-button type="primary" style="margin:10px" @click="addUser">搜索</a-button>
  95. <a-button
  96. type="primary"
  97. icon="reload"
  98. @click="getDataReset"
  99. style="background-color:#67c23a;border-color:#67c23a"
  100. >刷新</a-button
  101. >
  102. </div>
  103. </a-row>
  104. </a-row>
  105. <a-row :gutter="10" style="margin-top:10px">
  106. <a-col :span="24">
  107. <a-card
  108. style="width:100%"
  109. :tabList="tabListNoTitle"
  110. :activeTabKey="noTitleKey"
  111. @tabChange="key => onTabChange(key, 'noTitleKey')"
  112. >
  113. <div style="display:flex;margin-bottom:15px">
  114. <!-- <a-select style="width: 120px" v-model="statHour" @change="getElseData" allowClear>
  115. <a-select-option v-for="item of 24" :key="item - 1" :value="item - 1">{{ item - 1 }}</a-select-option>
  116. </a-select> -->
  117. <a-button type="primary" @click="exportExcel">导出</a-button>
  118. </div>
  119. <a-table
  120. size="middle"
  121. :columns="columns"
  122. :dataSource="data"
  123. bordered
  124. id="outTable"
  125. :pagination="ipagination"
  126. :scroll="{ x: 2000 }"
  127. :loading="loading"
  128. >
  129. </a-table>
  130. </a-card>
  131. </a-col>
  132. </a-row>
  133. </div>
  134. </template>
  135. <script>
  136. import ARow from 'ant-design-vue/es/grid/Row'
  137. import ACol from 'ant-design-vue/es/grid/Col'
  138. import countTo from 'vue-count-to'
  139. import moment from 'moment'
  140. import { getDailyReport } from '@api/statistics'
  141. import { getAction, postAction, downFile, downFilePost } from '@/api/manage'
  142. import axios from 'axios'
  143. import lifting from '../components/lifting'
  144. import timeCheck from '../components/timeCheck'
  145. import Treeselect from '../components/Treeselect.vue'
  146. import { mapGetters } from 'vuex'
  147. import { JeecgListMixin } from '@/mixins/ipagination'
  148. var length = 0
  149. var active = 1
  150. const columns = [
  151. {
  152. title: '代理商',
  153. dataIndex: 'agent',
  154. scopedSlots: { customRender: 'agent' },
  155. align: 'center'
  156. },
  157. {
  158. title: '媒体',
  159. dataIndex: 'media',
  160. scopedSlots: { customRender: 'media' },
  161. align: 'center'
  162. },
  163. {
  164. title: '设备',
  165. dataIndex: 'systemType',
  166. align: 'center'
  167. },
  168. {
  169. title: '日期',
  170. dataIndex: 'statDate',
  171. align: 'center'
  172. },
  173. {
  174. title: '渠道包',
  175. dataIndex: 'campaignName',
  176. align: 'center'
  177. },
  178. {
  179. title: '账面花费',
  180. dataIndex: 'charge',
  181. align: 'center',
  182. scopedSlots: { customRender: 'charge' }
  183. },
  184. {
  185. title: '现金花费',
  186. dataIndex: 'cashCost',
  187. align: 'center',
  188. scopedSlots: { customRender: 'cashCost' }
  189. },
  190. {
  191. title: '曝光',
  192. dataIndex: 'photoShow',
  193. align: 'center',
  194. scopedSlots: { customRender: 'photoShow' }
  195. },
  196. {
  197. title: '点击',
  198. dataIndex: 'photoClick',
  199. align: 'center',
  200. scopedSlots: { customRender: 'photoClick' }
  201. },
  202. {
  203. title: '点击率',
  204. dataIndex: 'clickRate',
  205. align: 'center',
  206. scopedSlots: { customRender: 'clickRate' }
  207. },
  208. {
  209. title: '千次嚗光花费',
  210. dataIndex: 'impression1kCost',
  211. align: 'center',
  212. scopedSlots: { customRender: 'impression1kCost' }
  213. },
  214. {
  215. title: '行为量',
  216. dataIndex: 'bclick',
  217. align: 'center',
  218. scopedSlots: { customRender: 'bclick' }
  219. },
  220. {
  221. title: '下载完成数',
  222. dataIndex: 'eventJinJianApp',
  223. align: 'center',
  224. scopedSlots: { customRender: 'eventJinJianApp' }
  225. },
  226. {
  227. title: '账户激活量',
  228. dataIndex: 'activation',
  229. align: 'center',
  230. scopedSlots: { customRender: 'activation' }
  231. },
  232. {
  233. title: '友盟激活量',
  234. dataIndex: 'youMengactivation',
  235. align: 'center',
  236. scopedSlots: { customRender: 'youMengactivation' }
  237. },
  238. {
  239. title: 'TD激活量',
  240. dataIndex: 'tdActivation',
  241. align: 'center',
  242. scopedSlots: { customRender: 'tdActivation' }
  243. },
  244. {
  245. title: '账户激活成本',
  246. dataIndex: 'activationCost',
  247. align: 'center',
  248. scopedSlots: { customRender: 'activationCost' }
  249. },
  250. {
  251. title: '友盟激活成本',
  252. dataIndex: 'youMengactivationCost',
  253. align: 'center',
  254. scopedSlots: { customRender: 'youMengactivationCost' }
  255. },
  256. {
  257. title: 'TD激活成本',
  258. dataIndex: 'tdActivationCost',
  259. align: 'center',
  260. scopedSlots: { customRender: 'tdActivationCost' }
  261. },
  262. {
  263. title: '平均行为单价',
  264. dataIndex: 'actionCost',
  265. align: 'center',
  266. scopedSlots: { customRender: 'actionCost' }
  267. },
  268. {
  269. title: '平均点击单价',
  270. dataIndex: 'clickCost',
  271. align: 'center',
  272. scopedSlots: { customRender: 'clickCost' }
  273. },
  274. {
  275. title: '行为率',
  276. dataIndex: 'actionRatio',
  277. align: 'center',
  278. scopedSlots: { customRender: 'actionRatio' }
  279. },
  280. {
  281. title: '下载完成行为率',
  282. dataIndex: 'eventJinJianAppRatio',
  283. align: 'center',
  284. scopedSlots: { customRender: 'eventJinJianAppRatio' }
  285. },
  286. {
  287. title: '下载完成激活率',
  288. dataIndex: 'activationRatio',
  289. align: 'center',
  290. scopedSlots: { customRender: 'activationRatio' }
  291. }
  292. ]
  293. const columnsThree = [
  294. {
  295. title: '代理商',
  296. dataIndex: 'agent',
  297. scopedSlots: { customRender: 'agent' },
  298. align: 'center'
  299. },
  300. {
  301. title: '媒体',
  302. dataIndex: 'media',
  303. scopedSlots: { customRender: 'media' },
  304. align: 'center'
  305. },
  306. {
  307. title: '设备',
  308. dataIndex: 'systemType',
  309. align: 'center'
  310. },
  311. {
  312. title: '日期',
  313. dataIndex: 'statDate',
  314. align: 'center'
  315. },
  316. {
  317. title: '账面花费',
  318. dataIndex: 'charge',
  319. align: 'center',
  320. scopedSlots: { customRender: 'charge' }
  321. },
  322. {
  323. title: '现金花费',
  324. dataIndex: 'cashCost',
  325. align: 'center',
  326. scopedSlots: { customRender: 'cashCost' }
  327. },
  328. {
  329. title: '曝光',
  330. dataIndex: 'photoShow',
  331. align: 'center',
  332. scopedSlots: { customRender: 'photoShow' }
  333. },
  334. {
  335. title: '点击',
  336. dataIndex: 'photoClick',
  337. align: 'center',
  338. scopedSlots: { customRender: 'photoClick' }
  339. },
  340. {
  341. title: '点击率',
  342. dataIndex: 'clickRate',
  343. align: 'center',
  344. scopedSlots: { customRender: 'clickRate' }
  345. },
  346. {
  347. title: '千次嚗光花费',
  348. dataIndex: 'impression1kCost',
  349. align: 'center',
  350. scopedSlots: { customRender: 'impression1kCost' }
  351. },
  352. {
  353. title: '行为量',
  354. dataIndex: 'bclick',
  355. align: 'center',
  356. scopedSlots: { customRender: 'bclick' }
  357. },
  358. {
  359. title: '下载完成数',
  360. dataIndex: 'eventJinJianApp',
  361. align: 'center',
  362. scopedSlots: { customRender: 'eventJinJianApp' }
  363. },
  364. {
  365. title: '账户激活量',
  366. dataIndex: 'activation',
  367. align: 'center',
  368. scopedSlots: { customRender: 'activation' }
  369. },
  370. {
  371. title: '友盟激活量',
  372. dataIndex: 'youMengactivation',
  373. align: 'center',
  374. scopedSlots: { customRender: 'youMengactivation' }
  375. },
  376. {
  377. title: 'TD激活量',
  378. dataIndex: 'tdActivation',
  379. align: 'center',
  380. scopedSlots: { customRender: 'tdActivation' }
  381. },
  382. {
  383. title: '账户激活成本',
  384. dataIndex: 'activationCost',
  385. align: 'center',
  386. scopedSlots: { customRender: 'activationCost' }
  387. },
  388. {
  389. title: '友盟激活成本',
  390. dataIndex: 'youMengactivationCost',
  391. align: 'center',
  392. scopedSlots: { customRender: 'youMengactivationCost' }
  393. },
  394. {
  395. title: 'TD激活成本',
  396. dataIndex: 'tdActivationCost',
  397. align: 'center',
  398. scopedSlots: { customRender: 'tdActivationCost' }
  399. },
  400. {
  401. title: '平均行为单价',
  402. dataIndex: 'actionCost',
  403. align: 'center',
  404. scopedSlots: { customRender: 'actionCost' }
  405. },
  406. {
  407. title: '平均点击单价',
  408. dataIndex: 'clickCost',
  409. align: 'center',
  410. scopedSlots: { customRender: 'clickCost' }
  411. },
  412. {
  413. title: '行为率',
  414. dataIndex: 'actionRatio',
  415. align: 'center',
  416. scopedSlots: { customRender: 'actionRatio' }
  417. },
  418. {
  419. title: '下载完成行为率',
  420. dataIndex: 'eventJinJianAppRatio',
  421. align: 'center',
  422. scopedSlots: { customRender: 'eventJinJianAppRatio' }
  423. },
  424. {
  425. title: '下载完成激活率',
  426. dataIndex: 'activationRatio',
  427. align: 'center',
  428. scopedSlots: { customRender: 'activationRatio' }
  429. }
  430. ]
  431. const columnsGroup = columns
  432. export default {
  433. name: 'data-display-statistics',
  434. components: {
  435. ACol,
  436. ARow,
  437. countTo,
  438. lifting,
  439. timeCheck,
  440. Treeselect
  441. },
  442. mixins: [JeecgListMixin],
  443. data: function() {
  444. return {
  445. // this.timeRange[1] = moment().add(1, 'months')
  446. statDate: moment().subtract(1, 'day'),
  447. title: '账户数据展示',
  448. show: true,
  449. data: [],
  450. dataAll: null,
  451. columns: columnsThree,
  452. options: [],
  453. list: [],
  454. appId: [],
  455. tabListNoTitle: [
  456. {
  457. key: 'day',
  458. tab: '安卓汇总'
  459. },
  460. {
  461. key: 'group',
  462. tab: 'ios汇总'
  463. },
  464. {
  465. key: 'application',
  466. tab: '应用直达'
  467. },
  468. {
  469. key: 'channel',
  470. tab: '渠道包分析'
  471. }
  472. ],
  473. noTitleKey: 'day',
  474. discount: 1.06,
  475. date: '',
  476. loading: false,
  477. dataElse: [],
  478. projectId: 50
  479. }
  480. },
  481. filters: {
  482. formatDate: function(value) {
  483. let date = new Date(value)
  484. let y = date.getFullYear()
  485. let MM = date.getMonth() + 1
  486. MM = MM < 10 ? '0' + MM : MM
  487. let d = date.getDate()
  488. d = d < 10 ? '0' + d : d
  489. let h = date.getHours()
  490. h = h < 10 ? '0' + h : h
  491. let m = date.getMinutes()
  492. m = m < 10 ? '0' + m : m
  493. let s = date.getSeconds()
  494. s = s < 10 ? '0' + s : s
  495. return y + '-' + MM + '-' + d
  496. },
  497. toFixtwo: function(value) {
  498. if (value) {
  499. return value.toFixed(2)
  500. } else {
  501. return 0.0
  502. }
  503. },
  504. getBo: function(value) {
  505. if (value) {
  506. return (value * 100).toFixed(2) + '%'
  507. } else {
  508. return '0.00%'
  509. }
  510. }
  511. },
  512. methods: {
  513. moment,
  514. filterOption(input, option) {
  515. return option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  516. },
  517. ...mapGetters(['nickname', 'avatar', 'userInfo']),
  518. getParticipateList() {
  519. postAction('/ctop/projectMember/participateListByMediaId', {
  520. userId: this.userInfo().id,
  521. type: "kuaishou"
  522. }).then(res => {
  523. if (res.success) {
  524. this.dataElse = res.result
  525. }
  526. })
  527. },
  528. onTabChange(key, type) {
  529. console.log(key, type)
  530. this[type] = key
  531. this.data = []
  532. if (this.noTitleKey == 'day') {
  533. this.columns = columnsThree
  534. this.data.push(this.dataAll.android)
  535. } else if (this.noTitleKey == 'group') {
  536. this.columns = columnsThree
  537. this.data.push(this.dataAll.ios)
  538. } else if (this.noTitleKey == 'application') {
  539. this.columns = columnsThree
  540. this.data.push(this.dataAll.directApplication)
  541. } else if (this.noTitleKey == 'channel') {
  542. this.columns = columns
  543. this.data = this.dataAll.channelSubcontracting.map((item, index) => {
  544. return {
  545. ...item,
  546. key: index
  547. }
  548. })
  549. }
  550. this.ipagination.total = this.data.length
  551. this.ipagination.current = 1
  552. },
  553. disabledDate(current) {
  554. return current && current > moment().subtract(1, 'day')
  555. },
  556. getDataReset() {
  557. this.addUser()
  558. },
  559. addUser() {
  560. var that = this
  561. // if (this.appId.length > 0 && this.date != '') {
  562. that.getDailyReport()
  563. // } else {
  564. // this.$message.error('请选择账户及时间')
  565. // }
  566. },
  567. getDailyReport() {
  568. var params = {}
  569. params.projectId = this.projectId
  570. params.disCount = this.discount
  571. params.statDate = this.statDate.format('YYYY-MM-DD')
  572. this.data = []
  573. this.loading = true
  574. postAction('/ctop/yiche/report/dailyReport', params).then(res => {
  575. if (res.success) {
  576. this.loading = false
  577. this.dataAll = res.result
  578. console.log(res)
  579. if (this.noTitleKey == 'day') {
  580. this.columns = columnsThree
  581. this.data.push({ ...res.result.android, key: 1 })
  582. } else if (this.noTitleKey == 'group') {
  583. this.columns = columnsThree
  584. this.data.push({ ...res.result.ios, key: 1 })
  585. } else if (this.noTitleKey == 'application') {
  586. this.columns = columnsThree
  587. this.data.push({ ...res.result.directApplication, key: 1 })
  588. } else if (this.noTitleKey == 'channel') {
  589. this.columns = columns
  590. this.data = res.result.channelSubcontracting.map((item, index) => {
  591. return {
  592. ...item,
  593. key: index
  594. }
  595. })
  596. }
  597. this.ipagination.total = this.data.length
  598. }
  599. })
  600. },
  601. getDate(value) {
  602. if (value) {
  603. let date = new Date(value)
  604. let y = date.getFullYear()
  605. let MM = date.getMonth() + 1
  606. MM = MM < 10 ? '0' + MM : MM
  607. let d = date.getDate()
  608. d = d < 10 ? '0' + d : d
  609. this.date = y + '-' + MM + '-' + d
  610. } else {
  611. let date = new Date()
  612. let y = date.getFullYear()
  613. let MM = date.getMonth() + 1
  614. MM = MM < 10 ? '0' + MM : MM
  615. let d = date.getDate()
  616. d = d < 10 ? '0' + d : d
  617. this.date = y + '-' + MM + '-' + d
  618. }
  619. },
  620. exportExcel() {
  621. var params = {}
  622. params.projectId = this.projectId
  623. params.disCount = this.discount
  624. params.statDate = this.statDate.format('YYYY-MM-DD')
  625. var name = this.dataElse.filter(item => {
  626. return item.projectId == this.projectId
  627. })[0].projectName
  628. downFilePost('/ctop/yiche/report/exportDailyReport', params).then(res => {
  629. let blob = new Blob([res], {
  630. type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
  631. })
  632. let downloadElement = document.createElement('a')
  633. let href = window.URL.createObjectURL(blob) //创建下载的链接
  634. downloadElement.href = href
  635. downloadElement.download = name + '-' + this.statDate.format('YYYY-MM-DD') + '-日报' //下载后文件名
  636. document.body.appendChild(downloadElement)
  637. downloadElement.click() //点击下载
  638. document.body.removeChild(downloadElement) //下载完成移除元素
  639. window.URL.revokeObjectURL(href) //释放掉blob对象
  640. })
  641. }
  642. },
  643. watch: {},
  644. distoryed() {},
  645. mounted: function() {
  646. this.getParticipateList()
  647. this.statDate = moment().subtract(1, 'day')
  648. // moment().format('YYYY-MM-DD_HH:mm')
  649. }
  650. }
  651. </script>