<template>
    <div class="hc-page-layout-box">
        <div
            :style="`width:${isWbsTreeShow ? leftWidth : 0}px; ${isWbsTreeShow ? '' : 'display: none'}`"
            class="hc-layout-left-box bg-white" :class="[isWbsTreeShow ? 'show' : '']"
        >
            <div class="hc-project-box">
                <div class="hc-project-icon-box">
                    <hc-icon name="stack" />
                </div>
                <div class="project-name-box ml-2">
                    <div class="project-alias">{{ projectInfo.projectName }}</div>
                </div>
            </div>
            <div class="hc-tree-box">
                <el-scrollbar>
                    <TestTree
                        :auto-expand-keys="treeAutoExpandKeys"
                        :project-id="projectId"
                        :tenant-id="userInfo?.tenant_id"
                        :wbs-temp-id="projectInfo?.referenceWbsTemplateIdTrial"
                        :wbs-type="2"
                        :entrust="1"
                        @node-tap="wbsElTreeClick"
                    />
                </el-scrollbar>
            </div>
            <!-- 左右拖动 -->
            <div class="horizontal-drag-line" @mousedown="onmousedown" />
        </div>
        <div class="hc-page-content-box">
            <!---展开收缩树 -->
            <div class="hc-expansion-contraction-tree" @click="setWbsTreeShow">
                <hc-icon v-show="isWbsTreeShow" name="arrow-left-s" />
                <hc-icon v-show="!isWbsTreeShow" name="arrow-right-s" />
            </div>
            <HcTabCard :tabs="authBtnTabdata" :tab-key="authBtnTabKey" @change="authBtnTabClick">
                <template #extra>
                    <HcTooltip keys="tentative_detect_test_add">
                        <el-button
                            :disabled="!primaryKeyId" hc-btn color="#37c0fe" style="color: white;"
                            @click="addFormModalClick"
                        >
                            <hc-icon name="add-circle" />
                            <span>新增</span>
                        </el-button>
                    </HcTooltip>
                    <!-- <HcTooltip keys="tentative_detect_test_copy">
                        <el-button
                            :disabled="tableCheckedKeys.length <= 0" :loading="copyLoading" hc-btn
                            color="#A16222" @click="copyDataClick"
                        >
                            <hc-icon name="file-copy-2" />
                            <span>复制</span>
                        </el-button>
                    </HcTooltip> -->
                    <HcTooltip keys="tentative_detect_test_report">
                        <el-button
                            :disabled="tableCheckedKeys.length <= 0" :loading="reportPdfLoading" hc-btn
                            color="#FF976A" style="color: white;" @click="reportPdfClick"
                        >
                            <hc-icon name="send-plane-2" />
                            <span>批量上报</span>
                        </el-button>
                    </HcTooltip>
               
                    <!-- <HcTooltip keys="tentative_detect_test_print">
                        <el-button
                            :disabled="tableCheckedKeys.length <= 0" :loading="printPdfLoading" hc-btn
                            color="#567722" @click="printPdfClick"
                        >
                            <hc-icon name="printer" />
                            <span>批量打印</span>
                        </el-button>
                    </HcTooltip> -->
                 
                    <!-- <HcTooltip keys="tentative_detect_test_quit">
                        <el-button
                            :disabled="tableCheckedKeys.length <= 0" :loading="quitPdfLoading" hc-btn
                            color="#e54d42" @click="quitPdfClick"
                        >
                            <hc-icon name="delete-bin-3" />
                            <span>批量废除</span>
                        </el-button>
                    </HcTooltip> -->
                    <!-- <HcTooltip keys="tentative_detect_test_null">
                        <el-button
                            :disabled="tableCheckedKeys.length <= 0" :loading="printNullPdfLoading" hc-btn
                            color="#567722" @click="printNullPdfClick"
                        >
                            <hc-icon name="printer" />
                            <span>打印空表</span>
                        </el-button>
                    </HcTooltip> -->
                    <el-dropdown trigger="click">
                        <el-button hc-btn type="success" :loading="dataBtnLoad">
                            <span>综合功能</span>
                            <hc-icon name="arrow-down-s" />
                        </el-button>
                        <template #dropdown>
                            <el-dropdown-menu>
                                <template v-for="item in dataSyncMenu" :key="item.key">
                                    <el-dropdown-item :disabled="tableCheckedKeys.length <= 0" @click="dataSyncMenuClick(item)">{{ item.name }}</el-dropdown-item>
                                </template>
                            </el-dropdown-menu>
                        </template>
                    </el-dropdown>
                    <HcTooltip keys="tentative_detect_test_del">
                        <el-button
                            :disabled="tableCheckedKeys.length <= 0" :loading="removeLoading" hc-btn
                            color="#e03997" class="ml-2" @click="delModalClick"
                        >
                            <hc-icon name="delete-bin-2" />
                            <span>删除</span>
                        </el-button>
                    </HcTooltip>
                    <el-button class="ml-2" :disabled="tableCheckedKeys.length <= 0" :loading="signLoading" hc-btn type="primary" @click="resignClick">re-sign</el-button>
                </template>
                <template #search>
                    <div class="w-40">
                        <el-input
                            v-model="searchForm.trialUserName" clearable placeholder="请输入试验人员"
                            @keyup="keyUpEvent"
                        />
                    </div>
                    <div class="ml-2 w-200px">
                        <el-select v-model="searchForm.contractId" placeholder="选择合同段" filterable block>
                            <el-option
                                v-for="item in contractData" :key="item.id" :label="item.contractName"
                                :value="item.id"
                            />
                        </el-select>
                    </div>
                    <div class="ml-2 w-32">
                        <el-select v-model="searchForm.queryStatus" clearable placeholder="是否合格">
                            <el-option
                                v-for="item in qualifiedData" :key="item.value" :label="item.label"
                                :value="item.value"
                            />
                        </el-select>
                    </div>
                    <div class="ml-2 w-250px">
                        <hc-date-picker :dates="betweenTime" clearable @change="betweenTimeUpdate" />
                    </div>
                    <div class="ml-2 w-72">
                        <el-input v-model="searchForm.queryValue" clearable placeholder="请输入项目名称关键字" @keyup="keyUpEvent" />
                    </div>
                    <div class="ml-2">
                        <el-button type="primary" @click="searchClick">
                            <hc-icon name="search-2" />
                            <span>搜索</span>
                        </el-button>
                    </div>
                </template>
                <HcTable
                    ref="tableRef" :column="tableColumn" :datas="tableData" :loading="tableLoading"
                    is-new :index-style="{ width: 60 }" is-check :check-style="{ width: 29 }"
                    @selection-change="tableSelection"
                >
                    <template #recordNo="{ row }">
                        <span class="text-link" @click="tableRowEdit(row, '1')">{{ row?.recordNo }}</span>
                    </template>
                    <template #reportNo="{ row }">
                        <span class="text-link" @click="tableRowEdit(row, '2')">{{ row?.reportNo }}</span>
                    </template>
                    <template #trialProjectName="{ row }">
                        <span class="text-link font-bold" @click="tableRowPdf(row)">{{ row?.trialProjectName }}</span>
                    </template>
                    <template #taskStatus="{ row }">
                        <!-- <el-tag :type="`${row.status === 2 ? 'success' : row.status === 0 ? 'warning' : row.status === 1 ? 'danger' : 'info'}`" -->
                        <el-tag
                            v-if="row.taskStatus"
                            :type="`${row.taskStatus === '已审批' ? 'success' : row.taskStatus === '待审批' ? 'warning' : row.taskStatus === '已废除' ? 'danger' : 'info'}`"
                            class="mx-1" effect="dark"
                        >
                            {{ row.taskStatus }}
                        </el-tag>
                    </template>
                    <template #detectionCategory="{ row }">
                        <!-- <span>{{arrKeyValue(categoryData, 'dictKey', 'dictValue', row.detectionCategory)}}</span> -->
                        <span>{{ row.detectionCategoryName }}</span>
                    </template>
                    <template #isUploadCertificate="{ row }">
                        <!-- <span>{{row.isUploadCertificate == 0 ? '是':row.isUploadCertificate == -1?'' : '否'}}</span> -->
                        <span>{{ row.isUploadCertificateName }}</span>
                    </template>
                    <template #contractId="{ row }">
                        <span>{{ contractInfo?.name }}</span>
                    </template>
                    <template #detectionResult="{ row }">
                        <span>{{ row?.reportNo && row?.reportNo.length > 0 ? row.detectionResultName : '' }}</span>
                    </template>
                    <template #action="{ row }">
                        <HcTooltip keys="tentative_detect_test_annex">
                            <el-link type="primary" @click="viewAttachmentModalClick(row)">附件</el-link>
                        </HcTooltip>
                        <el-link type="primary" @click="relatedSearchClick(row)">关联查阅</el-link>
                        <!-- HcTooltip keys="tentative_detect_test_info">
                            <el-link type="primary" @click="samplingRecordModalClick(row)">样品信息</el-link>
                        </HcTooltip -->
                    </template>
                </HcTable>
                <template #action>
                    <HcPages :pages="searchForm" @change="pageChange" />
                </template>
            </HcTabCard>
        </div>

        <!-- 查看附件 -->
        <hc-new-dialog
            :footer="false" :show="viewAttachmentModal" is-table title="查看附件" widths="70rem"
            @close="viewAttachmentModalClose"
        >
            <template #extra>
                <HcNewSwitch :datas="tabTypeTab" :keys="tabTypeKey" size="default" @change="tabTypeChange" />
            </template>
            <div v-loading="viewAttachmentLoading" class="hc-switch-tab-content">
                <div class="h-full w-full flex">
                    <div v-if="viewAttachmentData.length > 0" class="pdf-file-list-box">
                        <template v-for="item in viewAttachmentData">
                            <div :class="[item.isCheck ? 'cur' : '']" class="file-item" @click="viewCurFile(item)">
                                {{ item.fileName || '' }}
                            </div>
                        </template>
                    </div>
                    <div v-else class="pdf-file-list-box">
                        <hc-empty />
                    </div>
                    <iframe v-if="attachmentPdfUrl" :src="attachmentPdfUrl" frameborder="1" height="100%" width="80%" />
                    <div class="hc-no-table-form">
                        <div class="table-form-no">
                            <HcDragUpload
                                :datas="uploadData" :file-list="fileListData" @del-file="delFileData"
                                @finished="uploadFinished" @progress="uploadprogress" @close="viewAttachmentModalClose"
                            />
                        </div>
                    </div>
                </div>
            </div>
        </hc-new-dialog>

        <!-- 查看样品信息 -->
        <hc-new-dialog
            :footer="false" :show="samplingRecordModal" is-table title="查看样品信息" widths="60%"
            @close="samplingRecordModalClose"
        >
            <HcTable
                :column="samplingTableColumn" :datas="samplingTableData" :is-index="false"
                :loading="samplingTableLoading" is-new
            />
        </hc-new-dialog>

        <!-- 关联查阅 -->
        <hc-dialog
            v-model="isRelatedSearch" :footer="false" is-table title="关联查阅" widths="80%" :padding="false"
            @close="relatedSearchModalClose"
        >
            <div class="hc-related-search-box relative mt-10px">
                <hc-card-item title="样品信息">
                    <template #extra>
                        <el-button :disabled="relatedData1.length <= 0" type="primary" size="small" @click="rowDispose">
                            样品处理
                        </el-button>
                    </template>
                    <hc-table :column="relatedColumn1" :datas="relatedData1" :is-index="false" />
                </hc-card-item>
                <hc-card-item title="委托单信息" class="mt-14px">
                    <hc-table :column="relatedColumn2" :datas="relatedData2" :is-index="false">
                        <template #status="{ row }">
                            <el-tag v-if="row.status === 1" type="info" effect="dark">未上报</el-tag>
                            <el-tag v-if="row.status === 2" type="warning" effect="dark">已上报-待审批</el-tag>
                            <el-tag v-if="row.status === 3" type="primary" effect="dark">待试验</el-tag>
                            <el-tag v-if="row.status === 4" type="success" effect="dark">委托完成</el-tag>
                        </template>
                    </hc-table>
                </hc-card-item>
                <hc-card-item title="设备采集信息" class="mt-14px">
                    <hc-table :column="relatedColumn3" :datas="relatedData3" :is-index="false" />
                </hc-card-item>
            </div>
        </hc-dialog>

        <!-- 样品处理 -->
        <hc-new-dialog v-model="disposeModal" is-footer-center title="样品处理" widths="40rem" @close="disposeClose">
            <el-form ref="formRef" :model="formModel" :rules="formRules" label-position="left" label-width="auto">
                <el-form-item label="处理方式：" prop="repealType">
                    <el-radio-group v-model="formModel.repealType">
                        <el-radio :value="1">处理</el-radio>
                        <el-radio :value="2">留样</el-radio>
                    </el-radio-group>
                </el-form-item>
                <el-form-item v-if="formModel.repealType === 1" label="处理原因：" prop="repealReason">
                    <el-input v-model="formModel.repealReason" type="textarea" :rows="5" resize="none" />
                </el-form-item>
                <el-form-item v-if="formModel.repealType === 2" label="留样时间：" prop="resamStartTime">
                    <hc-date-picker :dates="formTime" clearable @change="formTimeUpdate" />
                </el-form-item>
            </el-form>
            <template #footer>
                <el-button @click="disposeClose">取消</el-button>
                <el-button hc-btn type="primary" :loading="saveLoading" @click="disposeSave">确定</el-button>
            </template>
        </hc-new-dialog>

        <!-- 批量上报审批 -->
        <HcReportModal
            :classify-type="authBtnTabKey"
            :addition="reportAddition" :contract-id="contractId" :ids="reportIds"
            :project-id="projectId" :show="showReportModal" :task-name="reportTaskName"
            :trial-self-inspection-record-id="1"
            :type-data="reportTypeData" title="批量上报审批" type="wbs"
            url="informationWriteQuery/batchTask" @finish="showReportFinish"
            @hide="showReportModal = false"
        />
        <!-- 一键重签弹窗 -->
        <hc-new-dialog v-model="resignModal" title="一键重签" widths="38rem" :loading="signLoading" @close="cancelresign" @save="signClick">
            <div>
                是否重新生成pdf:
                <el-radio-group v-model="resignModalRadio">
                    <el-radio :value="2">否</el-radio>
                    <el-radio :value="1">是</el-radio>
                </el-radio-group>
            </div>
        </hc-new-dialog>
    </div>
</template>

<script setup>
import { onActivated, onMounted, ref, watch } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import { useAppStore } from '~src/store'
import TestTree from '../material/components/TestTree.vue'
import { delStoreValue, getStoreValue, setStoreValue } from '~src/utils/storage'
import HcDragUpload from './components/HcDragUpload.vue'
import { getDictionary } from '~api/other'
import { eVisaTaskCheckApi } from '~api/other'
import { getErtractInfo } from '~api/other'
import wbsApi from '~api/data-fill/wbs'
import dataApi from '~api/tentative/detect/test'
import testSampleApi from '~api/tentative/material/testSample'
import commissionApi from '~api/tentative/detect/commission'
import acquisitionApi from '~api/tentative/acquisition/data'
import { arrToId, arrToKey, formValidate, getArrValue, getObjVal, getObjValue, isNullES, isString } from 'js-fast-way'
import { HcDelMsg } from 'hc-vue3-ui'
import { toPdfPage } from '~uti/btn-auth'

//变量
const router = useRouter()
const useRoutes = useRoute()
const useAppState = useAppStore()
const userInfo = ref(useAppState.getUserInfo)
const projectId = ref(useAppState.getProjectId)
const contractId = ref(useAppState.getContractId)
const projectInfo = ref(useAppState.getProjectInfo)
const contractInfo = ref(useAppState.getContractInfo)
const isCollapse = ref(useAppState.getCollapse)
const isBubble = ref(useAppState.getBubble)

//监听
watch(() => [useAppState.getCollapse, useAppState.getBubble], ([Collapse, bubble]) => {
    isCollapse.value = Collapse
    isBubble.value = bubble
})

//获取气泡数据
const getButtonsVal = (value) => {
    return useAppState.getButtonsVal(value)
}

//自动展开缓存
const treeAutoExpandKeys = ref(getStoreValue('testTreeExpandKeys') || [])
const btn_edit = ref(false)

//渲染完成
onMounted(() => {
    btn_edit.value = getButtonsVal('tentative_detect_test_edit')
    setContractType(contractInfo.value?.contractType)
    getCategoryData()
    getContractData()
})

//缓存被激活时,重新获取表格数据
onActivated(() => {
    getDataApi()
})

const isFirstTime = ref(false)
const getDataApi = async () => {
    isFirstTime.value = true
    const routerQuery = useRoutes?.query
    let currentPage = routerQuery?.current
    if (isNullES(currentPage)) {
        searchForm.value.current = 1
    } else {
        searchForm.value.current = Number(currentPage)
    }
    console.log(searchForm.value)
    // setMountOnEventKey()
    getTableData().then()
}

//获取合同段信息
const contractData = ref([])
const getContractData = async () => {
    const { data } = await getErtractInfo({
        projectId: projectId.value,
        contractId: contractId.value,
    })
    const res = getArrValue(data)
    contractData.value = res
    if (res.length <= 0) return
    let cid
    for (let i = 0; i < res.length; i++) {
        if (contractId.value == res[i].id) {
            cid = res[i].id
        }
    }
    searchForm.value.contractId = isNullES(cid) ? res[0].id : cid
}

const qualifiedData = ref([
    { label: '不合格', value: '0' },
    { label: '合格', value: '1' },
])

//树展开和收起
const isWbsTreeShow = ref(true)
const setWbsTreeShow = () => {
    isWbsTreeShow.value = !isWbsTreeShow.value
}

//获取检测类别类型
const categoryData = ref([])
const getCategoryData = async () => {
    const { data } = await getDictionary({
        code: 'trial_detection_category',
    })
    const arrData = getArrValue(data)
    arrData.forEach(item => {
        item.dictKey = Number(item.dictKey)
    })
    categoryData.value = arrData
}

//搜索表单
const searchForm = ref({
    trialUserName: null, queryStatus: null, queryValue: null, type: '1',
    current: 1, size: 20, total: 0,
})

//树相关的变量
const primaryKeyId = ref('')
const nodeDataInfo = ref({})

//树被点击
const wbsElTreeClick = ({ data, keys }) => {
    nodeDataInfo.value = data
    primaryKeyId.value = data['primaryKeyId'] || ''
    setStoreValue('testTreeItem', data)
    //缓存自动展开
    treeAutoExpandKeys.value = keys
    setStoreValue('testTreeExpandKeys', keys)
    //改变搜索表单数据
    searchForm.value.nodeId = data['primaryKeyId']
    if (!isFirstTime.value) {
        searchForm.value.current = 1
    } else {
        isFirstTime.value = false
    }
    getTableData()
}

//身份按钮切换数据
const authBtnTabKey = ref('1')
const authBtnTabdata = ref([
    { key: '1', name: '施工自检' },
    { key: '2', name: '监理抽检' },
    { key: '3', name: '业主抽检' },
])
const authBtnTabClick = (item) => {
    tableData.value = []
    if (item.key !== authBtnTabKey.value && item.key < 3) {
        authBtnTabKey.value = item.key
        searchForm.value.type = item.key
        searchForm.value.current = 1
        getTableData()
    } else if (item.key === '3') {
        authBtnTabKey.value = item.key
        searchForm.value.type = item.key
        searchForm.value.current = 1
        getTableData()
    }
}
//contractType,  1施工，2监理, 3业主
const setContractType = (contractType) => {
    let typeValue = '1'
    if (contractType > 0) {
        typeValue = contractType + ''
    }
    authBtnTabKey.value = typeValue
    searchForm.value.type = typeValue
    searchForm.value.current = 1
}

//日期时间被选择
const betweenTime = ref(null)
const betweenTimeUpdate = ({ arr }) => {
    betweenTime.value = arr
    if (arr.length > 0) {
        searchForm.value.startTime = arr[0]
        searchForm.value.endTime = arr[1]
    } else {
        searchForm.value.startTime = ''
        searchForm.value.endTime = ''
    }
}

//回车搜索
const keyUpEvent = (e) => {
    if (e.key === 'Enter') {
        searchForm.value.current = 1
        getTableData()
    }
}

//搜索
const searchClick = () => {
    searchForm.value.current = 1
    getTableData()
}

//分页被点击
const pageChange = ({ current, size }) => {
    searchForm.value.current = current
    searchForm.value.size = size
    getTableData()
}


const dataBtnLoad = ref(false)
//综合功能菜单
const dataSyncMenu = [
    { key: 'copy', name: '复制', load: true },
    { key: 'print', name: '批量打印', load: true },
    { key: 'delete', name: '批量废除', load: true },
    { key: 'printExcel', name: '打印空表', load: true },
]
const dataSyncMenuClick = (item) => {
    const { key } = item
    if (key === 'copy') {
        copyDataClick()
 
    } else if (key === 'print') {
        printPdfClick()
    } else if (key === 'delete') {
        quitPdfClick()
    } else if (key === 'printExcel') {
        printNullPdfClick()
    }
    
}

//表格数据
const tableRef = ref(null)
const tableColumn = ref([
    { key: 'recordNo', name: '记录编号', width: 190 },
    { key: 'reportNo', name: '报告编号', width: 190, autoWidth: true },
    { key: 'trialProjectName', name: '试验项目名称', width: 100, autoWidth: true },
    { key: 'detectionResult', name: '检测结果', width: 140, autoWidth: true },
    { key: 'taskStatus', name: '任务状态', width: 120, autoWidth: true },
    { key: 'reportDate', name: '报告日期', width: 120, autoWidth: true },
    { key: 'trialUserName', name: '试验人员', width: 170, autoWidth: true },
    { key: 'samplingLocation', name: '取样地点', width: 180, autoWidth: true },
    { key: 'detectionCategory', name: '检测类别', width: 100, autoWidth: true },
    { key: 'isUploadCertificate', name: '是否上传合格证', width: 120, autoWidth: true },
    { key: 'contractId', name: '合同段', width: 140, autoWidth: true },
    { key: 'company', name: '单位', width: 160, autoWidth: true },
    { key: 'entrustName', name: '委托单名称', autoWidth: true },
    { key: 'entrustNo', name: '委托单编号', autoWidth: true },
    { key: 'specificationNumber', name: '样品编号', width: 220, autoWidth: true },
    { key: 'specificationModel', name: '规格类型', width: 200, autoWidth: true },
    //{key:'projectPosition', name: '工程部位及用途', width: 160},
    { key: 'projectPositionName', name: '工程部位及用途', width: 160, autoWidth: true },
 
    { key: 'action', name: '操作', width: 120, fixed: 'right', align: 'center' },
])
const tableData = ref([])

//获取数据
const tableLoading = ref(false)
const getTableData = async () => {
    tableLoading.value = true
    const { error, code, data } = await dataApi.queryPage({
        ...searchForm.value,
        projectId: projectId.value,
        //contractId: contractId.value,
    })
    //处理数据
    tableLoading.value = false
    if (!error && code === 200) {
        tableData.value = getArrValue(data?.records)
        searchForm.value.total = data?.total || 0
    } else {
        tableData.value = []
        searchForm.value.total = 0
    }
}

//多选
const tableCheckedKeys = ref([])
const tableSelection = (rows) => {
    tableCheckedKeys.value = rows
}

//新增
const addFormModalClick = () => {
    delStoreValue('test-form')
    setStoreValue('prenodeDataInfo', nodeDataInfo.value)
    const obj = getObjValue(searchForm.value)
    router.push({
        path: '/tentative/detect/test-form',
        query: {
            nodeId: primaryKeyId.value,
            dataType: authBtnTabKey.value,
            cid: obj?.contractId,
            isaddType: true,
            current: obj?.current,
        },
    })
}

//编辑
const tableRowEdit = (row, tabTypeKey) => {
    setStoreValue('test-form', row)
    setStoreValue('prenodeDataInfo', nodeDataInfo.value)
    const obj = getObjValue(searchForm.value)
    router.push({
        path: '/tentative/detect/test-form',
        query: {
            id: row.id,
            nodeId: row.nodeId,
            dataType: row.type,
            tabTypeKey: tabTypeKey,
            cid: obj?.contractId,
            current: obj?.current,
            // prenodeDataInfo:JSON.stringify(nodeDataInfo.value)
        },
    })
}

//预览PDF
const tableRowPdf = ({ pdfUrl }) => {
    if (pdfUrl) {
        toPdfPage(pdfUrl)
        //window.open(pdfUrl, '_blank')
    } else {
        window.$message?.warning('该数据暂无PDF')
    }
}

//复制
const copyDataClick = () => {
    const rows = tableCheckedKeys.value
    if (rows.length > 0) {
        const ids = arrToId(rows)
        copyDataApi(ids)
    } else {
        window.$message?.warning('请先勾选需要复制的记录')
    }
}

//请求复制
const copyLoading = ref(false)
const copyDataApi = async (ids) => {
    //请求数据
    copyLoading.value = true
    dataBtnLoad.value = true
    const { error, code, msg } = await dataApi.copyData({
        projectId: projectId.value,
        ids: ids,
    }, false)
    //处理数据
    copyLoading.value = false
    dataBtnLoad.value = false
    if (!error && code === 200) {
        window.$message?.success('复制成功')
        searchClick()
    } 
}

//删除
const delModalClick = () => {
    const rows = tableCheckedKeys.value
    if (rows.length > 0) {
        const ids = arrToId(rows)
        HcDelMsg(async (resolve) => {
            await removeDataApi(ids)
            resolve() //关闭弹窗的回调
        })
    } else {
        window.$message?.warning('请先勾选需要删除的记录')
    }
}

//请求删除
const removeLoading = ref(false)
const removeDataApi = async (ids) => {
    //请求数据
    removeLoading.value = true
    const { error, code, msg } = await dataApi.removeData({
        projectId: projectId.value,
        ids: ids,
    }, false)
    //处理数据
    removeLoading.value = false
    if (!error && code === 200) {
        window.$message?.success('删除成功')
        searchClick()
    } 
}

//批量打印
const printPdfLoading = ref(false)
const printPdfClick = async () => {
    const rows = tableCheckedKeys.value
    if (rows.length > 0) {
        const ids = arrToId(rows)
        //请求数据
        printPdfLoading.value = true
        dataBtnLoad.value = true
        const { error, code, msg, data } = await dataApi.printPdf({
            projectId: projectId.value,
            ids: ids,
        }, false)
        //处理数据
        const pdfUrl = isString(data) ? data || '' : ''
        printPdfLoading.value = false
        dataBtnLoad.value = false
        if (!error && code === 200 && pdfUrl) {
            toPdfPage(pdfUrl)
            //window.open(pdfUrl, '_blank')
        } else {
            window.$message?.error(msg || '文件异常')
        }
    } else {
        window.$message?.warning('请先勾选需要批量打印的记录')
    }
}

//批量废除
const quitPdfLoading = ref(false)
const quitPdfClick = async () => {
    const rows = tableCheckedKeys.value
    if (rows.length > 0) {
        const ids = arrToId(rows)
        const res1 = rows.some(item => item.taskStatus === '未上报')
        const res2 = rows.some(item => item.taskStatus === '已废除')
        if (res1) {
            window.$message?.warning('未上报的文件不能废除')
        } else if (res2) {
            window.$message?.warning('已废除的文件不能再次废除')
        } else {
            //请求数据
            quitPdfLoading.value = true
            dataBtnLoad.value = true
            const { error, code, msg } = await dataApi.batchAbolish({
                projectId: projectId.value,
                contractId: contractId.value,
                primaryKeyId: primaryKeyId.value,
                ids: ids,
            }, false)
            dataBtnLoad.value = false
            //处理数据
            if (!error && code === 200) {
                window.$message?.success('废除成功')
                quitPdfLoading.value = false
                searchClick()
            } else {
                quitPdfLoading.value = false
                // window.$message?.error(msg)
            }
        }

    } else {
        window.$message?.warning('请先勾选需要批量打印的记录')
    }
}

//批量上报
const reportPdfLoading = ref(false)
//批量上报
const reportIds = ref('')
const reportTaskName = ref('')
const reportAddition = ref({})
const showReportModal = ref(false)
const reportLoading = ref(false)
const reportTypeData = ref([])
const reportPdfClick = async () => {
    const rows = tableCheckedKeys.value
    if (rows.length > 0) {
        const info = getStoreValue('prenodeDataInfo') || {}
        const res1 = rows.some(item => item.pdfUrl.length < 1)
        const res2 = rows.some(item => item.taskStatus === '待审批' || item.taskStatus === '已审批')
        if (res1) {
            window.$message?.warning('当前数据暂无pdf无法上报')
        } else if (res2) {
            window.$message?.warning('已上报的数据无法再次上报')
        } else {
            reportLoading.value = true
            const ids = arrToId(rows)
            reportIds.value = ids
            const taskCheck = await eVisaTaskCheckApi({
                projectId: projectId.value,
                contractId: contractId.value,
            })
            //处理数据
            let newArr = []
            for (let i = 0; i < rows.length; i++) {
                newArr.push(rows[i]['tableIds'])
            }
            reportTypeData.value = [...newArr]
            console.log(reportTypeData.value, ' reportTypeData.value')
            reportLoading.value = false
            if (taskCheck) {
                //初始弹出弹窗，防呆

                reportAddition.value = {
                    classify: authBtnTabKey.value,
                    contractIdRelation: info['contractIdRelation'],
                }
                showReportModal.value = true
                //请求文件题名
                const { data } = await wbsApi.queryDocumentTitle({
                    // primaryKeyId: info['primaryKeyId'],
                    primaryKeyId: rows[0].id,
                    classify: authBtnTabKey.value,
                })
                reportTaskName.value = isString(data) ? data : ''

            } else {
                window.$message?.warning('暂无相关数据')
            }
        }


    } else {
        window.$message?.warning('请先勾选需要批量上报的记录')
    }
}
//上报完成
const showReportFinish = () => {
    showReportModal.value = false
    getTableData()
}

//打印空表
const printNullPdfLoading = ref(false)
const printNullPdfClick = async () => {
    const rows = tableCheckedKeys.value
    if (rows.length > 0) {
        const ids = arrToId(rows)
        //请求数据
        printNullPdfLoading.value = true
        dataBtnLoad.value = true
        const { error, code, msg, data } = await dataApi.printNullPdf({
            projectId: projectId.value,
            ids: ids,
        }, false)
        //处理数据
        const pdfUrl = isString(data) ? data || '' : ''
        printNullPdfLoading.value = false
        dataBtnLoad.value = false
        if (!error && code === 200 && pdfUrl) {
            toPdfPage(pdfUrl)
            //window.open(pdfUrl, '_blank')
        } else {
            window.$message?.error(msg || '文件异常')
        }
    } else {
        window.$message?.warning('请先勾选需要打印空表的记录')
    }
}

//查看附件
const viewAttachmentModal = ref(false)
const viewAttachmentLoading = ref(false)
const viewAttachmentId = ref('')
const viewAttachmentData = ref([])
const viewAttachmentModalClick = async ({ id }) => {
    viewAttachmentId.value = id
    viewAttachmentModal.value = true
    getAttachmentModalClick(viewAttachmentId.value, '1')

}
const getCaption = (obj) => {
    const index = obj.lastIndexOf('pdf')
    return index
}

//获取附件
const getAttachmentModalClick = async (id, type) => {
    viewAttachmentLoading.value = true
    const { error, code, data } = await dataApi.ancillaryDocumentsList({ id: id, type: type })
    console.log(data, 'data')
    viewAttachmentLoading.value = false
    if (!error && code === 200) {
        viewAttachmentData.value = getArrValue(data)
        curFileData.value = viewAttachmentData.value[0]
        viewCurFile(curFileData.value)

    } else {
        viewAttachmentData.value = []

    }

}
const refeshAttachmentModalClick = async (id, type) => {
    const { error, code, data } = await dataApi.ancillaryDocumentsList({ id: id, type: type })
    //处理数据
    viewAttachmentLoading.value = false
    if (!error && code === 200) {
        viewAttachmentData.value = getArrValue(data)
        if (viewAttachmentData.value.length < 1) {
            //  window.$message?.warning('该条记录不存在附件')
        } else {
            viewCurFile(viewAttachmentData.value[0])
        }

    } else {
        viewAttachmentData.value = []

    }
}
const attachmentPdfUrl = ref('')
const curFileData = ref({})
//类型tab数据和相关处理
const tabTypeKey = ref('1')
const tabTypeTab = ref([
    { key: '1', name: '生产合格证' },
    { key: '2', name: '厂家质检报告' },
    { key: '3', name: '其他文件' },
])
const tabTypeChange = (item) => {
    console.log(1111111111)
    tabTypeKey.value = item?.key
    getAttachmentModalClick(viewAttachmentId.value, item?.key)
    fileListData.value = []


    refeshAttachmentModalClick(viewAttachmentId.value, tabTypeKey.value)
}

//关闭查看附件
const viewAttachmentModalClose = () => {
    viewAttachmentModal.value = false
    curFileData.value = ''
    attachmentPdfUrl.value = ''
}
const uploadData = ref({})
const fileListData = ref([])
const listuploadref = ref('1')
//截取文件名称
const splitFileName = (str) => {
    // if(str.indexOf("https://bladex-test-info.oss-cn-chengdu.aliyuncs.com//upload") != -1){
    if (str.indexOf('https://blade-oss-chongqing.oss-cn-shenzhen.aliyuncs.com//upload') != -1) {
        let a = str.split('//')[2].split('/')[2]
        return a
    } else {
        return str
    }

}
//查看当前文件pdf
const viewCurFile = (item) => {
    console.log(item, 'item')
    if (item) {
        curFileData.value = item
        let arr = []
        arr.push({ name: item.fileName, url: item.url })
        fileListData.value = getArrValue(arr)
        viewAttachmentData.value.forEach((ele) => {
            ele.isCheck = false
        })
        item.isCheck = true

    }

}

//上传进度
const uploadprogress = (res) => {
    console.log('进度')
}

//上传完成
const uploadFinished = async (res) => {
    const { error, code, data } = await dataApi.updateAncillaryDocument(
        {
            selfId: viewAttachmentId.value,
            url: res.link,
            type: tabTypeKey.value,

        })
    console.log(data, 'data')
    if (!error && code === 200) {
        refeshAttachmentModalClick(viewAttachmentId.value, tabTypeKey.value)
    }
}
//上传文件delFileData
const delFileData = async (res) => {
    console.log('删除文件', curFileData.value)
    if (curFileData.value.isDel == 0) {
        window.$message.warning('该文件不可删除')
    } else {
        const { error, code, data } = await dataApi.removedocuments({
            projectId: projectId.value,
            id: curFileData.value.id,
        })
        if (!error && code === 200) {
            window.$message.success('删除成功')
            refeshAttachmentModalClick(viewAttachmentId.value, tabTypeKey.value)
        }
    }

}

//样品信息数据
const samplingTableColumn = ref([
    { key: 'materialName', name: '样品名称' },
    { key: 'samplingDate', name: '取样时间' },
    { key: 'specificationNumber', name: '样品编号' },
    { key: 'specificationModel', name: '规格型号' },
    { key: 'materialCount', name: '试样数量' },
    { key: 'calculationUnit', name: '计算单位' },
    { key: 'proposedPosition', name: '拟用部位' },
    { key: 'representativeCount', name: '代表数量' },
    { key: 'userName', name: '取样人' },
])
const samplingTableData = ref([])
const samplingTableLoading = ref(false)

//取样记录
const samplingRecordModal = ref(false)
const samplingRecordModalClick = async ({ id }) => {
    samplingRecordModal.value = true
    samplingTableLoading.value = true
    const { error, code, data } = await dataApi.getSampleList({
        projectId: projectId.value,
        id: id,
    })
    //处理数据
    samplingTableLoading.value = false
    if (!error && code === 200) {
        samplingTableData.value = getArrValue(data)
    } else {
        samplingTableData.value = []
    }
}

//关闭样品信息
const samplingRecordModalClose = () => {
    samplingRecordModal.value = false
    samplingTableData.value = []
}

//左右拖动，改变树形结构宽度
const leftWidth = ref(382)
const onmousedown = () => {
    const leftNum = isCollapse.value ? 142 : 272
    document.onmousemove = (ve) => {
        let diffVal = ve.clientX - leftNum
        if (diffVal >= 310 && diffVal <= 900) {
            leftWidth.value = diffVal
        }
    }
    document.onmouseup = () => {
        document.onmousemove = null
        document.onmouseup = null
    }
}

//关联查阅
const isRelatedSearch = ref(false)
const relatedSearchClick = (row) => {
    isRelatedSearch.value = true
    //获取样品信息
    getSampleList(row.id)
    //获取委托单
    getCommissionData(row.entrustId)
    //获取关联设备
    getAcquisitionData(row.loadDataId)
}

//样品信息
const relatedColumn1 = [
    { key: 'materialName', name: '样品名称' },
    { key: 'samplingDate', name: '取样日期' },
    { key: 'specificationNumber', name: '样品编号' },
    { key: 'specificationModel', name: '规格型号' },
    { key: 'materialCount', name: '试样数量' },
    { key: 'calculationUnit', name: '计算单位' },
    { key: 'proposedPosition', name: '拟用部位' },
    { key: 'representativeCount', name: '代表数量' },
    { key: 'userName', name: '取样人' },
    { key: 'carryTime', name: '入库时间', align: 'center' },
    { key: 'createTime', name: '试验时间', align: 'center' },
    { key: 'no-key', name: '样品处理' },
    { key: 'no-key', name: '时间(或处理原因)' },
]
const relatedData1 = ref([])
const getSampleList = async (id) => {
    relatedData1.value = []
    if (isNullES(id) || id == 0) return
    const { data } = await dataApi.getSampleList({ id })
    relatedData1.value = getArrValue(data)
}

//委托单信息
const relatedColumn2 = [
    { key: 'entrustInfo', name: '委托单位' },
    { key: 'entrustNo', name: '委托单编号' },
    { key: 'entrustName', name: '委托单名称' },
    { key: 'status', name: '委托单状态', width: 120, align: 'center' },
]
const relatedData2 = ref([])
const getCommissionData = async (id) => {
    relatedData2.value = []
    if (isNullES(id) || id == 0) return
    const { data } = await commissionApi.detail(id)
    const res = getObjVal(data)
    relatedData2.value = res ? [res] : []
}

//设备采集信息
const relatedColumn3 = [
    { key: 'engineInfo', name: '工程部位' },
    { key: 'deviceName', name: '设备名称' },
    { key: 'equipmentAcquisitionNumber', name: '设备采集编号', width: 180, align: 'center' },
    { key: 'testDate', name: '试验日期', width: 160, align: 'center' },
    { key: 'specificationNumber', name: '样品编号', width: 180, align: 'center' },
    { key: 'testTypeName', name: '试验类型', width: 100, align: 'center' },
    { key: 'beArea', name: '承压面积(mm2)', width: 100, align: 'center' },
    { key: 'specimenSize', name: '试件尺寸(mm)', width: 100, align: 'center' },
    { key: 'desStrength', name: '设计强度(MPa)', width: 100, align: 'center' },
    { key: 'ageDate', name: '龄期(d)', width: 100, align: 'center' },
    { key: 'load1', name: '荷载1(KN)', width: 100, align: 'center' },
    { key: 'load2', name: '荷载2(KN)', width: 100, align: 'center' },
    { key: 'load3', name: '荷载3(KN)', width: 100, align: 'center' },
    { key: 'no-key', name: '荷载4(KN)', width: 100, align: 'center' },
    { key: 'no-key', name: '荷载5(KN)', width: 100, align: 'center' },
    { key: 'no-key', name: '荷载6(KN)', width: 100, align: 'center' },
    { key: 'strengthAVG', name: '强度代表值(MPa)', width: 100, align: 'center' },
    {
        name: '最大力总延伸(%)',
        children: [
            { key: 'maxConceal1', name: '1', width: 100, align: 'center' },
            { key: 'maxConceal2', name: '2', width: 100, align: 'center' },
            { key: 'maxConceal3', name: '3', width: 100, align: 'center' },
        ],
    },
    //{ key: 'dataQualified', name: '试验结果是否合格', width: 100, align: 'center' },
    { key: 'dataStatus', name: '数据状态', width: 100, align: 'center' },
]
const relatedData3 = ref([])
const getAcquisitionData = async (id) => {
    relatedData3.value = []
    if (isNullES(id) || id == 0) return
    const { data } = await acquisitionApi.selectDataInfoById(id)
    const res = getObjVal(data)
    if (res) {
        relatedData3.value = res ? [res] : []
        setRelatedColumn3(res.testTypePId)
    }
}

//设置表头
const setRelatedColumn3 = (type) => {
    //压力机
    if (type === '1') {
        relatedColumn3.value = [
            { key: 'engineInfo', name: '工程部位' },
            { key: 'deviceName', name: '设备名称' },
            { key: 'equipmentAcquisitionNumber', name: '设备采集编号', width: 180, align: 'center' },
            { key: 'testDate', name: '试验日期', width: 160, align: 'center' },
            { key: 'specificationNumber', name: '样品编号', width: 180, align: 'center' },
            { key: 'testTypeName', name: '试验类型', width: 100, align: 'center' },
            { key: 'beArea', name: '承压面积(mm2)', width: 100, align: 'center' },
            { key: 'specimenSize', name: '试件尺寸(mm)', width: 100, align: 'center' },
            { key: 'desStrength', name: '设计强度(MPa)', width: 100, align: 'center' },
            { key: 'no-key', name: '龄期(d)', width: 100, align: 'center' },
            { key: 'load1', name: '荷载1(KN)', width: 100, align: 'center' },
            { key: 'load2', name: '荷载2(KN)', width: 100, align: 'center' },
            { key: 'load3', name: '荷载3(KN)', width: 100, align: 'center' },
            { key: 'no-key', name: '荷载4(KN)', width: 100, align: 'center' },
            { key: 'no-key', name: '荷载5(KN)', width: 100, align: 'center' },
            { key: 'no-key', name: '荷载6(KN)', width: 100, align: 'center' },
            { key: 'no-key', name: '强度代表值(MPa)', width: 100, align: 'center' },
            {
                name: '最大力总延伸(%)',
                children: [
                    { key: 'maxConceal1', name: '1', width: 100, align: 'center' },
                    { key: 'maxConceal2', name: '2', width: 100, align: 'center' },
                    { key: 'maxConceal3', name: '3', width: 100, align: 'center' },
                ],
            },
            //{ key: 'dataQualified', name: '试验结果是否合格', width: 100, align: 'center' },
            { key: 'dataStatus', name: '数据状态', width: 100, align: 'center' },
        ]
    } else if (type === '2') {
        //万能机
        relatedColumn3.value = [
            { key: 'engineInfo', name: '工程部位' },
            { key: 'deviceName', name: '设备名称' },
            { key: 'equipmentAcquisitionNumber', name: '设备采集编号', width: 180, align: 'center' },
            { key: 'testDate', name: '试验日期', width: 160, align: 'center' },
            { key: 'specificationNumber', name: '样品编号', width: 180, align: 'center' },
            { key: 'testTypeName', name: '试验类型', width: 100, align: 'center' },
            { key: 'no-key', name: '牌号', width: 100, align: 'center' },
            { key: 'no-key', name: '公称直径(mm)', width: 100, align: 'center' },
            { key: 'no-key', name: '规格', width: 100, align: 'center' },
            {
                name: '最大力/荷载(KN)',
                children: [
                    { key: 'no-key', name: '1', width: 100, align: 'center' },
                    { key: 'no-key', name: '2', width: 100, align: 'center' },
                    { key: 'no-key', name: '3', width: 100, align: 'center' },
                    { key: 'no-key', name: '4', width: 100, align: 'center' },
                    { key: 'no-key', name: '5', width: 100, align: 'center' },
                    { key: 'no-key', name: '6', width: 100, align: 'center' },
                ],
            },
            {
                name: '抗拉强度/强度代表值(MPa)',
                children: [
                    { key: 'no-key', name: '1', width: 100, align: 'center' },
                    { key: 'no-key', name: '2', width: 100, align: 'center' },
                    { key: 'no-key', name: '3', width: 100, align: 'center' },
                    { key: 'no-key', name: '4', width: 100, align: 'center' },
                    { key: 'no-key', name: '5', width: 100, align: 'center' },
                    { key: 'no-key', name: '6', width: 100, align: 'center' },
                ],
            },
            {
                name: '上屈服力(KN)',
                children: [
                    { key: 'no-key', name: '1', width: 100, align: 'center' },
                    { key: 'no-key', name: '2', width: 100, align: 'center' },
                    { key: 'no-key', name: '3', width: 100, align: 'center' },
                    { key: 'no-key', name: '4', width: 100, align: 'center' },
                    { key: 'no-key', name: '5', width: 100, align: 'center' },
                    { key: 'no-key', name: '6', width: 100, align: 'center' },
                ],
            },
            {
                name: '下屈服力(KN)',
                children: [
                    { key: 'no-key', name: '1', width: 100, align: 'center' },
                    { key: 'no-key', name: '2', width: 100, align: 'center' },
                    { key: 'no-key', name: '3', width: 100, align: 'center' },
                    { key: 'no-key', name: '4', width: 100, align: 'center' },
                    { key: 'no-key', name: '5', width: 100, align: 'center' },
                    { key: 'no-key', name: '6', width: 100, align: 'center' },
                ],
            },
            {
                name: '上屈服强度(MPa)',
                children: [
                    { key: 'no-key', name: '1', width: 100, align: 'center' },
                    { key: 'no-key', name: '2', width: 100, align: 'center' },
                    { key: 'no-key', name: '3', width: 100, align: 'center' },
                    { key: 'no-key', name: '4', width: 100, align: 'center' },
                    { key: 'no-key', name: '5', width: 100, align: 'center' },
                    { key: 'no-key', name: '6', width: 100, align: 'center' },
                ],
            },
            {
                name: '下屈服强度(MPa)',
                children: [
                    { key: 'no-key', name: '1', width: 100, align: 'center' },
                    { key: 'no-key', name: '2', width: 100, align: 'center' },
                    { key: 'no-key', name: '3', width: 100, align: 'center' },
                    { key: 'no-key', name: '4', width: 100, align: 'center' },
                    { key: 'no-key', name: '5', width: 100, align: 'center' },
                    { key: 'no-key', name: '6', width: 100, align: 'center' },
                ],
            },
            { key: 'dataStatus', name: '数据状态', width: 100, align: 'center' },
        ]
    }
}

//关闭关联查阅
const relatedSearchModalClose = () => {
    isRelatedSearch.value = false
    relatedData1.value = []
    relatedData2.value = []
    relatedData3.value = []
}

//表单数据
const formRef = ref(null)
const formModel = ref({})
const formRules = {
    repealType: {
        required: true,
        trigger: 'blur',
        message: '请选择处理方式',
    },
    repealReason: {
        required: true,
        trigger: 'blur',
        message: '请填写处理原因',
    },
    resamStartTime: {
        required: true,
        trigger: 'blur',
        message: '请选择留样时间',
    },
}

//样品处理
const disposeModal = ref(false)
const rowDispose = () => {
    disposeModal.value = true
    const rows = relatedData1.value
    formModel.value = {
        id: arrToId(rows),
        repealType: 1,
    }
}

//日期时间被选择
const formTime = ref(null)
const formTimeUpdate = ({ arr }) => {
    formTime.value = arr
    if (arr.length > 0) {
        formModel.value.resamStartTime = arr[0]
        formModel.value.resamEndTime = arr[1]
    } else {
        formModel.value.resamStartTime = ''
        formModel.value.resamEndTime = ''
    }
}

//确定提交
const saveLoading = ref(false)
const disposeSave = async () => {
    const isForm = await formValidate(formRef.value)
    if (!isForm) return
    const { error, code, msg } = await testSampleApi.update(formModel.value)
    saveLoading.value = false
    if (!error && code === 200) {
        window.$message.success('提交成功')
        disposeClose()
        getTableData().then()
    } else {
        window.$message.error(msg || '操作失败')
    }
}

//关闭弹窗
const disposeClose = () => {
    disposeModal.value = false
    formModel.value = {}
}

//一键重签
const signLoading = ref(false)
const resignModal = ref(false)
const resignModalRadio = ref(0)
const resignClick = async ()=>{
    const rows = tableCheckedKeys.value
    if (rows.length <= 0) {
        window.$message?.warning('请先勾选已审批的数据')
        return
    }

    resignModal.value = true


}
const signClick = async () => {
    const rows = tableCheckedKeys.value
    //获取任务id
    const taskIds = arrToKey(rows, 'id')


    //发起请求
    signLoading.value = true
    const { error, code, msg } = await dataApi.reSigningTrial({

        projectId: projectId.value,
        trialIds: taskIds,
    
        type:resignModalRadio.value,
    })
    //处理数据
    signLoading.value = false

    if (!error && code === 200) {
        window.$message?.success(msg ?? '提交成功，请请耐心等待重签，可继续操作其它的功能。')
        getTableData().then()
    } else {
        window.$message?.error(msg ?? '操作失败')
    }
    resignModal.value = false
}
const cancelresign = ()=>{
    resignModalRadio.value = 0
    resignModal.value = false
}
</script>

<style lang="scss" scoped>
@import "../../../styles/tentative/detect/test.scss";

.hc-switch-tab-content {
    .pdf-file-list-box {
        position: relative;
        border-right: 1px solid #e9e9e9;
        padding: 5px 0;
        overflow-y: auto;
        height: 100%;
        flex: 1;

        .file-item {
            position: relative;
            cursor: pointer;
            padding: 6px 10px;
            &:hover {
                color: var(--el-color-primary);
                background-color: var(--el-color-primary-light-8);
            }
            &.cur {
                color: var(--el-color-primary);
                background-color: var(--el-color-primary-light-8);
            }
        }
    }
    .hc-no-table-form {
        flex: 1;
    }
}
</style>

<style lang="scss">
.hc-related-search-box .hc-card-item-box {
    background: #f5f5f5;
    .hc-card-item-header {
        color: #101010;
        padding-bottom: 14px;
        border-bottom: 1px solid #d6d6d6;
    }
    .hc-card-item-header .item-header {
        font-size: 16px;
    }
}
</style>
