| | |
| | | --> |
| | | <template> |
| | | <basic-container> |
| | | <avue-form ref="form" :option="attachOption" v-model="attachForm" @submit="formSubmit"></avue-form> |
| | | <avue-form ref="form" :option="attachOption" v-model="attachForm" @submit="formSubmit" @blur="handleTrim"></avue-form> |
| | | </basic-container> |
| | | </template> |
| | | |
| | |
| | | watch: { |
| | | 'attachForm.drawingNo': function (val) { |
| | | if(val && this.attachForm.processNo && this.attachForm.processEdition) { |
| | | this.attachForm.title = `${val}-${this.attachForm.processNo}-${this.attachForm.processEdition}-数控程序编制`; |
| | | this.attachForm.title = `${val}-${this.attachForm.processNo}-${this.attachForm.processEdition}-计划任务`; |
| | | } |
| | | }, |
| | | 'attachForm.processNo': function (val) { |
| | | if(val && this.attachForm.drawingNo && this.attachForm.processEdition) { |
| | | //this.attachForm.title = `${val}-${this.attachForm.processNo}-数控程序编制`; |
| | | this.attachForm.title = `${this.attachForm.drawingNo}-${val}-${this.attachForm.processEdition}-数控程序编制`; |
| | | this.attachForm.title = `${this.attachForm.drawingNo}-${val}-${this.attachForm.processEdition}-计划任务`; |
| | | } |
| | | }, |
| | | 'attachForm.processEdition': function (val) { |
| | | if(val && this.attachForm.drawingNo && this.attachForm.processNo ) { |
| | | //this.attachForm.title = `${val}-${this.attachForm.processNo}-数控程序编制`; |
| | | this.attachForm.title = `${this.attachForm.drawingNo}-${this.attachForm.processNo}-${val}-数控程序编制`; |
| | | this.attachForm.title = `${this.attachForm.drawingNo}-${this.attachForm.processNo}-${val}-计划任务`; |
| | | } |
| | | }, |
| | | }, |
| | |
| | | |
| | | var isTempFlow = getQueryString("isTempFlow"); |
| | | isTempFlow = isTempFlow === 'Y'?'Y':'N'; |
| | | console.log('isTempFlow='+isTempFlow); |
| | | |
| | | var that = this; |
| | | return { |
| | | isTempFlow:isTempFlow,//是否临时流程 |
| | | form: {}, |
| | | machineCodeList: [], |
| | | attachOption: { |
| | |
| | | prop: 'title', |
| | | type: 'input', |
| | | span: 24, |
| | | disabled:true, |
| | | dataType: 'string', |
| | | rules: [{ required: true, message: '必填', trigger: 'blur' }], |
| | | rules: [{ required: true, message: '必填'}], |
| | | blur: (col) => { |
| | | this.handleTrim(col) |
| | | } |
| | | }, |
| | | { |
| | | label: '零组件号', |
| | |
| | | type: 'input', |
| | | span: 12, |
| | | dataType: 'string', |
| | | blur: (col) => { |
| | | this.handleTrim(col) |
| | | }, |
| | | rules: [{ required: true, message: '必填', trigger: 'blur' }], |
| | | }, |
| | | { |
| | |
| | | span: 12, |
| | | dataType: 'string', |
| | | rules: [{ required: true, message: '必填', trigger: 'blur' }], |
| | | blur: (col) => { |
| | | this.handleTrim(col) |
| | | }, |
| | | }, |
| | | { |
| | | label: '产品型号', |
| | |
| | | span: 12, |
| | | dataType: 'string', |
| | | rules: [{ required: true, message: '必填', trigger: 'blur' }], |
| | | blur: (col) => { |
| | | this.handleTrim(col) |
| | | }, |
| | | }, |
| | | { |
| | | label: '工序号', |
| | |
| | | step: 1, |
| | | precision: 0, |
| | | dataType: 'string', |
| | | max: 999, |
| | | rules: [{ required: true, message: '必填', trigger: 'blur' }], |
| | | blur: (col) => { |
| | | this.handleTrim(col) |
| | | }, |
| | | }, |
| | | { |
| | | label: '工序名称', |
| | |
| | | span: 12, |
| | | dataType: 'string', |
| | | rules: [{ required: true, message: '必填', trigger: 'blur' }], |
| | | blur: (col) => { |
| | | this.handleTrim(col) |
| | | }, |
| | | }, |
| | | { |
| | | label: '工序版次', |
| | |
| | | span: 12, |
| | | dataType: 'string', |
| | | rules: [{ required: true, message: '必填', trigger: 'blur' }], |
| | | blur: (col) => { |
| | | this.handleTrim(col) |
| | | }, |
| | | }, |
| | | { |
| | | label: '工艺版次', |
| | | label: '批次号', |
| | | prop: 'craftEdition', |
| | | placeholder:'如"A"', |
| | | type: 'input', |
| | | span: 12, |
| | | dataType: 'string', |
| | | maxlength: 10, |
| | | rules: [{ required: true, message: '必填', trigger: 'blur' }], |
| | | blur: (col) => { |
| | | this.handleTrim(col) |
| | | }, |
| | | }, |
| | | { |
| | | label: '加工机床', |
| | |
| | | type: 'input', |
| | | span: 12, |
| | | dataType: 'string', |
| | | placeholder:'非偏离单任务请留空', |
| | | blur: (col) => { |
| | | this.handleTrim(col) |
| | | }, |
| | | // rules: [{ required: true, message: '必填', trigger: 'blur' }], |
| | | } |
| | | ], |
| | |
| | | }; |
| | | }, |
| | | methods: { |
| | | |
| | | handleTrim(col){ |
| | | //console.log(col) |
| | | let value = this.attachForm[col.column.prop]; |
| | | if (typeof value === 'string') { |
| | | const trimmedValue = value.trim(); |
| | | // 只有当值确实发生变化时才更新 |
| | | if (trimmedValue !== value) { |
| | | this.attachForm[col.column.prop] = trimmedValue; |
| | | } |
| | | } |
| | | // this.attachForm[col.column.prop]='dddd' |
| | | }, |
| | | formSubmit(form, done) { |
| | | var form = { ...form }; |
| | | this.machineCodeList.forEach(item => { |
| | |
| | | done(); |
| | | } |
| | | ); |
| | | }, |
| | | handleGlobalBlur( {prop, value} ) { |
| | | console.log('prop') |
| | | // 1. 筛选需要处理的字段类型(仅输入类:input/textarea) |
| | | const inputTypes = ["input", "textarea"]; |
| | | const currentColumn = this.attachOption.column.find(item => item.prop === prop); |
| | | |
| | | // 2. 若为输入类字段,且值为字符串,执行 trim 处理 |
| | | if (currentColumn && inputTypes.includes(currentColumn.type) && typeof value === "string") { |
| | | const trimmedValue = value.trim(); |
| | | // 3. 同步处理后的值到表单 model(避免直接修改 prop,通过 $set 确保响应式) |
| | | this.$set(this.attachForm, prop, trimmedValue); |
| | | } |
| | | }, |
| | | handleBlur(prop, value) { |
| | | if (typeof value === 'string') { |
| | | const trimmedValue = value.trim(); |
| | | // 只有当值确实发生变化时才更新 |
| | | if (trimmedValue !== value) { |
| | | this.attachForm[prop] = trimmedValue; |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | }; |