網(wǎng)站首頁 編程語言 正文
<template>
<!-- 托盤標(biāo)列表 -->
<UK-Table
:data="trayTableData"
@getSelection="getSelection"
showCheckBox
showIndex
:rowHeader="trayRowHeader"
showSet
:objectSpanMethod="objectSpanMethod"
>
<template #headerFloatLeft>
<el-button type="primary" @click="uploadingDetail('上傳打托文件')">
上傳打托文件
<i class="el-icon-upload el-icon--right"></i>
</el-button>
<el-button type="primary" @click="printOrder">打印托盤標(biāo)</el-button>
</template>
<template #tableButton>
<el-button :type="trayTableData.length ? 'warning' : ''" :disabled="!trayTableData.length" @click="carpoolingOrder"
>拼車下單</el-button
>
<el-button :type="trayTableData.length ? 'primary' : ''" :disabled="!trayTableData.length" @click="returnTop"
>返庫上架</el-button
>
</template>
</UK-Table>
</template>
<script>
import { setrowspans, getWordCnt } from '@/utils/mergeCells'
export default {
methods: {
getList(val) {
if (val) {
this.detailId = val.Id
this.IsConfirm = val.IsConfirm
}
overseasReplenPalletGetDetail(this.detailId).then(res => {
if (res.ErrorCode === 0) {
const { BaseInfo, ReplenishOrderList, TrayLabelList } = res.Body
ReplenishOrderList.forEach(v => {
v.ItemInfo.forEach(item => {
this.PlanCtnsTotal += item.PlanCtns
this.CtnsTotal += item.Ctns
})
})
this.formInline = BaseInfo
this.replenishOrderList = ReplenishOrderList
// 單元格合并
this.trayTableData = setrowspans(TrayLabelList, 'FnSku')
// 合并的單元格重新排序
this.trayTableData = getWordCnt(TrayLabelList, 'FnSku', 'TrayIndex')
}
})
},
// 表格合并
objectSpanMethod({ row, columnIndex }) {
if ([2, 3].includes(columnIndex)) {
return {
rowspan: row.rowspan,
colspan: 1
}
}
},
}
}
</script>
mergeCells.js
/*
tableData:要合并的表格數(shù)組
rowProperty:以哪個(gè)字段為判斷條件合并
*/
export function setrowspans(tableData, rowProperty) {
// 先給所有的數(shù)據(jù)都加一個(gè)v.rowspan = 1
tableData.forEach(v => {
v.rowspan = 1
})
// 雙層循環(huán)
for (let i = 0; i < tableData.length; i++) {
for (let j = i + 1; j < tableData.length; j++) {
if (tableData[j][rowProperty] && tableData[i][rowProperty] === tableData[j][rowProperty]) {
tableData[i].rowspan++
tableData[j].rowspan--
}
}
// 這里跳過已經(jīng)重復(fù)的數(shù)據(jù)
i = i + tableData[i].rowspan - 1
}
return tableData
}
// 合并的數(shù)據(jù)重新排序
/*
tableArr:要合并的表格數(shù)組
rowProperty:以哪個(gè)字段為判斷條件排序
customIndex:自定義排序的字段
*/
export function getWordCnt(tableArr, rowProperty, customIndex) {
let temporaryFnSku = ''
let num = 0
for (let i = 0, l = tableArr.length; i < l; i++) {
if (tableArr[i][rowProperty] !== temporaryFnSku) {
num = 0
}
temporaryFnSku = tableArr[i][rowProperty]
if (tableArr[i][rowProperty] === temporaryFnSku) {
num++
tableArr[i][customIndex] = num
}
}
return tableArr
}
效果圖
原文鏈接:https://blog.csdn.net/weixin_46060121/article/details/125857937
相關(guān)推薦
- 2023-03-27 python去除空格,tab制表符和\n換行符的小技巧分享_python
- 2022-04-30 WPF在自定義文本框中實(shí)現(xiàn)輸入法跟隨光標(biāo)_實(shí)用技巧
- 2022-04-09 SpringBoot 提示:RequestRejectedException:The request
- 2022-10-17 PaddleOCR?識別表情包文字示例詳解_python
- 2022-02-01 通過url路徑下載服務(wù)器文件
- 2022-12-07 C語言程序中結(jié)構(gòu)體的內(nèi)存對齊詳解_C 語言
- 2022-05-24 Go中的新增對模糊測試的支持_Golang
- 2022-03-23 C語言實(shí)現(xiàn)簡單的三子棋游戲源碼_C 語言
- 最近更新
-
- window11 系統(tǒng)安裝 yarn
- 超詳細(xì)win安裝深度學(xué)習(xí)環(huán)境2025年最新版(
- Linux 中運(yùn)行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎(chǔ)操作-- 運(yùn)算符,流程控制 Flo
- 1. Int 和Integer 的區(qū)別,Jav
- spring @retryable不生效的一種
- Spring Security之認(rèn)證信息的處理
- Spring Security之認(rèn)證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權(quán)
- redisson分布式鎖中waittime的設(shè)
- maven:解決release錯(cuò)誤:Artif
- restTemplate使用總結(jié)
- Spring Security之安全異常處理
- MybatisPlus優(yōu)雅實(shí)現(xiàn)加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務(wù)發(fā)現(xiàn)-Nac
- Spring Security之基于HttpR
- Redis 底層數(shù)據(jù)結(jié)構(gòu)-簡單動態(tài)字符串(SD
- arthas操作spring被代理目標(biāo)對象命令
- Spring中的單例模式應(yīng)用詳解
- 聊聊消息隊(duì)列,發(fā)送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠(yuǎn)程分支