Explorar o código

Merge branch 'feature_20240912_CR多个调色机设备同时扫码'

# Conflicts:
#	src/views/deviceWithin/addStoreVisit.vue
zhujindu hai 1 ano
pai
achega
f2b2940d2b

+ 28 - 24
src/components/storeCode.vue

@@ -9,11 +9,11 @@
 </template>
 
 <script>
-import axios from "axios";
-import { getOptionByResult } from "@/api/index";
+import axios from 'axios';
+import { getOptionByResult } from '@/api/index';
 
 export default {
-  name: "uploadImg",
+  name: 'storeCode',
   props: {
     index: {
       type: Number,
@@ -21,7 +21,7 @@ export default {
     },
     tid: {
       type: String,
-      default: "",
+      default: '',
     },
     cid: {
       type: Number,
@@ -29,35 +29,35 @@ export default {
     },
     code: {
       type: String,
-      default: "",
+      default: '',
     },
     index1: {
       type: [String, Number],
-      default: "",
+      default: '',
     },
     index2: {
       type: [String, Number],
-      default: "",
+      default: '',
     },
     index3: {
       type: [String, Number],
-      default: "",
+      default: '',
     },
     index4: {
       type: [String, Number],
-      default: "",
+      default: '',
     },
     taskId: {
       type: String,
-      default: "",
+      default: '',
     },
     collectionId: {
       type: String,
-      default: "",
+      default: '',
     },
     type: {
       type: String,
-      default: "",
+      default: '',
     },
     insert: {
       type: Boolean,
@@ -67,7 +67,7 @@ export default {
   data() {
     return {
       shows: false,
-      url: "",
+      url: '',
     };
   },
   methods: {
@@ -76,11 +76,13 @@ export default {
       let that = this;
       let wx = this.wx;
       let qiyeData;
+      console.log(that.code);
+      debugger;
 
       const instance = axios.create();
-      instance.defaults.headers.common["userId"] = localStorage.getItem("loginName");
+      instance.defaults.headers.common['userId'] = localStorage.getItem('loginName');
       instance
-        .get(process.env.VUE_APP_BASE_API + "mobile/wx/ticket", {
+        .get(process.env.VUE_APP_BASE_API + 'mobile/wx/ticket', {
           params: {
             url: url,
           },
@@ -95,22 +97,24 @@ export default {
               timestamp: qiyeData.timestamp, // 必填,生成签名的时间戳
               nonceStr: qiyeData.nonceStr, // 必填,生成签名的随机串
               signature: qiyeData.signature, // 必填,签名,见 附录-JS-SDK使用权限签名算法
-              jsApiList: ["ready", "scanQRCode"],
+              jsApiList: ['ready', 'scanQRCode'],
             });
             wx.ready(function () {
               wx.scanQRCode({
-                desc: "scanQRCode desc",
+                desc: 'scanQRCode desc',
                 needResult: 1,
-                scanType: ["barCode"],
+                scanType: ['barCode'],
                 success: function (res) {
+                  console.log(res);
                   var result = res.resultStr;
+                  console.log(result);
                   var success = false;
-                  if (that.code == result && that.code != "" && that.code != null) {
+                  if (that.code == result && that.code != '' && that.code != null) {
                     success = true;
                   }
                   let loading1 = that.$toast.loading({
                     duration: 0,
-                    message: "数据加载中...",
+                    message: '数据加载中...',
                     forbidClick: true,
                   });
                   getOptionByResult({
@@ -120,13 +124,13 @@ export default {
                   }).then((response) => {
                     loading1.clear();
                     if (response.code == 200) {
-                      that.$emit("newcode", {
+                      that.$emit('newcode', {
                         cid: response.data.collectionId,
                         cpid: response.data.collectionOptionId,
                         nocpid: response.data.diffCollectionOptionId,
                         type: that.type,
                         index: that.index,
-                        code: that.code + "," + result,
+                        code: that.code + ',' + result,
                         success: success,
                         index1: that.index1,
                         index2: that.index2,
@@ -137,8 +141,8 @@ export default {
                   });
                 },
                 error: function (res) {
-                  if (res.errMsg.indexOf("function_not_exist") > 0) {
-                    alert("版本过低请升级");
+                  if (res.errMsg.indexOf('function_not_exist') > 0) {
+                    alert('版本过低请升级');
                   }
                 },
               });

+ 140 - 128
src/components/uploadVNormal.vue

@@ -1,78 +1,87 @@
 <template>
   <div class="questionNamep">
     <div class="cameraDiv" @click="uploadImg">
-      <van-icon class="photo photos" name="photograph" size="22px" color="#969696"/>
+      <van-icon class="photo photos" name="photograph" size="22px" color="#969696" />
     </div>
     <div id="allmap"></div>
   </div>
 </template>
 
 <script>
-import {addstorePhoto, addVisitsPosition} from "@/api/index";
+import { addstorePhoto, addVisitsPosition } from "@/api/index";
 import axios from "axios";
 
 export default {
-  name: 'uploadImg',
+  name: "uploadImg",
   props: {
     uploadid: {
       type: String,
-      default: ''
+      default: "",
     },
     storeGroupId: {
       type: String,
-      default: ''
+      default: "",
     },
     parentCollectionId: {
       type: String,
-      default: ''
+      default: "",
     },
     secondCollectionId: {
       type: String,
-      default: ''
-    }, firstCollectionId: {
+      default: "",
+    },
+    firstCollectionId: {
       type: String,
-      default: ''
+      default: "",
     },
     visitsId: {
       type: String,
-      default: ''
+      default: "",
     },
     taskId: {
       type: String,
-      default: ''
+      default: "",
     },
     collectionId: {
       type: String,
-      default: ''
+      default: "",
     },
     objectType: {
       type: String,
-      default: ''
+      default: "",
     },
     type: {
       type: Number,
-      default: 1
+      default: 1,
     },
     imgArr: {
       type: Array,
       default() {
-        return []
-      }
+        return [];
+      },
     },
     visitModel: {
       type: String,
-      default: '1'
+      default: "1",
+    },
+    deviceCode: {
+      type: String,
+      default: "",
+    },
+    putInCode: {
+      type: String,
+      default: "",
     },
   },
   data() {
     return {
       shows: false,
-      url: ""
-    }
+      url: "",
+    };
   },
   methods: {
-    uploadImg(){
-      var map = new TMap.Map('allmap', {
+    uploadImg() {
+      var map = new TMap.Map("allmap", {
         zoom: 14,
         center: new TMap.LatLng(39.986785, 116.301012),
       });
@@ -85,131 +94,135 @@ export default {
       markers.setGeometries([]);
 
       if (this.objectType == "" || this.objectType == null) {
-        this.$toast("请选择类型!")
-        return
+        this.$toast("请选择类型!");
+        return;
       }
       let url = window.location.href;
       let that = this;
-      let wx = this.wx
-      let qiyeData
-      let addressesRemark=""
+      let wx = this.wx;
+      let qiyeData;
+      let addressesRemark = "";
       const instance = axios.create();
-      instance.defaults.headers.common['userId'] = localStorage.getItem("loginName");
-      instance.get(process.env.VUE_APP_BASE_API + 'mobile/wx/ticket',
-          {
-            params: {
-              url: url
-            }
-          }).then(response => {
-        if (response.status == 200) {
-          qiyeData = response.data.data;
-          wx.config({
-            beta: true, // 必须这么写,否则wx.invoke调用形式的jsapi会有问题
-            debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
-            appId: qiyeData.appId, // 必填,企业微信的corpID
-            timestamp: qiyeData.timestamp, // 必填,生成签名的时间戳
-            nonceStr: qiyeData.nonceStr, // 必填,生成签名的随机串
-            signature: qiyeData.signature, // 必填,签名,见 附录-JS-SDK使用权限签名算法
-            jsApiList: ["ready", "chooseImage","uploadImage","getLocation"] // 必填,需要使用的JS接口列表,凡是要调用的接口都需要传进来
-          });
-          wx.ready(function () {
-            wx.getLocation({
-              type: 'gcj02',
-              success: function (res) {
-                var location = new TMap.LatLng(res.latitude, res.longitude);
-                map.setCenter(location);
-                markers.updateGeometries([
-                  {
-                    id: 'main', // 点标注数据数组
-                    position: location,
-                  },
-                ]);
-                geocoder
-                    .getAddress({ location: location })
-                    .then(function(result){
-                      var addresses=result.result.formatted_addresses
-                      addressesRemark=addresses.recommend
-                    },function(err){
-                      addressesRemark=""
-                    })
-              },
-              fail: function () {
-                that.$dialog.alert({
-                  message: 'GPS未开启',
-                })
-              }
+      instance.defaults.headers.common["userId"] = localStorage.getItem("loginName");
+      instance
+        .get(process.env.VUE_APP_BASE_API + "mobile/wx/ticket", {
+          params: {
+            url: url,
+          },
+        })
+        .then((response) => {
+          if (response.status == 200) {
+            qiyeData = response.data.data;
+            wx.config({
+              beta: true, // 必须这么写,否则wx.invoke调用形式的jsapi会有问题
+              debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
+              appId: qiyeData.appId, // 必填,企业微信的corpID
+              timestamp: qiyeData.timestamp, // 必填,生成签名的时间戳
+              nonceStr: qiyeData.nonceStr, // 必填,生成签名的随机串
+              signature: qiyeData.signature, // 必填,签名,见 附录-JS-SDK使用权限签名算法
+              jsApiList: ["ready", "chooseImage", "uploadImage", "getLocation"], // 必填,需要使用的JS接口列表,凡是要调用的接口都需要传进来
+            });
+            wx.ready(function () {
+              wx.getLocation({
+                type: "gcj02",
+                success: function (res) {
+                  var location = new TMap.LatLng(res.latitude, res.longitude);
+                  map.setCenter(location);
+                  markers.updateGeometries([
+                    {
+                      id: "main", // 点标注数据数组
+                      position: location,
+                    },
+                  ]);
+                  geocoder.getAddress({ location: location }).then(
+                    function (result) {
+                      var addresses = result.result.formatted_addresses;
+                      addressesRemark = addresses.recommend;
+                    },
+                    function (err) {
+                      addressesRemark = "";
+                    }
+                  );
+                },
+                fail: function () {
+                  that.$dialog.alert({
+                    message: "GPS未开启",
+                  });
+                },
               });
-            wx.chooseImage({
-              count: 1,
-              sizeType: ['compressed'], // 可以指定是原图还是压缩图,默认二者都有
-              sourceType: ['camera'], // 可以指定来源是相册还是相机,默认二者都有
-              defaultCameraMode: "normal", //表示进入拍照界面的默认模式,目前有normal与batch两种选择,normal表示普通单拍模式,batch表示连拍模式,不传该参数则为normal模式。从3.0.26版本开始支持front和batch_front两种值,其中front表示默认为前置摄像头单拍模式,batch_front表示默认为前置摄像头连拍模式。(注:用户进入拍照界面仍然可自由切换两种模式)
-              isSaveToAlbum:0,
-              success: function (res) {
-                var localIds=""
-                if(res.localIds!=undefined){
-                  localIds= res.localIds[0]
-                }else{
-                  localIds=res.localId
-                }
-                wx.uploadImage({
-                  localId: localIds, // 需要上传的图片的本地ID,由chooseImage接口获得
-                  isShowProgressTips: 1, // 默认为1,显示进度提示
-                  success: function (res) {
-                    that.uploadImagev(res.serverId,addressesRemark)
+              wx.chooseImage({
+                count: 1,
+                sizeType: ["compressed"], // 可以指定是原图还是压缩图,默认二者都有
+                sourceType: ["camera"], // 可以指定来源是相册还是相机,默认二者都有
+                defaultCameraMode: "normal", //表示进入拍照界面的默认模式,目前有normal与batch两种选择,normal表示普通单拍模式,batch表示连拍模式,不传该参数则为normal模式。从3.0.26版本开始支持front和batch_front两种值,其中front表示默认为前置摄像头单拍模式,batch_front表示默认为前置摄像头连拍模式。(注:用户进入拍照界面仍然可自由切换两种模式)
+                isSaveToAlbum: 0,
+                success: function (res) {
+                  var localIds = "";
+                  if (res.localIds != undefined) {
+                    localIds = res.localIds[0];
+                  } else {
+                    localIds = res.localId;
                   }
-                });
-              }
+                  wx.uploadImage({
+                    localId: localIds, // 需要上传的图片的本地ID,由chooseImage接口获得
+                    isShowProgressTips: 1, // 默认为1,显示进度提示
+                    success: function (res) {
+                      that.uploadImagev(res.serverId, addressesRemark);
+                    },
+                  });
+                },
+              });
             });
-          })
-        }
-      });
+          }
+        });
     },
-    uploadImagev(meidaId,addressesRemark){
+    uploadImagev(meidaId, addressesRemark) {
       var that = this;
-      var parentCollectionId=null
-      if(that.parentCollectionId!=null&&that.parentCollectionId!="null"){
-        parentCollectionId=that.parentCollectionId
+      var parentCollectionId = null;
+      if (that.parentCollectionId != null && that.parentCollectionId != "null") {
+        parentCollectionId = that.parentCollectionId;
       }
-      var secondCollectionId=null
-      if(that.secondCollectionId!=null&&that.secondCollectionId!="null"){
-        secondCollectionId=that.secondCollectionId
+      var secondCollectionId = null;
+      if (that.secondCollectionId != null && that.secondCollectionId != "null") {
+        secondCollectionId = that.secondCollectionId;
       }
-      var firstCollectionId=null
-      if(that.firstCollectionId!=null&&that.firstCollectionId!="null"){
-        firstCollectionId=that.firstCollectionId
-      }
-      var form={
-        mediaId:meidaId,
-        collectionItemId:that.collectionId,
-        objectType:that.objectType,
-        storeGroupId:that.storeGroupId,
-        taskId:that.taskId,
-        visitsId:localStorage.getItem('visitId'),
-        visitModel:that.visitModel,
-        visitSource:"1",
-        locationRemark:addressesRemark,
-        parentCollectionId:parentCollectionId,
-        secondCollectionId:secondCollectionId,
-        firstCollectionId:firstCollectionId,
+      var firstCollectionId = null;
+      if (that.firstCollectionId != null && that.firstCollectionId != "null") {
+        firstCollectionId = that.firstCollectionId;
       }
+      var form = {
+        mediaId: meidaId,
+        collectionItemId: that.collectionId,
+        objectType: that.objectType,
+        storeGroupId: that.storeGroupId,
+        taskId: that.taskId,
+        visitsId: localStorage.getItem("visitId"),
+        visitModel: that.visitModel,
+        visitSource: "1",
+        locationRemark: addressesRemark,
+        parentCollectionId: parentCollectionId,
+        secondCollectionId: secondCollectionId,
+        firstCollectionId: firstCollectionId,
+        deviceCode: that.deviceCode, //设备编号
+        putInCode: that.putInCode, //投放编号
+      };
       var loind1 = that.$toast.loading({
         duration: 0,
-        message: '上传中...',
+        message: "上传中...",
         forbidClick: true,
       });
-      addstorePhoto(form).then(res=>{
+      addstorePhoto(form).then((res) => {
         if (res.code == 200) {
           loind1.clear();
-          that.$toast("上传成功!")
-          that.$emit('newimgarr', {fileUrl: res.data.url, id: res.data.fileId, type: 2});
+          that.$toast("上传成功!");
+          that.$emit("newimgarr", { fileUrl: res.data.url, id: res.data.fileId, type: 2 });
         } else {
-          that.$toast("上传失败!")
+          that.$toast("上传失败!");
         }
-      })
-    }
+      });
+    },
   },
-}
+};
 </script>
 <style lang="scss" scoped>
 .questionNamep {
@@ -239,12 +252,11 @@ export default {
       z-index: 89;
     }
   }
-
 }
-#allmap{
+#allmap {
   width: 10px;
   height: 10px;
   left: -1000px;
   position: relative;
 }
-</style>
+</style>

+ 15 - 8
src/views/deviceWithin/addStoreVisit.vue

@@ -1228,6 +1228,8 @@
             :parentCollectionId="parentCollectionId"
             :secondCollectionId="secondCollectionId"
             :firstCollectionId="firstCollectionId"
+            :deviceCode="deviceCode"
+            :putInCode="putInCode"
             :imgArr="imgs"
             :objectType="PhotoType"
             :shouws="true"
@@ -1721,7 +1723,7 @@ export default {
         loading1.clear();
         this.deviceCode = '';
         this.putInCode = '';
-        this.equipmentCode = res.data.equipmentCode;
+        // this.equipmentCode = res.data.equipmentCode;
         var checkUnManage = res.data.sfaTaskList[this.$route.query.ids];
         var collectionItemLists = res.data.sfaTaskList[this.$route.query.ids].collectionItemList;
         if (checkUnManage.checkUnManage != null && checkUnManage.checkUnManage != 'N') {
@@ -1730,13 +1732,16 @@ export default {
           this.checked = false;
         }
         this.unManage = res.data.sfaTaskList[this.$route.query.ids].unManage;
-        this.deviceCode = res.data.deviceCode;
-        this.putInCode = res.data.putInCode;
-        if (res.data.sfaTaskList[this.$route.query.ids].inspectionType == 'buy') {
-          this.equipmentCode = res.data.putInCode;
+        this.deviceCode = res.data.sfaTaskList[this.$route.query.ids].deviceCode || ''; // 设备编号
+        this.putInCode = res.data.sfaTaskList[this.$route.query.ids].putInCode || ''; // 投放编号
+        // 调色机类型:buy-购买类调色机,place-放置类调色机
+        let inspectionType = res.data.sfaTaskList[this.$route.query.ids].inspectionType;
+        if (inspectionType == 'buy') {
+          this.equipmentCode = res.data.sfaTaskList[this.$route.query.ids].putInCode || '';
+          this.showCode = true;
+        } else if (inspectionType == 'place') {
+          this.equipmentCode = res.data.sfaTaskList[this.$route.query.ids].equipmentCode || '';
           this.showCode = true;
-        } else {
-          this.showCode = false;
         }
         if (
           (res.data.sfaTaskList[this.$route.query.ids].processStatus == 3 &&
@@ -2371,7 +2376,7 @@ export default {
       } else {
         checkUnManage = 'N';
       }
-
+      // taskType:3物料,2产品类型,1常规类型
       if (this.$route.query.taskType == 3) {
         formData = {
           storeId: this.storeId,
@@ -2394,6 +2399,8 @@ export default {
           insert: this.insert,
           collectionAnswers: [],
           checkUnManage: checkUnManage,
+          deviceCode: this.deviceCode || '', //设备编号
+          putInCode: this.putInCode || '', //投放编号
         };
       }
       if (this.$route.query.taskType == 1) {