index.vue 11 KB

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