<template>
  <view class="toolbar" :class="!isNumberKey?'fixed-class':''" @click="Scanning()" hover-class="seimin-btn-hover">
    <text class="toolbar-icon newicon newicon-saoma"></text>
    <text class="toolbar-sao">扫一扫</text>
    <!-- 填写交接人工号弹窗 -->
    <selectAccount @click.stop.native v-if="hosModels.disjunctor" :disjunctor="hosModels.disjunctor" @ok="hosOk"
      @cancel="hosCancel">
    </selectAccount>
  </view>
</template>

<script>
  import {
    post,
    SM
  } from "../../http/http.js";
  export default {
    data() {
      return {
        hosId: uni.getStorageSync('userData').user.currentHospital.id,
        // 填写交接人工号弹窗model
        hosModels: {
          disjunctor: false,
        },
        userId: {
          ids: [],
        },
        workData: [],
        infoDATA: {},
        tabType: "", //当前选中项
        selectArr: [], //选中项
        code: "",
        currentCode: '', //当前小扫描的科室二维码
        SMFlag: true,
      }
    },
		props:{
			isNumberKey:Boolean
		},
    methods: {
      // 填写交接人工号-确认
      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;
        this.orderDeptHandler(false, data);
      },
      // 填写交接人工号-取消
      hosCancel() {
        this.hosModels.disjunctor = false;
        this.flag = true;
      },
      // 填写交接人工号弹窗
      showSelectAccount() {
        this.hosModels = {
          disjunctor: true,
        };
      },
      // 标本配送-待送达-运输过程-标本数字交接,则,科室签到不需要填写交接人
      validateHandoverSpecimen(){
        return post("/simple/data/fetchDataList/taskType", {
          "idx": 0,
          "sum": 1,
          "taskType": {
              "hosId": {
                  "id": this.hosId
              },
              "associationType": {
                  "key": "association_types",
                  "value": "specimen"
              }
          }
        });
      },
      //科室签到
      //trueBigScanner----判断是否大扫描
      //bigScanner----判断是否需要交接人
      //accountObj----弹窗填写的交接人信息
      async orderDeptHandler(bigScanner, accountObj) {
        console.log(this.infoDATA);
        uni.showLoading({
          title: "加载中",
          mask: true,
        });
        if(this.tabType === 'specimen' && this.infoDATA.specimen && this.infoDATA.specimen[0].gdState.value == 5){
          let result = await this.validateHandoverSpecimen();
          if (result.status == 200) {
            if(result.list.length){
              // 标本-运送过程-终点科室-标本数字交接
              if(result.list[0].carryingCourses[1].checkoutMethod.value == 3){
                bigScanner = false;
              }
            }else{
              uni.showToast({
                icon: "none",
                title: "请配置标本配送任务类型！",
              });
              uni.hideLoading();
              return;
            }
          }
        }
        let type = "orderSign/" + this.code;
        let list = {
          ids: this.userId.ids,
          trueBigScanner: ['666']
        };
        bigScanner && (list.bigScanner = ['666']);
        if (accountObj) {
          list.handover = [accountObj.accountId];
        }

        post("/workerOrder/" + type, list).then((res) => {
          console.log(this.tabType)
          uni.hideLoading();
          if (res.status == 200) {
            if (this.tabType == 'specimenPlan') {
              // -----------------------------
              console.log(this.selectArr, '选中工单')
              let gd = this.infoDATA.specimenPlan.find(v => v.id == this.selectArr[0]);
              let startDeptId = gd.startDept.id; //起点科室id
              let isDigitalHandover = gd.taskType.isDigitalHandover; //是否数字交接开关
              let signDeptId = res.deptId; //签到的科室id
              let gdId = gd.id;
              let gdState = gd.gdState.value;
              let endDepts = gd.endDepts.map(v => v.id).toString();
              uni.navigateTo({
                url: `../scanning_djEnd/scanning_djEnd?type=${
                  this.tabType
                }&type1=${res.type}&code=${this.code}&dept=${
                  res.dept
                }&ids=${encodeURIComponent(
                  JSON.stringify(this.userId.ids)
                )}&model=${encodeURIComponent(JSON.stringify(res))}&accountObj=${encodeURIComponent(JSON.stringify(accountObj))}&deptId=${res.deptId}&startDeptId=${startDeptId}&isDigitalHandover=${isDigitalHandover}&signDeptId=${signDeptId}&gdId=${gdId}&gdState=${gdState}&endDepts=${endDepts}`,
              });
            } else if (this.tabType == 'specimen') {
              // 同济是false
              if (res.deptType && res.deptType.value === 'middleRoom') {
              // if (false) {
                // 如果是中转科室
                uni.navigateTo({
                  url: `../checkAfterBigScreen/checkAfterBigScreen?type=${
                  this.tabType
                }&type1=${res.type}&code=${this.code}&dept=${
                  res.dept
                }&ids=${encodeURIComponent(
                  JSON.stringify(this.userId.ids)
                )}&model=${encodeURIComponent(JSON.stringify(res))}&accountObj=${encodeURIComponent(JSON.stringify(accountObj))}&deptId=${res.deptId}`,
                });
              } else if(res.type === 'spe-dsd-4'){
                // 检验方式是标本数字交接
                uni.navigateTo({
                  url: `/pages/specimenHandoverNew/specimenHandoverNew?type=${
                  this.tabType
                }&type1=${res.type}&code=${this.code}&dept=${
                  res.dept
                }&ids=${encodeURIComponent(
                  JSON.stringify(this.userId.ids)
                )}&model=${encodeURIComponent(JSON.stringify(res))}&accountObj=${encodeURIComponent(JSON.stringify(accountObj))}&deptId=${res.deptId}`,
                });
              } else{
                uni.navigateTo({
                  url: `../scanning_djEnd/scanning_djEnd?type=${
                  this.tabType
                }&type1=${res.type}&code=${this.code}&dept=${
                  res.dept
                }&ids=${encodeURIComponent(
                  JSON.stringify(this.userId.ids)
                )}&model=${encodeURIComponent(JSON.stringify(res))}&accountObj=${encodeURIComponent(JSON.stringify(accountObj))}&deptId=${res.deptId}`,
                });
              }
            }
          } else if (res.status == "0000") {
            this.showSelectAccount();
          } else {
            this.flag = true;
            uni.navigateTo({
              url: `../scanning_djEnd/scanning_djEnd?type=${this.tabType}&type1=${
              res.type
            }&code=${this.code}&dept=${res.dept}&ids=${encodeURIComponent(
              JSON.stringify(this.userId.ids)
            )}&model=${encodeURIComponent(JSON.stringify(res))}&deptId=${res.deptId}`,
            });
          }
        });
      },
      //获取药包信息
      getInfo(responeseData, code){
        console.log(responeseData);
        uni.showLoading({
          title: "加载中",
          mask: true,
        });

        post(`/transflow/scanInfo`, {type: responeseData.drugsBagType, id: responeseData.drugsBagId, orderStateValue: responeseData.orderStateValue}).then(res => {
          uni.hideLoading();
          if(res.state == 200){
            if(res.data){
              let drugsBag = res.data.dto || {};
              let orderId = responeseData.orderId;
              let config = res.data.taskTypeConfig || {};
              console.log(res);
              if(responeseData.orderStateValue == 2 || responeseData.orderStateValue == 3 || (responeseData.orderStateValue == 4 && responeseData.workerId == uni.getStorageSync('userData').user.id)){
                // 待抢单、待接单、待到达(本人),进入起点科室流程
                uni.navigateTo({
                  url: `/pages/newDrug/createOrder/createOrder?drugsBagType=${responeseData.drugsBagType}&drugsBagId=${responeseData.drugsBagId}&orderId=${responeseData.orderId || ''}&type=receive`,
                });
              }else if(responeseData.orderStateValue == 5 && responeseData.workerId == uni.getStorageSync('userData').user.id){
                // 待送达(本人)，进入终点科室流程
                this.pageNavigateByConfig(config, responeseData, responeseData, code)
              }else{
                // 查看药包信息
                uni.navigateTo({
                  url: `/pages/newDrug/createOrder/createOrder?drugsBagType=${responeseData.drugsBagType}&drugsBagId=${responeseData.drugsBagId}&type=view`,
                });
              }
            }
          }else{
            uni.showToast({
              icon: "none",
              title: res.msg || "接口获取数据失败！",
            });
          }
        })
      },
      //获取标本打包信息
      getSpecimenPackageInfo(responeseData, code){
        console.log(responeseData);
        uni.showLoading({
          title: "加载中",
          mask: true,
        });
      
        post(`/transflow/scanInfo`, {type: responeseData.packageType, id: responeseData.data.id, orderStateValue: responeseData.orderStateValue}).then(res => {
          uni.hideLoading();
          if(res.state == 200){
            if(res.data){
              let orderId = responeseData.orderId;
              let config = res.data.taskTypeConfig || {};
              console.log(res);
              if(responeseData.orderStateValue == 2 || responeseData.orderStateValue == 3 || (responeseData.orderStateValue == 4 && responeseData.workerId == uni.getStorageSync('userData').user.id)){
                // 待抢单、待接单、待到达(本人),进入起点科室流程
                uni.navigateTo({
                  url: `/pages/specimenPackage/createOrder/createOrder?packageType=${responeseData.packageType}&packageId=${responeseData.data.id}&orderId=${responeseData.orderId || ''}&type=receive`,
                });
              }else if(responeseData.orderStateValue == 5 && responeseData.workerId == uni.getStorageSync('userData').user.id){
                // 待送达(本人),进入终点科室流程
                this.pageSpecimenPackageNavigateByConfig(config, responeseData, responeseData, code)
              }else{
                // 查看标本包信息
                uni.navigateTo({
                  url: `/pages/specimenPackage/createOrder/createOrder?packageType=${responeseData.packageType}&packageId=${responeseData.data.id}&type=view`,
                });
              }
            }
          }else{
            uni.showToast({
              icon: "none",
              title: res.msg || "接口获取数据失败！",
            });
          }
        })
      },
      // 工单完成
      completeOrder(responseData, queryObj){
        console.log(responseData, queryObj)
        uni.showLoading({
          title: "加载中",
          mask: true,
        });
        let postData = {
          "type": queryObj.drugsBagType,
          "orderId": responseData.orderId,
        };
        post('/transflow/checkComplete', postData).then(res => {
          uni.hideLoading();
          if(res.state == 200){
             uni.showToast({
               icon: "none",
               title: responseData.orderStateValue == 4 ? "交接成功，请尽快送达科室！" : (responseData.orderStateValue == 5 ? "交接成功，完成配送！" : ""),
               duration: 60000,
               mask: true,
               complete(){
                 setTimeout(() => {
                   uni.hideToast();
                   uni.redirectTo({
                     url: `/pages/receiptpage/receiptpage`,
                   });
                 }, 2000)
               }
             });
          }else{
            uni.showToast({
              icon: "none",
              title: res.msg || "接口获取数据失败！",
            });
          }
        })
      },
      // 标本打包-工单完成
      completeSpecimenPackageOrder(responseData, queryObj){
        console.log(responseData, queryObj)
        uni.showLoading({
          title: "加载中",
          mask: true,
        });
        let postData = {
          "type": queryObj.packageType,
          "packageId": responseData.dto.id,
          "orderId": responseData.orderId,
        };
        post('/transflow/checkComplete', postData).then(res => {
          uni.hideLoading();
          if(res.state == 200){
             uni.showToast({
               icon: "none",
               title: responseData.orderStateValue == 4 ? "交接成功，请尽快送达科室！" : (responseData.orderStateValue == 5 ? "交接成功，完成配送！" : ""),
               duration: 60000,
               mask: true,
               complete(){
                 setTimeout(() => {
                   uni.hideToast();
                   uni.redirectTo({
                     url: `/pages/receiptpage/receiptpage`,
                   });
                 }, 2000)
               }
             });
          }else{
            uni.showToast({
              icon: "none",
              title: res.msg || "接口获取数据失败！",
            });
          }
        })
      },
      // 根据配置跳转页面 
      pageNavigateByConfig(config, responseData, queryObj, code){
        let drugsBagType = queryObj.drugsBagType;
        let orderId = responseData.orderId;
        let drugsBagId = responseData.drugsBagId;
        let orderStateValue = responseData.orderStateValue;
        if(config.drugsModel === 1){
          // 一单一码
          if(responseData.orderStateValue == 4){
            // 待到达
            if(config.drugsStartCheck === 1){
              // 起点科室支持核对
              uni.navigateTo({
                url: `/pages/newDrug/checkPage/checkPage?drugsBagType=${drugsBagType}&orderId=${orderId}`,
              });
            }else{
              // 起点科室不支持核对
              if(config.drugsStartPhoto === 1){
                // 起点科室支持拍照留存
                uni.navigateTo({
                  url: `/pages/newDrug/photoRetention/photoRetention?drugsBagType=${drugsBagType}&orderId=${orderId}`,
                });
              }else{
                // 起点科室不支持拍照留存
                this.completeOrder(responseData, queryObj);
              }
            }
          }else if(responseData.orderStateValue == 5){
            // 待送达
            uni.showLoading({
              title: "加载中",
              mask: true,
            });
            post("/transflow/scanBind", { type: drugsBagType, orderId, code }).then((ress) => {
              uni.hideLoading();
              if (ress.state == 200) {
                if(ress.data.msg){
                  uni.showToast({
                    icon: "none",
                    title: ress.data.msg || "接口获取数据失败！",
                  });
                }else{
                  if(config.drugsEndCheck === 1){
                    // 起点科室支持核对
                    uni.navigateTo({
                      url: `/pages/newDrug/checkPage/checkPage?drugsBagType=${drugsBagType}&orderId=${orderId}`,
                    });
                  }else{
                    // 起点科室不支持核对
                    if(config.drugsEndPhoto === 1){
                      // 起点科室支持拍照留存
                      uni.navigateTo({
                        url: `/pages/newDrug/photoRetention/photoRetention?drugsBagType=${drugsBagType}&orderId=${orderId}`,
                      });
                    }else{
                      // 终点科室不支持拍照留存
                      this.completeOrder(responseData, queryObj);
                    }
                  }
                }
              } else {
                uni.showToast({
                  icon: "none",
                  title: ress.msg || "接口获取数据失败！",
                });
              }
            });
          }
        }else if(config.drugsModel === 2){
          // 一单多码
          uni.showLoading({
            title: "加载中",
            mask: true,
          });
          post("/transflow/scanBind", { type: drugsBagType, orderId, code }).then((ress) => {
            uni.hideLoading();
            if (ress.state == 200) {
              if(ress.data.msg){
                uni.showToast({
                  icon: "none",
                  title: ress.data.msg || "接口获取数据失败！",
                });
              }else{
								if(config.drugsEndCountMethod && config.drugsEndCountMethod==2){
									uni.navigateTo({
									  url: `/pages/newDrug/checkPage/checkPage?drugsBagType=${drugsBagType}&orderId=${orderId}`,
									});
								}else{
									uni.navigateTo({
									  url: `/pages/newDrug/continueScanning/continueScanning?drugsBagType=${drugsBagType}&orderId=${orderId}&drugsBagId=${drugsBagId}&orderStateValue=${orderStateValue}`,
									});
								}
              }
            } else {
              uni.showToast({
                icon: "none",
                title: ress.msg || "接口获取数据失败！",
              });
            }
          });
        }
      },
      // 标本打包-根据配置跳转页面
      pageSpecimenPackageNavigateByConfig(config, responseData, queryObj, code){
        let packageType = queryObj.packageType;
        let orderId = responseData.orderId;
        let packageId = responseData.data.id;
        let orderStateValue = responseData.orderStateValue;
        if(config.spePackageModel === 1){
          // 一单一包
          if(responseData.orderStateValue == 5){
            // 待送达
            uni.showLoading({
              title: "加载中",
              mask: true,
            });
            post("/transflow/scanBind", { type: packageType, orderId, code }).then((ress) => {
              uni.hideLoading();
              if (ress.state == 200) {
                if(ress.data.msg){
                  uni.showToast({
                    icon: "none",
                    title: ress.data.msg || "接口获取数据失败！",
                  });
                }else{
                  if(config.drugsEndCheck === 1){
                    // 终点科室支持核对
                    uni.navigateTo({
                      url: `/pages/specimenPackage/createOrder/createOrder?packageType=${packageType}&packageId=${packageId}&orderId=${orderId}&type=end`,
                    });
                  }else{
                    // 终点科室不支持核对
                    this.completeSpecimenPackageOrder(responseData, queryObj);
                  }
                }
              } else {
                uni.showToast({
                  icon: "none",
                  title: ress.msg || "接口获取数据失败！",
                });
              }
            });
          }
        }
      },
      // 底部扫描
      Scanning(qrcodePrefix = '') {
				// 起点科室-综合交接
				// this.ScanningCommon('', '1011103648');
				// 起点科室-非综合交接
				// this.ScanningCommon('', '5465456466546546565');
				// 终点科室-综合交接
				// this.ScanningCommon('', '7868686868688');
				
				// 发起中转配送
				// this.ScanningCommon('', '05ae81fc-3f07-4b8a-bbcb-53c40ede7d3d');
				
				// 快捷建单-轮巡工单码
				// this.ScanningCommon('', '3330ec8e-76eb-413e-b000-995f08d2ff96');
				
				// 中转科室码--金银湖流转中心
				// this.ScanningCommon('', '7d047a94-e102-446c-b477-94f977faaebd');
				
				// 终点科室核对码--本部住院检验科
				// this.ScanningCommon('', '95c5de27-c05f-11ea-8cfe-000c29097622');
				
        if (!this.SMFlag) {
          return;
        }
        this.SMFlag = false;
        SM().then((content) => {
          this.ScanningCommon(qrcodePrefix, content);
        }).catch(err => {
          this.SMFlag = true;
        });
      },
      //底部扫描-无须扫码
      ScanningCommon(qrcodePrefix = '', content){
        uni.showLoading({
          title: "加载中",
          mask: true,
        });
        //检验二维码的有效性(扫码前必须验证)
        post("/dept/scanning", {
            content,
          })
          .then((result) => {
            this.currentCode = result.code;
            this.SMFlag = true;
            // 200检测通过，201没有有效期也通过。
            if (result.state == 200 || result.state == 201) {
              let data = {
                code: result.code, //二维码
              };
              //微信—大扫描（科室码，患者码，标本码，快捷建单码，药包码）
              let code = result.code.includes(qrcodePrefix) ? result.code : qrcodePrefix + result.code;
              post("/workerOrder/scanCode", { code, hosId: this.hosId })
                .then((res) => {
                  uni.hideLoading();
                  if (res.status == 200) {
                    // 扫描标本码
                    if (res.type == "specimen") {
                      let infoDATA = {
                        stype: res.data.stype,
                        scode: res.data.scode,
                        patientName: res.data.patientName,
                        sickRoom: res.data.sickRoom ?
                          res.data.sickRoom.dept : "-",
                        checkDept: res.data.checkDept ?
                          res.data.checkDept.dept : "-",
                        bedNum: res.data.bedNum,
                      };
                      uni.navigateTo({
                        url: `../scanning_B/scanning_B?res=${encodeURIComponent(
                        JSON.stringify(res)
                      )}&infoDATA=${encodeURIComponent(
                        JSON.stringify(infoDATA)
                      )}`,
                      });
                    } else if (res.type == "patient") {
                      //如果是患者腕带码
                      // code: data.code //二维码
                      res.workOrder = res.workOrder ? res.workOrder : []; //liao
                      uni.navigateTo({
                        url: `../scanning_ins/scanning_ins?code=${
                        data.code
                      }&infoDATA=${encodeURIComponent(
                        JSON.stringify(res.data)
                      )}&workData=${encodeURIComponent(
                        JSON.stringify(res.workOrder)
                      )}&patientOrders=${encodeURIComponent(
                        JSON.stringify(res.patientOrders)
                      )}`,
                      });
                    } else if (res.type == "quickOrder") {
                      //快捷建单
                      if(res.data.isDigitalHandover == 1){
                        uni.navigateTo({
                          url: `../specimenChecking/specimenChecking?infoDATA=${encodeURIComponent(
                          JSON.stringify(res.data)
                        )}`,
                        });
                      }else{
                        uni.navigateTo({
                          url: `../shortcutbuildOrders/shortcutbuildOrders?infoDATA=${encodeURIComponent(
                          JSON.stringify(res.data)
                        )}`,
                        });
                      }
                    } else if (res.type == "dept") {
                      // 扫描科室码
                      // code: data.code //二维码
                      let infoDATA = res.data;
                      console.log(infoDATA)

                      if(res.sign === 'bloodTake'){
                        //新血制品-扫科室
                        uni.navigateTo({
                          url: `/pages/newBlood/startOrderSignBlood/startOrderSignBlood?deptId=${res.deptId}&deptName=${res.deptName}&taskTypeId=${res.taskTypeId}`,
                        });
                      }else if(Object.keys(infoDATA).length === 1 && (infoDATA.specimen || (infoDATA.specimenPlan && infoDATA.specimenPlan.length === 1))){
                        // 判断是否是标本配送，并且仅仅只有这一种业务类型，默认全选,并跳转到下一步;
                        // 判断是否是标本轮巡 ，并且仅仅只有这一种业务类型，并且只有一个工单，默认选中,并跳转到下一步;
                        this.infoDATA = infoDATA;
                        this.workData = infoDATA.specimen || infoDATA.specimenPlan;
                        this.tabType = infoDATA.specimen ? 'specimen' : 'specimenPlan';
                        this.code = data.code;
                        this.selectArr = [];
                        for (var i = 0; i < this.workData.length; i++) {
                          this.selectArr.push(this.workData[i].id);
                        }
                        this.userId.ids = this.selectArr;
                        this.orderDeptHandler(true);
                      }else if(res.deptHandoverType && res.deptHandoverType.value == 'clinicalWaste'){
                        // 医废
                        uni.navigateTo({
                          url: `/pages/medicalWaste/medicalWasteSignIn/medicalWasteSignIn?code=${data.code}&deptName=${res.deptName}&deptId=${res.deptId}`,
                        });
                      }else if(res.sign === 'patientIntelligentScan'){
                        // 患者陪检和患者其他服务智能扫码
                        uni.navigateTo({
                          url: `/pages/newSendBack/sendBackOrder/sendBackOrder?deptId=${res.deptId}&code=${data.code}`,
                        });
                      }else{
                        uni.navigateTo({
                          url: `../scanning_all/scanning_all?infoDATA=${encodeURIComponent(
                          JSON.stringify(infoDATA)
                        )}&code=${data.code}&deptName=${res.deptName}&deptId=${res.deptId}`,
                        });
                      }
                    } else if (res.type == 'drugsBag') {
                      if (res.drugsBagType == 'drugsJpbag' || res.drugsBagType == 'drugsWestern' || res.drugsBagType == 'drugsReturn' || res.drugsBagType == 'drugsPoison' || res.drugsBagType == 'drugsHerbal') {
                        //新药品-扫静配|西药|退药|毒麻|中草药
                        if(res.newOrderId){
                          // 待送达合并工单
                          uni.navigateTo({
                            url: `/pages/newDrug/createOrder/createOrder?drugsBagType=${res.drugsBagType}&drugsBagId=${res.drugsBagId}&orderId=${res.orderId || ''}&type=merge&newOrderId=${res.newOrderId || ''}`,
                          });
                        }else{
                          if(res.orderId){
                            // 有工单
                            this.getInfo(res, code);
                          }else{
                            // 没有工单,进入起点科室流程
                            uni.navigateTo({
                              url: `/pages/newDrug/createOrder/createOrder?drugsBagType=${res.drugsBagType}&drugsBagId=${res.drugsBagId}&type=build`,
                            });
                          }
                        }
                      }else{
                        //扫药包码
                        uni.navigateTo({
                          url: `/pages/scanning_drug/scanning_drug?drugsBagId=${res.drugsBagId}&drugsBagBatchNo=${res.drugsBagBatchNo}`,
                        });
                      }
                    } else if (res.type == 'specimenPackage') {
                      res.packageType = res.type;
                      //标本打包
                      if(res.data.status.value === '0'){
                        // 未配置状态的标本包-查看标本包信息
                        uni.navigateTo({
                          url: `/pages/specimenPackage/createOrder/createOrder?packageType=${res.packageType}&packageId=${res.data.id}&type=view`,
                        });
                      }else if(res.orderId){
                        // 有工单
                        this.getSpecimenPackageInfo(res, code);
                      }else{
                        // 没有工单,进入起点科室流程
                        uni.navigateTo({
                          url: `/pages/specimenPackage/createOrder/createOrder?packageType=${res.packageType}&packageId=${res.data.id}&type=build`,
                        });
                      }
                    } else if (res.type == 'nucleicAcid') {
                      //扫核酸码
                      uni.navigateTo({
                        url: `/pages/scanning_nucleicAcid/scanning_nucleicAcid?qrcode=${data.code}`,
                      });
                    } else if (res.type == 'blood') {
                      //扫血制品
                      // 判断size,多个则进入新页面选择
                      if(res.size > 1){
                        uni.navigateTo({
                          url: `/pages/bloodSelect/bloodSelect?qrcode=${data.code}&navigateTo=scanning_blood`,
                        });
                      } else {
                        uni.navigateTo({
                          url: `/pages/scanning_blood/scanning_blood?qrcode=${data.code}`,
                        });
                      }
                    } else if (res.type == 'receiveOrder') {
                      //扫快捷接单
                      uni.showModal({
                        title: "提示",
                        content: `您本次接单包括${res.names.join('、')}，一共含有${res.data.length}个工单，是否确认接单？`,
                        success: function(result) {
                          if (result.confirm) {
                            uni.showLoading({
                              title: "加载中",
                              mask: true,
                            });
                            post("/workerOrder/receiveOrders", {ids: res.data.toString()}).then((result) => {
                              uni.hideLoading();
                              if (result.status == 200) {
                                uni.showModal({
                                  title: "提示",
                                  content: `本次接单包括${res.names.join('、')}，${res.data.length}个工单已接单完成`,
                                  showCancel: false,
                                  success: function(res) {
                                    if (res.confirm) {
                                      console.log("用户点击确定");
                                      uni.redirectTo({
                                        url: "../receiptpage/receiptpage",
                                      });
                                    } else if (res.cancel) {
                                      console.log("用户点击取消");
                                    }
                                  },
                                });
                              } else {
                                uni.showToast({
                                  icon: "none",
                                  title: result.msg || "接口获取数据失败！",
                                });
                              }
                            });
                          } else if (result.cancel) {
                            console.log("用户点击取消");
                          }
                        },
                      });
                    } else if(res.type == 'clinicalWaste'){
                      // 医废
                      if(res.wasteDetails){
                        uni.navigateTo({
                          url: `/pages/medicalWaste/medicalWasteDetail/medicalWasteDetail?qrcode=${res.code}`,
                        });
                      }else{
                        uni.navigateTo({
                          url: `/pages/medicalWaste/medicalWasteBind/medicalWasteBind?qrcode=${res.code}`,
                        });
                      }
											// 扫描中转交接码/终点科室-综合交接
                    } else if(res.type == 'businessHandover'){
                      uni.navigateTo({
                        url: `/pages/transferConnect/transferConnect?data=${JSON.stringify(res)}`,
                      });
											// 扫描中转配送建单
                    } else if(res.type == 'quickOrderBusinessHandover'){
											uni.navigateTo({
											  url: `/pages/transferDistribution/transferDistribution?data=${JSON.stringify(res)}`,
											});
										}
                  } else {
                    if(res.bigScanSpecialMsg){
                      uni.navigateTo({
                        url: `../scanning_big_Result/scanning_big_Result?msg=${res.msg || ''}&qrcode=${this.currentCode}&bigScanSpecialMsg=${encodeURIComponent(JSON.stringify(res.bigScanSpecialMsg))}`,
                      });
                    }else{
                      uni.navigateTo({
                        url: `../scanning_Result/scanning_Result?status=${res.status}&msg=${res.msg}&qrcode=${this.currentCode}`,
                      });
                    }
                  }
                });
            } else {
              uni.hideLoading();
              uni.showToast({
                icon: "none",
                title: result.info || "接口获取数据失败！",
              });
            }
          })
      },
    },
    onShow() {
      this.SMFlag = true;
    }
  };
</script>

<style lang="less">
  // 底部扫一扫
	.fixed-class{
		position: fixed;
	}
  .toolbar {
    // position: fixed;
    left: 0;
    right: 0;
    bottom: 30rpx;
    z-index: 999;
    height: 88rpx;
    display: flex;
    justify-content: center;
    align-items: center;
    box-sizing: border-box;
    border-radius: 4rpx;
    // box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.24);
    // background-color: #e5e9ed;

    .toolbar-icon {
      font-size: 52rpx;
      margin-right: 16rpx;
      color: #07863c;
    }

    .toolbar-sao {
      font-size: 36rpx;
      color: #333;
    }
  }
</style>
