<template>
  <view class="Scanning">
    <view class="Scanning_top footerOtherMargin">
      <view class="Scanning_top_icon">
        <text class="cubeic-ok icon_transport transport-duigou"></text>
      </view>
      <view class="Scanning_top_text">
        <view class="text1"> 扫描完成 </view>
        <view class="text2">
          您已在
          <text
            style="font-weight: 600; color: rgb(73, 184, 86)"
            v-if="
              infoType == 'plan-spe-ddd-1' ||
              infoType == 'plan-spe-ddd-2' ||
              infoType == 'spe-ddd-1' ||
              infoType == 'spe-ddd-2' ||
              infoType == 'drug-ddd-2' ||
              infoType == 'jp-ddd-2'
            "
            >{{ infoDATA.startDept.dept }}</text
          >
          <text
            style="font-weight: 600; color: rgb(73, 184, 86)"
            v-if="infoType == 'drug-dsd-2' || infoType == 'jp-dsd-2'"
            >{{ infoDATA.endDepts[0].dept }}</text
          >
          <text
            style="font-weight: 600; color: rgb(73, 184, 86)"
            v-if="
              infoType == 'plan-spe-dsd-2' ||
              infoType == 'plan-spe-dsd-3' ||
              infoType == 'plan-spe-dsd-1' ||
              infoType == 'spe-dsd-2' ||
              infoType == 'spe-dsd-3' ||
              infoType == 'spe-dsd-1' ||
              infoType == 'ins-zxz-1' ||
              infoType == 'ins-dsd-1' ||
              infoType == 'trans-dsd-1' ||
              (infoType == 'qt-ddd-1' && infoDATA.gdState.value == '5') ||
              infoDATA.gdState.value == '6' ||
              infoDATA.gdState.value == '8'
            "
            >{{ DEPT }}</text
          >
          <text
            >扫描<text style="color: #ff3b53">{{ speNum }}</text> 个标本,
            确认是否继续配送或是完成工单。</text
          >
        </view>
      </view>
    </view>
    <view class="foot_btn1 footerPadding">
      <view class="btn1" @click="Scanning_again()"> 继续配送 </view>
      <view
        class="btn2"
        @click="Scanning_complete(dataId)"
        v-if="
          infoType == 'plan-spe-ddd-1' ||
          infoType == 'plan-spe-dsd-1' ||
          infoType == 'spe-ddd-1' ||
          infoType == 'spe-dsd-1'
        "
      >
        完成工单
      </view>
      <view
        class="btn2"
        @click="Scanning_complete1(dataId)"
        v-if="
          infoType == 'plan-spe-ddd-2' ||
          infoType == 'plan-spe-dsd-2' ||
          infoType == 'plan-spe-dsd-3' ||
          infoType == 'spe-ddd-2' ||
          infoType == 'spe-dsd-2' ||
          infoType == 'spe-dsd-3'
        "
      >
        完成工单
      </view>
    </view>
    <!-- 弹窗 -->
    <showModel
      :title="models.title"
      :icon="models.icon"
      :disjunctor="models.disjunctor"
      :content="models.content"
      @ok="ok"
      @cancel="cancel"
      :operate="models.operate"
    ></showModel>
  </view>
</template>
<script>
import showModel from "../../components/showModel/showModel.vue";
import { get, post, SM, webHandle } from "../../http/http.js";
export default {
  data() {
    return {
      // 弹窗model
      models: {
        disjunctor: false,
      },
      wcId: [], //完成工单id
      modelFlag: "", //弹窗标识
      infoDATA: [],
      infoType: "",
      DEPTCode: "",
      DEPT: "",
      dataId: "",
      speNum: 0,
      queryObj: {}, //路由传递过来的参数
    };
  },
  methods: {
    // 继续配送
    Scanning_again(id) {
      uni.navigateTo({
        url: "../receiptpage/receiptpage",
      });
    },
    // 确定
    ok() {
      this.models.disjunctor = false;
      if (this.modelFlag == "complete1") {
        //一对多、多对多完成工单
        let data = {
          type: this.infoType,
          ids: this.wcId,
        };
        let id = this.wcId;
        if (this.queryObj.type === "specimenPlan") {
          //标本轮巡
          post("/workerOrder/finishPlanSpes", data).then((res) => {
            if (res.status == 200) {
              uni.navigateTo({
                url: `../scanning_orderSign/scanning_orderSign?type=${
                  this.queryObj.type
                }&type1=${this.queryObj.type1}&deptCode=${
                  this.queryObj.code
                }&id=${encodeURIComponent(JSON.stringify(id))}`,
              });
            } else {
              uni.showToast({
                icon: "none",
                title: "请求失败！",
              });
            }
          });
        } else {
          post("/workerOrder/finishSpes", data).then((res) => {
            if (res.status == 200) {
              uni.navigateTo({
                url: `../scanning_orderSign/scanning_orderSign?type=${
                  this.queryObj.type
                }&type1=${this.queryObj.type1}&deptCode=${
                  this.queryObj.code
                }&id=${encodeURIComponent(JSON.stringify(id))}`,
              });
            } else {
              uni.showToast({
                icon: "none",
                title: "请求失败！",
              });
            }
          });
        }
      } else if (this.modelFlag == "complete") {
        //一对一完成工单
        let id = this.wcId;
        post("/workerOrder/finishSpeOrder", id).then((res) => {
          if (res.status == 200) {
            uni.navigateTo({
              url: `../scanning_orderSign/scanning_orderSign?type=${
                this.queryObj.type
              }&type1=${this.queryObj.type1}&deptCode=${
                this.queryObj.code
              }&id=${encodeURIComponent(JSON.stringify(id))}`,
            });
          } else {
            uni.showToast({
              icon: "none",
              title: "请求失败！",
            });
          }
        });
      }
    },
    // 取消
    cancel() {
      this.models.disjunctor = false;
    },
    //一对多、多对多完成工单
    Scanning_complete1(id) {
      this.wcId = id;
      this.modelFlag = "complete1"; //弹窗标识
      this.models = {
        disjunctor: true,
        title: "提示",
        content: "是否确定标本配送完成？",
        icon: "warn",
        operate: {
          ok: "确定",
          cancel: "取消",
        },
      };
    },
    //一对一完成工单
    Scanning_complete(id) {
      this.wcId = id;
      this.modelFlag = "complete"; //弹窗标识
      this.models = {
        disjunctor: true,
        title: "提示",
        content: "是否确定标本配送完成？",
        icon: "warn",
        operate: {
          ok: "确定",
          cancel: "取消",
        },
      };
    },
  },
  onLoad(options) {
    this.queryObj = options;
    let id = JSON.parse(options.id);
    this.dataId = id;
    this.infoType = options.type1;
    this.DEPTCode = options.deptCode;
    this.DEPT = options.dept;
    this.speNum = uni.getStorageSync("speNum");
    this.speNum = Number(this.speNum);
    // #ifdef APP-PLUS
    webHandle("no", "app");
    // #endif
    // #ifdef H5
    webHandle("no", "wx");
    // #endif
  },
};
</script>
<style lang="less">
.Scanning {
  padding: 0 20rpx;

  .Scanning_top {
    height: 340rpx;

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

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

    .Scanning_top_text {
      text-align: center;

      .text1 {
        margin-top: 40rpx;
        font-size: 48rpx;
      }

      .text2 {
        margin-top: 16rpx;
        font-size: 36rpx;
      }
    }
  }

  .page_item {
    margin-top: 16rpx;
    margin-bottom: 124rpx;
    min-height: 356rpx;
    background: #fff;
    border-radius: 8rpx;
    overflow: hidden;
    padding: 0 16rpx;
    border: 2rpx solid #e5e9ed;

    .L {
      width: 40rpx;
      height: 40rpx;
      border-radius: 50%;
      background: #f9fafb;
      position: relative;
      left: -50rpx;
      top: 66rpx;
    }

    .R {
      width: 40rpx;
      height: 40rpx;
      border-radius: 50%;
      background: #f9fafb;
      position: relative;
      float: right;
      right: -50rpx;
      top: 26rpx;
    }

    .starting {
      width: 50rpx;
      height: 50rpx;
      color: #fff;
      background: #49b856;
      display: inline-block;
      border-radius: 50%;
      text-align: center;
      line-height: 46rpx;
      font-size: 32rpx;
      margin-right: 6rpx;
    }

    .End {
      width: 50rpx;
      height: 50rpx;
      color: #fff;
      background: #39b199;
      display: inline-block;
      border-radius: 50%;
      text-align: center;
      line-height: 46rpx;
      font-size: 32rpx;
      margin-right: 6rpx;
    }

    .page_item_top {
      height: 86rpx;
      border-bottom: 2rpx dashed #e5e9ed;
      padding: 0 16rpx;

      .page_item_top_L {
        height: 100%;
        float: left;
        line-height: 88rpx;

        .emergencys {
          background: #ff3b53 !important;
          width: 124rpx !important;
        }

        .emergency {
          background: #ff3b53 !important;
        }

        .emergency1 {
          background: #49b856 !important;
        }

        .page_item_cont_start {
          text-align: center;
          height: 44rpx;
          width: 104rpx;
          line-height: 44rpx;
          border-radius: 8rpx;
          background: #49b856;
          color: #fff;
          display: inline-block;
        }

        .L_time {
          color: #6cc076;
          font-size: 32rpx;
        }

        .L_text {
          font-size: 32rpx;
          display: inline-block;
          font-weight: 700;
        }
      }

      .page_item_top_R {
        height: 60rpx;
        float: right;
        padding-top: 20rpx;
        font-size: 32rpx;
        position: absolute;
        right: 50rpx;

        .L_iocn {
          display: inline-block;
          height: 52rpx;
          line-height: 48rpx;
          color: rgb(7, 134, 60);
          font-size: 36rpx;
          font-weight: 700;
        }
      }
    }

    .page_item_cont {
      min-height: 180rpx;
      max-height: 424rpx;
      padding: 0 16rpx;
      text-align: left;
      position: relative;

      .text_big {
        font-size: 32rpx;
        position: absolute;
        right: 16rpx;
        font-weight: 700;
        margin-top: 10rpx;
      }

      .text_big2 {
        font-size: 32rpx;
        position: absolute;
        right: 16rpx;
        font-weight: 700;
      }

      .line {
        height: 20rpx;
        width: 2rpx;
        border-left: 2rpx solid #e5e9ed;
        position: absolute;
        top: 82rpx;
        left: 40rpx;
      }

      .lines {
        height: 40%;
        width: 2rpx;
        border-left: 2rpx solid #e5e9ed;
        position: absolute;
        top: 23%;
        left: 36rpx;
      }

      .page_item_cont_T {
        padding-top: 28rpx;
        font-size: 28rpx;

        .page_item_cont_title {
          height: 100%;
          font-size: 32rpx;
        }
      }

      .page_item_cont_B {
        padding-top: 28rpx;
        margin-bottom: 28rpx;

        .page_item_cont_title {
          height: 60rpx;
          font-size: 32rpx;
        }

        .page_item_cont_title1 {
          height: 60rpx;
          line-height: 60rpx;
          font-size: 32rpx;
          padding-left: 64rpx;
        }
      }
    }

    .page_item_foot {
      border-top: 2rpx dashed #e5e9ed;
      border-bottom: 2rpx dashed #e5e9ed;
      padding: 28rpx 16rpx;
      text-align: left;

      .page_item_foot_text {
        font-size: 32rpx;
        margin-bottom: 20rpx;

        .text1 {
          color: rgb(102, 102, 102);
        }

        .text2 {
          float: right;
          font-weight: 700;
        }
      }

      .text_padd {
        padding: 0 10% 0 10%;
      }
    }

    #infos {
      display: none;
    }

    .page_item_infos {
      padding-bottom: 20rpx;
      border-bottom: 2rpx dashed #e5e9ed;

      .page_item_info2 {
        text-align: left;
        line-height: 60rpx;
        font-size: 32rpx;
        padding-left: 16rpx;

        .page_item_foot_text {
          font-size: 32rpx;
          margin-bottom: 20rpx;

          .text1 {
            color: rgb(102, 102, 102);
          }

          .text2 {
            float: right;
            font-weight: 700;
          }
        }
      }
    }
  }

  .foot_btn1 {
    position: fixed;
    bottom: 0;
    right: 20rpx;
    left: 20rpx;
    line-height: 66rpx;
    height: 100rpx;
    border-top: 2rpx solid #e5e9ed;
    background: #f9fafb;
    text-align: center;

    view {
      height: 66rpx;
      width: 45%;
      background-image: linear-gradient(to right, #72c172, #3bb197);
      color: #fff;
      border-radius: 8rpx;
      font-size: 32rpx;
      margin-top: 16rpx;
    }

    .btn1 {
      float: left;
    }

    .btn2 {
      float: right;
    }
  }
}
</style>
