<template>
    <div class="box_gbig">
        <div class="box_title">
            <span>{{ props.title }}</span>
            <div class="btnBox">
                <el-button type="primary" @click="CloseEvent">
                    <el-icon>
                        <CirclePlus />
                    </el-icon>
                    <span>返回</span>
                </el-button>
            </div>
        </div>
        <div class="xz_btn">
            <el-button type="primary" @click="onloadImg">
                <el-icon>
                    <Download />
                </el-icon>
                <span>下载</span>
            </el-button>
        </div>
        <div class="box_img">
            <div class="box_bg" id="htmlPdfcan">
                <div class="pic_title">
                    安&nbsp;全&nbsp;生&nbsp;产&nbsp;培&nbsp;训&nbsp;合&nbsp;格&nbsp;证&nbsp;书
                </div>
                <div class="pic_fix">
                    <div class="pic_left">
                        <img :src="getImgUrl('indexImages/zwtp.jpg')" alt="" style="height:100%;width:auto;">
                    </div>
                    <div class="pic_cent">
                        <div class="nameStyle">姓名：<span class="textStyle">{{ entity.tcperson }}</span></div>
                        <div class="titleStyle">性别：
                            <span class="textStyle">{{ entity.tcsex == '1' ? '男' : '女' }}</span>
                        </div>
                        <div class="titleStyle">身份证号：<span class="textStyle">{{ entity.tcidcard }}</span></div>
                    </div>
                    <div class="pic_right">
                        <div class="titleStyle1">证书编号：<span class="textStyle1">{{ entity.tcno }}</span></div>
                        <div class="titleStyle1">发证时间：<span class="textStyle1">{{ entity.tcbegindate }}</span></div>
                    </div>
                </div>
                <div class="trainTitleStyle">
                    培训时间：<span class="textStyle">{{ entity.jsjytime }}</span>
                </div>
                <div class="left_span">
                    <div style="width: 40%;">
                        <div class="font_div">
                            <div class="nameStyle">培训类型：<span class="textStyle">{{ entity.trainingType }}</span></div>
                            <div class="titleStyle2">成绩：<span class="textStyle">{{ entity.achievement }}分</span></div>
                            <div class="titleStyle2">岗位类别：<span class="textStyle">{{ entity.jobCategory }}</span></div>
                        </div>
                    </div>
                    <div style="width: 65%;">
                        <div class="font_div">
                            <div class="nameStyle">培训学时：<span class="textStyle">{{ entity.trainingHours }}学时</span>
                            </div>
                            <div class="titleStyle2">考核结果：<span class="textStyle">{{ entity.assessmentResults }}</span>
                            </div>
                            <div class="titleStyle2">发证单位：<span class="textStyle">{{ entity.tcawardunit }}</span></div>
                        </div>
                    </div>
                </div>
                <!-- 底部 -->
                <div class="foot">
                    <div class="imgs">
                        <img :src="getImgUrl('indexImages/yan.png')">
                    </div>
                    <div class="foot_font">中国烟草 CHINA TOBACCO
                    </div>
                </div>
                <div class="pxhgimg">
                    <img :src="getImgUrl('indexImages/QualifiedTraining.png')">
                </div>

            </div>
            <div class="box_bg2" id="attachedPages">
                <div class="pic_title">
                    安&nbsp;全&nbsp;生&nbsp;产&nbsp;培&nbsp;训&nbsp;内&nbsp;容
                </div>
                <div style="width: 620px;">
                    <div class="textstyle2">1.安全生产法律法规</div>
                    <div class="textstyle2">2.安全标准化自评</div>
                    <div class="textstyle2">3.职业病危害及防护</div>
                    <div class="textstyle2">4.隐患排查与危险源治理基本方法和措施</div>
                    <div class="textstyle2">5.如何落实企业安全生产责任制</div>
                    <div class="textstyle2">6.消防安全及安全文化建设</div>
                </div>
                <!-- 底部 -->
                <div class="foot">
                    <div class="imgs">
                        <img :src="getImgUrl('indexImages/yan.png')">
                    </div>
                    <div class="foot_font">中国烟草 CHINA TOBACCO
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>

<script setup>
import { getImgUrl } from "@/utils/tools.js"
// 引入
import { watch, onMounted, defineProps, ref, getCurrentInstance } from "vue";
import { Html2canvasImg } from '@/utils/html2pdf.js';
const { proxy } = getCurrentInstance();
// 数据
const { D_BZ_XB } = proxy.$dict("D_BZ_XB");
const entity = ref({
})
const props = defineProps({
    title: String,
    obj: Object
});
watch(
    () => props.obj,
    (val) => {
        if (val) {
            entity.value = val
        } else {
            entity.value = {
            }
        }
    }

)
const emits = defineEmits(["close"]);
const CloseEvent = () => {
    emits("close");
};

onMounted(() => {

});
function onloadImg() {
    Html2canvasImg("htmlPdfcan", "安全生产培训合格证书")
    Html2canvasImg("attachedPages", "安全生产培训内容")
}
</script>

<style lang="scss" scoped>
.btnBox {
    margin-top: 10px;
    margin-right: 10px;
}

.box_gbig {
    width: 100%;
    height: 75vh;
    overflow-y: scroll;

    .xz_btn {
        margin: 20px;
    }

    .box_title {
        height: 50px;
        border-bottom: 1px dashed #bbb1b1;
        width: 100%;
        display: flex;
        justify-content: space-between;

        >span {
            font-size: 18px;
            color: #000;
            line-height: 51px;
        }

    }

    .box_img {
        margin-top: 20px;
        display: flex;
        justify-content: space-between;

        .box_bg {
            width: 40%;
            height: 400px;
            font-family: '仿宋', monospace;
            font-weight: 600;
            overflow: hidden;
            position: absolute;
            top: 25vh;
            border: 1px solid #d3c4c4;
            border-radius: 10px;
            left: 20%;
            margin-left: -250px;
            text-align: left;
            box-sizing: border-box;
            background: url('~@/assets/images/bg.png') repeat center;
            background-size: 4% 4%;
        }

        .box_bg2 {
            width: 40%;
            height: 400px;
            font-family: '仿宋', monospace;
            font-weight: 600;
            overflow: hidden;
            position: absolute;
            top: 25vh;
            border: 1px solid #d3c4c4;
            border-radius: 10px;
            right: 10%;
            margin-left: -250px;
            text-align: left;
            box-sizing: border-box;
            background: url('~@/assets/images/bg.png') repeat center;
            background-size: 4% 4%;
        }
    }
}

.pic_title {
    text-align: center;
    color: rgb(0, 61, 141);
    font-size: 25px;
    font-family: '黑体';
    margin: 15px auto;
}

.pic_fix {
    width: 620px;
    display: flex;
    justify-content: space-between;

    .pic_left {
        width: 100px;
        height: 130px;
        display: flex;
        align-content: center;
        justify-content: center;
        overflow: hidden;
        border: 1px solid rgba(0, 0, 0, 0.1);
        margin-left: 15px;
    }

    .pic_cent {
        width: 40%;
        height: 140px;
    }

    .pic_right {
        width: 37%;
        height: 140px;
        margin-right: 10px;
    }
}

.left_span {
    width: 620px;
    display: flex;
}

.font_div {
    height: 140px;
    margin: 10px 15px auto;
}

.nameStyle {
    margin-top: 5px;
    color: rgb(0, 61, 141);
    font-size: 16px;
    font-family: '仿宋';
}

.textStyle {
    color: rgb(0, 61, 141);
    font-size: 16px;
    font-family: '仿宋';
    border-bottom: 1px solid rgb(0, 61, 141);
    padding: 0 10px 5px 10px;
}

.textStyle1 {
    color: rgb(0, 61, 141);
    font-size: 16px;
    font-family: '仿宋';
}

.titleStyle {
    margin-top: 20px;
    color: rgb(0, 61, 141);
    font-size: 16px;
    font-family: '仿宋';
}

.titleStyle1 {
    margin-top: 8px;
    color: rgb(0, 61, 141);
    font-size: 16px;
    font-family: '仿宋';
}

.trainTitleStyle {
    font-size: 18px;
    margin: 10px 12px auto;
    font-size: 16px;
    font-family: '仿宋';
    color: rgb(0, 61, 141);
}

.titleStyle2 {
    margin-top: 10px;
    color: rgb(0, 61, 141);
    font-size: 16px;
    font-family: '仿宋';
}

.textstyle2 {
    margin-top: 15px;
    color: rgb(0, 61, 141);
    font-size: 20px;
    font-family: '仿宋';
    margin-left: 31%;
}

.foot {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 50px;
    background: rgb(42, 82, 151);
    display: flex;

    .foot_font {
        font-size: 20px;
        color: white;
        font-style: italic;
        display: flex;
        justify-content: center;
        align-items: center;
    }
}

.pxhgimg {
    position: absolute;
    z-index: 999;
    height: 60px;
    right: 40px;
    top: 52%;
    margin-top: -30px;

    >img {
        width: 150px;
        height: auto;
        transform: rotate(30deg);
        -ms-transform: rotate(30deg);
        -moz-transform: rotate(30deg);
        -webkit-transform: rotate(30deg);
        -o-transform: rotate(30deg);
    }
}

.imgs {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background-color: rgb(42, 82, 151);
    display: flex;
    align-items: center;
    justify-content: center;

    >img {
        width: 50px;
        height: 50px;
        border-radius: 50%;
        margin-top: -80px;
    }
}
</style>