xm-operation-statistics.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <template>
  2. <div>
  3. <a-col :span="20" style="z-index:100">
  4. <a-form-model v-bind="{ wrapperCol: { span: 24 } }">
  5. <a-form-model-item>
  6. 统计时间:
  7. <a-date-picker
  8. v-model="startDate"
  9. :default-value="startDate"
  10. placeholder="开始时间"
  11. @change="dateChange"
  12. />
  13. ~
  14. <a-date-picker
  15. v-model="endDate"
  16. :default-value="endDate"
  17. placeholder="结束时间"
  18. @change="dateChange"
  19. />
  20. {{ tip }}
  21. &nbsp;&nbsp;&nbsp;&nbsp;
  22. <a-button @click="changDate('day', -7)">近七天</a-button>
  23. <a-button @click="changDate('month', -1)">近一个月</a-button>
  24. <a-button @click="changDate('month', -3)">近三个月</a-button>
  25. </a-form-model-item>
  26. </a-form-model>
  27. </a-col>
  28. <sd-data-table
  29. ref="dataTable"
  30. :columns="columns"
  31. :data-url="'api/xcoa-mobile/v1/operation-log/statistics'"
  32. :process-req="processReq"
  33. :defultpagination-pagesize="100"
  34. :process-res="processRes"
  35. :row-key="'menuId'"
  36. :change-param="changeParam"
  37. >
  38. </sd-data-table>
  39. </div>
  40. </template>
  41. <script>
  42. import moment from 'moment'
  43. import components from './_import-components/xm-operation-log-list-import'
  44. export default {
  45. name: 'XmOperatorStatisticsList',
  46. metaInfo: {
  47. title: '用户操作统计',
  48. },
  49. components,
  50. data() {
  51. return {
  52. startDate: '2024-01-11',
  53. endDate: '2024-01-11',
  54. tip: '',
  55. data: [],
  56. columns: [],
  57. }
  58. },
  59. computed: {},
  60. mounted() {
  61. this.columns.push({ title: '模块', dataIndex: 'menuName' })
  62. this.columns.push({ title: '点击次数', dataIndex: 'count' })
  63. this.changDate('day', -7)
  64. },
  65. methods: {
  66. dateChange(data) {
  67. this.$refs.dataTable.refresh()
  68. this.tip = ''
  69. },
  70. changDate(type, amount) {
  71. if (type === 'day') {
  72. const d1 = new Date()
  73. d1.setDate(d1.getDate() + amount)
  74. this.startDate = moment(d1.getTime()).format('YYYY-MM-DD')
  75. this.endDate = moment(new Date().getTime()).format('YYYY-MM-DD')
  76. this.tip = '近' + Math.abs(amount) + '天'
  77. }
  78. if (type === 'month') {
  79. const d2 = new Date()
  80. d2.setMonth(d2.getMonth() + amount)
  81. this.startDate = moment(d2.getTime()).format('YYYY-MM-DD')
  82. this.endDate = moment(new Date().getTime()).format('YYYY-MM-DD')
  83. this.tip = '近' + Math.abs(amount) + '个月'
  84. }
  85. this.$refs.dataTable.refresh()
  86. },
  87. changeParam(param) {
  88. console.log(param)
  89. param.startDateRange = this.startDate
  90. param.endDateRange = this.endDate
  91. },
  92. processRes(res) {
  93. return res
  94. },
  95. processReq(req) {
  96. if (req.data.pageSize === undefined) {
  97. req.data.pageSize = 10
  98. }
  99. return req
  100. },
  101. },
  102. }
  103. </script>
  104. <style module lang="scss">
  105. @use '@/common/design' as *;
  106. </style>