timeStatistics.vue 11 KB

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