index.vue 9.4 KB

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