Browse Source

操作记录

CzRger 1 year ago
parent
commit
0919e1079b

+ 8 - 0
src/api/modules/oper-log.ts

@@ -2,8 +2,16 @@ import { handle } from '../index'
 
 const suffix = 'api'
 
+//  操作记录 > 列表
 export const getOperationLogList = (params: any) => handle({
   url: `/${suffix}/operLog/list`,
   method: 'post',
   params
 })
+//  操作记录 > 导出
+export const operLogExport = (params: any) => handle({
+  url: `/${suffix}/operLog/export`,
+  method: 'post',
+  params,
+  config: {responseType: 'blob'}
+})

+ 2 - 0
src/store/modules/dictionary-define.ts

@@ -7,6 +7,8 @@ export const dictionaryDefine = {
 	config_log_remind_time: ['configLogRemindTimeList', 'configLogRemindTimeMap', 'configLogRemindTimeObjMap'], //	公共配置-日志提醒时间
 	config_week_remind_time: ['configWeekRemindTimeList', 'configWeekRemindTimeMap', 'configWeekRemindTimeObjMap'], //	公共配置-周报提醒时间
 	config_week_submit_date: ['configWeekSubmitDateList', 'configWeekSubmitDateMap', 'configWeekSubmitDateObjMap'], //	公共配置-周报提交星期
+	oper_module: ['operModuleList', 'operModuleMap', 'operModuleObjMap'], //	操作记录-操作模块
+	oper_type: ['operTypeList', 'operTypeMap', 'operTypeObjMap'], //	操作记录-操作类型
 }
 
 const stateMap = {}

+ 3 - 1
src/views/system/login-log/index.vue

@@ -214,7 +214,9 @@ export default defineComponent({
       }
       that.$api.loginLogExport(queryParams).then(res => {
         downLoadBlob(res, '登录日志.xlsx')
-        console.log(res)
+        ElMessage.success('导出成功!')
+      }).catch(() => {
+        ElMessage.error('导出失败!')
       })
     }
     onMounted(() => {

+ 58 - 45
src/views/system/operation-records/index.vue

@@ -18,37 +18,25 @@
                 :options="$store.state.dictionary.deptList"/>
             <CusFormColumn
                 label="操作模块:"
+                link="select"
                 v-model:param="queryForm.operModule"
-                static
-                labelKey="label"
-                valueKey="value"
-                :options="[
-                    {label: '席位管理', value: '1'},
-                    {label: '签卡管理', value: '2'},
-                ]"/>
+                :options="$store.state.dictionary.operModuleList"/>
             <CusFormColumn
                 label="操作类型:"
                 link="select"
-                static
                 v-model:param="queryForm.operType"
-                labelKey="label"
-                valueKey="value"
-                :options="[
-                    {label: '类型一', value: '1'},
-                    {label: '类型二', value: '2'},
-                    {label: '类型三', value: '3'},
-                ]"/>
-            <CusFormColumn
-                label="操作对象:"
-                v-model:param="queryForm.shipId"/>
-            <CusFormColumn
-                label="操作详情:"
-                v-model:param="queryForm.shipId"/>
+                :options="$store.state.dictionary.operTypeList"/>
+<!--            <CusFormColumn-->
+<!--                label="操作对象:"-->
+<!--                v-model:param="queryForm.shipId"/>-->
+<!--            <CusFormColumn-->
+<!--                label="操作详情:"-->
+<!--                v-model:param="queryForm.shipId"/>-->
             <CusFormColumn
                 label="操作时间:"
                 link="datetime"
                 type="datetimerange"
-                v-model:param="queryForm.shipId"/>
+                v-model:param="queryForm.operationDate"/>
             <CusSearchButtons
                 @handleReset="handleReset"
                 @handleSearch="onSearch"
@@ -56,7 +44,7 @@
           </CusForm>
         </template>
         <template #buttons>
-          <div class="__cus-button_submit __hover">
+          <div class="__cus-button_submit __hover" @click="onExport">
             <SvgIcon name="export" size="16"/>导出
           </div>
         </template>
@@ -69,8 +57,8 @@
               :total="queryResult.total"
               :page="queryPage.pageNum"
               :pageSize="queryPage.pageSize"
+              v-model:selected="selected"
               @handlePage="handlePage"
-              @handleSort="handleSort"
           >
           </CusTable>
         </template>
@@ -94,8 +82,10 @@ import {
 } from 'vue'
 import {useStore} from 'vuex'
 import {useRouter, useRoute} from 'vue-router'
-import {getOperationLogList} from "@/api/modules/oper-log";
+import {getOperationLogList, operLogExport} from "@/api/modules/oper-log";
 import {getDeptList} from "@/api/modules/dept";
+import {ElMessage} from "element-plus";
+import {downLoadBlob} from "@/utils/downLoadUrl";
 
 export default defineComponent({
   name: '',
@@ -122,8 +112,6 @@ export default defineComponent({
       queryForm: <any>{},
       //  查询表单参数备份
       back_queryForm: {},
-      //  查询表格排序
-      querySort: {},
       //  表格表头
       tableHead: [
         {value: "p1", label: "操作人", show: true},
@@ -131,15 +119,18 @@ export default defineComponent({
         {value: "p1", label: "设备IP", show: true},
         {value: "p1", label: "操作模块", show: true},
         {value: "p1", label: "操作类型", show: true},
-        {value: "p1", label: "操作对象", show: true},
-        {value: "p1", label: "操作详情", show: true},
+        // {value: "p1", label: "操作对象", show: true},
+        // {value: "p1", label: "操作详情", show: true},
         {value: "p1", label: "操作时间", show: true},
       ],
+      selected: []
     });
     const ref_cusTable = ref()
     //  获取字典
     const initDictionary = () => {
       store.dispatch('dictionary/LOAD_DEPT')
+      store.dispatch('dictionary/LOAD_DICT_LIST', 'oper_module')
+      store.dispatch('dictionary/LOAD_DICT_LIST', 'oper_type')
     }
     //  查询分页参数改变处理方法
     const handlePage = ({page, pageSize}: any) => {
@@ -147,11 +138,6 @@ export default defineComponent({
       state.queryPage.pageSize = pageSize
       handleSearch(page, pageSize)
     }
-    //  查询排序参数改变处理方法
-    const handleSort = ({key, value}: any) => {
-      state.querySort = key ? {key: value} : {}
-      handleSearch()
-    }
     //  重置查询表单方法
     const handleReset = () => {
       state.queryForm = {}
@@ -164,23 +150,25 @@ export default defineComponent({
       const queryParams: any = {
         pageNum: page,
         pageSize: pageSize,
-        sort: {},
-      }
-      //  添加排序参数
-      for (const [k, v] of Object.entries(state.querySort)) {
-        that.$util.isValue(v) ? (queryParams.sort[k] = v) : null;
       }
       //  添加表单参数
       for (const [k, v] of Object.entries(state.back_queryForm)) {
-        that.$util.isValue(v) ? (queryParams[k] = v) : null;
+        if (that.$util.isValue(v)) {
+          if (k === 'operationDate') {
+            queryParams['beginTime'] = v[0]
+            queryParams['endTime'] = v[1]
+          } else {
+            queryParams[k] = v
+          }
+        }
       }
-      //  添加复合查询参数
       state.loading = true
-      that.$api.getDeptList()
       that.$api.getOperationLogList(queryParams).then((res: any) => {
         if (res.code === 200) {
-          // state.queryResult.tableData = res.rows
-          // state.queryResult.total = res.total
+          state.queryResult.tableData = res.rows
+          state.queryResult.total = res.total
+        } else {
+          ElMessage.error(res.message)
         }
         state.loading = false
       }).catch(() => {
@@ -194,6 +182,31 @@ export default defineComponent({
       state.queryPage.pageNum = 1
       handleSearch()
     }
+    const onExport = () => {
+      const queryParams: any = {
+      }
+      if (state.selected.length > 0) {
+        queryParams['ids'] = state.selected.map(v => v.id)
+      } else {
+        //  添加表单参数
+        for (const [k, v] of Object.entries(state.back_queryForm)) {
+          if (that.$util.isValue(v)) {
+            if (k === 'operationDate') {
+              queryParams['beginTime'] = v[0]
+              queryParams['endTime'] = v[1]
+            } else {
+              queryParams[k] = v
+            }
+          }
+        }
+      }
+      that.$api.operLogExport(queryParams).then(res => {
+        downLoadBlob(res, '操作记录.xlsx')
+        ElMessage.success('导出成功!')
+      }).catch(() => {
+        ElMessage.error('导出失败!')
+      })
+    }
     onMounted(() => {
       state.back_queryForm = JSON.parse(JSON.stringify(state.queryForm))
       initDictionary()
@@ -204,9 +217,9 @@ export default defineComponent({
       ...toRefs(state),
       handleSearch,
       handlePage,
-      handleSort,
       handleReset,
       onSearch,
+      onExport
     }
   },
 })