xiaohaizhao 2 ماه پیش
والد
کامیت
8d1b3ecb2d
6فایلهای تغییر یافته به همراه96 افزوده شده و 193 حذف شده
  1. 2 2
      App.vue
  2. 7 17
      pages/generalServices/detail.vue
  3. 1 1
      pages/launchApplication/index.vue
  4. 44 143
      pages/workOrder/changeMsg.vue
  5. 32 27
      pages/workOrder/detail.vue
  6. 10 3
      utils/Http.js

+ 2 - 2
App.vue

@@ -2,7 +2,7 @@
 import { ref, getCurrentInstance } from 'vue'
 export default {
 	onLaunch: function () {
-		if (process.env.NODE_ENV === 'development') {
+		/* if (process.env.NODE_ENV === 'development') {
 		} else {
 			const { $Http } = getCurrentInstance().proxy;
 			if (uni.getStorageSync('userMsg').token) {
@@ -29,7 +29,7 @@ export default {
 					}
 				})
 			}
-		}
+		} */
 	},
 	onShow: function () {
 		try {

+ 7 - 17
pages/generalServices/detail.vue

@@ -87,23 +87,6 @@
                 <view class="label">产品型号</view>
                 <view class="value">{{ detail.model || '--' }}</view>
             </view>
-            <view class="row" v-if="detail.name || detail.phonenumber" style="align-items: center;">
-                <view class="label justify">客户信息</view>
-                <view class="value phonenumber">{{ detail.name || '' }}
-                    <block v-if="detail.phonenumber">
-                        <text style="margin: 0 20rpx 0 10rpx;">
-                            {{ detail.phonenumber }}
-                        </text>
-                        <My-button :customStyle="{
-                            width: '142rpx',
-                            height: '48rpx',
-                            'background-color': '#FFFFFF',
-                            'color': '#3874F6',
-                            borderRadius: '10rpx'
-                        }" frontIcon="icon-bodadianhua1" text="电话" :phonenumber="detail.phonenumber" />
-                    </block>
-                </view>
-            </view>
             <view class="row" v-if="detail.servicetype !== '安装' && detail.cardno">
                 <view class="label">保修信息</view>
                 <view class="value">
@@ -218,6 +201,12 @@ function getDetail() {
     $Http.basic({ "id": "20230206091603", "content": { "nocache": true, sa_serviceorderid } }).then(res => {
         console.log("服务申请单详情", res)
         if (res.code !== 1) return uni.showToast({ title: res.msg, icon: 'none' });
+
+        try {
+            res.data.inqualityguaranteeperiod = new Date() >= new Date(res.data.cardbegdate) && new Date() <= new Date(res.data.cardenddate);
+        } catch (error) {
+
+        }
         detail = reactive(res.data);
         time.value = new Date().getTime();
         console.log("detail", detail)
@@ -231,6 +220,7 @@ function getDetail() {
             }
             return v
         })
+
         $Http.basic({ "id": 20230207154203, "content": { "sa_serviceorderid": sa_serviceorderid, pageSize: 1 } }).then(res => {
             console.log("服务申请单工单列表", res)
             if (res.code !== 1) return uni.showToast({ title: res.msg, icon: 'none' });

+ 1 - 1
pages/launchApplication/index.vue

@@ -287,7 +287,6 @@ function skuConfirm() {
                 return;
             }
             changeItem(res.data[0]);
-            uni.showToast({ title: '已自动写入客户信息', icon: 'none' });
         })
     } else {
         form.sku = '';
@@ -303,6 +302,7 @@ function changeItem(item) {
     list.forEach(key => {
         form[key] = item[key] || '';
     });
+    console.log("选择产品", form);
     closePopup();
 }
 

+ 44 - 143
pages/workOrder/changeMsg.vue

@@ -1,5 +1,5 @@
 <template>
-    <view class="content"><!-- labelAlign="right" -->
+    <view class="content">
         <up-form :model="form" labelWidth="70" ref="uFormRef">
             <view class="title" style="margin-top: 0;">
                 服务信息
@@ -21,15 +21,6 @@
                 </up-radio-group>
             </up-form-item>
 
-            <!--      <up-form-item v-if="rules.class2[0].required" label="故障类型" :required="rules.class2[0].required"
-                prop="class2">
-                <up-radio-group v-model="form.class2">
-                    <up-radio :customStyle="{ marginLeft: '12px' }" v-for="(item) in class2" :key="item.value"
-                        :label="item.value" :name="item.value">
-                    </up-radio>
-                </up-radio-group>
-            </up-form-item> -->
-
             <up-form-item label="服务地址" :required="rules.province[0].required" prop="province">
                 <picker class="picker" mode="region" :value="[form.province, form.city, form.county]"
                     @change="changeRegion">
@@ -64,7 +55,7 @@
                 产品信息
             </view>
             <up-form-item label="序列号" :required="rules.sku[0].required" prop="sku">
-                <up-input v-model="form.sku" placeholder="序列号" clearable @blur="skuConfirm">
+                <up-input v-model="sku" placeholder="序列号" clearable @blur="skuConfirm">
                     <template #suffix>
                         <up-icon name="scan" color="#2979ff" size="28" @click="openScan" />
                     </template>
@@ -77,7 +68,7 @@
             <up-form-item label="产品型号" prop="model">
                 <up-input v-model="form.model" disabled placeholder="型号" />
             </up-form-item>
-            <up-form-item label="保修卡号" prop="cardno">
+            <up-form-item v-if="form.servicetype != '安装'" label="保修卡号" prop="cardno">
                 <up-input v-model="form.cardno" disabled placeholder="保修卡号" />
             </up-form-item>
         </up-form>
@@ -85,35 +76,6 @@
             <My-button text="保存" :loading="loading" />
         </view>
     </view>
-
-    <up-popup :show="products.length" @close="closePopup" :customStyle="{
-        width: '80vw',
-    }" mode="right">
-        <scroll-view :safeAreaInsetBottom="false" scroll-y style="width: 100%;height: 100vh;">
-            <view class="product" v-for="item in products" :key="item.itemid" hover-class="navigator-hover"
-                @click="changeItem(item)">
-                <view class="itemname">
-                    {{ item.itemname }}
-                </view>
-                <view class="row">
-                    序列号: {{ item.sku || '--' }}
-                </view>
-                <view class="row">
-                    产品编号: {{ item.itemno || '--' }}
-                </view>
-                <view class="row">
-                    产品型号: {{ item.model || '--' }}
-                </view>
-                <view class="row">
-                    经销商: {{ item.enterprisename || '--' }}
-                </view>
-                <view class="row">
-                    用户信息: {{ item.name || '--' }} {{ item.phonenumber || '--' }}
-                </view>
-            </view>
-            <view style="height: 30px;" />
-        </scroll-view>
-    </up-popup>
 </template>
 
 <script setup>
@@ -122,6 +84,7 @@ const { $Http } = getCurrentInstance().proxy;
 import { onLoad } from '@dcloudio/uni-app';
 
 const uFormRef = ref(null);
+const sku = ref('');
 const form = reactive({
     class1: '', // 产品品类
     class2: '', // 故障类型
@@ -152,7 +115,7 @@ const rules = reactive({
     province: [{ required: true, message: '请选择省市县', trigger: 'change' }],
     address: [{ required: true, message: '请输入详细地址', trigger: 'blur' }],
     scenecontact: [{ required: true, message: '请输入联系人', trigger: 'blur' }],
-    sku: [{ required: false, message: '请输入序列号', trigger: 'blur' }],
+    sku: [{ required: false, message: '请输入序列号', trigger: 'change' }],
     scenecontactphonenumber: [{ required: true, message: '请输入联系人电话', trigger: 'blur', pattern: /^1(3[0-9]|4[01456879]|5[0-35-9]|6[2567]|7[0-8]|8[0-9]|9[0-35-9])\d{8}$/, message: '请输入正确的手机号码' }],
 });
 
@@ -191,7 +154,6 @@ let detail = reactive({});
 let loading = ref(false);
 
 function save() {
-    if (querySku.value === false) return uni.showToast({ title: '序列号不正确', icon: 'none' });
     if (loading.value) return;
     uFormRef.value.validate().then(valid => {
         if (valid) {
@@ -213,6 +175,9 @@ function save() {
                 loading.value = false;
                 console.log("保存工单", res);
                 uni.showToast({ title: res.code !== 1 ? res.msg : "保存成功", icon: 'none', mask: res.code == 1 });
+                let workorderids = uni.getStorageSync('workorderids') || [];
+                workorderids.push(sa_workorderid);
+                uni.setStorageSync('workorderids', workorderids);
                 if (res.code == 1) setTimeout(() => {
                     uni.navigateBack();
                 }, 500);
@@ -233,6 +198,7 @@ function getDetail() {
         rules.class2[0].required = detail.type == '维修';
         if (detail.type == '安装') {
             servertypes.value = ['安装'];
+            rules.sku[0].required = true
         } else {
             $Http.getClass('servertype').then(res1 => {
                 servertypes.value = res1.data.map(v => v.value).filter(v => v != '安装')
@@ -243,8 +209,20 @@ function getDetail() {
             for (const key in form) {
                 if (detail[key] !== undefined) {
                     form[key] = detail[key];
+                    if (key == 'sku') {
+                        sku.value = detail[key];
+                    }
                 }
             }
+        if (detail.type == '安装') {
+            let id = detail.sa_workorderid,
+                workorderids = uni.getStorageSync('workorderids') || [];
+            let hasId = workorderids.findIndex(item => item == id);
+            if (hasId == -1) {
+                form.sku = '';
+                sku.value = '';
+            }
+        }
         disabled.value = detail.item ? true : false
     })
 }
@@ -255,110 +233,47 @@ function changeRegion(e) {
     form.county = e.detail.value[2];
 }
 
-let querySku = ref(true); // SKU是否正确
-
 function skuConfirm() {
-    if (form.sku) {
-        ['enterprisename', "customername", 'customerphonenumber', 'sa_customersid', 'cardno', 'itemid', 'itemname', 'itemno', 'model', 'phonenumber', 'unitname', 'spec'].forEach(key => {
-            form[key] = '';
-        });
-        if (form.sku.length < 3) {
-            querySku.value = false;
-            return uni.showToast({ title: '请输入正确的序列号', icon: 'none' });
-        }
-        uni.showLoading({ title: '查询中...' });
+    if (sku.value) {
+        if (sku.value == '') return;
         $Http.basic({
-            "id": 2025080813465203,
+            "id": 20221215101003,
             "content": {
-                "pageNumber": 1,
-                "pageSize": 1,
                 "where": {
-                    sku: form.sku,
+                    "sku": sku.value.trim()
                 }
             }
         }).then(res => {
-            console.log(res)
+            console.log("查询sku", res)
             uni.hideLoading();
-            if (res.code !== 1) return uni.showToast({ title: res.msg, icon: 'none' });
-            if (res.data.length === 0 || res.data[0].sku !== form.sku) {
-                uni.showToast({ title: '未找到对应的产品信息', icon: 'none' });
-                querySku.value = false;
+            if (res.code !== 1) {
+                uni.showToast({ title: res.msg, icon: 'none' })
+                form.sku = '';
+                sku.value = '';
+                return
+            };
+            if (res.data.length === 0 || res.data[0].sku !== sku.value.trim()) {
+                uni.showToast({ title: '未查询到对应的产品信息,请确认序列号是否正确', icon: 'none' });
+                form.sku = '';
+                sku.value = '';
                 return;
             }
-            querySku.value = true;
-            res.data[0].customername = res.data[0].customername || res.data[0].name;
-            res.data[0].customerphonenumber = res.data[0].customerphonenumber || res.data[0].phonenumber;
-            res.data[0].enterprisename = res.data[0].enterprisename || res.data[0].enterprisename;
-            ["customername", 'customerphonenumber', 'sa_customersid', 'phonenumber', 'enterprisename', 'cardno', 'itemid', 'itemname', 'itemno', 'model', 'unitname', 'spec'].forEach(key => {
-                form[key] = res.data[0][key] || '';
-            });
-            uni.showToast({ title: '已将产品信息写入', icon: 'none' });
+            changeItem(res.data[0]);
         })
     } else {
         form.sku = '';
+        sku.value = '';
     }
 }
 
-let products = ref([]); // 产品列表
-function closePopup() {
-    products.value = [];
-}
 function changeItem(item) {
-    item.customername = item.customername || item.name;
-    item.customerphonenumber = item.customerphonenumber || item.phonenumber;
-
-    if (item.itemid == detail.itemid) {
-        handle();
-    } else {
-        uni.showModal({
-            title: '提示',
-            content: `当前选择的产品与工单中的产品不一致,是否继续?`,
-            success: function ({ confirm }) {
-                if (confirm) handle()
-            }
-        });
-    }
-
-    function handle() {
-        item.enterprisename = item.enterprisename || item.enterprisename;
-        ['enterprisename', "customername", 'customerphonenumber', 'sa_customersid', 'sku', 'cardno', 'itemid', 'itemname', 'itemno', 'model', 'phonenumber', 'unitname', 'spec'].forEach(key => {
-            form[key] = item[key] || '';
-        });
-        uni.showToast({ title: '已将产品信息写入', icon: 'none' });
-        querySku.value = true;
-        closePopup();
-    }
-}
-
-function phonenumberConfirm() {
-    // 校验手机号
-    const phoneRegex = /^1(3[0-9]|4[01456879]|5[0-35-9]|6[2567]|7[0-8]|8[0-9]|9[0-35-9])\d{8}$/;
-    if (!phoneRegex.test(form.customerphonenumber)) {
-        return uni.showToast({ title: '请输入正确的手机号', icon: 'none' });
-    }
-    uni.showLoading({ title: '查询中...' });
-    $Http.basic({
-        "id": 2025080813465203,
-        "content": {
-            "pageNumber": 1,
-            "pageSize": 50,
-            "where": {
-                phonenumber: form.customerphonenumber,
-            }
-        }
-    }).then(res => {
-        uni.hideLoading();
-        console.log("根据用户手机查询", res)
-        if (res.code !== 1) return uni.showToast({ title: res.msg, icon: 'none' });
-        if (res.data.length === 0) return uni.showToast({ title: '未找到对应的客户信息', icon: 'none' });
-        if (res.data.length == 1 && detail.itemid == res.data[0].itemid) {
-            changeItem(res.data[0]);
-        } else {
-            products.value = res.data;
-        }
-    })
+    let list = ['sku', 'cardno', 'itemid', 'itemname', 'itemno', 'sa_customersid'];
+    list.forEach(key => {
+        if (key == 'sku') sku.value = item[key] || '';
+        form[key] = item[key] || '';
+    });
+    uFormRef.value.clearValidate('sku');
 }
-
 function openScan() {
     uni.scanCode({
         onlyFromCamera: true,
@@ -378,20 +293,6 @@ function openScan() {
         }
     });
 }
-
-//去选择产品
-function toSelectProduct() {
-    uni.navigateTo({
-        url: '/pages/select/product'
-    });
-    $Http.onSelected = (item) => {
-        ['enterprisename', 'sku', 'cardno', 'itemid', 'itemname', 'itemno', 'model', 'phonenumber', 'unitname', 'spec'].forEach(key => {
-            form[key] = item[key] || '';
-        });
-        uni.navigateBack()
-        delete $Http.onSelected
-    }
-}
 </script>
 
 <style lang="scss" scoped>

+ 32 - 27
pages/workOrder/detail.vue

@@ -56,7 +56,7 @@
                 <view class="label">服务需求</view>
                 <view class="value">{{ detail.remarks || '--' }}</view>
             </view>
-            <up-transition :show="transition">
+            <up-transition :show="transition" v-if="detail.sku || detail.itemname">
                 <view class="transition">
                     <up-divider />
                     <view class="row" v-if="detail.sku">
@@ -67,15 +67,11 @@
                         <view class="label">产品品名</view>
                         <view class="value">{{ detail.itemname || '--' }}</view>
                     </view>
-                    <view class="row" v-if="detail.itemno">
-                        <view class="label">产品编号</view>
-                        <view class="value">{{ detail.itemno || '--' }}</view>
-                    </view>
                     <view class="row" v-if="detail.model">
                         <view class="label">产品型号</view>
                         <view class="value">{{ detail.model || '--' }}</view>
                     </view>
-                    <view class="row" v-if="detail.servicetype !== '安装' && detail.cardno">
+                    <view class="row" v-if="detail.cardno">
                         <view class="label">保修信息</view>
                         <view class="value">
                             <text :style="{ color: detail.inqualityguaranteeperiod ? '#70B603' : '#D9001B' }"
@@ -126,17 +122,17 @@
                         'color': '#3874F6',
                     }" text="信息修改" />
                 </view>
-                <view class="but-box-item" @click="!detail.sku ? toCMTips() : confirmStartShow = true">
+                <view class="but-box-item" @click="detail.servicetype == '安装' ? toCMTips() : confirmStartShow = true">
                     <My-button text="确认开始" />
-                    <up-modal negativeTop="100" cancelText="信息修改" confirmText="确认开始" :show="confirmStartShow"
+                    <up-modal negativeTop="100" title="提示" cancelText="信息修改" confirmText="确认开始" :show="confirmStartShow"
                         showCancelButton @confirm="confirmStart" @cancel="confirmCancel" ref="uModal"
                         :asyncClose="true">
                         <view class="slot-content">
                             <view>
-                                请仔细核对服务信息和客户信息
+                                请仔细<text style="color: red;">核对服务信息</text>以及<text style="color: red;">填写单程距离</text>
                             </view>
                             <view style="margin-top: 20rpx;">
-                                开始工单后确认信息将不可修改!
+                                开始工单后<text style="color: red;">信息不可修改!</text>
                             </view>
                         </view>
                     </up-modal>
@@ -199,7 +195,6 @@ onShow(() => {
 })
 
 let detail = reactive({
-    itemsText: [],
     servicetype: ""
 });
 
@@ -213,14 +208,6 @@ function getDetail() {
             sa_workorderid: res.data.sa_workorderid,
         }
         if (res.code !== 1) return uni.showToast({ title: res.msg, icon: 'none' });
-        try {
-            res.data.itemsText = res.data.titems.map(item => {
-                return `${item.itemname} ${item.model}`;
-            })
-        } catch (error) {
-
-        }
-
         try {
             res.data.inqualityguaranteeperiod = new Date() >= new Date(res.data.cardbegdate) && new Date() <= new Date(res.data.cardenddate);
         } catch (error) {
@@ -286,6 +273,10 @@ function submit() {
                         title: res.code == 1 ? '提交成功' : res.msg,
                         icon: 'none'
                     });
+                    let workorderids = uni.getStorageSync('workorderids') || [];
+                    // 把当前工单id从缓存中移除
+                    workorderids = workorderids.filter(item => item != detail.sa_workorderid);
+                    uni.setStorageSync('workorderids', workorderids);
                     if (res.code == 1) {
                         getDetail();
                         transition.value = true;
@@ -329,7 +320,7 @@ function snatchingOrders() {
         "id": "2025101710510903",
         "content": {
             "sa_workorderid": detail.sa_workorderid,
-            "projectlearders": [wx.getStorageSync('userMsg').userid],
+            "projectlearders": [uni.getStorageSync('userMsg').userid],
             ismanage: 0 // 用于避免多次抢单
         },
     }).then(res => {
@@ -346,13 +337,23 @@ function snatchingOrders() {
 }
 
 function toCMTips() {
-    uni.showModal({
-        confirmText: '前去修改',
-        content: '请完善产品信息和客户信息,确认开始后将不可修改!',
-        success: ({ confirm }) => {
-            if (confirm) toChangeMsg();
-        },
-    })
+    let id = detail.sa_workorderid,
+        workorderids = uni.getStorageSync('workorderids') || [];
+    let hasId = workorderids.findIndex(item => item == id);
+    if (hasId == -1) {
+        uni.showModal({
+            title: '提示',
+            confirmText: '信息确认',
+            content: '安装工单请务必确认服务信息和客户信息无误,且需正确录入产品序列号!',
+            success: ({ confirm }) => {
+                if (confirm) toChangeMsg();
+            },
+        })
+    }
+    else {
+        confirmStartShow.value = true
+    }
+
 }
 
 // 修改信息
@@ -380,6 +381,10 @@ function confirmStart() {
                 title: '确认开始成功',
                 icon: 'none'
             });
+            let workorderids = uni.getStorageSync('workorderids') || [];
+            // 把当前工单id从缓存中移除
+            workorderids = workorderids.filter(item => item != detail.sa_workorderid);
+            uni.setStorageSync('workorderids', workorderids);
         } else {
             if (res.msg) uni.showToast({
                 title: res.msg,

+ 10 - 3
utils/Http.js

@@ -44,7 +44,7 @@ class HTTP {
         }
 
         if (process.env.NODE_ENV === 'development') {
-            this.baseUrl = this.urls[0].url;
+            this.baseUrl = this.urls[1].url;
         } else {
             this.baseUrl = this.urls[0].url;
         }
@@ -140,7 +140,11 @@ class HTTP {
                 }
 
                 // 会话过期处理
-                if (res.data.msg === '登录凭证已过期,请重新登录!' || res.data.msg == '身份令牌无效,请重新登陆!') {
+                if (['登录凭证已过期,请重新登录!', '身份令牌无效,请重新登陆!', '登陆状态已过期,请重新登陆!'].includes(res.data.msg)) {
+                    // 防止重复弹出通知
+                    if (this.sessionExpiredNotified) return;
+                    this.sessionExpiredNotified = true;
+
                     // 清除过期会话ID
                     this.jsessionid = '';
                     uni.removeStorageSync('JSESSIONID');
@@ -152,11 +156,14 @@ class HTTP {
                             content: '您的登录状态已过期,请重新登录。',
                             showCancel: false,
                             success: () => {
+                                this.sessionExpiredNotified = false; // 重置通知状态
                                 uni.redirectTo({
                                     url: '/pages/login/login',
-                                })
+                                });
                             }
                         });
+                    } else {
+                        this.sessionExpiredNotified = false; // 重置通知状态
                     }
                 }
             }