<template>
  <scroll-view scroll-y class="pharmacyDetails">
    <view class="page_item footerOtherMargin">
      <view class="page_header" v-for="(item, index) in resultList" :key="item.bindId">
        <view class="page_header_item" v-if="item.modifyReason">
          <view class="page_header_title"> 修改原因: </view>
          <view class="page_header_content">
            {{ item.modifyReason }}
          </view>
        </view>
        <view class="page_header_item" v-if="item.imgs && item.imgs.length">
          <view class="page_header_title"> 图片列表: </view>
          <view class="page_header_content">
            <image v-for="(item, i) in item.imgs" :key="i" :src="item" @click="previewImage(index, i)" mode="widthFix"
              @error="close(index, i)"></image>
          </view>
        </view>
      </view>
      <view class="page_item_wrap" v-for="spe in specimens" :key="spe.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">{{ spe.scode }}<text v-if="spe.stype">({{spe.stype.name}})</text></view>
              </view>
              <view class="page_item_top_R">
                <text :style="{color:spe.urgent == 1?'red':'green'}">{{spe.urgent == 1 ? "急" : "普"}}</text>
              </view>
            </view>
          </view>
          <view class="page_item_cont">
            <view class="page_item_cont_T">
              <view class="page_item_cont_title">
                <view> 检验项目 </view>
                <view class="text_big">{{ spe.specimenDesc || "无" }}</view>
              </view>
              <view class="page_item_cont_title">
                <view> 患者姓名 </view>
                <view class="text_big">{{ spe.patientName }}<text v-if="spe.bedNum">({{spe.bedNum}})</text></view>
              </view>
              <view class="page_item_cont_title">
                <view> 住院号 </view>
                <view class="text_big">{{spe.residenceNo||'无'}}</text></view>
              </view>
              <view class="page_item_cont_title">
                <view class="text_big">{{
                  spe.sickRoom ? spe.sickRoom.dept : "无"
                }}</view>
                <text style="width: 4em;text-align: center;" class="icon_transport transport-arrow-right-full"></text>
                <view class="text_big">{{
                  spe.checkDept ? spe.checkDept.dept : "无"
                }}</view>
              </view>
            </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="foot_btn2 footerPadding">
      <view class="btn2" @click="goBack">返回</view>
    </view>
  </scroll-view>
</template>
<script>
  import {
    post,
    get,
    webHandle
  } from "../../http/http.js";
  export default {
    data() {
      return {
        resultList: [],
        imgs: [],
        queryObj: {}, //路由传递过来的数据
        specimens: [],
        modifyReason: '',
      };
    },
    methods: {
      previewImage(index, i) {
        //uniapp预览轮播图
        uni.previewImage({
          current: i, //预览图片的下标
          urls: this.resultList[index].imgs, //预览图片的地址,必须要数组形式,如果不是数组形式就转换成数组形式就可以
        });
      },
      close(index, i) {
        this.resultList[index].imgs.splice(i, 1);
      },
      getInfo() {
        let postData = {
          deptId: this.queryObj.endDeptId,
          gdId: this.queryObj.workOrderId,
        };
        post(`/api/getStartDeptSpecimensNum`, postData).then(async (res) => {
          if (res.status == 200) {
            for (let i = 0; i < res.data.length; i++) {
              let result = await get(`/common/common/listAttachment/specimenPhotos/${res.data[i].bindId}`);
              if (result.status == 200) {
                res.data[i].imgs = result.data.map((v) => v.previewUrl);
              } else {
                res.data[i].imgs = [];
              }
            }
            this.resultList = res.data;
          }
        });
      },
      // 返回
      goBack() {
        uni.navigateBack();
      },
      // 获取标本信息
      getDetail() {
        let postData = {
          gdId: this.queryObj.workOrderId,
          endDeptId: this.queryObj.endDeptId,
        };
        
        uni.showLoading({
          title: "加载中",
          mask: true,
        });
        post("/api/endDeptReceiveSpecimens", postData).then((res) => {
          uni.hideLoading();
          if (res.status == 200) {
            this.specimens = res.data;
          } else {
            uni.showToast({
              icon: "none",
              title: res.msg || "接口获取数据失败!",
            });
          }
        });
      },
    },
    onLoad(options) {
      console.log(options);
      this.queryObj = options;
      this.getDetail();
      this.getInfo();
      // #ifdef APP-PLUS
      webHandle("no", "app");
      // #endif
      // #ifdef H5
      webHandle("no", "wx");
      // #endif
    },
  };
</script>
<style lang="less" scoped>
  .pharmacyDetails {
    background-color: rgb(249, 250, 251);
    padding-top: 50rpx;
    height: 100%;
    box-sizing: border-box;
    
    .page_header {
      margin: 20rpx;
      padding: 16rpx;
      border: 2rpx solid #e5e9ed;
      background: #fff;
      border-radius: 8rpx;
    
      .page_header_item {
        margin-bottom: 16rpx;
    
        .page_header_title {
          margin-bottom: 8rpx;
          font-weight: bold;
        }
    
        .page_header_content {
          display: flex;
    
          image {
            height: 100rpx;
            width: 30%;
            margin: 0 8rpx;
          }
        }
      }
    }

    .pharmacyDetails_title {
      font-size: 46rpx;
      font-weight: 550;
      text-align: center;
    }

    .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;
      }
    }

    .cube-toolbar-item {
      width: 710rpx;
      height: 68rpx;
      line-height: 68rpx;
      position: fixed;
      left: 20rpx;
      bottom: 160rpx;
      border-radius: 8rpx;
      background: linear-gradient(to right, #72c172, #3bb197);
      font-size: 36rpx;
      color: #fff;
      text-align: center;
    }

    .btn-wrap {
      display: flex;
      justify-content: space-between;
      position: fixed;
      left: 20rpx;
      bottom: 160rpx;
    }

    .cube-toolbar-item1 {
      width: 350rpx;
      height: 68rpx;
      line-height: 68rpx;
      border-radius: 8rpx;
      margin: 0 5rpx;
      background: linear-gradient(to right, #72c172, #3bb197);
      font-size: 36rpx;
      color: #fff;
      text-align: center;
    }

    .foot_btn2 {
      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;

      .btn2 {
        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;
      }

      .btn3 {
        height: 66rpx;
        width: 48%;
        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>