|
@@ -1,102 +1,109 @@
|
1
|
1
|
import { useState, useEffect } from "react";
|
2
|
2
|
|
3
|
3
|
export default function useProcessStatus(orderInfo) {
|
4
|
|
-/**
|
5
|
|
- * 业务流程如下:
|
6
|
|
- * 1、农户下单 - 未支付 (管理端待分配订单)
|
7
|
|
- * 2、农机手待接单
|
8
|
|
- * 3、农机手接单干活
|
9
|
|
- * 4、农机手结单 - 确定亩数 (农户待支付)
|
10
|
|
- * 5、农户待评价
|
11
|
|
- * 6、结单(订单完成)
|
12
|
|
- */
|
|
4
|
+ /**
|
|
5
|
+ * 业务流程如下:
|
|
6
|
+ * 1、农户下单 - 未支付 (管理端待分配订单)
|
|
7
|
+ * 2、农机手待接单
|
|
8
|
+ * 3、农机手接单干活
|
|
9
|
+ * 4、农机手结单 - 确定亩数 (农户待支付)
|
|
10
|
+ * 5、农户待评价
|
|
11
|
+ * 6、结单(订单完成)
|
|
12
|
+ */
|
13
|
13
|
|
14
|
|
- const [processStatus, setProcessStatus] = useState()
|
|
14
|
+ const [processStatus, setProcessStatus] = useState();
|
15
|
15
|
|
16
|
16
|
useEffect(() => {
|
17
|
17
|
if (!orderInfo || !orderInfo.orderId) return;
|
18
|
18
|
|
19
|
19
|
setProcessStatus(getProcessStatus(orderInfo));
|
20
|
|
- }, [orderInfo])
|
|
20
|
+ }, [orderInfo]);
|
21
|
21
|
|
22
|
|
- return { processStatus }
|
|
22
|
+ return { processStatus };
|
23
|
23
|
}
|
24
|
24
|
|
25
|
25
|
export function getProcessStatus(orderInfo) {
|
26
|
|
-
|
27
|
26
|
if (!orderInfo || !orderInfo.orderId) return;
|
28
|
27
|
|
29
|
28
|
// 订单完成
|
30
|
29
|
if (orderInfo.isEvaluated) {
|
31
|
|
- return 6
|
|
30
|
+ return 6;
|
32
|
31
|
}
|
33
|
|
-
|
|
32
|
+
|
34
|
33
|
// 待支付
|
35
|
|
- if (orderInfo.workStatus === 3 && orderInfo.charges > 0 && orderInfo.payStatus !== 1) {
|
36
|
|
- return 4
|
|
34
|
+ if (
|
|
35
|
+ orderInfo.workStatus === 3 &&
|
|
36
|
+ orderInfo.charges > 0 &&
|
|
37
|
+ orderInfo.payStatus !== 1
|
|
38
|
+ ) {
|
|
39
|
+ return 4;
|
37
|
40
|
}
|
38
|
41
|
|
39
|
42
|
// 待评价
|
40
|
43
|
if (orderInfo.workStatus === 3 && !orderInfo.isEvaluated) {
|
41
|
|
- return 5
|
|
44
|
+ return 5;
|
42
|
45
|
}
|
43
|
46
|
|
44
|
47
|
// 工作中
|
45
|
|
- if (orderInfo.workStatus !== 3 && orderInfo.dispatchStatus) {
|
46
|
|
- return 3
|
|
48
|
+ if (
|
|
49
|
+ orderInfo.workStatus > 0 &&
|
|
50
|
+ orderInfo.workStatus < 3 &&
|
|
51
|
+ orderInfo.dispatchStatus
|
|
52
|
+ ) {
|
|
53
|
+ return 3;
|
47
|
54
|
}
|
48
|
55
|
|
49
|
56
|
// 待接单
|
50
|
57
|
if (!orderInfo.workStatus && orderInfo.dispatchStatus) {
|
51
|
|
- return 2
|
|
58
|
+ return 2;
|
52
|
59
|
}
|
53
|
60
|
|
54
|
61
|
// 待分配
|
55
|
62
|
if (orderInfo.status === 1 && !orderInfo.dispatchStatus) {
|
56
|
|
- return 1
|
|
63
|
+ return 1;
|
57
|
64
|
}
|
58
|
|
-
|
59
|
|
- return -1
|
|
65
|
+
|
|
66
|
+ return -1;
|
60
|
67
|
}
|
61
|
68
|
|
62
|
69
|
export function getProcessSignBy(status) {
|
63
|
|
- if (status === undefined || status === null) return {}
|
64
|
|
-
|
|
70
|
+ if (status === undefined || status === null) return {};
|
|
71
|
+
|
65
|
72
|
switch (status) {
|
66
|
73
|
case 1:
|
67
|
74
|
return {
|
68
|
|
- label: '待分配',
|
69
|
|
- color: '#FF703B'
|
70
|
|
- }
|
|
75
|
+ label: "待分配",
|
|
76
|
+ color: "#FF703B",
|
|
77
|
+ };
|
71
|
78
|
case 2:
|
72
|
79
|
return {
|
73
|
|
- label: '待作业',
|
74
|
|
- color: '#FF703B'
|
75
|
|
- }
|
|
80
|
+ label: "待作业",
|
|
81
|
+ color: "#FF703B",
|
|
82
|
+ };
|
76
|
83
|
case 3:
|
77
|
84
|
return {
|
78
|
|
- label: '进行中',
|
79
|
|
- color: '#44F68B'
|
80
|
|
- }
|
|
85
|
+ label: "进行中",
|
|
86
|
+ color: "#44F68B",
|
|
87
|
+ };
|
81
|
88
|
case 4:
|
82
|
89
|
return {
|
83
|
|
- label: '待付款',
|
84
|
|
- color: '#51D4FF'
|
85
|
|
- }
|
|
90
|
+ label: "待付款",
|
|
91
|
+ color: "#51D4FF",
|
|
92
|
+ };
|
86
|
93
|
case 5:
|
87
|
94
|
return {
|
88
|
|
- label: '待评价',
|
89
|
|
- color: '#51D4FF'
|
90
|
|
- }
|
|
95
|
+ label: "待评价",
|
|
96
|
+ color: "#51D4FF",
|
|
97
|
+ };
|
91
|
98
|
case 6:
|
92
|
99
|
return {
|
93
|
|
- label: '已完成',
|
94
|
|
- color: '#FF703B'
|
95
|
|
- }
|
|
100
|
+ label: "已完成",
|
|
101
|
+ color: "#FF703B",
|
|
102
|
+ };
|
96
|
103
|
default:
|
97
|
104
|
return {
|
98
|
|
- label: '异常',
|
99
|
|
- color: '#FF0000'
|
100
|
|
- }
|
|
105
|
+ label: "异常",
|
|
106
|
+ color: "#FF0000",
|
|
107
|
+ };
|
101
|
108
|
}
|
102
|
109
|
}
|