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

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;}
}

 

 

相关文章:

  • Web攻防-SQL注入二次攻击堆叠执行SQLMAPTamper编写指纹修改分析调试
  • NoSQL 之Redis哨兵
  • 【数据结构】图
  • C++课设:简易日历程序(支持传统节假日 + 二十四节气 + 个人纪念日管理)
  • JUC并发—volatile和synchronized原理(二)
  • 麒麟v10系统的docker重大问题解决-不支持容器名称解析
  • 多种风格导航菜单 HTML 实现(附源码)
  • 从模型到生产力:应用集成如何帮助AI实现业务落地
  • Web自动化测试流程
  • pp-ocrv5改进
  • 【AI论文】超越80/20规则:高熵少数令牌驱动LLM推理的有效强化学习
  • 新版双紫擒龙、紫紫红黄、动能二号源码指标源码公式讲解
  • 深入理解 Linux 进程控制
  • vue在打包的时候能不能固定assets里的js和css文件名称
  • 力扣刷题Day 72:寻找旋转排序数组中的最小值(153)
  • 车型库查询接口如何用Java进行调用?
  • coze平台创建智能体,关于智能体后端接入的问题
  • 永磁同步电机无速度算法--基于卡尔曼滤波器的滑模观测器
  • 添加按钮跳转页面并且根据网站的用户状态判断是否显示按钮
  • 贝叶斯网络_TomatoSCI分析日记
  • 婚庆公司网站建设策划书/爱站网seo工具
  • 做网站需要看什么书/国内最新新闻摘抄
  • 网站建设有哪些步骤/推广发布任务平台app下载
  • 时间轴 网站模板/注册网站平台要多少钱
  • 网站优化我自己可以做吗/舆情报告范文
  • 扬州做网站的科技公司/百度信息流优化