<template>
    <el-collapse v-model="activeNames">
        <el-collapse-item
            title="核查办理"
            name="verify"
            v-if="negative.checkStatusCode"
        >
            <div class="row">
                <div class="col col-12">
                    <label>核查结论</label>
                    <span>{{ negative.checkStatusName }}</span>
                </div>
                <div class="col col-6" v-if="negative.isRectifyName">
                    <label>是否整改</label>
                    <span>{{ negative.isRectifyName }}</span>
                </div>
                <div class="col col-6" v-if="negative.accountabilityTarget">
                    <label>追责对象</label>
                    <span>{{
                        getDictLable(
                            dict.accountabilityTarget,
                            negative.accountabilityTarget
                        )
                    }}</span>
                </div>
                <div class="col col-6" v-if="negative.rectifyRestrictionDays">
                    <label>整改限制</label>
                    <span>{{ `${negative.rectifyRestrictionDays}天` }}</span>
                </div>

            </div>
            <div class="row" v-if="negative.checkStatusDesc">
                <div class="col col-24">
                    <label>问题核查情况</label>
                    <span>{{ negative.checkStatusDesc }}</span>
                </div>
            </div>
            <div class="row" v-if="negative.rectifyDesc">
                <div class="col col-24">
                    <label>问题整改情况</label>
                    <span>{{ negative.rectifyDesc }}</span>
                </div>
            </div>
            <div class="row" v-if="negative.unrectifyReason">
                <div class="col col-24">
                    <label>问题未整改原因</label>
                    <span>{{ negative.unrectifyReason }}</span>
                </div>
            </div>
        </el-collapse-item>
        <el-collapse-item
            title="信访情况"
            name="mail"
            v-if="
                negative.problemSourcesCode === ProblemSources.GJXFPT ||
                negative.problemSourcesCode === ProblemSources.GABXF ||
                negative.problemSourcesCode === ProblemSources.JZXX ||
                negative.problemSourcesCode === ProblemSources.XF12337
            "
        >
            <div class="row" >
                <div class="col col-24" v-if="negative.handlePolices.length > 0">
                    <label>经办人</label>
                    <span>
                        <div v-for="item in negative.handlePolices" :key="item" class="mr-20">
                            <span class="mr-8">{{ item.name }}</span>
                            <span class="text-primary">{{ item.empNo }}</span>
                        </div>
                    </span>
                </div>
                <div class="col col-24" v-if="negative.visitingLeaderName">
                    <label>接访领导</label>
                    <span>{{ negative.visitingLeaderName }} {{ negative.visitingLeaderEmpNo }}</span>
                </div>
                <div class="col col-6" v-if="negative.resolveSituation">
                    <label>化解情况</label>
                    <span>{{ negative.resolveSituation }}</span>
                </div>
                <div class="col col-6" v-if="negative.resolveStatus">
                    <label>当前状态</label>
                    <span>{{ negative.resolveStatus }}</span>
                </div>
                <div class="col col-6" v-if="negative.handleResult12337">
                    <label>处理结论结果</label>
                    <span>{{ negative.handleResult12337Group }} - {{ negative.handleResult12337 }}</span>
                </div>
                <div class="col col-6" v-if="negative.verifiedIsLeader">
                    <label style="line-height: 1.1">涉及人员是否属于领导班子成员</label>
                    <span>{{ negative.verifiedIsLeader }}</span>
                </div>
                <div class="col col-6" v-if="negative.processResult">
                    <label>办理结果</label>
                    <span>{{ negative.processResult }}</span>
                </div>
                <div class="col col-24" v-if="negative.disciplinaryActionDesc">
                    <label>处分处理情况</label>
                    <span>{{ negative.disciplinaryActionDesc }}</span>
                </div>
            </div>
        </el-collapse-item>
        <el-collapse-item
            v-for="(blame, index) in negative.blames.filter(
                (item) => item.type === BlameType.PERSONAL
            )"
            :key="index"
            :title="`涉及人员${index + 1}`"
            :name="`involved${index}`"
        >
            <div class="row">
                <div class="col col-6">
                    <label>涉及人员姓名</label>
                    <span>
                        <span>{{ blame.blameName }}</span>
                        <span class="text-primary ml-10">{{ blame.blameEmpNo }}</span>
                    </span>
                </div>
                <div class="col col-6">
                    <label>身份证</label>
                    <span>{{ blame.blameIdCode }}</span>
                </div>
                <div class="col col-6">
                    <label>人员属性</label>
                    <span>{{
                        getDictLable(dict.personType, blame.ivPersonTypeCode)
                    }}</span>
                </div>
            </div>
            <div
                class="row"
                v-for="(problem, index) in blame.problems"
                :key="index"
            >
                <div class="col col-24">
                    <label>问题类型{{ index + 1 }}</label>
                    <span
                        >{{ problem.oneLevelContent }} /
                        {{ problem.twoLevelContent }} /
                        {{ problem.threeLevelContent }}
                        {{ problem.threeLevelContent === '其他' && problem.threeLevelContentOther ? `(${problem.threeLevelContentOther})` : ''}}
                        </span
                    >
                </div>
            </div>
            <div class="row">
                <div class="col col-6" v-if="blame.responsibilityTypeName">
                    <label>责任类别</label>
                    <span>{{ blame.responsibilityTypeName }}</span>
                </div>
                <div class="col col-6" v-if="blame.subjectiveAspectCode">
                    <label>主观方面</label>
                    <span>{{ blame.subjectiveAspectName }}</span>
                </div>
                <div class="col col-6" v-if="blame.handleResultCode">
                    <label>处置结果</label>
                    <span>
                        <span>{{ blame.handleResultName }}</span>
                        <span v-if="blame.handleResultNameOther">({{ blame.handleResultNameOther }})</span>
                    </span>
                </div>
                <div class="col col-6" v-if="blame.protectRightsName">
                    <label>维权容错</label>
                    <span>{{ blame.protectRightsName }}</span>
                </div>
                <div class="col col-6" v-if="blame.superviseMeasuresCode">
                    <label>督察措施</label>
                    <span>{{ blame.superviseMeasuresName }}</span>
                </div>

            </div>
            <div class="row">

              <div class="col col-12" v-if="blame.ConfinementData">
                <label>禁闭时间</label>
                <span >{{blame.ConfinementData.startTime+ "   -   " + blame.ConfinementData.endTime}}</span>
              </div>
              <div class="col col-4" v-if="blame.ConfinementData">
                <label>禁闭时长（天）</label>
                <span >{{blame.ConfinementData.confinementTime}}</span>
              </div>
              <div class="col col-24" v-if="blame.ConfinementData">
                <label>禁闭措施</label>
                <span>{{blame.ConfinementData.matter}}</span>
              </div>
            </div>
            <div v-perms="['negative:score']">
                <div
                    class="row"
                    v-for="item in negative.scorePolices.filter(
                        (item) => blame.blameIdCode === item.idCode
                    )"
                    :key="item"

                >
                    <div class="col col-6">
                        <label>问题分值</label>
                        <span
                            style="color: var(--danger-color)"
                            class="text-bold"
                            >{{ item.score }}</span
                        >
                    </div>
                    <div class="col col-6">
                        <label>公式</label>
                        <span>{{ item.expression }}</span>
                    </div>
                </div>
            </div>
            <div class="row" style="background: #f5f5f5">
                <div class="col col-6">
                    <label>涉及领导姓名</label>
                    <span v-if="blame.leadName">{{ blame.leadName }} {{ blame.leadEmpNo }}</span>
                    <span v-else>/</span>
                </div>
                <div class="col col-6">
                    <label>身份证</label>
                    <span>{{ blame.leadIdCode || '/' }}</span>
                </div>

                <div class="col col-6" v-if="blame.leadResponsibilityTypeName">
                    <label>责任类别</label>
                    <span>{{ blame.leadResponsibilityTypeName }}</span>
                </div>
                <div class="col col-6" v-if="blame.leadMeasuresCode">
                    <label>督察措施</label>
                    <span>{{ blame.leadMeasuresName }}</span>
                </div>
                <div class="col col-6" v-if="blame.leadHandleResultCode">
                    <label>处置结果</label>
                    <span>
                        <span>{{ blame.leadHandleResultName }}</span>
                        <span v-if="blame.leadHandleResultNameOther">({{ blame.leadHandleResultNameOther }})</span>
                    </span>
                </div>

            </div>
          <div class="row" style="background: #f5f5f5" v-if="blame.leadConfinement">
            <div class="col col-12"v-if="blame.leadConfinement" >
              <label>禁闭时间</label>
              <span >{{blame.leadConfinement.startTime+ "   -   " + blame.leadConfinement.endTime}}</span>
            </div>
            <div class="col col-4" v-if="blame.leadConfinement">
              <label>禁闭时长（天）</label>
              <span >{{blame.leadConfinement.confinementTime}}</span>
            </div>
            <div class="col col-24" v-if="blame.leadConfinement">
              <label>禁闭措施</label>
              <span>{{blame.leadConfinement.matter}}</span>
            </div>
          </div>


            <div class="row" style="background: #f5f5f5">
              <div class="col col-6" v-if="blame.leadProtectRightsName">
                <label>维权容错</label>
                <span>{{ blame.leadProtectRightsName }}</span>
              </div>
            </div>
        </el-collapse-item>
        <el-collapse-item
            v-for="(blame, index) in negative.blames.filter(
                (item) => item.type === BlameType.DEPARTMENT
            )"
            :key="index"
            :title="`涉及单位`"
            :name="`involved_department`"
        >
            <div class="row">
                <div class="col col-6">
                    <label>班子成员姓名</label>
                    <span>{{ blame.blameName }}</span>
                </div>
                <div class="col col-6">
                    <label>身份证号码</label>
                    <span>{{ blame.blameIdCode }}</span>
                </div>
                <div class="col col-6">
                    <label>人员属性</label>
                    <span>{{
                        getDictLable(dict.personType, blame.ivPersonTypeCode)
                    }}</span>
                </div>
            </div>
            <div
                class="row"
                v-for="(problem, index) in blame.problems"
                :key="index"
            >
                <div class="col col-24">
                    <label>问题类型{{ index + 1 }}</label>
                    <span
                        >{{ problem.oneLevelContent }} /
                        {{ problem.twoLevelContent }} /
                        {{ problem.threeLevelContent }}
                        {{ problem.threeLevelContent === '其他' && problem.threeLevelContentOther ? `(${problem.threeLevelContentOther})` : ''}}
                        </span
                    >
                </div>
            </div>
            <div class="row">
                <div class="col col-6" v-if="blame.subjectiveAspectCode">
                    <label>主观方面</label>
                    <span>{{ blame.subjectiveAspectName }}</span>
                </div>
                <div class="col col-6">
                    <label>责任类别</label>
                    <span>{{ blame.responsibilityTypeName }}</span>
                </div>
                <div class="col col-6" v-if="blame.handleResultCode">
                    <label>处置结果</label>
                    <span>
                        <span>{{ blame.handleResultName }}</span>
                        <span v-if="blame.handleResultNameOther">({{ blame.handleResultNameOther }})</span>
                    </span>
                </div>
            </div>
        </el-collapse-item>
        <el-collapse-item
            name="completionAttachment"
            v-if="negative.files.length"
        >
            <template #title>
                <span>办结佐证材料</span>
                <span class="ml-8 text-small" style="color: #666">{{ negative.files.length }}个附件</span>
            </template>
            <file-list :files="negative.files" />
        </el-collapse-item>

    </el-collapse>
</template>
<script setup>
import { BlameType, ProblemSources } from "@/enums/dictEnums";
import {reduceMerge} from '@/utils/util';
import { ProcessingStatus } from "@/enums/flowEnums";
import { getDictLable } from "@/utils/util";
import useCatchStore from "@/stores/modules/catch";
import {getConfinementListAll} from "@/api/work/confinement";

const dict = useCatchStore().getDicts([
    "accountabilityTarget",
    "personType",
    "verifySituation",
    "verifyFileSituation",
]);

const activeNames = ref([
    "verify",
    "involved_department",
    "completionAttachment",
    "completed",
    "mail"
]);
let negative = inject("negative");


console.log('negative.value',negative.value)
for (
    let i = 0;
    i <
    negative.value.blames.filter((item) => item.type === BlameType.PERSONAL)
        .length;
    i++
) {
    activeNames.value.push("involved" + i);
}
</script>
<style lang="scss" scoped>
.el-collapse {
    --el-collapse-header-text-color: var(--primary-color);
    --el-collapse-header-font-size: 16px;
}
</style>
