24282 1 сар өмнө
parent
commit
e30c474371

+ 1 - 4
jy-log/src/main/java/com/jy/log/record/RecordAuditAspect.java

@@ -78,25 +78,22 @@ public class RecordAuditAspect {
                 }
             }
             case UPDATE -> {
-                logUserOperation.setAuditStatus(0);
-
                 if (args != null && args.length == 1 && args[0] instanceof BaseIdPo) {
                     logUserOperation.setBusinessId(((BaseIdPo) args[0]).getId());
                 }
 
+                logUserOperation.setAuditStatus(0);
                 Object oldData = getOldData(point, signature, recordAudit);
                 logUserOperation.setSourceData(JSONObject.toJSONString(oldData));
             }
             case DELETE -> {
                 logUserOperation.setAuditStatus(0);
-
                 Object oldData = getOldData(point, signature, recordAudit);
                 logUserOperation.setSourceData(JSONObject.toJSONString(oldData));
             }
         }
 
         logUserOperationService.add(logUserOperation);
-
         return result;
     }
 

+ 50 - 39
jy-log/src/main/java/com/jy/log/service/impl/LogUserOperationServiceImpl.java

@@ -5,6 +5,7 @@ import com.alibaba.fastjson2.JSONArray;
 import com.alibaba.fastjson2.JSONObject;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.jy.framework.exception.ServiceException;
+import com.jy.framework.model.base.BaseIdPo;
 import com.jy.framework.utils.AssertUtil;
 import com.jy.log.dao.LogUserOperationDao;
 import com.jy.log.model.dto.LogUserOperationDto;
@@ -19,6 +20,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.lang.reflect.Method;
+import java.util.Date;
 import java.util.List;
 
 /**
@@ -56,47 +58,56 @@ public class LogUserOperationServiceImpl implements LogUserOperationService {
     @Transactional(rollbackFor = Exception.class)
     @Override
     public void edit(LogUserOperationDto dto) {
-        logUserOperationDao.updateById(dto);
-
-        //if (dto.getAuditStatus().equals(1)) {
-            try {
-                RecordAuditAspect.EXIST_FUN.set(true);
-
-                // 获取springBean
-                Object bean = SpringUtil.getBean(Class.forName(dto.getServiceBeanName()));
-
-                // 获取入参class
-                Class<?>[] array = JSONArray.parseArray(dto.getReqClasses()).toJavaList(String.class).stream()
-                        .map(item -> {
-                            try {
-                                return Class.forName(item);
-                            } catch (ClassNotFoundException e) {
-                                throw new RuntimeException(e);
-                            }
-                        }).toArray(Class[]::new);
-
-                // 获取执行方法
-                Method method = bean.getClass().getMethod(dto.getMethodName(), array);
-
-                // 获取方法参数
-                Object[] params = new Object[array.length];
-                List<JSONObject> paramList = JSONArray.parseArray(dto.getOperationData()).toJavaList(JSONObject.class);
-                for (int i = 0; i < paramList.size(); i++) {
-                    params[i] = paramList.get(i).toJavaObject(array[i]);
-                }
-
-                // 执行方法
-                method.invoke(bean, params);
-
-                System.out.print("");
-            } catch (Exception e) {
-                log.error(e.getMessage(), e);
-                throw new ServiceException("业务执行失败");
-            } finally {
-                RecordAuditAspect.EXIST_FUN.remove();
+        boolean update = logUserOperationDao.update(q -> q
+                .eq(BaseIdPo::getId, dto.getId())
+                .eq(LogUserOperation::getAuditStatus, 0)
+                .set(LogUserOperation::getAuditStatus, dto.getAuditStatus())
+                .set(LogUserOperation::getRemark, dto.getRemark())
+                .set(LogUserOperation::getAuditTime, new Date())
+        );
+
+        if (!update) {
+            throw new ServiceException("已被审核");
+        }
+
+        if (dto.getAuditStatus() == 2) {
+            return;
+        }
+
+        try {
+            RecordAuditAspect.EXIST_FUN.set(true);
+
+            // 获取springBean
+            Object bean = SpringUtil.getBean(Class.forName(dto.getServiceBeanName()));
+
+            // 获取入参class
+            Class<?>[] array = JSONArray.parseArray(dto.getReqClasses()).toJavaList(String.class).stream()
+                    .map(item -> {
+                        try {
+                            return Class.forName(item);
+                        } catch (ClassNotFoundException e) {
+                            throw new RuntimeException(e);
+                        }
+                    }).toArray(Class[]::new);
+
+            // 获取执行方法
+            Method method = bean.getClass().getMethod(dto.getMethodName(), array);
+
+            // 获取方法参数
+            Object[] params = new Object[array.length];
+            List<JSONObject> paramList = JSONArray.parseArray(dto.getOperationData()).toJavaList(JSONObject.class);
+            for (int i = 0; i < paramList.size(); i++) {
+                params[i] = paramList.get(i).toJavaObject(array[i]);
             }
-        //}
 
+            // 执行方法
+            method.invoke(bean, params);
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            throw new ServiceException("业务执行失败");
+        } finally {
+            RecordAuditAspect.EXIST_FUN.remove();
+        }
     }
 
     @Transactional(rollbackFor = Exception.class)

+ 26 - 61
jy-ui/src/views/business/log/userOperation/index.vue

@@ -4,21 +4,18 @@ import { FormConfigType } from '@/components/AForm/type'
 import { ToolbarConfigType } from '@/components/AToolbar/type'
 import { ColumnConfigType } from '@/components/ATable/type'
 import { StrAnyObj, StrAnyObjArr } from '@/typings'
-import { useHandleData } from '@/utils/useHandleData'
-import { getPageApi, getDetailApi, addApi, editApi, deleteApi } from '@/api/business/log/userOperation'
+import { getPageApi, getDetailApi, editApi } from '@/api/business/log/userOperation'
 
 const queryRef = ref<InstanceType<typeof AForm>>()
 const formRef = ref<InstanceType<typeof AForm>>()
 
 const showQuery = ref<boolean>(true)
-const selectKeys = ref<string[]>([])
 const pageTotal = ref<number>(0)
 
 const queryData = ref<StrAnyObj>({ pageNum: 1, pageSize: 10 })
 const tableData = ref<StrAnyObjArr>([])
 const formData = ref<StrAnyObj>({})
 
-const dialogTitle = ref<string>('')
 const dialogVisible = ref<boolean>(false)
 
 const queryConfig: FormConfigType[] = [
@@ -86,33 +83,19 @@ const toolbarConfig: ToolbarConfigType[] = [
       queryRef.value?.resetFields()
       getPage()
     }
-  },
-  {
-    common: 'add',
-    click() {
-      dialogVisible.value = true
-      dialogTitle.value = '新增'
-    }
   }
-  // {
-  //   common: 'delete',
-  //   disabled() {
-  //     return selectKeys.value.length == 0
-  //   },
-  //   click() {
-  //     handleRemove(selectKeys.value)
-  //   }
-  // }
 ]
 
 const columnConfig: ColumnConfigType[] = [
   {
     prop: 'moduleName',
-    label: '模块标题'
+    label: '模块标题',
+    width: 160
   },
   {
     prop: 'operatorName',
-    label: '操作人姓名'
+    label: '操作人姓名',
+    width: 160
   },
   {
     prop: 'operationType',
@@ -127,11 +110,13 @@ const columnConfig: ColumnConfigType[] = [
           return '删除'
       }
       return ''
-    }
+    },
+    width: 120
   },
   {
     prop: 'createTime',
-    label: '操作时间'
+    label: '操作时间',
+    width: 160
   },
   {
     prop: 'description',
@@ -150,43 +135,35 @@ const columnConfig: ColumnConfigType[] = [
           return '拒绝'
       }
       return ''
-    }
+    },
+    width: 120
   },
   {
     prop: 'auditTime',
-    label: '审核时间'
+    label: '审核时间',
+    width: 160
   },
   {
     prop: 'remark',
     label: '审核注释'
   },
   {
-    width: 250,
+    width: 120,
     handleConfig: [
       {
+        if: (row) => row.auditStatus == 0,
         text: '审核',
         click(row) {
           dialogVisible.value = true
-          dialogTitle.value = '审核'
           getDetailApi({ id: row.id }).then((resp: StrAnyObj) => {
             formData.value = resp
           })
         }
       }
-      // {
-      //   common: 'delete',
-      //   click(row) {
-      //     handleRemove([row.id])
-      //   }
-      // }
     ]
   }
 ]
 
-const formConfig: FormConfigType[] = [
-
-]
-
 onMounted(() => {
   getPage()
 })
@@ -198,32 +175,15 @@ function getPage() {
   })
 }
 
-function tableSelectionChange(item: StrAnyObjArr) {
-  selectKeys.value = item.map((item) => item.id)
-}
-
-function formSubmit() {
+function formSubmit(status: boolean) {
   formRef.value?.validate(() => {
-    editApi(formData.value).then(() => {
+    editApi({ ...formData.value, auditStatus: status ? 1 : 2 }).then(() => {
       dialogVisible.value = false
       ElMessage.success('操作成功')
       getPage()
     })
   })
 }
-
-function formClosed() {
-  formRef.value?.resetFields()
-}
-
-function handleRemove(idList: string[]) {
-  useHandleData('是否确认删除?', () => {
-    deleteApi({ idList }).then(() => {
-      ElMessage.success('删除成功')
-      getPage()
-    })
-  })
-}
 </script>
 
 <template>
@@ -233,7 +193,6 @@ function handleRemove(idList: string[]) {
     </el-card>
 
     <a-table
-      selection
       :data="tableData"
       :page-total="pageTotal"
       :toolbar-config="toolbarConfig"
@@ -243,12 +202,18 @@ function handleRemove(idList: string[]) {
       v-model:page-size="queryData.pageSize"
       @page-num-change="getPage"
       @page-size-change="getPage"
-      @selection-change="tableSelectionChange"
     >
     </a-table>
 
-    <a-dialog v-model="dialogVisible" :title="dialogTitle" @submit="formSubmit" @closed="formClosed">
-      <a-form ref="formRef" v-model="formData" :config="formConfig" :span="24"> </a-form>
+    <a-dialog v-model="dialogVisible" title="审核" :footer="false">
+      <el-input style="padding: 20px 0" type="textarea" v-model="formData.remark" placeholder="请输入审核备注" />
+      <div style="text-align: center">
+        <div>
+          <el-button plain type="info" @click="dialogVisible = false">关 闭</el-button>
+          <el-button plain type="success" @click="formSubmit(true)">通 过</el-button>
+          <el-button plain type="warning" @click="formSubmit(false)">拒 绝</el-button>
+        </div>
+      </div>
     </a-dialog>
   </div>
 </template>