24282 před 11 měsíci
rodič
revize
41986489f9

+ 24 - 55
jy-flow/src/main/java/com/jy/flow/controller/DefController.java

@@ -6,10 +6,6 @@ import com.warm.flow.core.service.DefService;
 import com.warm.flow.core.utils.page.Page;
 import com.warm.flow.orm.entity.FlowDefinition;
 import jakarta.annotation.Resource;
-import jakarta.servlet.http.HttpServletResponse;
-import org.dom4j.Document;
-import org.dom4j.io.OutputFormat;
-import org.dom4j.io.XMLWriter;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.DeleteMapping;
 import org.springframework.web.bind.annotation.GetMapping;
@@ -19,7 +15,6 @@ import org.springframework.web.bind.annotation.PutMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
-import org.springframework.web.multipart.MultipartFile;
 
 import java.io.IOException;
 import java.util.Collections;
@@ -54,7 +49,6 @@ public class DefController {
     @PostMapping
     @Transactional(rollbackFor = Exception.class)
     public Boolean add(@RequestBody FlowDefinition flowDefinition) {
-        flowDefinition.setActivityStatus(0);
         return defService.checkAndSave(flowDefinition);
     }
 
@@ -72,7 +66,7 @@ public class DefController {
      */
     @DeleteMapping("/{id}")
     @Transactional(rollbackFor = Exception.class)
-    public boolean remove(@PathVariable(name = "id", required = true) Long id) {
+    public boolean remove(@PathVariable(name = "id") Long id) {
         return defService.removeDef(Collections.singletonList(id));
     }
 
@@ -95,6 +89,22 @@ public class DefController {
     }
 
     /**
+     * 激活流程
+     */
+    @GetMapping("/active/{definitionId}")
+    public Boolean active(@PathVariable("definitionId") Long definitionId) {
+        return defService.active(definitionId);
+    }
+
+    /**
+     * 挂起流程
+     */
+    @GetMapping("/unActive/{definitionId}")
+    public Boolean unActive(@PathVariable("definitionId") Long definitionId) {
+        return defService.unActive(definitionId);
+    }
+
+    /**
      * 保存流程定义
      */
     @PostMapping("/saveXml")
@@ -112,34 +122,9 @@ public class DefController {
         return defService.copyDef(id);
     }
 
-    @PostMapping("/importDefinition")
-    @Transactional(rollbackFor = Exception.class)
-    public void importDefinition(MultipartFile file) throws Exception {
-        defService.importXml(file.getInputStream());
-    }
-
-    @PostMapping("/exportDefinition/{id}")
-    public void exportDefinition(@PathVariable("id") Long id, HttpServletResponse response) throws Exception {
-        Document document = defService.exportXml(id);
-        // 设置生成xml的格式
-        OutputFormat of = OutputFormat.createPrettyPrint();
-        // 设置编码格式
-        of.setEncoding("UTF-8");
-        of.setIndent(true);
-        of.setIndent("    ");
-        of.setNewlines(true);
-
-        // 创建一个xml文档编辑器
-        XMLWriter writer = new XMLWriter(response.getOutputStream(), of);
-        writer.setEscapeText(false);
-        response.reset();
-        response.setCharacterEncoding("UTF-8");
-        response.setContentType("application/x-msdownload");
-        response.setHeader("Content-Disposition", "attachment;");
-        writer.write(document);
-        writer.close();
-    }
-
+    /**
+     * 获取流程xml定义字符串
+     */
     @GetMapping("/xmlString/{id}")
     public String xmlString(@PathVariable("id") Long id) {
         return defService.xmlString(id);
@@ -148,33 +133,17 @@ public class DefController {
     /**
      * 查询流程图
      */
-    @GetMapping("/flowChartNoColor/{definitionId}")
-    public String flowChartNoColor(@PathVariable("definitionId") Long definitionId) throws IOException {
-        return defService.flowChartNoColor(definitionId);
-    }
-
-    /**
-     * 查询流程图
-     */
     @GetMapping("/flowChart/{instanceId}")
     public String flowChart(@PathVariable("instanceId") Long instanceId) throws IOException {
         return defService.flowChart(instanceId);
     }
 
     /**
-     * 激活流程
-     */
-    @GetMapping("/active/{definitionId}")
-    public Boolean active(@PathVariable("definitionId") Long definitionId) {
-        return defService.active(definitionId);
-    }
-
-    /**
-     * 挂起流程
+     * 查询流程图
      */
-    @GetMapping("/unActive/{definitionId}")
-    public Boolean unActive(@PathVariable("definitionId") Long definitionId) {
-        return defService.unActive(definitionId);
+    @GetMapping("/flowChartNoColor/{definitionId}")
+    public String flowChartNoColor(@PathVariable("definitionId") Long definitionId) throws IOException {
+        return defService.flowChartNoColor(definitionId);
     }
 
 }

+ 9 - 9
jy-flow/src/main/java/com/jy/flow/controller/ExecuteController.java

@@ -147,15 +147,6 @@ public class ExecuteController {
     }
 
     /**
-     * 分页抄送任务列表
-     */
-    @GetMapping("/copyPage")
-    public Page<FlowHisTask> copyPage(FlowTaskDto dto) {
-        dto.setPermissionList(AbstractWarmFlowAdapter.permissionList());
-        return executeService.copyPage(dto);
-    }
-
-    /**
      * 分页已办任务列表
      */
     @GetMapping("/donePage")
@@ -180,6 +171,15 @@ public class ExecuteController {
     }
 
     /**
+     * 分页抄送任务列表
+     */
+    @GetMapping("/copyPage")
+    public Page<FlowHisTask> copyPage(FlowTaskDto dto) {
+        dto.setPermissionList(AbstractWarmFlowAdapter.permissionList());
+        return executeService.copyPage(dto);
+    }
+
+    /**
      * 查询已办任务历史记录
      */
     @GetMapping("/doneList/{instanceId}")

+ 6 - 1
jy-ui/src/api/flow/execute.ts

@@ -1,7 +1,7 @@
 import request from '@/utils/request'
 import { PageType, StrAnyObj } from '@/typings'
 
-// 查询待办任务列表
+// 查询待办任务分页
 export function getToDoPageApi(params: StrAnyObj): Promise<PageType<StrAnyObj>> {
   return request.get('/flow/execute/todoPage', params)
 }
@@ -15,3 +15,8 @@ export function getDoneListApi(id: string): Promise<PageType<StrAnyObj>> {
 export function handleApi(data: StrAnyObj): Promise<void> {
   return request.post(`/flow/execute/handle`, data)
 }
+
+// 查询已办任务分页
+export function getDonePageApi(params: StrAnyObj): Promise<PageType<StrAnyObj>> {
+  return request.get('/flow/execute/donePage', params)
+}

+ 253 - 0
jy-ui/src/views/flow/taskDone/index.vue

@@ -0,0 +1,253 @@
+<script setup lang="ts">
+import AForm from '@/components/AForm/index.vue'
+import { FormConfigType } from '@/components/AForm/type'
+import { ToolbarConfigType } from '@/components/AToolbar/type'
+import { ColumnConfigType } from '@/components/ATable/type'
+import { StrAnyObj, StrAnyObjArr } from '@/typings'
+import {getDoneListApi, getDonePageApi, handleApi} from '@/api/flow/execute'
+import { getChartApi } from '@/api/flow/definition'
+
+const modules = import.meta.glob('@/views/**/*.vue')
+
+const queryRef = ref<InstanceType<typeof AForm>>()
+
+const showQuery = ref<boolean>(true)
+const pageTotal = ref<number>(0)
+
+const queryData = ref<StrAnyObj>({ pageNum: 1, pageSize: 10 })
+const tableData = ref<StrAnyObjArr>([])
+
+const chartVisible = ref(false)
+const imgUrl = ref('')
+
+const doneListVisible = ref(false)
+const doneList = ref([])
+
+const handleData = ref({})
+
+const handleVisible = ref(false)
+const handleComponent = ref(null)
+const businessId = ref(null)
+const taskId = ref(null)
+
+const queryConfig: FormConfigType[] = [
+  {
+    type: 'input',
+    prop: 'nodeName',
+    label: '节点名称'
+  },
+  {
+    type: 'select',
+    prop: 'flowStatus',
+    label: '流程状态',
+    dict: 'flow_status'
+  },
+  {
+    type: 'datePicker',
+    prop: 'createTime',
+    label: '创建时间',
+    datePickerType: 'date',
+    format: 'YYYY-MM-DD',
+    valueFormat: 'YYYY-MM-DD 00:00:00'
+  }
+]
+
+const toolbarConfig: ToolbarConfigType[] = [
+  {
+    common: 'search',
+    click() {
+      queryData.value.pageNum = 1
+      getPage()
+    }
+  },
+  {
+    common: 'reset',
+    click() {
+      queryRef.value?.resetFields()
+      getPage()
+    }
+  }
+]
+
+const columnConfig: ColumnConfigType[] = [
+  {
+    prop: 'flowName',
+    label: '流程名称'
+  },
+  {
+    prop: 'nodeName',
+    label: '节点名称'
+  },
+  {
+    prop: 'approver',
+    label: '审批人'
+  },
+  {
+    prop: 'transferredBy',
+    label: '转办人'
+  },
+  {
+    prop: 'delegate',
+    label: '委派人'
+  },
+  {
+    prop: 'flowStatus',
+    label: '流程状态',
+    dict: 'flow_status'
+  },
+  {
+    prop: 'activityStatus',
+    label: '激活状态',
+    dict: 'activity_status'
+  },
+  {
+    prop: 'createTime',
+    label: '创建时间'
+  },
+  {
+    width: 200,
+    handleConfig: [
+      {
+        text: '办理',
+        click(row) {
+          const path = `/src/views/${row.formPath}`
+          const module = modules[path]
+          if (!module) {
+            ElMessage.error(`未知流程表单路径:${path}`)
+            return
+          }
+          businessId.value = row.businessId
+          taskId.value = row.id
+          handleComponent.value = markRaw(defineAsyncComponent(module))
+          handleVisible.value = true
+        }
+      },
+      {
+        text: '流程图',
+        click(row) {
+          getChartApi(row.instanceId).then((resp) => {
+            chartVisible.value = true
+            imgUrl.value = 'data:image/gif;base64,' + resp
+          })
+        }
+      },
+      {
+        text: '审批记录',
+        click(row) {
+          getDoneListApi(row.instanceId).then((resp) => {
+            doneListVisible.value = true
+            doneList.value = resp
+          })
+        }
+      }
+    ]
+  }
+]
+
+const doneListColumnConfig: ColumnConfigType[] = [
+  {
+    prop: 'nodeName',
+    label: '审批节点'
+  },
+  {
+    prop: 'targetNodeName',
+    label: '跳转节点'
+  },
+  {
+    prop: 'approver',
+    label: '审批人'
+  },
+  {
+    prop: 'createTime',
+    label: '审批时间'
+  },
+  {
+    prop: 'message',
+    label: '审批意见',
+    showOverflowTooltip: true
+  }
+]
+
+const handleConfig: FormConfigType[] = [
+  {
+    type: 'input',
+    itemType: 'textarea',
+    label: '审批意见',
+    prop: 'message',
+    rows: 5
+  },
+  {
+    type: 'slot',
+    label: '审批类型',
+    prop: 'handle'
+  }
+]
+
+onMounted(() => {
+  getPage()
+})
+
+function getPage() {
+  getDonePageApi(queryData.value).then((resp) => {
+    tableData.value = resp.records
+    pageTotal.value = resp.total
+  })
+}
+
+function handle(handleType) {
+  const message = handleData.value.message
+  handleApi({ taskId: taskId.value, handleType, message }).then(() => {
+    getPage()
+    ElMessage.success('办理成功')
+    this.handleVisible = false
+  })
+}
+</script>
+
+<template>
+  <div>
+    <el-card v-if="showQuery">
+      <a-form ref="queryRef" v-model="queryData" :config="queryConfig" :span="6"> </a-form>
+    </el-card>
+
+    <a-table
+      :data="tableData"
+      :page-total="pageTotal"
+      :toolbar-config="toolbarConfig"
+      :column-config="columnConfig"
+      v-model:showQuery="showQuery"
+      v-model:page-num="queryData.pageNum"
+      v-model:page-size="queryData.pageSize"
+      @page-num-change="getPage"
+      @page-size-change="getPage"
+    >
+    </a-table>
+
+    <a-dialog title="" v-model="handleVisible" width="1200px" :footer="false">
+      <el-card shadow="always">
+        <template #header>流程明细</template>
+        <component :is="handleComponent" :businessId="businessId" />
+      </el-card>
+
+      <el-card shadow="always" style="margin-top: 20px">
+        <template #header>办理参数</template>
+        <a-form v-model="handleData" :config="handleConfig" :span="24">
+          <template #handle>
+            <el-button type="primary" @click="handle(1)">通 过</el-button>
+            <el-button type="primary" @click="handle(2)">回 退</el-button>
+            <el-button type="primary" @click="handle(3)">拒 绝</el-button>
+            <el-button @click="handleVisible = false">关 闭</el-button>
+          </template>
+        </a-form>
+      </el-card>
+    </a-dialog>
+
+    <a-dialog title="流程图" v-model="chartVisible" width="1200px" :footer="false">
+      <img :src="imgUrl" width="100%" style="margin: 0 auto" alt="" />
+    </a-dialog>
+
+    <a-dialog title="审批记录" v-model="doneListVisible" width="1000px" :footer="false">
+      <a-table :data="doneList" :column-config="doneListColumnConfig" :card="false"> </a-table>
+    </a-dialog>
+  </div>
+</template>

+ 2 - 7
jy-ui/src/views/flow/taskTodo/index.vue

@@ -34,7 +34,7 @@ const queryConfig: FormConfigType[] = [
   {
     type: 'input',
     prop: 'nodeName',
-    label: '任务名称'
+    label: '节点名称'
   },
   {
     type: 'select',
@@ -76,7 +76,7 @@ const columnConfig: ColumnConfigType[] = [
   },
   {
     prop: 'nodeName',
-    label: '任务名称'
+    label: '节点名称'
   },
   {
     prop: 'approver',
@@ -96,11 +96,6 @@ const columnConfig: ColumnConfigType[] = [
     dict: 'flow_status'
   },
   {
-    prop: 'activityStatus',
-    label: '激活状态',
-    dict: 'activity_status'
-  },
-  {
     prop: 'createTime',
     label: '创建时间'
   },