| @ -1,167 +1,179 @@ | |||
| import { getuuid ,justUpdateFilledFormData} from '@/utils/index.js' | |||
| import { getuuid, justUpdateFilledFormData } from '@/utils/index.js' | |||
| import { EventBus } from '@/utils/eventBus' | |||
| import { getLatestSn, getLatestSnArr } from '@/api/template' | |||
| export default { | |||
| inject: ['templateFillType'], | |||
| 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') | |||
| }, | |||
| inject: ['templateFillType', 'getMybh'], | |||
| 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 | |||
| 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 fields = [] | |||
| const stepFormData = this.getFilledFormData() | |||
| if (!myCodeFields.length || !maxVolumeField || !maxVolumeUnitField) { | |||
| console.warn('请配制分装参数') | |||
| return | |||
| } | |||
| const fzInfo = stepFormData.fzInfo || this.formData.fzInfo; | |||
| const maxVolume = stepFormData[maxVolumeField] | |||
| const maxVolumeUnit = stepFormData[maxVolumeUnitField] | |||
| myCodeFields.forEach((key) => { | |||
| fields.push(stepFormData[key]) | |||
| }) | |||
| EventBus.$emit('showSubPackageDialog', { | |||
| mybh: fields.join(''), | |||
| fzType: 'step', | |||
| ...fzInfo, | |||
| maxVolume, | |||
| maxVolumeUnit, | |||
| uuid: this.uuid, | |||
| }) | |||
| } | |||
| }, | |||
| if (buttonName === '分装') { | |||
| const stepFormData = this.getFilledFormData() | |||
| const fzInfo = stepFormData.fzInfo || this.formData.fzInfo; | |||
| let fields = [] | |||
| let maxVolume, maxVolumeUnit; | |||
| if (this.getMybh) { | |||
| const { mybh, maxVolume:max, maxVolumeUnit:unit } = this.getMybh() | |||
| if(!mybh || !max || !unit){ | |||
| this.$message.warning('请先填写分装数据') | |||
| return | |||
| } | |||
| 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(''), | |||
| fzType: 'step', | |||
| ...fzInfo, | |||
| maxVolume, | |||
| 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 | |||
| ]) | |||
| } | |||
| } | |||
| } | |||
| 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 | |||
| ]) | |||
| } | |||
| } | |||
| } | |||
| } | |||