From 24ed368b866dd016a7dca8e65d16bbbd4fdc1298 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B7=BB=E7=A0=96-JAVA=5CAdministrator?= <591141169@qq.com> Date: Tue, 7 May 2024 13:38:37 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9A=82=E5=AD=98=E5=8A=9F=E8=83=BD=E6=8F=90?= =?UTF-8?q?=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../inspectionJob/inspectionJobMain/index.ts | 6 + src/utils/disposition/defaultButtons.ts | 14 ++ .../qms/inspection/inspectionJob/addForm.vue | 128 ++++++++++++++++++ .../qms/inspection/inspectionJob/index.vue | 1 - 4 files changed, 148 insertions(+), 1 deletion(-) diff --git a/src/api/qms/inspectionJob/inspectionJobMain/index.ts b/src/api/qms/inspectionJob/inspectionJobMain/index.ts index 2b59a7401..aca7fd268 100644 --- a/src/api/qms/inspectionJob/inspectionJobMain/index.ts +++ b/src/api/qms/inspectionJob/inspectionJobMain/index.ts @@ -22,6 +22,11 @@ export const createInspectionJobMain = async (data) => { return await request.post({ url: `/qms/inspection-job-main/create`, data }) } +// 暂存检验任务 +export const stagingInspectionJobMain = async (data) => { + return await request.post({ url: `/qms/inspection-job-main/staging`, data }) +} + // 修改检验任务 export const updateInspectionJobMain = async (data) => { return await request.put({ url: `/qms/inspection-job-main/update`, data }) @@ -46,6 +51,7 @@ export const abandonInspectionJobMain = async (id) => { export const closeInspectionJobMain = async (id) => { return await request.put({ url: `/qms/inspection-job-main/close?id=` + id }) } + // 导出检验申请 Excel export const exportInspectionJobMain = async (params) => { return await request.download({ url: `/qms/inspection-job-main/export-excel`, params }) diff --git a/src/utils/disposition/defaultButtons.ts b/src/utils/disposition/defaultButtons.ts index 164f2c295..1d967ae75 100644 --- a/src/utils/disposition/defaultButtons.ts +++ b/src/utils/disposition/defaultButtons.ts @@ -187,6 +187,20 @@ export function formCloseBtn(option:any) { }) } +// form表单-关闭按钮 +export function formStagingBtn(option:any) { + return __defaultBtnOption(option,{ + label: t(`btn.暂存`).replace('btn.', ''), + name: 'staging', + hide: false, + + color: '', + float:'right', + hasPermi: '' + }) +} + + // drawer抽屉头部-编辑按钮 export function drawerEditBtn(option:any) { return __defaultBtnOption(option,{ diff --git a/src/views/qms/inspection/inspectionJob/addForm.vue b/src/views/qms/inspection/inspectionJob/addForm.vue index 8d3704a9a..c38c44d2d 100644 --- a/src/views/qms/inspection/inspectionJob/addForm.vue +++ b/src/views/qms/inspection/inspectionJob/addForm.vue @@ -522,6 +522,10 @@ const buttonBaseClick =async(val) => { // await InspectionJobMainApi.abandonInspectionJobMain(data.value.id) dialogVisible.value = false } + // 暂存 + else if (val == 'staging') { + staging() + } } // 传递给父类 const emit = defineEmits(['submitForm', 'searchTableSuccess']) @@ -661,12 +665,136 @@ const submitForm = async () => { console.log(111) } } + + +const staging = async () => { + try { + console.log(data.value.subList) + const elForm = unref(formMainRef)?.getElFormRef() + // 校验表单 + if (!elForm) return + const valid = await elForm.validate() + if (!valid) return + // 校验包装列表 + + console.log(11,data.value.packageList) + if(data.value.packageList?.length>0){ + const validateForm1 = await tableFormRef.value.validateForm() + if (!validateForm1) return + let isPass = data.value.packageList.some(cur=>parseFloat(cur.sampleAmount)>parseFloat(cur.amount)) + if(isPass){ + message.error(`采样数量不能大于数量`) + return + } + // let number = 0 + // data.value.packageList.forEach(cur=>{ + // number += parseFloat(cur.sampleAmount) + // }) + // number = number.toFixed('2') + // if(number != data.value.sampleTotalAmount){ + // message.error(`采样数量之和必须等于采样总数量`) + // return + // } + } + + const bol2 = await validateForm(formFeaturesRef.value) + if (!bol2) { + message.error(`模板中有检验工序和检验特性未填写完全`) + return + } + // 判断数组是否有未填的选项 + let arrBol = [] + let isOutweigh = []//结束时间是否大于开始时间 + let numberList = []//判断合格数量和不合格数量之和是否等于主表数量 + let parseFloatList = []//判断合格数量和不合格数量是否是整数 + data.value.subList.forEach((item, index) => { + if (item.inspectionJobCharacteristicsUpdateReqVO.resultEntryMethod == 1) { + arrBol.push( + item.inspectionJobCharacteristicsUpdateReqVO.recordInspectionQuantifyList.some( + (cur, key) => { + return !cur.qualifiedQuantity || !cur.unqualifiedQuantity + } + ) + ) + } + if (item.inspectionJobCharacteristicsUpdateReqVO.featureType == 0) { + arrBol.push( + item.inspectionJobCharacteristicsUpdateReqVO.recordInspectionQuantifyList.some( + (cur, key) => { + return !cur.inspectionValue + } + ) + ) + } + if (item.inspectionJobCharacteristicsUpdateReqVO.featureType == 1) { + arrBol.push( + item.inspectionJobCharacteristicsUpdateReqVO.recordInspectionQuantifyList.some( + (cur, key) => { + return !cur.qualitativeCode + } + ) + ) + } + // 开始时间大于结束时间放入数组中 + if (item.inspectionJobCharacteristicsUpdateReqVO.inspectionStartTime >item.inspectionJobCharacteristicsUpdateReqVO.inspectionEndTime) { + isOutweigh.push(item.inspectionJobCharacteristicsUpdateReqVO.inspectionStartTime) + } + // 合格数量和不合格数量之和不能是小数 + if (item.inspectionJobCharacteristicsUpdateReqVO.resultEntryMethod == 1) { + parseFloatList.push( + item.inspectionJobCharacteristicsUpdateReqVO.recordInspectionQuantifyList.some( + (cur, key) => { + return String(cur.qualifiedQuantity).indexOf('.')>-1 || String(cur.unqualifiedQuantity).indexOf('.')>-1 + } + ) + ) + // 合格数量和不合格数量之和不等于总数量 + numberList.push( + item.inspectionJobCharacteristicsUpdateReqVO.recordInspectionQuantifyList.some( + (cur, key) => { + console.log(12,cur.qualifiedQuantity) + console.log(13,cur.unqualifiedQuantity) + console.log(14,item.inspectionJobCharacteristicsUpdateReqVO.sampleQty) + return parseFloat(cur.qualifiedQuantity) + parseFloat(cur.unqualifiedQuantity) != parseFloat(item.inspectionJobCharacteristicsUpdateReqVO.sampleQty) + } + ) + ) + } + }) + let isEmpty1 = arrBol.some(item=>item == true) + let isEmptyNumberList = numberList.some(item=>item == true) + let isParseFloat = parseFloatList.some(item=>item == true) + if(isEmpty1){ + message.error('检验工序和检验特性有字段未填写完全') + return; + } + if(isOutweigh?.length>0){ + message.error('检验特性中有开始时间大于结束时间') + return; + } + if(isParseFloat){ + message.error('合格数量和不合格数量之和不可以是小数') + return; + } + if(isEmptyNumberList){ + message.error('合格数量和不合格数量之和必须等于样品份数') + return; + } + await InspectionJobMainApi.stagingInspectionJobMain(data.value) + message.success('暂存成功!') + } catch { + console.log(111) + } +} + + /** 弹窗按钮 */ let Butttondata: any = [] if (props.footButttondata) { Butttondata = props.footButttondata } else { Butttondata = [ + defaultButtons.formStagingBtn(null), // 暂存 defaultButtons.formSaveBtn(null), // 保存 defaultButtons.formCloseBtn(null) // 关闭 ] diff --git a/src/views/qms/inspection/inspectionJob/index.vue b/src/views/qms/inspection/inspectionJob/index.vue index 1c3b1f33b..5b24b0c84 100644 --- a/src/views/qms/inspection/inspectionJob/index.vue +++ b/src/views/qms/inspection/inspectionJob/index.vue @@ -203,7 +203,6 @@ const list = ref([]) detailRef.value.openDetail(row, titleName, titleValue, 'basicInspectionJobMain') } //执行 - const formRef = ref() const execute = async (type : string, row ?: number) => { formRef.value.open(type, row)