accountMaterStatistics.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561
  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. <!-- <a-select
  51. v-model="appId"
  52. showSearch
  53. allowClear
  54. mode="multiple"
  55. placeholder="请选择账户"
  56. optionFilterProp="children"
  57. style="width: 50%"
  58. @focus="handleFocus"
  59. @blur="handleBlur"
  60. @change="handleChange"
  61. :filterOption="true"
  62. @search="search"
  63. :maxTagCount="1"
  64. >
  65. <a-select-option
  66. v-for="appModel in options"
  67. :key="appModel.id + new Date().getTime()"
  68. :value="appModel.accountId"
  69. >{{ appModel.advertiserName }}&#12288;&#12288;{{ appModel.accountId }}&#12288;&nbsp;&#12288;{{
  70. appModel.authName
  71. }}&#12288;&#12288;{{ appModel.operationName }}</a-select-option
  72. >
  73. </a-select> -->
  74. <treeselect :appId.sync="appId" />
  75. <a-button type="primary" style="margin:10px" @click="addUser">搜索</a-button>
  76. <a-button
  77. type="primary"
  78. icon="reload"
  79. @click="getDataReset"
  80. style="background-color:#67c23a;border-color:#67c23a"
  81. >刷新</a-button
  82. >
  83. </div>
  84. </a-row>
  85. <a-row>
  86. <a-col :span="24">
  87. <a-card :bordered="false" class="search-box">
  88. <time-check @getAdd="getAdd" :startValue.sync="startValue" :timeList="timeList"></time-check>
  89. </a-card>
  90. </a-col>
  91. </a-row>
  92. </a-row>
  93. <a-row :gutter="10" style="margin-top:10px">
  94. <a-col :span="24">
  95. <a-card style="width:100%;">
  96. <a-table
  97. :columns="columns"
  98. :dataSource="data"
  99. bordered
  100. id="outTable"
  101. :pagination="ipagination"
  102. size="middle"
  103. :customRow="rowClick"
  104. :loading="loading"
  105. :scroll="{ x: true }"
  106. >
  107. <div slot="url" slot-scope="url">
  108. <video class="video" :src="url" controls="controls" style="height:200px;width:112.5px">
  109. 您的浏览器不支持 video 标签。
  110. </video>
  111. </div>
  112. <span slot="photoClickRatio" slot-scope="photoClickRatio">{{ photoClickRatio | getBo }}</span>
  113. <span slot="actionRatio" slot-scope="actionRatio">{{ actionRatio | getBo }}</span>
  114. <span slot="impression1kCost" slot-scope="impression1kCost">{{ impression1kCost | toFixtwo }}</span>
  115. <span slot="photoClickCost" slot-scope="photoClickCost">{{ photoClickCost | toFixtwo }}</span>
  116. <span slot="actionCost" slot-scope="actionCost">{{ actionCost | toFixtwo }}</span>
  117. <span slot="conversionPrice" slot-scope="conversionPrice">{{ conversionPrice | toFixtwo }}</span>
  118. </a-table>
  119. </a-card>
  120. </a-col>
  121. </a-row>
  122. <ratio-modal ref="ratio" />
  123. </div>
  124. </template>
  125. <script>
  126. import ARow from 'ant-design-vue/es/grid/Row'
  127. import ACol from 'ant-design-vue/es/grid/Col'
  128. import countTo from 'vue-count-to'
  129. import moment from 'moment'
  130. import { getMaterialReportByAccount, getMaterialAccount } from '@api/statistics'
  131. import axios from 'axios'
  132. import lifting from './components/lifting'
  133. import timeCheck from './components/timeCheck'
  134. import ratioModal from './components/ratioModal'
  135. import { mapGetters } from 'vuex'
  136. import { JeecgListMixin } from '@/mixins/ipagination'
  137. // import the component
  138. import Treeselect from './components/Treeselect.vue'
  139. // 引入基本模板
  140. let echarts = require('echarts/lib/echarts')
  141. // 引入柱状图组件
  142. require('echarts/lib/chart/bar')
  143. require('echarts/lib/chart/pie')
  144. require('echarts/lib/chart/line')
  145. // 引入提示框和title组件
  146. require('echarts/lib/component/tooltip')
  147. require('echarts/lib/component/title')
  148. require('echarts/lib/component/graphic')
  149. require('echarts/lib/component/toolbox')
  150. require('echarts/lib/component/legend')
  151. var length = 0
  152. var active = 1
  153. const columns = [
  154. {
  155. title: '视频',
  156. dataIndex: 'url',
  157. key: 'url',
  158. align: 'center',
  159. scopedSlots: { customRender: 'url' },
  160. fixed: 'left',
  161. width: 150
  162. },
  163. {
  164. title: '花费',
  165. dataIndex: 'cost',
  166. key: 'cost',
  167. align: 'center',
  168. sorter: (a, b) => a.cost - b.cost
  169. },
  170. {
  171. title: '封面曝光数',
  172. dataIndex: 'photoShow',
  173. key: 'photoShow',
  174. align: 'center',
  175. sorter: (a, b) => a.photoShow - b.photoShow
  176. },
  177. {
  178. title: '封面点击数',
  179. dataIndex: 'photoClick',
  180. key: 'photoClick',
  181. align: 'center',
  182. sorter: (a, b) => a.photoClick - b.photoClick
  183. },
  184. {
  185. title: '素材曝光数',
  186. dataIndex: 'aclick',
  187. key: 'aclick',
  188. align: 'center',
  189. sorter: (a, b) => a.aclick - b.aclick
  190. },
  191. {
  192. title: '行为数',
  193. dataIndex: 'bclick',
  194. key: 'bclick',
  195. align: 'center',
  196. sorter: (a, b) => a.bclick - b.bclick
  197. },
  198. {
  199. title: '封面点击率',
  200. dataIndex: 'photoClickRatio',
  201. key: 'photoClickRatio',
  202. align: 'center',
  203. scopedSlots: { customRender: 'photoClickRatio' },
  204. sorter: (a, b) => a.photoClickRatio - b.photoClickRatio
  205. },
  206. {
  207. title: '行为率',
  208. dataIndex: 'actionRatio',
  209. key: 'actionRatio',
  210. align: 'center',
  211. scopedSlots: { customRender: 'actionRatio' },
  212. sorter: (a, b) => a.actionRatio - b.actionRatio
  213. },
  214. {
  215. title: '均千次封面曝光花费(元)',
  216. dataIndex: 'impression1kCost',
  217. key: 'impression1kCost',
  218. scopedSlots: { customRender: 'impression1kCost' },
  219. align: 'center',
  220. sorter: (a, b) => a.impression1kCost - b.impression1kCost
  221. },
  222. {
  223. title: '平均封面点击单价(元)',
  224. dataIndex: 'photoClickCost',
  225. key: 'photoClickCost',
  226. scopedSlots: { customRender: 'photoClickCost' },
  227. align: 'center',
  228. sorter: (a, b) => a.photoClickCost - b.photoClickCost
  229. },
  230. {
  231. title: '平均行为单价(元)',
  232. dataIndex: 'actionCost',
  233. key: 'actionCost',
  234. scopedSlots: { customRender: 'actionCost' },
  235. align: 'center',
  236. sorter: (a, b) => a.actionCost - b.actionCost
  237. },
  238. {
  239. title: '转化数',
  240. dataIndex: 'conversions',
  241. key: 'conversions',
  242. align: 'center',
  243. sorter: (a, b) => a.conversions - b.conversions
  244. },
  245. {
  246. title: '转化单价(元)',
  247. dataIndex: 'conversionPrice',
  248. key: 'conversionPrice',
  249. scopedSlots: { customRender: 'conversionPrice' },
  250. align: 'center',
  251. sorter: (a, b) => a.conversionPrice - b.conversionPrice
  252. }
  253. ]
  254. const columnsDetail = [
  255. {
  256. title: '日期',
  257. dataIndex: 'statDate',
  258. key: 'statDate',
  259. align: 'center'
  260. },
  261. {
  262. title: '花费',
  263. dataIndex: 'cost',
  264. key: 'cost',
  265. align: 'center'
  266. },
  267. {
  268. title: '封面曝光数',
  269. dataIndex: 'photoShow',
  270. key: 'photoShow',
  271. align: 'center'
  272. },
  273. {
  274. title: '封面点击数',
  275. dataIndex: 'photoClick',
  276. key: 'photoClick',
  277. align: 'center'
  278. },
  279. {
  280. title: '素材曝光数',
  281. dataIndex: 'aclick',
  282. key: 'aclick',
  283. align: 'center'
  284. },
  285. {
  286. title: '行为数',
  287. dataIndex: 'bclick',
  288. key: 'bclick',
  289. align: 'center'
  290. },
  291. {
  292. title: '封面点击率',
  293. dataIndex: 'photoClickRatio',
  294. key: 'photoClickRatio',
  295. align: 'center',
  296. scopedSlots: { customRender: 'photoClickRatio' }
  297. },
  298. {
  299. title: '行为率',
  300. dataIndex: 'actionRatio',
  301. key: 'actionRatio',
  302. align: 'center',
  303. scopedSlots: { customRender: 'actionRatio' }
  304. },
  305. {
  306. title: '均千次封面曝光花费(元)',
  307. dataIndex: 'impression1kCost',
  308. key: 'impression1kCost',
  309. scopedSlots: { customRender: 'impression1kCost' },
  310. align: 'center'
  311. },
  312. {
  313. title: '平均封面点击单价(元)',
  314. dataIndex: 'photoClickCost',
  315. key: 'photoClickCost',
  316. scopedSlots: { customRender: 'photoClickCost' },
  317. align: 'center'
  318. },
  319. {
  320. title: '平均行为单价(元)',
  321. dataIndex: 'actionCost',
  322. key: 'actionCost',
  323. scopedSlots: { customRender: 'actionCost' },
  324. align: 'center'
  325. },
  326. {
  327. title: '转化数',
  328. dataIndex: 'conversions',
  329. key: 'conversions',
  330. align: 'center'
  331. },
  332. {
  333. title: '转化单价(元)',
  334. dataIndex: 'conversionPrice',
  335. key: 'conversionPrice',
  336. scopedSlots: { customRender: 'conversionPrice' },
  337. align: 'center'
  338. }
  339. ]
  340. export default {
  341. name: 'data-display-statistics',
  342. components: {
  343. ACol,
  344. ARow,
  345. countTo,
  346. lifting,
  347. timeCheck,
  348. ratioModal,
  349. Treeselect
  350. },
  351. mixins: [JeecgListMixin],
  352. data: function() {
  353. return {
  354. title: '账户素材报表',
  355. show: true,
  356. timeList: [
  357. { label: '今天', value: 1, show: true },
  358. { label: '昨天', value: 2, show: true },
  359. { label: '近一周', value: 3, show: true },
  360. { label: '近十五天', value: 4, show: true },
  361. { label: '近一月', value: 5, show: true },
  362. { label: '近三月', value: 6, show: true }
  363. ],
  364. active: 1,
  365. data: [],
  366. columns,
  367. columnsDetail,
  368. options: [],
  369. list: [],
  370. appId: [],
  371. startValue: [],
  372. allValue: [],
  373. loading: false,
  374. // pagination: {
  375. // // 分页配置器
  376. // pageSize: 10, // 一页的数据限制
  377. // current: 1, // 当前页
  378. // onChange: current => {
  379. // // 切换分页时的回调,
  380. // // 当在页面定义change事件时,切记要把此处的事件清除,因为这两个事件重叠了,可能到时候会导致一些莫名的bug
  381. // this.pagination.current = current
  382. // }
  383. // },
  384. rowClick: record => ({
  385. // 事件
  386. on: {
  387. click: () => {
  388. // 点击改行时要做的事情
  389. // this.detail = record
  390. // this.visible = true
  391. // this.getMineList(record.signature)
  392. this.$refs.ratio.getMineList(record, this.active)
  393. }
  394. }
  395. })
  396. }
  397. },
  398. filters: {
  399. formatDate: function(value) {
  400. let date = new Date(value)
  401. let y = date.getFullYear()
  402. let MM = date.getMonth() + 1
  403. MM = MM < 10 ? '0' + MM : MM
  404. let d = date.getDate()
  405. d = d < 10 ? '0' + d : d
  406. let h = date.getHours()
  407. h = h < 10 ? '0' + h : h
  408. let m = date.getMinutes()
  409. m = m < 10 ? '0' + m : m
  410. let s = date.getSeconds()
  411. s = s < 10 ? '0' + s : s
  412. return y + '-' + MM + '-' + d + ' ' + h + ':' + m + ':' + s
  413. },
  414. toFixtwo: function(value) {
  415. if (value) {
  416. return value.toFixed(2)
  417. } else {
  418. return 0.0
  419. }
  420. },
  421. getBo: function(value) {
  422. if (value) {
  423. return (value * 100).toFixed(2) + '%'
  424. } else {
  425. return '0.00%'
  426. }
  427. }
  428. },
  429. methods: {
  430. moment,
  431. ...mapGetters(['nickname', 'avatar', 'userInfo']),
  432. disabledDate(current) {
  433. return current && current > moment().endOf('day')
  434. },
  435. handleChange(value) {
  436. console.log(value)
  437. // this.appId = value
  438. },
  439. getElseData(value) {
  440. this.getStatistics()
  441. },
  442. handleBlur() {
  443. console.log('blur')
  444. },
  445. handleFocus() {
  446. console.log('focus')
  447. if (this.appId.length > 0) {
  448. this.options = []
  449. for (let i = 0; i < this.list.length; i++) {
  450. for (let j = 0; j < this.appId.length; j++) {
  451. if (this.list[i].accountId == this.appId[j]) {
  452. this.options.push(this.list[i])
  453. }
  454. }
  455. }
  456. } else {
  457. this.options = this.list
  458. }
  459. },
  460. search(value) {
  461. // console.log(value)
  462. this.options = []
  463. if (value != '') {
  464. this.options = this.list.filter(item => {
  465. var data = item.accountId + ' ' + item.authName + ' ' + item.advertiserName + ' ' + item.operationName
  466. return data.toLowerCase().indexOf(value.toLowerCase()) > -1
  467. })
  468. this.options = [...this.options]
  469. console.log(this.options)
  470. } else {
  471. if (this.appId.length > 0) {
  472. this.options = []
  473. for (let i = 0; i < this.list.length; i++) {
  474. for (let j = 0; j < this.appId.length; j++) {
  475. if (this.list[i].accountId == this.appId[j]) {
  476. this.options.push(this.list[i])
  477. }
  478. }
  479. }
  480. } else {
  481. this.options = this.list
  482. }
  483. }
  484. },
  485. getDataReset() {
  486. this.active = 1
  487. this.allValue = []
  488. this.addUser()
  489. },
  490. addUser() {
  491. this.loading = true
  492. var that = this
  493. if (this.appId.length > 0) {
  494. var params = {}
  495. params.accountIds = JSON.stringify(that.appId)
  496. params.type = that.active
  497. if (that.active == 9) {
  498. params.startDate = this.allValue[0]
  499. params.endDate = this.allValue[1]
  500. }
  501. } else {
  502. this.$message.error('请选择账户')
  503. return
  504. }
  505. getMaterialReportByAccount(params).then(res => {
  506. this.data = res
  507. this.ipagination.total = res.length
  508. this.loading = false
  509. })
  510. },
  511. getStatistics() {
  512. var params = {}
  513. params.accountIds = JSON.stringify(this.appId)
  514. params.type = this.active
  515. params.statHour = this.statHour
  516. params.discount = this.discount
  517. if (this.active == 9) {
  518. params.startDate = this.allValue[0]
  519. params.endDate = this.allValue[1]
  520. }
  521. this.data = []
  522. },
  523. getAdd(checked) {
  524. if (checked == 9) {
  525. if (this.startValue.length > 0 && this.startValue[0]) {
  526. this.allValue[0] = moment(this.startValue[0]._d).format('YYYY-MM-DD')
  527. this.allValue[1] = moment(this.startValue[1]._d).format('YYYY-MM-DD')
  528. }
  529. } else {
  530. this.startValue = []
  531. this.allValue = []
  532. }
  533. this.active = checked
  534. active = checked
  535. this.pagination.current = 1
  536. this.addUser(checked)
  537. },
  538. dianji() {
  539. this.$router.replace({ path: '/modules/Statistics/materialStatistics' })
  540. }
  541. },
  542. watch: {},
  543. distoryed() {},
  544. mounted: function() {
  545. this.$nextTick(() => {
  546. getMaterialAccount({ userId: this.userInfo().id }).then(res => {
  547. this.list = res
  548. this.options = res
  549. })
  550. })
  551. }
  552. }
  553. </script>