xiaohaizhao 6 месяцев назад
Родитель
Сommit
6aee0c9269

+ 2 - 2
pages/index/home.vue

@@ -111,7 +111,7 @@ function uploadNumber() {
 				['待开始', '进行中', '已提交'].map(v =>
 					$Http.basic({
 						"id": "20230208140203", "content":
-							{ "pageNumber": 1, "pageSize": 0, "where": { "status": v, "condition": "" } }
+							{ "pageNumber": 1, "pageSize": 0, "nocache": true, "where": { "status": v, "condition": "" } }
 					})
 				)
 			).then(res => {
@@ -126,7 +126,7 @@ function uploadNumber() {
 		} else {
 			$Http.basic({
 				"id": "20230208140203", "content":
-					{ "pageNumber": 1, "pageSize": 0, isadmin: item.label == '抢单中心' ? '1' : '', "where": { "status": item.label == '抢单中心' ? '' : item.label, "condition": "", ispublic: item.label == '抢单中心' ? '1' : '' } }
+					{ "pageNumber": 1, "pageSize": 0, "nocache": true, isadmin: item.label == '抢单中心' ? '1' : '', "where": { "status": item.label == '抢单中心' ? '待接单' : item.label, "condition": "", ispublic: item.label == '抢单中心' ? '1' : '' } }
 			}).then(res => {
 				if (res.code !== 0) {
 					item.badge = res.total;

+ 33 - 1
pages/workOrder/detail.vue

@@ -125,12 +125,18 @@
                         'color': '#3874F6',
                     }" frontIcon="icon-bodadianhua1" text="电话" :phonenumber="detail.customerphonenumber" />
                 </view>
-                <view class="but-box-item" @click="takeOrderShow = true">
+                <view class="but-box-item" v-if="detail.team.length" @click="takeOrderShow = true">
                     <My-button frontIcon="icon-jiedan" text="接单" />
                     <up-modal negativeTop="100" :show="takeOrderShow" title="是否确认接单?" showCancelButton
                         @confirm="takeOrders" @cancel="takeOrderShow = false" ref="uModal"
                         :asyncClose="true"></up-modal>
                 </view>
+                <view class="but-box-item" v-else @click="takeOrderShow = true">
+                    <My-button frontIcon="icon-jiedan" text="抢单" />
+                    <up-modal negativeTop="100" :show="takeOrderShow" title="是否确认抢单?" showCancelButton
+                        @confirm="snatchingOrders" @cancel="takeOrderShow = false" ref="uModal"
+                        :asyncClose="true"></up-modal>
+                </view>
             </view>
             <!-- 底部按钮 -->
             <view v-else-if="detail.status == '待开始'" class="but-box">
@@ -317,6 +323,32 @@ function takeOrders() {
     })
 }
 
+function snatchingOrders() {
+    $Http.basic({
+        "id": "2025101710510903",
+        "content": {
+            "sa_workorderid": detail.sa_workorderid,
+            "projectlearders": [wx.getStorageSync('userMsg').userid],
+            ismanage: 0 // 用于避免多次抢单
+        },
+    }).then(res => {
+        if (res.code == 1) {
+            console.log("抢单结果", res)
+            takeOrderShow.value = false;
+            getDetail();
+            uni.showToast({
+                title: '抢单成功',
+                icon: 'none'
+            });
+        } else {
+            if (res.msg) uni.showToast({
+                title: res.msg,
+                icon: 'none'
+            });
+        }
+    })
+}
+
 function toCMTips() {
     uni.showModal({
         confirmText: '前去修改',

+ 1 - 0
pages/workOrder/index.vue

@@ -63,6 +63,7 @@ import { onLoad, onShow } from '@dcloudio/uni-app';
 
 const listBox = ref(null);
 const content = reactive({
+    "nocache": true,
     loading: false,
     isadmin: 0,
     "pageNumber": 1,

+ 40 - 6
pages/workOrder/snatchingOrders.vue

@@ -42,12 +42,13 @@ import { onLoad, onShow } from '@dcloudio/uni-app';
 const listBox = ref(null);
 const content = reactive({
     loading: false,
+    "nocache": true,
     isadmin: 1,
     "pageNumber": 1,
     "pageSize": 20,
     "where": {
         ispublic: 1,
-        "status": '',
+        "status": '待接单',
         "condition": ""
     }
 });
@@ -96,19 +97,21 @@ function openModel(item) {
 
 function takeOrders() {
     $Http.basic({
-        id: 20230210101103,
+        "id": "2025101710510903",
         "content": {
-            "sa_workorderid": takeItem.sa_workorderid
-        }
+            "sa_workorderid": takeItem.sa_workorderid,
+            "projectlearders": [wx.getStorageSync('userMsg').userid],
+            ismanage: 0 // 用于避免多次抢单
+        },
     }).then(res => {
-        console.log("接单结果", res)
         if (res.code == 1) {
+            console.log("抢单结果", res)
             takeOrderShow.value = false;
             uni.navigateTo({
                 url: '/pages/workOrder/detail?id=' + takeItem.sa_workorderid,
                 success: (result) => {
                     uni.showToast({
-                        title: '单成功',
+                        title: '单成功',
                         icon: 'none'
                     });
                 },
@@ -121,6 +124,37 @@ function takeOrders() {
             });
         }
     })
+
+    const handleTakeOrder = () => {
+        $Http.basic({
+            id: 20230210101103,
+            "content": {
+                "sa_workorderid": takeItem.sa_workorderid
+            }
+        }).then(res => {
+            console.log("接单结果", res)
+            if (res.code == 1) {
+                takeOrderShow.value = false;
+                uni.navigateTo({
+                    url: '/pages/workOrder/detail?id=' + takeItem.sa_workorderid,
+                    success: (result) => {
+                        uni.showToast({
+                            title: '接单成功',
+                            icon: 'none'
+                        });
+                    },
+                })
+                $Http.updateList(content, getList)
+            } else {
+                if (res.msg) uni.showToast({
+                    title: res.msg,
+                    icon: 'none'
+                });
+            }
+        })
+    }
+
+
 }
 
 </script>

+ 2 - 2
pages/workOrder/work.vue

@@ -490,8 +490,8 @@ function clickRadio(value, key) {
         } else {
             delete rules.newtitems;
         }
-        if (form[key] == '1' && !data.oldtitems.length) toAddItem('newtitems');
-        form.oldtitems = data.oldtitems.length ? '1' : '';
+        if (form[key] == '1' && !(data.oldtitems.length + data.newtitems.length)) toAddItem('newtitems');
+        form.newtitems = data.newtitems.length ? '1' : '';
         uFormRef.value.setRules(rules);
     }
     console.log("form", form)