index.vue 10 KB

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