opLog.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. <template>
  2. <div>
  3. <el-row class="handle-box" style="margin-bottom: 10px">
  4. <el-col :span="24">
  5. <el-input v-model="search.operName" size="small" placeholder="操作人" class="ch-input ch-input-size" @keyup.enter.native="handleSearch()" />
  6. <el-input v-model="search.title" size="small" placeholder="标题" class="ch-input ch-input-size" @keyup.enter.native="handleSearch()" />
  7. <el-button size="small" class="ch-button-warning" @click="handleReset()"><i class="el-icon-search" />&nbsp;重置</el-button>
  8. <el-button size="small" class="ch-button" @click="handleSearch()"><i class="el-icon-search" />&nbsp;搜索</el-button>
  9. <el-button size="small" class="ch-button-export" @click="confirmOutput()"><i class="el-icon-download" />&nbsp;导出</el-button>
  10. </el-col>
  11. </el-row>
  12. <el-row class="handle-box">
  13. <el-col :span="24">
  14. <el-table v-loading="loading" :data="AllData" stripe row-class-name="g_table_row">
  15. <el-table-column type="index" width="60" />
  16. <el-table-column label="标题" prop="title" />
  17. <el-table-column label="操作人" prop="operName" header-align="center" align="center" />
  18. <el-table-column label="操作IP" prop="operIp" header-align="center" align="center" />
  19. <el-table-column label="操作参数" header-align="center" align="center">
  20. <template slot-scope="scope">
  21. <el-popover
  22. popper-class="statistic_base"
  23. placement="right"
  24. width="600"
  25. trigger="click"
  26. >
  27. <el-card style="margin: 0">
  28. <el-row v-for="param in scope.row.params" :key="param.key" class="col-self">
  29. <el-col :span="9" class="col-txt"><span>{{ param.key }}</span></el-col>
  30. <el-col :span="13" class="col-input col-bg">
  31. <span>{{ param.value }}</span>
  32. </el-col>
  33. </el-row>
  34. </el-card>
  35. <el-button slot="reference" size="mini" type="primary" plain>查看参数</el-button>
  36. </el-popover>
  37. </template>
  38. </el-table-column>
  39. <el-table-column label="操作时间" prop="operAt" header-align="center" align="center" />
  40. <el-table-column label="操作" header-align="center" align="center" width="120">
  41. <template scope="scope">
  42. <el-button size="mini" type="danger" @click="handleDel(scope.row)">删除</el-button>
  43. </template>
  44. </el-table-column>
  45. </el-table>
  46. <div class="table-page">
  47. <el-pagination
  48. :current-page.sync="currentPage"
  49. :page-size="pageSize"
  50. background
  51. layout="total, prev, pager, next"
  52. :total="allpage"
  53. @current-change="handleCurrentChange"
  54. />
  55. </div>
  56. </el-col>
  57. </el-row>
  58. </div>
  59. </template>
  60. <script>
  61. import Base from '@/views/base/base'
  62. import BaseData from '@/views/base/baseData'
  63. export default {
  64. name: 'OpLog',
  65. mixins: [Base, BaseData],
  66. data() {
  67. return {
  68. dc_key: [],
  69. // 列表相关
  70. search: {
  71. operName: '',
  72. title: ''
  73. },
  74. AllData: [],
  75. loading: false
  76. }
  77. },
  78. mounted() {
  79. this.getData()
  80. },
  81. methods: {
  82. getData: function() {
  83. const _this = this
  84. _this.loading = true
  85. _this.AllData = []
  86. this.search.pageNum = this.currentPage
  87. this.search.pageSize = this.pageSize
  88. this.baseRequest('list', this.search).then((res) => {
  89. // console.log(' _this.AllData1', _this.AllData)
  90. if (res.data.rows) {
  91. // console.log('res.data.rows', res.data.rows)
  92. res.data.rows.forEach(function(item) {
  93. const json = _this.getItemJson(item)
  94. // console.log('json', json)
  95. _this.AllData.push(json)
  96. })
  97. _this.allpage = res.data.total
  98. }
  99. // console.log(' _this.AllData2', _this.AllData)
  100. _this.loading = false
  101. }).catch(() => {
  102. })
  103. // this.initOutData()
  104. },
  105. handleSearch: function() {
  106. this.getData()
  107. },
  108. handleReset: function() {
  109. for (const i in this.search) {
  110. if (i !== 'pageNum' && i !== 'pageSize') {
  111. this.search[i] = ''
  112. }
  113. }
  114. this.handleSearch()
  115. },
  116. initOutData: function() {
  117. const _this = this
  118. this.OutData = []
  119. const title = [' 标题', ' 操作人', ' 操作参数', ' 操作IP', ' 操作时间']
  120. this.OutData.push(title)
  121. this.baseRequest('listAll', this.search).then((res) => {
  122. if (res.data) {
  123. res.data.forEach(function(item) {
  124. const jsonMap = _this.getItemJson(item)
  125. const jsonArray = []
  126. jsonArray.push(jsonMap.title)
  127. jsonArray.push(jsonMap.operName)
  128. jsonArray.push(jsonMap.operParam)
  129. jsonArray.push(jsonMap.operIp)
  130. jsonArray.push(jsonMap.operAt)
  131. _this.OutData.push(jsonArray)
  132. })
  133. const OutSize = [{ wch: 15 }, { wch: 15 }, { wch: 15 }, { wch: 15 }, { wch: 15 }]
  134. const fileName = 'opLog导出 ' + new Date().Format('yyyyMMddhhmm')
  135. this.$outputXlsxFile(this.OutData, OutSize, fileName)
  136. }
  137. }).catch(() => {
  138. })
  139. },
  140. getItemJson: function(item) {
  141. // item.operAt = this.$common.transDate(item.operAt, this.$constant.DATE_PATTERN.DATE_TIME_s_h)
  142. item.params = []
  143. if (item.operParam) {
  144. // console.log('item.operParam',item.operParam)
  145. try {
  146. const params = this.$common.castEval(item.operParam)
  147. for (const key in params) {
  148. item.params.push({
  149. key: key,
  150. value: params[key][0]
  151. })
  152. }
  153. } catch (e) {
  154. console.log('异常错误,日志截断', item.operParam)
  155. }
  156. }
  157. return item
  158. },
  159. confirmOutput() {
  160. this.initOutData()
  161. },
  162. baseRequest(opUrl, postData) {
  163. return this.$channel.globeRequest('LogController', opUrl, postData, 'project')
  164. }
  165. }
  166. }
  167. </script>
  168. <style scoped>
  169. .ch-input .el-input__inner {
  170. border-color: #32323A;
  171. }
  172. .ch-input-size {
  173. width: 150px;
  174. }
  175. .ch-button {
  176. border-color: #32323A;
  177. background-color: #32323A;
  178. color: #fff;
  179. }
  180. .ch-button-warning {
  181. margin-left: 10px;
  182. border-color: #E6A23C;
  183. background-color: #E6A23C;
  184. color: #fff;
  185. }
  186. .ch-button-export {
  187. margin-left: 10px;
  188. border-color: #98CC1F;
  189. background-color: #98CC1F;
  190. color: #fff;
  191. }
  192. /deep/.el-dialog__header {
  193. padding: 10px 20px;
  194. }
  195. /deep/.el-dialog__body {
  196. padding: 10px 20px;
  197. }
  198. </style>