index.vue 8.8 KB

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