accountMaterStatistics.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521
  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: 2400 }"
  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: '视频md5',
  148. dataIndex: 'signature',
  149. key: 'signature',
  150. align: 'center',
  151. scopedSlots: { customRender: 'signature' },
  152. fixed: 'left',
  153. width: 250
  154. },
  155. {
  156. title: '花费',
  157. dataIndex: 'cost',
  158. key: 'cost',
  159. align: 'center',
  160. sorter: (a, b) => a.cost - b.cost
  161. },
  162. {
  163. title: '安卓下载完成数',
  164. dataIndex: 'downloadCompleted',
  165. key: 'downloadCompleted',
  166. align: 'center',
  167. sorter: (a, b) => a.downloadCompleted - b.downloadCompleted
  168. },
  169. {
  170. title: '封面曝光数',
  171. dataIndex: 'photoShow',
  172. key: 'photoShow',
  173. align: 'center',
  174. sorter: (a, b) => a.photoShow - b.photoShow
  175. },
  176. {
  177. title: '封面点击数',
  178. dataIndex: 'photoClick',
  179. key: 'photoClick',
  180. align: 'center',
  181. sorter: (a, b) => a.photoClick - b.photoClick
  182. },
  183. {
  184. title: '素材曝光数',
  185. dataIndex: 'aclick',
  186. key: 'aclick',
  187. align: 'center',
  188. sorter: (a, b) => a.aclick - b.aclick
  189. },
  190. {
  191. title: '行为数',
  192. dataIndex: 'bclick',
  193. key: 'bclick',
  194. align: 'center',
  195. sorter: (a, b) => a.bclick - b.bclick
  196. },
  197. {
  198. title: '封面点击率',
  199. dataIndex: 'photoClickRatio',
  200. key: 'photoClickRatio',
  201. align: 'center',
  202. scopedSlots: { customRender: 'photoClickRatio' },
  203. sorter: (a, b) => a.photoClickRatio - b.photoClickRatio
  204. },
  205. {
  206. title: '行为率',
  207. dataIndex: 'actionRatio',
  208. key: 'actionRatio',
  209. align: 'center',
  210. scopedSlots: { customRender: 'actionRatio' },
  211. sorter: (a, b) => a.actionRatio - b.actionRatio
  212. },
  213. {
  214. title: '均千次封面曝光花费(元)',
  215. dataIndex: 'impression1kCost',
  216. key: 'impression1kCost',
  217. scopedSlots: { customRender: 'impression1kCost' },
  218. align: 'center',
  219. sorter: (a, b) => a.impression1kCost - b.impression1kCost,
  220. },
  221. {
  222. title: '平均封面点击单价(元)',
  223. dataIndex: 'photoClickCost',
  224. key: 'photoClickCost',
  225. scopedSlots: { customRender: 'photoClickCost' },
  226. align: 'center',
  227. sorter: (a, b) => a.photoClickCost - b.photoClickCost,
  228. },
  229. {
  230. title: '平均行为单价(元)',
  231. dataIndex: 'actionCost',
  232. key: 'actionCost',
  233. scopedSlots: { customRender: 'actionCost' },
  234. align: 'center',
  235. sorter: (a, b) => a.actionCost - b.actionCost
  236. },
  237. {
  238. title: '转化数',
  239. dataIndex: 'conversions',
  240. key: 'conversions',
  241. align: 'center',
  242. sorter: (a, b) => a.conversions - b.conversions
  243. },
  244. {
  245. title: '转化单价(元)',
  246. dataIndex: 'conversionPrice',
  247. key: 'conversionPrice',
  248. scopedSlots: { customRender: 'conversionPrice' },
  249. align: 'center',
  250. sorter: (a, b) => a.conversionPrice - b.conversionPrice
  251. }
  252. ]
  253. const columnsDetail = [
  254. {
  255. title: '日期',
  256. dataIndex: 'statDate',
  257. key: 'statDate',
  258. align: 'center'
  259. },
  260. {
  261. title: '花费',
  262. dataIndex: 'cost',
  263. key: 'cost',
  264. align: 'center'
  265. },
  266. {
  267. title: '封面曝光数',
  268. dataIndex: 'photoShow',
  269. key: 'photoShow',
  270. align: 'center'
  271. },
  272. {
  273. title: '封面点击数',
  274. dataIndex: 'photoClick',
  275. key: 'photoClick',
  276. align: 'center'
  277. },
  278. {
  279. title: '素材曝光数',
  280. dataIndex: 'aclick',
  281. key: 'aclick',
  282. align: 'center'
  283. },
  284. {
  285. title: '行为数',
  286. dataIndex: 'bclick',
  287. key: 'bclick',
  288. align: 'center'
  289. },
  290. {
  291. title: '封面点击率',
  292. dataIndex: 'photoClickRatio',
  293. key: 'photoClickRatio',
  294. align: 'center',
  295. scopedSlots: { customRender: 'photoClickRatio' }
  296. },
  297. {
  298. title: '行为率',
  299. dataIndex: 'actionRatio',
  300. key: 'actionRatio',
  301. align: 'center',
  302. scopedSlots: { customRender: 'actionRatio' }
  303. },
  304. {
  305. title: '均千次封面曝光花费(元)',
  306. dataIndex: 'impression1kCost',
  307. key: 'impression1kCost',
  308. scopedSlots: { customRender: 'impression1kCost' },
  309. align: 'center'
  310. },
  311. {
  312. title: '平均封面点击单价(元)',
  313. dataIndex: 'photoClickCost',
  314. key: 'photoClickCost',
  315. scopedSlots: { customRender: 'photoClickCost' },
  316. align: 'center'
  317. },
  318. {
  319. title: '平均行为单价(元)',
  320. dataIndex: 'actionCost',
  321. key: 'actionCost',
  322. scopedSlots: { customRender: 'actionCost' },
  323. align: 'center'
  324. },
  325. {
  326. title: '转化数',
  327. dataIndex: 'conversions',
  328. key: 'conversions',
  329. align: 'center'
  330. },
  331. {
  332. title: '转化单价(元)',
  333. dataIndex: 'conversionPrice',
  334. key: 'conversionPrice',
  335. scopedSlots: { customRender: 'conversionPrice' },
  336. align: 'center'
  337. }
  338. ]
  339. export default {
  340. name: 'data-display-statistics',
  341. components: {
  342. ACol,
  343. ARow,
  344. countTo,
  345. lifting,
  346. timeCheck,
  347. ratioModal,
  348. Treeselect
  349. },
  350. mixins: [JeecgListMixin],
  351. data: function() {
  352. return {
  353. title: '账户素材报表',
  354. show: true,
  355. timeList: [
  356. // { label: '今天', value: 1, show: false },
  357. { label: '昨天', value: 2, show: true },
  358. { label: '近一周', value: 3, show: true },
  359. { label: '近十五天', value: 4, show: true },
  360. { label: '近一月', value: 5, show: true },
  361. { label: '近三月', value: 6, show: true }
  362. ],
  363. active: 2,
  364. data: [],
  365. columns,
  366. columnsDetail,
  367. list: [],
  368. appId: [],
  369. startValue: [],
  370. allValue: [],
  371. loading: false,
  372. rowClick: record => ({
  373. // 事件
  374. on: {
  375. click: () => {
  376. // 点击改行时要做的事情
  377. // this.detail = record
  378. // this.visible = true
  379. // this.getMineList(record.signature)
  380. this.$refs.ratio.getMineList(record, this.active)
  381. }
  382. }
  383. })
  384. }
  385. },
  386. filters: {
  387. formatDate: function(value) {
  388. let date = new Date(value)
  389. let y = date.getFullYear()
  390. let MM = date.getMonth() + 1
  391. MM = MM < 10 ? '0' + MM : MM
  392. let d = date.getDate()
  393. d = d < 10 ? '0' + d : d
  394. let h = date.getHours()
  395. h = h < 10 ? '0' + h : h
  396. let m = date.getMinutes()
  397. m = m < 10 ? '0' + m : m
  398. let s = date.getSeconds()
  399. s = s < 10 ? '0' + s : s
  400. return y + '-' + MM + '-' + d + ' ' + h + ':' + m + ':' + s
  401. },
  402. toFixtwo: function(value) {
  403. if (value) {
  404. return value.toFixed(2)
  405. } else {
  406. return 0.0
  407. }
  408. },
  409. getBo: function(value) {
  410. if (value) {
  411. return (value * 100).toFixed(2) + '%'
  412. } else {
  413. return '0.00%'
  414. }
  415. }
  416. },
  417. methods: {
  418. moment,
  419. ...mapGetters(['nickname', 'avatar', 'userInfo']),
  420. disabledDate(current) {
  421. return current && current > moment().endOf('day')
  422. },
  423. handleChange(value) {
  424. console.log(value)
  425. // this.appId = value
  426. },
  427. getElseData(value) {
  428. this.getStatistics()
  429. },
  430. handleBlur() {
  431. console.log('blur')
  432. },
  433. getDataReset() {
  434. this.active = 2
  435. this.allValue = []
  436. this.addUser()
  437. },
  438. getDataResetAll() {
  439. this.active = 2
  440. this.$refs.timeCheck.active = 1
  441. this.allValue = []
  442. this.appId = []
  443. this.data = []
  444. },
  445. addUser() {
  446. this.loading = true
  447. var that = this
  448. if (this.appId.length > 0) {
  449. var params = {}
  450. params.accountIds = JSON.stringify(that.appId)
  451. params.type = that.active
  452. if (that.active == 9) {
  453. params.startDate = this.allValue[0]
  454. params.endDate = this.allValue[1]
  455. }
  456. } else {
  457. this.$message.error('请选择账户')
  458. return
  459. }
  460. getMaterialReportByAccount(params).then(res => {
  461. if (res.success) {
  462. if (res.result.length > 0) {
  463. this.data = res.result
  464. this.ipagination.total = res.result.length
  465. } else {
  466. this.$message.error('选择的账户无数据')
  467. }
  468. this.loading = false
  469. } else {
  470. this.$message.error(res.message)
  471. this.loading = false
  472. }
  473. })
  474. },
  475. getStatistics() {
  476. var params = {}
  477. params.accountIds = JSON.stringify(this.appId)
  478. params.type = this.active
  479. params.statHour = this.statHour
  480. params.discount = this.discount
  481. if (this.active == 9) {
  482. params.startDate = this.allValue[0]
  483. params.endDate = this.allValue[1]
  484. }
  485. this.data = []
  486. },
  487. getAdd(checked) {
  488. if (checked == 9) {
  489. if (this.startValue.length > 0 && this.startValue[0]) {
  490. this.allValue[0] = moment(this.startValue[0]._d).format('YYYY-MM-DD')
  491. this.allValue[1] = moment(this.startValue[1]._d).format('YYYY-MM-DD')
  492. }
  493. } else {
  494. this.startValue = []
  495. this.allValue = []
  496. }
  497. this.active = checked
  498. active = checked
  499. this.ipagination.current = 1
  500. this.addUser(checked)
  501. },
  502. dianji() {
  503. this.$router.replace({ path: '/Statistics/materialStatistics' })
  504. }
  505. },
  506. watch: {},
  507. distoryed() {},
  508. mounted: function() {
  509. this.$nextTick(() => {})
  510. }
  511. }
  512. </script>