|
|
|
@ -786,15 +786,6 @@ export default {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (column.field === 'kgs' || column.field === 'tareweight') {
|
|
|
|
|
// let nowIndex = 0
|
|
|
|
|
// this.tableData.map((item, index) => {
|
|
|
|
|
// if (item.rowKey === row.rowKey) {
|
|
|
|
|
// nowIndex = index
|
|
|
|
|
// }
|
|
|
|
|
// })
|
|
|
|
|
// this.tableData[nowIndex]['weighkgs'] = Number(this.tableData[nowIndex].kgs) + Number(this.tableData[nowIndex].tareweight)
|
|
|
|
|
// row['weighkgs'] = Number(row['kgs']) + Number(row['tareweight'])
|
|
|
|
|
// debugger
|
|
|
|
|
row['weighkgs'] = this.calc(Number(row['kgs']), Number(row['tareweight']), '+')
|
|
|
|
|
const kgsVal = row['weighkgs'] + ''
|
|
|
|
|
const kgsIndex = kgsVal.includes('.') ? kgsVal.indexOf('.') + 1 : false
|
|
|
|
@ -908,10 +899,170 @@ export default {
|
|
|
|
|
this.log({ data, selectionRangeIndexes, selectionRangeKeys })
|
|
|
|
|
},
|
|
|
|
|
beforePaste: ({ data, selectionRangeIndexes, selectionRangeKeys }) => {
|
|
|
|
|
this.log({ data, selectionRangeIndexes, selectionRangeKeys })
|
|
|
|
|
const changeValue = data[0][selectionRangeKeys.endColKey]
|
|
|
|
|
if (this.inTableLoad) {
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
if (
|
|
|
|
|
['pkgs', 'kgs', 'cbm', 'tareweight'].includes(selectionRangeKeys.endColKey) &&
|
|
|
|
|
!new RegExp(/^[+]{0,1}(\d+)$|^[+]{0,1}(\d+\.\d+)$/).test(changeValue)
|
|
|
|
|
) {
|
|
|
|
|
const height = document.body.clientHeight - 100
|
|
|
|
|
this.$message.config({
|
|
|
|
|
top: `${height}px`,
|
|
|
|
|
duration: 2,
|
|
|
|
|
maxCount: 3
|
|
|
|
|
})
|
|
|
|
|
this.$message.error(`输入的${this.enmuErrorLabel(selectionRangeKeys.endColKey)}不符合规则`)
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
this.$message.destroy()
|
|
|
|
|
this.$message.config({
|
|
|
|
|
top: `100px`,
|
|
|
|
|
duration: 2,
|
|
|
|
|
maxCount: 3
|
|
|
|
|
})
|
|
|
|
|
}, 2000)
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
if (selectionRangeKeys.endColKey === 'cntrno') {
|
|
|
|
|
const res = this.checkCntrno(changeValue)
|
|
|
|
|
if (res !== '') {
|
|
|
|
|
const height = document.body.clientHeight - 100
|
|
|
|
|
this.$message.config({
|
|
|
|
|
top: `${height}px`,
|
|
|
|
|
duration: 2,
|
|
|
|
|
maxCount: 3
|
|
|
|
|
})
|
|
|
|
|
this.$message.error(res)
|
|
|
|
|
// row['cntrno'] = ''
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
this.$message.destroy()
|
|
|
|
|
this.$message.config({
|
|
|
|
|
top: `100px`,
|
|
|
|
|
duration: 2,
|
|
|
|
|
maxCount: 3
|
|
|
|
|
})
|
|
|
|
|
}, 2000)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
afterPaste: ({ data, selectionRangeIndexes, selectionRangeKeys }) => {
|
|
|
|
|
this.log({ data, selectionRangeIndexes, selectionRangeKeys })
|
|
|
|
|
let changeValue = data[0][selectionRangeKeys.endColKey]
|
|
|
|
|
const index = selectionRangeIndexes.startRowIndex
|
|
|
|
|
if (this.inTableLoad) {
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
if (['kgs', 'cbm', 'tareweight', 'weighkgs'].includes(selectionRangeKeys.endColKey)) {
|
|
|
|
|
changeValue = changeValue + ''
|
|
|
|
|
const valIndex = changeValue.includes('.') ? changeValue.indexOf('.') + 1 : false
|
|
|
|
|
const valCount = changeValue.length - valIndex
|
|
|
|
|
if (valIndex && valCount > 5) {
|
|
|
|
|
const height = document.body.clientHeight - 100
|
|
|
|
|
this.$message.config({
|
|
|
|
|
top: `${height}px`,
|
|
|
|
|
duration: 2,
|
|
|
|
|
maxCount: 3
|
|
|
|
|
})
|
|
|
|
|
this.$message.error('仅支持小数点后五位')
|
|
|
|
|
this.tableData[index][selectionRangeKeys.endColKey] = changeValue.substr(0, valIndex + 5)
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
this.$message.destroy()
|
|
|
|
|
this.$message.config({
|
|
|
|
|
top: `100px`,
|
|
|
|
|
duration: 2,
|
|
|
|
|
maxCount: 3
|
|
|
|
|
})
|
|
|
|
|
}, 2000)
|
|
|
|
|
} else {
|
|
|
|
|
const arrayNum = changeValue.split('.')
|
|
|
|
|
if (!/\./.test(changeValue)) {
|
|
|
|
|
this.tableData[index][selectionRangeKeys.endColKey] = changeValue + '.00'
|
|
|
|
|
} else if (arrayNum[1].length < 2) {
|
|
|
|
|
this.tableData[index][selectionRangeKeys.endColKey] = changeValue + '0'
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (selectionRangeKeys.endColKey === 'pkgs') {
|
|
|
|
|
if (!/(^[1-9]\d*$)/.test(changeValue)) {
|
|
|
|
|
const height = document.body.clientHeight - 100
|
|
|
|
|
this.$message.config({
|
|
|
|
|
top: `${height}px`,
|
|
|
|
|
duration: 2,
|
|
|
|
|
maxCount: 3
|
|
|
|
|
})
|
|
|
|
|
this.$message.error('件数请输入整数')
|
|
|
|
|
const cNum = changeValue.indexOf('.')
|
|
|
|
|
this.tableData[index][selectionRangeKeys.endColKey] = changeValue.substr(0, cNum)
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
this.$message.destroy()
|
|
|
|
|
this.$message.config({
|
|
|
|
|
top: `100px`,
|
|
|
|
|
duration: 2,
|
|
|
|
|
maxCount: 3
|
|
|
|
|
})
|
|
|
|
|
}, 2000)
|
|
|
|
|
} else {
|
|
|
|
|
}
|
|
|
|
|
let num = 0
|
|
|
|
|
this.tableData.map((item, index) => {
|
|
|
|
|
if (item.pkgs) {
|
|
|
|
|
num += Number(item.pkgs)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
this.totalPkgs = num
|
|
|
|
|
}
|
|
|
|
|
if (selectionRangeKeys.endColKey === 'kgs') {
|
|
|
|
|
let num = 0
|
|
|
|
|
this.tableData.map((item, index) => {
|
|
|
|
|
num = (num * 10000 + Number(item.kgs) * 10000) / 10000
|
|
|
|
|
// num += Number(item.kgs)
|
|
|
|
|
})
|
|
|
|
|
num += ''
|
|
|
|
|
const pNum = num.split('.')
|
|
|
|
|
if (!/\./.test(num)) {
|
|
|
|
|
this.totalKgs = num + '.00'
|
|
|
|
|
} else if (pNum[1].length < 2) {
|
|
|
|
|
this.totalKgs = num + '0'
|
|
|
|
|
} else {
|
|
|
|
|
this.totalKgs = Number(pNum[0] + '.' + pNum[1].substr(0, 5))
|
|
|
|
|
// this.totalKgs = num
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (selectionRangeKeys.endColKey === 'cbm') {
|
|
|
|
|
let num = 0
|
|
|
|
|
this.tableData.map((item, index) => {
|
|
|
|
|
// num += Number(item.cbm)
|
|
|
|
|
num = (num * 10000 + Number(item.cbm) * 10000) / 10000
|
|
|
|
|
})
|
|
|
|
|
num += ''
|
|
|
|
|
const pNum = num.split('.')
|
|
|
|
|
if (!/\./.test(num)) {
|
|
|
|
|
this.totalCbm = num + '.00'
|
|
|
|
|
} else if (pNum[1].length < 2) {
|
|
|
|
|
this.totalCbm = num + '0'
|
|
|
|
|
} else {
|
|
|
|
|
// this.totalCbm = num
|
|
|
|
|
this.totalCbm = Number(pNum[0] + '.' + pNum[1].substr(0, 5))
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (selectionRangeKeys.endColKey === 'kgs' || selectionRangeKeys.endColKey === 'tareweight') {
|
|
|
|
|
this.tableData[index]['weighkgs'] = this.calc(Number(this.tableData[index]['kgs']), Number(this.tableData[index]['tareweight']), '+')
|
|
|
|
|
const kgsVal = this.tableData[index]['weighkgs'] + ''
|
|
|
|
|
const kgsIndex = kgsVal.includes('.') ? kgsVal.indexOf('.') + 1 : false
|
|
|
|
|
const kgsCount = kgsVal.includes('.') ? kgsVal.length - kgsIndex : false
|
|
|
|
|
if (kgsCount > 4) {
|
|
|
|
|
this.tableData[index]['weighkgs'] = kgsVal.substr(0, kgsIndex + 5)
|
|
|
|
|
} else if (!kgsIndex) {
|
|
|
|
|
this.tableData[index]['weighkgs'] = kgsVal + '.00'
|
|
|
|
|
} else {
|
|
|
|
|
const arrayNum = kgsVal.split('.')
|
|
|
|
|
if (!/\./.test(kgsVal)) {
|
|
|
|
|
this.tableData[index]['weighkgs'] = kgsVal + '.00'
|
|
|
|
|
} else if (arrayNum[1].length < 2) {
|
|
|
|
|
this.tableData[index]['weighkgs'] = kgsVal + '0'
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
beforeCut: ({ data, selectionRangeIndexes, selectionRangeKeys }) => {
|
|
|
|
|
this.log({ data, selectionRangeIndexes, selectionRangeKeys })
|
|
|
|
@ -1142,7 +1293,6 @@ export default {
|
|
|
|
|
this.$refs['tableRef'].setCellSelection({ rowKey, colKey })
|
|
|
|
|
},
|
|
|
|
|
init() {
|
|
|
|
|
this.inTableLoad = true
|
|
|
|
|
if (Object.keys(this.details).length > 0) {
|
|
|
|
|
const arr = []
|
|
|
|
|
const totalCtnall = {}
|
|
|
|
@ -1200,9 +1350,6 @@ export default {
|
|
|
|
|
this.totalKgs = 0
|
|
|
|
|
this.totalCbm = 0
|
|
|
|
|
}
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
this.inTableLoad = false
|
|
|
|
|
}, 1200)
|
|
|
|
|
},
|
|
|
|
|
filterOption1(input, option) {
|
|
|
|
|
return (
|
|
|
|
|