<template>
    <div id="submit-report-layout-target" class="hc-page-box conclusion">
        <HcCard>
            <template #header>
                <div class="hc-conclusion-header-box">
                    <div class="hc-conclusion-icon-box">
                        <HcIcon name="file-ppt-2" fill/>
                    </div>
                    <div class="ml-2 conclusion-name-box">
                        <span class="text-xl text-cut conclusion-alias">编写结论、提交报告</span>
                        <div class="text-xs text-cut conclusion-name">{{projectInfo['name']}}</div>
                    </div>
                </div>
            </template>
            <template #extra>
                <el-button hc-btn type="primary" @click="writeReportClick">下一步、编写报告</el-button>
                <el-button hc-btn @click="toBackClick">
                    <HcIcon name="arrow-go-back"/>
                    <span>返回主页</span>
                </el-button>
            </template>

            <el-container class="hc-table-layout">
                <el-container id="hc_table_container" class="hc-table-container">
                    <HcCardItem id="hc_table_data" title="抽检统计：">
                        <template #extra>
                            <span class="text-red">预警提示：抽检率未达到验收要求，目前至抽检了4.5%</span>
                        </template>
                        <TableStats :contractId="contractId" :projectId="projectId"/>
                    </HcCardItem>
                    <HcCardItem id="hc_table_score" title="专家验收评分表：">
                        <template #header>
                            <span>专家验收评分表：</span>
                            <el-checkbox v-model="searchFormScore.score" class="size-xl">生成打分表</el-checkbox>
                        </template>
                        <template #extra>
                            <div class="w-40">
                                <el-select v-model="searchFormScore.type" placeholder="参建方类型表">
                                    <el-option label="业主建设单位" value="1"/>
                                    <el-option label="监理单位" value="2"/>
                                    <el-option label="施工单位" value="3"/>
                                </el-select>
                            </div>
                        </template>
                        <TableScore :contractId="contractId" :projectId="projectId" :type="searchFormScore.type"/>
                    </HcCardItem>
                </el-container>
                <el-aside id="hc_table_aside" class="hc-table-aside">
                    <HcCardItem title="抽检意见记录汇总：">
                        <TableOpinion :contractId="contractId" :projectId="projectId" @opinionTap="tableOpinionTap"/>
                    </HcCardItem>
                </el-aside>
            </el-container>
        </HcCard>

        <!--抽检记录详情-->
        <HcDialog :show="isOpinionModal" title="抽检记录详情" widths="60%" @close="onOpinionModalClose" isTable :footer="false">
            <div class="hc-table-opinion-text">
                <div class="title">案卷题名：安康至来凤国家高速公路奉节至巫山....</div>
                <div class="opinion-text">
                    <div class="text-1">抽检意见：</div>
                    <div class="text-2" v-if="!opinionTextEdit">{{opinionText}}</div>
                    <div class="text-2 input" v-if="opinionTextEdit">
                        <el-input style="flex: 1;" :rows="3" v-model="opinionText" placeholder="请输入抽检意见" type="textarea" resize="none"/>
                        <el-button class="ml-4" hc-btn type="primary" @click="opinionTextEditHihe">保存</el-button>
                    </div>
                    <div class="text-blue text-hover icon-1" v-if="!opinionTextEdit" @click="opinionTextEditShow">
                        <HcIcon name="edit-2"/>
                    </div>
                </div>
            </div>
            <div class="hc-table-opinion-pdf">
                <HcPdf
                    src="https://bladex-test-info.oss-cn-chengdu.aliyuncs.com//upload/20221212/ce9799c7d18efc03efefd6f242439f2e.pdf"/>
            </div>
        </HcDialog>

    </div>
</template>

<script setup>
import {ref, onMounted} from "vue";
import {useAppStore} from "~src/store";
import {useRouter} from "vue-router";
import TableStats from "./components/conclusion/table-stats.vue"
import TableOpinion from "./components/conclusion/table-opinion.vue"
import TableScore from "./components/conclusion/table-score.vue"

//变量
const router = useRouter()
const useAppState = useAppStore()
const projectId = ref(useAppState.getProjectId);
const contractId = ref(useAppState.getContractId);
const projectInfo = ref(useAppState.getProjectInfo);

//渲染完成
onMounted(() => {
    setSplitRef()
})

//初始化设置拖动分割线
const setSplitRef = () => {
    //配置参考： https://split.js.org/#/?direction=vertical&snapOffset=0
    setTimeout(() => {
        window.$split(['#hc_table_container', '#hc_table_aside'], {
            sizes: [80, 20],
            snapOffset: 0,
            minSize: [400, 600],
        });
        window.$split(['#hc_table_data', '#hc_table_score'], {
            direction: 'vertical',
            snapOffset: 0,
            minSize: 200,
        });
    }, 800)
}

const searchFormScore = ref({
    type: '', score: true
})


//查看意见
const isOpinionModal = ref(false)
const tableOpinionTap = () => {
    isOpinionModal.value = true
}
const onOpinionModalClose = () => {
    isOpinionModal.value = false
}

//抽检记录意见
const opinionText = ref('水保方案未加盖公章XXXXX')
const opinionTextEdit = ref(false)

const opinionTextEditShow = () => {
    opinionTextEdit.value = true
}

const opinionTextEditHihe = () => {
    opinionTextEdit.value = false
}

//编写报告
const writeReportClick = () => {
    router.push({
        name: 'transfer-write-report'
    })
}

//返回
const toBackClick = () => {
    router.push({
        name: 'transfer-initial-expert'
    })
}
</script>

<style lang="scss" scoped>
@import '~style/transfer/scoped/submit-report.scss';

.hc-conclusion-header-box {
    position: relative;
    display: flex;
    align-items: flex-start;
    .hc-conclusion-icon-box {
        font-size: 28px;
        color: var(--el-color-primary);
    }
    .conclusion-name-box {
        flex: auto;
        position: relative;
        overflow: hidden;
        .conclusion-alias {
            color: var(--el-color-primary);
        }
        .conclusion-name {
            margin-top: 4px;
            color: #838791;
        }
    }
}
.hc-table-opinion-text {
    position: relative;
    color: #010101;
    font-size: 16px;
    margin-bottom: 10px;
    .title {
        position: relative;
        margin-bottom: 10px;
    }
    .opinion-text {
        position: relative;
        display: flex;
        align-items: flex-start;
        height: 73px;
        .text-2 {
            position: relative;
        }
        .text-2.input {
            position: relative;
            display: flex;
            align-items: flex-end;
            flex: 1;
        }
        .icon-1 {
            position: relative;
            margin-top: 3px;
            margin-left: 12px;
        }
    }
}
.hc-table-opinion-pdf {
    position: relative;
    height: calc(100% - 118px);
}
</style>

<style lang="scss">
@import '~style/transfer/submit-report.scss';
.hc-page-box.conclusion .hc-table-layout .hc-table-aside {
    width: var(--el-aside-width,600px);
}
</style>
