|
|
|
@ -26,10 +26,12 @@ |
|
|
|
<div class="header-container"> |
|
|
|
<div v-for="(item, index) in fzList" class="list-item" :key="index"> |
|
|
|
<div class="list-label">{{ formData.mybh }}-set{{ item.subCode }}</div> |
|
|
|
<HandleFormItem :fieldKey = "'clfz_set'+index+'_prenum'" :item="preInputNumberItem" :error="fzListErrors[index]" |
|
|
|
type="inputNumber" @blur="onBlurFzNum(index)" v-model="item.prenum" /> |
|
|
|
<HandleFormItem :fieldKey = "'clfz_set'+index+'_actnum'" class="ml-5" :item="inputNumberItem" :error="fzListErrors[index]" |
|
|
|
type="inputNumber" @blur="onBlurFzNum(index)" v-model="item.actnum" /> |
|
|
|
<HandleFormItem :fieldKey = "'clfz_set'+index+'_prenum'" :item="preInputNumberItem" |
|
|
|
:error="hasError(index, 'prenum')" |
|
|
|
type="inputNumber" @blur="onBlurFzNum(index,'prenum')" v-model="item.prenum" /> |
|
|
|
<HandleFormItem :fieldKey = "'clfz_set'+index+'_actnum'" class="ml-5" :item="inputNumberItem" |
|
|
|
:error="hasError(index, 'actnum')" |
|
|
|
type="inputNumber" @blur="onBlurFzNum(index,'actnum')" v-model="item.actnum" /> |
|
|
|
<HandleFormItem |
|
|
|
class="ml-5" |
|
|
|
type="button" |
|
|
|
@ -47,7 +49,9 @@ import HandleFormItem from '@/components/Template/HandleFormItem.vue'; |
|
|
|
import { compareVolume } from '@/utils/volumeTools.js'; |
|
|
|
import { EventBus } from '@/utils/eventBus'; |
|
|
|
import { getLatestSn } from '@/api/template'; |
|
|
|
import { isValueEmpty } from '@/utils/index.js'; |
|
|
|
export default { |
|
|
|
inject: ['templateFillType'], |
|
|
|
dicts: [ |
|
|
|
'business_tjdw', |
|
|
|
], |
|
|
|
@ -150,58 +154,6 @@ export default { |
|
|
|
this.formData = {}; |
|
|
|
this.resetErrors(); |
|
|
|
}, |
|
|
|
show(data) { |
|
|
|
const cloneData = JSON.parse(JSON.stringify(data)); |
|
|
|
if(data && data.uuid) {//为了标识eventBus的事件id |
|
|
|
this.uuid = data.uuid |
|
|
|
} |
|
|
|
if (data.fzList) { |
|
|
|
this.fzList = JSON.parse(JSON.stringify(cloneData.fzList)); |
|
|
|
// 初始化分装列表错误状态 |
|
|
|
this.fzListErrors = new Array(this.fzList.length).fill(false); |
|
|
|
delete cloneData.fzList; |
|
|
|
} |
|
|
|
this.formData = cloneData; |
|
|
|
// 重置错误状态 |
|
|
|
this.resetErrors(); |
|
|
|
this.visible = true; |
|
|
|
}, |
|
|
|
onSubmit() { |
|
|
|
// 验证表单数据 |
|
|
|
if (!this.validateFormData()) { |
|
|
|
this.$message.error('表单内容未填完,请填写后再提交') |
|
|
|
return; |
|
|
|
} else { |
|
|
|
const errMsg = "分装后小份容量之和大于母液容量,是否确认分装?" |
|
|
|
const {maxVolume,maxVolumeUnit,dw} = this.formData; |
|
|
|
|
|
|
|
const totalVolume = this.fzList.reduce((acc, cur) => acc + Number(cur.num), 0); |
|
|
|
const compareResult = compareVolume(totalVolume,dw,maxVolume, maxVolumeUnit); |
|
|
|
console.log(compareResult,totalVolume,dw,maxVolume, maxVolumeUnit,"比较结果"); |
|
|
|
if(compareResult > 0||!maxVolume){//没有填写实际溶液体积的也需要提示错误信息 |
|
|
|
this.$modal.confirm(errMsg, '提示', { |
|
|
|
confirmButtonText: this.$t('form.saveConfirm'), |
|
|
|
cancelButtonText: this.$t('form.cancel'), |
|
|
|
type: 'warning' |
|
|
|
}).then(() => { |
|
|
|
this.submitEmit(); |
|
|
|
}).catch(() => { |
|
|
|
// 取消操作,不执行任何操作 |
|
|
|
}); |
|
|
|
return; |
|
|
|
} |
|
|
|
this.submitEmit(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
}, |
|
|
|
submitEmit(){ |
|
|
|
EventBus.$emit('dialogSubPackageSubmit', {...this.formData, fzList: this.fzList,uuid:this.uuid}); |
|
|
|
setTimeout(() => { |
|
|
|
this.close(); |
|
|
|
}, 500); |
|
|
|
}, |
|
|
|
validateFormData() { |
|
|
|
let isValid = true; |
|
|
|
|
|
|
|
@ -226,18 +178,24 @@ export default { |
|
|
|
// 验证分装列表中的数值 |
|
|
|
if (this.fzList && this.fzList.length > 0) { |
|
|
|
for (let i = 0; i < this.fzList.length; i++) { |
|
|
|
if (!this.fzList[i].num) { |
|
|
|
// 确保fzListErrors数组有足够的元素 |
|
|
|
if (this.fzListErrors.length <= i) { |
|
|
|
this.$set(this.fzListErrors, i, true); |
|
|
|
} else { |
|
|
|
this.fzListErrors[i] = true; |
|
|
|
} |
|
|
|
if (isValueEmpty(this.fzList[i].prenum)) { |
|
|
|
this.fzListErrors.push({ |
|
|
|
rowIndex: i, |
|
|
|
field: "prenum", |
|
|
|
error: "请输入预填分装数量", |
|
|
|
}) |
|
|
|
isValid = false; |
|
|
|
} |
|
|
|
if (isValueEmpty(this.fzList[i].actnum)) { |
|
|
|
this.fzListErrors.push({ |
|
|
|
rowIndex: i, |
|
|
|
field: "actnum", |
|
|
|
error: "请输入实际分装数量", |
|
|
|
}) |
|
|
|
isValid = false; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return isValid; |
|
|
|
}, |
|
|
|
resetErrors() { |
|
|
|
@ -248,7 +206,7 @@ export default { |
|
|
|
|
|
|
|
// 重置分装列表错误状态 |
|
|
|
this.fzListErrors.forEach((_, index) => { |
|
|
|
this.$set(this.fzListErrors, index, false); |
|
|
|
this.fzListErrors = [] |
|
|
|
}); |
|
|
|
}, |
|
|
|
// 分装数量失去焦点时,根据数量生成分装列表 |
|
|
|
@ -275,24 +233,10 @@ export default { |
|
|
|
actnum: "", |
|
|
|
subCode: codes[i], |
|
|
|
}); |
|
|
|
// 同步初始化错误状态数组 |
|
|
|
this.fzListErrors.push(false); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
onAverage() { |
|
|
|
const { mfbzl } = this.formData; |
|
|
|
this.fzList.forEach((item, index) => { |
|
|
|
item.num = mfbzl; |
|
|
|
// 同时更新错误状态 |
|
|
|
if (this.fzListErrors[index] !== undefined) { |
|
|
|
this.$set(this.fzListErrors, index, false); |
|
|
|
} |
|
|
|
}) |
|
|
|
// 清除相关字段的错误状态 |
|
|
|
this.formErrors.mfbzl = false; |
|
|
|
}, |
|
|
|
onGetValue(item) { |
|
|
|
item.actnum = 123; |
|
|
|
console.log(item,"获取值") |
|
|
|
@ -303,13 +247,28 @@ export default { |
|
|
|
this.formErrors[field] = false; |
|
|
|
} |
|
|
|
}, |
|
|
|
onBlurFzNum(index) { |
|
|
|
if (this.fzList[index] && this.fzList[index].num) { |
|
|
|
if (this.fzListErrors[index] !== undefined) { |
|
|
|
onBlurFzNum(index, field) { |
|
|
|
if (this.fzList[index]) { |
|
|
|
// 确保fzListErrors数组有足够的元素 |
|
|
|
if (this.fzListErrors.length <= index) { |
|
|
|
this.$set(this.fzListErrors, index, false); |
|
|
|
} |
|
|
|
|
|
|
|
if (this.fzList[index][field]) { |
|
|
|
// 有值的话就清空对应的错误信息 |
|
|
|
this.$set(this.fzListErrors, index, false); |
|
|
|
} else { |
|
|
|
// 没有值的话就边框标红 |
|
|
|
this.$set(this.fzListErrors, index, true); |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
hasError(index, field) { |
|
|
|
const o = this.fzListErrors.find((item)=>{ |
|
|
|
return item.rowIndex === index && item.field === field; |
|
|
|
}) |
|
|
|
return o !== undefined; |
|
|
|
}, |
|
|
|
// 数据变化处理方法 |
|
|
|
onDataChange() { |
|
|
|
// 触发自定义事件,将数据变化传递给父组件 |
|
|
|
|