<script setup>
	/**
	 * name：
	 * user：sa0ChunLuyu
	 * date：2023年3月19日 14:00:34
	 */
	import {
		onMounted,
		ref
	} from 'vue'
	import {
		PrepareCheckReportAction,
		AnalysisTypeListAction,
		$image,
		$response
	} from '@/api'
	import {
		onShow
	} from '@dcloudio/uni-app'
	const analysis_list = ref([{
		title: '临床生化',
		list: []
	}, {
		title: '临床免疫',
		list: []
	}, {
		title: '常规',
		list: []
	}])

	const $props = defineProps({
		id_number: {
			type: String,
			default: ''
		},
		hospital: {
			type: String,
			default: ''
		}
	});

	onMounted(() => {
		GetGreySet()
		AnalysisTypeList()
	})

	const AnalysisTypeList = async () => {
		const response = await AnalysisTypeListAction()
		$response(response, () => {
			analysis_list.value = response.data.list
		})
	}

	const analysisClick = (id) => {
		uni.showLoading({
			title: '项目查询中...'
		});
		PrepareCheckReport(id)
		
	}
	//报告预检查,检查此项是否有内容，如果有则进入，没有则给出提示
	const PrepareCheckReport = async (id)=>{
		let data={id_number:$props.id_number,id:id}
		console.log(data)
		const response = await PrepareCheckReportAction(data)
		$response(response, () => {
			console.log(response)
			if(response.data.status=='ok'){
				uni.hideLoading();
				uni.navigateTo({
					url: `/pages/main/analysis_content/analysis_content?hospital=${$props.hospital}&type=1&id=${id}&id_number=${$props.id_number}`
				})
			}
		})
	}
	//设置灰度
	const SysGreyType=ref(0)
	const GetGreySet=()=>{
		uni.getStorage({
			key: 'SysGreytype',
			success: function (res) {
				console.log(res.data);
				if(res.data==1){
					SysGreyType.value=1
				}
			}
		});
	}
</script>
<template>
	<view>
		<view v-for="(i,k) in analysis_list" :key="k" :class="SysGreyType==1? 'grey' :''">
			<view class="analysis_title_wrapper">
				<view class="analysis_title_icon_wrapper">
					<image :src="$image('/storage/assets/report/report/竖线@2x.png')"></image>
				</view>
				<view class="analysis_title_text_wrapper">{{ i.title }}</view>
			</view>
			<view class="analysis_list_wrapper">
				<view @click="analysisClick(ii.id)" class="analysis_list_item_wrapper" v-for="(ii,kk) in i.list"
					:key="kk">
					<view class="analysis_list_item_icon_wrapper" :style="{
						background: ii.color
					}"></view>
					<view class="analysis_list_item_content_wrapper">
						<view class="analysis_list_item_content_title_wrapper">{{ ii.name }}</view>
						<view class="analysis_list_item_content_desc_wrapper">{{ ii.desc }}</view>
					</view>
					<view class="analysis_list_item_right_wrapper">
						<image :src="$image('/storage/assets/report/home/右箭头@2x.png')"></image>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>
<style scoped>
	.analysis_list_item_content_wrapper {
		margin-left: 31rpx;
	}

	.analysis_list_item_content_desc_wrapper {
		font-size: 22rpx;
		font-weight: 500;
		color: #939898;
		line-height: 1;
		margin-top: 18rpx;
	}

	.analysis_list_item_content_title_wrapper {
		font-size: 28rpx;
		font-weight: 500;
		color: #222222;
		line-height: 1;
	}

	.analysis_list_wrapper {
		width: 750rpx;
		background: #FFFFFF;
		border-radius: 10rpx;
		padding-bottom: 30rpx;
		padding-top: 10rpx;
	}

	.analysis_list_item_right_wrapper image {
		width: 15rpx;
		height: 26rpx;
		display: block;
	}

	.analysis_list_item_right_wrapper {
		position: absolute;
		right: 20rpx;
		top: 50%;
		transform: translateY(-50%);
		width: 15rpx;
		height: 26rpx;
	}

	.analysis_list_item_icon_wrapper {
		width: 60rpx;
		height: 60rpx;
		border-radius: 50%;
		margin-left: 11rpx;
	}

	.analysis_list_item_wrapper {
		display: flex;
		position: relative;
		width: 710rpx;
		height: 110rpx;
		background: #F3FAFA;
		box-shadow: 0px 1rpx 0px 0px rgba(22, 197, 169, 0.2);
		border-radius: 10rpx;
		margin: 10rpx auto 0;
		align-items: center;
	}

	.analysis_title_text_wrapper {
		color: #57C1B0;
		font-size: 28rpx;
		font-weight: bold;
		line-height: 1;
		margin-left: 18rpx;
	}

	.analysis_title_icon_wrapper image {
		width: 10rpx;
		height: 32rpx;
		display: block;
	}

	.analysis_title_icon_wrapper {
		width: 10rpx;
		height: 32rpx;
		margin-left: 31rpx;
	}

	.analysis_title_wrapper {
		height: 80rpx;
		display: flex;
		align-items: center;
	}
	.grey{
			   filter: grayscale(100%);   
		}
</style>
