index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" 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. icon="el-icon-delete"
  78. size="mini"
  79. :disabled="multiple"
  80. @click="handleDelete"
  81. v-hasPermi="['system:operlog:remove']"
  82. >删除</el-button>
  83. </el-col>
  84. <el-col :span="1.5">
  85. <el-button
  86. type="danger"
  87. icon="el-icon-delete"
  88. size="mini"
  89. @click="handleClean"
  90. v-hasPermi="['system:operlog:remove']"
  91. >清空</el-button>
  92. </el-col>
  93. <el-col :span="1.5">
  94. <el-button
  95. type="warning"
  96. icon="el-icon-download"
  97. size="mini"
  98. @click="handleExport"
  99. v-hasPermi="['system:config:export']"
  100. >导出</el-button>
  101. </el-col>
  102. </el-row>
  103. <el-table v-loading="loading" :data="list" @selection-change="handleSelectionChange">
  104. <el-table-column type="selection" width="55" align="center" />
  105. <el-table-column label="日志编号" align="center" prop="operId" />
  106. <el-table-column label="系统模块" align="center" prop="title" />
  107. <el-table-column label="操作类型" align="center" prop="businessType" :formatter="typeFormat" />
  108. <el-table-column label="请求方式" align="center" prop="requestMethod" />
  109. <el-table-column label="操作人员" align="center" prop="operName" />
  110. <el-table-column label="主机" align="center" prop="operIp" width="130" :show-overflow-tooltip="true" />
  111. <el-table-column label="操作状态" align="center" prop="status" :formatter="statusFormat" />
  112. <el-table-column label="操作日期" align="center" prop="operTime" width="180">
  113. <template slot-scope="scope">
  114. <span>{{ parseTime(scope.row.operTime) }}</span>
  115. </template>
  116. </el-table-column>
  117. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  118. <template slot-scope="scope">
  119. <el-button
  120. size="mini"
  121. type="text"
  122. icon="el-icon-view"
  123. @click="handleView(scope.row,scope.index)"
  124. v-hasPermi="['system:operlog:query']"
  125. >详细</el-button>
  126. </template>
  127. </el-table-column>
  128. </el-table>
  129. <pagination
  130. v-show="total>0"
  131. :total="total"
  132. :page.sync="queryParams.pageNum"
  133. :limit.sync="queryParams.pageSize"
  134. @pagination="getList"
  135. />
  136. <!-- 操作日志详细 -->
  137. <el-dialog title="操作日志详细" :visible.sync="open" width="700px" append-to-body>
  138. <el-form ref="form" :model="form" label-width="100px" size="mini">
  139. <el-row>
  140. <el-col :span="12">
  141. <el-form-item label="操作模块:">{{ form.title }} / {{ typeFormat(form) }}</el-form-item>
  142. <el-form-item
  143. label="登录信息:"
  144. >{{ form.operName }} / {{ form.operIp }}</el-form-item>
  145. </el-col>
  146. <el-col :span="12">
  147. <el-form-item label="请求地址:">{{ form.operUrl }}</el-form-item>
  148. <el-form-item label="请求方式:">{{ form.requestMethod }}</el-form-item>
  149. </el-col>
  150. <el-col :span="24">
  151. <el-form-item label="操作方法:">{{ form.method }}</el-form-item>
  152. </el-col>
  153. <el-col :span="24">
  154. <el-form-item label="请求参数:">{{ form.operParam }}</el-form-item>
  155. </el-col>
  156. <el-col :span="24">
  157. <el-form-item label="返回参数:">{{ form.jsonResult }}</el-form-item>
  158. </el-col>
  159. <el-col :span="12">
  160. <el-form-item label="操作状态:">
  161. <div v-if="form.status === 0">正常</div>
  162. <div v-else-if="form.status === 1">失败</div>
  163. </el-form-item>
  164. </el-col>
  165. <el-col :span="12">
  166. <el-form-item label="操作时间:">{{ parseTime(form.operTime) }}</el-form-item>
  167. </el-col>
  168. <el-col :span="24">
  169. <el-form-item label="异常信息:" v-if="form.status === 1">{{ form.errorMsg }}</el-form-item>
  170. </el-col>
  171. </el-row>
  172. </el-form>
  173. <div slot="footer" class="dialog-footer">
  174. <el-button @click="open = false">关 闭</el-button>
  175. </div>
  176. </el-dialog>
  177. </div>
  178. </template>
  179. <script>
  180. import { list, delOperlog, cleanOperlog } from "@/api/system/operlog";
  181. export default {
  182. name: "Operlog",
  183. data() {
  184. return {
  185. // 遮罩层
  186. loading: true,
  187. // 选中数组
  188. ids: [],
  189. // 非多个禁用
  190. multiple: true,
  191. // 总条数
  192. total: 0,
  193. // 表格数据
  194. list: [],
  195. // 是否显示弹出层
  196. open: false,
  197. // 类型数据字典
  198. typeOptions: [],
  199. // 类型数据字典
  200. statusOptions: [],
  201. // 日期范围
  202. dateRange: [],
  203. // 表单参数
  204. form: {},
  205. // 查询参数
  206. queryParams: {
  207. pageNum: 1,
  208. pageSize: 10,
  209. title: undefined,
  210. operName: undefined,
  211. businessType: undefined,
  212. status: undefined
  213. }
  214. };
  215. },
  216. created() {
  217. this.getList();
  218. this.getDicts("sys_oper_type").then(response => {
  219. this.typeOptions = response.data;
  220. });
  221. this.getDicts("sys_common_status").then(response => {
  222. this.statusOptions = response.data;
  223. });
  224. },
  225. methods: {
  226. /** 查询登录日志 */
  227. getList() {
  228. this.loading = true;
  229. list(this.addDateRange(this.queryParams, this.dateRange)).then( response => {
  230. this.list = response.rows;
  231. this.total = response.total;
  232. this.loading = false;
  233. }
  234. );
  235. },
  236. // 操作日志状态字典翻译
  237. statusFormat(row, column) {
  238. return this.selectDictLabel(this.statusOptions, row.status);
  239. },
  240. // 操作日志类型字典翻译
  241. typeFormat(row, column) {
  242. return this.selectDictLabel(this.typeOptions, row.businessType);
  243. },
  244. /** 搜索按钮操作 */
  245. handleQuery() {
  246. this.queryParams.pageNum = 1;
  247. this.getList();
  248. },
  249. /** 重置按钮操作 */
  250. resetQuery() {
  251. this.dateRange = [];
  252. this.resetForm("queryForm");
  253. this.handleQuery();
  254. },
  255. // 多选框选中数据
  256. handleSelectionChange(selection) {
  257. this.ids = selection.map(item => item.operId)
  258. this.multiple = !selection.length
  259. },
  260. /** 详细按钮操作 */
  261. handleView(row) {
  262. this.open = true;
  263. this.form = row;
  264. },
  265. /** 删除按钮操作 */
  266. handleDelete(row) {
  267. const operIds = row.operId || this.ids;
  268. this.$confirm('是否确认删除日志编号为"' + operIds + '"的数据项?', "警告", {
  269. confirmButtonText: "确定",
  270. cancelButtonText: "取消",
  271. type: "warning"
  272. }).then(function() {
  273. return delOperlog(operIds);
  274. }).then(() => {
  275. this.getList();
  276. this.msgSuccess("删除成功");
  277. }).catch(function() {});
  278. },
  279. /** 清空按钮操作 */
  280. handleClean() {
  281. this.$confirm('是否确认清空所有操作日志数据项?', "警告", {
  282. confirmButtonText: "确定",
  283. cancelButtonText: "取消",
  284. type: "warning"
  285. }).then(function() {
  286. return cleanOperlog();
  287. }).then(() => {
  288. this.getList();
  289. this.msgSuccess("清空成功");
  290. }).catch(function() {});
  291. },
  292. /** 导出按钮操作 */
  293. handleExport() {
  294. this.download('system/operlog/export', {
  295. ...this.queryParams
  296. }, `operlog_${new Date().getTime()}.xlsx`)
  297. }
  298. }
  299. };
  300. </script>