Skip to content

Commit 103db2a

Browse files
committed
fix chart show
1 parent eebafb6 commit 103db2a

File tree

8 files changed

+60
-27
lines changed

8 files changed

+60
-27
lines changed

admin-ui/src/components/Flow/flow/FlowDetail.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ const FlowDetail: React.FC<FlowDetailProps> = (props) => {
4242
)}
4343

4444
{/*仅当非发起流程时再展示审批意见框*/}
45-
{FlowFormView && !flowData.isDone() && !flowData.isStartFlow() && (
45+
{FlowFormView && flowData.showOpinion() && (
4646
<div className="opinionForm">
4747
<div>
4848
<Divider>

admin-ui/src/components/Flow/flow/FlowHistoryLine.tsx

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from "react";
22
import {UserOutlined} from "@ant-design/icons";
3-
import {Timeline} from "antd";
3+
import {Tag, Timeline} from "antd";
44
import moment from "moment";
55
import {FlowData} from "@/components/Flow/flow/data";
66

@@ -12,11 +12,35 @@ const FlowHistoryLine: React.FC<FlowHistoryLineProps> = (props) => {
1212
const flowData = props.flowData;
1313
const timelineData = flowData.getHistoryRecords();
1414
const items = timelineData.map((item: any, index: any) => {
15+
16+
const flowType = item.flowType;
17+
18+
const flowTypeLabel = ()=>{
19+
if(flowType === "DONE"){
20+
return (
21+
<Tag color="success">已审批</Tag>
22+
);
23+
}else if(flowType === "TODO"){
24+
return (
25+
<Tag color="processing">待审批</Tag>
26+
);
27+
}else if(flowType === "CIRCULATE"){
28+
return (
29+
<Tag color="cyan">已抄送</Tag>
30+
)
31+
}else if(flowType === "TRANSFER"){
32+
return (
33+
<Tag color="blue">已转办</Tag>
34+
)
35+
}
36+
}
37+
1538
return {
1639
dot: <UserOutlined className="UserOutlined" />,
1740
children: (
1841
<div>
19-
<div className="title">{flowData.getNode(item.nodeCode).name}</div>
42+
<div className="title">{flowData.getNode(item.nodeCode).name} </div>
43+
<div><span>状态:</span> <span>{flowTypeLabel()}</span></div>
2044
<div>
2145
<span>创建人:</span> <span>{item.currentOperator.name}</span>
2246
{item.opinion && (

admin-ui/src/components/Flow/flow/FlowTabs.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const FlowTabs: React.FC<FlowTabsProps> = (props) => {
3838
},
3939
{
4040
key: 'history',
41-
label: '流程历史',
41+
label: '流程记录',
4242
children: (
4343
<Skeleton loading={true}>
4444
<></>
@@ -73,9 +73,9 @@ const FlowTabs: React.FC<FlowTabsProps> = (props) => {
7373
view={props.view}/>
7474
),
7575
},
76-
!flowData.isStartFlow() && {
76+
flowData.showHistory() && {
7777
key: 'history',
78-
label: '流程历史',
78+
label: '流程记录',
7979
children: <FlowHistory flowData={flowData}/>,
8080
},
8181
{

admin-ui/src/components/Flow/flow/data.ts

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -155,24 +155,18 @@ export class FlowData extends FlowWorkData {
155155
getNodeState = (code: string) => {
156156
const historyRecords = this.data.historyRecords || [];
157157

158-
const historyNodeCodes = historyRecords.map((record: any) => {
159-
return record.nodeCode;
160-
});
161-
162-
const currentNodeCode = this.data.flowNode.code;
163-
if (currentNodeCode === code) {
164-
if (this.isFinished()) {
165-
return "done";
166-
}
167-
return "current";
168-
}
169158

170-
if (historyNodeCodes.indexOf(code) !== -1) {
159+
if (this.isFinished()) {
171160
return "done";
172161
}
173162

174-
if (this.isFinished()) {
175-
return "done";
163+
for(const record of historyRecords){
164+
if(record.nodeCode === code){
165+
if(record.flowType==='TODO'){
166+
return "wait";
167+
}
168+
return "done";
169+
}
176170
}
177171

178172
return "wait";
@@ -217,5 +211,16 @@ export class FlowData extends FlowWorkData {
217211
}
218212
return false;
219213
}
214+
215+
showHistory() {
216+
if(this.isDone()){
217+
return true;
218+
}
219+
return !this.isStartFlow();
220+
}
221+
222+
showOpinion() {
223+
return this.canHandle();
224+
}
220225
}
221226

example/example-application/src/main/java/com/codingapi/example/query/FlowRecordQueryController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public class FlowRecordQueryController {
2929
@GetMapping("/list")
3030
public MultiResponse<FlowRecordEntity> list(SearchRequest searchRequest) {
3131
PageRequest pageRequest = PageRequest.of(searchRequest.getCurrent(), searchRequest.getPageSize(), Sort.by("id").descending());
32-
return MultiResponse.of(flowRecordQuery.findAll(pageRequest));
32+
return MultiResponse.of(flowRecordQuery.findAllFlowRecords(pageRequest));
3333
}
3434

3535

example/example-infra-flow/src/main/java/com/codingapi/example/jpa/FlowRecordEntityRepository.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,16 @@ public interface FlowRecordEntityRepository extends FastRepository<FlowRecordEnt
3333
@Query(value = "select r from FlowRecordEntity r where r.currentOperatorId = ?1 and r.workCode = ?2 and r.read = false and r.flowStatus = 'RUNNING' order by r.id desc")
3434
Page<FlowRecordEntity> findUnReadByOperatorIdAndWorkCode(long operatorId, String workCode, PageRequest pageRequest);
3535

36-
@Query(value = "select r from FlowRecordEntity r where r.currentOperatorId = ?1 and r.flowType = 'DONE' order by r.id desc")
36+
@Query(value = "select d from FlowRecordEntity d where d.id in (select max(r.id) from FlowRecordEntity r where r.currentOperatorId = ?1 and r.flowType = 'DONE' group by r.processId ) order by d.id desc")
3737
Page<FlowRecordEntity> findDoneByOperatorId(long operatorId, PageRequest pageRequest);
3838

39-
@Query(value = "select r from FlowRecordEntity r where r.currentOperatorId = ?1 and r.workCode = ?2 and r.flowType = 'DONE' order by r.id desc")
39+
@Query(value = "select d from FlowRecordEntity d where d.id in (select max(r.id) from FlowRecordEntity r where r.currentOperatorId = ?1 and r.workCode = ?2 and r.flowType = 'DONE' group by r.processId) order by d.id desc")
4040
Page<FlowRecordEntity> findDoneByOperatorIdAndworkCode(long operatorId, String workCode, PageRequest pageRequest);
4141

42-
@Query(value = "select r from FlowRecordEntity r where r.currentOperatorId = ?1 and r.preId = 0 and r.nodeCode = 'start' order by r.id desc")
42+
@Query(value = "select d from FlowRecordEntity d where d.id in (select max(r.id) from FlowRecordEntity r where r.currentOperatorId = ?1 and r.preId = 0 and r.nodeCode = 'start' group by r.processId) order by d.id desc")
4343
Page<FlowRecordEntity> findInitiatedByOperatorId(long operatorId, PageRequest pageRequest);
4444

45-
@Query(value = "select r from FlowRecordEntity r where r.currentOperatorId = ?1 and r.workCode = ?2 and r.preId = 0 and r.nodeCode = 'start' order by r.id desc")
45+
@Query(value = "select d from FlowRecordEntity d where d.id in (select max(r.id) from FlowRecordEntity r where r.currentOperatorId = ?1 and r.workCode = ?2 and r.preId = 0 and r.nodeCode = 'start' group by r.processId) order by d.id desc")
4646
Page<FlowRecordEntity> findInitiatedByOperatorIdAndWorkCode(long operatorId, String workCode, PageRequest pageRequest);
4747

4848
@Query(value = "select r from FlowRecordEntity r where r.currentOperatorId = ?1 and r.flowType = 'TODO' and r.flowStatus = 'RUNNING' and r.timeoutTime >0 and r.timeoutTime < ?2 order by r.id desc")
@@ -57,4 +57,8 @@ public interface FlowRecordEntityRepository extends FastRepository<FlowRecordEnt
5757
@Query(value = "select r from FlowRecordEntity r where r.currentOperatorId = ?1 and r.workCode =?2 and r.flowType = 'TODO' and r.flowStatus = 'RUNNING' and r.postponedCount > 0 order by r.id desc")
5858
Page<FlowRecordEntity> findPostponedTodoByOperatorIdAndWorkCode(long operatorId, String workCode, PageRequest pageRequest);
5959

60+
61+
@Query(value = "select d from FlowRecordEntity d where d.id in (select max(r.id) from FlowRecordEntity r group by r.processId ) order by d.id desc")
62+
Page<FlowRecordEntity> findAllFlowRecords(PageRequest pageRequest);
63+
6064
}

example/example-infra-flow/src/main/java/com/codingapi/example/query/FlowRecordQueryImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public class FlowRecordQueryImpl implements FlowRecordQuery {
2020

2121
@Override
2222
public Page<FlowRecord> findAll(PageRequest pageRequest) {
23-
Page<FlowRecordEntity> page = flowRecordEntityRepository.findAll(pageRequest);
23+
Page<FlowRecordEntity> page = flowRecordEntityRepository.findAllFlowRecords(pageRequest);
2424
return page.map(item->FlowRecordConvertor.convert(item,userRepository));
2525
}
2626

springboot-starter-flow/src/main/java/com/codingapi/springboot/flow/service/impl/FlowDetailService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public FlowDetail detail(long recordId, IFlowOperator currentOperator) {
6464
}
6565
}
6666

67-
return new FlowDetail(flowRecord, snapshot, flowWork, flowRecords, operators, currentOperator != null && flowRecord.isOperator(currentOperator));
67+
return new FlowDetail(flowRecord, snapshot, flowWork, flowRecords, operators, currentOperator != null && flowRecord.isTodo() && flowRecord.isOperator(currentOperator));
6868
}
6969

7070

0 commit comments

Comments
 (0)