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

网站品牌栏目建设淘宝关键词搜索排名

网站品牌栏目建设,淘宝关键词搜索排名,淘宝网站建设的目标是什么,想自己做网站 有免费的吗1. 功能概述 本教程将介绍如何使用 Vue 3 和 arco 组件库实现表格合并功能。具体来说,我们会根据表格数据中的某个字段(如 type)对表格的某一列(如入库类型列)进行合并,同时将质检说明列合并为一列。 2. …
1. 功能概述

本教程将介绍如何使用 Vue 3 和 arco 组件库实现表格合并功能。具体来说,我们会根据表格数据中的某个字段(如 type)对表格的某一列(如入库类型列)进行合并,同时将质检说明列合并为一列。

2. 数据准备

首先,我们需要准备一份数据示例:

import { ref, computed } from 'vue';const storageGoodsVosdata = ref([{id: 1,workOrderId: 'WO001',goodsNo: 'G001',goodsName: 'Test Product 1',skuCode: 'SKU001',skuInfo: 'Color: White; Style: Simple',quantity: 1,type: 0,typeName: 'Defective Incoming',reasonCode: 'R01',reasonCodeStr: 'Label/Certificate/Manual/Missing or Damaged',logisticReceiptsUrls: ['https://example.com/image1.jpg','https://example.com/image2.jpg',],outerPackagingUrls: ['https://example.com/image3.jpg','https://example.com/image4.jpg',],housekeepingDiagramUrls: ['https://example.com/image5.jpg','https://example.com/image6.jpg',],createTime: '2025-02-12 09:43:31',},{id: 2,workOrderId: 'WO001',goodsNo: 'G001',goodsName: 'Test Product 1',skuCode: 'SKU001',skuInfo: 'Color: White; Style: Simple',quantity: 1,type: 0,typeName: 'Defective Incoming',reasonCode: 'R01',reasonCodeStr: 'Label/Certificate/Manual/Missing or Damaged',logisticReceiptsUrls: ['https://example.com/image1.jpg','https://example.com/image2.jpg',],outerPackagingUrls: ['https://example.com/image3.jpg','https://example.com/image4.jpg',],housekeepingDiagramUrls: ['https://example.com/image5.jpg','https://example.com/image6.jpg',],createTime: '2025-02-12 09:43:31',},{id: 3,workOrderId: 'WO001',goodsNo: 'G002',goodsName: 'Test Product 2',skuCode: 'SKU002',skuInfo: 'Color: Black; Style: Modern',quantity: 1,type: 1,typeName: 'Goods Incoming',reasonCode: 'R01',reasonCodeStr: 'Label/Certificate/Manual/Missing or Damaged',logisticReceiptsUrls: ['https://example.com/image7.jpg','https://example.com/image8.jpg',],outerPackagingUrls: ['https://example.com/image9.jpg','https://example.com/image10.jpg',],housekeepingDiagramUrls: ['https://example.com/image11.jpg','https://example.com/image12.jpg',],createTime: '2025-02-12 09:43:31',},{id: 4,workOrderId: 'WO001',goodsNo: 'G002',goodsName: 'Test Product 2',skuCode: 'SKU002',skuInfo: 'Color: Black; Style: Modern',quantity: 1,type: 1,typeName: 'Goods Incoming',reasonCode: 'R01',reasonCodeStr: 'Label/Certificate/Manual/Missing or Damaged',logisticReceiptsUrls: ['https://example.com/image7.jpg','https://example.com/image8.jpg',],outerPackagingUrls: ['https://example.com/image9.jpg','https://example.com/image10.jpg',],housekeepingDiagramUrls: ['https://example.com/image11.jpg','https://example.com/image12.jpg',],createTime: '2025-02-12 09:43:31',},
]);const sortedStorageData = computed(() => {return [...storageGoodsVosdata.value].sort((a, b) => a.type - b.type);
});
3. 表格合并方法

接下来,我们定义一个 spanMethod 函数来处理表格合并逻辑:

function spanMethod({ rowIndex, columnIndex }) {if (columnIndex === 0) { // 只处理第一列(入库类型列)const arr = sortedStorageData.value;const item = arr[rowIndex];// 如果是第一行,或者当前行的类型与前一行不同if (rowIndex === 0 || arr[rowIndex - 1].type !== item.type) {// 计算当前类型的连续行数const count = arr.slice(rowIndex).findIndex(row => row.type !== item.type);return {rowspan: count === -1 ? arr.length - rowIndex : count,colspan: 1,};}// 其他行不显示return {rowspan: 0,colspan: 0,};}// 处理质检说明列(最后一列)if (columnIndex === 8) { // 质检说明列的索引if (rowIndex === 0) {return {rowspan: sortedStorageData.value.length,colspan: 1,};}return {rowspan: 0,colspan: 0,};}
}
模板部分

最后,我们在模板中使用 a-table 组件来渲染表格,并绑定数据和合并方法:

<template><a-table:data="sortedStorageData":bordered="{ cell: true }":pagination="false":span-method="spanMethod"><template #columns><a-table-column title="Incoming Type" data-index="typeName" align="center" :min-width="180"><template #cell="{ record }">{{ record.type === 1 ? 'Goods Incoming' : 'Defective Incoming' }}</template></a-table-column><a-table-columntitle="Product SKU Number"data-index="salary"align="center":min-width="180"><template #cell="{ record }">{{ record.goodsNo }}</template></a-table-column><a-table-columncell-class="custom-col"title="Product Name"data-index="goodsNo"align="center":min-width="180"><template #cell="{ record }"><div class="good-item-wrapper">{{ record.goodsName }}</div></template></a-table-column><a-table-columncell-class="custom-col"title="Quantity"data-index="goodsName"align="center":min-width="180"><template #cell="{ record }"><div class="good-item-wrapper">×{{ record.quantity }}</div></template></a-table-column><a-table-column cell-class="custom-col" title="Defective Reason" data-index="spec" align="center" :min-width="180"><template #cell="{ record }"><div class="good-item-wrapper">{{ record.type === 1 ? '--' : record.reasonCodeStr }}</div></template></a-table-column><a-table-columncell-class="custom-col"title="Logistic Receipts"data-index="quantity"align="center":min-width="180"><template #cell="{ record }"><div class="good-item-wrapper"><div v-show="record.type === 1">--</div><div style="display: flex; gap: 5px;"><a-imagev-for="item in record.logisticReceiptsUrls"v-show="record.type === 0":key="item"width="30":src="item"/></div></div></template></a-table-column><a-table-columncell-class="custom-col"title="Outer Packaging"data-index="quantity"align="center":min-width="180"><template #cell="{ record }"><div class="good-item-wrapper"><div v-show="record.type === 1">--</div><div style="display: flex; gap: 5px;"><a-imagev-for="item in record.outerPackagingUrls"v-show="record.type === 0":key="item"width="30":src="item"/></div></div></template></a-table-column><a-table-columncell-class="custom-col"title="Housekeeping Diagram"data-index="quantity"align="center":min-width="180"><template #cell="{ record }"><div class="good-item-wrapper"><div v-show="record.type === 1">--</div><div style="display: flex; gap: 5px;"><a-imagev-for="item in record.housekeepingDiagramUrls"v-show="record.type === 0":key="item"width="30":src="item"/></div></div></template></a-table-column><a-table-columncell-class="custom-col"title="Quality Inspection Note"data-index="quantity"align="center":min-width="180"><template #cell="{ record }"><div class="good-item-wrapper"><!-- 这里可以替换为实际的质检说明数据 -->质检说明</div></template></a-table-column></template></a-table>
</template><script setup>
import { ref, computed } from 'vue';
import { ATable, ATableColumn, AImage } from 'ant-design-vue';const storageGoodsVosdata = ref([{id: 1,workOrderId: 'WO001',goodsNo: 'G001',goodsName: 'Test Product 1',skuCode: 'SKU001',skuInfo: 'Color: White; Style: Simple',quantity: 1,type: 0,typeName: 'Defective Incoming',reasonCode: 'R01',reasonCodeStr: 'Label/Certificate/Manual/Missing or Damaged',logisticReceiptsUrls: ['https://example.com/image1.jpg','https://example.com/image2.jpg',],outerPackagingUrls: ['https://example.com/image3.jpg','https://example.com/image4.jpg',],housekeepingDiagramUrls: ['https://example.com/image5.jpg','https://example.com/image6.jpg',],createTime: '2025-02-12 09:43:31',},{id: 2,workOrderId: 'WO001',goodsNo: 'G001',goodsName: 'Test Product 1',skuCode: 'SKU001',skuInfo: 'Color: White; Style: Simple',quantity: 1,type: 0,typeName: 'Defective Incoming',reasonCode: 'R01',reasonCodeStr: 'Label/Certificate/Manual/Missing or Damaged',logisticReceiptsUrls: ['https://example.com/image1.jpg','https://example.com/image2.jpg',],outerPackagingUrls: ['https://example.com/image3.jpg','https://example.com/image4.jpg',],housekeepingDiagramUrls: ['https://example.com/image5.jpg','https://example.com/image6.jpg',],createTime: '2025-02-12 09:43:31',},{id: 3,workOrderId: 'WO001',goodsNo: 'G002',goodsName: 'Test Product 2',skuCode: 'SKU002',skuInfo: 'Color: Black; Style: Modern',quantity: 1,type: 1,typeName: 'Goods Incoming',reasonCode: 'R01',reasonCodeStr: 'Label/Certificate/Manual/Missing or Damaged',logisticReceiptsUrls: ['https://example.com/image7.jpg','https://example.com/image8.jpg',],outerPackagingUrls: ['https://example.com/image9.jpg','https://example.com/image10.jpg',],housekeepingDiagramUrls: ['https://example.com/image11.jpg','https://example.com/image12.jpg',],createTime: '2025-02-12 09:43:31',},{id: 4,workOrderId: 'WO001',goodsNo: 'G002',goodsName: 'Test Product 2',skuCode: 'SKU002',skuInfo: 'Color: Black; Style: Modern',quantity: 1,type: 1,typeName: 'Goods Incoming',reasonCode: 'R01',reasonCodeStr: 'Label/Certificate/Manual/Missing or Damaged',logisticReceiptsUrls: ['https://example.com/image7.jpg','https://example.com/image8.jpg',],outerPackagingUrls: ['https://example.com/image9.jpg','https://example.com/image10.jpg',],housekeepingDiagramUrls: ['https://example.com/image11.jpg','https://example.com/image12.jpg',],createTime: '2025-02-12 09:43:31',},
]);const sortedStorageData = computed(() => {return [...storageGoodsVosdata.value].sort((a, b) => a.type - b.type);
});
function spanMethod({ rowIndex, columnIndex }) {if (columnIndex === 0) { // 只处理第一列(入库类型列)const arr = sortedStorageData.value;const item = arr[rowIndex];// 如果是第一行,或者当前行的类型与前一行不同if (rowIndex === 0 || arr[rowIndex - 1].type !== item.type) {// 计算当前类型的连续行数const count = arr.slice(rowIndex).findIndex(row => row.type !== item.type);return {rowspan: count === -1 ? arr.length - rowIndex : count,colspan: 1,};}// 其他行不显示return {rowspan: 0,colspan: 0,};}// 处理质检说明列(最后一列)if (columnIndex === 8) { // 质检说明列的索引if (rowIndex === 0) {return {rowspan: sortedStorageData.value.length,colspan: 1,};}return {rowspan: 0,colspan: 0,};}
}
</script><style scoped>
.custom-col {/* 可以添加自定义样式 */
}.good-item-wrapper {/* 可以添加自定义样式 */
}
</style>
5. 解释
  • 数据排序:使用 computed 计算属性对数据进行排序,确保相同类型的数据相邻。
  • 表格合并逻辑spanMethod 函数根据列索引和行索引来决定哪些单元格需要合并。对于入库类型列,根据 type 字段合并相同类型的行;对于质检说明列,将所有行合并为一列。
  • 模板渲染:使用 a-table 组件渲染表格,并通过 #columns 插槽定义表格列。每个列可以通过 #cell 插槽自定义单元格内容。

通过以上步骤,你就可以实现一个带有合并单元格功能的表格。

6. 效果

在这里插入图片描述

http://www.dtcms.com/wzjs/88942.html

相关文章:

  • vs2012手机网站开发教程苏州网站优化排名推广
  • 最好的建站公司免费下载优化大师
  • 网站上传的图片不显示搜索引擎怎么做
  • 常德建设公司网站网上学电脑培训中心
  • ppt设计培训班重庆做seo外包的
  • 重庆南岸网站建设b2b和b2c是什么意思
  • 美女做直播网站有哪些网站优化包括对什么优化
  • 专门做名片的网站长春网站制作
  • 四川城乡与建设厅网站网站制作app免费软件
  • 域名申请成功后怎么做网站怎么创建网页链接
  • 北京网络营销网站网络营销课程作业
  • 建什么网站做cpa赣州seo唐三
  • 网站仿站教程神马seo教程
  • 郑州发布最新消息今天拼多多seo搜索优化
  • 网站建设 工具seo黑帽多久入门
  • 做网站主要注意些什么seo智能优化系统
  • 建设网站对服务器有什么要求个人接外包项目平台
  • wordpress对接COS后网站变慢seo与网络推广的区别和联系
  • 徐州网站优化seo外链优化
  • 化妆品网站建设目标与期望全国疫情实时动态
  • 网站目标关键词阿里巴巴国际贸易网站
  • asp.net网站设计分工营销方案ppt
  • 静海的做网站苏州网站优化排名推广
  • wordpress 音乐站主题贵州seo技术培训
  • 大型网站tag标签 索引百度seo培训要多少钱
  • java购物网站开发流程市场监督管理局职责
  • 企业创建网站厦门网站搜索引擎优化
  • wordpress企业免费模板南通seo网站优化软件
  • 西安网站制作工程师永久免费google搜索引擎
  • 做推广的网站需要注意什么开创集团与百度