<script setup>
/**
 * name：
 * user：xzbg
 * date：2024年9月27日 16:01:08
 */
import { ref } from "vue";
import { $api, $response } from "@/api";
import { onShow } from "@dcloudio/uni-app";
import { useStore } from "@/store";
const $store = useStore();

let bgcx_list = ref([]); // 体检报告列表

const mountedAction = () => {
  gettjbgInfo();
};

const gettjbgInfo = async () => {
  // 获取 体检报告列表
  console.log($store, "store");
  let obj = {
    tj_status: 1,
    hospital_id: $store.save.hospital,
  };
  const response = await $api("GetReportList", obj);
  $response(response, () => {
    console.log(response, "response");
    bgcx_list.value = response.data.list;
    uni.hideLoading();
  });
};
// const bgList = ref([1, 2, 3, 4])
const selectdbObj = async (item) => {
	let tjbgList = $store.getTjbgInfo();
	if($store.setTjbgInfo?.length < 2){
		tjbgList.push(item);
	}
  $store.setTjbgInfo(tjbgList);
  // console.log(item.name)
  // 关闭当前页面携带医生名称返回上一个，，并且携带item.name
  uni.navigateBack({
    delta: 1,
  });
};

const config_ref = ref(null);
const configRef = (e) => {
  if (!config_ref.value) {
    config_ref.value = e;
    mountedAction();
  }
};

onShow(() => {
  if (!!config_ref.value) {
    mountedAction();
  }
});
</script>
<template>
  <view>
    <view v-if="!!$store.config">
      <view :ref="configRef"></view>
    </view>
    <view class="">
      <view
        style="box-shadow: 0rpx 0rpx 10rpx 0rpx rgba(0, 0, 0, 0.05)"
        class="text-24rpx text-#333 m-20rpx p-24rpx bg-#fff rounded-10rpx"
        v-for="(item, index) in bgcx_list"
        :key="index"
      >
        <view
          class="pb-30rpx text-#0E0E0E text-34rpx flex flex-justify-between"
        >
          <text class="line-clamp-1">{{ item["套餐名称"] }}</text>
          <text
            class="w-90rpx h-42rpx bg-#32A8D9 text-#fff text-24rpx rounded-rb-20rpx rounded-lt-20rpx text-center line-height-[1.6]"
            >{{ item["团检"] ? "团检" : "个检" }}</text
          >
        </view>
        <view class="pb-15rpx">
          <text class="text-#8B8B8B">体检人：</text>
          <text class="ml-25rpx">{{ item["姓名"] }}</text>
        </view>
        <view class="pb-15rpx">
          <text class="text-#8B8B8B">体检时间：</text>
          <text>{{ item["检前签到时间"]?.split("T").join(" ") }}</text>
        </view>
        <view class="pb-15rpx">
          <text class="text-#8B8B8B">报告编号：</text>
          <text>{{ item["体检号"] }}</text>
        </view>
        <view class="pb-20rpx">
          <text class="text-#8B8B8B">报告日期：</text>
          <text>{{ item["报告日期"]?.split("T").join(" ") }}</text>
        </view>

        <view
          style="border-top: 1px solid #e6e9e9"
          class="pt-20rpx flex flex-justify-end"
        >
          <view
            @click="selectdbObj(item)"
            class="bg-#33ACB5 w-200rpx rounded-5rpx text-#fff text-center line-height-[2.5]"
            >报告对比</view
          >
        </view>
      </view>
    </view>
  </view>
</template>
<style scoped></style>
