<template>
	<view class="custom-wrap u-padding-30">
		<view class="custom-tabs u-flex box-shadow">
			<view :class="['custom-tabs-tab', tabIndx ? '' : 'custom-tabs-tab_active']" @click="handleChangeTab(0)">
				<u-icon name="anquan" custom-prefix="custom-icon" size="80" />
				<text class="u-margin-top-20">安全生产数据</text>
			</view>
			<view :class="['custom-tabs-tab', tabIndx ? 'custom-tabs-tab_active' : '']" @click="handleChangeTab(1)">
				<u-icon name="zhiliang" custom-prefix="custom-icon" size="80" />
				<text class="u-margin-top-20">质量焊接数据</text>
			</view>
		</view>
		<u-transition :show="tabIndx === 0" name="slide-right">
			<view v-if="tabIndx == 0">
				<!-- 顶部定位数据 -->
				<ProjectCard :projectInfoData="safetySignboardData?.ProjectInfo" />
				<view style="margin-top: -60rpx; padding: 0 20rpx 40rpx">
					<template>
						<!-- 企业及分支机构人数 -->
						<OrganizerCard :orgData="safetySignboardData?.Org" :projectInfoData="safetySignboardData.ProjectInfo" />
						<!-- 危大工程数 -->
						<BigCrisisCard :dangerousProjectData="dangerousProjectData" />
						<!-- 四级风险数据 -->
						<RiskRankingCard :riskClassificationData="riskClassificationData" />
						<!-- 作业许可数 -->
						<WorkCard :licensesData="safetySignboardData?.Licenses" />
						<!-- 培训数据  -->
						<EducationCard :educationData="educationData" />
						<!-- 领导级安全检查数 -->
						<SafetyCard :hsseProblemData="hsseProblemData" :hsseProblemDataNum="hsseProblemDataNum" />
						<!-- 项目安全检查数据 -->
						<DefectTreatmentCard :hsseProblem="safetySignboardData?.HsseProblem" />
						<!-- 应急数据 -->
						<EmergencyCard :emergencyData="emergencyData" />
						<!-- 机具管理 -->
						<SpecialEquipCard :costEquipmentData="safetySignboardData?.CostEquipment" />

						<!-- 安全工时 -->
						<!-- <SafeHoursCard v-if="i === 1" /> -->

						<!-- 安全费用 -->
						<!-- <CostCard v-if="i === 5" /> -->
					</template>
				</view>
			</view>
		</u-transition>
		<u-transition :show="tabIndx === 1" name="slide-right">
			<view v-if="tabIndx == 1">
				<!-- 企业和分支机构人数 -->
				<OrgPersonCard :qmsOrgData="qualityWeldingData?.QmsOrg" />
				<!-- 人员报验、培训及交底数 -->
				<EducationCard1 :qmsEducation="qualityWeldingData?.QmsEducation" />
				<!-- 星级标准化工地建设 -->
				<!-- <StarLevelCard /> -->
				<!-- 计量器具数 -->
				<MeasuringCard :qmsMeasuringInstruments="qualityWeldingData.QmsMeasuringInstruments" />
				<!-- 设备材料及机具报验数 -->
				<EquipmentCard :qmsInspectionData="qualityWeldingData?.QmsInspection" />
				<!-- 工程划分数 -->
				<ProjectItem :projectDivisionData="projectDivisionData" />
				<!-- 领导级质量检查数 -->
				<SafetyCards :qualityProblemData="qualityProblemData" :qualityProblemDatas="qualityProblemDatas" />
				<!-- 项目质量检查数 -->
				<QualityCard :qualityProblemData="qualityWeldingData?.QualityProblem" />
				<!-- 控制点验收数 -->
				<AcceptanceData :controlPointAcceptanceData="controlPointAcceptanceData" />
				<!-- 优质工程数 -->
				<HighQuality :awardStatsData="awardStatsData" />
				<!-- QC活动数 -->
				<QCActivity :awardStatsData="awardStatsData" />
				<!-- 施工方案数 -->
				<ConstructionScheme :constructSolutionData="constructSolutionData" />
				<!-- 图纸会审及交底数 -->
				<ReviewAndBriefing :comprehensiveData="qualityWeldingData?.Comprehensive" />
				<!-- 焊接数 -->
				<WeldingData :hjData="qualityWeldingData?.HjData" />
				<!-- 报验记录 -->
				<!-- <InspectionRecord /> -->
			</view>
		</u-transition>
	</view>
</template>

<script setup>
import { defineAsyncComponent, ref, onMounted } from 'vue';
import { getSafetySignboard, getQualityWelding } from '@/api/moduleApi/index.js';
import { isLoggedIn } from '@/utils';
import { useUserStore } from '@/store';
/* 加载组件
	-------------------------------------------------------------*/
// 安全
import ProjectCard from './safe/projectCard.vue';
import SafeHoursCard from './safe/safeHoursCard.vue';
import OrganizerCard from './safe/organizerCard.vue';
import EducationCard from './safe/educationCard.vue';
import DefectTreatmentCard from './safe/defectTreatmentCard.vue';
import CostCard from './safe/costCard.vue';
import SpecialEquipCard from './safe/specialEquipCard.vue';
import BigCrisisCard from './safe/bigCrisisCard.vue';
import RiskRankingCard from './safe/riskRankingCard.vue';
import WorkCard from './safe/workCard.vue';
import SafetyCard from './safe/safetyCard.vue';
import EmergencyCard from './safe/emergencyCard.vue';
// 质量
import OrgPersonCard from './qms/orgPersonCard.vue';
import StarLevelCard from './qms/starLevelCard.vue';
import EducationCard1 from './qms/educationCard.vue';
import MeasuringCard from './qms/measuringCard.vue';
import EquipmentCard from './qms/equipmentCard.vue';
import InspectionRecord from './qms/inspectionRecord.vue';
import ProjectItem from './qms/projectItemCard.vue';
import HighQuality from './qms/highQuality.vue';
import QCActivity from './qms/QCActivity.vue';
import ConstructionScheme from './qms/constructionScheme.vue';
import ReviewAndBriefing from './qms/reviewAndBriefing.vue';
import QmsInspect from './qms/qmsInspect.vue';
import QualityCard from './qms/qualityCard.vue';
import AcceptanceData from './qms/acceptanceData.vue';
import WeldingData from './qms/weldingData.vue';
import SafetyCards from './qms/safetyCard.vue';

let userStore = useUserStore();
const safeComponent = ref([2, 7, 8, 9, 3, 11, 4, 10, 6, 1, 5]);

const tabIndx = ref(0);

const handleChangeTab = (idx) => {
	tabIndx.value = idx;
};

//总数据
let safetySignboardData = ref({});
// 危大工程数据
let dangerousProjectData = ref([]);
// 四级风险数据
let riskClassificationData = ref([]);
// 培训数据
let educationData = ref([]);
// 领导级安全检查数
let hsseProblemData = ref([]);
let hsseProblemDataNum=ref([])
// 应急数据
let emergencyData = ref([]);
const getSafetySignboardData = async () => {
	let { userInfo } = userStore;
	let res = await getSafetySignboard();
	safetySignboardData.value = res;
	// 危大工程数据
	dangerousProjectData.value = [res.DangerousProject.FinishedNum, res.DangerousProject.ConstructionNum, res.DangerousProject.OperativesNum, res.DangerousProject.TrainPersonNum];
	// 四级风险数据
	riskClassificationData.value = [
		{ name: '重大风险', value: res.RiskClassification.HighRiskNum, labelText: `重大风险:${res.RiskClassification.HighRiskNum}` },
		{ name: '较大风险', value: res.RiskClassification.MediumRiskNum, labelText: `较大风险:${res.RiskClassification.MediumRiskNum}` },
		{ name: '一般风险', value: res.RiskClassification.GeneralRiskNum, labelText: `一般风险:${res.RiskClassification.GeneralRiskNum}` },
		{ name: '低风险', value: res.RiskClassification.LowRiskNum, labelText: `低风险:${res.RiskClassification.LowRiskNum}` }
	];
	// 培训数据
	educationData.value = [res.Education.SpecialTrainNum, res.Education.SafeTrainNum, res.Education.SpecialOperationTrainNum, res.Education.HseTechnicalNum];
	// 领导级安全检查数
	//未完成
	hsseProblemData.value = [res.HsseProblem.GroupProblemNotCompletedNum, res.HsseProblem.UnitProblemNotCompletedNum + res.HsseProblem.BranchProblemNotCompletedNum];
	//总数
	hsseProblemDataNum.value = [res.HsseProblem.GroupProblemNum, res.HsseProblem.UnitProblemNum + res.HsseProblem.BranchProblemNum];
	// 应急数据
	emergencyData.value = [
		res.Emergency.CompanyComprehensivePlanNum,
		res.Emergency.CompanySpecialPlanNum,
		res.Emergency.CompanyOnSiteDisposalPlan,
		res.Emergency.CompanyDrillNum,
		res.Emergency.CompanyDrillPersonNum
	];
};
//质量看板指标
let qualityWeldingData = ref({});
//工程划分数
let projectDivisionData = ref([]);
// 领导级质量检查数
let qualityProblemData = ref([]);
let qualityProblemDatas=ref([])
// 控制点验收数
let controlPointAcceptanceData = ref({
	//关键工序、特殊过程、隐蔽工程等合格率
	QualifiedRateList: [],
	//关键工序、特殊过程、隐蔽工程等验收数
	AcceptNumList: [],
	// 关键工序、特殊过程、隐蔽工程等合格数
	QualifiedList: [],
	// 单位工程、分部工程、分项工程合格率
	EngineerQualifiedRateList: [],
	// 单位工程、分部工程、分项工程验收数
	EngineerAcceptNumList: [],
	// 单位工程、分部工程、分项工程合格数
	EngineerQualifiedList: []
});
// 优质工程
let awardStatsData = ref({
	qualityEngineering: [],
	qc: []
});
// 施工方案数
let constructSolutionData = ref([]);
const getQualityWeldingData = async () => {
	let { userInfo } = userStore;
	let res = await getQualityWelding();
	qualityWeldingData.value = res;
	console.log('质量看板指标', res);
	// 工程划分数
	projectDivisionData.value = [res.ProjectDivision.UnitProjectNum, res.ProjectDivision.SubProjectNum, res.ProjectDivision.SubdivisionalWorksNum];
	// 领导级质量检查数
	qualityProblemData.value = [res.QualityProblem.GroupProblemNum, res.QualityProblem.UnitProblemNum, res.QualityProblem.BranchProblemNum];
	qualityProblemDatas.value = [res.QualityProblem.GroupProblemNotCompletedNum, res.QualityProblem.UnitProblemNotCompletedNum, res.QualityProblem.BranchProblemNotCompletedNum];
	// 控制点验收数
	controlPointAcceptanceData.value = {
		QualifiedRateList: res.QualifiedRateList,
		AcceptNumList: res.AcceptNumList,
		QualifiedList: res.QualifiedList,
		EngineerQualifiedRateList: res.EngineerQualifiedRateList,
		EngineerAcceptNumList: res.EngineerAcceptNumList,
		EngineerQualifiedList: res.EngineerQualifiedList
	};
	// 优质工程
	Object.assign(awardStatsData.value, {
		qualityEngineering: [res.AwardStats.LubanNum, res.AwardStats.GuoyouNum, res.AwardStats.ProvinceNum, res.AwardStats.CityNum],
		qc: [res.AwardStats.QcProvinceNum, res.AwardStats.QcGroupNum, res.AwardStats.QcEnterpriseNum]
	});
	// 施工方案
	constructSolutionData.value = [
		res.ConstructSolution.ConstructSolutionNum,
		res.ConstructSolution.ConstructSolutionProjectApproveNum,
		res.ConstructSolution.ConstructSolutionUnitApproveNum
	];
	console.log('+++++++++++++', awardStatsData.value);
};
onMounted(() => {
	if (!isLoggedIn()) {
		return;
	}
	getSafetySignboardData();
	getQualityWeldingData();
});
</script>

<style lang="scss"></style>
