| | |
| | | <script setup> |
| | | import {computed, nextTick, onMounted, reactive, ref, toRefs} from "vue"; |
| | | import {useRouter} from 'vue-router' |
| | | import {useRouter,useRoute} from 'vue-router' |
| | | import request from "@/utils/request"; |
| | | import {ElMessage} from "element-plus"; |
| | | import {changeFilterEvent, filterChanged} from "@/hook" |
| | |
| | | let brokenVisible = ref(false) |
| | | const xGrid = ref() |
| | | const brokenGrid =ref() |
| | | let router = useRouter() |
| | | const router = useRouter() |
| | | const route = useRoute() |
| | | const user=userInfo() |
| | | |
| | | //定义表头数据 |
| | | const titleUploadData = ref({ |
| | | //流程卡号 |
| | | processId: 'NG24030701B01/1', |
| | | processId: 'NG24030804A02/1', |
| | | //销售单号 |
| | | orderId: '', |
| | | reviewedState:0, |
| | | //生产单号 |
| | | productionId: '', |
| | | //设备类型 |
| | |
| | | |
| | | }) |
| | | |
| | | |
| | | onMounted(() =>{ |
| | | if(route.query.processId !== undefined && route.query.processId!=='' && route.query.processId!=null ){ |
| | | titleUploadData.value.processId = route.query.processId |
| | | } |
| | | //判断是否传入报工编号 |
| | | if(route.query.reportingWorkId!== undefined && route.query.reportingWorkId!=='' && route.query.reportingWorkId!=null){ |
| | | request.post(`reportingWork/selectUpdateReportingWork/${route.query.reportingWorkId}`).then(res=>{ |
| | | if(res.code === '200'){ |
| | | titleUploadData.value = res.data.reportingWork |
| | | console.log(res.data) |
| | | xGrid.value.reloadData(res.data.reportingWorkDetails) |
| | | } |
| | | }) |
| | | } |
| | | }) |
| | | |
| | | |
| | | //表尾求和 |
| | | const sumNum = (list, field) => { |
| | | let count = 0 |
| | |
| | | |
| | | |
| | | const optionVal = ref('') |
| | | const options = [ |
| | | { |
| | | value: '切割', |
| | | label: '切割', |
| | | }, |
| | | { |
| | | value: '磨边', |
| | | label: '磨边', |
| | | }, |
| | | { |
| | | value: '钢化', |
| | | label: '钢化', |
| | | }, |
| | | ] |
| | | |
| | | //班次 |
| | | const classesVal = ref('早班') |
| | |
| | | showOverflow: "ellipsis", |
| | | filterMethod: filterChanged |
| | | }, |
| | | {field: 'quantity', title: '上工完工数量',}, |
| | | {field: 'quantity', title: '可报数量',}, |
| | | { |
| | | field: 'completedQuantity', title: '完工数量', |
| | | field: 'completedQuantity', title: '完工数量',width: 120, |
| | | editRender: { |
| | | name: 'input', |
| | | attrs: {placeholder: ''}, |
| | | attrs: {placeholder: ''} |
| | | }, |
| | | |
| | | }, |
| | |
| | | // {code: 'sameDamage', name: '次破相同'}, |
| | | // {code: 'sameOneCompletion', name: '完工一列相同'}, |
| | | // {code: 'sameOneDamage', name: '次破一列相同'}, |
| | | {code: 'saveReportingWork', name: '保存', status: 'primary', icon: 'vxe-icon-save'}, |
| | | {code: 'print_lck', name: '保存并审核', status: 'primary', icon: 'vxe-icon-save'}, |
| | | {code: 'saveReportingWork', name: '保存', status: 'primary', icon: 'vxe-icon-save',disabled:true}, |
| | | {code: 'saveReportingWorkReview', name: '保存并审核', status: 'primary', icon: 'vxe-icon-save',disabled:true}, |
| | | ], |
| | | // import: false, |
| | | // export: true, |
| | |
| | | if ($grid) { |
| | | switch (code) { |
| | | case 'saveReportingWork': { |
| | | if($grid.getTableData().fullData.length===0){ |
| | | ElMessage.warning(`请选择流程卡数据`) |
| | | return false |
| | | } |
| | | const device = titleUploadData.value.deviceName |
| | | if(device === null || device === undefined || device === ''){ |
| | | ElMessage.error('请选择报工设备!') |
| | | return |
| | | } |
| | | const teamsGroupsName = titleUploadData.value.teamsGroupsName |
| | | if(teamsGroupsName === null || teamsGroupsName === undefined || teamsGroupsName === ''){ |
| | | ElMessage.error('请选择报工设备!') |
| | | return |
| | | } |
| | | const errMap = await $grid.validate(true) |
| | | if (errMap) { |
| | | ElMessage.error(`校验不通过!`) |
| | | return |
| | | } |
| | | saveReportingWork() |
| | | saveReportingWork(0) |
| | | break |
| | | } |
| | | case 'saveReportingWorkReview': { |
| | | const errMap = await $grid.validate(true) |
| | | if (errMap) { |
| | | ElMessage.error(`校验不通过!`) |
| | | return |
| | | } |
| | | saveReportingWork(1) |
| | | break |
| | | } |
| | | } |
| | |
| | | |
| | | |
| | | const checkClose = async (done) => { |
| | | if(brokenGrid.value.getTableData().fullData.length===0){ |
| | | done() |
| | | return true |
| | | } |
| | | const errMap = await brokenGrid.value.validate(true) |
| | | if (errMap) { |
| | | ElMessage.error(`校验不通过!`) |
| | |
| | | }) |
| | | |
| | | let reportingWorkNum = isNaN(brokenRow.value.completedQuantity*1)?0:brokenRow.value.completedQuantity*1 |
| | | if(breakageQuantityCount+reportingWorkNum>brokenRow.value.quantity*1){ |
| | | if((breakageQuantityCount+reportingWorkNum>brokenRow.value.quantity*1) ){ |
| | | ElMessage.warning(`损耗数:'${breakageQuantityCount}' |
| | | 完工数:'${reportingWorkNum}'之和${breakageQuantityCount+reportingWorkNum} |
| | | 不能大于${brokenRow.value.quantity*1}`) |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | //第一次加载数据 |
| | | |
| | | request.post(`/reportingWork/selectProcess`).then((res) => { |
| | |
| | | } |
| | | }) |
| | | |
| | | const saveReportingWork = () => { |
| | | const saveReportingWork = (type) => { |
| | | |
| | | if(xGrid.value.getTableData().fullData.length===0){ |
| | | ElMessage.warning(`请选择流程卡数据`) |
| | | return false |
| | | } |
| | | const device = titleUploadData.value.deviceName |
| | | if(device === null || device === undefined || device === ''){ |
| | | ElMessage.error('请选择报工设备!') |
| | | return |
| | | } |
| | | const teamsGroupsName = titleUploadData.value.teamsGroupsName |
| | | if(teamsGroupsName === null || teamsGroupsName === undefined || teamsGroupsName === ''){ |
| | | ElMessage.error('请选择报工设备!') |
| | | return |
| | | } |
| | | |
| | | titleUploadData.value.creator = user.user.userName |
| | | titleUploadData.value.creatorId = user.user.userId |
| | |
| | | |
| | | const requestData = { |
| | | title:titleUploadData.value, |
| | | detail:xGrid.value.getTableData().fullData |
| | | detail:xGrid.value.getTableData().fullData, |
| | | type:type//审核状态 |
| | | } |
| | | gridOptions.toolbarConfig.buttons[0].disabled=true |
| | | gridOptions.toolbarConfig.buttons[1].disabled=true |
| | | request.post(`/reportingWork/saveReportingWork`,requestData).then(res =>{ |
| | | if (res.code == 200){ |
| | | ElMessage.success("报工成功") |
| | | router.push({path:'/main/reportingWorks/AddReportingWork',query:{random:Math.random()}}) |
| | | router.push({path:'/main/reportingWorks/AddReportingWork',query:{processId:titleUploadData.value.processId,random:Math.random()}}) |
| | | }else{ |
| | | ElMessage.error(res.msg) |
| | | const errorObj = JSON.parse(res.msg) |
| | | const msg = "序号:"+errorObj.orderNumber+'\n' |
| | | +'小片顺序:'+errorObj.technologyNumber+'\n' |
| | | +"实际可报工数量:"+errorObj.processNum+'<'+ |
| | | "报工数量:"+errorObj.sumNum+'\n' |
| | | +"请刷新界面重新报工" |
| | | |
| | | ElMessage.error(msg) |
| | | } |
| | | }).catch(err =>{ |
| | | ElMessage.error(err.message) |
| | | }).finally(()=>{ |
| | | gridOptions.toolbarConfig.buttons[0].disabled=false |
| | | gridOptions.toolbarConfig.buttons[1].disabled=false |
| | | }) |
| | | } |
| | | |
| | |
| | | } |
| | | }) |
| | | |
| | | let loadingFlag = ref(false) |
| | | let disabledFlag = ref(true) |
| | | const reviewReportingWork = () => { |
| | | const processId = titleUploadData.value.processId |
| | | if (processId.indexOf("/") < 0) { |
| | | ElMessage.warning("请输入正确格式流程卡") |
| | | return |
| | | } |
| | | let indexOfChar = processId.indexOf("/") |
| | | let leftString = processId.slice(0, indexOfChar) |
| | | if (leftString.length !== 13) { |
| | | ElMessage.warning("请输入正确位数的流程卡") |
| | | return |
| | | } |
| | | //工序 |
| | | let process = titleUploadData.value.thisProcess |
| | | if (process === "" || process == null) { |
| | | ElMessage.warning("请选择工序") |
| | | return |
| | | } |
| | | if(titleUploadData.value.previousProcess===''){ |
| | | ElMessage.warning("第一道工序不需要审核") |
| | | return |
| | | } |
| | | const reportWork = { |
| | | process: titleUploadData.value.previousProcess, |
| | | processId:processId |
| | | } |
| | | loadingFlag.value= true |
| | | request.post("/reportingWork/reviewReportingWork",reportWork).then((res) =>{ |
| | | if(res.code === '200'){ |
| | | ElMessage.success("审核成功") |
| | | router.push({path:'/main/reportingWorks/AddReportingWork', |
| | | query:{ |
| | | processId:titleUploadData.value.processId, |
| | | random:Math.random() |
| | | } |
| | | }) |
| | | } |
| | | }).finally( |
| | | loadingFlag.value= false |
| | | ) |
| | | |
| | | } |
| | | |
| | | |
| | | //下拉款选择工序时查询 |
| | | const getWork = () => { |
| | |
| | | //工序 |
| | | let process = titleUploadData.value.thisProcess |
| | | if (process == "" || process == null) { |
| | | |
| | | ElMessage.warning("请选择工序") |
| | | return |
| | | } |
| | |
| | | |
| | | request.post(`/reportingWork/addSelectLastWork/${processIdStr}/${technologyStr}/${process}`).then((res) => { |
| | | if (res.code == 200) { |
| | | if(res.data.data===null){ |
| | | ElMessage.error("未查询到此流程卡数据") |
| | | return |
| | | } |
| | | //表头赋值 |
| | | titleUploadData.value = res.data.data |
| | | titleUploadData.value.processId = processId |
| | |
| | | titleSelectJson.value.breakageType = res.data.breakageType |
| | | //次破原因 |
| | | titleSelectJson.value.breakageReason = res.data.breakageReason |
| | | //console.log(res.data) |
| | | if(titleUploadData.value.reviewedState==1){ |
| | | gridOptions.toolbarConfig.buttons[0].disabled=false |
| | | gridOptions.toolbarConfig.buttons[1].disabled=false |
| | | disabledFlag.value=true |
| | | }else { |
| | | gridOptions.toolbarConfig.buttons[0].disabled=true |
| | | gridOptions.toolbarConfig.buttons[1].disabled=true |
| | | disabledFlag.value=false |
| | | } |
| | | |
| | | //判断早晚班 |
| | | titleUploadData.value.classes='早班' |
| | | |
| | | |
| | | titleUploadData.value.reportingWorkTime = formatCurrentTime() |
| | | //绑定下方表格 |
| | | detail.value = res.data.Detail |
| | |
| | | let hours = dateObj.getHours().toString().padStart(2, '0'); // 小时 |
| | | let minutes = dateObj.getMinutes().toString().padStart(2, '0'); // 分钟 |
| | | let seconds = dateObj.getSeconds().toString().padStart(2, '0'); // 秒数 |
| | | if(parseInt(hours)>=17)titleUploadData.value.classes='晚班' |
| | | if(parseInt(hours)>=17 && parseInt(hours)<8)titleUploadData.value.classes='晚班' |
| | | return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`; // 返回格式化后的时间字符串 |
| | | } |
| | | |
| | | const ptypeChangeEvent = (row) => { |
| | | // for (let i = 0; i < row.length; i++){ |
| | | // |
| | | // let process=row[i].responsibleProcess |
| | | // } |
| | | const editClosedEvent = ({ row, column }) => { |
| | | if (column.property==='completedQuantity') { |
| | | xGrid.value.getTableData().fullData.forEach((item, index) =>{ |
| | | if(item.order_number===row.order_number){ |
| | | item.completedQuantity=row.completedQuantity |
| | | } |
| | | }) |
| | | } |
| | | } |
| | | |
| | | </script> |
| | | |
| | | <template> |
| | |
| | | /> |
| | | </el-select> |
| | | |
| | | <el-button type="primary">审核通过</el-button> |
| | | <el-button type="primary">审核不通过</el-button> |
| | | <el-button :disabled="disabledFlag" :loading="loadingFlag" @click="reviewReportingWork" type="primary">审核通过</el-button> |
| | | <!-- <el-button type="primary">审核不通过</el-button>--> |
| | | |
| | | <label>流程卡面积:xxx平方米</label> |
| | | </div> |
| | |
| | | <el-text>可报工数量:</el-text> |
| | | </el-col> |
| | | <el-col :span="2"> |
| | | <el-text>{{ titleUploadData.flowCard.quantity }}</el-text> |
| | | <el-text>{{ titleUploadData.previousProcessQuantity }}</el-text> |
| | | |
| | | </el-col> |
| | | <el-col :span="2"> |
| | |
| | | v-bind="gridOptions" |
| | | v-on="gridEvents" |
| | | @filter-change="filterChanged" |
| | | @edit-closed="editClosedEvent" |
| | | |
| | | > |
| | | |