From 94d825fa2d7cf146e99378f19cc9d19789057757 Mon Sep 17 00:00:00 2001 From: mayong Date: Thu, 5 Dec 2024 17:59:23 +0800 Subject: [PATCH] =?UTF-8?q?=E5=87=BA=E5=85=A5=E5=BA=93=E7=94=B3=E8=AF=B7?= =?UTF-8?q?=E7=94=B3=E8=AF=B7=E9=A1=B5=E9=9D=A2=E6=95=B0=E6=8D=AE=E4=BA=A4?= =?UTF-8?q?=E4=BA=92=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/stock/component/applyForm.vue | 41 +++++++--- src/views/stock/component/applyModal.vue | 94 ++++++++++++++++++++--- src/views/stock/component/scanForm.vue | 74 +++++++++++++----- src/views/stock/inboud/inboud-page.vue | 2 +- src/views/stock/outboud/outbound-page.vue | 6 +- 5 files changed, 170 insertions(+), 47 deletions(-) diff --git a/src/views/stock/component/applyForm.vue b/src/views/stock/component/applyForm.vue index be86ade..13edb31 100644 --- a/src/views/stock/component/applyForm.vue +++ b/src/views/stock/component/applyForm.vue @@ -8,16 +8,18 @@ - 采购入库 - 归还入库 + 采购入库 + 归还入库 + 出库外借 - - + + @@ -25,8 +27,7 @@
- + empty-text="请先选择物料" :edit-config="{ trigger: 'click', mode: 'cell', autoFocus: true }"> @@ -57,13 +58,29 @@ import api from '@/api' import { useUserStore } from '@/stores/user' import dayjs, { Dayjs } from 'dayjs'; -// 和外层界面的数据交互 +// 和外层界面的数据交互 +const props = defineProps( + { + applyType: { + type: String, + default: '' + } + } // 申请类型 applyType页面传值的使用1和2,1: 采购入库 和 归还入库 2: 出库外借 +) const getTableData = () => { const $table = tableRef.value return $table?.getTableData().fullData; } - -defineExpose({ getTableData}) +const getApplyForm = () => { + return { + type: formData.value.applyType, + applicant: formData.value.applicant, + applyDate: formData.value.applyDate.format('YYYY-MM-DD HH:mm:ss'), + isConfirm: true, + exceptionExplain: '' + } +} +defineExpose({ getTableData, getApplyForm }) interface FormData { applicant: string; // 申请人 @@ -76,7 +93,7 @@ const userStore = useUserStore() const formData = ref({ applicant: userStore.userName, applyDate: dayjs(), - applyType: '1', // 1: 采购入库 2: 归还入库 3: 出库外借 + applyType: props.applyType, // 1: 采购入库 2: 归还入库 3: 出库外借 slectedList: [] }); @@ -138,7 +155,7 @@ const insertEvent = (value: any) => { } // 取消选中时,删除table中的行 -const removeEvent = (value: any) => { +const removeEvent = (value : any) => { const $table = tableRef.value // 根据value找到对应的行 if ($table) { diff --git a/src/views/stock/component/applyModal.vue b/src/views/stock/component/applyModal.vue index 3c16046..bd04ea9 100644 --- a/src/views/stock/component/applyModal.vue +++ b/src/views/stock/component/applyModal.vue @@ -1,20 +1,24 @@ @@ -30,26 +34,92 @@ import applyForm from '../component/applyForm.vue' import scanForm from '../component/scanForm.vue'; import applyConfirm from '../component/applyConfirm.vue'; +import successResul from '../component/successResul.vue'; +import api from '@/api' - +// 和外层界面的数据交互 +defineProps( + { + applyType: { + type: String, + default: '', + } + } // 申请类型 applyType页面传值的使用1和2,1: 采购入库 和 归还入库 2: 出库外借 +) // steps const current = ref(0) // 翻页的引用 const applyFormRef = ref(); // step1表单引用 -const selectData = ref(); - -const totalValue = ref(199); +const scanFormRef = ref(); // step2表单引用 +const applyConfirmRef = ref(); // step3表单引用 +const selectData = ref(); // step1中用户申请选择的物料数据,存的原始数据 +const scanData = ref(); // step2中用户扫码的物料数据 +const totalValue = ref(0); // 传给扫码页面的合计数值 +const conformData = ref>([]); // step3中的待确认数据 +const loading = ref(false); // 提交按钮的loading状态 const items = [{ title: '录入申请' }, { title: '扫码点货' }, { title: '人工确认' }] - +/** + * 点击下一步 + */ const nextStep = () => { - if (applyFormRef.value) { + + if (applyFormRef.value && current.value === 0) { // 再step1中点击下一步的时候,就去获取step1中的表单数据 selectData.value = applyFormRef.value.getTableData(); + selectData.value.forEach((item) => { + if (item.assignRule === 1) { + totalValue.value += item.quantity + } + }) } + if (scanFormRef.value && current.value === 1) { // 再step2中点击下一步的时候,就去获取step2中的表单数据 + const items = scanFormRef.value.getTableData(); + const groupedSums = items.reduce((acc, item) => { + if (!acc[item.code]) { + acc[item.code] = 0; + } + acc[item.code]++; + return acc; + }, {}); + scanData.value = items + // 组装步骤三的原始数据 + conformData.value = selectData.value.map(item => { + return { + id: item.id, + name: item.name, + code: item.code, + applyNum: item.quantity, + scan: item.assignRule, + scanNum: groupedSums[item.code] || 0, + remark: item.quantity != groupedSums[item.code] ? `实际扫码数量与申请数量不一致` : '', + } + }); + } + // 切换到下一步 current.value++ } +/** + * 提交申请 + */ +const submit = () => { + loading.value = true; + // 提交申请 + console.log('提交申请') + // 获取用户最终确认的数据 + const applyDetails = applyConfirmRef.value.getTableData(); // 申请明细数据 + const applyForm = applyFormRef.value.getApplyForm(); // 申请表单数据 + + api.materialApi.apply.saveOrUpdateApply({ applyForm: applyForm, applyDetails: applyDetails }, () => { + console.log('申请成功') + // 清理缓存数据 + loading.value = false; + current.value = 3; + }); +} + +