李志伟 před 3 roky
rodič
revize
8948e29ec5

+ 2
- 2
src/components/Jianbian/index.jsx Zobrazit soubor

@@ -8,12 +8,12 @@ export default (props) => {
8 8
       type == 'machinery' ?
9 9
         (value ? 'workingClass' : 'waitClass') :
10 10
         status == 0 ? 'waitClass' :
11
-          status == 1 ? 'workingClass' :
11
+          status == 1 || status == 2 ? 'workingClass' :
12 12
             status == 3 ? 'overClass' : ''
13 13
     ]}
14 14
     >
15 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 17
       </View>
18 18
     </View>
19 19
   )

+ 4
- 3
src/components/MyCard/index.jsx Zobrazit soubor

@@ -12,10 +12,11 @@ export default (props) => {
12 12
       <Jianbian status={job?value?.status:value?.workStatus} />
13 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 21
       </View>
21 22
       <View className='line' />
@@ -29,7 +30,7 @@ export default (props) => {
29 30
       <MyCell header='作业时间'><View>{value?.startDate}</View><View>{value?.endDate}</View></MyCell>
30 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 36
         order && <View className='line' />

+ 37
- 6
src/pages/index/components/order/index.jsx Zobrazit soubor

@@ -49,9 +49,18 @@ export default (props) => {
49 49
     setJob()
50 50
   }
51 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 66
   const handleArea = (e) => {
@@ -62,8 +71,31 @@ export default (props) => {
62 71
     setShowOver(false)
63 72
   }
64 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 101
   useEffect(() => {
@@ -154,7 +186,6 @@ export default (props) => {
154 186
           </View>
155 187
           <Button className='btn' onClick={handleOverOk}>确认</Button>
156 188
         </Popup>
157
-
158 189
       </ScrollView>
159 190
     </View>
160 191
   )

+ 4
- 2
src/pages/orderDetail/index.jsx Zobrazit soubor

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

+ 2
- 2
src/services/job.js Zobrazit soubor

@@ -19,11 +19,11 @@ import request from '@/utils/request'
19 19
  * @param {*} data
20 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 26
  * @param {*} data
27 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 });