| @ -1,100 +1,167 @@ | |||
| import { getuuid } from '@/utils/index.js'; | |||
| import { EventBus } from "@/utils/eventBus"; | |||
| import { getuuid ,justUpdateFilledFormData} from '@/utils/index.js' | |||
| import { EventBus } from '@/utils/eventBus' | |||
| import { getLatestSn, getLatestSnArr } from '@/api/template' | |||
| export default { | |||
| 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: '' | |||
| } | |||
| 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: () => ({}) | |||
| }, | |||
| data() { | |||
| return { | |||
| uuid: getuuid(), | |||
| 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(); | |||
| } | |||
| }, | |||
| mounted() { | |||
| EventBus.$on("dialogSubPackageSubmit", (data) => { | |||
| this.onSubPackageSubmit(data) | |||
| }) | |||
| EventBus.$on("subPackageDialogPrintTag", (data) => { | |||
| this.onPrintTag(data) | |||
| }) | |||
| justUpdateFilledFormData(){ | |||
| justUpdateFilledFormData(); | |||
| }, | |||
| destroyed() { | |||
| EventBus.$off("dialogSubPackageSubmit") | |||
| EventBus.$off("subPackageDialogPrintTag") | |||
| //获取最新的多个编号 | |||
| async getLatestSnArr(params) { | |||
| const res = await getLatestSnArr(params) | |||
| if (res.code === 200) { | |||
| return res.data | |||
| } | |||
| return [] | |||
| }, | |||
| methods: { | |||
| // 打印标签 | |||
| onPrintTag(data) { | |||
| this.$emit("printTag") | |||
| }, | |||
| onSubPackageSubmit(data) { | |||
| if (data.uuid === this.uuid) { | |||
| console.log(data, "ddd") | |||
| //通知后端保存数据 | |||
| const params = { | |||
| type: "fieldChanged", | |||
| newRecord: null, | |||
| resourceList: null, | |||
| } | |||
| EventBus.$emit('onModifyRecord', params); | |||
| } | |||
| }, | |||
| // 点击按钮 | |||
| 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 maxVolume = stepFormData[maxVolumeField]; | |||
| const maxVolumeUnit = stepFormData[maxVolumeUnitField]; | |||
| myCodeFields.forEach((key) => { | |||
| fields.push(stepFormData[key]) | |||
| }); | |||
| EventBus.$emit("showSubPackageDialog", { mybh: fields.join(""), maxVolume, maxVolumeUnit, uuid: this.uuid, fzType: "step" }) | |||
| } | |||
| }, | |||
| 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 | |||
| async getFormData() { | |||
| return await this.$refs.stepFormPackageRef.getFormData(); | |||
| }, | |||
| getFilledFormData() { | |||
| return this.$refs.stepFormPackageRef?.getFilledFormData(); | |||
| }, | |||
| getSjResource() { | |||
| return this.$refs.stepFormPackageRef?.getSjResource(); | |||
| }, | |||
| //试验配制条件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]); | |||
| } | |||
| 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(''), | |||
| maxVolume, | |||
| maxVolumeUnit, | |||
| uuid: this.uuid, | |||
| fzType: 'step', | |||
| ...fzInfo, | |||
| }) | |||
| } | |||
| }, | |||
| 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 | |||
| ]) | |||
| } | |||
| } | |||
| } | |||
| } | |||