<el-table-column
v-for="(item,key) in zdList"
:prop="item.zd_En"
:label="item.zd_Cn"
:key="key"
:visible="item.isTrue"
>
</el-table-column>
<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>
const zdList = ref([])
const checkList= ref({})
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;
zdList.value.forEach(item => {
checkList.value[item.zd_En] = item.isTrue; // Initialize all columns as visible
});
getTableData()
selectIfAddOrUpdate()
fetchTableFields()
} else {
console.error('获取表结构失败,错误码:', tableStructureResponse.status);
}
} catch (error) {
console.error('请求表结构出错:', error);
}
};
const saveColumn = () => {
isShowColumn.value = false;
}
我想实现vue动态显示table表格某个列 以上方法应该可以实现,但是调用无法控制显示与隐藏 请大家帮忙看看
isTrue是数据库查询出来的数据