ratioModal.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. <style>
  2. th div {
  3. white-space: nowrap;
  4. }
  5. </style>
  6. <template>
  7. <div class="data-display-statistics">
  8. <a-modal title="环比展示" v-model="visible" @ok="handleOk" width="90%">
  9. <div v-if="url">
  10. <video class="video" :src="url" controls="controls" style="height:200px;" v-show="showVideo">
  11. 您的浏览器不支持 video 标签。
  12. </video>
  13. </div>
  14. <a-button type="primary" @click="showVideo = !showVideo">{{
  15. !showVideo ? '点击查看视频' : '点击收起视频'
  16. }}</a-button>
  17. <a-card style="width:100%;">
  18. <a-table
  19. :columns="columnsDetail"
  20. :dataSource="dataDetail"
  21. bordered
  22. id="outTable"
  23. :pagination="false"
  24. :loading="loading"
  25. :scroll="{ x: true }"
  26. >
  27. <span slot="photoClickRatio" slot-scope="photoClickRatio">{{ photoClickRatio | getBo }}</span>
  28. <span slot="actionRatio" slot-scope="actionRatio">{{ actionRatio | getBo }}</span>
  29. <span slot="impression1kCost" slot-scope="impression1kCost, record">
  30. <span v-if="record.statDate == '环比'">{{ impression1kCost | getBo }}</span>
  31. <span v-else>{{ impression1kCost | toFixtwo }}</span>
  32. </span>
  33. <span slot="photoClickCost" slot-scope="photoClickCost, record">
  34. <span v-if="record.statDate == '环比'">{{ photoClickCost | getBo }}</span>
  35. <span v-else>{{ photoClickCost | toFixtwo }}</span>
  36. </span>
  37. <span slot="actionCost" slot-scope="actionCost, record">
  38. <span v-if="record.statDate == '环比'">{{ actionCost | getBo }}</span>
  39. <span v-else>{{ actionCost | toFixtwo }}</span>
  40. </span>
  41. <span slot="conversionPrice" slot-scope="conversionPrice, record">
  42. <span v-if="record.statDate == '环比'">{{ conversionPrice | getBo }}</span>
  43. <span v-else>{{ conversionPrice | toFixtwo }}</span>
  44. </span>
  45. </a-table>
  46. </a-card>
  47. </a-modal>
  48. </div>
  49. </template>
  50. <script>
  51. import ARow from 'ant-design-vue/es/grid/Row'
  52. import ACol from 'ant-design-vue/es/grid/Col'
  53. import moment from 'moment'
  54. import { getKuaiShouChainRatio } from '@api/statistics'
  55. import axios from 'axios'
  56. import { mapGetters } from 'vuex'
  57. var length = 0
  58. var active = 1
  59. const columnsDetail = [
  60. {
  61. title: '日期',
  62. dataIndex: 'statDate',
  63. key: 'statDate',
  64. align: 'center',
  65. fixed: 'left',
  66. width: 130
  67. },
  68. {
  69. title: '花费',
  70. dataIndex: 'cost',
  71. key: 'cost',
  72. align: 'center'
  73. },
  74. {
  75. title: '封面曝光数',
  76. dataIndex: 'photoShow',
  77. key: 'photoShow',
  78. align: 'center'
  79. },
  80. {
  81. title: '封面点击数',
  82. dataIndex: 'photoClick',
  83. key: 'photoClick',
  84. align: 'center'
  85. },
  86. {
  87. title: '素材曝光数',
  88. dataIndex: 'aclick',
  89. key: 'aclick',
  90. align: 'center'
  91. },
  92. {
  93. title: '行为数',
  94. dataIndex: 'bclick',
  95. key: 'bclick',
  96. align: 'center'
  97. },
  98. {
  99. title: '封面点击率',
  100. dataIndex: 'photoClickRatio',
  101. key: 'photoClickRatio',
  102. align: 'center',
  103. scopedSlots: { customRender: 'photoClickRatio' }
  104. },
  105. {
  106. title: '行为率',
  107. dataIndex: 'actionRatio',
  108. key: 'actionRatio',
  109. align: 'center',
  110. scopedSlots: { customRender: 'actionRatio' }
  111. },
  112. {
  113. title: '均千次封面曝光花费(元)',
  114. dataIndex: 'impression1kCost',
  115. key: 'impression1kCost',
  116. scopedSlots: { customRender: 'impression1kCost' },
  117. align: 'center'
  118. },
  119. {
  120. title: '平均封面点击单价(元)',
  121. dataIndex: 'photoClickCost',
  122. key: 'photoClickCost',
  123. scopedSlots: { customRender: 'photoClickCost' },
  124. align: 'center'
  125. },
  126. {
  127. title: '平均行为单价(元)',
  128. dataIndex: 'actionCost',
  129. key: 'actionCost',
  130. scopedSlots: { customRender: 'actionCost' },
  131. align: 'center'
  132. },
  133. {
  134. title: '转化数',
  135. dataIndex: 'conversions',
  136. key: 'conversions',
  137. align: 'center'
  138. },
  139. {
  140. title: '转化单价(元)',
  141. dataIndex: 'conversionPrice',
  142. key: 'conversionPrice',
  143. scopedSlots: { customRender: 'conversionPrice' },
  144. align: 'center'
  145. }
  146. ]
  147. export default {
  148. name: 'ration-modal',
  149. components: {
  150. ACol,
  151. ARow
  152. },
  153. data: function() {
  154. return {
  155. columnsDetail,
  156. showVideo: false,
  157. dataDetail: [],
  158. url: '',
  159. visible: false,
  160. loading: true
  161. }
  162. },
  163. filters: {
  164. toFixtwo: function(value) {
  165. if (value) {
  166. return value.toFixed(2)
  167. } else {
  168. return 0.0
  169. }
  170. },
  171. getBo: function(value) {
  172. if (value) {
  173. return (value * 100).toFixed(2) + '%'
  174. } else {
  175. return '0.00%'
  176. }
  177. }
  178. },
  179. methods: {
  180. moment,
  181. getMineList(md5, active) {
  182. this.visible = true
  183. this.loading = true
  184. this.url = md5.url
  185. this.dataDetail = []
  186. this.showVideo = false
  187. var params = {}
  188. params.type = active
  189. params.signature = md5.signature
  190. if (md5.accountId) {
  191. params.accountId = md5.accountId
  192. }
  193. getKuaiShouChainRatio(params).then(res => {
  194. if (res.success) {
  195. if (res.result.contrast) {
  196. var now = {
  197. key: 1,
  198. ...res.result.contrast,
  199. statDate:
  200. active == 1 || active == 2
  201. ? res.result.contrast.statDate
  202. : res.result.contrast.startDate + ' ~ ' + res.result.contrast.endDate
  203. }
  204. var yesterday = {
  205. key: 2,
  206. ...res.result.beContrast,
  207. statDate:
  208. active == 1 || active == 2
  209. ? res.result.beContrast.statDate
  210. : res.result.beContrast.startDate + ' ~ ' + res.result.beContrast.endDate
  211. }
  212. var chainRatio = {
  213. key: 3,
  214. statDate: '环比',
  215. photoClickRatio: res.result.chainRatio.photoClickRatioProportion,
  216. conversions: (res.result.chainRatio.conversionsProportion * 100).toFixed(2) + '%',
  217. cost: (res.result.chainRatio.costProportion * 100).toFixed(2) + '%',
  218. impression1kCost: res.result.chainRatio.impression1kCostProportion,
  219. photoClick: (res.result.chainRatio.photoClickProportion * 100).toFixed(2) + '%',
  220. bclick: (res.result.chainRatio.bClickProportion * 100).toFixed(2) + '%',
  221. aclick: (res.result.chainRatio.aClickProportion * 100).toFixed(2) + '%',
  222. photoClickCost: res.result.chainRatio.photoClickCostProportion,
  223. conversionPrice: res.result.chainRatio.conversionPriceProportion,
  224. actionRatio: res.result.chainRatio.actionRatioProportion,
  225. actionCost: res.result.chainRatio.actionCostProportion,
  226. photoShow: (res.result.chainRatio.showProportion * 100).toFixed(2) + '%'
  227. }
  228. this.dataDetail.push(now)
  229. this.dataDetail.push(yesterday)
  230. this.dataDetail.push(chainRatio)
  231. }
  232. this.loading = false
  233. } else {
  234. this.visible = true
  235. this.loading = false
  236. }
  237. })
  238. },
  239. handleOk() {}
  240. },
  241. watch: {},
  242. distoryed() {}
  243. }
  244. </script>