一物一码合并

master
lion 4 months ago
parent faaf487a34
commit 13c8323f12

@ -675,11 +675,11 @@
dengjifenlei:this.select.dengjifenlei,
// is_export:this.select.is_export,
filter: [
// {
// 'key': 'wuzibianma',
// 'op': 'like',
// 'value': this.select.wzbm
// },
/* {
'key': 'wuzibianma',
'op': 'like',
'value': this.select.wzbm
}, */
{
'key': 'zichanmingcheng',
'op': 'like',

@ -181,8 +181,8 @@
<span style="color: red;font-weight: 600;padding-right: 4px;" />出库明细
</div>
<div class="xy-table-item-content" style="width: calc(100% - 160px);">
<Button type="primary" icon="md-add" style="margin-bottom: 10px" @click="isShowMingxi=true"></Button>
<xy-table style="width: 100%" :height="260" :is-page="false" :list="mingxiList" :table-item="mingxiTable">
<Button type="primary" icon="md-add" style="margin-bottom: 10px" @click="openMingxiModal"></Button>
<xy-table style="width: 100%" :height="260" :is-page="false" :list="getDisplayList()" :table-item="mingxiTable">
<template v-slot:btns>
<el-table-column label="操作" width="90" header-align="center" align="center">
<template v-slot:default="scope">
@ -490,6 +490,7 @@ export default {
indexList:[], // id
},
mingxiList: [],
mergedDisplayList: [], //
showLoading: true,
mingxiTable: [
// {label:'id',
@ -543,7 +544,7 @@ export default {
label: '是否回库',
prop: 'shifouhuiku',
width: 80
}, , {
}, {
label: '回库日期',
prop: 'huikushijian',
width: 120
@ -561,8 +562,13 @@ export default {
if (this.type === 'editor' || this.type === 'outbounds') {
this.getDetail()
} else {
//
this.mingxiList = []
this.mergedDisplayList = []
this.clearMingxiData()
this.getUserName()
this.form.jilurenyuan = this.authName
console.log('新增模式:主弹窗打开时已清空所有数据')
}
} else {
if(this.$route.query.oaType==='wuzi'){
@ -571,11 +577,20 @@ export default {
this.id = ''
this.type = ''
this.mingxiList = []
this.mergedDisplayList = []
this.fileList = []
this.authName = ''
this.activeStep = 0
this.$refs['dialog'].reset()
}
},
//
isShowMingxi(newVal) {
if (!newVal) {
//
console.log('明细弹窗关闭,保持数据状态')
}
}
},
created() {
@ -747,7 +762,7 @@ export default {
zichanmingcheng : this.mingxiObj.zichanmingcheng,
wuzileixing : this.mingxiObj.wuzileixing,
rukupici : this.mingxiObj.rukupici,
zaikushuliang : 1,
zaikushuliang : this.mingxiObj.zaikushuliang,
jiliangdanwei : this.mingxiObj.jiliangdanwei,
inventorys_id : item,
guigexinghao : this.mingxiObj.guigexinghao,
@ -768,25 +783,17 @@ export default {
}else{
this.mingxiList.push(this.mingxiObj)
}
this.mingxiObj = {
wuzibianma: '',
jieyongshuliang: '',
shifouhuiku: '',
huikushijian: '',
otherMetadata:[],
indexList:[]
}
//
this.mergeOneCodeItems()
//
this.clearMingxiFormData()
this.isShowMingxi = false
},
mingxiCancel() {
this.mingxiObj = {
wuzibianma: '',
jieyongshuliang: '',
shifouhuiku: '',
huikushijian: '',
otherMetadata:[],
indexList:[]
}
//
this.clearMingxiData()
this.isShowMingxi = false
},
//
@ -807,15 +814,130 @@ export default {
type: 'success',
message: '删除成功'
})
//
if (row.isMerged && row.originalItems) {
row.originalItems.forEach(originalItem => {
const originalIndex = this.mingxiList.findIndex(item =>
item.wuzibianma === originalItem.wuzibianma &&
item.inventorys_id === originalItem.inventorys_id
)
if (originalIndex !== -1) {
this.mingxiList.splice(originalIndex, 1)
}
})
} else {
//
this.mingxiList.splice(index, 1)
}
//
this.mergeOneCodeItems()
}
},
//
openMingxiModal() {
//
console.log('打开明细弹窗,保持现有数据状态')
//
this.isShowMingxi = true
},
//
clearMingxiData() {
console.log('开始清除明细弹窗数据...')
console.log('清除前 mergedDisplayList:', this.mergedDisplayList)
//
this.mingxiObj = {
wuzibianma: '',
jieyongshuliang: '',
shifouhuiku: '',
huikushijian: '',
otherMetadata: [],
indexList: []
}
//
this.mergedDisplayList = []
//
if (this.$refs.inventorysSelect) {
this.$refs.inventorysSelect.selectItem = {}
this.$refs.inventorysSelect.wuziPageIndex = 1
}
console.log('清除后 mergedDisplayList:', this.mergedDisplayList)
console.log('明细弹窗数据已清除完成')
},
//
clearMingxiFormData() {
console.log('开始清除明细表单数据...')
//
this.mingxiObj = {
wuzibianma: '',
jieyongshuliang: '',
shifouhuiku: '',
huikushijian: '',
otherMetadata: [],
indexList: []
}
//
if (this.$refs.inventorysSelect) {
this.$refs.inventorysSelect.selectItem = {}
this.$refs.inventorysSelect.wuziPageIndex = 1
}
console.log('明细表单数据已清除完成')
},
//
clearAllMingxiData() {
console.log('开始清空所有明细相关数据...')
//
this.mingxiList = []
this.mergedDisplayList = []
//
this.mingxiObj = {
wuzibianma: '',
jieyongshuliang: '',
shifouhuiku: '',
huikushijian: '',
otherMetadata: [],
indexList: []
}
//
if (this.$refs.inventorysSelect) {
this.$refs.inventorysSelect.selectItem = {}
this.$refs.inventorysSelect.wuziPageIndex = 1
}
console.log('所有明细相关数据已清空完成')
},
showWuzi() {
this.$refs.inventorysSelect.isShowWuzi = true
},
//
selectInventorysMx(e) {
console.log("e",e)
console.log("选择的物资数据:", e)
console.log("物资数据字段详情:")
console.log("- wuzibianma (物资编码):", e.wuzibianma)
console.log("- zichanmingcheng (资产名称):", e.zichanmingcheng)
console.log("- wuzileixing (物资类型):", e.wuzileixing)
console.log("- rukupici (入库批次):", e.rukupici)
console.log("- zaikushuliang (在库数量):", e.zaikushuliang)
console.log("- jiliangdanwei (计量单位):", e.jiliangdanwei)
console.log("- guigexinghao (规格型号):", e.guigexinghao)
console.log("- shengchanriqi (生产日期):", e.shengchanriqi)
console.log("- 其他字段:", Object.keys(e).filter(key => !['wuzibianma', 'zichanmingcheng', 'wuzileixing', 'rukupici', 'zaikushuliang', 'jiliangdanwei', 'guigexinghao', 'shengchanriqi', 'id'].includes(key)))
//
if(e.wuzileixing==='一物一码'){
@ -835,6 +957,7 @@ export default {
this.mingxiObj.inventorys_id = e.id
this.mingxiObj.guigexinghao = e.guigexinghao
this.mingxiObj.shengchanriqi = e.shengchanriqi
console.log("this.mingxiObj",this.mingxiObj)
if(e.wuzileixing==='一类一码'){
this.mingxiList.map(item => {
@ -848,6 +971,11 @@ export default {
}
})
}
// mingxiObj
// mingxiList
console.log('物资选择完成,等待确认提交')
this.$forceUpdate()
},
//
@ -911,6 +1039,8 @@ export default {
}
this.form.id = this.id
this.mingxiList = res.id_outbounds_items_outbounds_id_relation
//
this.mergeOneCodeItems()
this.fileList = []
const _lists = res.zuozhengwenjian_upload_details ? res.zuozhengwenjian_upload_details : []
for (var f of _lists) {
@ -998,6 +1128,196 @@ export default {
this.isShow = false
this.$emit('refresh')
})
},
//
mergeOneCodeItems() {
//
const mergedDisplayList = []
const mergedMap = new Map()
//
this.mingxiList.forEach(item => {
if (item.wuzileixing === '一物一码') {
// 使key
const key = item.wuzibianma
if (mergedMap.has(key)) {
//
const existingItem = mergedMap.get(key)
existingItem.jieyongshuliang += parseInt(item.jieyongshuliang) || 1
existingItem.originalItems.push(item) //
} else {
//
const mergedItem = {
...item,
jieyongshuliang: parseInt(item.jieyongshuliang) || 1,
originalItems: [item], //
isMerged: true //
}
mergedMap.set(key, mergedItem)
mergedDisplayList.push(mergedItem)
}
} else {
//
mergedDisplayList.push({
...item,
originalItems: [item], //
isMerged: false //
})
}
})
//
this.mergedDisplayList = mergedDisplayList
console.log('合并后的显示列表:', this.mergedDisplayList)
console.log('原始明细列表:', this.mingxiList)
},
//
updateMergedDisplayList() {
console.log('开始更新合并显示列表...')
console.log('当前 mingxiObj:', this.mingxiObj)
console.log('当前 mingxiList:', this.mingxiList)
// mingxiObj
if (!this.mingxiObj || !this.mingxiObj.wuzibianma) {
console.log('mingxiObj 为空,跳过更新')
return
}
//
const tempList = [...this.mingxiList]
//
const existingIndex = tempList.findIndex(item =>
item.inventorys_id === this.mingxiObj.inventorys_id
)
if (existingIndex === -1) {
//
tempList.push({
...this.mingxiObj,
jieyongshuliang: this.mingxiObj.jieyongshuliang || 1
})
console.log('已添加当前选择的物资到临时列表')
} else {
//
tempList[existingIndex] = {
...this.mingxiObj,
jieyongshuliang: this.mingxiObj.jieyongshuliang || 1
}
console.log('已更新已有的物资')
}
//
const mergedDisplayList = []
const mergedMap = new Map()
tempList.forEach(item => {
if (item.wuzileixing === '一物一码') {
// 使key
const key = item.wuzibianma
if (mergedMap.has(key)) {
//
const existingItem = mergedMap.get(key)
existingItem.jieyongshuliang += parseInt(item.jieyongshuliang) || 1
existingItem.originalItems.push(item) //
} else {
//
const mergedItem = {
...item,
jieyongshuliang: parseInt(item.jieyongshuliang) || 1,
originalItems: [item], //
isMerged: true //
}
mergedMap.set(key, mergedItem)
mergedDisplayList.push(mergedItem)
}
} else {
//
mergedDisplayList.push({
...item,
originalItems: [item], //
isMerged: false //
})
}
})
//
this.mergedDisplayList = mergedDisplayList
console.log('更新后的合并显示列表:', this.mergedDisplayList)
console.log('临时列表:', tempList)
},
//
getDisplayList() {
//
if (!this.mingxiObj || !this.mingxiObj.wuzibianma) {
return this.mergedDisplayList.length > 0 ? this.mergedDisplayList : this.mingxiList
}
//
const tempList = [...this.mingxiList]
//
const existingIndex = tempList.findIndex(item =>
item.inventorys_id === this.mingxiObj.inventorys_id
)
if (existingIndex === -1) {
//
tempList.push({
...this.mingxiObj,
jieyongshuliang: this.mingxiObj.jieyongshuliang || 1
})
} else {
//
tempList[existingIndex] = {
...this.mingxiObj,
jieyongshuliang: this.mingxiObj.jieyongshuliang || 1
}
}
//
const mergedDisplayList = []
const mergedMap = new Map()
tempList.forEach(item => {
if (item.wuzileixing === '一物一码') {
// 使key
const key = item.wuzibianma
if (mergedMap.has(key)) {
//
const existingItem = mergedMap.get(key)
existingItem.jieyongshuliang += parseInt(item.jieyongshuliang) || 1
existingItem.originalItems.push(item) //
} else {
//
const mergedItem = {
...item,
jieyongshuliang: parseInt(item.jieyongshuliang) || 1,
originalItems: [item], //
isMerged: true //
}
mergedMap.set(key, mergedItem)
mergedDisplayList.push(mergedItem)
}
} else {
//
mergedDisplayList.push({
...item,
originalItems: [item], //
isMerged: false //
})
}
})
return mergedDisplayList
}
}

@ -65,7 +65,7 @@
<Button v-if="scope.row.zhuangtai==0 || scope.row.zhuangtai==4" style="margin-right: 10px;" type="primary" size="small"
@click="toOaFollow(scope.row,scope.row.chukuleixing)">发起流程</Button>
<!-- v-if="scope.row.zhuangtai==2 &&(isCkName=='仓库管理员'||roleName=='系统管理员')" -->
<Button style="margin-right: 10px;" type="primary" size="small"
<Button v-if="scope.row.zhuangtai==2 &&(isCkName==''||roleName=='')" style="margin-right: 10px;" type="primary" size="small"
@click="printChuku(scope.row.id)">确认出库</Button>
<Poptip v-if="scope.row.zhuangtai==0" transfer confirm title="确认要删除该出库记录?"
@ -227,8 +227,11 @@ export default {
align: 'left',
customFn: (row) => {
if (row.id_outbounds_items_outbounds_id_relation.length > 0) {
return row.id_outbounds_items_outbounds_id_relation.map(item => {
return (<p> {item.wuzibianma}-{item.zichanmingcheng}
// wuzibianma
const mergedItems = this.mergeOutboundItems(row.id_outbounds_items_outbounds_id_relation)
return mergedItems.map(item => {
return (<p>{item.zichanmingcheng}
{item.guigexinghao ? '(' + item.guigexinghao + ')' : ''}
{item.jieyongshuliang}{item.jiliangdanwei}
</p>)
@ -368,6 +371,43 @@ export default {
})
this.getindex()
})
},
// wuzibianma
mergeOutboundItems(items) {
if (!Array.isArray(items) || items.length === 0) {
return []
}
// 使 Map wuzibianma
const mergedMap = new Map()
items.forEach(item => {
const key = item.wuzibianma
if (mergedMap.has(key)) {
//
const existingItem = mergedMap.get(key)
existingItem.jieyongshuliang += parseInt(item.jieyongshuliang) || 0
//
//
} else {
//
mergedMap.set(key, {
...item,
jieyongshuliang: parseInt(item.jieyongshuliang) || 0
})
}
})
//
const mergedItems = Array.from(mergedMap.values())
console.log('原始明细:', items)
console.log('合并后明细:', mergedItems)
return mergedItems
}
}

Loading…
Cancel
Save