accountMaterStatistics.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511
  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. .search-box .ant-card-body {
  17. padding: 5px 15px;
  18. }
  19. .ant-modal-wrap .yincang .ant-modal-content .ant-modal-footer {
  20. display: none !important;
  21. }
  22. .yincang .ant-col-6 p {
  23. text-align: left;
  24. color: red;
  25. font-size: 16px;
  26. font-weight: 500;
  27. }
  28. .ant-table-thead div {
  29. font-weight: 700;
  30. }
  31. .tool-tip {
  32. position: absolute;
  33. top: 65px;
  34. right: 10px;
  35. }
  36. th div {
  37. white-space: nowrap;
  38. }
  39. </style>
  40. <template>
  41. <div class="data-account-statistics">
  42. <a-row class="image-list-heading vm-panel">
  43. <div class="panel-heading" style="display:flex;justify-content: space-between;">
  44. {{ title }}
  45. <a-button @click="dianji">进入素材报表</a-button>
  46. </div>
  47. <a-row type="flex" align="middle" justify="space-between" class="panel-body">
  48. <div class="search-bar" style="width:100%">
  49. <span>账户选择:</span>
  50. <treeselect :appId.sync="appId" request="2,4"/>
  51. <a-button type="primary" style="margin:10px" @click="addUser">搜索</a-button>
  52. <a-button
  53. type="primary"
  54. icon="reload"
  55. @click="getDataReset"
  56. style="background-color:#67c23a;border-color:#67c23a"
  57. >刷新</a-button
  58. >
  59. <a-button type="primary" style="margin:10px" @click="getDataResetAll">重置</a-button>
  60. </div>
  61. </a-row>
  62. <a-row>
  63. <a-col :span="24">
  64. <a-card :bordered="false" class="search-box">
  65. <time-check
  66. @getAdd="getAdd"
  67. :startValue.sync="startValue"
  68. :timeList="timeList"
  69. ref="timeCheck"
  70. :activeNow="2"
  71. ></time-check>
  72. </a-card>
  73. </a-col>
  74. </a-row>
  75. </a-row>
  76. <a-row :gutter="10" style="margin-top:10px">
  77. <a-col :span="24">
  78. <a-card style="width:100%;">
  79. <a-table
  80. :columns="columns"
  81. :dataSource="data"
  82. bordered
  83. id="outTable"
  84. :pagination="ipagination"
  85. size="middle"
  86. :customRow="rowClick"
  87. :loading="loading"
  88. :scroll="{ x: 2000 }"
  89. >
  90. <div slot="url" slot-scope="url">
  91. <video class="video" :src="url" controls="controls" style="height:200px;width:112.5px">
  92. 您的浏览器不支持 video 标签。
  93. </video>
  94. </div>
  95. <span slot="photoClickRatio" slot-scope="photoClickRatio">{{ photoClickRatio | getBo }}</span>
  96. <span slot="actionRatio" slot-scope="actionRatio">{{ actionRatio | getBo }}</span>
  97. <span slot="impression1kCost" slot-scope="impression1kCost">{{ impression1kCost | toFixtwo }}</span>
  98. <span slot="photoClickCost" slot-scope="photoClickCost">{{ photoClickCost | toFixtwo }}</span>
  99. <span slot="actionCost" slot-scope="actionCost">{{ actionCost | toFixtwo }}</span>
  100. <span slot="conversionPrice" slot-scope="conversionPrice">{{ conversionPrice | toFixtwo }}</span>
  101. </a-table>
  102. </a-card>
  103. </a-col>
  104. </a-row>
  105. <ratio-modal ref="ratio" />
  106. </div>
  107. </template>
  108. <script>
  109. import ARow from 'ant-design-vue/es/grid/Row'
  110. import ACol from 'ant-design-vue/es/grid/Col'
  111. import countTo from 'vue-count-to'
  112. import moment from 'moment'
  113. import { getMaterialReportByAccount } from '@api/statistics'
  114. import axios from 'axios'
  115. import lifting from './components/lifting'
  116. import timeCheck from './components/timeCheck'
  117. import ratioModal from './components/ratioModal'
  118. import { mapGetters } from 'vuex'
  119. import { JeecgListMixin } from '@/mixins/ipagination'
  120. // import the component
  121. import Treeselect from './components/Treeselect.vue'
  122. // 引入基本模板
  123. let echarts = require('echarts/lib/echarts')
  124. // 引入柱状图组件
  125. require('echarts/lib/chart/bar')
  126. require('echarts/lib/chart/pie')
  127. require('echarts/lib/chart/line')
  128. // 引入提示框和title组件
  129. require('echarts/lib/component/tooltip')
  130. require('echarts/lib/component/title')
  131. require('echarts/lib/component/graphic')
  132. require('echarts/lib/component/toolbox')
  133. require('echarts/lib/component/legend')
  134. var length = 0
  135. var active = 1
  136. const columns = [
  137. {
  138. title: '视频',
  139. dataIndex: 'url',
  140. key: 'url',
  141. align: 'center',
  142. scopedSlots: { customRender: 'url' },
  143. fixed: 'left',
  144. width: 150
  145. },
  146. {
  147. title: '花费',
  148. dataIndex: 'cost',
  149. key: 'cost',
  150. align: 'center',
  151. sorter: (a, b) => a.cost - b.cost
  152. },
  153. {
  154. title: '安卓下载完成数',
  155. dataIndex: 'downloadCompleted',
  156. key: 'downloadCompleted',
  157. align: 'center',
  158. sorter: (a, b) => a.downloadCompleted - b.downloadCompleted
  159. },
  160. {
  161. title: '封面曝光数',
  162. dataIndex: 'photoShow',
  163. key: 'photoShow',
  164. align: 'center',
  165. sorter: (a, b) => a.photoShow - b.photoShow
  166. },
  167. {
  168. title: '封面点击数',
  169. dataIndex: 'photoClick',
  170. key: 'photoClick',
  171. align: 'center',
  172. sorter: (a, b) => a.photoClick - b.photoClick
  173. },
  174. {
  175. title: '素材曝光数',
  176. dataIndex: 'aclick',
  177. key: 'aclick',
  178. align: 'center',
  179. sorter: (a, b) => a.aclick - b.aclick
  180. },
  181. {
  182. title: '行为数',
  183. dataIndex: 'bclick',
  184. key: 'bclick',
  185. align: 'center',
  186. sorter: (a, b) => a.bclick - b.bclick
  187. },
  188. {
  189. title: '封面点击率',
  190. dataIndex: 'photoClickRatio',
  191. key: 'photoClickRatio',
  192. align: 'center',
  193. scopedSlots: { customRender: 'photoClickRatio' },
  194. sorter: (a, b) => a.photoClickRatio - b.photoClickRatio
  195. },
  196. {
  197. title: '行为率',
  198. dataIndex: 'actionRatio',
  199. key: 'actionRatio',
  200. align: 'center',
  201. scopedSlots: { customRender: 'actionRatio' },
  202. sorter: (a, b) => a.actionRatio - b.actionRatio
  203. },
  204. {
  205. title: '均千次封面曝光花费(元)',
  206. dataIndex: 'impression1kCost',
  207. key: 'impression1kCost',
  208. scopedSlots: { customRender: 'impression1kCost' },
  209. align: 'center',
  210. sorter: (a, b) => a.impression1kCost - b.impression1kCost
  211. },
  212. {
  213. title: '平均封面点击单价(元)',
  214. dataIndex: 'photoClickCost',
  215. key: 'photoClickCost',
  216. scopedSlots: { customRender: 'photoClickCost' },
  217. align: 'center',
  218. sorter: (a, b) => a.photoClickCost - b.photoClickCost
  219. },
  220. {
  221. title: '平均行为单价(元)',
  222. dataIndex: 'actionCost',
  223. key: 'actionCost',
  224. scopedSlots: { customRender: 'actionCost' },
  225. align: 'center',
  226. sorter: (a, b) => a.actionCost - b.actionCost
  227. },
  228. {
  229. title: '转化数',
  230. dataIndex: 'conversions',
  231. key: 'conversions',
  232. align: 'center',
  233. sorter: (a, b) => a.conversions - b.conversions
  234. },
  235. {
  236. title: '转化单价(元)',
  237. dataIndex: 'conversionPrice',
  238. key: 'conversionPrice',
  239. scopedSlots: { customRender: 'conversionPrice' },
  240. align: 'center',
  241. sorter: (a, b) => a.conversionPrice - b.conversionPrice
  242. }
  243. ]
  244. const columnsDetail = [
  245. {
  246. title: '日期',
  247. dataIndex: 'statDate',
  248. key: 'statDate',
  249. align: 'center'
  250. },
  251. {
  252. title: '花费',
  253. dataIndex: 'cost',
  254. key: 'cost',
  255. align: 'center'
  256. },
  257. {
  258. title: '封面曝光数',
  259. dataIndex: 'photoShow',
  260. key: 'photoShow',
  261. align: 'center'
  262. },
  263. {
  264. title: '封面点击数',
  265. dataIndex: 'photoClick',
  266. key: 'photoClick',
  267. align: 'center'
  268. },
  269. {
  270. title: '素材曝光数',
  271. dataIndex: 'aclick',
  272. key: 'aclick',
  273. align: 'center'
  274. },
  275. {
  276. title: '行为数',
  277. dataIndex: 'bclick',
  278. key: 'bclick',
  279. align: 'center'
  280. },
  281. {
  282. title: '封面点击率',
  283. dataIndex: 'photoClickRatio',
  284. key: 'photoClickRatio',
  285. align: 'center',
  286. scopedSlots: { customRender: 'photoClickRatio' }
  287. },
  288. {
  289. title: '行为率',
  290. dataIndex: 'actionRatio',
  291. key: 'actionRatio',
  292. align: 'center',
  293. scopedSlots: { customRender: 'actionRatio' }
  294. },
  295. {
  296. title: '均千次封面曝光花费(元)',
  297. dataIndex: 'impression1kCost',
  298. key: 'impression1kCost',
  299. scopedSlots: { customRender: 'impression1kCost' },
  300. align: 'center'
  301. },
  302. {
  303. title: '平均封面点击单价(元)',
  304. dataIndex: 'photoClickCost',
  305. key: 'photoClickCost',
  306. scopedSlots: { customRender: 'photoClickCost' },
  307. align: 'center'
  308. },
  309. {
  310. title: '平均行为单价(元)',
  311. dataIndex: 'actionCost',
  312. key: 'actionCost',
  313. scopedSlots: { customRender: 'actionCost' },
  314. align: 'center'
  315. },
  316. {
  317. title: '转化数',
  318. dataIndex: 'conversions',
  319. key: 'conversions',
  320. align: 'center'
  321. },
  322. {
  323. title: '转化单价(元)',
  324. dataIndex: 'conversionPrice',
  325. key: 'conversionPrice',
  326. scopedSlots: { customRender: 'conversionPrice' },
  327. align: 'center'
  328. }
  329. ]
  330. export default {
  331. name: 'data-display-statistics',
  332. components: {
  333. ACol,
  334. ARow,
  335. countTo,
  336. lifting,
  337. timeCheck,
  338. ratioModal,
  339. Treeselect
  340. },
  341. mixins: [JeecgListMixin],
  342. data: function() {
  343. return {
  344. title: '账户素材报表',
  345. show: true,
  346. timeList: [
  347. // { label: '今天', value: 1, show: false },
  348. { label: '昨天', value: 2, show: true },
  349. { label: '近一周', value: 3, show: true },
  350. { label: '近十五天', value: 4, show: true },
  351. { label: '近一月', value: 5, show: true },
  352. { label: '近三月', value: 6, show: true }
  353. ],
  354. active: 2,
  355. data: [],
  356. columns,
  357. columnsDetail,
  358. list: [],
  359. appId: [],
  360. startValue: [],
  361. allValue: [],
  362. loading: false,
  363. rowClick: record => ({
  364. // 事件
  365. on: {
  366. click: () => {
  367. // 点击改行时要做的事情
  368. // this.detail = record
  369. // this.visible = true
  370. // this.getMineList(record.signature)
  371. this.$refs.ratio.getMineList(record, this.active)
  372. }
  373. }
  374. })
  375. }
  376. },
  377. filters: {
  378. formatDate: function(value) {
  379. let date = new Date(value)
  380. let y = date.getFullYear()
  381. let MM = date.getMonth() + 1
  382. MM = MM < 10 ? '0' + MM : MM
  383. let d = date.getDate()
  384. d = d < 10 ? '0' + d : d
  385. let h = date.getHours()
  386. h = h < 10 ? '0' + h : h
  387. let m = date.getMinutes()
  388. m = m < 10 ? '0' + m : m
  389. let s = date.getSeconds()
  390. s = s < 10 ? '0' + s : s
  391. return y + '-' + MM + '-' + d + ' ' + h + ':' + m + ':' + s
  392. },
  393. toFixtwo: function(value) {
  394. if (value) {
  395. return value.toFixed(2)
  396. } else {
  397. return 0.0
  398. }
  399. },
  400. getBo: function(value) {
  401. if (value) {
  402. return (value * 100).toFixed(2) + '%'
  403. } else {
  404. return '0.00%'
  405. }
  406. }
  407. },
  408. methods: {
  409. moment,
  410. ...mapGetters(['nickname', 'avatar', 'userInfo']),
  411. disabledDate(current) {
  412. return current && current > moment().endOf('day')
  413. },
  414. handleChange(value) {
  415. console.log(value)
  416. // this.appId = value
  417. },
  418. getElseData(value) {
  419. this.getStatistics()
  420. },
  421. handleBlur() {
  422. console.log('blur')
  423. },
  424. getDataReset() {
  425. this.active = 2
  426. this.allValue = []
  427. this.addUser()
  428. },
  429. getDataResetAll() {
  430. this.active = 2
  431. this.$refs.timeCheck.active = 1
  432. this.allValue = []
  433. this.appId = []
  434. this.data = []
  435. },
  436. addUser() {
  437. this.loading = true
  438. var that = this
  439. if (this.appId.length > 0) {
  440. var params = {}
  441. params.accountIds = JSON.stringify(that.appId)
  442. params.type = that.active
  443. if (that.active == 9) {
  444. params.startDate = this.allValue[0]
  445. params.endDate = this.allValue[1]
  446. }
  447. } else {
  448. this.$message.error('请选择账户')
  449. return
  450. }
  451. getMaterialReportByAccount(params).then(res => {
  452. if (res.success) {
  453. if (res.result.length > 0) {
  454. this.data = res.result
  455. this.ipagination.total = res.result.length
  456. } else {
  457. this.$message.error('选择的账户无数据')
  458. }
  459. this.loading = false
  460. } else {
  461. this.$message.error(res.message)
  462. this.loading = false
  463. }
  464. })
  465. },
  466. getStatistics() {
  467. var params = {}
  468. params.accountIds = JSON.stringify(this.appId)
  469. params.type = this.active
  470. params.statHour = this.statHour
  471. params.discount = this.discount
  472. if (this.active == 9) {
  473. params.startDate = this.allValue[0]
  474. params.endDate = this.allValue[1]
  475. }
  476. this.data = []
  477. },
  478. getAdd(checked) {
  479. if (checked == 9) {
  480. if (this.startValue.length > 0 && this.startValue[0]) {
  481. this.allValue[0] = moment(this.startValue[0]._d).format('YYYY-MM-DD')
  482. this.allValue[1] = moment(this.startValue[1]._d).format('YYYY-MM-DD')
  483. }
  484. } else {
  485. this.startValue = []
  486. this.allValue = []
  487. }
  488. this.active = checked
  489. active = checked
  490. this.ipagination.current = 1
  491. this.addUser(checked)
  492. },
  493. dianji() {
  494. this.$router.replace({ path: '/Statistics/materialStatistics' })
  495. }
  496. },
  497. watch: {},
  498. distoryed() {},
  499. mounted: function() {
  500. this.$nextTick(() => {})
  501. }
  502. }
  503. </script>