feat(src/views/reagent/warehousing): 添加index作为数据唯一性标识

duizhaopin_ui
duan 2 years ago
parent 58d0436881
commit 41409ff44d

@ -187,12 +187,16 @@ export default {
tempDate = this.strToDate(this.formData.production_date) tempDate = this.strToDate(this.formData.production_date)
} }
let temDate = this.formData.expiration_date let temDate = this.formData.expiration_date
if (typeof (this.formData.expiration_date) === 'string') { if (temDate && typeof (this.formData.expiration_date) === 'string') {
temDate = this.strToDate(this.formData.expiration_date) temDate = this.strToDate(this.formData.expiration_date)
} }
// if (temDate && tempDate) {
const diff = temDate.getTime() - tempDate.getTime() //
this.formData.shelf_life = Math.trunc(diff / (60 * 60 * 24 * 1000)) const diff = temDate.getTime() - tempDate.getTime()
this.formData.shelf_life = Math.trunc(diff / (60 * 60 * 24 * 1000))
} else {
this.formData.shelf_life = 0
}
this.$emit('handlefunc', this.formData) this.$emit('handlefunc', this.formData)
} }
if (!valid) return if (!valid) return

@ -297,26 +297,21 @@ export default {
return return
} }
const data = JSON.parse(JSON.stringify(this.currentRow)) const data = JSON.parse(JSON.stringify(this.currentRow))
const id = data.index
delete data.status delete data.status
delete data.index
bind_tmp_enter_warehouse(stringify({ bind_tmp_enter_warehouse(stringify({
'tmplate_content': JSON.stringify(data), 'tmplate_content': JSON.stringify(data),
'bar_code': newCode, 'bar_code': newCode,
'client_id': this.client_id_input 'client_id': this.client_id_input
})).then(res => { })).then(res => {
if (res.status === 0) { if (res.status === 0) {
let cindex = 0 // index this.bindToDBData[id].status = true
this.$message.success('入库成功!') this.$message.success('入库成功!')
this.bindToDBData = this.bindToDBData.map((item, index) => {
if (item.variety_id === this.currentRow.variety_id) {
item.status = true
cindex = index + 1
}
return item
})
// //
if (cindex <= this.bindToDBData.length - 1) { if (id < this.bindToDBData.length - 1) {
// //
this.$refs.singleTable.setCurrentRow(this.bindToDBData[cindex]) this.$refs.singleTable.setCurrentRow(this.bindToDBData[id + 1])
} }
} else { } else {
this.$message.error('入库失败,请重试!') this.$message.error('入库失败,请重试!')
@ -407,9 +402,13 @@ export default {
this.formVisible = false this.formVisible = false
this.bindToDBData = [] this.bindToDBData = []
for (let i = 0; i < obj.num; i++) { for (let i = 0; i < obj.num; i++) {
this.bindToDBData.push({ ...this.propsformdata, ...obj, 'status': false }) this.bindToDBData.push({ ...this.propsformdata, ...obj, 'status': false, 'index': i })
} }
this.client_id_input = obj.client_id this.client_id_input = obj.client_id
//
this.$nextTick(() => {
this.$refs.singleTable.setCurrentRow(this.bindToDBData[0])
})
this.bindToDBVisible = true this.bindToDBVisible = true
}, },
// //
@ -535,8 +534,9 @@ export default {
} }
this.bindToDBData = [] this.bindToDBData = []
this.multipleSelection.forEach(item => { this.multipleSelection.forEach(item => {
this.bindToDBData.push(...JSON.parse(item.template_content).map(item => { this.bindToDBData.push(...JSON.parse(item.template_content).map((item, index) => {
item.status = false item.status = false
item.index = index
return item return item
})) }))
}) })

Loading…
Cancel
Save