index.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  1. <template>
  2. <div class="p-4">
  3. <div class="operate-header">
  4. <div class="operate-title">操作日志</div>
  5. <div class="handle-btns">
  6. <span class="label-item">操作类型:</span>
  7. <div class="select-item">
  8. <a-select v-model:value="opt" :options="selectOpt">
  9. </a-select>
  10. </div>
  11. <span class="label-item">查询时间:</span>
  12. <div class="input-item">
  13. <a-range-picker :show-time="{ format: 'HH:mm:ss' }" format="YYYY-MM-DD HH:mm:ss"
  14. :placeholder="['开始时间', '结束时间']" v-model:value="searchDate" />
  15. </div>
  16. <a-button class="btn" @click="resetForm">重置</a-button>
  17. <a-button class="btn" type="primary" @click="searchTable">查询</a-button>
  18. </div>
  19. </div>
  20. <div class="operate-body">
  21. <BasicTable @register="registerTable">
  22. <template #STATE="{ record }">
  23. <span>{{ record.SFCG ? '成功' : '失败' }}</span>
  24. </template>
  25. <template #action="{ record }">
  26. <TableAction :actions="[
  27. {
  28. label: '详情',
  29. tooltip: '详情',
  30. icon: 'ant-design:form-outlined',
  31. onClick: openDialog.bind(null, record),
  32. },
  33. ]" />
  34. </template>
  35. </BasicTable>
  36. </div>
  37. <OperateDrawer v-if="ifShowDialog" @closeDialog="ifShowDialog = false" :formData="formData"
  38. :drawerTitle="drawerTitle">
  39. </OperateDrawer>
  40. </div>
  41. </template>
  42. <script>
  43. import { defineComponent, reactive, ref, toRefs, computed, onMounted, watch } from 'vue';
  44. // 导入表格组件,表格事件
  45. import { BasicTable, useTable, TableAction } from '/@/components/Table';
  46. import OperateDrawer from './OperateDrawer.vue';
  47. import { getSelectList } from '/@/api/sys/log';
  48. import { FormOutlined, RedoOutlined } from '@ant-design/icons-vue';
  49. import moment from 'moment';
  50. export default defineComponent({
  51. name: 'operate',
  52. components: { OperateDrawer, FormOutlined, RedoOutlined, BasicTable, TableAction },
  53. setup() {
  54. onMounted(() => {
  55. // getLoginData();
  56. });
  57. const data = reactive({
  58. tableData: [],//表格数据
  59. formData: {
  60. ID: "",
  61. USERNAME: "",
  62. USERID: "",
  63. OPT: "",
  64. CZSM: "",
  65. SFCG: 0,
  66. CJRQ: "",
  67. },
  68. drawerTitle: "日志记录详情",
  69. ifShowDialog: false
  70. });
  71. const selectOpt = ref([])
  72. const searchForm = reactive({
  73. opt: "",//查询类型
  74. searchDate: [moment().subtract(30, 'days'), moment()],//查询时间
  75. })
  76. //获取所有日志
  77. const getLoginData = () => {
  78. return new Promise((resolve, reject) => {
  79. // data.tableData = []
  80. selectOpt.value = []
  81. let param = {
  82. page: 1,
  83. rows: 10000000,
  84. startCreateTimeStr: searchForm.searchDate[0].format('YYYY-MM-DD HH:mm:ss'),
  85. endCreateTimeStr: searchForm.searchDate[1].format('YYYY-MM-DD HH:mm:ss'),
  86. keyStr: searchForm.opt
  87. }
  88. getSelectList(param).then(res => {
  89. if (res.resp_msg === "获取成功!") {
  90. let resData = res.datas.records
  91. let optArr = []
  92. resData.forEach((item, index) => {
  93. optArr.push(item.OPT)
  94. // data.tableData.push({
  95. // key: item.ID,
  96. // ...item
  97. // })
  98. })
  99. let set1 = new Set(optArr)
  100. let newArr = [...set1]
  101. newArr.forEach(item => {
  102. selectOpt.value.push({
  103. value: item,
  104. label: item
  105. })
  106. })
  107. selectOpt.value.length && (searchForm.opt = selectOpt.value[0].value)
  108. resolve(resData)
  109. }else{
  110. reject()
  111. }
  112. })
  113. })
  114. }
  115. //表格列
  116. const columns = [
  117. {
  118. title: '用户名称',
  119. align: 'center',
  120. dataIndex: 'USERNAME',
  121. key: 'USERNAME'
  122. },
  123. {
  124. title: '用户ID',
  125. align: 'center',
  126. dataIndex: 'USERID',
  127. key: 'USERID'
  128. },
  129. {
  130. title: '操作类型',
  131. align: 'center',
  132. dataIndex: 'OPT',
  133. key: 'OPT'
  134. },
  135. {
  136. title: '操作说明',
  137. align: 'center',
  138. dataIndex: 'CZSM',
  139. key: 'CZSM'
  140. },
  141. {
  142. title: '操作状态',
  143. align: 'center',
  144. dataIndex: 'SFCG',
  145. slots: {
  146. customRender: 'STATE',
  147. }
  148. },
  149. {
  150. title: '操作时间',
  151. align: 'center',
  152. dataIndex: 'CJRQ',
  153. key: 'CJRQ'
  154. }
  155. ]
  156. //重置表格
  157. const resetForm = () => {
  158. selectOpt.value.length && (searchForm.opt = selectOpt.value[0].value)
  159. searchForm.searchDate = [moment().subtract(30, 'days'), moment()]
  160. }
  161. //表格查询功能
  162. const searchTable = () => {
  163. reload();
  164. }
  165. //打开详情弹窗
  166. const openDialog = (record) => {
  167. data.formData = { ...record }
  168. data.drawerTitle = '日志记录详情'
  169. data.ifShowDialog = true
  170. }
  171. const [registerTable, { reload }] = useTable({
  172. title: '操作日志列表',
  173. api: getLoginData, //数据
  174. columns: columns, //表头配置
  175. bordered: true,
  176. useSearchForm: false, //开启搜索区域
  177. // formConfig: formConfig, //搜索字段配置
  178. actionColumn: {
  179. width: 120,
  180. title: '操作',
  181. dataIndex: 'action',
  182. slots: { customRender: 'action' },
  183. },
  184. // rowSelection: { type: 'radio' },
  185. pagination: {
  186. // pageSize: 10,
  187. hideOnSinglePage: false
  188. },
  189. showTableSetting: true, // 显示表格设置
  190. tableSetting: { fullScreen: false },
  191. showIndexColumn: true,
  192. indexColumnProps: { fixed: 'left' },
  193. });
  194. return {
  195. columns,
  196. selectOpt,
  197. ...toRefs(data),
  198. ...toRefs(searchForm),
  199. // func
  200. registerTable,
  201. reload,
  202. getLoginData,
  203. resetForm,
  204. searchTable,
  205. openDialog
  206. };
  207. },
  208. });
  209. </script>
  210. <style lang="less" scoped>
  211. .p-4 {
  212. height: 100%;
  213. .operate-header {
  214. padding: 10px;
  215. width: 100%;
  216. height: 70px;
  217. background-color: #fff;
  218. display: flex;
  219. justify-content: space-between;
  220. align-items: center;
  221. .operate-title {
  222. font-size: 16px;
  223. font-weight: 500;
  224. margin-left: 20px;
  225. user-select: none;
  226. }
  227. .handle-btns {
  228. margin-right: 20px;
  229. display: flex;
  230. align-items: center;
  231. .label-item {
  232. width: 80px;
  233. }
  234. .select-item {
  235. width: 130px;
  236. }
  237. .input-item {
  238. width: 350px;
  239. }
  240. .btn {
  241. margin-left: 10px;
  242. }
  243. }
  244. }
  245. .operate-body {
  246. padding: 0 30px;
  247. margin-top: 20px;
  248. width: 100%;
  249. // height: 800px;
  250. height: calc(100% - 90px);
  251. background-color: #fff;
  252. .body-header {
  253. display: flex;
  254. height: 80px;
  255. width: 100%;
  256. justify-content: space-between;
  257. align-items: center;
  258. .item-title {
  259. height: 40px;
  260. line-height: 40px;
  261. font-size: 16px;
  262. user-select: none;
  263. }
  264. .table-btns {
  265. .btn {
  266. margin-right: 10px;
  267. &:last-child {
  268. margin-right: 0;
  269. }
  270. }
  271. }
  272. }
  273. .body-content {
  274. padding-bottom: 20px;
  275. height: calc(100% - 80px);
  276. a {
  277. margin-right: 10px;
  278. }
  279. }
  280. }
  281. }
  282. </style>