问题修改
This commit is contained in:
		
							parent
							
								
									a021fbbc0f
								
							
						
					
					
						commit
						030aa30b97
					
				| 
						 | 
					@ -119,6 +119,7 @@
 | 
				
			||||||
<script>
 | 
					<script>
 | 
				
			||||||
import ImageUtils from "../../services/utils/imageUtils";
 | 
					import ImageUtils from "../../services/utils/imageUtils";
 | 
				
			||||||
import {decryptWithSM4} from "../../utils/sm";
 | 
					import {decryptWithSM4} from "../../utils/sm";
 | 
				
			||||||
 | 
					import {getDeviceListAPI} from "../../services/picking/outbound";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export default {
 | 
					export default {
 | 
				
			||||||
  data() {
 | 
					  data() {
 | 
				
			||||||
| 
						 | 
					@ -525,7 +526,6 @@ export default {
 | 
				
			||||||
            console.log("resData.data.result",resData.data.result)
 | 
					            console.log("resData.data.result",resData.data.result)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (resData.code===0){
 | 
					            if (resData.code===0){
 | 
				
			||||||
              console.log(111111)
 | 
					 | 
				
			||||||
              if (resData.data.result) {
 | 
					              if (resData.data.result) {
 | 
				
			||||||
                this.queryCodeParams.maCode = resData.data.result
 | 
					                this.queryCodeParams.maCode = resData.data.result
 | 
				
			||||||
                await this.closeCamera();
 | 
					                await this.closeCamera();
 | 
				
			||||||
| 
						 | 
					@ -554,55 +554,6 @@ export default {
 | 
				
			||||||
            })
 | 
					            })
 | 
				
			||||||
          },
 | 
					          },
 | 
				
			||||||
        })
 | 
					        })
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // const response = await new Promise((resolve, reject)=>
 | 
					 | 
				
			||||||
        //         {
 | 
					 | 
				
			||||||
        //           uni.request({
 | 
					 | 
				
			||||||
        //             url: '/material/app/ocr/getOcrCode',
 | 
					 | 
				
			||||||
        //             method: 'POST',
 | 
					 | 
				
			||||||
        //             data: {
 | 
					 | 
				
			||||||
        //               image: cleanBase64,
 | 
					 | 
				
			||||||
        //               jiju_type: '',
 | 
					 | 
				
			||||||
        //               auth_lic: 'xIWDlaDVdijcBB4mjhGCPYk5Kvk8tHZJbUn+vW+ih15+MYx98e/PXyBmKL5gFcWMPznLgDA15QuSAnZQSLddwdy9HkZgtuQDEEZZ351Eyb1eiDUccUnyoSGIrNimbx5TooBNNPYqU4qJeFrPJXAqjBHzRrxoBxuR2CEGKQPgHC4='
 | 
					 | 
				
			||||||
        //             },
 | 
					 | 
				
			||||||
        //             header: {
 | 
					 | 
				
			||||||
        //               "Content-Type": "application/json;charset=UTF-8"
 | 
					 | 
				
			||||||
        //             },
 | 
					 | 
				
			||||||
        //             timeout: 30000,
 | 
					 | 
				
			||||||
        //             success: resolve,
 | 
					 | 
				
			||||||
        //             fail: reject
 | 
					 | 
				
			||||||
        //           });
 | 
					 | 
				
			||||||
        //         }
 | 
					 | 
				
			||||||
        //     );
 | 
					 | 
				
			||||||
        // console.log("response",response);
 | 
					 | 
				
			||||||
        // console.log("response.data",response.data);
 | 
					 | 
				
			||||||
        //
 | 
					 | 
				
			||||||
        // // 建议的解析逻辑
 | 
					 | 
				
			||||||
        // if (response.data?.code === 0) {
 | 
					 | 
				
			||||||
        //   const ocrData = response.data.data;
 | 
					 | 
				
			||||||
        //   if (ocrData?.result) {
 | 
					 | 
				
			||||||
        //     this.queryCodeParams.maCode = ocrData.result;
 | 
					 | 
				
			||||||
        //     await this.closeCamera();
 | 
					 | 
				
			||||||
        //     this.getCode();
 | 
					 | 
				
			||||||
        //     uni.showToast({
 | 
					 | 
				
			||||||
        //       title: '识别成功',
 | 
					 | 
				
			||||||
        //       icon: 'success'
 | 
					 | 
				
			||||||
        //     });
 | 
					 | 
				
			||||||
        //   } else {
 | 
					 | 
				
			||||||
        //     uni.showToast({
 | 
					 | 
				
			||||||
        //       title: '未识别到有效编码',
 | 
					 | 
				
			||||||
        //       icon: 'none'
 | 
					 | 
				
			||||||
        //     });
 | 
					 | 
				
			||||||
        //   }
 | 
					 | 
				
			||||||
        // } else {
 | 
					 | 
				
			||||||
        //   // 处理HTTP或业务错误
 | 
					 | 
				
			||||||
        //   const errorMsg = response.data?.msg || 'OCR识别失败';
 | 
					 | 
				
			||||||
        //   uni.showToast({
 | 
					 | 
				
			||||||
        //     title: errorMsg,
 | 
					 | 
				
			||||||
        //     icon: 'none'
 | 
					 | 
				
			||||||
        //   });
 | 
					 | 
				
			||||||
        // }
 | 
					 | 
				
			||||||
      } catch (error) {
 | 
					      } catch (error) {
 | 
				
			||||||
        console.error('图片处理或OCR识别失败:', error);
 | 
					        console.error('图片处理或OCR识别失败:', error);
 | 
				
			||||||
        uni.showToast({
 | 
					        uni.showToast({
 | 
				
			||||||
| 
						 | 
					@ -682,10 +633,8 @@ export default {
 | 
				
			||||||
        //   quality: 50,
 | 
					        //   quality: 50,
 | 
				
			||||||
        //   outputFormat: 'base64'
 | 
					        //   outputFormat: 'base64'
 | 
				
			||||||
        // });
 | 
					        // });
 | 
				
			||||||
 | 
					 | 
				
			||||||
        console.log('相册图片处理完成,开始OCR识别...');
 | 
					        console.log('相册图片处理完成,开始OCR识别...');
 | 
				
			||||||
        const response = await new Promise((resolve, reject)=>
 | 
					
 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
        uni.request({
 | 
					        uni.request({
 | 
				
			||||||
          url: '/material/app/ocr/getOcrCode',
 | 
					          url: '/material/app/ocr/getOcrCode',
 | 
				
			||||||
          method: 'POST',
 | 
					          method: 'POST',
 | 
				
			||||||
| 
						 | 
					@ -694,27 +643,52 @@ export default {
 | 
				
			||||||
            jiju_type: '',
 | 
					            jiju_type: '',
 | 
				
			||||||
            auth_lic: 'xIWDlaDVdijcBB4mjhGCPYk5Kvk8tHZJbUn+vW+ih15+MYx98e/PXyBmKL5gFcWMPznLgDA15QuSAnZQSLddwdy9HkZgtuQDEEZZ351Eyb1eiDUccUnyoSGIrNimbx5TooBNNPYqU4qJeFrPJXAqjBHzRrxoBxuR2CEGKQPgHC4='
 | 
					            auth_lic: 'xIWDlaDVdijcBB4mjhGCPYk5Kvk8tHZJbUn+vW+ih15+MYx98e/PXyBmKL5gFcWMPznLgDA15QuSAnZQSLddwdy9HkZgtuQDEEZZ351Eyb1eiDUccUnyoSGIrNimbx5TooBNNPYqU4qJeFrPJXAqjBHzRrxoBxuR2CEGKQPgHC4='
 | 
				
			||||||
          },
 | 
					          },
 | 
				
			||||||
                    timeout: 30000,
 | 
					          header: {
 | 
				
			||||||
                    success: resolve,
 | 
					            "Content-Type": "application/json;charset=UTF-8"
 | 
				
			||||||
                    fail: reject
 | 
					          },
 | 
				
			||||||
                  });
 | 
					          success: async (res) => {
 | 
				
			||||||
 | 
					            if (!res.data.code){
 | 
				
			||||||
 | 
					              res=JSON.parse(decryptWithSM4(res.data))
 | 
				
			||||||
 | 
					            } else {
 | 
				
			||||||
 | 
					              res =res.data
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            );
 | 
					            console.log("res", res);
 | 
				
			||||||
        console.log("response",response.data);
 | 
					            console.log("res.data",res.data)
 | 
				
			||||||
        if (response.data?.data?.result) {
 | 
					            const {data: resData} = res
 | 
				
			||||||
          this.queryCodeParams.maCode = response.data.data.result;
 | 
					            console.log("resData",resData)
 | 
				
			||||||
 | 
					            console.log("resData.data",resData.data)
 | 
				
			||||||
 | 
					            console.log("resData.code",resData.code)
 | 
				
			||||||
 | 
					            console.log("resData.data.result",resData.data.result)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (resData.code===0){
 | 
				
			||||||
 | 
					              if (resData.data.result) {
 | 
				
			||||||
 | 
					                this.queryCodeParams.maCode = resData.data.result
 | 
				
			||||||
                await this.closeCamera();
 | 
					                await this.closeCamera();
 | 
				
			||||||
          this.getCode();
 | 
					                await this.getCode();
 | 
				
			||||||
          uni.showToast({
 | 
					                await uni.showToast({
 | 
				
			||||||
                  title: '识别成功',
 | 
					                  title: '识别成功',
 | 
				
			||||||
                  icon: 'success'
 | 
					                  icon: 'success'
 | 
				
			||||||
                });
 | 
					                });
 | 
				
			||||||
              } else {
 | 
					              } else {
 | 
				
			||||||
                uni.showToast({
 | 
					                uni.showToast({
 | 
				
			||||||
            title: '未识别到有效编码',
 | 
					                  title: '识别失败!' + resData.data.msg,
 | 
				
			||||||
            icon: 'none'
 | 
					                  icon: 'none',
 | 
				
			||||||
          });
 | 
					                })
 | 
				
			||||||
              }
 | 
					              }
 | 
				
			||||||
 | 
					            } else {
 | 
				
			||||||
 | 
					              uni.showToast({
 | 
				
			||||||
 | 
					                title: '识别失败!',
 | 
				
			||||||
 | 
					                icon: 'none',
 | 
				
			||||||
 | 
					              })
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					          },
 | 
				
			||||||
 | 
					          fail: (err) => {
 | 
				
			||||||
 | 
					            uni.showToast({
 | 
				
			||||||
 | 
					              title: '请求失败:' + err.errMsg,
 | 
				
			||||||
 | 
					              icon: 'none',
 | 
				
			||||||
 | 
					            })
 | 
				
			||||||
 | 
					          },
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
      } catch (error) {
 | 
					      } catch (error) {
 | 
				
			||||||
        console.error('相册图片处理或OCR识别失败:', error);
 | 
					        console.error('相册图片处理或OCR识别失败:', error);
 | 
				
			||||||
        uni.showToast({
 | 
					        uni.showToast({
 | 
				
			||||||
| 
						 | 
					@ -736,20 +710,9 @@ export default {
 | 
				
			||||||
        return;
 | 
					        return;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      try {
 | 
					      try {
 | 
				
			||||||
        const response = await new Promise((resolve, reject)=>
 | 
					        getDeviceListAPI({'maCode': this.queryCodeParams.maCode}).then(response => {
 | 
				
			||||||
                {
 | 
					          console.log("xxxxxxxxxxx",response)
 | 
				
			||||||
                  uni.request({
 | 
					          if (response.data && response.data.length !== 0) {
 | 
				
			||||||
                    url: '/material/ma_machine/getHisByCode',
 | 
					 | 
				
			||||||
                    method: 'GET',
 | 
					 | 
				
			||||||
                    data: {maCode: this.queryCodeParams.maCode},
 | 
					 | 
				
			||||||
                    success: resolve,
 | 
					 | 
				
			||||||
                    fail: reject
 | 
					 | 
				
			||||||
                  });
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
            )
 | 
					 | 
				
			||||||
        ;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        if (response.data?.data && response.data.data.length > 0) {
 | 
					 | 
				
			||||||
            this.optionList = response.data.data.map(option => ({
 | 
					            this.optionList = response.data.data.map(option => ({
 | 
				
			||||||
              value: option.maId,
 | 
					              value: option.maId,
 | 
				
			||||||
              text: option.maCode
 | 
					              text: option.maCode
 | 
				
			||||||
| 
						 | 
					@ -757,12 +720,51 @@ export default {
 | 
				
			||||||
            if (response.data.data.length === 1) {
 | 
					            if (response.data.data.length === 1) {
 | 
				
			||||||
              this.codeData = response.data.data[0];
 | 
					              this.codeData = response.data.data[0];
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        } else {
 | 
					          }else{
 | 
				
			||||||
            uni.showToast({
 | 
					            uni.showToast({
 | 
				
			||||||
              title: '未查询到该编号信息',
 | 
					              title: '未查询到该编号信息',
 | 
				
			||||||
            icon: 'none'
 | 
					              icon: 'none',
 | 
				
			||||||
          });
 | 
					              duration: 2000
 | 
				
			||||||
 | 
					            })
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
 | 
					        }).catch(error => {
 | 
				
			||||||
 | 
					          console.error("获取设备信息失败", error)
 | 
				
			||||||
 | 
					          uni.hideLoading()
 | 
				
			||||||
 | 
					        })
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // const response = await new Promise((resolve, reject)=>
 | 
				
			||||||
 | 
					        //         {
 | 
				
			||||||
 | 
					        //           uni.request({
 | 
				
			||||||
 | 
					        //             url: '/material/ma_machine/getHisByCode',
 | 
				
			||||||
 | 
					        //             method: 'GET',
 | 
				
			||||||
 | 
					        //             data: {maCode: this.queryCodeParams.maCode},
 | 
				
			||||||
 | 
					        //             success: resolve,
 | 
				
			||||||
 | 
					        //             fail: reject
 | 
				
			||||||
 | 
					        //           });
 | 
				
			||||||
 | 
					        //         }
 | 
				
			||||||
 | 
					        //     )
 | 
				
			||||||
 | 
					        // ;
 | 
				
			||||||
 | 
					        // let res;
 | 
				
			||||||
 | 
					        // if (!response.data.code) {
 | 
				
			||||||
 | 
					        //   res=JSON.parse(decryptWithSM4(res.data))
 | 
				
			||||||
 | 
					        // } else {
 | 
				
			||||||
 | 
					        //   res =res.data
 | 
				
			||||||
 | 
					        // }
 | 
				
			||||||
 | 
					        // console.log("res", res);
 | 
				
			||||||
 | 
					        // if (response.data?.data && response.data.data.length > 0) {
 | 
				
			||||||
 | 
					        //   this.optionList = response.data.data.map(option => ({
 | 
				
			||||||
 | 
					        //     value: option.maId,
 | 
				
			||||||
 | 
					        //     text: option.maCode
 | 
				
			||||||
 | 
					        //   }));
 | 
				
			||||||
 | 
					        //   if (response.data.data.length === 1) {
 | 
				
			||||||
 | 
					        //     this.codeData = response.data.data[0];
 | 
				
			||||||
 | 
					        //   }
 | 
				
			||||||
 | 
					        // } else {
 | 
				
			||||||
 | 
					        //   uni.showToast({
 | 
				
			||||||
 | 
					        //     title: '未查询到该编号信息',
 | 
				
			||||||
 | 
					        //     icon: 'none'
 | 
				
			||||||
 | 
					        //   });
 | 
				
			||||||
 | 
					        // }
 | 
				
			||||||
      } catch (error) {
 | 
					      } catch (error) {
 | 
				
			||||||
        console.error('查询失败:', error);
 | 
					        console.error('查询失败:', error);
 | 
				
			||||||
        uni.showToast({
 | 
					        uni.showToast({
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue