import { getuuid, justUpdateFilledFormData } from '@/utils/index.js'
|
|
import { EventBus } from '@/utils/eventBus'
|
|
import { getLatestSn, getLatestSnArr } from '@/api/template'
|
|
export default {
|
|
inject: {
|
|
templateFillType: { default: 'preFill' },
|
|
getStepData: { default: () => null },
|
|
getMybh: { default: () => null }
|
|
},
|
|
dicts: [
|
|
'business_tjdw',
|
|
'business_czhj',
|
|
'business_rqcz',
|
|
'business_zldw',
|
|
'business_yqscdw',
|
|
'business_zsdw',
|
|
'business_wddw',
|
|
'business_ccwz',
|
|
'business_ggdw',
|
|
'business_hjxx',
|
|
'business_zzzc',
|
|
'business_step_pcr',
|
|
'business_fycx',
|
|
'business_step_pcrfxyp',
|
|
'business_cctj'
|
|
],
|
|
props: {
|
|
formData: {
|
|
type: Object,
|
|
default: () => ({})
|
|
},
|
|
stepIndex: {
|
|
type: String,
|
|
default: ''
|
|
}
|
|
},
|
|
data() {
|
|
return {
|
|
uuid: getuuid(),
|
|
fzInfo: {},
|
|
}
|
|
},
|
|
mounted() {
|
|
EventBus.$on('dialogSubPackageSubmit', (data) => {
|
|
this.onSubPackageSubmit(data)
|
|
})
|
|
EventBus.$on('subPackageDialogPrintTag', (data) => {
|
|
this.onPrintTag(data)
|
|
})
|
|
},
|
|
destroyed() {
|
|
EventBus.$off('dialogSubPackageSubmit')
|
|
EventBus.$off('subPackageDialogPrintTag')
|
|
},
|
|
|
|
methods: {
|
|
//回填编号 preField 前缀 updateField 需要更新的字段
|
|
async handleBackfillCode(preField, updateField) {
|
|
const updateValue = this.formData[updateField];
|
|
if (this.templateFillType === 'actFill' && !updateValue) {
|
|
const stepFormData = this.getFilledFormData();
|
|
const preValue = stepFormData[preField];
|
|
const result = await this.getLatestSn({
|
|
pre: preValue,
|
|
})
|
|
this.$refs.stepFormPackageRef.updateFormData(updateField, result[0])
|
|
this.justUpdateFilledFormData();
|
|
}
|
|
},
|
|
justUpdateFilledFormData() {
|
|
justUpdateFilledFormData();
|
|
},
|
|
//获取最新的多个编号
|
|
async getLatestSnArr(params) {
|
|
const res = await getLatestSnArr(params)
|
|
if (res.code === 200) {
|
|
return res.data
|
|
}
|
|
return []
|
|
},
|
|
async getLatestSn(params) {
|
|
const defaultParams = {
|
|
count: 1,
|
|
type: 1,
|
|
pre: ''
|
|
}
|
|
const finalParams = { ...defaultParams, ...params }
|
|
const res = await getLatestSn(finalParams)
|
|
if (res.code === 200) {
|
|
return res.data
|
|
}
|
|
return []
|
|
},
|
|
// 打印标签
|
|
onPrintTag(data) {
|
|
this.$emit('printTag')
|
|
},
|
|
onSubPackageSubmit(data) {
|
|
if (data.uuid === this.uuid) {
|
|
delete data.uuid //删除uuid字段,不然会导致下次匹配的时候匹配到错误的uuid
|
|
this.$refs.stepFormPackageRef.updateFormData('fzInfo', data)
|
|
this.justUpdateFilledFormData();
|
|
}
|
|
},
|
|
// 点击按钮
|
|
onHandleClickButton(e, item, key) {
|
|
const {
|
|
buttonName = '',
|
|
myCodeFields = [],
|
|
maxVolumeField = '',
|
|
maxVolumeUnitField = ''
|
|
} = e
|
|
|
|
if (buttonName === '分装') {
|
|
const stepFormData = this.getFilledFormData()
|
|
const fzInfo = stepFormData.fzInfo || this.formData.fzInfo;
|
|
let fields = [],options = []
|
|
let maxVolume, maxVolumeUnit;
|
|
if (this.getMybh && this.getMybh()) {
|
|
const { mybh,mybhOptions=[], maxVolume:max, maxVolumeUnit:unit } = this.getMybh()
|
|
if((!mybh &&!mybhOptions.length) || !max || !unit){
|
|
this.$message.warning('请先填写分装数据')
|
|
return
|
|
}
|
|
options = mybhOptions
|
|
fields.push(mybh)
|
|
maxVolume = max || ''
|
|
maxVolumeUnit = unit || ''
|
|
} else {
|
|
if (!myCodeFields.length || !maxVolumeField || !maxVolumeUnitField) {
|
|
this.$message.warning('请配制分装参数')
|
|
return
|
|
}
|
|
maxVolume = stepFormData[maxVolumeField]
|
|
maxVolumeUnit = stepFormData[maxVolumeUnitField]
|
|
myCodeFields.forEach((key) => {
|
|
fields.push(stepFormData[key])
|
|
})
|
|
}
|
|
EventBus.$emit('showSubPackageDialog', {
|
|
mybh: fields.join(''),
|
|
id: this.stepIndex,
|
|
fzType: 'step',
|
|
...fzInfo,
|
|
maxVolume,
|
|
mybhOptions:options,
|
|
maxVolumeUnit,
|
|
uuid: this.uuid,
|
|
})
|
|
}
|
|
},
|
|
|
|
async getFormData() {
|
|
const data = await this.$refs.stepFormPackageRef.getFormData();
|
|
data.fzInfo = data.fzInfo || this.formData.fzInfo;
|
|
return data
|
|
},
|
|
getFilledFormData() {
|
|
const data = this.$refs.stepFormPackageRef?.getFilledFormData();
|
|
data.fzInfo = data.fzInfo || this.formData.fzInfo;
|
|
return data
|
|
},
|
|
getSjResource() {
|
|
const data = this.$refs.stepFormPackageRef?.getSjResource();
|
|
data.fzInfo = data.fzInfo || this.formData.fzInfo;
|
|
return data
|
|
},
|
|
//试验配制条件options
|
|
getDictOptions(dictType) {
|
|
return this.dict.type[dictType] || []
|
|
},
|
|
resetRecord() {
|
|
this.$refs.stepFormPackageRef.resetRecord()
|
|
},
|
|
//更新温层数据
|
|
updateWcData(key, value) {
|
|
const options = this.getDictOptions('business_ccwz')
|
|
const selectedOption = options.find((item) => item.value === value)
|
|
if (selectedOption) {
|
|
this.$refs.stepFormPackageRef.updateFormData(key, [
|
|
selectedOption.raw.remark
|
|
])
|
|
}
|
|
}
|
|
}
|
|
}
|