index.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. <template>
  2. <table-page-template>
  3. <div slot='form' class='condition'>
  4. <el-input
  5. v-model.trim='searchValue'
  6. class='margin-right'
  7. style='width: 300px;'
  8. placeholder='请输入操作人、动作、对象id等关键字搜索'
  9. @change='searchChange'
  10. ></el-input>
  11. <el-date-picker
  12. class='margin-right'
  13. v-model='dateValue'
  14. type='daterange'
  15. align='right'
  16. :clearable='false'
  17. unlink-panels
  18. range-separator='至'
  19. start-placeholder='开始日期'
  20. end-placeholder='结束日期'
  21. :picker-options='pickerOptions'
  22. @change='dateChange'
  23. value-format='yyyy-MM-dd'
  24. ></el-date-picker>
  25. <el-button type='primary'>动作说明</el-button>
  26. <el-button type='primary' @click='refresh'>刷新</el-button>
  27. <el-button type='primary' @click='downExcel'>导出到Excel</el-button>
  28. </div>
  29. <el-table slot='table' :data='tableData' border tooltip-effect='dark' style='width: 100%' v-loading='loading'>
  30. <el-table-column prop='CreateTime' label='时间' width='150'></el-table-column>
  31. <el-table-column prop='Comming' label='来源' width='120'></el-table-column>
  32. <el-table-column prop='UserName' label='操作人' width='120'></el-table-column>
  33. <el-table-column prop='Phone' label='手机' width='150'></el-table-column>
  34. <el-table-column prop='Action' label='动作'></el-table-column>
  35. <el-table-column prop='UserId' label='对象id'></el-table-column>
  36. <el-table-column label='操作说明' width='350'>
  37. <template slot-scope='scope'>
  38. <div class='ellipsis' :title='scope.row.Note'>{{scope.row.Note}}</div>
  39. </template>
  40. </el-table-column>
  41. </el-table>
  42. <base-pagination :currentPages='pageNum' :total='total' @pageChanged='pageChanged' slot='pagination'></base-pagination>
  43. </table-page-template>
  44. </template>
  45. <script>
  46. import {
  47. getBuildLog, //获取日志
  48. dowmloadLog //下载日志
  49. } from '@/api/scan/request'
  50. import { mapGetters, mapActions } from 'vuex'
  51. import axios from 'axios'
  52. var date = new Date()
  53. const nowDate = date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate()
  54. export default {
  55. name: 'data-log',
  56. data() {
  57. return {
  58. loading: false,
  59. searchValue: '',
  60. tableData: [],
  61. dateValue: [nowDate, nowDate],
  62. pickerOptions: {
  63. shortcuts: [
  64. {
  65. text: '今天',
  66. onClick(picker) {
  67. const end = new Date()
  68. const start = new Date()
  69. start.setTime(start.getTime() - 3600 * 1000 * 24 * 0)
  70. picker.$emit('pick', [start, end])
  71. }
  72. },
  73. {
  74. text: '昨天',
  75. onClick(picker) {
  76. const end = new Date()
  77. const start = new Date()
  78. start.setTime(start.getTime() - 3600 * 1000 * 24 * 1)
  79. picker.$emit('pick', [start, end])
  80. }
  81. },
  82. {
  83. text: '最近三天',
  84. onClick(picker) {
  85. const end = new Date()
  86. const start = new Date()
  87. start.setTime(start.getTime() - 3600 * 1000 * 24 * 3)
  88. picker.$emit('pick', [start, end])
  89. }
  90. },
  91. {
  92. text: '最近一周',
  93. onClick(picker) {
  94. const end = new Date()
  95. const start = new Date()
  96. start.setTime(start.getTime() - 3600 * 1000 * 24 * 7)
  97. picker.$emit('pick', [start, end])
  98. }
  99. },
  100. {
  101. text: '最近一个月',
  102. onClick(picker) {
  103. const end = new Date()
  104. const start = new Date()
  105. start.setTime(start.getTime() - 3600 * 1000 * 24 * 30)
  106. picker.$emit('pick', [start, end])
  107. }
  108. }
  109. ]
  110. },
  111. pageNum: 1,
  112. pageSize: 10,
  113. total: 80
  114. }
  115. },
  116. computed: {
  117. ...mapGetters('peojMess', ['projectId', 'userId'])
  118. },
  119. methods: {
  120. searchChange(value) {
  121. this.pageNum = 1
  122. this.getLogData()
  123. },
  124. refresh() {
  125. this.getLogData()
  126. },
  127. // 导出
  128. downExcel() {
  129. let param = {
  130. startTime: this.dateValue[0] + ' 00:00:00',
  131. endTime: this.dateValue[1] + ' 23:59:59',
  132. filter: this.searchValue,
  133. ProjId: this.projectId,
  134. UserId: this.userId,
  135. Comming: 'revit'
  136. }
  137. axios({
  138. method: 'post',
  139. url: '/ScanBuilding/service/user_log/export',
  140. data: param,
  141. responseType: 'blob'
  142. })
  143. .then(function(res) {
  144. var blob = new Blob([res.data], {
  145. type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8'
  146. })
  147. var fileName = res.headers['content-disposition']
  148. if (fileName) fileName = fileName.substring(fileName.indexOf('=') + 1)
  149. if ('download' in document.createElement('a')) {
  150. // 非IE下载
  151. const elink = document.createElement('a')
  152. elink.download = fileName
  153. elink.style.display = 'none'
  154. elink.href = URL.createObjectURL(blob)
  155. document.body.appendChild(elink)
  156. elink.click()
  157. URL.revokeObjectURL(elink.href) // 释放URL 对象
  158. document.body.removeChild(elink)
  159. } else {
  160. // IE10+下载
  161. navigator.msSaveBlob(blob, fileName)
  162. }
  163. })
  164. .catch(function(err) {
  165. console.dirxml(err)
  166. })
  167. },
  168. pageChanged(page, size) {
  169. this.pageNum = page
  170. this.pageSize = size
  171. this.getLogData()
  172. },
  173. dateChange(value) {
  174. this.pageNum = 1
  175. this.getLogData()
  176. },
  177. getLogData() {
  178. this.loading = true;
  179. let param = {
  180. startTime: this.dateValue[0] + ' 00:00:00',
  181. endTime: this.dateValue[1] + ' 23:59:59',
  182. filter: this.searchValue,
  183. pageNum: this.pageNum,
  184. pageSize: this.pageSize,
  185. ProjId: this.projectId,
  186. UserId: this.userId
  187. }
  188. getBuildLog(param).then(res => {
  189. this.loading = false;
  190. this.total = res.data.Count
  191. this.tableData = res.data.LogList
  192. })
  193. },
  194. init() {
  195. this.getLogData()
  196. }
  197. },
  198. created() {
  199. this.init()
  200. }
  201. }
  202. </script>
  203. <style lang='less' scoped>
  204. .margin-right {
  205. margin-right: 10px;
  206. }
  207. .condition {
  208. margin-bottom: 10px;
  209. display: flex;
  210. }
  211. .ellipsis {
  212. width: 350px;
  213. overflow: hidden;
  214. text-overflow: ellipsis;
  215. white-space: nowrap;
  216. }
  217. </style>