index.vue 9.1 KB

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