index.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
  4. <el-form-item label="操作地址" prop="operIp">
  5. <el-input
  6. v-model="queryParams.operIp"
  7. placeholder="请输入操作地址"
  8. clearable
  9. style="width: 240px;"
  10. @keyup.enter.native="handleQuery"
  11. />
  12. </el-form-item>
  13. <el-form-item label="系统模块" prop="title">
  14. <el-input
  15. v-model="queryParams.title"
  16. placeholder="请输入系统模块"
  17. clearable
  18. style="width: 240px;"
  19. @keyup.enter.native="handleQuery"
  20. />
  21. </el-form-item>
  22. <el-form-item label="操作人员" prop="operName">
  23. <el-input
  24. v-model="queryParams.operName"
  25. placeholder="请输入操作人员"
  26. clearable
  27. style="width: 240px;"
  28. @keyup.enter.native="handleQuery"
  29. />
  30. </el-form-item>
  31. <el-form-item label="类型" prop="businessType">
  32. <el-select
  33. v-model="queryParams.businessType"
  34. placeholder="操作类型"
  35. clearable
  36. style="width: 240px"
  37. >
  38. <el-option
  39. v-for="dict in dict.type.sys_oper_type"
  40. :key="dict.value"
  41. :label="dict.label"
  42. :value="dict.value"
  43. />
  44. </el-select>
  45. </el-form-item>
  46. <el-form-item label="状态" prop="status">
  47. <el-select
  48. v-model="queryParams.status"
  49. placeholder="操作状态"
  50. clearable
  51. style="width: 240px"
  52. >
  53. <el-option
  54. v-for="dict in dict.type.sys_common_status"
  55. :key="dict.value"
  56. :label="dict.label"
  57. :value="dict.value"
  58. />
  59. </el-select>
  60. </el-form-item>
  61. <el-form-item label="操作时间">
  62. <el-date-picker
  63. v-model="dateRange"
  64. style="width: 240px"
  65. value-format="yyyy-MM-dd HH:mm:ss"
  66. type="daterange"
  67. range-separator="-"
  68. start-placeholder="开始日期"
  69. end-placeholder="结束日期"
  70. :default-time="['00:00:00', '23:59:59']"
  71. ></el-date-picker>
  72. </el-form-item>
  73. <el-form-item>
  74. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  75. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  76. </el-form-item>
  77. </el-form>
  78. <el-row :gutter="10" class="mb8">
  79. <el-col :span="1.5">
  80. <el-button
  81. type="danger"
  82. plain
  83. icon="el-icon-delete"
  84. size="mini"
  85. :disabled="multiple"
  86. @click="handleDelete"
  87. v-hasPermi="['monitor:operlog:remove']"
  88. >删除</el-button>
  89. </el-col>
  90. <el-col :span="1.5">
  91. <el-button
  92. type="danger"
  93. plain
  94. icon="el-icon-delete"
  95. size="mini"
  96. @click="handleClean"
  97. v-hasPermi="['monitor:operlog:remove']"
  98. >清空</el-button>
  99. </el-col>
  100. <el-col :span="1.5">
  101. <el-button
  102. type="warning"
  103. plain
  104. icon="el-icon-download"
  105. size="mini"
  106. @click="handleExport"
  107. v-hasPermi="['monitor:operlog:export']"
  108. >导出</el-button>
  109. </el-col>
  110. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  111. </el-row>
  112. <el-table ref="tables" v-loading="loading" :data="list" @selection-change="handleSelectionChange" :default-sort="defaultSort" @sort-change="handleSortChange">
  113. <el-table-column type="selection" width="50" align="center" />
  114. <el-table-column label="日志编号" align="center" prop="operId" />
  115. <el-table-column label="系统模块" align="center" prop="title" :show-overflow-tooltip="true" />
  116. <el-table-column label="操作类型" align="center" prop="businessType">
  117. <template slot-scope="scope">
  118. <dict-tag :options="dict.type.sys_oper_type" :value="scope.row.businessType"/>
  119. </template>
  120. </el-table-column>
  121. <el-table-column label="操作人员" align="center" prop="operName" width="110" :show-overflow-tooltip="true" sortable="custom" :sort-orders="['descending', 'ascending']" />
  122. <el-table-column label="操作地址" align="center" prop="operIp" width="130" :show-overflow-tooltip="true" />
  123. <el-table-column label="操作地点" align="center" prop="operLocation" :show-overflow-tooltip="true" />
  124. <el-table-column label="操作状态" align="center" prop="status">
  125. <template slot-scope="scope">
  126. <dict-tag :options="dict.type.sys_common_status" :value="scope.row.status"/>
  127. </template>
  128. </el-table-column>
  129. <el-table-column label="操作日期" align="center" prop="operTime" width="160" sortable="custom" :sort-orders="['descending', 'ascending']">
  130. <template slot-scope="scope">
  131. <span>{{ parseTime(scope.row.operTime) }}</span>
  132. </template>
  133. </el-table-column>
  134. <el-table-column label="消耗时间" align="center" prop="costTime" width="110" :show-overflow-tooltip="true" sortable="custom" :sort-orders="['descending', 'ascending']">
  135. <template slot-scope="scope">
  136. <span>{{ scope.row.costTime }}毫秒</span>
  137. </template>
  138. </el-table-column>
  139. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  140. <template slot-scope="scope">
  141. <el-button
  142. size="mini"
  143. type="text"
  144. icon="el-icon-view"
  145. @click="handleDetail(scope.row,scope.index)"
  146. v-hasPermi="['monitor:operlog:query']"
  147. >详细</el-button>
  148. </template>
  149. </el-table-column>
  150. </el-table>
  151. <pagination
  152. v-show="total>0"
  153. :total="total"
  154. :page.sync="queryParams.pageNum"
  155. :limit.sync="queryParams.pageSize"
  156. @pagination="getList"
  157. />
  158. <operlog-detail :visible.sync="detailVisible" :row="detailRow" />
  159. </div>
  160. </template>
  161. <script>
  162. import OperlogDetail from './detail'
  163. import { list, delOperlog, cleanOperlog } from "@/api/monitor/operlog"
  164. export default {
  165. name: "Operlog",
  166. components: { OperlogDetail },
  167. dicts: ['sys_oper_type', 'sys_common_status'],
  168. data() {
  169. return {
  170. // 遮罩层
  171. loading: true,
  172. // 选中数组
  173. ids: [],
  174. // 非多个禁用
  175. multiple: true,
  176. // 显示搜索条件
  177. showSearch: true,
  178. // 总条数
  179. total: 0,
  180. // 表格数据
  181. list: [],
  182. // 是否显示弹出层
  183. detailVisible: false,
  184. detailRow: {},
  185. // 日期范围
  186. dateRange: [],
  187. // 默认排序
  188. defaultSort: { prop: "operTime", order: "descending" },
  189. // 表单参数
  190. form: {},
  191. // 查询参数
  192. queryParams: {
  193. pageNum: 1,
  194. pageSize: 10,
  195. operIp: undefined,
  196. title: undefined,
  197. operName: undefined,
  198. businessType: undefined,
  199. status: undefined
  200. }
  201. }
  202. },
  203. created() {
  204. this.getList()
  205. },
  206. methods: {
  207. /** 查询登录日志 */
  208. getList() {
  209. this.loading = true
  210. list(this.addDateRange(this.queryParams, this.dateRange)).then( response => {
  211. this.list = response.rows
  212. this.total = response.total
  213. this.loading = false
  214. }
  215. )
  216. },
  217. // 详细按钮操作
  218. handleDetail(row) {
  219. this.detailRow = row
  220. this.detailVisible = true
  221. },
  222. /** 搜索按钮操作 */
  223. handleQuery() {
  224. this.queryParams.pageNum = 1
  225. this.getList()
  226. },
  227. /** 重置按钮操作 */
  228. resetQuery() {
  229. this.dateRange = []
  230. this.resetForm("queryForm")
  231. this.queryParams.pageNum = 1
  232. this.$refs.tables.sort(this.defaultSort.prop, this.defaultSort.order)
  233. },
  234. /** 多选框选中数据 */
  235. handleSelectionChange(selection) {
  236. this.ids = selection.map(item => item.operId)
  237. this.multiple = !selection.length
  238. },
  239. /** 排序触发事件 */
  240. handleSortChange(column, prop, order) {
  241. this.queryParams.orderByColumn = column.prop
  242. this.queryParams.isAsc = column.order
  243. this.getList()
  244. },
  245. /** 删除按钮操作 */
  246. handleDelete(row) {
  247. const operIds = row.operId || this.ids
  248. this.$modal.confirm('是否确认删除日志编号为"' + operIds + '"的数据项?').then(function() {
  249. return delOperlog(operIds)
  250. }).then(() => {
  251. this.getList()
  252. this.$modal.msgSuccess("删除成功")
  253. }).catch(() => {})
  254. },
  255. /** 清空按钮操作 */
  256. handleClean() {
  257. this.$modal.confirm('是否确认清空所有操作日志数据项?').then(function() {
  258. return cleanOperlog()
  259. }).then(() => {
  260. this.getList()
  261. this.$modal.msgSuccess("清空成功")
  262. }).catch(() => {})
  263. },
  264. /** 导出按钮操作 */
  265. handleExport() {
  266. this.download('monitor/operlog/export', {
  267. ...this.queryParams
  268. }, `operlog_${new Date().getTime()}.xlsx`)
  269. }
  270. }
  271. }
  272. </script>