Commit 42557b4e authored by jingnan's avatar jingnan 👀

卷内序号行内编辑组件定义

parent 7338badf
/**
* @Description: 卷内序号行内编辑
* @author gjn
* @date 2024-11-05
*/
<template>
<div class="EditVolumeNumber">
<el-input v-model="volumeNumber" size="small" @change="handleChange" />
</div>
</template>
<script>
import { post } from '@/utils/http'
export default {
componentName: '卷内序号行内编辑',
name: 'EditVolumeNumber',
components: {},
props: {
scope: {
type: Object,
default: () => {}
},
form: {
type: Object,
default: () => {}
},
value: {
type: [String, Number],
default: 0
}
},
data() {
return {
volumeNumber: ''
}
},
computed: {},
watch: {
'form.volumeNumber': {
immediate: true,
handler(val) {
this.volumeNumber = val
}
}
},
created() {
},
methods: {
handleChange() {
if (!this.form.belongingCaseFile) return this.$utils.showMessageWarning('请先编辑所属案件信息!')
this.$emit('input', this.volumeNumber)
this.$set(this.form, 'archiveNumber', this.generateArchiveNumber(this.form.belongingCaseFile, this.volumeNumber))
},
generateArchiveNumber(caseNumber, sequenceNumber) {
// 检查序号是否包含'-'且'-'后可能跟随括号或其他内容
const hasDash = sequenceNumber.includes('-')
const hasBrackets = sequenceNumber.includes('-(')
let numberPart = ''
let suffix = ''
if (hasDash) {
// 如果包含'-',并且可能是'-('的形式,则特殊处理括号
if (hasBrackets) {
const match = sequenceNumber.match(/^(\d+)-\(.*\)$/)
if (match) {
numberPart = match[1] // 获取'-'前的数字部分
suffix = '-' + sequenceNumber.substring(numberPart.length + 1) // 获取'-'及其后的内容,包括括号
} else {
const parts = sequenceNumber.split('-')
numberPart = parts[0]
suffix = '-' + parts.slice(1).join('-')
}
} else {
const parts = sequenceNumber.split('-')
numberPart = parts[0]
suffix = '-' + parts.slice(1).join('-')
}
} else {
numberPart = sequenceNumber
}
// 将数字部分补成3位
const paddedNumberPart = numberPart.toString().padStart(3, '0')
// 拼接档号
const archiveNumber = `${caseNumber}${paddedNumberPart}${suffix}`
return archiveNumber
},
// 示例用法同上
changeAmount(val) {
const params = {
...this.form,
volumeNumber: this.volumeNumber,
operator: 'MODIFY'
}
post(`InStorageRequestItem/inStorageRequestItem/update`, params).then(res => {
this.$message({
type: 'success',
message: '数量编辑成功!'
})
if (res.items && res.items.inventoryJobResponses) {
const allocatedAmount = this.$utils.sumArray(res.items.inventoryJobResponses, 'allocatedAmount')
this.$set(this.scope.row, 'allocatedAmount', allocatedAmount)
this.$bus.$emit('changeAllocatedAmount', { index: this.scope.$index, allocatedAmount, inventoryJobResponses: res.items.inventoryJobResponses })
}
}).catch((err) => {
console.log(err)
})
}
}
}
</script>
<style lang='scss'>
</style>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment