<template> <el-card class="box-card"> <el-table :data="tableData" v-loading="loading" element-loading-text="数据加载中..." :span-method="objectSpanMethod" :border="true" max-height="400px" > <el-table-column label="评价类型" prop="evaluationType" width="120" /> <el-table-column label="控制项" prop="controlItem" width="240" /> <el-table-column label="评价标准" prop="evaluationCriterion" /> <el-table-column label="是否达标" prop="status" width="100"> <template #default="{ row }"> <el-switch v-model="row.status" active-value="1" inactive-value="0" :disabled="true" /> </template> </el-table-column> <el-table-column label="佐证材料" align="center" width="200"> <template #default="{ row }"> <div class="file-list"> <div class="file" v-for="file in row.fileSaveRequestList" > <span class="ellipsis" :title="file.name" @click="handlePreview(file)" >{{ file.name }}</span> </div> </div> </template> </el-table-column> </el-table> </el-card> </template> <script setup> import useTable from './mixins' const { proxy } = getCurrentInstance(); const { treeData, loading, tableData, setMergeData, handlePreview, } = useTable(proxy, 'evaluationCriterion') const getDetail = (data) => { if(!data) return setFields(data, '0') setSort(data) setMergeData(data) treeData.value = data } const setFields = (data, level) => { for (const item of data) { item.level = level if(!item.fileSaveRequestList) { item.fileSaveRequestList = [] } switch (level) { case '0': item.sort = item.evaluationTypeRank break; case '1': item.sort = item.controlItemRank break; case '2': item.sort = item.evaluationCriterionRank break; default: break; } if(item.children) { setFields(item.children, level * 1 + 1 + '') } } } const setSort = (data) => { data.sort((a, b) => { return b.sort - a.sort }) for (const item of data) { if(item.children) { setSort(item.children) } } } // 表数据合并 const objectSpanMethod = ({ row, column, rowIndex, columnIndex }) => { if(columnIndex === 0){ const rowspan = row.length1 - rowIndex === row.sum1 ? row.sum1 : 0 return { rowspan, colspan: 1 } } else if(columnIndex === 1) { const rowspan = row.length2 - rowIndex === row.sum2 ? row.sum2 : 0 return { rowspan, colspan: 1 } } } defineExpose({ getDetail }) </script> <style lang="scss" scoped> .pointer { cursor: pointer; } .disabled { cursor: not-allowed !important; } .file-list { .file { display: flex; align-items: center; } .del { flex-shrink: 0; color: #f56c6c; cursor: pointer; margin-left: 10px; } .disabled { cursor: not-allowed !important; } } .ellipsis { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; cursor: pointer; } </style>