|
@@ -63,7 +63,8 @@
|
|
|
</u-form-item>
|
|
</u-form-item>
|
|
|
<u-form-item label="报损数量" :prop="'detailInfos[' + index + '].lossNumber'" :required="true">
|
|
<u-form-item label="报损数量" :prop="'detailInfos[' + index + '].lossNumber'" :required="true">
|
|
|
<u--input v-model="inputForm.detailInfos[index].lossNumber" placeholder="请输入报损数量"
|
|
<u--input v-model="inputForm.detailInfos[index].lossNumber" placeholder="请输入报损数量"
|
|
|
- :disabled="nodeFlag" @blur="handleLossNumberBlur(index)"></u--input>
|
|
|
|
|
|
|
+ type="number" :disabled="nodeFlag" @input="handleLossNumberInput(index)"
|
|
|
|
|
+ @blur="handleLossNumberBlur(index)"></u--input>
|
|
|
</u-form-item>
|
|
</u-form-item>
|
|
|
<u-form-item label="报损原因" :prop="'detailInfos[' + index + '].lossReason'" :required="true">
|
|
<u-form-item label="报损原因" :prop="'detailInfos[' + index + '].lossReason'" :required="true">
|
|
|
<u--textarea v-model="inputForm.detailInfos[index].lossReason" placeholder="请输入报损原因"
|
|
<u--textarea v-model="inputForm.detailInfos[index].lossReason" placeholder="请输入报损原因"
|
|
@@ -378,28 +379,22 @@ export default {
|
|
|
}
|
|
}
|
|
|
return this.formatNumber(current * (specNumber > 0 ? specNumber : 1))
|
|
return this.formatNumber(current * (specNumber > 0 ? specNumber : 1))
|
|
|
},
|
|
},
|
|
|
- formatNumberInput(inputValue, decimalLimit = 2) {
|
|
|
|
|
|
|
+ formatNumberInput(inputValue) {
|
|
|
if (this.isEmpty(inputValue)) {
|
|
if (this.isEmpty(inputValue)) {
|
|
|
return ''
|
|
return ''
|
|
|
}
|
|
}
|
|
|
- const valueText = String(inputValue)
|
|
|
|
|
- if (!/^\d*\.?\d*$/.test(valueText)) {
|
|
|
|
|
|
|
+ let value = String(inputValue).replace(/[^\d.]/g, '')
|
|
|
|
|
+ if (value.endsWith('.')) {
|
|
|
return ''
|
|
return ''
|
|
|
}
|
|
}
|
|
|
- let value = valueText.replace(/[^\d.]/g, '')
|
|
|
|
|
const dotIndex = value.indexOf('.')
|
|
const dotIndex = value.indexOf('.')
|
|
|
if (dotIndex !== -1) {
|
|
if (dotIndex !== -1) {
|
|
|
- const substr = value.substr(dotIndex + 1)
|
|
|
|
|
- if (substr.indexOf('.') !== -1) {
|
|
|
|
|
- value = value.substr(0, dotIndex + 1) + substr.replace(/\./g, '')
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- if (dotIndex !== -1) {
|
|
|
|
|
const integerPart = value.substring(0, dotIndex)
|
|
const integerPart = value.substring(0, dotIndex)
|
|
|
- const decimalPart = value.substring(dotIndex + 1, dotIndex + 1 + decimalLimit)
|
|
|
|
|
|
|
+ const decimalPart = value.substring(dotIndex + 1).replace(/\./g, '').replace(/[1-9]/g, '')
|
|
|
value = integerPart + '.' + decimalPart
|
|
value = integerPart + '.' + decimalPart
|
|
|
}
|
|
}
|
|
|
- return value
|
|
|
|
|
|
|
+ value = value.replace(/^0+(\d)/, '$1')
|
|
|
|
|
+ return value === '.' ? '' : value
|
|
|
},
|
|
},
|
|
|
addDetail() {
|
|
addDetail() {
|
|
|
this.inputForm.detailInfos.push(this.createDetailRow())
|
|
this.inputForm.detailInfos.push(this.createDetailRow())
|
|
@@ -529,6 +524,13 @@ export default {
|
|
|
detail.lossNumber = ''
|
|
detail.lossNumber = ''
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
|
|
+ handleLossNumberInput(index) {
|
|
|
|
|
+ const detail = (this.inputForm.detailInfos || [])[index]
|
|
|
|
|
+ if (!detail) {
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ detail.lossNumber = this.formatNumberInput(detail.lossNumber)
|
|
|
|
|
+ },
|
|
|
validateDetailInfos(checkStock = true) {
|
|
validateDetailInfos(checkStock = true) {
|
|
|
if (this.isEmpty(this.inputForm.detailInfos)) {
|
|
if (this.isEmpty(this.inputForm.detailInfos)) {
|
|
|
this.$message.error('请填写报损明细')
|
|
this.$message.error('请填写报损明细')
|
|
@@ -557,6 +559,10 @@ export default {
|
|
|
this.$message.error(`报损明细第${lineNo}行请输入报损数量`)
|
|
this.$message.error(`报损明细第${lineNo}行请输入报损数量`)
|
|
|
return false
|
|
return false
|
|
|
}
|
|
}
|
|
|
|
|
+ if (!/^[1-9]\d*(?:\.0+)?$/.test(String(detail.lossNumber))) {
|
|
|
|
|
+ this.$message.error(`报损明细第${lineNo}行报损数量请输入正整数`)
|
|
|
|
|
+ return false
|
|
|
|
|
+ }
|
|
|
if (this.isEmpty(detail.lossReason)) {
|
|
if (this.isEmpty(detail.lossReason)) {
|
|
|
this.$message.error(`报损明细第${lineNo}行请输入报损原因`)
|
|
this.$message.error(`报损明细第${lineNo}行请输入报损原因`)
|
|
|
return false
|
|
return false
|