vue动态table 动态表头数据+动态列表数据

server/2025/2/11 19:36:03/

效果图:
在这里插入图片描述

javascript"><template><div style="padding: 20px"><el-scrollbar><div class="scrollbar-flex-content"><div class="opt-search"><div style="width: 100px"> </div><div class="opt-box"><el-button type="primary" @click="selectClounm"> 选择列 </el-button><el-dropdown placement="bottom-start" style="margin: 0 15px"><el-button type="primary"> 批量操作 </el-button><template #dropdown><el-dropdown-menu><el-dropdown-item><el-icon><View /></el-icon>批量转换工作项状态</el-dropdown-item><el-dropdown-item @click="handleBatch('copy')"><el-icon><CopyDocument /></el-icon> 批量复制</el-dropdown-item><el-dropdown-item @click="deleteDatil"><el-icon><DeleteFilled /></el-icon>批量删除</el-dropdown-item><el-dropdown-item @click="handleBatch('move')"><el-icon><Switch /></el-icon> 批量移动</el-dropdown-item><el-dropdown-item><el-icon><HelpFilled /></el-icon> 导入需求</el-dropdown-item><el-dropdown-item><el-icon><HelpFilled /></el-icon> 导出需求</el-dropdown-item></el-dropdown-menu></template></el-dropdown></div></div><!-- <div>选择结果: {{ multipleSelection }}</div> --><el-table :data="tableData" style="width: 100%" @selection-change="handleSelectionChange" v-loading="loading" table-layout="auto"><el-table-column type="selection" width="55" fixed/><el-table-column sortable label="Id" prop="workitemId" fixed width="150" align="center"></el-table-column><el-table-columnsortablev-for="item in showTableColumn":key="item.prop":fixed="item.fixed":align="item.align":prop="item.prop":min-width="item.minWidth":width="item.width":show-overflow-tooltip="item.tooltip":resizable="item.resizable":label="item.label":formatter="formatterValue"><template #default="{row}"><!-- link --><template v-if="item.prop === 'title'"><el-link  type="primary" :underline="false" @click="showDetail(row)"> {{row.title }} </el-link></template><template v-if="item.prop === 'description'"><span v-html="formattedUsers(row.description)"></span></template></template></el-table-column><!-- <el-table-column prop="action" label="操作" width="100"><template #default="scope"><el-buttonsize="small"type="primary"linkicon="Edit"@click="edit(scope.row)">编辑</el-button></template></el-table-column> --></el-table><el-paginationstyle="margin-top: 20px"v-model:current-page="pager.num"v-model:page-size="pager.size":page-sizes="[10, 20, 30, 50]"layout="total,sizes, prev, pager, next":total="total"@size-change="handleSizeChange"@current-change="handleCurrentChange"/></div></el-scrollbar></div><listTable ref="rowRef" /><batchActionDialogv-model="batchTypeV"v-model:visible="batchTypeV":batchType="batchType":title="`${batchType === 'move' ? '移动' : '复制'}工作项`"></batchActionDialog><showDialog ref="showDialogRef" :showTableColumn="citiesArr" @reqGetlist="reqGetlist" @reqGetProjectViews="reqGetProjectViews" :itemsArr="items" :visible.sync="visible" @closeShowDialog="closeShowDialog"></showDialog><detailShowDialog ref="RefdetailShowDialog" :detailTitle="detailTitle" :detailVisable.sync="detailVisable" @reqGetlist="reqGetlist" @reqGetProjectViews="reqGetProjectViews" @closeDetailDialog="closeDetailDialog"></detailShowDialog>
</template><script setup>
import { ref, onMounted, computed, watch, nextTick } from 'vue'
import { treeTask , listColumns, tabledrawer, workitemInstIds,projectId } from '../info'
import listTable from './listComponents/list-table.vue'
import { deleteInst,allFilterFields,getlist } from '@/api/workitem'
import batchActionDialog from './detailComponents/batchAction.vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import showDialog from './components/workflow/listShowDialog.vue'
import detailShowDialog from './components/workflow/detailShowDialog.vue'
import asc from "@/utils/asc.js"
const checkedValues = ref([])
const expandableColumns = ref([])let loading = ref(true)
let showTableColumn = ref([])
let visible = ref(false)const formattedUsers = (val)=> { return JSON.parse(JSON.stringify(asc.decrypt(val)))
}const multipleSelection = ref([]);
const handleSelectionChange = (rows) => {// console.log(rows)workitemInstIds.value = rows.map((item) => item.workitemInstId)multipleSelection.value = workitemInstIds.value// console.log(workitemInstIds.value.join(','))
}
watch(() => treeTask.value.workitemTypeId,() => {// drawTable()reqGetProjectViews()reqGetlist()}
)const edit = (row) => { console.log(row);
}
let detailVisable = ref(false)
let RefdetailShowDialog = ref(false)
let detailTitle = ref('')
const showDetail = (row) => {// console.log(row);detailTitle.value = {workitemTypeIcon:row.workitemTypeIcon,workitemId:row.workitemId,title:row.title// `${row.workitemId} - ${row.title}`}detailVisable.value = trueRefdetailShowDialog.value.oneDetail(row.workitemInstId)
}
const closeDetailDialog = () => { detailVisable.value = false
}
//
let citiesArr = computed(() => {let cities =  showTableColumn.value.map(item => item.label)return cities
})
let items = computed(() => {let items = showTableColumn.value.map((item, index) => {return {...item,id: index + 1,checked: true};
});return items
})
onMounted(() => {// drawTable()reqGetProjectViews()reqGetlist()
})
const pager =reactive({num: 1,size: 10
})
const handleSizeChange = (val) => {pager.size = valreqGetlist()
}
const handleCurrentChange = (val) => {pager.num = valreqGetlist()
}let showDialogRef = ref('')
const selectClounm = async () => {visible.value = true
}
// 关闭弹层
const closeShowDialog = () => { visible.value = false
}// 表头
const reqGetProjectViews = async()=>{ const { rows:res } = await allFilterFields(projectId.value, treeTask.value.workitemTypeId ||'202501101355540000079e3d84c60223')const arr = res.map(item => ({...item,prop: item.name,tooltip: true,align: 'center',}))showTableColumn.value = arr.sort((a, b) => a.sort - b.sort )console.log(showTableColumn.value);// console.log(arr);
}const SearchText = ref(null)
const total = ref(0)
const tableData = ref([])
// 列表
const reqGetlist = async () => {loading.value = true const res = await getlist({pageNum: pager.num,pageSize: pager.size,title: SearchText.value});tableData.value = res.rows.map(item => ({workitemType: item.workitemTypeName,status: item.status,testResult: item.title,title: item.title,assignee: item.assignee,testSteps: item.title,description: item.description,project: item.projectName,priority:item.priority,author: item.createBy,workitemId: item.workitemId,workitemInstId: item.workitemInstId,workitemTypeIcon:item.workitemTypeIcon}))total.value = res.totalloading.value = false
}const rowRef = ref(null)//删除,移动,复制-------------------------------------------------
let handleNodeClick = inject('handleNodeClick')
const deleteDatil = () => {deleteInst(workitemInstIds.value.join(',')).then(({ code }) => {handleNodeClick(treeTask.value)VFormRenderV.value = falsecheckListIndex.value = nulllistTask.value = {}infoTaskIcon.value = ''ElMessage.success('删除成功!')})
}
const batchType = ref('')
const batchTypeV = ref(false)
const handleBatch = (type) => {batchType.value = typebatchTypeV.value = true
}
const getTableHeight = computed(() => {console.log(window.innerHeight - 440, 's duosao')return window.innerHeight - 440
})
</script>
<style lang="scss" scoped>
.check {display: flex;align-items: center;
}
.checkbox-group-flex {margin-left: 10px;display: flex;flex-direction: column; /* 设置为列方向布局,使内部元素垂直排列 */
}
.opt-search {flex-shrink: 0;padding: 10px 0;display: flex;align-items: center;justify-content: space-between;border-bottom: 1px solid #fdfdfd;.opt-box {display: flex;align-items: center;}
}
.borderno {--el-tag-border-color: none;
}</style>

http://www.ppmy.cn/server/166839.html

相关文章

centos 和 ubuntu 区别

一、发行版与支持 1. CentOS 是基于 Red Hat Enterprise Linux&#xff08;RHEL&#xff09;源代码重新编译而成的社区版&#xff0c;遵循开源协议。一般由社区进行维护&#xff0c;每 7 年左右发布一个主要版本&#xff0c;注重稳定性和长期支持&#xff0c;适合对系统稳定性…

面向对象设计在Java程序开发中的最佳实践研究

面向对象设计在Java程序开发中的最佳实践研究 面向对象设计&#xff08;Object-Oriented Design&#xff0c;OOD&#xff09;是Java程序开发的核心思想。通过合理运用OOD原则&#xff0c;开发者可以构建可维护、可扩展和高效的系统。本文将探讨面向对象设计在Java开发中的最佳…

数据结构在 Web 开发中的重要性与应用

数据结构是 Web 开发的基石&#xff0c;直接关系到应用程序的效率、可扩展性和可维护性。 根据实际需求选择合适的数据结构&#xff0c;能够有效优化性能、简化代码&#xff0c;并提升用户体验。 本文将深入探讨 PHP 和 Laravel 中的常用数据结构&#xff0c;并结合实际案例&am…

Java高频面试之SE-19

hello啊&#xff0c;各位观众姥爷们&#xff01;&#xff01;&#xff01;本baby今天又来了&#xff01;哈哈哈哈哈嗝&#x1f436; 什么是序列化&#xff1f;什么是反序列化&#xff1f; 序列化&#xff08;Serialization&#xff09; 定义&#xff1a; 序列化是将对象的状…

前端权限控制和管理

前端权限控制和管理 1.前言2.权限相关概念2.1权限的分类(1)后端权限(2)前端权限 2.2前端权限的意义 3.前端权限控制思路3.1菜单的权限控制3.2界面的权限控制3.3按钮的权限控制3.4接口的权限控制 4.实现步骤4.1菜单栏控制4.2界面的控制(1)路由导航守卫(2)动态路由 4.3按钮的控制…

CEF132 编译指南 MacOS 篇 - 基础开发工具安装实战 (二)

1. 引言 在 macOS 平台上编译 CEF132 之前&#xff0c;首要任务是搭建一个完善的开发环境。与 Windows 和 Linux 环境不同&#xff0c;macOS 的开发环境主要以 Xcode 为核心。本篇将作为 CEF132 编译指南系列的第二篇&#xff0c;详细指导读者如何在 macOS 系统上安装和配置 X…

DeepSeek图解10页PDF

以前一直在关注国内外的一些AI工具&#xff0c;包括文本型、图像类的一些AI实践&#xff0c;最近DeepSeek突然爆火&#xff0c;从互联网收集一些资料与大家一起分享学习。 本章节分享的文件为网上流传的DeepSeek图解10页PDF&#xff0c;免费附件链接给出。 1 本地 1 本地部…

LLM Note

PreNorm vs PostNorm Transformer Layer中有两处残连接&#xff0c;分别是网络输入 x \boldsymbol x x与SelfAttention层和MLP/FFN层的输出。 前标准化&#xff1a; 标准化在残连接add之前&#xff0c;即对SelfAttention/MLP层的输入进行标准化&#xff0c;将其输出再与输入相…