<template>
  <view class="Scanning_Result_seimin">
    <view class="Scanning_top" v-if="queryObj.status == 200">
      <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>
    </view>

    <view class="Scanning_top" v-if="queryObj.status != 200">
      <view class="Scanning_top_icon">
        <text class="cubeic-close icon_transport transport-shibai"></text>
      </view>
      <view class="Scanning_top_text">
        <view class="text1"> 操作失败 </view>
      </view>
    </view>

    <view class="Scanning_cont" v-if="queryObj.status == 200">
      <view class="Scanning_cont_block"> 药包编码 : #{{ queryObj.packid }} </view>
      <view class="Scanning_cont_block" v-if="queryObj.account"> 交接人账号 : {{ queryObj.account }} </view>
      <view class="Scanning_cont_block" v-if="queryObj.accountName">
        交接人姓名 : {{ queryObj.accountName }}
      </view>
      <view class="Scanning_cont_block"> 所属科室 : {{ queryObj.targetDept || "-" }} </view>
      <!-- 药品批次列表 -->
      <table class="speTable">
        <tr>
          <td>药包号</td>
          <td>药包状态</td>
        </tr>
        <tr v-for="item in batchNoList" :key="item.id">
          <td class="maxWidth">{{item.packid || "无"}}</td>
          <td>{{item.drugsState ? item.drugsState.name : "无"}}</td>
        </tr>
      </table>
      <!-- <view class="page_item_wrap" v-for="item in batchNoList" :key="item.id">
        <view class="page_item">
          <view class="page_item_top">
            <view class="page_item_top-inner">
              <view class="page_item_top_L">
                <view class="L_text">{{item.packid || "无"}}</view>
              </view>
              <view class="page_item_top_R">
                <text>{{item.drugsState ? item.drugsState.name : "无"}}</text>
              </view>
            </view>
          </view>
          <view class="page_item_cont">
            <view class="page_item_cont_T">
              
            </view>
          </view>
          <view class="L"></view>
          <view class="R"></view>
        </view>
        <view class="L-l"></view>
        <view class="R-l"></view>
      </view> -->
    </view>
    <view class="Scanning_cont" v-if="queryObj.status != 200">
      <view class="Scanning_cont_center Scanning_cont_block">
        {{ queryObj.msg }}
      </view>
    </view>
    <view class="foot_btn">
      <view class="btn3" @click="showAlert()"> 知道了 </view>
    </view>
  </view>
</template>
<script>
import { post, webHandle } from "../../http/http.js";
export default {
  data() {
    return {
      hosId: null,
      options: {},
      queryObj: {},
      batchNoList: [],
      taskTypeConfig: {},
    };
  },
  methods: {
    // 知道了
    showAlert() {
      uni.navigateTo({
        url: "../receiptpage/receiptpage",
      });
    },
    // 判断药品页面控制-是否显示关联批次药品
    isShowDrugsBatchInfo(){
      uni.showLoading({
        title: "加载中",
        mask: true,
      });
      post("/simple/data/fetchDataList/taskType", {
        "idx": 0,
        "sum": 10,
        "taskType": {
          "simpleQuery": true,
          "hosId": {
            "id": this.hosId
          },
          "associationType": {
            "key": "association_types",
            "value": "drugsBag"
          }
        }
      }).then((res) => {
        if (res.status == 200) {
          res.list = res.list || [];
          let taskType = res.list[0] || {};
          if(taskType.id){
            post("/simple/data/fetchDataList/taskTypeConfig", {
              "idx": 0,
              "sum": 10,
              "taskTypeConfig": {
                "taskTypeDTO": {
                  "hosId": {
                    "id": this.hosId
                  },
                  "associationType": taskType.associationType
                }
              }
            }).then((res) => {
              if (res.status == 200) {
                res.list = res.list || [];
                this.taskTypeConfig = res.list[0] || {};
                if(this.taskTypeConfig.drugsBatchInfo == 1){
                  this.queryDrugsBagForBatchNo(this.queryObj.batchNo);
                }else{
                  uni.hideLoading();
                }
              } else {
                uni.hideLoading();
                uni.showToast({
                  icon: "none",
                  title: "请求失败！",
                });
              }
            });
          }else{
            uni.hideLoading();
            uni.showToast({
              icon: "none",
              title: "请配置药品业务类型！",
            });
          }
        } else {
          uni.hideLoading();
          uni.showToast({
            icon: "none",
            title: "请求失败！",
          });
        }
      });
    },
    //获取药包信息及其关联的工单信息
    queryDrugsBagForBatchNo(batchNo) {
      post("/drugsBag/fetchDataList/drugsBag", {
        "idx": 0,
        "sum": 10,
        "drugsBag": {
            "hosId": this.hosId,
            "batchNo": batchNo,
        }
      }).then((res) => {
        uni.hideLoading();
        if (res.status == 200) {
          this.batchNoList = res.list || [];
        } else {
          uni.showToast({
            icon: "none",
            title: "请求失败",
          });
        }
      });
    },
  },
  onLoad(options) {
    this.hosId = uni.getStorageSync('userData').user.currentHospital.id;
    console.log(options, "result");
    this.options = options;
    this.isShowDrugsBatchInfo();
    this.queryObj = JSON.parse(this.options.info);
    // #ifdef APP-PLUS
    webHandle("no", "app");
    // #endif
    // #ifdef H5
    webHandle("no", "wx");
    // #endif
  },
};
</script>
<style lang="less">
.Scanning_Result_seimin {
  padding: 0 20rpx;
  .speTable {
    margin: 32rpx 0;
    width: 100%;
    border-collapse: collapse;
    .green{
      color: green;
    }
    .red{
      color: red;
    }
    .maxWidth{
      width: 60%;
    }
    td{
      border: 2rpx solid #666;
    }
  }
  .page_item_wrap {
    position: relative;
    margin-top: 32rpx;
  
    .page_item {
      margin-top: 16rpx;
      margin-bottom: 124rpx;
      background: #fff;
      border-radius: 8rpx;
      margin: 0 20rpx;
      border: 2rpx solid #e5e9ed;
      position: relative;
      overflow: hidden;
      padding: 0 16rpx;
  
      .L {
        width: 40rpx;
        height: 40rpx;
        border-radius: 50%;
        background: #f9fafb;
        position: absolute;
        left: -20rpx;
        top: 68rpx;
        border: 2rpx solid #e5e9ed;
      }
  
      .R {
        width: 40rpx;
        height: 40rpx;
        border-radius: 50%;
        background: #f9fafb;
        position: absolute;
        float: right;
        right: -20rpx;
        top: 68rpx;
        border: 2rpx solid #e5e9ed;
      }
  
      .page_item_top {
        height: 88rpx;
        border-bottom: 2rpx dashed #e5e9ed;
        padding: 0 16rpx;
  
        .page_item_top-inner {
          display: flex;
          justify-content: space-between;
          align-items: center;
          height: 100%;
  
          .page_item_top_L {
            .L_text {
              font-size: 32rpx;
              font-weight: 700;
            }
          }
  
          .page_item_top_R {
            font-size: 32rpx;
  
            .L_iocn {
              color: rgb(7, 134, 60);
              font-size: 36rpx;
              font-weight: 700;
            }
          }
        }
      }
  
      .page_item_cont {
        min-height: 90rpx;
        padding: 0 16rpx;
        text-align: left;
        position: relative;
  
        .text_big {
          font-size: 32rpx;
          font-weight: 700;
          // margin-top: 10rpx;
        
          p {
            font-weight: 700;
            line-height: 1.5;
          }
        }
  
        .line {
          height: 20rpx;
          width: 2rpx;
          border-left: 2rpx solid #e5e9ed;
          position: absolute;
          top: 82rpx;
          left: 40rpx;
        }
  
        .page_item_cont_T {
          padding-top: 28rpx;
          padding-bottom: 28rpx;
          font-size: 28rpx;
  
          .page_item_cont_title {
            height: 100%;
            font-size: 32rpx;
            display: flex;
            justify-content: space-between;
            align-items: center;
          }
        }
  
        .page_item_cont_B {
          padding-top: 28rpx;
          margin-bottom: 28rpx;
  
          .page_item_cont_title {
            font-size: 32rpx;
            display: flex;
            justify-content: space-between;
            align-items: center;
          }
        }
  
        .page_item_cont_C {
          margin-bottom: 28rpx;
  
          .page_item_cont_title_C {
            font-size: 32rpx;
            display: flex;
            justify-content: space-between;
            align-items: center;
          }
        }
  
        #infos {
          display: none;
        }
      }
    }
  
    .L-l {
      width: 2rpx;
      height: 40rpx;
      background: #f9fafb;
      position: absolute;
      left: 20rpx;
      top: 72rpx;
    }
  
    .R-l {
      width: 2rpx;
      height: 40rpx;
      background: #f9fafb;
      position: absolute;
      right: 20rpx;
      top: 72rpx;
    }
  }
  .Scanning_top {
    .Scanning_top_icon {
      width: 140rpx;
      height: 140rpx;
      margin: 0 auto;
      margin-top: 116rpx;
      border-radius: 50%;
      line-height: 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;
      }

      .success_tips {
        color: red;
        font-size: 30rpx;
      }
    }
  }

  .Scanning_cont {
    font-size: 32rpx;
    text-align: center;

    .Scanning_cont_block {
      margin-bottom: 16rpx;
    }

    .Scanning_cont_center {
      text-align: center;
    }

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

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

  .foot_btn {
    position: fixed;
    bottom: 0;
    right: 20rpx;
    left: 20rpx;
    line-height: 66rpx;
    height: 100rpx;
    border-top: 2rpx solid #e5e9ed;
    background: #f9fafb;
    display: flex;
    justify-content: space-between;

    .btn1,
    .btn2,
    .btn3 {
      height: 66rpx;
      width: 100%;
      margin: 0 1%;
      background-image: linear-gradient(to right, #72c172, #3bb197);
      color: #fff;
      border-radius: 8rpx;
      font-size: 32rpx;
      margin-top: 16rpx;
      text-align: center;
    }
  }
}
</style>
