<el-table
id="tableId"
ref="multipleTable"
:data="tableData"
stripe
border
tooltip-effect="dark"
style="width: 100%"
@selection-change="handleSelectionChange">
<el-table-column
type="selection"
width="55">
</el-table-column>
<el-table-column
v-for="(item,key) in zdList"
:prop="item.zd_En"
:label="item.zd_Cn"
:key="key"
show-overflow-tooltip
:visible="item.isTrue"
>
</el-table-column>
<el-table-column
label="操作"
width="120">
<template v-slot="scope">
<el-button
v-if="scope.row.model_file"
type="primary"
size="small"
round
@click="downloadFile(scope.row.model_file)">
下载文件
</el-button>
</template>
</el-table-column>
</el-table>
<transition name="fade">
<div class="columnOption" v-show="isShowColumn">
<div class="content">
<div class="head">选择显示字段</div>
<div class="body">
<el-checkbox v-model="checkList[item.zd_En]" v-for="(item,key) in zdList" :key="key" >{{ item.zd_Cn }}</el-checkbox>
<br>
</div>
<div class="footer">
<el-button size="small" type="primary" plain @click="saveColumn"
>保存列配置
</el-button
>
</div>
</div>
</div>
</transition>
let isShowColumn = ref(false)
const zdList = ref([])
const checkList= ref([])
const saveColumn = () => {
zdList.value.forEach(item => {
item.isTrue = checkList.value.includes(item.zd_En);
});
isShowColumn.value = false;
}
const handleNodeClick = async (data) => {
queryConditions.value = {};
if (tableNameArr === '') {
tableNameArr = 'm_model'
} else {
tableNameArr = data.tableName
}
// 获取表结构的查询参数
const tableStructureParams = {table_name: tableNameArr, b_visible: 1};
try {
// 获取表结构
const tableStructureResponse = await axios.post(
"http://localhost:9997/data/query",
tableStructureParams,
{
params: {
tableName: "table_structure",
}
}
);
if (tableStructureResponse.status === 200) {
// 更新 zdList.value
zdList.value = tableStructureResponse.data;
console.log(zdList.value)
getTableData()
selectIfAddOrUpdate()
fetchTableFields()
} else {
console.error('获取表结构失败,错误码:', tableStructureResponse.status);
}
} catch (error) {
console.error('请求表结构出错:', error);
}
};
根据以上代码帮我实现表格列的显示与隐藏@码农阿豪