index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406
  1. <template>
  2. <el-tabs type="border-card" @tab-click="clickTab">
  3. <el-tab-pane label="登录日志">
  4. <div class="mainContentBox">
  5. <avue-crud
  6. :option="optionLogin"
  7. v-model:page="pageLogin"
  8. v-model:search="searchLogin"
  9. :table-loading="loading"
  10. :permission="permission"
  11. @search-change="handleLoginQuery"
  12. @search-reset="resetQueryLogin"
  13. @size-change="handleLoginQuery"
  14. @current-change="handleLoginQuery"
  15. @row-del="rowDel1"
  16. :data="pageDataLogin"
  17. >
  18. <template #menu-left="{}">
  19. <el-button
  20. class="ml-3"
  21. v-hasPerm="['plan:order:export']"
  22. @click="clearLog1"
  23. >
  24. 清空
  25. <template #icon>
  26. <svg-icon icon-class="qingkong"></svg-icon>
  27. </template>
  28. </el-button>
  29. </template>
  30. </avue-crud>
  31. </div>
  32. </el-tab-pane>
  33. <el-tab-pane label="操作日志">
  34. <div class="mainContentBox">
  35. <avue-crud
  36. :option="option"
  37. v-model:page="page"
  38. v-model:search="search"
  39. :table-loading="loading"
  40. :permission="permission"
  41. @search-change="handleOperQuery"
  42. @search-reset="resetQuery"
  43. @size-change="handleOperQuery"
  44. @current-change="handleOperQuery"
  45. @row-del="rowDel2"
  46. :data="pageData"
  47. >
  48. <template #menu-left="{}">
  49. <el-button
  50. class="ml-3"
  51. v-hasPerm="['plan:order:export']"
  52. @click="clearLog2"
  53. >
  54. <template #icon> <i-ep-download /> </template>清空
  55. </el-button>
  56. </template>
  57. </avue-crud>
  58. </div>
  59. </el-tab-pane>
  60. </el-tabs>
  61. </template>
  62. <script setup lang="ts">
  63. import { useCommonStoreHook ,useDictionaryStore} from "@/store";
  64. import {
  65. getLoginLogPage,
  66. getOperaLogPage,
  67. clearLoginLog,
  68. clearOperaLog,
  69. deleteLoginLogs,
  70. deleteOperaLogs,
  71. } from "@/api/system/log";
  72. const { dicts,getLabelByValue } = useDictionaryStore();
  73. // 弹窗对象
  74. const dialog = reactive({
  75. visible: false,
  76. type: "order-form",
  77. width: 800,
  78. title: "",
  79. });
  80. const search = ref({});
  81. const option = ref({});
  82. const pageData = ref([]);
  83. const form = ref({});
  84. const page = ref({ total: 0, currentPage: 1, pageSize: 10 });
  85. const searchLogin = ref({});
  86. const optionLogin = ref({});
  87. const pageDataLogin = ref([]);
  88. const pageLogin = ref({ total: 0, currentPage: 1, pageSize: 10 });
  89. const loading = ref(false);
  90. const permission = reactive({
  91. delBtn: true,
  92. addBtn: true,
  93. editBtn: true,
  94. menu: true,
  95. });
  96. option.value = {
  97. border: true,
  98. searchIndex: 3,
  99. searchIcon: true,
  100. searchMenuSpan: 8,
  101. align: "center",
  102. menuAlign: "center",
  103. search: true,
  104. viewBtn: true,
  105. editBtn: false,
  106. addBtn: false,
  107. refreshBtn: false,
  108. column: [
  109. {
  110. label: "编号",
  111. prop: "id",
  112. width: 80,
  113. },
  114. {
  115. label: "系统模块",
  116. prop: "requestModel",
  117. },
  118. {
  119. label: "操作类型",
  120. prop: "operatorType",
  121. search: true,
  122. html: true,
  123. width: 100,
  124. type: "select",
  125. formatter: (val) => {
  126. if (val.operatorType === "1") {
  127. return '<b class="el-tag el-tag--success el-tag--light">新增</b>';
  128. } else if (val.operatorType === "2") {
  129. return '<b class="el-tag el-tag--info el-tag--light">修改</b>';
  130. } else if (val.operatorType === "3") {
  131. return '<b class="el-tag el-tag--danger el-tag--light">删除</b>';
  132. } else if (val.operatorType === "4") {
  133. return '<b class="el-tag el-tag--info el-tag--light">授权</b>';
  134. } else if (val.operatorType === "5") {
  135. return '<b class="el-tag el-tag--warning el-tag--light">导出</b>';
  136. } else if (val.operatorType === "6") {
  137. return '<b class="el-tag el-tag--warning el-tag--light">导入</b>';
  138. } else if (val.operatorType === "7") {
  139. return '<b class="el-tag el-tag--warning el-tag--light">强退</b>';
  140. } else if (val.operatorType === "9") {
  141. return '<b class="el-tag el-tag--danger el-tag--light">清空</b>';
  142. } else if (val.operatorType === "10") {
  143. return '<b class="el-tag el-tag--info el-tag--light">其它</b>';
  144. }
  145. },
  146. dicData: [
  147. { label: "其它", value: "10" },
  148. { label: "新增", value: "1" },
  149. { label: "修改", value: "2" },
  150. { label: "删除", value: "3" },
  151. { label: "授权", value: "4" },
  152. { label: "导出", value: "5" },
  153. { label: "导入", value: "6" },
  154. { label: "强退", value: "7" },
  155. { label: "清空", value: "9" },
  156. ],
  157. },
  158. {
  159. label: "操作地址",
  160. prop: "requestUrl",
  161. width: 200,
  162. overHidden: true,
  163. },
  164. {
  165. label: "操作人员",
  166. prop: "creator",
  167. type: "select",
  168. dicData: dicts.user_name_list,
  169. props: {"label": "dictLabel","value":"dictValue"},
  170. search: true,
  171. },
  172. {
  173. label: "请求参数",
  174. prop: "requestParams",
  175. overHidden: true,
  176. },
  177. {
  178. label: "返回参数",
  179. prop: "responseStr",
  180. overHidden: true,
  181. },
  182. {
  183. label: "操作状态",
  184. prop: "state",
  185. html: true,
  186. width: 100,
  187. type: "select",
  188. formatter: (val) => {
  189. if (val.state === 0) {
  190. return '<b class="el-tag el-tag--success el-tag--light">成功</b>';
  191. }
  192. return '<b class="el-tag el-tag--danger el-tag--light">失败</b>';
  193. },
  194. dicData: [
  195. { label: "成功", value: 0 },
  196. { label: "失败", value: 1 },
  197. ],
  198. },
  199. {
  200. label: "操作日期",
  201. prop: "created",
  202. display: false,
  203. },
  204. ],
  205. };
  206. optionLogin.value = {
  207. border: true,
  208. searchIndex: 3,
  209. searchIcon: true,
  210. searchMenuSpan: 8,
  211. align: "center",
  212. menuAlign: "center",
  213. search: true,
  214. editBtn: false,
  215. addBtn: false,
  216. refreshBtn: false,
  217. column: [
  218. {
  219. label: "编号",
  220. prop: "id",
  221. width: 80,
  222. },
  223. {
  224. label: "用户名称",
  225. prop: "creator",
  226. type: "select",
  227. dicData: dicts.user_name_list,
  228. props: {"label": "dictLabel","value":"dictValue"},
  229. search: true,
  230. },
  231. {
  232. label: "登录地址",
  233. prop: "loginIp",
  234. },
  235. {
  236. label: "登录系统",
  237. prop: "operatorType",
  238. html: true,
  239. type: "select",
  240. formatter: (val) => {
  241. if (val.operatorType === "aio") {
  242. return '<b class="el-tag el-tag--info el-tag--light">一体机</b>';
  243. }
  244. return '<b class="el-tag el-tag--info el-tag--light">后台</b>';
  245. },
  246. },
  247. {
  248. label: "浏览器",
  249. prop: "clientBrowser",
  250. },
  251. {
  252. label: "操作系统",
  253. prop: "clientOs",
  254. },
  255. {
  256. label: "登录状态",
  257. prop: "state",
  258. search: true,
  259. html: true,
  260. type: "select",
  261. formatter: (val) => {
  262. if (val.state === 0) {
  263. return '<b class="el-tag el-tag--success el-tag--light">成功</b>';
  264. }
  265. return '<b class="el-tag el-tag--danger el-tag--light">失败</b>';
  266. },
  267. dicData: [
  268. { label: "成功", value: 0 },
  269. { label: "失败", value: 1 },
  270. ],
  271. },
  272. {
  273. label: "操作信息",
  274. prop: "responseStr",
  275. },
  276. {
  277. label: "访问时间",
  278. prop: "created",
  279. },
  280. ],
  281. };
  282. const clearLog1 = () => {
  283. ElMessageBox.confirm("当前操作会删除数据,你确认要继续吗?")
  284. .then(() => {
  285. clearLoginLog().then((data: any) => {
  286. ElMessage({
  287. message: data.msg,
  288. type: "success",
  289. });
  290. handleLoginQuery(null, null);
  291. });
  292. })
  293. .catch(() => {
  294. // catch error
  295. });
  296. };
  297. const clearLog2 = () => {
  298. ElMessageBox.confirm("当前操作会删除数据,你确认要继续吗?")
  299. .then(() => {
  300. clearOperaLog().then((data: any) => {
  301. ElMessage({
  302. message: data.msg,
  303. type: "success",
  304. });
  305. handleOperQuery(null, null);
  306. });
  307. })
  308. .catch(() => {
  309. // catch error
  310. });
  311. };
  312. const handleLoginQuery = (params: any, done: any) => {
  313. loading.value = true;
  314. const querySearch = {
  315. pageSize: pageLogin.value.pageSize,
  316. pageNo: pageLogin.value.currentPage,
  317. ...params,
  318. };
  319. getLoginLogPage(querySearch)
  320. .then(({ data }) => {
  321. pageDataLogin.value = data.records;
  322. pageLogin.value.total = data.totalCount;
  323. pageLogin.value.currentPage = data.pageNo;
  324. pageLogin.value.pageSize = data.pageSize;
  325. })
  326. .finally(() => {
  327. loading.value = false;
  328. if (done) {
  329. done();
  330. }
  331. });
  332. };
  333. const rowDel1 = (form: any, index: any) => {
  334. ElMessageBox.confirm("当前操作会删除数据,你确认要继续吗?")
  335. .then(() => {
  336. deleteLoginLogs([form.id])
  337. .then((data: any) => {
  338. ElMessage({
  339. message: data.msg,
  340. type: "success",
  341. });
  342. handleLoginQuery(null, null);
  343. })
  344. .finally(() => {});
  345. })
  346. .catch(() => {
  347. // catch error
  348. });
  349. };
  350. const rowDel2 = (form: any, index) => {
  351. ElMessageBox.confirm("当前操作会删除数据,你确认要继续吗?")
  352. .then(() => {
  353. deleteOperaLogs([form.id])
  354. .then((data: any) => {
  355. ElMessage({
  356. message: data.msg,
  357. type: "success",
  358. });
  359. handleOperQuery(null, null);
  360. })
  361. .finally(() => {});
  362. })
  363. .catch(() => {
  364. // catch error
  365. });
  366. };
  367. const clickTab = (targetName: any) => {
  368. if (targetName.index === 0) {
  369. handleLoginQuery(null, null);
  370. } else {
  371. handleOperQuery(null, null);
  372. }
  373. };
  374. const handleOperQuery = (params: any, done: any) => {
  375. loading.value = true;
  376. const querySearch = {
  377. pageSize: page.value.pageSize,
  378. pageNo: page.value.currentPage,
  379. ...params,
  380. };
  381. if(search.value.operatorType){
  382. querySearch.operatorType = search.value.operatorType
  383. }
  384. if(search.value.creator){
  385. querySearch.creator = search.value.creator
  386. }
  387. getOperaLogPage(querySearch)
  388. .then(({ data }) => {
  389. pageData.value = data.records;
  390. page.value.total = data.totalCount;
  391. page.value.currentPage = data.pageNo;
  392. page.value.pageSize = data.pageSize;
  393. })
  394. .finally(() => {
  395. loading.value = false;
  396. if (done) {
  397. done();
  398. }
  399. });
  400. };
  401. const resetQuery = () => {};
  402. const resetQueryLogin = () => {};
  403. onMounted?.(() => {
  404. handleLoginQuery(null, null);
  405. });
  406. </script>