xiaohaizhao 5 miesięcy temu
rodzic
commit
51ac7f8f67

+ 5 - 8
components/My_upload/My_upload.vue

@@ -113,8 +113,7 @@ const requestType = (file) => {
     // #endif
 
     return {
-        "classname": "system.attachment.huawei.OBS",
-        "method": "getFileName",
+        id: '10019701',
         "content": {
             "filename": `${Date.now() + file.size}.${ext}`,
             "filetype": ext,
@@ -176,8 +175,7 @@ const uploadFile = (res, data) => {
         header: { 'Content-Type': 'application/octet-stream' },
         success: () => {
             $Http.basic({
-                "classname": "system.attachment.huawei.OBS",
-                "method": "uploadSuccess",
+                id: 10019901,
                 "content": { "serialfilename": res.serialfilename }
             }).then(s => {
                 console.log("文件上传反馈", s)
@@ -212,11 +210,10 @@ function handleFileLink(list, ownertable = "temporary", ownerid = 1, usetype = '
             icon: "none"
         })
         list.forEach(v => {
-            const file = props.fileList.find(s => v.url === s.url);
-            delete file.status;
-            delete file.message;
-
+            const file = props.fileList.find(s => v.url === s.url || v.url === s.thumb);
             if (file) {
+                delete file.status;
+                delete file.message;
                 Object.assign(file, res.data.find(s => s.attachmentid === v.attachmentid));
             }
         });

+ 1 - 1
pages/index/home.vue

@@ -108,7 +108,7 @@ function uploadNumber() {
 	itemList.value.forEach((item) => {
 		if (item.label == '进行中') {
 			Promise.all(
-				['待开始', '进行中', '提交'].map(v =>
+				['待开始', '进行中', '提交'].map(v =>
 					$Http.basic({
 						"id": "20230208140203", "content":
 							{ "pageNumber": 1, "pageSize": 0, "nocache": true, "where": { "status": v, "condition": "" } }

+ 9 - 9
pages/workOrder/changeMsg.vue

@@ -75,8 +75,8 @@
                 <up-input v-model="form.model" disabled placeholder="型号" />
             </up-form-item>
 
-            <up-form-item label="经销商" prop="serviceenterprisename">
-                <up-textarea maxlength="499" v-model="form.serviceenterprisename" disabled placeholder="经销商" autoHeight
+            <up-form-item label="经销商" prop="enterprisename">
+                <up-textarea maxlength="499" v-model="form.enterprisename" disabled placeholder="经销商" autoHeight
                     height="20" />
             </up-form-item>
             <up-form-item label="客户名称" prop="customername">
@@ -154,7 +154,7 @@ const form = reactive({
     'model': "", // 型号
     'unitname': "", // 计量单位
     'spec': "", // 规格
-    serviceenterprisename: "", //  经销商
+    enterprisename: "", //  经销商
     cardno: "" // 保修卡号
 });
 const rules = reactive({
@@ -263,7 +263,7 @@ let querySku = ref(true); // SKU是否正确
 
 function skuConfirm() {
     if (form.sku) {
-        ['serviceenterprisename', "customername", 'customerphonenumber', 'sa_customersid', 'cardno', 'itemid', 'itemname', 'itemno', 'model', 'phonenumber', 'unitname', 'spec'].forEach(key => {
+        ['enterprisename', "customername", 'customerphonenumber', 'sa_customersid', 'cardno', 'itemid', 'itemname', 'itemno', 'model', 'phonenumber', 'unitname', 'spec'].forEach(key => {
             form[key] = '';
         });
         if (form.sku.length < 3) {
@@ -292,8 +292,8 @@ function skuConfirm() {
             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].serviceenterprisename = res.data[0].serviceenterprisename || res.data[0].enterprisename;
-            ["customername", 'customerphonenumber', 'sa_customersid', 'phonenumber', 'serviceenterprisename', 'cardno', 'itemid', 'itemname', 'itemno', 'model', 'unitname', 'spec'].forEach(key => {
+            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' });
@@ -324,8 +324,8 @@ function changeItem(item) {
     }
 
     function handle() {
-        item.serviceenterprisename = item.serviceenterprisename || item.enterprisename;
-        ['serviceenterprisename', "customername", 'customerphonenumber', 'sa_customersid', 'sku', 'cardno', 'itemid', 'itemname', 'itemno', 'model', 'phonenumber', 'unitname', 'spec'].forEach(key => {
+        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' });
@@ -389,7 +389,7 @@ function toSelectProduct() {
         url: '/pages/select/product'
     });
     $Http.onSelected = (item) => {
-        ['serviceenterprisename', 'sku', 'cardno', 'itemid', 'itemname', 'itemno', 'model', 'phonenumber', 'unitname', 'spec'].forEach(key => {
+        ['enterprisename', 'sku', 'cardno', 'itemid', 'itemname', 'itemno', 'model', 'phonenumber', 'unitname', 'spec'].forEach(key => {
             form[key] = item[key] || '';
         });
         uni.navigateBack()

+ 51 - 38
pages/workOrder/detail.vue

@@ -162,17 +162,20 @@
                 </view>
             </view>
         </view>
-
         <view class="main" v-if="current >= 2 && detail.nodes.length" style="padding: 30rpx;">
             <nodes ref="Nodes" :nodes="detail.nodes" />
+            <view v-if="detail.status == '提交' && detail.needcode"
+                style='width: 60%;margin: 40rpx auto 0;padding-bottom: 30rpx;' @click="openModal">
+                <My-button text="完工验证码" />
+            </view>
             <view v-if="detail.status == '进行中'" style='width: 60%;margin: 40rpx auto 0;padding-bottom: 30rpx;'
-                @click="submit"><My-button text="完工提交" />
+                @click="submit">
+                <My-button text="完工提交" />
             </view>
         </view>
-
     </view>
-
     <view style="height: 50px;" />
+    <VCode v-if="detail.needcode" :sa_workorderid="detail.sa_workorderid" ref="Code" @callBack="getDetail" />
 </template>
 
 <script setup>
@@ -180,6 +183,13 @@ import { ref, reactive, getCurrentInstance } from 'vue';
 const { $Http } = getCurrentInstance().proxy;
 import { onLoad, onShow, onUnload } from '@dcloudio/uni-app';
 import nodes from './modules/nodes.vue';
+import VCode from './modules/vCode.vue';
+
+// 验证码相关
+const Code = ref(null);
+function openModal() {
+    Code.value.openModal()
+}
 
 const transition = ref(true);
 const Nodes = ref(null);
@@ -237,8 +247,9 @@ function getDetail() {
     })
 }
 
-// 提交工单
-function submit() {
+
+// 工序是否完成
+function isAllNodesCompleted() {
     // 收集所有必填末级节点
     const requiredLeafNodes = [];
 
@@ -261,38 +272,40 @@ function submit() {
     findLeafNodes(detail.nodes);
     // 检查所有必填末级节点是否已完成
     const allCompleted = requiredLeafNodes.every(node => node.status === "1");
-    if (allCompleted) {
-        uni.showModal({
-            confirmText: '继续提交',
-            content: '请确认工单内容,提交后不可修改!',
-            success: ({ confirm }) => {
-                if (confirm) {
-                    $Http.basic({
-                        id: 2025072315401603,
-                        "content": {
-                            "sa_workorderid": detail.sa_workorderid
-                        }
-                    }).then(res => {
-                        console.log("提交结果", res)
-                        uni.showToast({
-                            title: res.code == 1 ? '提交成功' : res.msg,
-                            icon: 'none'
-                        });
-                        if (res.code == 1) {
-                            getDetail();
-                            transition.value = true;
-                        }
-                    })
-                }
-            },
-        })
-    } else {
-        uni.showModal({
-            confirmText: '关闭',
-            content: '还有工序未完成,不能提交!',
-            showCancel: false
-        })
-    }
+    if (!allCompleted) uni.showModal({
+        confirmText: '关闭',
+        content: '还有工序未完成,不能提交!',
+        showCancel: false
+    })
+    return allCompleted;
+}
+
+// 提交工单
+function submit() {
+    if (isAllNodesCompleted()) uni.showModal({
+        confirmText: '继续提交',
+        content: '请确认工单内容,提交后不可修改!',
+        success: ({ confirm }) => {
+            if (confirm) {
+                $Http.basic({
+                    id: 2025072315401603,
+                    "content": {
+                        "sa_workorderid": detail.sa_workorderid
+                    }
+                }).then(res => {
+                    console.log("提交结果", res)
+                    uni.showToast({
+                        title: res.code == 1 ? '提交成功' : res.msg,
+                        icon: 'none'
+                    });
+                    if (res.code == 1) {
+                        getDetail();
+                        transition.value = true;
+                    }
+                })
+            }
+        },
+    })
 }
 
 

+ 24 - 1
pages/workOrder/index.vue

@@ -43,7 +43,15 @@
                         height: '70rpx',
                     }" frontIcon="icon-jiedan" text="接单" />
                 </view>
-                <navigator v-else :url="'/pages/workOrder/detail?id=' + item.sa_workorderid" class="but-box-item">
+                <view v-if="content.where.status == '提交'" class="but-box-item" @click="sendCode(item)">
+                    <My-button :customStyle="{
+                        height: '70rpx',
+                    }" :disabled="!item.needcode" :text="item.needcode ? '完工确认码' : '等待完工确认'" />
+                    <VCode v-if="item.needcode" :ref="createRef('Code' + item.sa_workorderid)" @callBack="getList"
+                        :sa_workorderid="item.sa_workorderid" />
+                </view>
+                <navigator v-if="content.where.status != '待接单' && content.where.status != '提交'"
+                    :url="'/pages/workOrder/detail?id=' + item.sa_workorderid" class="but-box-item">
                     <My-button :customStyle="{
                         height: '70rpx',
                     }" frontIcon="icon-jiedan" text="报工" />
@@ -60,6 +68,21 @@
 import { ref, reactive, getCurrentInstance } from 'vue';
 const { $Http } = getCurrentInstance().proxy;
 import { onLoad, onShow } from '@dcloudio/uni-app';
+import VCode from './modules/vCode.vue';
+
+// 验证码相关
+let codes = {};
+
+function createRef(id) {
+    if (!codes[id]) codes[id] = ref(null);
+    return codes[id];
+}
+
+function sendCode(item) {
+    const vCodeRef = codes['Code' + item.sa_workorderid];
+    vCodeRef.value[0].openModal()
+}
+
 
 const listBox = ref(null);
 const content = reactive({

+ 140 - 0
pages/workOrder/modules/vCode.vue

@@ -0,0 +1,140 @@
+<template>
+    <up-modal :show="showModal" @cancel="showModal = false" @confirm="completion" ref="uModal" confirmText="确认完工"
+        showCancelButton :asyncClose="true">
+        <view class="slot-content">
+            <!-- #ifndef APP-NVUE -->
+            <up-input placeholder="完工验证码" v-model="code" :focus="downTime == 59">
+                <!-- #endif -->
+                <!-- #ifdef APP-NVUE -->
+                <up-input placeholder="完工验证码" v-model="code" :focus="downTime == 59">
+                    <!-- #endif -->
+                    <template #suffix>
+                        <up-button @tap="getCode" :disabled="downTime" :text="tips" type="success" size="mini">{{
+                            downTime +
+                            '秒重新获取' }}</up-button>
+                    </template>
+                    <!-- #ifndef APP-NVUE -->
+                </up-input>
+                <!-- #endif -->
+                <!-- #ifdef APP-NVUE -->
+            </up-input>
+            <!-- #endif -->
+        </view>
+    </up-modal>
+</template>
+
+<script setup>
+import { getCurrentInstance, ref, defineProps, defineEmits } from 'vue';
+const emit = defineEmits(['callBack'])
+
+const { $Http } = getCurrentInstance().proxy;
+const props = defineProps({
+    sa_workorderid: {
+        type: [Number, String],
+    },
+    callBack: {
+        type: Function
+    }
+});
+
+let code = ref(''),
+    showModal = ref(false),
+    downTime = ref(''),
+    interval = null,
+    uModal = ref(null);
+
+function completion(e) {
+    if (code.value.trim() == '') {
+        uModal.value.loading = false;
+        return uni.showToast({
+            title: '请输入完工验证码',
+            icon: 'none'
+        });
+    }
+    $Http.basic({
+        "id": "20230215173203",
+        "content": {
+            "sa_workorderid": props.sa_workorderid,
+            "code": code.value
+        }
+    }).then(res1 => {
+        console.log("校验验证码", res1)
+        if (res1.code == 1) {
+            $Http.basic({
+                "id": "20230209144903",
+                "content": { "sa_workorderid": props.sa_workorderid }
+            }).then(res => {
+                console.log("完结工单", res)
+                if (res.code == 1) {
+                    setTimeout(() => {
+                        showModal.value = false;
+                        code.value = '';
+                        downTime.value = '';
+                        clearInterval(interval);
+                    }, 300)
+                    emit('callBack', true)
+                } else {
+                    uni.showToast({
+                        title: res.msg,
+                        icon: 'none'
+                    });
+                    uModal.value.loading = false;
+                }
+            })
+        } else {
+            uni.showToast({
+                title: res1.msg,
+                icon: 'none'
+            });
+            uModal.value.loading = false;
+        }
+    })
+}
+
+function openModal() {
+    if (downTime.value == '') {
+        getCode().then(res => {
+            if (res) showModal.value = true;
+        })
+    } else {
+        showModal.value = true;
+    }
+}
+
+// 获取完工验证码
+function getCode() {
+    if (downTime.value != '') return;
+    return new Promise((resolve) => {
+        $Http.basic({
+            id: 20230215173103,
+            "content": {
+                "sa_workorderid": props.sa_workorderid
+            }
+        }).then(res => {
+            console.log("获取验证码结果", res)
+            resolve(res.code == 1);
+            downTime.value = 60;
+            if (res.code == 1) {
+                interval = setInterval(() => {
+                    downTime.value--;
+                    if (downTime.value <= 0) {
+                        clearInterval(interval);
+                        downTime.value = '';
+                    }
+                }, 1000);
+            } else {
+                downTime.value = '';
+                uni.showToast({
+                    title: res.msg,
+                    icon: 'none'
+                });
+            }
+        })
+    })
+}
+
+// 将内部方法暴露给模板使用
+defineExpose({
+    openModal
+});
+</script>

+ 13 - 2
utils/Http.js

@@ -23,15 +23,26 @@ class HTTP {
 
         //得到缩略图或者压缩图  getType默认得到缩略图传true得到压缩图
         this.getSpecifiedImage = (obj, getType = false) => {
+            obj.url = this.getImageUrl(obj.url)
             try {
                 let type = getType ? 'compressed' : 'thumbnail';
                 let imgObj = obj.subfiles.find(v => v.type == type);
-                return imgObj.url || obj.url;
+                return this.getImageUrl(imgObj.url || obj.url);
             } catch (error) {
-                return obj.url;
+                return this.getImageUrl(obj.url);
             }
         }
 
+        // 判断图片是本地还是云存储
+        this.getImageUrl = (url) => {
+            if (!url) return '';
+            //判断url中是否存在http,没有的话要拼接 this.baseUrl
+            if (!/^https?:\/\//.test(url)) {
+                url = this.baseUrl + url
+            }
+            return url;
+        }
+
         if (process.env.NODE_ENV === 'development') {
             this.baseUrl = this.urls[0].url;
         } else {