網站首頁 編程語言 正文
<template>
<!-- 托盤標列表 -->
<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">打印托盤標</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:要合并的表格數組
rowProperty:以哪個字段為判斷條件合并
*/
export function setrowspans(tableData, rowProperty) {
// 先給所有的數據都加一個v.rowspan = 1
tableData.forEach(v => {
v.rowspan = 1
})
// 雙層循環
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--
}
}
// 這里跳過已經重復的數據
i = i + tableData[i].rowspan - 1
}
return tableData
}
// 合并的數據重新排序
/*
tableArr:要合并的表格數組
rowProperty:以哪個字段為判斷條件排序
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
相關推薦
- 2022-09-19 C++中的explicit關鍵字詳解_C 語言
- 2022-11-18 Python?數據清洗刪除缺失值替換缺失值詳情_python
- 2022-09-16 python解析照片拍攝時間進行圖片整理_python
- 2022-08-14 git?stash(儲藏)的用法總結_相關技巧
- 2022-06-21 Python+Django實現簡單HelloWord網頁的示例代碼_python
- 2022-09-09 pycharm中創建sql文件及模板的過程_python
- 2022-06-02 關于docker?registry使用詳解_docker
- 2022-08-05 基于python詳解PyScript到底是什么_python
- 最近更新
-
- window11 系統安裝 yarn
- 超詳細win安裝深度學習環境2025年最新版(
- Linux 中運行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎操作-- 運算符,流程控制 Flo
- 1. Int 和Integer 的區別,Jav
- spring @retryable不生效的一種
- Spring Security之認證信息的處理
- Spring Security之認證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權
- redisson分布式鎖中waittime的設
- maven:解決release錯誤:Artif
- restTemplate使用總結
- Spring Security之安全異常處理
- MybatisPlus優雅實現加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務發現-Nac
- Spring Security之基于HttpR
- Redis 底層數據結構-簡單動態字符串(SD
- arthas操作spring被代理目標對象命令
- Spring中的單例模式應用詳解
- 聊聊消息隊列,發送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠程分支