dayStatistics.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397
  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.id">
  80. {{ item.projectName }}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{{
  81. item.mediaId == "1" ? '头条' :item.mediaId == "2"? '快手':item.mediaId == "3"?'头条内广':'快手内广'
  82. }}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{{ item.advertiserName }}
  83. </a-select-option>
  84. </a-select>
  85. <span style="margin-left:10px">系统类型:</span>
  86. <a-select
  87. v-model="systemType"
  88. style="width:300px"
  89. showSearch
  90. optionFilterProp="children"
  91. :filterOption="filterOption"
  92. >
  93. <a-select-option value="1">
  94. 不限
  95. </a-select-option>
  96. <a-select-option value="android">
  97. 安卓
  98. </a-select-option>
  99. <a-select-option value="ios">
  100. ios
  101. </a-select-option>
  102. </a-select>
  103. <a-button type="primary" style="margin:10px" @click="addUser">搜索</a-button>
  104. <a-button
  105. type="primary"
  106. icon="reload"
  107. @click="getDataReset"
  108. style="background-color:#67c23a;border-color:#67c23a"
  109. >刷新</a-button
  110. >
  111. </div>
  112. </a-row>
  113. </a-row>
  114. <a-row :gutter="10" style="margin-top:10px">
  115. <a-col :span="24">
  116. <a-card
  117. style="width:100%"
  118. :tabList="tabListNoTitle"
  119. :activeTabKey="noTitleKey"
  120. @tabChange="key => onTabChange(key, 'noTitleKey')"
  121. >
  122. <div style="display:flex;margin-bottom:15px" v-if="tabListNoTitle.length > 0">
  123. <!-- <a-select style="width: 120px" v-model="statHour" @change="getElseData" allowClear>
  124. <a-select-option v-for="item of 24" :key="item - 1" :value="item - 1">{{ item - 1 }}</a-select-option>
  125. </a-select> -->
  126. <a-button type="primary" @click="exportExcel">导出</a-button>
  127. </div>
  128. <a-table
  129. v-if="tabListNoTitle.length > 0"
  130. size="middle"
  131. :columns="columns"
  132. :dataSource="data"
  133. bordered
  134. id="outTable"
  135. :pagination="ipagination"
  136. :scroll="{ x: true }"
  137. :loading="loading"
  138. >
  139. </a-table>
  140. </a-card>
  141. </a-col>
  142. </a-row>
  143. </div>
  144. </template>
  145. <script>
  146. import ARow from 'ant-design-vue/es/grid/Row'
  147. import ACol from 'ant-design-vue/es/grid/Col'
  148. import countTo from 'vue-count-to'
  149. import moment from 'moment'
  150. import { getDailyReport } from '@api/statistics'
  151. import { getAction, postAction, downFile, downFilePost } from '@/api/manage'
  152. import axios from 'axios'
  153. import lifting from '../components/lifting'
  154. import timeCheck from '../components/timeCheck'
  155. import Treeselect from '../components/Treeselect.vue'
  156. import { mapGetters } from 'vuex'
  157. import { JeecgListMixin } from '@/mixins/ipagination'
  158. import qs from 'qs'
  159. var length = 0
  160. var active = 1
  161. const columns = [
  162. {
  163. title: '日期',
  164. dataIndex: 'date',
  165. scopedSlots: { customRender: 'date' },
  166. align: 'center'
  167. },
  168. {
  169. title: '总花费(元)',
  170. dataIndex: 'cost',
  171. align: 'center'
  172. },
  173. {
  174. title: '双出价(元)',
  175. dataIndex: 'doubleBid',
  176. align: 'center'
  177. },
  178. {
  179. title: '非双出价(元)',
  180. dataIndex: 'singleBid',
  181. align: 'center'
  182. },
  183. {
  184. title: '激活数',
  185. dataIndex: 'active',
  186. align: 'center'
  187. },
  188. {
  189. title: '激活成本',
  190. dataIndex: 'activeCost',
  191. align: 'center'
  192. },
  193. {
  194. title: '每日计划(组)',
  195. dataIndex: 'planNum',
  196. align: 'center'
  197. },
  198. {
  199. title: '每日素材安排',
  200. dataIndex: 'mat',
  201. align: 'center'
  202. }
  203. ]
  204. export default {
  205. name: 'data-display-statistics',
  206. components: {
  207. ACol,
  208. ARow,
  209. countTo,
  210. lifting,
  211. timeCheck,
  212. Treeselect
  213. },
  214. mixins: [JeecgListMixin],
  215. data: function() {
  216. return {
  217. // this.timeRange[1] = moment().add(1, 'months')
  218. statDate: moment().subtract(1, 'day'),
  219. title: '账户数据展示',
  220. show: true,
  221. data: [],
  222. dataAll: null,
  223. columns: columns,
  224. options: [],
  225. list: [],
  226. appId: [],
  227. tabListNoTitle: [],
  228. noTitleKey: 'day',
  229. discount: 1.06,
  230. date: '',
  231. loading: false,
  232. dataElse: [],
  233. projectId: 285,
  234. systemType: '1'
  235. }
  236. },
  237. filters: {
  238. formatDate: function(value) {
  239. let date = new Date(value)
  240. let y = date.getFullYear()
  241. let MM = date.getMonth() + 1
  242. MM = MM < 10 ? '0' + MM : MM
  243. let d = date.getDate()
  244. d = d < 10 ? '0' + d : d
  245. let h = date.getHours()
  246. h = h < 10 ? '0' + h : h
  247. let m = date.getMinutes()
  248. m = m < 10 ? '0' + m : m
  249. let s = date.getSeconds()
  250. s = s < 10 ? '0' + s : s
  251. return y + '-' + MM + '-' + d
  252. },
  253. toFixtwo: function(value) {
  254. if (value) {
  255. return value.toFixed(2)
  256. } else {
  257. return 0.0
  258. }
  259. },
  260. getBo: function(value) {
  261. if (value) {
  262. return (value * 100).toFixed(2) + '%'
  263. } else {
  264. return '0.00%'
  265. }
  266. }
  267. },
  268. methods: {
  269. moment,
  270. filterOption(input, option) {
  271. return option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  272. },
  273. ...mapGetters(['nickname', 'avatar', 'userInfo']),
  274. getParticipateList() {
  275. getAction('/ctop/projectMember/participateList', {
  276. userId: this.userInfo().id
  277. }).then(res => {
  278. if (res.code == 0) {
  279. this.dataElse = res.result
  280. }
  281. })
  282. },
  283. onTabChange(key, type) {
  284. console.log(key, type)
  285. this[type] = key
  286. this.data = []
  287. var list = this.tabListNoTitle.filter(item => {
  288. return item.key == key
  289. })
  290. console.log(list)
  291. this.data = list[0].data
  292. this.ipagination.total = this.data.length
  293. this.ipagination.current = 1
  294. },
  295. disabledDate(current) {
  296. return current && current > moment().subtract(1, 'day')
  297. },
  298. getDataReset() {
  299. this.addUser()
  300. },
  301. addUser() {
  302. var that = this
  303. // if (this.appId.length > 0 && this.date != '') {
  304. that.getDailyReport()
  305. // } else {
  306. // this.$message.error('请选择账户及时间')
  307. // }
  308. },
  309. getDailyReport() {
  310. var params = {}
  311. params.projectId = this.projectId
  312. params.systemType = this.systemType == '1' ? '' : this.systemType
  313. this.data = []
  314. this.loading = true
  315. postAction('/ctop/advertiser/xxlDailyReportList', params).then(res => {
  316. if (res.success) {
  317. console.log(res)
  318. this.loading = false
  319. // {
  320. // key: 'channel',
  321. // tab: '渠道包分析'
  322. // }
  323. // ],
  324. // noTitleKey: 'day',
  325. this.noTitleKey = res.data[0].sheetName
  326. this.tabListNoTitle = res.data.map(item => {
  327. return {
  328. key: item.sheetName,
  329. tab: item.sheetName,
  330. data: item.details
  331. }
  332. })
  333. this.data = this.tabListNoTitle[0].data.map((item, index) => {
  334. return {
  335. ...item,
  336. key: index
  337. }
  338. })
  339. this.ipagination.total = this.data.length
  340. }
  341. })
  342. },
  343. getDate(value) {
  344. if (value) {
  345. let date = new Date(value)
  346. let y = date.getFullYear()
  347. let MM = date.getMonth() + 1
  348. MM = MM < 10 ? '0' + MM : MM
  349. let d = date.getDate()
  350. d = d < 10 ? '0' + d : d
  351. this.date = y + '-' + MM + '-' + d
  352. } else {
  353. let date = new Date()
  354. let y = date.getFullYear()
  355. let MM = date.getMonth() + 1
  356. MM = MM < 10 ? '0' + MM : MM
  357. let d = date.getDate()
  358. d = d < 10 ? '0' + d : d
  359. this.date = y + '-' + MM + '-' + d
  360. }
  361. },
  362. exportExcel() {
  363. var params = {}
  364. params.projectId = this.projectId
  365. params.systemType = this.systemType == '1' ? '' : this.systemType
  366. var param = qs.stringify(params)
  367. var name = this.dataElse.filter(item => {
  368. return item.projectId == this.projectId
  369. })[0].projectName
  370. downFilePost('/ctop/advertiser/exportXxlDailyReport', param).then(res => {
  371. let blob = new Blob([res], {
  372. type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
  373. })
  374. let downloadElement = document.createElement('a')
  375. let href = window.URL.createObjectURL(blob) //创建下载的链接
  376. downloadElement.href = href
  377. downloadElement.download = name + '-' + this.statDate.format('YYYY-MM-DD') + '-日报' //下载后文件名
  378. document.body.appendChild(downloadElement)
  379. downloadElement.click() //点击下载
  380. document.body.removeChild(downloadElement) //下载完成移除元素
  381. window.URL.revokeObjectURL(href) //释放掉blob对象
  382. })
  383. }
  384. },
  385. watch: {},
  386. distoryed() {},
  387. mounted: function() {
  388. this.getParticipateList()
  389. this.statDate = moment().subtract(1, 'day')
  390. // moment().format('YYYY-MM-DD_HH:mm')
  391. }
  392. }
  393. </script>