timeStatistics.vue 11 KB

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