| | |
| | | <!-- |
| | | * @Author: 李喆(开发组) lzhe@yxqiche.com |
| | | * @Date: 2025-05-28 12:03:55 |
| | | * @LastEditors: 李喆(开发组) lzhe@yxqiche.com |
| | | * @LastEditTime: 2025-06-13 14:50:38 |
| | | * @LastEditors: gaoshp |
| | | * @LastEditTime: 2025-08-10 13:05:56 |
| | | * @FilePath: /mdmweb/src/views/flowmgr/taskassign.vue |
| | | * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE |
| | | --> |
| | | <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"><!-- --> |
| | | <template #machineCode="{}"> |
| | | <el-tree-select ref="tree" filterable v-model="attachForm.machineCode" |
| | | node-key="machineCode" |
| | | :data="treeData" :props="defaultProps"> |
| | | </el-tree-select> |
| | | </template> |
| | | <template #drawingNo="{}"> |
| | | <el-autocomplete v-model="attachForm.drawingNo" |
| | | :fetch-suggestions="querySearchAsync" |
| | | :trigger-on-focus="false" @select="handleSelect" |
| | | > |
| | | </el-autocomplete> |
| | | </template> |
| | | <!-- |
| | | <template #programmer="{}"> |
| | | <el-autocomplete ref="autoProgrammer" :disabled="drawingNoMatch" v-model="attachForm.programmer" |
| | | :fetch-suggestions="queryProgrammerAsync" |
| | | :trigger-on-focus="false" @select="handleProgrammerSelect" |
| | | > |
| | | </el-autocomplete> |
| | | </template> |
| | | --> |
| | | </avue-form> |
| | | </basic-container> |
| | | </template> |
| | | |
| | | <script> |
| | | export default { |
| | | watch: { |
| | | 'attachForm.drawingNo': function (val) { |
| | | if(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}-计划任务`; |
| | | } |
| | | }, |
| | | '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}-计划任务`; |
| | | } |
| | | }, |
| | | }, |
| | | data() { |
| | | var that = this; |
| | | return { |
| | | form: {}, |
| | | machineCodeList: [], |
| | | |
| | | treeData: [], |
| | | defaultProps: { |
| | | children: 'children', |
| | | label: 'name', |
| | | disabled: (data) => data.nodeType!=='machine',//仅机床节点可选 |
| | | isLeaf: (data) => !data.hasChildren |
| | | }, |
| | | timeout:0, //零件号加载的timeout |
| | | //drawingNoMatch:true,//零件号是否匹配分工表 |
| | | attachOption: { |
| | | labelWidth: 160, |
| | | submitBtn: true, |
| | |
| | | tip: false, |
| | | column: [ |
| | | { |
| | | label: '图号', |
| | | label: '流程标题', |
| | | prop: 'title', |
| | | type: 'input', |
| | | span: 24, |
| | | disabled:true, |
| | | dataType: 'string' |
| | | }, |
| | | { |
| | | label: '零组件号', |
| | | prop: 'drawingNo', |
| | | type: 'input', |
| | | span: 12, |
| | | dataType: 'string', |
| | | blur: (col) => { |
| | | this.handleTrim(col); |
| | | |
| | | }, |
| | | rules: [{ required: true, message: '必填', trigger: 'blur' }], |
| | | }, |
| | | { |
| | | label: '图号版次', |
| | | label: '图纸版次', |
| | | prop: 'drawingNoEdition', |
| | | type: 'input', |
| | | span: 12, |
| | | dataType: 'string', |
| | | rules: [{ required: true, message: '必填', trigger: 'blur' }], |
| | | blur: (col) => { |
| | | this.handleTrim(col) |
| | | }, |
| | | }, |
| | | { |
| | | label: '产品型号', |
| | | prop: 'productType', |
| | | prop: 'productModel', |
| | | type: 'input', |
| | | span: 12, |
| | | dataType: 'string', |
| | | // rules: [ |
| | | // { |
| | | // required: true, |
| | | // message: '请选择流程类型', |
| | | // trigger: 'blur', |
| | | // }, |
| | | // ], |
| | | rules: [{ required: true, message: '必填', trigger: 'blur' }], |
| | | blur: (col) => { |
| | | this.handleTrim(col) |
| | | }, |
| | | }, |
| | | { |
| | | label: '工序号', |
| | | prop: 'processNo', |
| | | type: 'input', |
| | | span: 12, |
| | | step: 1, |
| | | precision: 0, |
| | | dataType: 'string', |
| | | rules: [{ required: true, message: '必填', trigger: 'blur' }], |
| | | blur: (col) => { |
| | | this.handleTrim(col) |
| | | }, |
| | | }, |
| | | { |
| | | label: '工序名称', |
| | |
| | | type: 'input', |
| | | span: 12, |
| | | dataType: 'string', |
| | | rules: [{ required: true, message: '必填', trigger: 'blur' }], |
| | | blur: (col) => { |
| | | this.handleTrim(col) |
| | | }, |
| | | }, |
| | | { |
| | | label: '工艺版次', |
| | | prop: 'craftEdition', |
| | | label: '工序版次', |
| | | prop: 'processEdition', |
| | | type: 'input', |
| | | span: 12, |
| | | dataType: 'string', |
| | | rules: [{ required: true, message: '必填', trigger: 'blur' }], |
| | | blur: (col) => { |
| | | this.handleTrim(col) |
| | | }, |
| | | }, |
| | | { |
| | | label: '批次号', |
| | | prop: 'craftEdition', |
| | | placeholder:'如"2S24001"', |
| | | type: 'input', |
| | | span: 12, |
| | | dataType: 'string', |
| | | maxlength: 10, |
| | | blur: (col) => { |
| | | this.handleTrim(col) |
| | | }, |
| | | }, |
| | | |
| | | { |
| | | label: '加工机床', |
| | | prop: 'machineCode', |
| | | type: 'select', |
| | | dicUrl: `/blade-mdm/machine/page`, |
| | | dicFormatter: function(res) { |
| | | that.machineCodeList = res.data.records; |
| | | return res.data.records; |
| | | }, |
| | | props: { |
| | | label: 'name', |
| | | value: 'code', |
| | | }, |
| | | rules: [{ required: true, message: '必填', trigger: 'blur' }], |
| | | span: 12 |
| | | }, |
| | | { |
| | | label: '计划锁定时间(天)', |
| | | prop: 'planLockDays', |
| | | type: 'input', |
| | | type: 'number', |
| | | min:0, |
| | | max:30, |
| | | span: 12, |
| | | dataType: 'string', |
| | | controls:true, |
| | | dataType: 'number', |
| | | controlsPosition:'right', |
| | | rules: [{ required: true, message: '必填', trigger: 'blur' }], |
| | | }, |
| | | { |
| | | label: '计划开工时间', |
| | |
| | | valueFormat: "YYYY-MM-DD", |
| | | span: 12, |
| | | dataType: 'string', |
| | | rules: [{ required: true, message: '必填', trigger: 'blur' }], |
| | | }, |
| | | { |
| | | label: '临时更改单号', |
| | | prop: 'deviation', |
| | | type: 'input', |
| | | span: 12, |
| | | dataType: 'string', |
| | | class:'input_holder_warn', |
| | | placeholder:'非临时更改单任务请留空', |
| | | blur: (col) => { |
| | | this.handleTrim(col) |
| | | }, |
| | | // rules: [{ required: true, message: '必填', trigger: 'blur' }], |
| | | }, |
| | | { |
| | | label: '主管工艺', |
| | | prop: 'producePlanId', |
| | | type: 'select',//column 12 |
| | | clearable:true, |
| | | remote: true, |
| | | placeholder:'无法匹配人员职责表时请选择主管工艺', |
| | | dicUrl: `/blade-mdm/producedivision/select-programmer?programmer={{key}}`, |
| | | dicFormatter:(res)=>{ |
| | | return res.data.map(obj => { |
| | | let item = new Object(); |
| | | item.value = obj.id; |
| | | item.label = obj.programmerName; |
| | | item.desc = `专业组长:${obj.teamLeaderName},校对:${obj.checkerName},审核:${obj.seniorName}` |
| | | return item; |
| | | }); ; |
| | | }, |
| | | span: 12, |
| | | dataType: 'string', |
| | | }, |
| | | /*{ |
| | | label: '主管工艺', |
| | | prop: 'programmer', |
| | | type: 'input',//column 12 |
| | | span: 12, |
| | | dataType: 'string', |
| | | },*/ |
| | | ], |
| | | }, |
| | | attachForm: {}, |
| | | attachForm: {planLockDays:7,planStartTime: this.$dayjs().format('YYYY-MM-DD')},//默认7天 |
| | | defaultForm: {planLockDays:7,planStartTime: this.$dayjs().format('YYYY-MM-DD')}, |
| | | }; |
| | | }, |
| | | methods: { |
| | | formSubmit(form,done) { |
| | | var form = {...form}; |
| | | this.machineCodeList.forEach(item=> { |
| | | if(form.machineCode == item.code) { |
| | | form.machineMode = item.name; |
| | | treeLoad () { |
| | | axios({ |
| | | url: '/blade-mdm/gkw/node/load-tree', |
| | | method: 'get', |
| | | }).then( |
| | | res => { |
| | | this.treeData = this.filterTreeData(res.data.data); |
| | | var firstIndex = 0; |
| | | res.data.data.forEach((item,index)=> { |
| | | if(item.children.length != 0) { |
| | | firstIndex = index; |
| | | } |
| | | }) |
| | | //defaultKeys.push(item.id); |
| | | this.defaultKeys = [res.data.data[firstIndex].id]; |
| | | } |
| | | }) |
| | | form.producePlanId = "1932411828915224578"; |
| | | ) |
| | | }, |
| | | filterTreeData(oriTreeData){ |
| | | var roots = []; |
| | | for(var i=0;i<oriTreeData.length;i++){ |
| | | roots.push(this.filterTreeNodes(oriTreeData[i])); |
| | | } |
| | | return roots; |
| | | }, |
| | | filterTreeNodes(node) { |
| | | // 如果当前节点的nodeType是'machine',则清除其子节点 |
| | | if (node.nodeType === 'machine') { |
| | | // 创建一个新对象,复制当前节点的属性,但清除children |
| | | return { |
| | | ...node, |
| | | children: [] |
| | | }; |
| | | } |
| | | |
| | | // 如果当前节点有子节点,递归处理每个子节点 |
| | | if (node.children && node.children.length > 0) { |
| | | return { |
| | | ...node, |
| | | children: node.children.map(child => this.filterTreeNodes(child)) |
| | | }; |
| | | } |
| | | |
| | | // 如果既不是machine节点也没有子节点,直接返回原节点 |
| | | return node; |
| | | }, |
| | | |
| | | querySearchAsync(query, cb) {//零组件号搜索建议 |
| | | axios({ |
| | | url: '/blade-mdm/producedivision/select-data', |
| | | method: 'get', |
| | | params: {drawingNo: query}, |
| | | }).then( |
| | | res => { |
| | | if(res.data.code == 200){ |
| | | let list = res.data.data; |
| | | for(let i of list){ |
| | | i.value = i.ljh; |
| | | } |
| | | |
| | | clearTimeout(this.timeout) |
| | | this.timeout = setTimeout(() => { |
| | | cb(list); |
| | | }, 1000) |
| | | |
| | | } |
| | | }, |
| | | error => { |
| | | console.log(error); |
| | | } |
| | | ); |
| | | |
| | | }, |
| | | handleSelect(item) { |
| | | this.attachForm.productModel = item.cph; |
| | | }, |
| | | /* |
| | | queryProgrammerAsync(query, cb) {//主管工艺搜索建议 |
| | | axios({ |
| | | url: '/blade-mdm/producedivision/select-programmer', |
| | | method: 'get', |
| | | params: {programmer: query}, |
| | | }).then( |
| | | res => { |
| | | if(res.data.code == 200){ |
| | | let list = res.data.data; |
| | | for(let i of list){ |
| | | i.value = '主管工艺:'+i.programmerName+',校对:'+i.checkerName; |
| | | } |
| | | |
| | | clearTimeout(this.timeout) |
| | | this.timeout = setTimeout(() => { |
| | | cb(list); |
| | | }, 600) |
| | | |
| | | } |
| | | }, |
| | | error => { |
| | | console.log(error); |
| | | } |
| | | ); |
| | | |
| | | }, |
| | | */ |
| | | /* |
| | | handleProgrammerSelect(item){ |
| | | this.attachForm.producePlanId = item.id; |
| | | this.attachForm.planDrawingNo = this.attachForm.drawingNo;//记录此时的零组件号 |
| | | console.log('productid',this.attachForm ) |
| | | |
| | | },*/ |
| | | 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 }; |
| | | |
| | | if(this.attachForm.producePlanId){ |
| | | //手动指定了人员职责表id,不用继续从服务端验证 |
| | | this.startDispatch(form,done); |
| | | }else{ |
| | | axios({ |
| | | url: '/blade-mdm/producedivision/select-by-drawingno', |
| | | method: 'get', |
| | | params: {drawingNo:this.attachForm.drawingNo}, |
| | | }).then( |
| | | res => { |
| | | |
| | | if(res.data.code == 200){ |
| | | |
| | | this.attachForm.producePlanId = res.data.data.id; |
| | | //this.drawingNoMatch = true; |
| | | console.log('planid',this.attachForm.productPlanId) |
| | | this.startDispatch(form,done); |
| | | }else{ |
| | | //this.drawingNoMatch = false; |
| | | |
| | | this.$alert(res.data.msg+".重新输入或者手动选择主管工艺。", '发起任务失败',{type:'error',confirmButtonText:'关闭'}); |
| | | } |
| | | done(); |
| | | }, |
| | | error => { |
| | | console.log(error); |
| | | done(); |
| | | } |
| | | ); |
| | | } |
| | | |
| | | }, |
| | | startDispatch(form,done){ |
| | | //验证都通过了,执行启动流程 |
| | | axios({ |
| | | url: '/blade-mdm/flow/dispatch/start', |
| | | method: 'post', |
| | | data: form, |
| | | }).then( |
| | | res => { |
| | | |
| | | if(res.data.code == 200){ |
| | | this.$message({ |
| | | type: 'success', |
| | | message: '操作成功!', |
| | | }); |
| | | this.$refs.form.resetForm(); |
| | | done(); |
| | | this.attachForm = this.defaultForm; |
| | | //this.drawingNoMatch = true; |
| | | }else{ |
| | | this.$alert(res.data.msg, '发起任务失败',{type:'error',confirmButtonText:'关闭'}); |
| | | } |
| | | done(); |
| | | }, |
| | | error => { |
| | | window.console.log(error); |
| | | done(); |
| | | window.console.log(error); |
| | | 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; |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | |
| | | mounted() { |
| | | this.treeLoad(); |
| | | }, |
| | | }; |
| | | </script> |
| | | |
| | | <style lang="scss"> |
| | | |
| | | .input_holder_warn { |
| | | .el-input__inner::placeholder { |
| | | color: rgb(255, 106, 0); /* 设置颜色为红色 */ |
| | | font-size: 16px; /* 设置字体大小为16px */ |
| | | } |
| | | } |
| | | </style> |