<template>
    <div class="bigBox">
        <MOSTY.FromPage :title="props.formData.title" @closeDialog="handleClose">
            <template #content>
                <!-- 三级自外 -->
                <div>
                    <MOSTY.Assort :title="onetitle">
                        <template #btn>
                            <div class="foot-back" v-if='state != "0200" && !showerinfo'>
                                <el-button @click="seeqdql" style='margin-right:20px;'>查看签到二维码</el-button>
                            </div>
                        </template>
                    </MOSTY.Assort>
                    <div>
                        <fromtemp v-if='ruleForm.id' :ruleForm='ruleForm' />
                    </div>
                    <div v-if='showqt'>
                        <MOSTY.Assort :title="qtxxtitle" />
                        <el-tabs v-model="activeName" class="demo-tabs" @tab-click="handleClicks">
                            <el-tab-pane label="考勤情况" name="01">
                                <kqqktable :id='ruleForm.id' :pxsstype='"1"' :state='state'
                                    :title="props.formData.title" :ruleForm="ruleForm" :from="props.from" />
                            </el-tab-pane>
                            <el-tab-pane label="评价情况" name="02">
                                <div class="barboxs" v-if='activeName == "02"'>
                                    <!-- <Lineone v-if='pjtitle.length > 0' :loadingshow="binshow" :ids="pxsspjqk"
                                        :barNum="pjList" :barTitle='pjtitle' :lineKey="pjkey" /> -->
                                    <Appraise :detailId="id" />
                                    <!-- <span v-else style='color:#bbb;font-size:20px;margin:auto;'>暂无评价情况</span> -->
                                </div>

                            </el-tab-pane>
                            <!-- examinationType 2:线下考试 4: 在线考试  -->
                            <el-tab-pane
                                v-if="props.formData.examinationType == 2 || props.formData.examinationType == 4"
                                label="考试情况" name="03">
                                <div style='display:flex;justify-content:space-between;' v-if='activeName == "03"'>
                                    <div class='leftks'>
                                        <AnnularPie v-if='barsShow' :data="ksqklist" :keys="cjkey" :text='kstext' />
                                        <span v-else style='color:#bbb;font-size:20px;margin:auto;'>暂无考试数据</span>
                                    </div>
                                    <div class='leftks2'>
                                        <gagues :loadingshow="barsShow" ids="fxdybsfgl" :key="keys" :barNum="kscount" />
                                    </div>

                                </div>
                                <div class="tabBox">
                                    <el-table ref="multipleTableRef" :data="list" v-loading="tableloading"
                                        element-loading-text="数据加载中..." style="width: 100%;" height="72vh" border>
                                        <el-table-column type="index" width="75" label="序号" />
                                        <el-table-column label="单位" property="orgname"></el-table-column>
                                        <el-table-column label="部门" property="depname"></el-table-column>
                                        <el-table-column label="姓名" property="name"></el-table-column>
                                        <el-table-column label="得分" property="examinationScore"></el-table-column>
                                    </el-table>
                                    <div class="fenye">
                                        <el-pagination class="pagination" @size-change="handleSizeChanges"
                                            @current-change="handleCurrentChanges"
                                            :current-page="listQuerys.pageCurrent" :page-sizes="[2, 5, 10, 20]"
                                            :page-size="listQuerys.pageSize"
                                            layout="total, prev, pager, next, sizes, jumper"
                                            :total="total"></el-pagination>
                                    </div>
                                </div>
                            </el-tab-pane>
                            <el-tab-pane label="查看附件" name="04">
                                <div style='margin-left:20px;'>
                                    <div v-if='ruleForm.planHostsDeptId == getItem("deptId").ssbmid'
                                        style='margin-top:10px;'>
                                        <el-button @click="isXgfj = !isXgfj">修改附件</el-button>
                                        <el-button v-if='isXgfj' @click="handleSeefile(ruleForm)">保存附件</el-button>
                                    </div>
                                    <MOSTY.Assort :title="'培训课件'" />
                                    <div style="margin: 10px">
                                        <MOSTY.Upload v-if='ruleForm.files || isXgfj' :widthNumber="800" :limit="5"
                                            :nopicer="true" :isImg="false" :ShowfileList="true" v-model="ruleForm.files"
                                            :gsgfList="['pdf', 'ofd', 'doc', 'docx', 'xls', 'xlsx', 'wps']"
                                            :showbut='isXgfj' :showinput="false" :delrow="delrow" :disabled='!isXgfj'>
                                        </MOSTY.Upload>
                                        <span v-else style='color:#bbb;font-size:20px;margin:auto;'>暂无培训课件附件信息</span>
                                    </div>
                                    <MOSTY.Assort :title="'培训方案附件'" />
                                    <div style="margin: 10px">
                                        <MOSTY.Upload v-if='ruleForm.pxfa || isXgfj' :widthNumber="800" :limit="5"
                                            :nopicer="true" :isImg="false" :ShowfileList="true" v-model="ruleForm.pxfa"
                                            :gsgfList="['pdf', 'ofd', 'doc', 'docx', 'xls', 'xlsx', 'wps']"
                                            :showbut='isXgfj' :showinput="false" :delrow="delrow" :disabled='!isXgfj'>
                                        </MOSTY.Upload>
                                        <span v-else style='color:#bbb;font-size:20px;margin:auto;'>暂无培训课件附件信息</span>
                                    </div>
                                    <MOSTY.Assort :title="'培训通知文件附件'" />
                                    <div style="margin: 10px">
                                        <MOSTY.Upload v-if='ruleForm.pxtzwj || isXgfj' :widthNumber="800" :limit="5"
                                            :nopicer="true" :isImg="false" :ShowfileList="true"
                                            v-model="ruleForm.pxtzwj" :showbut='isXgfj' :showinput="false"
                                            :gsgfList="['pdf', 'ofd', 'doc', 'docx', 'xls', 'xlsx', 'wps']"
                                            :delrow="delrow" :disabled='!isXgfj'></MOSTY.Upload>
                                        <span v-else style='color:#bbb;font-size:20px;margin:auto;'>暂无培训课件附件信息</span>
                                    </div>
                                    <MOSTY.Assort :title="'签到表附件'" />
                                    <div style="margin: 10px">
                                        <MOSTY.Upload v-if='ruleForm.qdb || isXgfj' :widthNumber="800" :limit="5"
                                            :nopicer="true" :isImg="false" :ShowfileList="true" v-model="ruleForm.qdb"
                                            :gsgfList="['pdf', 'ofd', 'doc', 'docx', 'xls', 'xlsx', 'wps']"
                                            :showbut='isXgfj' :showinput="false" :delrow="delrow" :disabled='!isXgfj'>
                                        </MOSTY.Upload>
                                        <span v-else style='color:#bbb;font-size:20px;margin:auto;'>暂无培训课件附件信息</span>
                                    </div>
                                    <div>
                                        <MOSTY.Assort :title="'培训过程资料'" />
                                        <div style="margin: 10px">
                                            <MOSTY.Upload v-if='ruleForm.imgs || isXgfj' :width="'100%'" :limit="5"
                                                :nopicer="false" :isImg="true" :ShowfileList="false"
                                                v-model="ruleForm.imgs" :nameshow='true' :gsgfList="['jpg', 'png']"
                                                @filehandleChange="changeFiles" :disabled='!isXgfj'>
                                            </MOSTY.Upload>
                                            <span v-else style='color:#bbb;font-size:20px;margin:auto;'>暂无培训过程资料</span>
                                        </div>
                                    </div>

                                </div>

                            </el-tab-pane>
                        </el-tabs>
                    </div>

                </div>
                <div v-if='showerinfo && state != "0200"'>
                    <MOSTY.Assort :title="'二级培训基本信息'">
                        <template #btn>
                            <div class="foot-back">
                                <el-button @click="seeqdql" style='margin-right:20px;'>查看签到二维码</el-button>
                            </div>
                        </template>
                    </MOSTY.Assort>
                    <div v-if='showerinfo'>
                        <fromtemp v-if='ejruleForm.id' :ruleForm='ejruleForm' />
                    </div>
                    <div v-if='showerqt && showerinfo'>
                        <MOSTY.Assort :title="'二级培训其他信息'" />

                        <el-tabs v-model="activeNames" class="demo-tabs" @tab-click="handleClick">
                            <el-tab-pane label="考勤情况" name="01">
                                <kqqktable :id='oldejid' :pxsstype='"1"' :state='state' :title="props.formData.title"
                                    :ruleForm="ruleForm" />
                            </el-tab-pane>
                            <el-tab-pane label="评价情况" name="02">
                                <div class="barboxs" v-if='activeNames == "02"'>
                                    <Lineone v-if='pjtitle.length > 0' :loadingshow="binshow" :ids="pxsspjqk"
                                        :barNum="pjList" :barTitle='pjtitle' :lineKey="pjkey" />
                                    <span v-else style='color:#bbb;font-size:20px;margin:auto;'>暂无评价情况</span>
                                </div>

                            </el-tab-pane>
                            <el-tab-pane label="考试情况" name="03">
                                <div style='display:flex;justify-content:space-between;' v-if='activeNames == "03"'>
                                    <div class='leftks'>
                                        <AnnularPie v-if='barsShow' :data="ksqklist" :keys="cjkey" :text='kstext' />
                                        <span v-else style='color:#bbb;font-size:20px;margin:auto;'>暂无考试数据</span>
                                    </div>
                                    <div class='leftks2'>
                                        <gagues :loadingshow="barsShow" ids="fxdybsfgl" :key="keys" :barNum="kscount" />
                                    </div>


                                </div>
                            </el-tab-pane>
                            <el-tab-pane label="查看附件" name="04">
                                <div style='margin-left:20px;'>
                                    <div v-if='ejruleForm.planHostsDeptId == getItem("deptId").ssbmid'
                                        style='margin-top:10px;'>
                                        <el-button v-if='!isXgejfj' @click="isXgejfj = !isXgejfj">修改附件</el-button>
                                        <el-button v-if='isXgejfj' @click="handleSeefile(ejruleForm)">保存附件</el-button>
                                    </div>
                                    <MOSTY.Assort :title="'培训课件'" />
                                    <div style="margin: 10px">
                                        <MOSTY.Upload v-if='ejruleForm.files || isXgejfj' :widthNumber="800" :limit="5"
                                            :nopicer="true" :isImg="false" :ShowfileList="true"
                                            v-model="ejruleForm.files" :showbut='isXgejfj' :showinput="false"
                                            :gsgfList="['pdf', 'ofd', 'doc', 'docx', 'xls', 'xlsx', 'wps']"
                                            :delrow="delrow" :disabled='!isXgejfj'></MOSTY.Upload>
                                        <span v-else style='color:#bbb;font-size:20px;margin:auto;'>暂无培训课件附件信息</span>
                                    </div>
                                    <MOSTY.Assort :title="'培训方案附件'" />
                                    <div style="margin: 10px">
                                        <MOSTY.Upload v-if='ejruleForm.pxfa || isXgfj' :widthNumber="800" :limit="5"
                                            :nopicer="true" :isImg="false" :ShowfileList="true"
                                            v-model="ejruleForm.pxfa" :showbut='isXgfj' :showinput="false"
                                            :gsgfList="['pdf', 'ofd', 'doc', 'docx', 'xls', 'xlsx', 'wps']"
                                            :delrow="delrow" :disabled='!isXgfj'></MOSTY.Upload>
                                        <span v-else style='color:#bbb;font-size:20px;margin:auto;'>暂无培训课件附件信息</span>
                                    </div>
                                    <MOSTY.Assort :title="'培训通知文件附件'" />
                                    <div style="margin: 10px">
                                        <MOSTY.Upload v-if='ejruleForm.pxtzwj || isXgfj' :widthNumber="800" :limit="5"
                                            :nopicer="true" :isImg="false" :ShowfileList="true"
                                            v-model="ejruleForm.pxtzwj" :showbut='isXgfj' :showinput="false"
                                            :gsgfList="['pdf', 'ofd', 'doc', 'docx', 'xls', 'xlsx', 'wps']"
                                            :delrow="delrow" :disabled='!isXgfj'></MOSTY.Upload>
                                        <span v-else style='color:#bbb;font-size:20px;margin:auto;'>暂无培训课件附件信息</span>
                                    </div>
                                    <MOSTY.Assort :title="'签到表附件'" />
                                    <div style="margin: 10px">
                                        <MOSTY.Upload v-if='ejruleForm.qdb || isXgfj' :widthNumber="800" :limit="5"
                                            :nopicer="true" :isImg="false" :ShowfileList="true" v-model="ejruleForm.qdb"
                                            :gsgfList="['pdf', 'ofd', 'doc', 'docx', 'xls', 'xlsx', 'wps']"
                                            :showbut='isXgfj' :showinput="false" :delrow="delrow" :disabled='!isXgfj'>
                                        </MOSTY.Upload>
                                        <span v-else style='color:#bbb;font-size:20px;margin:auto;'>暂无培训课件附件信息</span>
                                    </div>
                                    <div>
                                        <MOSTY.Assort :title="'培训过程资料'" />
                                        <div style="margin: 10px">
                                            <MOSTY.Upload v-if='ejruleForm.imgs || isXgejfj' :width="'100%'" :limit="5"
                                                :nopicer="false" :isImg="true" :ShowfileList="false"
                                                v-model="ejruleForm.imgs" :nameshow='true' :gsgfList="['jpg', 'png']"
                                                @filehandleChange="changeFiles" :disabled='!isXgejfj'>
                                            </MOSTY.Upload>
                                            <span v-else style='color:#bbb;font-size:20px;margin:auto;'>暂无培训过程资料</span>
                                        </div>
                                    </div>
                                </div>

                            </el-tab-pane>
                        </el-tabs>
                    </div>

                </div>
                <div v-if='pxsstype != "2" && !showqt && sjtype != "jc" && !showerinfo'>
                    <MOSTY.Assort :title="'二级培训信息'" />
                    <div>
                        <span style='color:#bbb;font-size:20px;'>暂无二级培训信息</span>
                    </div>
                </div>
                <div v-if='pxsstype != "2" && showqt && sjtype != "jc"'>
                    <MOSTY.Assort :title="'二级培训信息'" />
                    <div v-if='activeTitle.length > 0'>
                        <MOSTY.ElTabs v-model="activeTitle" :titleList='titleList' @handleChange='handleejClick' />
                        <div style='margin-top:10px;height: 30vh'>
                            <MOSTY.Table :table-columns="tableColumns" :tableData="ejpxlist"
                                :tableloading="tableloading" :tableHeight="'100%'" :isSelect="false"
                                style="width: 100%;" :isSort="false">
                                <template #actions="{ row }">
                                    <span class="operesee" @click='erjxq(row, "ej")'><el-icon>
                                            <View />
                                        </el-icon>查看</span>
                                </template>
                            </MOSTY.Table>
                        </div>

                    </div>

                    <div v-else>
                        <span style='color:#bbb;font-size:20px;'>暂无二级培训信息</span>
                    </div>
                </div>
                <div v-if='pxsstype != "2" && sjtype != "jc"'>
                    <MOSTY.Assort :title="'三级培训信息'" />

                    <div v-if='sjpxlist.length'>
                        <div style='margin-top:10px;height: 30vh'>
                            <MOSTY.Table :table-columns="tableColumns" :tableData="sjpxlist"
                                :tableloading="tableloading" :tableHeight="'100%'" :isSelect="false"
                                style="width: 100%;" :isSort="false">
                                <template #actions="{ row }">
                                    <span class="operesee" @click='erjxq(row, "sj")'><el-icon>
                                            <View />
                                        </el-icon>查看</span>
                                </template>
                            </MOSTY.Table>
                        </div>
                    </div>
                    <div v-else>
                        <span style='color:#bbb;font-size:20px;'>暂无三级培训信息</span>
                    </div>

                </div>
            </template>
            <template #footer>
                <el-button @click="handleClose" type="primary">
                    <el-icon>
                        <DocumentDelete />
                    </el-icon>
                    <span>关闭</span>
                </el-button>
            </template>
            <template #dwbox>
                <!-- 详情-->
                <Ewmdialoag v-model="showerw" @closezzjg="showerw = false" :pxinfo="ruleForm" from="pxssxqdia" />
                <!-- 详情 -->
                <div v-if="addDiaShowxq" class="dialog-box">
                    <sjjypxxq :id='sjid' :type='jltype' :orgcode='orgcode' @changeAddVi="changexqclose">
                    </sjjypxxq>
                </div>
            </template>
        </MOSTY.FromPage>
    </div>
</template>

<script setup>
// 引入
import { ref, onMounted, defineProps, defineEmits, reactive, watch, getCurrentInstance } from "vue";
import { getApi, postApi } from "@/api/tobAcco_api.js";
import AnnularPie from "@/views/dutyBook/jgryandzz/commponents/total/AnnularPie.vue"
import { ElMessage, ElMessageBox } from "element-plus";
import * as MOSTY from "@/components/MyComponents/index";
import { getItem } from "@/utils/storage";
import { filterqx } from "@/utils/auth.js";
import fromtemp from "./fromtemp.vue";
import Ewmdialoag from "./pxjhcoms/ewmdialoag.vue";
import kqqktable from "./kqqktable.vue";
import sjjypxxq from "./sjjypxxq.vue";
import Lineone from "./pxjhcoms/eachers/lineone.vue";
import Appraise from './appraise.vue'
import gagues from "./pxjhcoms/eachers/gauge.vue";
const ruleForm = ref({
});
const ejruleForm = ref({
});
const tableloading = ref(false)
const pjkey = ref(1)
const sjid = ref(null)
const showqt = ref(true)
const isXgejfj = ref(true)
const isXgfj = ref(false);
const showerqt = ref(true)
const addDiaShowxq = ref(false)
const kscount = ref(0);
const activeNames = ref('01')
const title = ref('')
const keys = ref(1)
const pjtitle = ref([])
const sjpxlist = ref([])//三级列表
const titleList = ref([])
const activeTitle = ref('')
const pjList = ref([])
const kstext = ref('0人' + '\n\n' + '总人数')
const binshow = ref(true);
const onetitle = ref('基础信息')
const qtxxtitle = ref('其他信息')
const orgcode = ref(null)
const cjkey = ref(1)
const activeName = ref('01')
const showerw = ref(false)
const barsShow = ref(false)
const oldejid = ref(null)//二级培训id
const ejpxlist = ref([])
const listQuery = ref({
    pageCurrent: 1,
    pageSize: 10
});
const listQuerys = ref({
    pageCurrent: 1,
    pageSize: 20,
    id: ''
})
const list = ref([])
const total = ref(0)
const state = ref(null)//实施下发状态
const pxsstype = ref(null)
const jltype = ref('')
/** {String } 类型：
 * - yj: 三级教育培训详情
 * - yj: 三级教育培训详情（一级培训）（二级未实施）
 * - ej: 三级教育培训详情（二级培训）
 * - sj: 三级教育培训详情（三级培训）
 * - jc 培训详情 */
const sjtype = ref('jc')//判断是几级培训
const showerinfo = ref(false)
/** formData.id */
const id = ref(null)
const emits = defineEmits(["changeAddVi", "changeclose"]);
//当前登录部门等级
const orgLevel = ref(JSON.parse(window.localStorage.getItem("deptId")).orgLevel.substring(0, 1))
const props = defineProps({
    formData: {
        type: Object,
        required: {}
    },
    type: String,
    /**来自的文件 */
    from: String,
});
const ksqklist = ref([
    { value: 0, name: '已合格', color: "#05a445" },
    { value: 0, name: '未合格', color: "#f9cc05" }
])
const tableColumns = ref([
    {
        title: "开始时间",
        prop: "startDate"
    },
    {
        title: "结束时间",
        prop: "finshDate"
    },
    {
        title: "培训项目名称",
        prop: "planName"
    },
    {
        title: "主办部门",
        prop: "planHostsDeptName"
    },
    {
        title: "操作",
        prop: "actions",
        slot: true
    }
])
// 初始化
onMounted(() => {
    // 计划外没有三级教育培训
    sjtype.value = props.formData.sjtype
    pxsstype.value = props.formData.type
    oldejid.value = props.formData.oldejid
    state.value = props.formData.state
    id.value = props.formData.id
    listQuerys.value.id = props.formData.id
    // 是否是安全部门
    showqt.value = true // 新需求能看详情就能看
    // if (props.formData.orgLevel) {
    //     if (filterqx('isaqbm') == '1') {
    //         //判断一级
    //         if (props.formData.orgLevel.substring(0, 1) == '1') {
    //             if (orgLevel.value == '1') {
    //                 //登陆人orgleve==1
    //                 showqt.value = true
    //             }

    //         } else if (props.formData.orgLevel.substring(0, 1) == '2') {
    //             //当前登录部门orgLevel为1、2能看
    //             if (orgLevel.value == '1' || orgLevel.value == '2') {
    //                 showqt.value = true
    //             }
    //         } else if (props.formData.orgLevel.substring(0, 1) == '3') {
    //             if (orgLevel.value == '1' || orgLevel.value == '2' || orgLevel.value == '3') {
    //                 showqt.value = true
    //             }
    //         } else if (parseInt(orgLevel.value) < parseInt(props.formData.orgLevel.substring(0, 1))) {
    //             //当前登录人的等级小于主办部门的等级
    //             showqt.value = false
    //             showerqt.value = true
    //         }
    //     } else {
    //         if (parseInt(orgLevel.value) < parseInt(props.formData.orgLevel.substring(0, 1))) {
    //             //当前登录人的等级小于主办部门的等级
    //             showerqt.value = true
    //         }
    //         showqt.value = false
    //     }
    // }

    if (pxsstype.value == '1') { //计划内详情
        getyjxqFrom()

    } else {
        getApi({ id: id.value }, '/mosty-jcgl/training/pxssInfoJhw').then((res) => {
            ruleForm.value = res;
            ruleForm.value.sffz = res.library.sffz ? res.library.sffz : ''
            ruleForm.value.examStartTime = res.library.examStartTime ? res.library.examStartTime : ''
            ruleForm.value.examEndTime = res.library.examEndTime ? res.library.examEndTime : ''
            ruleForm.value.examTime = res.library.examTime ? res.library.examTime : ''
            ruleForm.value.specialityType = ruleForm.value.specialityType.split(",");

        })
    }
    if (sjtype.value != 'jc') {
        onetitle.value = '一级培训基本信息'
        qtxxtitle.value = '一级培训其他信息'
    }
    getpjqklist()

});
const getList = () => {
    tableloading.value = true
    getApi(listQuerys.value, '/mosty-jcgl/training/signPage').then(res => {
        if (res.records) {
            list.value = res.records;
            total.value = res.total
            tableloading.value = false
        }
    })
}
function handleejClick(val) {
    orgcode.value = val.name
    // if (sjtype.value != 'jc') {
    //     erjixqData(id.value, val.name)
    // } else if (sjtype.value == 'ej') {
    //     erjixqData(oldejid.value, val.name)
    // }
    if (sjtype.value == 'ej') {
        erjixqData(oldejid.value, val.name)
    } else if (sjtype.value != 'jc') {
        erjixqData(id.value, val.name)
    }
    //获取三级培训列表
    // getsjtable(ruleForm.value.id, val.name)
}
//三级详情按钮
function erjxq(row, val) {
    if (val == 'ej') {
        jltype.value = 'ej'
    } else if (val == 'sj') {
        jltype.value = 'sj'
    }
    sjid.value = row.id
    addDiaShowxq.value = true
}
function changexqclose() {
    jltype.value = null
    sjid.value = null
    addDiaShowxq.value = false
    orgcode.value = null

}
/** 根据单位id查询二级培训详情 */
function erjixqData(id, orgcode) {
    getApi({ id: id, orgcode: orgcode }, '/mosty-jcgl/training/getEjpxById').then(res => {
        ejpxlist.value = res
        // const arr = res.filter(item => item.id)
        // Promise.all(arr.map(item => getLev3Table(item.id, item.orgCode))).then((arrRes) => {
        // })
        if (res?.[0]?.id) getsjtable(res[0].id, res[0].orgCode)
    })
}
//
function getejtable(id, orgcode) {
    getApi({ id: id, orgcode: orgcode }, '/mosty-jcgl/training/getSjpxById').then(res => {
        ejpxlist.value = res
    })
}
//根据培训id查询二级培训标题
function getyititle(id) {
    getApi({ id }, '/mosty-jcgl/training/getEjpxBt').then(res => {
        if (res.length > 0) {
            activeTitle.value = res[0].orgCode
            orgcode.value = res[0].orgCode
            titleList.value = res.map(item => {
                return { name: item.orgName, value: item.orgCode }
            })
            // if (sjtype.value != 'jc') {
            //     erjixqData(id, res[0].orgCode)
            // } else if (sjtype.value == 'ej') {
            //     erjixqData(oldejid.value, res[0].orgCode)
            // }
            if (sjtype.value == 'ej') {
                erjixqData(oldejid.value, res[0].orgCode)
            } else if (sjtype.value != 'jc') {
                erjixqData(id, res[0].orgCode)
            }
            // getsjtable(ruleForm.value.id, res[0].orgCode)
        }
    })
}
/**获取二级详情信息 */
function getsjxqFrom(id) {
    getApi({ id }, '/mosty-jcgl/training/pxssInfoJhn').then((res) => {
        if (res) {
            ejruleForm.value = res;
            ejruleForm.value.sffz = res.library.sffz ? res.library.sffz : ''
            ejruleForm.value.examStartTime = res.library.examStartTime ? res.library.examStartTime : ''
            ejruleForm.value.examEndTime = res.library.examEndTime ? res.library.examEndTime : ''
            ejruleForm.value.examTime = res.library.examTime ? res.library.examTime : ''
            ejruleForm.value.specialityType = ejruleForm.value.specialityType.split(",");
            ejruleForm.value.oldejid = oldejid.value
            getejtable(oldejid.value, res.planHostsDeptId)
            //获取三级培训列表
            getsjtable(ejruleForm.value.id, null)
        }
    })
}
//获取一级详情
function getyjxqFrom() {
    getApi({ id: id.value }, '/mosty-jcgl/training/pxssInfoJhn').then((res) => {
        ruleForm.value = res
        ruleForm.value.sffz = res.library.sffz ? res.library.sffz : ''
        ruleForm.value.examStartTime = res.library.examStartTime ? res.library.examStartTime : ''
        ruleForm.value.examEndTime = res.library.examEndTime ? res.library.examEndTime : ''
        ruleForm.value.examTime = res.library.examTime ? res.library.examTime : ''
        ruleForm.value.specialityType = ruleForm.value.specialityType.split(",");
        if (sjtype.value == 'yj') {
            //根据培训id查询二级培训标题
            getyititle(id.value)
        } else if (sjtype.value == 'ej') {
            //与创建部门相同只能看一级的基础信息和二级列表=》否则就可以看一级与二级的基础信息与其他信息
            if (ruleForm.value.planHostsDeptId == getItem("deptId").ssbmid) {
                showerinfo.value = false
            } else {
                showerinfo.value = true
                // 二级教育培训详情
                getsjxqFrom(oldejid.value)
                // getyititle(oldejid.value)
            }
        }
    })
}
function getLev3Table(id, orgcode) {
    return new Promise((resolve, reject) => {
        getApi({ id: id, orgcode }, '/mosty-jcgl/training/getSjpxById').then(res => {
            resolve(Array.isArray(res) ? res : [])
        })
    })
}
//获取三级培训表
function getsjtable(id, orgcode) {
    getApi({ id, orgcode }, '/mosty-jcgl/training/getSjpxById').then(res => {
        sjpxlist.value = res
    })
}
//查看签到签离二维码
function seeqdql() {
    showerw.value = true
}
function handleClick(val) {
    isXgfj.value = false
    isXgejfj.value = false
    if (activeNames.value == '02') {
        getpjqklist(oldejid.value)
    } else if (activeNames.value == '03') {
        getkslist(oldejid.value)
    }
}
function handleClicks(val) {
    isXgfj.value = false
    isXgejfj.value = false
    activeName.value = val.props.name
    if (activeName.value == '02') {
        getpjqklist(id.value)
    } else if (activeName.value == '03') {
        getkslist(id.value)
        getList()
    }
}
//	计划内实施-详情-评价情况统计
function getpjqklist(id) {
    getApi({ id }, '/mosty-jcgl/training/getPjStatistics').then((res) => {
        if (res) {
            pjtitle.value = res.map(item => { return item.TQuestion })
            pjList.value = res.map(it => { return Number(it.avg).toFixed(1) })
            binshow.value = true;
            pjkey.value++
        }
    })
}
//查看考试情况
function getkslist(id) {
    ksqklist.value[0].value = 0
    ksqklist.value[1].value = 0
    kscount.value = 0
    getApi({ id }, '/mosty-jcgl/training/getHgl').then((res) => {
        if (res) {
            ksqklist.value[0].value = res.hgrs ? res.hgrs : 0
            ksqklist.value[1].value = res.whgrs ? res.whgrs : 0
            kscount.value = res.pjf ? Number(res.pjf).toFixed(1) : 0
            var count = ksqklist.value[0].value + ksqklist.value[1].value
            kstext.value = `${count}人` + '\n' + '总人数'
            cjkey.value++
            keys.value++
            barsShow.value = true;

        }

    })
}

//修改附件
function handleSeefile(val) {
    let data = {}
    if (!val) return
    data.files = val.files ? val.files.toString() : ''; // 培训课件
    data.imgs = val.imgs ? val.imgs.toString() : ''; // 培训过程
    data.pxfa = val.pxfa ? val.pxfa.toString() : ''; //培训方案
    data.pxtzwj = val.pxtzwj ? val.pxtzwj.toString() : ''; //培训通知
    data.qdb = val.qdb ? val.qdb.toString() : ''; //签到表
    data.id = val.id;
    postApi(data, '/mosty-jcgl/training/pxssUpdateFile').then((res) => {
        ElMessage.success('附件修改成功');
        getyjxqFrom()
    })
    isXgejfj.value = false
    isXgfj.value = false
}




// 关闭
const handleClose = () => {
    isXgejfj.value = false
    isXgfj.value = false
    emits("changeAddVi", false);

};

// 关闭×
const closeDialog = () => {
    emits("changeAddVi", false);
    emits("changeclose", false);
};

//页码发生变化
const handleCurrentChange = (val) => {
    listQuery.value.pageCurrent = val;
    getPxjhlist();
};
//查询条数发生变化
const handleSizeChange = (val) => {
    listQuery.value.pageSize = val;
    getPxjhlist();
};
//页码发生变化
const handleCurrentChanges = (val) => {
    listQuerys.value.pageCurrent = val;
    getList();
};
//查询条数发生变化
const handleSizeChanges = (val) => {
    listQuerys.value.pageSize = val;
    getList();
};
</script>

<style lang="scss" scoped>
// ::v-deep .el-dialog__body {
//     overflow: auto !important;
//     max-height: 70vh !important;
// }

::v-deep .el-tabs__header {
    margin-bottom: 0px !important;
}

::v-deep .el-tabs__item {
    color: #000;
}

::v-deep .el-tabs__nav-scroll {
    background-color: var(--el-table-cell-bmx-backgroundcolor) !important;
}

::v-deep .el-tabs__item.is-active {
    color: var(--el-color-primary) !important;
}

::v-deep .el-tabs__active-bar {
    background-color: var(--el-color-primary) !important;
}

::v-deep .el-tabs__nav-wrap::after {
    background: none !important;
    margin-left: 21px;

}

::v-deep .el-tabs__nav {
    padding: 0 22px;
}

.sele-title {
    display: flex;
    justify-content: space-between;
    font-size: 16px;
    padding: 10px 20px;
}

.sele-titles {
    display: flex;
    justify-content: space-between;
    font-size: 16px;
    padding: 10px 20px 0px 50px;

    // >span {
    //     display: block;
    //     width: 33%;
    //     text-align: center;
    // }
}

.beiz {
    width: 100%;
    padding: 10px;
    background: #0b6047;
}

.addbtn {
    margin: 10px;
    display: flex;
    justify-content: end;
}

.barboxs {
    width: 100%;
    height: 397px;
    padding: 10px 20px;
    position: relative;
}

.leftks {
    width: 40%;
    height: 300px;
    padding: 10px 20px;
    position: relative;
}

.leftks2 {
    width: 50%;
    height: 300px;
    padding: 10px 20px;
    position: relative;
}
</style>
