当前位置: 首页 > backend >正文

table表格合并,循环渲染样式

效果 

html 

<table><!-- 标题 --><tr><th colspan="100"><el-input style="width: 300px;" v-model="paymentForm.name"></el-input></th></tr><!-- 栏目 --><tr><th colspan="2"></th><th :colspan="item.child.length" v-for="item, i in paymentForm.titleX" :key="i">{{ item.name }}</th></tr><tr><th colspan="2">摘要</th><template v-for="item, i in paymentForm.titleX" :key="i"><th v-for="item, k in item.child" :key="k">{{ item }}</th></template></tr><!-- 数据内容 --><template v-for="item, i in paymentForm.titleY" :key="i"><!-- 单行展示 --><tr v-show="!item.child" class="red"><td colspan="2">{{ item.name }}</td><td v-for="arr, index in item.arr" :key="index"><el-input v-model="item.arr[index]"></el-input></td></tr><!-- 多行展示 --><tr v-for="item2, k in item.child" :key="k" v-show="item.child.length"><td v-if="k == 0" :rowspan="item.child.length">{{ item.name }}</td><td v-if="item.child.length">{{ item2.name }}</td><td v-for="arr, index in item2.arr" :key="index"><el-input v-model="item2.arr[index]"></el-input></td></tr></template>
</table>

js 

let paymentForm = ref({name: "账户变动情况",titleX: [{ name: '账号1', child: ['基本户建行', '一般户工行1', '一般户工行2', '一般户民生', '农商', '民生', '支付宝'] },{ name: '账号2', child: ['基本户', '支付宝'] },{ name: '账号3', child: ['基本户', '支付宝'] },],titleY: [{ name: '昨日结余', arr: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,] },{name: '收入',child: [{ name: "订单回款", arr: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,] },{ name: "利息", arr: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,] },{ name: "其他", arr: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,] }]},{ name: '收入合计', arr: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,] },{name: '支出',child: [{ name: "工资", arr: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,] },{ name: "社保", arr: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,] },{ name: "还款", arr: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,] },{ name: "其他", arr: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,] }]},{ name: '支出合计', arr: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,] },{ name: '本日余额', arr: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,] },{ name: '合计', arr: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,] }]
})

 css

table {width: 100%;border: 1px solid #ccc;text-align: center;border-collapse: collapse;:deep(.el-input, .el-select, .el-range-editor .el-input__wrapper) {width: 100%;border: none !important;}:deep(.el-input__wrapper) {box-shadow: none !important;}tr {th {padding: 5px 0;border: 1px solid #ccc;text-align: center;min-width: 70px;}td {padding: 5px 0;border: 1px solid #ccc;text-align: center;min-width: 90px;}}.red {color: red;font-weight: 700;}
}

 

 

http://www.xdnf.cn/news/12475.html

相关文章:

  • git commit 执行报错 sh: -/: invalid option
  • SpringBoot+MySQL家政服务平台 设计开发
  • OpenAI对抗法庭命令:捍卫ChatGPT用户隐私之战
  • mybatis的if判断==‘1‘不生效,改成‘1‘.toString()才生效的原因
  • 浏览器后台服务 vs 在线教育:QPS、并发模型与架构剖析
  • 如何对Video视频进行SEO优化?
  • Ubuntu Cursor升级成v1.0
  • 大数据量高实时性场景下订单生成的优化方案
  • 2025主流智能体Agent终极指南:Manus、OpenManus、MetaGPT、AutoGPT与CrewAI深度横评
  • windows上的visual studio2022的项目使用jenkins自动打包
  • Visual Studio问题记录
  • 准确--k8s cgroup问题排查
  • 【学习笔记】构造函数+重载相关
  • 生成 Git SSH 证书
  • Linux 常用命令语法总结
  • 【Go语言基础【9】】字符串格式化与输入处理
  • 神经网络-Day46
  • react 常见的闭包陷阱深入解析
  • 循环神经网络(RNN)
  • 麒麟系统使用-进行.NET开发
  • 1.3 编译程序:单个C文件和多个C文件
  • Python打卡DAY46
  • JSON解析崩溃原因及解决方案
  • linux系统dd 工具介绍
  • 理解JavaScript中map和parseInt的陷阱:一个常见的面试题解析
  • win10+TensorRT+OpenCV+Qt+YOLOV8模型部署教程
  • 2025年多层PCB技术发展与厂商实践指南
  • C++总复习
  • 嵌入式学习笔记 - FreeRTOS 信号量以及释放函数
  • cursor和windsurf使用体验对比