index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryRef" :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="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="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 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 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="操作时间" style="width: 308px">
  53. <el-date-picker
  54. v-model="dateRange"
  55. value-format="YYYY-MM-DD"
  56. type="daterange"
  57. range-separator="-"
  58. start-placeholder="开始日期"
  59. end-placeholder="结束日期"
  60. ></el-date-picker>
  61. </el-form-item>
  62. <el-form-item>
  63. <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
  64. <el-button icon="Refresh" @click="resetQuery">重置</el-button>
  65. </el-form-item>
  66. </el-form>
  67. <el-row :gutter="10" class="mb8">
  68. <el-col :span="1.5">
  69. <el-button
  70. type="danger"
  71. plain
  72. icon="Delete"
  73. :disabled="multiple"
  74. @click="handleDelete"
  75. v-hasPermi="['system:operlog:remove']"
  76. >删除</el-button>
  77. </el-col>
  78. <el-col :span="1.5">
  79. <el-button
  80. type="danger"
  81. plain
  82. icon="Delete"
  83. @click="handleClean"
  84. v-hasPermi="['system:operlog:remove']"
  85. >清空</el-button>
  86. </el-col>
  87. <el-col :span="1.5">
  88. <el-button
  89. type="warning"
  90. plain
  91. icon="Download"
  92. @click="handleExport"
  93. v-hasPermi="['system:operlog:export']"
  94. >导出</el-button>
  95. </el-col>
  96. <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
  97. </el-row>
  98. <el-table ref="operlogRef" v-loading="loading" :data="operlogList" @selection-change="handleSelectionChange" :default-sort="defaultSort" @sort-change="handleSortChange">
  99. <el-table-column type="selection" width="55" align="center" />
  100. <el-table-column label="日志编号" align="center" prop="operId" />
  101. <el-table-column label="系统模块" align="center" prop="title" />
  102. <el-table-column label="操作类型" align="center" prop="businessType">
  103. <template #default="scope">
  104. <dict-tag :options="sys_oper_type" :value="scope.row.businessType" />
  105. </template>
  106. </el-table-column>
  107. <el-table-column label="请求方式" align="center" prop="requestMethod" />
  108. <el-table-column label="操作人员" align="center" prop="operName" :show-overflow-tooltip="true" sortable="custom" :sort-orders="['descending', 'ascending']" width="100" />
  109. <el-table-column label="主机" align="center" prop="operIp" width="130" :show-overflow-tooltip="true" />
  110. <el-table-column label="操作状态" align="center" prop="status">
  111. <template #default="scope">
  112. <dict-tag :options="sys_common_status" :value="scope.row.status" />
  113. </template>
  114. </el-table-column>
  115. <el-table-column label="操作日期" align="center" prop="operTime" sortable="custom" :sort-orders="['descending', 'ascending']" width="180">
  116. <template #default="scope">
  117. <span>{{ parseTime(scope.row.operTime) }}</span>
  118. </template>
  119. </el-table-column>
  120. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  121. <template #default="scope">
  122. <el-button
  123. type="text"
  124. icon="View"
  125. @click="handleView(scope.row, scope.index)"
  126. v-hasPermi="['system:operlog:query']"
  127. >详细</el-button>
  128. </template>
  129. </el-table-column>
  130. </el-table>
  131. <pagination
  132. v-show="total > 0"
  133. :total="total"
  134. v-model:page="queryParams.pageNum"
  135. v-model:limit="queryParams.pageSize"
  136. @pagination="getList"
  137. />
  138. <!-- 操作日志详细 -->
  139. <el-dialog title="操作日志详细" v-model="open" width="700px" append-to-body>
  140. <el-form :model="form" label-width="100px">
  141. <el-row>
  142. <el-col :span="12">
  143. <el-form-item label="操作模块:">{{ form.title }} / {{ typeFormat(form) }}</el-form-item>
  144. <el-form-item
  145. label="登录信息:"
  146. >{{ form.operName }} / {{ form.operIp }} / {{ form.operLocation }}</el-form-item>
  147. </el-col>
  148. <el-col :span="12">
  149. <el-form-item label="请求地址:">{{ form.operUrl }}</el-form-item>
  150. <el-form-item label="请求方式:">{{ form.requestMethod }}</el-form-item>
  151. </el-col>
  152. <el-col :span="24">
  153. <el-form-item label="操作方法:">{{ form.method }}</el-form-item>
  154. </el-col>
  155. <el-col :span="24">
  156. <el-form-item label="请求参数:">{{ form.operParam }}</el-form-item>
  157. </el-col>
  158. <el-col :span="24">
  159. <el-form-item label="返回参数:">{{ form.jsonResult }}</el-form-item>
  160. </el-col>
  161. <el-col :span="12">
  162. <el-form-item label="操作状态:">
  163. <div v-if="form.status === 0">正常</div>
  164. <div v-else-if="form.status === 1">失败</div>
  165. </el-form-item>
  166. </el-col>
  167. <el-col :span="12">
  168. <el-form-item label="操作时间:">{{ parseTime(form.operTime) }}</el-form-item>
  169. </el-col>
  170. <el-col :span="24">
  171. <el-form-item label="异常信息:" v-if="form.status === 1">{{ form.errorMsg }}</el-form-item>
  172. </el-col>
  173. </el-row>
  174. </el-form>
  175. <template #footer>
  176. <div class="dialog-footer">
  177. <el-button @click="open = false">关 闭</el-button>
  178. </div>
  179. </template>
  180. </el-dialog>
  181. </div>
  182. </template>
  183. <script setup name="Operlog">
  184. import { list, delOperlog, cleanOperlog } from "@/api/monitor/operlog";
  185. const { proxy } = getCurrentInstance();
  186. const { sys_oper_type, sys_common_status } = proxy.useDict("sys_oper_type","sys_common_status");
  187. const operlogList = ref([]);
  188. const open = ref(false);
  189. const loading = ref(true);
  190. const showSearch = ref(true);
  191. const ids = ref([]);
  192. const single = ref(true);
  193. const multiple = ref(true);
  194. const total = ref(0);
  195. const title = ref("");
  196. const dateRange = ref([]);
  197. const defaultSort = ref({ prop: "operTime", order: "descending" });
  198. const data = reactive({
  199. form: {},
  200. queryParams: {
  201. pageNum: 1,
  202. pageSize: 10,
  203. title: undefined,
  204. operName: undefined,
  205. businessType: undefined,
  206. status: undefined
  207. }
  208. });
  209. const { queryParams, form } = toRefs(data);
  210. /** 查询登录日志 */
  211. function getList() {
  212. loading.value = true;
  213. list(proxy.addDateRange(queryParams.value, dateRange.value)).then(response => {
  214. operlogList.value = response.rows;
  215. total.value = response.total;
  216. loading.value = false;
  217. });
  218. }
  219. /** 操作日志类型字典翻译 */
  220. function typeFormat(row, column) {
  221. return proxy.selectDictLabel(sys_oper_type.value, row.businessType);
  222. }
  223. /** 搜索按钮操作 */
  224. function handleQuery() {
  225. queryParams.value.pageNum = 1;
  226. getList();
  227. }
  228. /** 重置按钮操作 */
  229. function resetQuery() {
  230. dateRange.value = [];
  231. proxy.resetForm("queryRef");
  232. proxy.$refs["operlogRef"].sort(defaultSort.value.prop, defaultSort.value.order);
  233. handleQuery();
  234. }
  235. /** 多选框选中数据 */
  236. function handleSelectionChange(selection) {
  237. ids.value = selection.map(item => item.operId);
  238. multiple.value = !selection.length;
  239. }
  240. /** 排序触发事件 */
  241. function handleSortChange(column, prop, order) {
  242. queryParams.value.orderByColumn = column.prop;
  243. queryParams.value.isAsc = column.order;
  244. getList();
  245. }
  246. /** 详细按钮操作 */
  247. function handleView(row) {
  248. open.value = true;
  249. form.value = row;
  250. }
  251. /** 删除按钮操作 */
  252. function handleDelete(row) {
  253. const operIds = row.operId || ids.value;
  254. proxy.$modal.confirm('是否确认删除日志编号为"' + operIds + '"的数据项?').then(function () {
  255. return delOperlog(operIds);
  256. }).then(() => {
  257. getList();
  258. proxy.$modal.msgSuccess("删除成功");
  259. }).catch(() => {});
  260. }
  261. /** 清空按钮操作 */
  262. function handleClean() {
  263. proxy.$modal.confirm("是否确认清空所有操作日志数据项?").then(function () {
  264. return cleanOperlog();
  265. }).then(() => {
  266. getList();
  267. proxy.$modal.msgSuccess("清空成功");
  268. }).catch(() => {});
  269. }
  270. /** 导出按钮操作 */
  271. function handleExport() {
  272. proxy.download("monitor/operlog/export",{
  273. ...queryParams.value,
  274. }, `config_${new Date().getTime()}.xlsx`);
  275. }
  276. getList();
  277. </script>