|
|
|
|
@ -261,6 +261,20 @@
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="xy-table-item">
|
|
|
|
|
<div class="xy-table-item-label">
|
|
|
|
|
<span style="color: red;font-weight: 600;padding-right: 4px;" />物资规格:
|
|
|
|
|
</div>
|
|
|
|
|
<div class="xy-table-item-content">
|
|
|
|
|
<el-input
|
|
|
|
|
v-model="mingxiObj.wuziguige"
|
|
|
|
|
type="text"
|
|
|
|
|
placeholder="请选择物资规格"
|
|
|
|
|
disabled
|
|
|
|
|
style="width: 300px;"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="xy-table-item">
|
|
|
|
|
<div class="xy-table-item-label">
|
|
|
|
|
<span style="color: red;font-weight: 600;padding-right: 4px;" />物资类型:
|
|
|
|
|
@ -504,6 +518,10 @@ export default {
|
|
|
|
|
label: '物资型号',
|
|
|
|
|
prop: 'guigexinghao',
|
|
|
|
|
width: 180
|
|
|
|
|
},{
|
|
|
|
|
label: '物资规格',
|
|
|
|
|
prop: 'wuziguige',
|
|
|
|
|
width: 180
|
|
|
|
|
}, {
|
|
|
|
|
label: '物资类型',
|
|
|
|
|
prop: 'wuzileixing',
|
|
|
|
|
@ -584,7 +602,7 @@ export default {
|
|
|
|
|
this.$refs['dialog'].reset()
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 监听明细弹窗的显示状态
|
|
|
|
|
isShowMingxi(newVal) {
|
|
|
|
|
if (!newVal) {
|
|
|
|
|
@ -766,6 +784,7 @@ export default {
|
|
|
|
|
jiliangdanwei : this.mingxiObj.jiliangdanwei,
|
|
|
|
|
inventorys_id : item,
|
|
|
|
|
guigexinghao : this.mingxiObj.guigexinghao,
|
|
|
|
|
wuziguige:this.mingxiObj.wuziguige,
|
|
|
|
|
shengchanriqi : this.mingxiObj.shengchanriqi,
|
|
|
|
|
jieyongshuliang: 1,
|
|
|
|
|
shifouhuiku: this.mingxiObj.shifouhuiku,
|
|
|
|
|
@ -783,10 +802,10 @@ export default {
|
|
|
|
|
}else{
|
|
|
|
|
this.mingxiList.push(this.mingxiObj)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 合并相同物资编码且为一物一码的数据
|
|
|
|
|
this.mergeOneCodeItems()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 清除明细弹窗数据(但不影响已保存的明细列表)
|
|
|
|
|
this.clearMingxiFormData()
|
|
|
|
|
this.isShowMingxi = false
|
|
|
|
|
@ -814,12 +833,12 @@ export default {
|
|
|
|
|
type: 'success',
|
|
|
|
|
message: '删除成功'
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 如果是合并项,需要删除所有相关的原始项目
|
|
|
|
|
if (row.isMerged && row.originalItems) {
|
|
|
|
|
row.originalItems.forEach(originalItem => {
|
|
|
|
|
const originalIndex = this.mingxiList.findIndex(item =>
|
|
|
|
|
item.wuzibianma === originalItem.wuzibianma &&
|
|
|
|
|
const originalIndex = this.mingxiList.findIndex(item =>
|
|
|
|
|
item.wuzibianma === originalItem.wuzibianma &&
|
|
|
|
|
item.inventorys_id === originalItem.inventorys_id
|
|
|
|
|
)
|
|
|
|
|
if (originalIndex !== -1) {
|
|
|
|
|
@ -830,7 +849,7 @@ export default {
|
|
|
|
|
// 如果不是合并项,直接删除
|
|
|
|
|
this.mingxiList.splice(index, 1)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 重新合并显示列表
|
|
|
|
|
this.mergeOneCodeItems()
|
|
|
|
|
}
|
|
|
|
|
@ -839,16 +858,16 @@ export default {
|
|
|
|
|
openMingxiModal() {
|
|
|
|
|
// 不清空任何数据,保持现有状态
|
|
|
|
|
console.log('打开明细弹窗,保持现有数据状态')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 打开弹窗
|
|
|
|
|
this.isShowMingxi = true
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 清除明细相关数据(完全清除,包括显示列表)
|
|
|
|
|
clearMingxiData() {
|
|
|
|
|
console.log('开始清除明细弹窗数据...')
|
|
|
|
|
console.log('清除前 mergedDisplayList:', this.mergedDisplayList)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 重置明细对象
|
|
|
|
|
this.mingxiObj = {
|
|
|
|
|
wuzibianma: '',
|
|
|
|
|
@ -858,24 +877,24 @@ export default {
|
|
|
|
|
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: '',
|
|
|
|
|
@ -885,24 +904,24 @@ export default {
|
|
|
|
|
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: '',
|
|
|
|
|
@ -912,16 +931,16 @@ export default {
|
|
|
|
|
otherMetadata: [],
|
|
|
|
|
indexList: []
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 重置物资选择组件的状态
|
|
|
|
|
if (this.$refs.inventorysSelect) {
|
|
|
|
|
this.$refs.inventorysSelect.selectItem = {}
|
|
|
|
|
this.$refs.inventorysSelect.wuziPageIndex = 1
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
console.log('所有明细相关数据已清空完成')
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
showWuzi() {
|
|
|
|
|
this.$refs.inventorysSelect.isShowWuzi = true
|
|
|
|
|
},
|
|
|
|
|
@ -936,8 +955,10 @@ export default {
|
|
|
|
|
console.log("- zaikushuliang (在库数量):", e.zaikushuliang)
|
|
|
|
|
console.log("- jiliangdanwei (计量单位):", e.jiliangdanwei)
|
|
|
|
|
console.log("- guigexinghao (规格型号):", e.guigexinghao)
|
|
|
|
|
console.log("- wuziguige (物资规格):", e.wuziguige)
|
|
|
|
|
|
|
|
|
|
console.log("- shengchanriqi (生产日期):", e.shengchanriqi)
|
|
|
|
|
console.log("- 其他字段:", Object.keys(e).filter(key => !['wuzibianma', 'zichanmingcheng', 'wuzileixing', 'rukupici', 'zaikushuliang', 'jiliangdanwei', 'guigexinghao', 'shengchanriqi', 'id'].includes(key)))
|
|
|
|
|
console.log("- 其他字段:", Object.keys(e).filter(key => !['wuzibianma', 'zichanmingcheng', 'wuzileixing', 'rukupici', 'zaikushuliang', 'jiliangdanwei', 'guigexinghao','wuziguige','shengchanriqi', 'id'].includes(key)))
|
|
|
|
|
|
|
|
|
|
// 一物一码去除已经选择了的 序号
|
|
|
|
|
if(e.wuzileixing==='一物一码'){
|
|
|
|
|
@ -956,6 +977,7 @@ export default {
|
|
|
|
|
this.mingxiObj.jiliangdanwei = e.jiliangdanwei
|
|
|
|
|
this.mingxiObj.inventorys_id = e.id
|
|
|
|
|
this.mingxiObj.guigexinghao = e.guigexinghao
|
|
|
|
|
this.mingxiObj.wuziguige = e.wuziguige
|
|
|
|
|
this.mingxiObj.shengchanriqi = e.shengchanriqi
|
|
|
|
|
|
|
|
|
|
console.log("this.mingxiObj",this.mingxiObj)
|
|
|
|
|
@ -971,11 +993,11 @@ export default {
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 选择物资后,只更新 mingxiObj,不插入到明细列表
|
|
|
|
|
// 明细数据只有在确认提交后才会插入到 mingxiList
|
|
|
|
|
console.log('物资选择完成,等待确认提交')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.$forceUpdate()
|
|
|
|
|
},
|
|
|
|
|
// 去除 再次选择的一物一码中已经选择的数据
|
|
|
|
|
@ -1129,19 +1151,19 @@ export default {
|
|
|
|
|
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)
|
|
|
|
|
@ -1167,34 +1189,34 @@ export default {
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 更新显示列表(用于表格显示)
|
|
|
|
|
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 =>
|
|
|
|
|
const existingIndex = tempList.findIndex(item =>
|
|
|
|
|
item.inventorys_id === this.mingxiObj.inventorys_id
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (existingIndex === -1) {
|
|
|
|
|
// 添加当前选择的物资到临时列表
|
|
|
|
|
tempList.push({
|
|
|
|
|
@ -1210,16 +1232,16 @@ export default {
|
|
|
|
|
}
|
|
|
|
|
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)
|
|
|
|
|
@ -1245,29 +1267,29 @@ export default {
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 更新显示列表
|
|
|
|
|
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 =>
|
|
|
|
|
const existingIndex = tempList.findIndex(item =>
|
|
|
|
|
item.inventorys_id === this.mingxiObj.inventorys_id
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (existingIndex === -1) {
|
|
|
|
|
// 添加当前选择的物资到临时列表
|
|
|
|
|
tempList.push({
|
|
|
|
|
@ -1281,16 +1303,16 @@ export default {
|
|
|
|
|
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)
|
|
|
|
|
@ -1316,7 +1338,7 @@ export default {
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return mergedDisplayList
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|