<template>
	<view class="djTaskDetail">
		<!-- 代煎作业质控标题 -->
		<view class="djTaskDetail_progress">
			<text class="djTaskDetail_progress_title">任务进度：<text class="djTaskDetail_progress_text">{{props.dpWcCount+'/'+props.dpCyCount}}</text></text>
			<text class="djTaskDetail_progress_title">不合格数<text class="djTaskDetail_progress_text">{{bhgNumber()}}</text></text>
		</view>
		<!-- 代煎表格 -->
		<view v-if="props.dpTaskList.length!=0">
			<uni-table class="djDetail_table">
				<!-- 表头行 -->
				<uni-tr>
					<uni-th align="center" width="155rpx">处方编号</uni-th>
					<uni-th align="center" width="150rpx">贴数(贴)</uni-th>
					<uni-th align="center" width="155rpx">平均误差(%)</uni-th>
				</uni-tr>
				<!-- 表格数据行 -->
				<uni-tr v-for="(item, index) in props.dpTaskList" :key="index" @click="toDetail(item)">
					<uni-td align="center">{{item.ptwybm}}</uni-td>
					<uni-td align="center">{{item.ts}}</uni-td>
					<uni-td align="center">{{item.wc}}
						<uni-icons type="right"></uni-icons>
					</uni-td>
				</uni-tr>
			</uni-table>
		</view>
		<view v-else>
			<dataEmpty></dataEmpty>
		</view>
		<!-- 开始质控 -->
		<view class="finish_button"
			v-if="props.taskStatus!='7004' && props.taskStatus!='7007' && props.taskStatus!='7008' && props.taskStatus!='7009' && props.taskStatus!='7010'">
			<button class="button" @click="startTask()">开始质控</button>
		</view>
	</view>
</template>

<script setup>
import http from '@/utils/request';
import { reactive,ref } from "vue";
import {onLoad,onShow,onUnload,onPullDownRefresh} from "@dcloudio/uni-app";
import dataEmpty from "@/pages/ypczk/zkTask/zkTaskDetail/noStartTaskDetail.vue";

const props = defineProps({
	// 代配质控详情列表
	dpTaskList:  Array,
	// 代配不合格数
	dpbhg:String,
	// 任务状态
	taskStatus:String,
	// 代配抽样数量
	dpCyCount:String,
	// 代配完成数量
	dpWcCount:String,
});

// 开始质控
const startTask=()=>{
	uni.$emit("startTaskInfo")
}

// 跳转详情界面
const toDetail=(e)=>{
	uni.navigateTo({
		url:"/pages/ypczk/zkTask/dpTask?status=get"+'&ptwybh='+e.ptwybm+'&fyfslx=3'+'&cfbh='+e.cfbh+'&id='+e.id+'&taskStatus='+props.taskStatus
	})
}

// 代配不合格数
const bhgNumber=()=>{
	let number=0
	props.dpTaskList.forEach(item=>{
		if (item.cfbhg == 1  || item.mxbhg > 0){
			number ++;
		}
	})
	return number
}

</script>

<style lang="scss" scoped>
@import './index.scss'
</style>
