<template>
  <view class="Scanning_djInfo">
    <view class="Scanning_top" v-if="res.status == 200">
      <view class="Scanning_top_icon">
        <view v-if="type == 'specimenPlan' || type == 'specimen'">
          <view class="fweight speNum" style="color: red;"> {{ speNum }} </view>
        </view>
        <text v-else class="cubeic-ok newicon newicon-duigou"></text>
      </view>
      <view class="Scanning_top_text">
        <view class="text1">操作成功</view>
      </view>
    </view>

    <view class="Scanning_top" v-if="res.status == 11111">
      <view class="Scanning_top_icon">
        <text class="cubeic-close newicon newicon-shibai"></text>
      </view>
      <view class="Scanning_top_text">
        <view class="text1" style="color: red;">操作失败</view>
      </view>
    </view>

    <view class="Scanning_top" v-if="
        res.status == 10005 ||
        res.status == 100018 ||
        res.status == 500 ||
        res.status == 10004 ||
        res.status == 100021 ||
        res.status == 100020 ||
        res.status == 100019 ||
        res.status == 100031
      ">
      <view class="Scanning_top_icon">
        <text class="cubeic-close newicon newicon-shibai"></text>
      </view>
      <view class="Scanning_top_text">
        <view class="text1">操作失败</view>
        <view class="text1 f30" v-if="queryObj.qrcode !== undefined">扫描内容：{{queryObj.qrcode}}</view>
      </view>
    </view>
    <view class="Scanning_cont" v-if="(res.status != 200 || res.msg != '成功！') && res.status != 11111">
      <view>{{ res.msg }}</view>
    </view>
    <view class="Scanning_cont" v-if="
        (res.status == 200 && type == 'specimenPlan') ||
        (res.status == 200 && type == 'specimen')
      ">
      <view>{{ infoDATA.data.stype.name }}（{{infoDATA.data.scode}}）</view>
      <view>检验项目 : {{ infoDATA.data.specimenDesc || "-" }}</view>
      <view>
        {{ infoDATA.data.sickRoom ? infoDATA.data.sickRoom.dept : "" }}
        <text style="width: 4em;text-align: center;margin-left: 1em;margin-right: 1em;" class="newicon newicon-arrow-right-full"></text>
        <text :class="{ red: isEndDeptRedShow }">{{ infoDATA.data.checkDept ? infoDATA.data.checkDept.dept : "" }}</text>
      </view>
      <view>患者姓名 : {{ infoDATA.data.patientName}}（{{infoDATA.data.bedNum}}）</view>
      <view>住院号 : {{ infoDATA.data.residenceNo || '-' }}</view>
    </view>
    <view class="Scanning_cont" v-if="
        (res.status == 11111 && type == 'specimenPlan') ||
        (res.status == 11111 && type == 'specimen')
      ">
      <view>{{ infoDATA.data.stype.name }}（{{infoDATA.data.scode}}）</view>
      <view>检验项目 : {{ infoDATA.data.specimenDesc || "-" }}</view>
      <view>标本状态 : <text style="color: red">{{ infoDATA.data.speState ? infoDATA.data.speState.name : '' }}</text></view>
      <view>
        {{ infoDATA.data.sickRoom ? infoDATA.data.sickRoom.dept : "" }}
        <text style="width: 4em;text-align: center;margin-left: 1em;margin-right: 1em;" class="newicon newicon-arrow-right-full"></text>
        <text :class="{ red: isEndDeptRedShow }">{{ infoDATA.data.checkDept ? infoDATA.data.checkDept.dept : "" }}</text>
      </view>
      <view>患者姓名 : {{ infoDATA.data.patientName}}（{{infoDATA.data.bedNum}}）</view>
      <view>住院号 : {{ infoDATA.data.residenceNo || '-' }}</view>
    </view>
    <view class="Scanning_cont" v-if="
        (res.status == 200 && type == 'inspect') || type == 'patientTransport'
      ">
      <view v-if="infoDATA.patient">患者姓名 : {{ infoDATA.patient || "-" }}</view>
      <view v-if="infoDATA.patient">住院号 : {{ infoDATA.residenceNo || "-" }}</view>
      <view v-if="infoDATA.patient">住院科室 : {{ infoDATA.deptName || "-" }}</view>
      <view v-if="infoDATA.patient">床号 : {{ infoDATA.bedNum || "-" }}</view>
      <view v-if="infoDATA.data">
        检查项目 :
        <text v-for="(data, i) in infoDATA.data" :key="i">{{ data.inspectName }},</text>
      </view>
      <view v-if="
          infoType == 'ins-dsd-1' ||
          infoType == 'trans-dsd-1' ||
          infoDATA.type == 'trans-dsd-1'
        ">工单已完成</view>
      <view v-if="infoDATA.type == 'ins-half-ok'">已到达检查科室，工单已完成。</view>
    </view>
    <view class="Scanning_cont" v-if="
        (res.status == 200 && type == 'drugsBag') ||
        (res.status == 200 && type == 'jPBag')
      ">
      <view> 药包类型 : {{(infoDATA.data.packType && infoDATA.data.packType !== 0) ? DRUGSBAG_TYPE[infoDATA.data.packType] : "-"}} </view>
      <view v-if="type == 'drugsBag'">药包编码 : #{{ infoDATA.data.packid }}</view>
      <view v-if="type == 'jPBag'">静配编码 : #{{ infoDATA.data.packid }}</view>
      <view>所属科室 : {{ infoDATA.data.target.dept }}</view>
      <view v-if="
          accountObj && (infoType === 'drug-ddd-2' || infoType === 'drug-dsd-2')
        ">
        交接人工号 : {{ accountObj.account }}
      </view>
      <view v-if="
          accountObj && (infoType === 'drug-ddd-2' || infoType === 'drug-dsd-2')
        ">
        交接人姓名 : {{ accountObj.accountName }}
      </view>
      <text v-if="infoType == 'drug-dsd-2' || infoType == 'jp-dsd-2'">工单已完成。</text>
      <view class="red"> 如果您当前科室还有药包需要扫描，请点击“继续扫描”！ </view>
    </view>

    <view class="foot_btn_spe" v-if="
        res.status == 100018 || type == 'specimen' || type == 'specimenPlan'
      ">
      <view class="btn1" @click="Scanning_again()">继续扫描</view>
      <view class="btn3" @click="hand_again()" v-if="type == 'specimen' || type == 'specimenPlan'">手动录入</view>
      <view class="btn3" @click="getNoScanSpecimen(false)" v-if="type == 'specimen' || type == 'specimenPlan'">未扫描标本</view>
      <view class="btn3" @click="getNoScanSpecimen(true)" v-if="type == 'specimen' || type == 'specimenPlan'">已扫描标本</view>
      <view class="btn2" @click="Scanning_complete(ids)">完成扫描</view>
    </view>
    <view class="foot_btn" v-if="
        type != 'specimen' &&
        res.status != 200 &&
        type != 'specimenPlan' &&
        type !== 'drugsBag' &&
        type !== 'jPBag' &&
        type !== 'patientTransport'
      ">
      <view class="btn3" @click="showAlert()">返回</view>
    </view>
    <view class="foot_btn" v-if="
        (res.status != 200 && type == 'drugsBag') ||
        (res.status != 200 && type == 'jPBag') ||
        (res.status != 200 && type == 'patientTransport')
      ">
      <view class="btn3" @click="Scanning_again()">继续扫描</view>
      <view class="btn3" @click="showAlert()" v-if="type == 'drugsBag'">返回</view>
    </view>
    <view class="foot_btn" v-if="
        res.status == 200 &&
        type != 'specimen' &&
        type != 'specimenPlan'
      ">
      <view class="btn3" @click="Scanning_again()" v-if="
          (res.status == 200 && type == 'drugsBag') ||
          (res.status == 200 && type == 'jPBag')
        ">继续扫描</view>
      <view class="btn3" @click="showAlert()">返回</view>
    </view>
    <!-- 弹窗 -->
    <showModel :title="models.title" :icon="models.icon" :disjunctor="models.disjunctor" :content="models.content"
      @ok="ok" @cancel="cancel" :operate="models.operate"></showModel>
    <!-- 弹窗 -->
    <showModel :title="models2.title" :icon="models2.icon" :disjunctor="models2.disjunctor" :content="models2.content"
      @ok="ok2" @know="know2" @cancel="cancel2" :operate="models2.operate">
    </showModel>
    <!-- 手动查询标本弹窗 -->
    <handViewSpecimen v-if="speModels.disjunctor" :title="speModels.title" :disjunctor="speModels.disjunctor"
      @ok="speOk" @cancel="speCancel">
    </handViewSpecimen>
		<!-- 调查问卷二维码 -->
		 <questionCode v-if="isQuestionModel" :orderId="gdId" @know="isQuestionModel = false"></questionCode>
		<!-- PDA扫描 -->
		<scanner></scanner>
	</view>
</template>
<script>
  import showModel from "../../components/showModel/showModel.vue";
	import scanner from "../../components/scanner/scanner.vue";
	import questionCode from "../../components/questionCode/questionCode.vue";
  import {
    get,
    post,
    SM,
    webHandle
  } from "../../http/http.js";
  import {
    DRUGSBAG_TYPE
  } from '../../tools/enum.drugsbagType.js';
  export default {
		components:{
			questionCode,
			scanner
		},
    data() {
      return {
        // 终点科室标红
        isEndDeptRedShow: false,
        isEndDeptRed: false,
				// 调研二维码
				isQuestionModel:false,
				gdId:null,
        DRUGSBAG_TYPE,
        currentCode: '', //当前小扫描的科室二维码
        // 手动查询标本弹窗model
        speModels: {
          disjunctor: false,
        },
        // 交接人信息
        accountObj: undefined,
        //传给后端查询是否继续扫描
        deptId: undefined,
        SMFlag: true,
        // 弹窗model
        models: {
          disjunctor: false,
        },
        // 完成扫描弹窗model1
        models2: {
          disjunctor: false,
        },
        wcId: "", //工单完成ID
        wcFlag: false,
        infoDATA: [],
        res: {
          status: "",
          msg: "",
        },
        infoType: "",
        DEPTCode: "",
        RESData: {},
        DEPT: "",
        dataId: "",
        type: "",
        model: {},
        idsType: 1,
        packid: "",
        speNum: 0,
        queryObj: {}, //路由传递过来的参数
        gotoFlag: true,
        content: "",
      };
    },
    methods: {
      // 手动查询标本-确认
      speOk(data) {
        console.log(data);
        if (!data.id) {
          //没有查询到标本
          uni.showModal({
            title: '提示',
            content: "没有查询到标本！",
            showCancel: false,
            success: function(res) {
              if (res.confirm) {
                console.log('用户点击确定');
              } else if (res.cancel) {
                console.log('用户点击取消');
              }
            }
          });
          return;
        }
        this.speModels.disjunctor = false;
        this.hand_scanning_common(data.scode, 'hand');
      },
      // 手动查询标本-取消
      speCancel() {
        this.speModels.disjunctor = false;
      },
      // 手动查询标本弹窗
      showHandViewSpecimen() {
        this.speModels = {
          title: '填写标本编码',
          disjunctor: true,
        }
      },
      // 手动录入标本
      hand_again() {
        this.showHandViewSpecimen();
      },
      // 手动输入标本和扫码公共方法
      hand_scanning_common(ress1, type) {
        let list = [];
        let postType = "";
        let ids = [];
        if (this.ids && this.ids[0]) {
          ids = this.ids;
        } else if (this.dataId) {
          ids = [];
          ids.push(this.dataId);
        }
        let data = {
          ids: ids,
          deptCode: this.DEPTCode,
          code: "", // 2
        };
        // ----------------
        uni.showLoading({
          title: "加载中",
          mask: true,
        });
        //检验二维码的有效性
        post("/dept/scanning", {
          content: ress1,
        }).then((result) => {
          this.SMFlag = true;
          this.currentCode = result.code;
          if (result.state == 200 || result.state == 201) {
            let ress = result.code;
            if (ress) {
              data.code = ress;
              if (this.type == "inspect") {
                postType = "handleIns";
                list = data;
              }
              if (this.type == "jPBag" || this.type == "drugsBag") {
                postType = "handleDrugsAndJp";
                data["type"] = this.infoType;
                list = data;
                if (this.accountObj) {
                  list.handover = this.accountObj.accountId;
                }
                list.deptId = this.deptId;
                if(this.type == "drugsBag"){
                  delete list.ids;
                }
              }
              if (this.type == "specimen") {
                postType = "handleSpes";
                data["speCode"] = data.code;
                delete data.code;
                data["type"] = this.infoType;
                list = data;
                if (this.accountObj) {
                  list.handover = this.accountObj.accountId;
                }
              }
              if (this.type == "specimenPlan") {
                postType = "handlePlanSpes";
                data["speCode"] = data.code;
                delete data.code;
                data["type"] = this.infoType;
                list = data;
                if (this.accountObj) {
                  list.handover = this.accountObj.accountId;
                }
              }
              if (this.type == "patientTransport") {
                postType = "handleTrans";
                list = data;
              }
              post("/workerOrder/" + postType, list).then((res) => {
                uni.hideLoading();
                if (res.status == 200 || res.status == 11111) {
                  //标本和标本轮巡工单，扫描标本后会自动调用摄像头，继续扫描，直到status不是200
                  if ((this.type == "specimenPlan" || this.type == "specimen") && res.status != 11111) {
                    this.getPageConfigSpecimen((flag, type, res) => {
                      if(flag){
                        if (type === 'scan') {
                          setTimeout(()=>{
														// #ifdef H5
														this.Scanning_again();
														// #endif
                          },500)
                        } else if (type === 'hand') {
                          this.hand_again();
                        }
                      }
                      if(res){
                        this.isEndDeptRedShow = this.isEndDeptRed;
                        this.infoDATA = res;
                        this.speNum = res.specimenCount;
                        this.res["status"] = res.status;
                        this.res["msg"] = res.msg;
                      }
                    }, type, res.data, res);
                    return;
                  }
                  if (
                    this.type == "inspect" ||
                    this.type == "patientTransport"
                  ) {
                    if (res.ids) {
                      for (var i = 0; i < this.ids.length; i++) {
                        if (this.ids[i] == res.ids[0]) {
                          this.ids.splice(i, 1);
                        }
                      }
                      if (this.ids.length > 1) {
                        this.idsType = 1;
                      } else {
                        this.idsType = 2;
                      }
                    }
                    this.infoDATA = res;
                    this.type = this.type;
                    this.DEPTCode = this.DEPTCode;
                  } else if (this.type == "drugsBag") {
                    // this.infoDATA.data.packid = res.data.packid;
                    this.infoDATA = res;
                    this.res["status"] = res.status;
                    this.res["msg"] = res.msg;
                  } else if (
                    this.type == "specimenPlan" ||
                    this.type == "specimen"
                  ) {
                    this.infoDATA = res;
                    this.speNum = res.specimenCount;
                    // --------------------------
                    this.res["status"] = res.status;
                    this.res["msg"] = res.msg;
                    // --------------------------
                  } else if (this.type == "jPBag") {
                    // this.infoDATA.data.packid = res.data.packid;
                    this.infoDATA = res;
                    this.res["status"] = res.status;
                    this.res["msg"] = res.msg;
                  } else {
                    uni.navigateTo({
                      url: `../scanning_djEnd/scanning_djEnd?type=${
                      this.queryObj.type
                    }&type1=${this.queryObj.type1}&code=${
                      this.queryObj.deptCode
                    }&dept=${this.queryObj.dept}&ids=${encodeURIComponent(
                      JSON.stringify(this.ids)
                    )}&model=${encodeURIComponent(
                      JSON.stringify(res)
                    )}&accountObj=${encodeURIComponent(
                      JSON.stringify(this.accountObj)
                    )}&deptId=${this.deptId}`,
                    });
                  }
                } else {
                  uni.navigateTo({
                    url: `../scanning_djEnd/scanning_djEnd?type=${
                    this.queryObj.type
                  }&type1=${this.queryObj.type1}&code=${
                    this.queryObj.deptCode
                  }&dept=${this.queryObj.dept}&ids=${encodeURIComponent(
                    JSON.stringify(this.ids)
                  )}&model=${encodeURIComponent(
                    JSON.stringify(res)
                  )}&speNum=${this.speNum}&accountObj=${encodeURIComponent(
                    JSON.stringify(this.accountObj)
                  )}&deptId=${this.deptId}&scanOrHand=${type}&qrcode=${this.currentCode}`,
                  });
                }
              });
            }
          } else {
            uni.hideLoading();
            uni.showToast({
              icon: "none",
              title: result.info || "接口获取数据失败！",
            });
          }
        });
        // ------------------------------
      },
      // 查看未扫描标本
      // isScan true已扫描标本，false未扫描标本
      getNoScanSpecimen(isScan) {
        if (!this.gotoFlag) {
          return;
        }
        this.gotoFlag = false;
        if(isScan){
          uni.navigateTo({
            url: `../noScanSpecimen/noScanSpecimen?deptName=${this.queryObj.dept}&workOrderId=${encodeURIComponent(JSON.stringify(this.queryObj.ids))}&deptCode=${this.queryObj.deptCode}&isScan=1`,
          });
        }else{
          uni.navigateTo({
            url: `../noScanSpecimen/noScanSpecimen?deptName=${this.queryObj.dept}&workOrderId=${encodeURIComponent(JSON.stringify(this.queryObj.ids))}&deptCode=${this.queryObj.deptCode}`,
          });
        }
      },
      overFinish() {
        let postType = "";
        if (
          this.queryObj.type1 === "plan-spe-ddd-2" ||
          this.queryObj.type1 === "plan-spe-dsd-2" ||
          this.queryObj.type1 === "plan-spe-dsd-3"
        ) {
          postType = "finishPlanSpes";
        } else if (this.queryObj.type1 == "spe-ddd-2") {
          postType = "finishSpes";
        }
        let data = {
          type: this.queryObj.type1,
          ids: this.wcId,
        };
        post("/workerOrder/" + postType, data).then((res) => {
          if (res.status == 200) {
            this.models2 = {
              disjunctor: true,
              title: "提示",
              content: `完成扫描成功`,
              icon: "success",
              operate: {
                know: "返回",
              },
            };
          } else {
            uni.showToast({
              icon: "none",
              title: res.msg || "接口获取数据失败！",
            });
          }
        });
      },
      // 确定
      ok() {
        this.models.disjunctor = false;
        let postData = {
          ids: this.queryObj.ids,
          sign: true,
          deptQrCode: this.queryObj.deptCode,
        };
        uni.showLoading({
          title: "加载中",
          mask: true,
        });
        post("/workerOrder/expectedAndActual", postData).then((ress) => {
          uni.hideLoading();
          if (ress.status == 200) {
            if (this.wcFlag) {
              //正常完成扫描
              this.overFinish();
            } else {
              this.gotoOver();
            }
          } else if (ress.status == 1000035) {
            let content = "";
            if (
              this.queryObj.type1 === "spe-ddd-2" ||
              this.queryObj.type1 === "plan-spe-ddd-2"
            ) {
              //待到达
              content =
                `系统内预计标本<strong class="red">${ress.expectReceiveNum}</strong>只，您扫描收取标本<strong class="red">${ress.actualReceiveNum}</strong>只，其中<strong class="red">${ress.notReceiveNum}</strong>只未扫描；`;
            } else {
              //待送达
              this.content = `本工单已签到<strong class="red">${
              ress.scanSet ? ress.scanSet.join("、") : ""
            }</strong>，剩余需签到科室<strong class="red">${
              ress.notScanSet ? ress.notScanSet.join("、") : ""
            }</strong>，总签收<strong class="red">${
              ress.totalAcceptance
            }</strong>只，剩余<strong class="red">${
              ress.notAcceptance
            }</strong>只未签收，您确定完成工单吗？`;
              content =
                `您在<strong class="red">${ress.deptName}</strong>检验科扫描了<strong class="red">${ress.deptScanNum}</strong>个标本，还需扫描<strong class="red">${ress.deptNotScanNum}</strong>标本。`;
            }
            // 取消弹窗 2022年10月10日
            this.ok2();
            // this.models2 = {
            //   disjunctor: true,
            //   title: "提示",
            //   content,
            //   icon: "warn",
            //   operate: {
            //     ok: "确定",
            //     cancel: "取消",
            //   },
            // };
          } else {
            uni.showToast({
              icon: "none",
              title: ress.msg || "接口获取数据失败！",
            });
          }
        });
      },
      // 取消
      cancel() {
        this.models.disjunctor = false;
      },
      // 确定
      ok2() {
        this.models2.disjunctor = false;
        let postData = {
          ids: this.queryObj.ids,
          deptQrCode: this.queryObj.deptCode,
        };
        uni.showLoading({
          title: "加载中",
          mask: true,
        });
        post("/workerOrder/expectedAndActual", postData).then((ress) => {
          uni.hideLoading();
          if (ress.status == 200) {
            if (this.wcFlag) {
              this.overFinish();
            } else {
              this.gotoOver();
            }
          } else {
            uni.showToast({
              icon: "none",
              title: ress.msg || "接口获取数据失败！",
            });
          }
        });
      },
      // 取消
      cancel2() {
        this.models2.disjunctor = false;
      },
      know2() {
        this.models2.disjunctor = false;
        uni.navigateTo({
          url: "../receiptpage/receiptpage",
        });
      },
      //完成扫描
      Scanning_complete(id) {
        // 如果是标本配送和标本轮巡,则进入标本核对页面
        if((this.type === 'specimen' || this.type === 'specimenPlan') && this.queryObj.type1.includes('ddd')){
          uni.navigateTo({
            url: `../checkAfterScanning/checkAfterScanning?id=${id}&type=${this.queryObj.type}&type1=${this.queryObj.type1}&dept=${this.queryObj.dept}&deptId=${this.queryObj.deptId}&deptCode=${this.queryObj.deptCode}&speNum=${this.speNum}&content=${this.content}`,
          });
          return;
        }
        this.wcId = id;
        if (
          this.queryObj.type1 == "plan-spe-ddd-2" ||
          this.queryObj.type1 == "spe-ddd-2"
        ) {
          this.wcFlag = true;
          this.models = {
            disjunctor: true,
            title: "提示",
            content: "是否确定标本已扫描完成?",
            icon: "warn",
            operate: {
              ok: "确定",
              cancel: "取消",
            },
          };
        } else if (
          this.queryObj.type1 == "plan-spe-dsd-2" ||
          this.queryObj.type1 == "plan-spe-dsd-3" ||
          this.queryObj.type1 == "spe-dsd-2" ||
          this.queryObj.type1 == "spe-dsd-3"
        ) {
          this.wcFlag = false;
          this.models = {
            disjunctor: true,
            title: "提示",
            content: "是否确定标本已扫描完成？",
            icon: "warn",
            operate: {
              ok: "确定",
              cancel: "取消",
            },
          };
        } else {
          this.gotoOver();
        }
      },
      // 跳转完成工单页面
      gotoOver() {
        if(this.queryObj.type === 'specimenPlan'){
          uni.navigateTo({
            url: `../specimenCheckingEnd/specimenCheckingEnd?type=${this.queryObj.type}&type1=${
            this.queryObj.type1
          }&id=${encodeURIComponent(JSON.stringify(this.wcId))}&deptCode=${
            this.queryObj.deptCode
          }&dept=${this.queryObj.dept}&content=${this.content}`,
          });
        }else{
          uni.navigateTo({
            url: `../scanning/scanning?type=${this.queryObj.type}&type1=${
            this.queryObj.type1
          }&id=${encodeURIComponent(JSON.stringify(this.wcId))}&deptCode=${
            this.queryObj.deptCode
          }&dept=${this.queryObj.dept}&content=${this.content}`,
          });
        }
      },
      // 继续扫描
      Scanning_again() {
        if (!this.SMFlag) {
          return;
        }
        this.SMFlag = false;
        SM()
          .then((ress1) => {
            this.hand_scanning_common(ress1, 'scan');
          })
          .catch((err) => {
            this.SMFlag = true;
          });
      },
			// pda扫描
			pdaChange(content){
				content = content.replace('\n','')
				this.hand_scanning_common(content, 'scan');
			},
      // 返回
      showAlert() {
        uni.navigateTo({
          url: "../receiptpage/receiptpage",
        });
      },
			// 获取问卷配置
			getQuestionnaireSet(){
				uni.showLoading({
				  title: "加载中",
				  mask: true,
				});
				const userData = uni.getStorageSync("userData");
				post("/simple/data/fetchDataList/questionnaireConfig",{
					questionnaireConfig:{
						hosId:userData.user.currentHospital.id
					},
					idx:0,
					sum:10
				}).then((res) => {
				  uni.hideLoading();
				  if (res.status == 200) {
				    let data = res.list[0];
						let taskTypeId = this.infoDATA.workOrderList[0].taskType.id
						if(data.taskTypeDTOS.length>0 && data.questionnaireDTOS.length>0){
							let isQuestion = data.taskTypeDTOS.find(i=> i.id == taskTypeId)
							if(isQuestion){
								this.isQuestionModel = true
							}
						}
				  } else {
				    uni.showToast({
				      icon: "none",
				      title: res.msg || "接口获取数据失败！",
				    });
				  }
				});
			},
      // 页面控制-标本
      getPageConfigSpecimen(fn, type, specimenDTO, ress){
        const userData = uni.getStorageSync("userData");
        console.log('userData', userData);
        console.log('specimenDTO', specimenDTO);
        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) => {
                uni.hideLoading();
                if (res.status == 200) {
                  let data = res.list[0];
              		if(data){
                    let deptNotAlertList = data.deptNotAlertList || [];
                    deptNotAlertList = deptNotAlertList.map(v => v.id);
                    if(deptNotAlertList.includes(specimenDTO.checkDept.id)){
                      this.isEndDeptRed = true;
                      console.log('红色')
                      fn(false, type, ress);
                    }else{
                      this.isEndDeptRed = false;
                      fn(true, type, ress);
                    }
                    console.log('this.isEndDeptRed', this.isEndDeptRed);
                  }else{
                    this.isEndDeptRed = false;
                    fn(true, type, ress);
                  }
                } 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 || "接口获取数据失败！",
            });
          }
        });
      },
    },
    onShow() {
      this.SMFlag = true;
      this.gotoFlag = true;
			let that = this;
			// #ifdef APP-PLUS
			uni.$off('scan') // 每次进来先 移除全局自定义事件监听器
			uni.$on('scan', function(data) {
				that.pdaChange(data)
			})
			// #endif
    },
    onLoad(options) {
      this.isEndDeptRedShow = options.isEndDeptRed === 'true';
      if (options.status == 200&&options.scanOrHand === 'hand'&&(options.type === "specimen"||options.type === "specimenPlan")) {
        this.getPageConfigSpecimen((flag) => {
          if(flag){
            this.hand_again();
          }
        });
      }
      console.log(options, "options");
      if (options.speNum) {
        this.speNum = options.speNum;
      }
      if (options.accountObj && options.accountObj != "undefined") {
        this.accountObj = JSON.parse(options.accountObj);
      }
      if (options.deptId && options.deptId != "undefined") {
        this.deptId = options.deptId;
      }
      this.queryObj = options;
      if (this.queryObj.model) {
        let list = JSON.parse(this.queryObj.model);
        this.infoDATA = list;
      } else {
        this.infoDATA = this.queryObj.infoData;
      }
			console.log(this.infoDATA, "22222");
      this.RESData = this.queryObj.resData;
      this.res["status"] = this.queryObj.status;
      this.res["msg"] = this.queryObj.msg;
      this.res["patient"] = this.queryObj.patient;
      this.infoType = this.queryObj.type1;
      if (this.queryObj.dept) {
        this.DEPT = this.queryObj.dept;
      }
      this.queryObj.ids = JSON.parse(this.queryObj.ids);
      if (this.queryObj.ids) {
        this.ids = this.queryObj.ids;
        if (this.ids.length > 1) {
          this.idsType = 1;
        } else {
          this.idsType = 2;
        }
      }
      this.DEPTCode = this.queryObj.deptCode;
      this.type = this.queryObj.type;
			this.taskTypeId = options.taskTypeId
			if(options.workOrderList && options.workOrderList!="undefined" && options.workOrderList!=undefined){
				this.infoDATA.workOrderList = JSON.parse(options.workOrderList)
			}
			if(this.queryObj.ids&&this.queryObj.ids.length>0){
				this.gdId = this.queryObj.ids[0]
			}else{
				this.gdId = this.infoDATA.workOrderList[0].id
			}
			if((this.res.status == 200 && this.type == 'inspect') || this.type == 'patientTransport'){
				if(this.infoType == 'ins-dsd-1' ||
					this.infoType == 'trans-dsd-1' ||
					this.infoDATA.type == 'trans-dsd-1' ||
					this.infoDATA.type == 'ins-half-ok'){
						this.getQuestionnaireSet()
					}
			}

			if(
			(this.res.status == 200 && this.type == 'drugsBag') ||
			(this.res.status == 200 && this.type == 'jPBag')){
				if(this.infoType == 'drug-dsd-2' || this.infoType == 'jp-dsd-2'){
					this.getQuestionnaireSet()
				}
			}
      // #ifdef APP-PLUS
      webHandle("no", "app");
      // #endif
      // #ifdef H5
      webHandle("no", "wx");
      // #endif
    },
  };
</script>
<style lang="less">
  .Scanning_djInfo {
    padding: 0 20rpx;

    .Scanning_top {
      min-height: 270rpx;

      .red {
        background-color: #ff3b53 !important;
      }

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

        .speNum{
          text-align: center;
          font-size: 140rpx;
        }

        .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;
      text-align: center;

      view {
        margin-bottom: 16rpx;
      }

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

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

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

      .btn1,
      .btn2,
      .btn3 {
        height: 88rpx;
        margin: 0 1%;
        flex: 1;
        background-image: linear-gradient(to right, #72c172, #3bb197);
        color: #fff;
        border-radius: 8rpx;
        font-size: 32rpx;
        margin-top: 16rpx;
      }
    }
    .foot_btn_spe {
      line-height: 88rpx;
      height: 100rpx;
      margin-top: 40rpx;
      text-align: center;
      display: flex;
      justify-content: space-between;
      flex-wrap: wrap;

      &::after {
        content: '';
        flex: 1;
      }

      view {
        height: 88rpx;
        width: 48%;
        margin: 0 1%;
        background-image: linear-gradient(to right, #72c172, #3bb197);
        color: #fff;
        border-radius: 8rpx;
        font-size: 32rpx;
        margin-top: 16rpx;
      }
    }
  }
</style>
