<template>
  <view class="Scanning_B">
    <view class="Scanning_top" v-if="res.status == 200 || res.status == 666">
      <view class="Scanning_top_icon">
        <text class="cubeic-ok newicon newicon-duigou"></text>
      </view>
      <view class="Scanning_top_text">
        <view class="text1" v-if="res.status == 200">扫描成功</view>
        <view class="text1" v-else-if="res.status == 666">查询成功</view>
      </view>
    </view>
    <view class="Scanning_top" v-if="res.status != 200 && res.status != 666">
      <view class="Scanning_top_icon">
        <text class="cubeic-close newicon newicon-shibai"></text>
      </view>
      <view class="Scanning_top_text">
        <view class="text1">扫描失败</view>
      </view>
    </view>

    <view class="Scanning_cont" v-if="res.status == 200 || res.status == 666">
      <view>标本类型 : {{ infoDATA.stype.name || "-" }} <text v-if="res.data.tubeType">、</text> {{res.data.tubeType && res.data.tubeType.name}}</view>
      <view>标本编码 : {{ infoDATA.scode || "-" }}</view>
      <view>标本状态 : <text :class="{ red: res.data.speState && res.data.speState.value == 8 }">{{ res.data.speState ? res.data.speState.name : "-" }}</text></view>
      <view>申请科室 : {{ infoDATA.sickRoom || "-" }}</view>
      <view>检验科室 : {{ infoDATA.checkDept || "-" }}</view>
      <view>检验项目 : {{ res.data.specimenDesc || "-" }}</view>
      <view>患者姓名 : {{ res.data.patientName}}<text v-if="res.data.bedNum">({{res.data.bedNum}})</text></view>
      <view>住院号 : {{ res.data.residenceNo || "-" }}</view>
    </view>
    <view class="Scanning_cont" v-else>
      <view>{{ res.msg }}</view>
    </view>
    <view class="foot_btn">
      <view class="btn3" @click="showAlert()">返回</view>
      <block v-if="res.data && res.data.speState && res.data.speState.value != 8">
        <!-- 1， 支持待到达本人，显示接单签到按钮 -->
        <!-- 1， 匹配到单子待接单，显示接单签到按钮 -->
        <!-- 2， 支持待到达非本人，显示接单签到按钮 -->
        <view class="btn3" @click="buildAndOrderSign(res.data.id,res.workOrder.id)" v-if="(bigScanShowSignBtn && res.workOrder && res.workOrder.worker && res.workOrder.gdState.value == 4 && loginUser.id == res.workOrder.worker.id) || (bigScanShowSignBtn && res.workOrder && (res.workOrder.gdState.value == 2 || res.workOrder.gdState.value == 3)) || (bigScanArriveNotOwner && res.workOrder && res.workOrder.worker && res.workOrder.gdState.value == 4 && loginUser.id != res.workOrder.worker.id)">接单并签到</view>
        <!-- 没有匹配到单子，显示建单并签到按钮 -->
        <view class="btn3" @click="buildAndOrderSign(res.data.id)" v-if="bigScanShowCreateBtn && !res.workOrder">建单并签到</view>
      </block>
      <view class="btn3" @click="back(res.data,res.data.gdid)"
        v-if="res.data && res.data.speState&&(res.data.speState.value == 2||res.data.speState.value == 3||res.data.speState.value == 4||res.data.speState.value == 5)">
        退回</view>
    </view>
    <!-- 填写交接人工号弹窗 -->
    <selectAccount v-if="hosModels.disjunctor" :disjunctor="hosModels.disjunctor" @ok="hosOk"
      @cancel="hosCancel">
    </selectAccount>
    <!-- 退回弹窗 -->
    <backModel v-if="backModels.disjunctor" :title="backModels.title" :disjunctor="backModels.disjunctor" @ok="backOk"
      @cancel="backCancel">
    </backModel>
    <!-- 弹窗 -->
    <showModel :title="models.title" :icon="models.icon" :disjunctor="models.disjunctor" :content="models.content"
      :operate="models.operate" @know="know"></showModel>
			<b></b>
		<!-- 标本第一次拦截 -->
		<uni-popup ref="alertDialog" type="dialog" :mask-click="false">
			<uni-popup-dialog type="info" cancelText="否" confirmText="是" title="提示" @confirm="dialogConfirm"
				@close="dialogClose">
				<text v-html="speContent"></text>
			</uni-popup-dialog>
		</uni-popup>
    <!-- 填写交接人工号弹窗 -->
    <selectAccount @click.stop.native v-if="hosModels1.disjunctor" :disjunctor="hosModels1.disjunctor" @ok="hosOk1" @cancel="hosCancel1"></selectAccount>
  </view>
</template>
<script>
  import {
    SM,
    get,
    post,
    webHandle
  } from "../../http/http.js";
  export default {
    data() {
      return {
        SMFlag:true,
        extraData: {},
        loginUser: uni.getStorageSync("userData").user,
        bigScanShowSignBtn: false,//显示接单签到按钮或待到达本人
        bigScanArriveNotOwner: false,//支持待到达非本人
        bigScanShowCreateBtn: false,//显示建单并签到按钮
        defaultScanSpe: false,//默认扫描标本进入标本扫描页
        backParams: {},
        workOrderId: 0,
        // 弹窗model
        models: {
          disjunctor: false,
        },
        backSpecimen: {},
        backStatus: '',
        infoDATA: {},
        res: {},
        // 填写交接人工号弹窗model
        hosModels: {
          disjunctor: false,
        },
        // 填写交接人工号弹窗model
        hosModels1: {
          disjunctor: false,
        },
        // 退回弹窗model
        backModels: {
          disjunctor: false,
        },
        currentCode: "",
        type: "", //类型，orderSign|buildAndOrderSign
				speCollectLimit:null,
				speStartCollectShowConfig:null,
				speContent:null,
				speData:null
      };
    },
    methods: {
      // 如果不是患者陪检或患者转运或其他
      // 科室签到
      nextDeptOrder_s(data, accountObj) {
        console.log(data, accountObj);
        let ids = [];
        let id = data.id;
        ids.push(id);
        let code = "";
        let postData = {
          ids,
        };
        if (this.type === 'buildAndOrderSign' || this.type === 'specimenAssignAndSign') {
          postData.specimenOrderSign = data.specimenSet.map(v => v.id); //破坏性，必须扫标本
        }
        if (accountObj) {
          postData.handover = [accountObj.accountId];
        }
        if (this.currentCode) {
          code = this.currentCode;
          // 科室签到
          post("/workerOrder/orderSign/" + code, postData).then((res) => {
            uni.hideLoading();
            if (res.status == 200) {
              // 跳转到扫描科室
              // type1: res.type, //type类型
              // id: data.id, //工单ID
              // deptCode: code, //二维码
              // dept: res.dept //科室名称
              uni.navigateTo({
                url: `/pages/scanning_code/scanning_code?type=${
                data.taskType.associationType.value
              }&type1=${res.type}&id=${data.id}&deptCode=${code}&dept=${
                res.dept
              }&accountObj=${encodeURIComponent(
                JSON.stringify(accountObj)
              )}&deptId=${res.deptId}&specimenId=${res.specimenId}&fromSpecimenBuild=1`,
              });
            } else {
              uni.navigateTo({
                url: `/pages/scanning_Result/scanning_Result?type=${data.taskType.associationType.value}&type1=${res.type}&id=${data.id}&status=600&msg=${res.msg}&isKs=1&qrcode=${this.currentCode}`,
              });
            }
          });
        }
      },
      // 退回
      back(specimen, workOrderId) {
        this.backSpecimen = specimen;
        this.backStatus = 'back';
        this.workOrderId = workOrderId;
        this.showBack();
      },
      // 执行工单
      // orderSign(workOrder) {
      //   this.type = 'orderSign';
      //   uni.showModal({
      //     title: '提示',
      //     content: '是否执行工单？',
      //     success: (res) => {
      //       if (res.confirm) {
      //         console.log('用户点击确定');
      //         uni.showLoading({
      //           title: "加载中",
      //           mask: true,
      //         });
      //         let postData = {
      //           content: workOrder.startDept.qrcode,
      //           taskTypeId: workOrder.taskType.id,
      //           gdState: workOrder.gdState.id,
      //         };
      //         //检验二维码的有效性
      //         post("/dept/scanning", postData).then((result) => {
      //           this.currentCode = result.code;
      //           if (result.state == 200 || result.state == 201) {
      //             if (result.account) {
      //               this.nextDeptOrder_s(workOrder, {
      //                 account: result.account,
      //                 accountName: result.name,
      //                 accountId: result.id,
      //               });
      //             } else {
      //               this.nextDeptOrder_s(workOrder);
      //             }
      //           } else if (result.state == "0000") {
      //             uni.hideLoading();
      //             this.showSelectAccount();
      //           } else {
      //             uni.hideLoading();
      //             uni.showToast({
      //               icon: "none",
      //               title: result.info || "接口获取数据失败！",
      //             });
      //           }
      //         });
      //       } else if (res.cancel) {
      //         console.log('用户点击取消');
      //       }
      //     }
      //   });
      // },
      // 接单并签到或建单并签到
      buildAndOrderSign(speId, orderId) {
        this.type = 'buildAndOrderSign';
        if (orderId) {
          // 接单并签到
          this.type = 'specimenAssignAndSign';
        } else {
          // 建单并签到
          this.type = 'buildAndOrderSign';
        }
        uni.showModal({
          title: '提示',
          content: `是否${this.type == 'specimenAssignAndSign'?'接单并签到':'建单并签到'}？`,
          success: (res) => {
            if (res.confirm) {
              console.log('用户点击确定');
              uni.showLoading({
                title: "加载中",
                mask: true,
              });
              let postData = {
                speId,
								speVerifyType:null
              }
              if (orderId) {
                // 接单并签到
                postData.orderId = orderId;
              }
							if(this.speData){
								postData.speVerifyType = this.speData.speVerifyType
							}else{
								delete postData.speVerifyType
							}
              post("/workerOrder/specimenCreateAndSign", postData).then((res) => {
								this.speContent = null
								this.speData = null
								if (res.state == 200 || res.state == 201) {
                  uni.hideLoading();
									this.$refs.alertDialog.close()
                  if (res.status == 200) {
                    // 跳转到扫描科室
                    // type1: res.type, //type类型
                    // id: data.id, //工单ID
                    // deptCode: code, //二维码
                    // dept: res.dept //科室名称
                    // uni.navigateTo({
                    //   url: `/pages/scanning_code/scanning_code?type=${
                    //   res.workOrder.taskType.associationType.value
                    // }&type1=${res.type}&id=${res.workOrder.id}&deptCode=${
                    //   this.currentCode
                    // }&dept=${res.dept}&accountObj=${encodeURIComponent(
                    //   JSON.stringify(undefined)
                    // )}&deptId=${res.deptId}&specimenId=${speId}&fromSpecimenBuild=1`,
                    // });
                    this.breforeJump(res);
                  } else {
                    uni.navigateTo({
                      url: `/pages/scanning_Result/scanning_Result?type=${res.workOrder.taskType.associationType.value}&type1=${res.type}&id=${res.workOrder.id}&status=600&msg=${res.msg}&isKs=1`,
                    });
                  }
                } else if (res.state == "0000") {
									this.$refs.alertDialog.close()
                  uni.hideLoading();
                  this.currentCode = res.code;
                  this.res.workOrder = res.workOrder;
                  this.showSelectAccount();
                } else if(res.status == 515){
                  uni.hideLoading();
									this.$refs.alertDialog.open()
									this.speContent = res.msg
									this.speData = res
                } else {
									uni.hideLoading();
									uni.showToast({
									  icon: "none",
									  title: res.msg || "接口获取数据失败！",
									});
								}
              });
            } else if (res.cancel) {
              console.log('用户点击取消');
            }
          }
        });
      },
			dialogConfirm() {
				uni.showLoading({
				  title: "加载中",
				  mask: true,
				});
				let postData = {
				  orderId: null,
					speId: this.speData.data.id,
					speVerifyType:null
				}
				if (this.res.workOrder) {
				  // 接单并签到
				  postData.orderId = this.res.workOrder.id;
				}else{
					delete postData.orderId
				}
				if(this.speData){
					postData.speVerifyType = this.speData.speVerifyType
				}else{
					delete postData.speVerifyType
				}
				post("/workerOrder/specimenCreateAndSign", postData).then((res) => {
				 this.speContent = null
				 this.speData = null
					if (res.state == 200 || res.state == 201) {
						this.$refs.alertDialog.close()
				    uni.hideLoading();
				    if (res.status == 200) {
				      this.breforeJump(res);
				    } else {
				      uni.navigateTo({
				        url: `/pages/scanning_Result/scanning_Result?type=${res.workOrder.taskType.associationType.value}&type1=${res.type}&id=${res.workOrder.id}&status=600&msg=${res.msg}&isKs=1`,
				      });
				    }
				  } else if (res.state == "0000") {
						this.$refs.alertDialog.close()
				    uni.hideLoading();
				    this.currentCode = res.code;
				    this.res.workOrder = res.workOrder;
				    this.showSelectAccount();
				  } else if(res.status == 515){
				    uni.hideLoading();
						this.$refs.alertDialog.open()
						this.speContent = res.msg
						this.speData = res
				  } else {
						uni.hideLoading();
						uni.showToast({
						  icon: "none",
						  title: res.msg || "接口获取数据失败！",
						});
					}
				});
			},
			dialogClose() {
				this.$refs.alertDialog.close()
				this.speContent = null
				this.speData = null
			},
      know() {
        this.models.disjunctor = false;
        if (this.models.icon === 'success') {
          uni.navigateTo({
            url: "../receiptpage/receiptpage",
          });
        }
      },
      // ==================填写工号 start===============
      // 填写交接人工号-确认
      hosOk1(data) {
        console.log(data);
        const {
          accountName,
          account,
          accountId
        } = data;
        if (!accountName && !account) {
          //没有填写交接人
          uni.showModal({
            title: "提示",
            content: "请填写交接人工号！",
            showCancel: false,
            success: function(res) {
              if (res.confirm) {
                console.log("用户点击确定");
              } else if (res.cancel) {
                console.log("用户点击取消");
              }
            },
          });
          return;
        } else if ((!accountName && account) || (accountName && !account)) {
          //没有填写交接人
          uni.showModal({
            title: "提示",
            content: "请填写正确的交接人工号！",
            showCancel: false,
            success: function(res) {
              if (res.confirm) {
                console.log("用户点击确定");
              } else if (res.cancel) {
                console.log("用户点击取消");
              }
            },
          });
          return;
        }
        this.hosModels1.disjunctor = false;
        this.validateAccount1(data);
      },
      // 填写交接人工号-取消
      hosCancel1() {
        this.hosModels1.disjunctor = false;
        this.flag = true;
      },
      // 填写交接人工号弹窗
      showSelectAccount1() {
        this.hosModels1 = {
          disjunctor: true,
        };
      },
      // 手动填写工号校验
      validateAccount1(accountObj){
        const { accountName, account, accountId } = accountObj;
        
        this.backHandlerAfter(this.extraData.specimen, this.extraData.workorderId, accountObj)
      },
      // ==================填写工号 end===============
      // 扫科室码
      scanDeptCode(){
        if (!this.SMFlag) {
          return;
        }
        this.SMFlag = false;
        SM().then((content) => {
          this.SMFlag = true;
          this.backHandlerAfter(this.extraData.specimen, this.extraData.workorderId, this.extraData.data, content)
        }).catch(err => {
          this.SMFlag = true;
        });
      },
      // 退回接口调用前查询验证方式
      backHandler(specimen, workorderId, data){
        this.extraData = {
          specimen,
          workorderId,
          data,
        }
        console.log(this.backParams);
        // extra7 验证方式 0无 1科室码 2动态码 3 填写工号
        if(this.backParams.reasonForReturn.extra7 == 1){
          // 科室码
          this.scanDeptCode();
        }else if(this.backParams.reasonForReturn.extra7 == 2){
          // 动态码
          this.scanDeptCode();
        }else if(this.backParams.reasonForReturn.extra7 == 3){
          // 填写工号
          this.showSelectAccount1();
        }else{
          // 无
          this.backHandlerAfter(specimen, workorderId, data)
        }
      },
      // 退回
      backHandlerAfter(specimen, workorderId, data, deptCode) {
        console.log(specimen, workorderId, data, deptCode);
        const {
          reasonForReturn,
          remarks,
        } = this.backParams;
        uni.showLoading({
          title: '加载中',
          mask: true
        })
        let postData = {
          reasonForReturn: reasonForReturn.id,
          remarks,
          scode: specimen.scode,
          hosId: uni.getStorageSync("userData").user.currentHospital.id,
          speState: specimen.speState ? specimen.speState.id : undefined,
          handoverId: data ? data.accountId : undefined,
          handoverName: data ? data.accountName : undefined,
          gdId: workorderId || undefined,
          deptCode: deptCode || undefined,
        }
        post('/workerOrder/returnSpecimen', postData).then(res => {
          uni.hideLoading();
          if (res.state == 200) {
            this.models = {
              disjunctor: true,
              title: "提示",
              content: `标本退回成功`,
              icon: "success",
            };
          } else {
            this.models = {
              disjunctor: true,
              title: "提示",
              content: res.msg || `标本退回失败`,
              icon: "error",
            };
          }
        })
      },
      // 填写交接人工号-确认
      hosOk(data) {
        console.log(data);
        const {
          accountName,
          account,
          accountId
        } = data;
        if (!accountName && !account) {
          //没有填写交接人
          uni.showModal({
            title: "提示",
            content: "请填写交接人工号！",
            showCancel: false,
            success: function(res) {
              if (res.confirm) {
                console.log("用户点击确定");
              } else if (res.cancel) {
                console.log("用户点击取消");
              }
            },
          });
          return;
        } else if ((!accountName && account) || (accountName && !account)) {
          //没有填写交接人
          uni.showModal({
            title: "提示",
            content: "请填写正确的交接人工号！",
            showCancel: false,
            success: function(res) {
              if (res.confirm) {
                console.log("用户点击确定");
              } else if (res.cancel) {
                console.log("用户点击取消");
              }
            },
          });
          return;
        }
        this.hosModels.disjunctor = false;
        uni.showLoading({
          title: "加载中",
          mask: true,
        });
        if (this.backStatus = 'back') {
          // 退回
          this.backHandler(this.backSpecimen, this.res.data.gdid, data);
        } else {
          this.nextDeptOrder_s(this.res.workOrder, data);
        }
      },
      // 填写交接人工号-取消
      hosCancel() {
        this.hosModels.disjunctor = false;
      },
      // 填写交接人工号弹窗
      showSelectAccount() {
        this.hosModels = {
          disjunctor: true,
        };
      },
      // 返回
      showAlert() {
        uni.navigateTo({
          url: "../receiptpage/receiptpage",
        });
      },
      // 退回-确认
      backOk(data) {
        console.log(data);
        this.backParams = data;
        this.hosModels.disjunctor = false;
        // ====================================
        uni.showLoading({
          title: "加载中",
          mask: true,
        });
        const userData = uni.getStorageSync("userData");
        // 查询标本配送业务
        post("/simple/data/fetchDataList/taskType",{
            "idx": 0,
            "sum": 10,
            "taskType": {
                "simpleQuery": true,
                "hosId": {
                    "id": userData.user.currentHospital.id
                },
                "associationType": {
                    "key": "association_types",
                    "value": "specimen"
                }
            }
        }).then((res) => {
          if (res.status == 200) {
            let taskTypeDTO = res.list[0];
        		if(taskTypeDTO){
              // 查询业务页面控制-标本
              post("/simple/data/fetchDataList/taskTypeConfig",{
                  "idx": 0,
                  "sum": 10,
                  "taskTypeConfig": {
                    taskTypeDTO,
                  }
              }).then((res) => {
                uni.hideLoading();
                if (res.status == 200) {
                  let data = res.list[0];
              		if(data){
                    if (data.returnSpecimenWhetherHandover == 1 && this.backParams.reasonForReturn.extra1 == 1) {
                      this.backCancel();
                      this.showSelectAccount();
                    } else {
                      this.backHandler(this.backSpecimen, this.workOrderId);
                    }
                  }else{
                    this.backHandler(this.backSpecimen, this.workOrderId);
                  }
                } else {
                  uni.showToast({
                    icon: "none",
                    title: res.msg || "接口获取数据失败！",
                  });
                }
              });
            }else{
              uni.hideLoading();
              uni.showToast({
                icon: "none",
                title: "未查询到标本配送业务！",
              });
            }
          } else {
            uni.hideLoading();
            uni.showToast({
              icon: "none",
              title: res.msg || "接口获取数据失败！",
            });
          }
        });
        // ====================================
      },
      // 退回-取消
      backCancel() {
        this.backStatus = '';
        this.backModels.disjunctor = false;
      },
      // 退回弹窗
      showBack() {
        this.backModels = {
          title: "退回",
          disjunctor: true,
        };
      },
      // 页面控制-标本
      getPageConfigSpecimen(){
        const userData = uni.getStorageSync("userData");
        console.log('userData', userData);
        uni.showLoading({
          title: "加载中",
          mask: true,
        });
        // 查询标本配送业务
        post("/simple/data/fetchDataList/taskType",{
            "idx": 0,
            "sum": 10,
            "taskType": {
                "simpleQuery": true,
                "hosId": {
                    "id": userData.user.currentHospital.id
                },
                "associationType": {
                    "key": "association_types",
                    "value": "specimen"
                }
            }
        }).then((res) => {
          if (res.status == 200) {
            let taskTypeDTO = res.list[0];
        		if(taskTypeDTO){
              // 查询业务页面控制-标本
              post("/simple/data/fetchDataList/taskTypeConfig",{
                  "idx": 0,
                  "sum": 10,
                  "taskTypeConfig": {
                    taskTypeDTO,
                  }
              }).then((res) => {
                if (res.status == 200) {
                  let data = res.list[0];
              		if(data){
                    this.bigScanShowSignBtn = data.bigScanShowSignBtn === 1;
                    this.bigScanArriveNotOwner = data.bigScanArriveNotOwner === 1;
                    this.bigScanShowCreateBtn = data.bigScanShowCreateBtn === 1;
                    this.defaultScanSpe = data.defaultScanSpe === 1;
										this.speCollectLimit = data.speCollectLimit;
										this.speStartCollectShowConfig = data.speStartCollectShowConfig;
                    if(this.defaultScanSpe){
                      this.defaultJumpPage();
                    }else{
                      uni.hideLoading();
                    }
                  }else{
                    uni.hideLoading();
                    uni.showToast({
                      icon: "none",
                      title: "未查询到配置！",
                    });
                  }
                } else {
                  uni.hideLoading();
                  uni.showToast({
                    icon: "none",
                    title: res.msg || "接口获取数据失败！",
                  });
                }
              });
            }else{
              uni.hideLoading();
              uni.showToast({
                icon: "none",
                title: "未查询到标本配送业务！",
              });
            }
          } else {
            uni.hideLoading();
            uni.showToast({
              icon: "none",
              title: res.msg || "接口获取数据失败！",
            });
          }
        });
      },
      // 默认情况下标本大扫描匹配到待到达工单，为当前的配送人员，直接进入标本扫描页面
      defaultJumpPage(){
        let workOrder = this.res.workOrder;
        console.log('workOrder:', workOrder)
        if(workOrder && workOrder.worker && workOrder.gdState.value == 4 && this.loginUser.id == workOrder.worker.id){
          let postData = {
            speId: this.res.data.id,
            orderId: workOrder.id,
          }
          post("/workerOrder/specimenCreateAndSign", postData).then((res) => {
						if (res.state == 200 || res.state == 201) {
              if (res.status == 200) {
                // 跳转到扫描科室
                // type1: res.type, //type类型
                // id: data.id, //工单ID
                // deptCode: code, //二维码
                // dept: res.dept //科室名称
                // uni.navigateTo({
                //   url: `/pages/scanning_code/scanning_code?type=${
                //   res.workOrder.taskType.associationType.value
                // }&type1=${res.type}&id=${res.workOrder.id}&deptCode=${
                //   this.currentCode
                // }&dept=${res.dept}&accountObj=${encodeURIComponent(
                //   JSON.stringify(undefined)
                // )}&deptId=${res.deptId}&specimenId=${speId}&fromSpecimenBuild=1`,
                // });
                this.breforeJump(res);
              } else {
                uni.hideLoading();
                uni.navigateTo({
                  url: `/pages/scanning_Result/scanning_Result?type=${res.workOrder.taskType.associationType.value}&type1=${res.type}&id=${res.workOrder.id}&status=600&msg=${res.msg}&isKs=1`,
                });
              }
            } else if (res.state == "0000") {
              uni.hideLoading();
              this.currentCode = res.code;
              this.res.workOrder = res.workOrder;
              this.showSelectAccount();
            } else if(res.status == 515){
							uni.hideLoading();
							this.$refs.alertDialog.open()
							this.speContent = res.msg
							this.speData = res
						}else {
              uni.hideLoading();
              uni.showToast({
                icon: "none",
                title: res.msg || "接口获取数据失败！",
              });
            }
          });
        }else{
          uni.hideLoading();
        }
      },
      // 跳转前统一处理
      breforeJump(resObj) {
        uni.showLoading({
          title: '加载中',
          mask: true,
        })
        post('/workerOrder/getSpecimenCount', {
          gdId: resObj.workOrder.id
        }).then(res => {
          get('/api/fetchData/specimen/' + this.res.data.id).then(ress => {
            uni.hideLoading();
            console.log(ress);
            ress.msg = '成功';
            ress.specimenCount = res.specimenCount;
            ress.type = resObj.type;
						if(this.speCollectLimit==1 && this.speStartCollectShowConfig==1){
							let sessData = `type=${
							  resObj.workOrder.taskType.associationType.value
							}&type1=${
							  resObj.type
							}&infoData=${encodeURIComponent(
							  JSON.stringify(ress.data)
							)}&status=${ress.status}&msg=${ress.msg}&deptCode=${
							  this.currentCode
							}&dept=${
							  resObj.dept
							}&taskTypeId=${
							  resObj.workOrder.taskType.id
							}&deptId=${resObj.deptId}&id=${resObj.workOrder.id}&model=${encodeURIComponent(
							  JSON.stringify(ress)
							)}&speNum=${res.specimenCount}`
							uni.setStorageSync('gdData', JSON.stringify(sessData))
							uni.navigateTo({
							  url: `../speConfigurationGather/speConfigurationGather?id=${resObj.workOrder.id}`,
							});
						}else{
							uni.navigateTo({
							  url: `../scanning_Result/scanning_Result?type=${
							  resObj.workOrder.taskType.associationType.value
							}&type1=${
							  resObj.type
							}&infoData=${encodeURIComponent(
							  JSON.stringify(ress.data)
							)}&status=${ress.status}&msg=${ress.msg}&deptCode=${
							  this.currentCode
							}&dept=${
							  resObj.dept
							}&taskTypeId=${
							  resObj.workOrder.taskType.id
							}&deptId=${resObj.deptId}&id=${resObj.workOrder.id}&model=${encodeURIComponent(
							  JSON.stringify(ress)
							)}&speNum=${res.specimenCount}`,
							});
						}
          })
        })
      },
    },
		onShow() {
      this.SMFlag = true;
			let that = this
			// #ifdef APP-PLUS
			uni.$off('scan') // 每次进来先 移除全局自定义事件监听器
			// uni.$on('scan', function(data) {
			// 	that.pdaChange(data)
			// })
			// #endif
		},
    onLoad(options) {
      this.res = JSON.parse(options.res);
      this.getPageConfigSpecimen();

      this.infoDATA = JSON.parse(options.infoDATA); //详细信息
      console.log(this.infoDATA);
      console.log(this.res);
      // #ifdef APP-PLUS
      webHandle("no", "app");
      // #endif
      // #ifdef H5
      webHandle("no", "wx");
      // #endif
    },
  };
</script>
<style lang="less">
  .Scanning_B {
    padding: 0px 74rpx;

    .uni-modal__btn_primary {
      color: #49b856 !important;
    }

    .Scanning_top {
      height: 270rpx;

      .Scanning_top_icon {
        width: 140rpx;
        height: 140rpx;
        margin: 0 auto;
        margin-top: 116rpx;
        border-radius: 50%;
        line-height: 140rpx;
        text-align: center;

        .cubeic-ok {
          font-size: 140rpx;
          color: #35b34a;
        }

        .cubeic-close {
          font-size: 140rpx;
          color: #ff3b53;
        }
      }

      .Scanning_top_text {
        .text1 {
          margin-top: 40rpx;
          font-size: 48rpx;
          text-align: center;
        }
      }
    }

    .Scanning_cont {
      font-size: 32rpx;

      view {
        margin-bottom: 16rpx;
        text-align: center;
      }

      .text {
        margin-top: 24rpx;
        color: #35b34a;
      }

      .text1 {
        margin-top: 24rpx;
        color: #ff3b53;
      }
    }

    .foot_btn {
      line-height: 88rpx;
      height: 100rpx;
      margin-top: 40rpx;
      display: flex;
      justify-content: center;

      .btn3 {
        flex: 1;
        height: 88rpx;
        background-image: linear-gradient(to right, #72c172, #3bb197);
        color: #fff;
        border-radius: 8rpx;
        font-size: 32rpx;
        margin-top: 16rpx;
        margin-right: 16rpx;
        text-align: center;

        &:last-of-type {
          margin-right: 0;
        }
      }
    }
  }
</style>
