| | |
| | | :on-success="handleDrawingUploadSuccess" |
| | | :on-remove="handleDrawingRemove" |
| | | :before-upload="handleDrawingBeforeUpload" |
| | | :limit="1" |
| | | :limit="5" |
| | | accept=".pdf,.jpg,.jpeg,.png,.dwg" |
| | | list-type="picture-card" |
| | | > |
| | |
| | | // 处理图纸文件反显 |
| | | if (data.salesLedgerFiles && data.salesLedgerFiles.length > 0) { |
| | | drawingFileList.value = data.salesLedgerFiles.map(file => ({ |
| | | id: file.id, // 带上id用于删除时调用接口 |
| | | name: file.name, |
| | | url: file.url |
| | | })); |
| | |
| | | console.log('上传成功响应', response); |
| | | console.log('response.data', response.data); |
| | | if (response.code === 200) { |
| | | modelForm.value.tempFileIds = [response.data?.tempId]; |
| | | modelForm.value.salesLedgerFiles = [{ |
| | | // 支持多文件,追加到数组 |
| | | modelForm.value.tempFileIds.push(response.data?.tempId); |
| | | modelForm.value.salesLedgerFiles.push({ |
| | | tempId: response.data?.tempId, |
| | | originalName: response.data?.originalName || file.name, |
| | | tempPath: response.data?.tempPath, |
| | | type: response.data?.type || 13 |
| | | }]; |
| | | }); |
| | | proxy.$modal.msgSuccess("上传成功"); |
| | | } else { |
| | | proxy.$modal.msgError(response.msg || "上传失败"); |
| | |
| | | }; |
| | | |
| | | const handleDrawingRemove = (file) => { |
| | | modelForm.value.tempFileIds = []; |
| | | modelForm.value.salesLedgerFiles = []; |
| | | // 如果是编辑模式下已存在的文件(带有id),调用删除接口 |
| | | if (file.id) { |
| | | delLedgerFile({ id: file.id }).then(res => { |
| | | if (res.code === 200) { |
| | | proxy.$modal.msgSuccess("删除成功"); |
| | | } |
| | | }).catch(err => { |
| | | console.error("删除文件失败:", err); |
| | | }); |
| | | } |
| | | // 从数组中移除对应的文件 |
| | | const index = modelForm.value.salesLedgerFiles.findIndex(item => |
| | | item.tempId === file.response?.data?.tempId || item.tempId === file.tempId |
| | | ); |
| | | if (index > -1) { |
| | | modelForm.value.tempFileIds.splice(index, 1); |
| | | modelForm.value.salesLedgerFiles.splice(index, 1); |
| | | } |
| | | }; |
| | | |
| | | onMounted(() => { |
| | |
| | | :loading="bindRouteLoading"> |
| | | <el-option v-for="item in routeOptions" |
| | | :key="item.id" |
| | | :label="`${item.processRouteCode || ''}`" |
| | | :label="item.processRouteName" |
| | | :value="item.id" /> |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-form> |
| | | <template #footer> |
| | | <span class="dialog-footer"> |
| | | <el-button type="primary" :loading="bindRouteSaving" @click="handleBindRouteConfirm">确 认</el-button> |
| | | <el-button @click="bindRouteDialogVisible = false">取 消</el-button> |
| | | <el-button type="primary" |
| | | :loading="bindRouteSaving" |
| | | @click="handleBindRouteConfirm">确 认</el-button> |
| | | </span> |
| | | </template> |
| | | </el-dialog> |
| | |
| | | import dayjs from "dayjs"; |
| | | import { useRouter } from "vue-router"; |
| | | import { |
| | | productOrderListPage, |
| | | listProcessRoute, |
| | | bindingRoute, |
| | | listProcessBom, delProductOrder, startOrPause, |
| | | } from "@/api/productionManagement/productionOrder.js"; |
| | | productOrderListPage, |
| | | bindingRoute, |
| | | listProcessBom, delProductOrder, startOrPause, |
| | | } from "@/api/productionManagement/productionOrder.js"; |
| | | import { listPage as getProcessRouteList } from "@/api/productionManagement/processRoute.js"; |
| | | import { listMain as getOrderProcessRouteMain } from "@/api/productionManagement/productProcessRoute.js"; |
| | | import { productionProductInputListPage } from "@/api/productionManagement/productionProductInput.js"; |
| | | import { listPage as listProductStructureRecord, pick as pickMaterial } from "@/api/productionManagement/productStructureRecord.js"; |
| | |
| | | showRouteItemModal(row); |
| | | }, |
| | | }, |
| | | { |
| | | name: "绑定工艺路线", |
| | | type: "text", |
| | | showHide: row => !row.processRouteCode, |
| | | clickFun: row => { |
| | | openBindRouteDialog(row); |
| | | }, |
| | | }, |
| | | // { |
| | | // name: "绑定工艺路线", |
| | | // type: "text", |
| | | // showHide: row => !row.processRouteCode, |
| | | // clickFun: row => { |
| | | // openBindRouteDialog(row); |
| | | // }, |
| | | // }, |
| | | { |
| | | name: "物料清单", |
| | | type: "text", |
| | |
| | | bindForm.routeId = null; |
| | | bindRouteDialogVisible.value = true; |
| | | routeOptions.value = []; |
| | | if (!row.productModelId) { |
| | | proxy.$modal.msgWarning("当前订单缺少产品型号,无法查询工艺路线"); |
| | | bindRouteDialogVisible.value = false; |
| | | return; |
| | | } |
| | | bindRouteLoading.value = true; |
| | | try { |
| | | const res = await listProcessRoute({ productModelId: row.productModelId }); |
| | | routeOptions.value = res.data || []; |
| | | const res = await getProcessRouteList({ current: -1, size: -1 }); |
| | | routeOptions.value = res.data?.records || []; |
| | | } catch (e) { |
| | | console.error("获取工艺路线列表失败:", e); |
| | | proxy.$modal.msgError("获取工艺路线列表失败"); |
| | |
| | | </div> |
| | | <PIMTable :isShowPagination="false" rowKey="id" :column="tableColumn" :tableData="tableData"> |
| | | <template #unQuantity="{ row }"> |
| | | {{ calcAlreadyReturned(row) }} |
| | | {{ row.unQuantity ?? 0 }} |
| | | </template> |
| | | <template #returnQuantity="{ row }"> |
| | | <el-input |
| | |
| | | const { form, rules } = toRefs(data); |
| | | |
| | | const calcAlreadyReturned = (row) => { |
| | | // 如果 row.unQuantity 已经有值(从后端获取的未退货数量),直接返回 |
| | | // 如果 row.unQuantity 已经有值(从后端获取的未退货数量),计算已退货数量 |
| | | if (row?.unQuantity !== undefined && row?.unQuantity !== null) { |
| | | return Number(row.unQuantity); |
| | | } |
| | | const total = Number(row?.shippingNum ?? row?.totalQuantity ?? 0); |
| | | const unQuantity = Number(row.unQuantity); |
| | | if (!Number.isFinite(total) || !Number.isFinite(unQuantity)) return 0; |
| | | return total - unQuantity; |
| | | }; |
| | | // 否则根据总数量和已退货数量计算 |
| | | const total = Number(row?.shippingNum ?? row?.totalQuantity ?? 0); |
| | | const returned = Number(row?.returnNum ?? 0); |
| | | if (!Number.isFinite(total) || !Number.isFinite(returned)) return 0; |
| | | return total - returned; |
| | | return returned; |
| | | }; |
| | | |
| | | const tableColumn = ref([ |
| | |
| | | await setFormForEdit(row); |
| | | } else { |
| | | tableData.value = []; |
| | | // 先清空 form 的所有属性,避免保留之前编辑的 id |
| | | Object.keys(form.value).forEach(key => { |
| | | form.value[key] = undefined; |
| | | }); |
| | | Object.assign(form.value, { |
| | | returnNoCheckbox: true, |
| | | returnNo: "", |
| | |
| | | const submitForm = () => { |
| | | proxy.$refs["formRef"].validate(valid => { |
| | | if (!valid) return; |
| | | |
| | | // 校验是否有产品数据 |
| | | if (!tableData.value || tableData.value.length === 0) { |
| | | proxy.$modal.msgWarning("请添加退货产品"); |
| | | return; |
| | | } |
| | | |
| | | // 校验未退货数量为0的产品 |
| | | const zeroUnQuantityProducts = tableData.value.filter(row => { |
| | | const unQuantity = Number(row.unQuantity ?? 0); |
| | | return unQuantity <= 0; |
| | | }); |
| | | if (zeroUnQuantityProducts.length > 0) { |
| | | const productNames = zeroUnQuantityProducts.map(p => p.productCategory || p.specificationModel || '未知产品').join('、'); |
| | | proxy.$modal.msgWarning(`以下产品未退货数量为0,无法退货:${productNames}`); |
| | | return; |
| | | } |
| | | |
| | | // 校验退货数量必须大于0 |
| | | const zeroReturnProducts = tableData.value.filter(row => { |
| | | const returnQty = Number(row.returnQuantity ?? 0); |
| | | return returnQty <= 0; |
| | | }); |
| | | if (zeroReturnProducts.length > 0) { |
| | | const productNames = zeroReturnProducts.map(p => p.productCategory || p.specificationModel || '未知产品').join('、'); |
| | | proxy.$modal.msgWarning(`以下产品退货数量必须大于0:${productNames}`); |
| | | return; |
| | | } |
| | | |
| | | const returnSaleProducts = (tableData.value || []).map(el => ({ |
| | | returnSaleLedgerProductId: el.returnSaleLedgerProductId ?? el.id, |
| | | productModelId: el.productModelId, |