李志伟 3 years ago
parent
commit
8948e29ec5

+ 2
- 2
src/components/Jianbian/index.jsx View File

8
       type == 'machinery' ?
8
       type == 'machinery' ?
9
         (value ? 'workingClass' : 'waitClass') :
9
         (value ? 'workingClass' : 'waitClass') :
10
         status == 0 ? 'waitClass' :
10
         status == 0 ? 'waitClass' :
11
-          status == 1 ? 'workingClass' :
11
+          status == 1 || status == 2 ? 'workingClass' :
12
             status == 3 ? 'overClass' : ''
12
             status == 3 ? 'overClass' : ''
13
     ]}
13
     ]}
14
     >
14
     >
15
       <View className='text'>
15
       <View className='text'>
16
-        {type == 'machinery' ? (value ? '使用中' : '空闲中') : status == 0 ? '待作业' : status == 1 ? '进行中' : status == 3 ? '已完成' : ''}
16
+        {type == 'machinery' ? (value ? '使用中' : '空闲中') : status == 0 ? '待作业' : status == 1 || status == 2 ? '进行中' : status == 3 ? '已完成' : ''}
17
       </View>
17
       </View>
18
     </View>
18
     </View>
19
   )
19
   )

+ 4
- 3
src/components/MyCard/index.jsx View File

12
       <Jianbian status={job?value?.status:value?.workStatus} />
12
       <Jianbian status={job?value?.status:value?.workStatus} />
13
       <View className='cardHead'>
13
       <View className='cardHead'>
14
         {
14
         {
15
-          job && <MyCell header='需求时间' job action='详情>>' handleAction={goDetail}>{value?.appointmentDate?.substr(0,10)}</MyCell>
15
+          //首页作业列表卡片
16
+          job &&!detail&& <MyCell header='需求时间' job action='详情>>' handleAction={goDetail}>{value?.appointmentDate?.substr(0,10)}</MyCell>
16
         }
17
         }
17
         {
18
         {
18
-          !job && <MyCell header='需求时间'>{value?.appointmentDate?.substr(0,10)}</MyCell>
19
+          (!job||job&&detail) && <MyCell header='需求时间'>{value?.appointmentDate?.substr(0,10)}</MyCell>
19
         }
20
         }
20
       </View>
21
       </View>
21
       <View className='line' />
22
       <View className='line' />
29
       <MyCell header='作业时间'><View>{value?.startDate}</View><View>{value?.endDate}</View></MyCell>
30
       <MyCell header='作业时间'><View>{value?.startDate}</View><View>{value?.endDate}</View></MyCell>
30
       <MyCell header='订单费用'>{(value?.charges&&value.charges/100)||600}元</MyCell>
31
       <MyCell header='订单费用'>{(value?.charges&&value.charges/100)||600}元</MyCell>
31
       {
32
       {
32
-        job &&value.status!=3&& <MyButton value={value.status==0?'开始作业':'完成作业'} onClick={onClick} />
33
+        job &&value?.status!=3&&!detail&& <MyButton value={value?.status==0?'开始作业':'完成作业'} onClick={onClick} />
33
       }
34
       }
34
       {
35
       {
35
         order && <View className='line' />
36
         order && <View className='line' />

+ 37
- 6
src/pages/index/components/order/index.jsx View File

49
     setJob()
49
     setJob()
50
   }
50
   }
51
   const handleOk = () => {
51
   const handleOk = () => {
52
-    console.log('开始作业')
53
-    toggleJob(job.jobId, { mode: false }).then(() => {
54
-      setShow(false)
52
+    toggleJob(job.jobId, { mode: true }).then(() => {
53
+      //目测有bug
54
+      getJobList({ pageNum: currentPage }).then(res => {
55
+        const lst = currentPage === 1 ? res.records || [] : jobList.concat(res.records || [])
56
+        //长列表加载当下一页没有数据时
57
+        if (res.records.length == 0 && currentPage != 1) {
58
+          setIsMore(true)
59
+          return
60
+        }
61
+        setJobList(lst)
62
+        onClose()
63
+      })
55
     })
64
     })
56
   }
65
   }
57
   const handleArea = (e) => {
66
   const handleArea = (e) => {
62
     setShowOver(false)
71
     setShowOver(false)
63
   }
72
   }
64
   const handleOverOk = () => {
73
   const handleOverOk = () => {
65
-    if (area) {
66
-      console.log(666)
74
+    //正整数或两位小数
75
+    const test2 = /^\d+(\.\d{1,2})?$/.test(area)
76
+    if (test2) {
77
+      overJob(job.jobId,{...job,area:area}).then(res=>{
78
+        Taro.showToast({
79
+          title: '恭喜完成作业',
80
+          icon: 'none',
81
+        })
82
+        getJobList({ pageNum: currentPage }).then(res2 => {
83
+          const lst = currentPage === 1 ? res2.records || [] : jobList.concat(res2.records || [])
84
+          //长列表加载当下一页没有数据时
85
+          if (res2.records.length == 0 && currentPage != 1) {
86
+            setIsMore(true)
87
+            return
88
+          }
89
+          setJobList(lst)
90
+          onOverClose()
91
+        })
92
+      })
93
+    }
94
+    else{
95
+      Taro.showToast({
96
+        title: '请输入正确的面积整数或最多两位小数',
97
+        icon: 'none',
98
+      })
67
     }
99
     }
68
   }
100
   }
69
   useEffect(() => {
101
   useEffect(() => {
154
           </View>
186
           </View>
155
           <Button className='btn' onClick={handleOverOk}>确认</Button>
187
           <Button className='btn' onClick={handleOverOk}>确认</Button>
156
         </Popup>
188
         </Popup>
157
-
158
       </ScrollView>
189
       </ScrollView>
159
     </View>
190
     </View>
160
   )
191
   )

+ 4
- 2
src/pages/orderDetail/index.jsx View File

21
         setValue(res)
21
         setValue(res)
22
       })
22
       })
23
     }
23
     }
24
-  }, [id])
24
+  }, [id, job])
25
   return (
25
   return (
26
     <View className='page-index'>
26
     <View className='page-index'>
27
       <View className='index-navbar'>
27
       <View className='index-navbar'>
28
         <CustomNav title='更多' />
28
         <CustomNav title='更多' />
29
       </View>
29
       </View>
30
       <View className='index-container'>
30
       <View className='index-container'>
31
-        <MyCard detail value={value} />
31
+        {
32
+          job?<MyCard detail job value={value} />:<MyCard detail value={value} />
33
+        }
32
       </View>
34
       </View>
33
     </View>
35
     </View>
34
   )
36
   )

+ 2
- 2
src/services/job.js View File

19
  * @param {*} data
19
  * @param {*} data
20
  * @returns
20
  * @returns
21
  */
21
  */
22
-export const toggleJob = (id, data) => request(`/work-job/${id}/pause`, { method: 'put', data });
22
+export const toggleJob = (id, params) => request(`/work-job/${id}/pause`, { method: 'put', params });
23
 
23
 
24
 /**
24
 /**
25
  * 完成作业
25
  * 完成作业
26
  * @param {*} data
26
  * @param {*} data
27
  * @returns
27
  * @returns
28
  */
28
  */
29
-export const overJob = (id, data) => request(`/worker/work-job/${id}/stop`, { method: 'put', data });
29
+export const overJob = (id, data) => request(`/work-job/${id}/stop`, { method: 'put', data });