xm-operation-log-list.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. <template>
  2. <div>
  3. <a-col :span="10" style="z-index: 100">
  4. <a-form-model v-bind="{ wrapperCol: { span: 24 } }">
  5. <a-form-model-item>
  6. <AuditGroupPicker
  7. v-model="unit"
  8. :single="true"
  9. :read-only="false"
  10. :root-node="rootNode"
  11. @chang="chang"
  12. />
  13. </a-form-model-item>
  14. </a-form-model>
  15. </a-col>
  16. <a-col :span="5" style="z-index: 100">
  17. <a-form-model v-bind="{ wrapperCol: { span: 24 } }">
  18. <a-form-model-item>
  19. <SdUserPicker
  20. v-model="user"
  21. :single="true"
  22. :read-only="false"
  23. :root-node="userPickerRoot"
  24. @chang="chang"
  25. />
  26. </a-form-model-item>
  27. </a-form-model>
  28. </a-col>
  29. <a-col :span="20" style="z-index: 100">
  30. <a-form-model v-bind="{ wrapperCol: { span: 24 } }">
  31. <a-form-model-item>
  32. 日志时间:
  33. <a-date-picker
  34. v-model="startDate"
  35. :default-value="startDate"
  36. placeholder="开始时间"
  37. @change="dateChange"
  38. />
  39. ~
  40. <a-date-picker
  41. v-model="endDate"
  42. :default-value="endDate"
  43. placeholder="结束时间"
  44. @change="dateChange"
  45. />
  46. {{ tip }}
  47. &nbsp;&nbsp;&nbsp;&nbsp;
  48. <a-button @click="changDate('day', -7)">近七天</a-button>
  49. <a-button @click="changDate('month', -1)">近一个月</a-button>
  50. <a-button @click="changDate('month', -3)">近三个月</a-button>
  51. <a-button>导出数据</a-button>
  52. </a-form-model-item>
  53. </a-form-model>
  54. </a-col>
  55. <sd-data-table
  56. ref="dataTable"
  57. :columns="columns"
  58. :data-url="'api/xcoa-mobile/v1/operation-log/all-list'"
  59. :process-req="processReq"
  60. :process-res="processRes"
  61. :defultpagination-pagesize="10"
  62. :row-key="'id'"
  63. :change-param="changeParam"
  64. >
  65. </sd-data-table>
  66. </div>
  67. </template>
  68. <script>
  69. import components from './_import-components/xm-operation-log-list-import'
  70. import AuditGroupPicker from '../../components/picker/audit-group-picker.vue'
  71. import SdUserPicker from '@/common/components/sd-user-picker.vue'
  72. import { getUserInfo } from '@/common/store-mixin'
  73. import axios from '@/common/services/axios-instance'
  74. import moment from 'moment'
  75. export default {
  76. name: 'XmOperatorLogList',
  77. metaInfo: {
  78. title: '用户操作日志列表',
  79. },
  80. components: { ...components, AuditGroupPicker, SdUserPicker },
  81. // components,
  82. data() {
  83. return {
  84. startDate: '',
  85. endDate: '',
  86. tip: '',
  87. unit: [],
  88. user: [],
  89. rootNode: {},
  90. data: [],
  91. columns: [],
  92. }
  93. },
  94. computed: {
  95. userPickerRoot() {
  96. return this.unit.length > 0 ? this.unit[0] : this.rootNode
  97. },
  98. },
  99. mounted() {
  100. this.columns.push({ title: '姓名', dataIndex: 'userName', width: '120px' })
  101. this.columns.push({ title: '公司', dataIndex: 'parentCompanyName' })
  102. this.columns.push({ title: '操作时间', dataIndex: 'time' })
  103. this.columns.push({ title: '操作模块', dataIndex: 'menuName' })
  104. this.columns.push({ title: '使用时长', dataIndex: 'holderDesc' })
  105. this.initAuditUnit()
  106. },
  107. methods: {
  108. changeParam(param) {
  109. console.log(param)
  110. param.startDateRange = this.startDate
  111. param.endDateRange = this.endDate
  112. if (this.unit.length !== 0) {
  113. param.unitCode = this.unit[0].code
  114. param.unitId = this.unit[0].id
  115. }
  116. if (this.user.length !== 0) {
  117. param.account = this.user[0].code
  118. }
  119. },
  120. chang() {
  121. this.$refs.dataTable.refresh()
  122. },
  123. dateChange(data) {
  124. this.$refs.dataTable.refresh()
  125. this.tip = ''
  126. },
  127. changDate(type, amount) {
  128. if (type === 'day') {
  129. const d1 = new Date()
  130. d1.setDate(d1.getDate() + amount)
  131. this.startDate = moment(d1.getTime()).format('YYYY-MM-DD')
  132. this.endDate = moment(new Date().getTime()).format('YYYY-MM-DD')
  133. this.tip = '近' + Math.abs(amount) + '天'
  134. }
  135. if (type === 'month') {
  136. const d2 = new Date()
  137. d2.setMonth(d2.getMonth() + amount)
  138. this.startDate = moment(d2.getTime()).format('YYYY-MM-DD')
  139. this.endDate = moment(new Date().getTime()).format('YYYY-MM-DD')
  140. this.tip = '近' + Math.abs(amount) + '个月'
  141. }
  142. this.$refs.dataTable.refresh()
  143. },
  144. processRes(res) {
  145. console.log(res)
  146. const data1 = []
  147. if (res.data.length > 0) {
  148. const localOffset = new Date().getTimezoneOffset() * 60000 // 本地时区偏移量(以毫秒为单位)
  149. res.data.forEach((item) => {
  150. item.time = moment(item.time).format('YYYY-MM-DD hh:mm:ss')
  151. item.holderDesc = item.holderDesc ? item.holderDesc : '-'
  152. data1.push(item)
  153. })
  154. }
  155. return { data: data1, total: res.totalSize }
  156. },
  157. processReq(req) {
  158. if (req.data.pageSize === undefined) {
  159. req.data.pageSize = 10
  160. }
  161. return req
  162. },
  163. initAuditUnit() {
  164. const userInfo = getUserInfo()
  165. console.log(userInfo)
  166. const params = {}
  167. axios({
  168. url: 'api/xcoa-mobile/v1/iamorg/getCurrentUserGroup',
  169. method: 'get',
  170. }).then((res) => {
  171. params.orgId = res.data.id
  172. axios({
  173. url: 'api/xcoa-mobile/v1/iamorg/findIamOrg',
  174. method: 'post',
  175. params,
  176. }).then((res) => {
  177. const groupInfo = res.data
  178. const deptCode = groupInfo.orgId
  179. const deptName = res.data.orgName
  180. this.rootNode = { code: deptCode, name: deptName, id: res.data.id }
  181. this.unit = [this.rootNode]
  182. this.changDate('day', -7)
  183. })
  184. })
  185. },
  186. },
  187. }
  188. </script>
  189. <style module lang="scss">
  190. @use '@/common/design' as *;
  191. </style>