| ¶Ô±ÈÐÂÎļþ |
| | |
| | | <template> |
| | | <el-dialog v-model="dialogVisible" |
| | | title="è¡¥æ" |
| | | width="1200px" |
| | | @close="handleClose"> |
| | | <el-table v-loading="loading" |
| | | :data="tableData" |
| | | border |
| | | row-key="id"> |
| | | <el-table-column label="å·¥åºåç§°" |
| | | prop="operationName" |
| | | min-width="140" /> |
| | | <el-table-column label="åæåç§°" |
| | | prop="productName" |
| | | min-width="140" /> |
| | | <el-table-column label="åæåå·" |
| | | prop="model" |
| | | min-width="140" /> |
| | | <el-table-column label="计éåä½" |
| | | prop="unit" |
| | | width="100" /> |
| | | <el-table-column label="éæ±æ°é" |
| | | prop="demandedQuantity" |
| | | width="100" /> |
| | | <el-table-column label="é¢ç¨æ°é" |
| | | prop="pickQuantity" |
| | | width="100" /> |
| | | <el-table-column label="已补æ°é" |
| | | prop="feedingQty" |
| | | width="100" /> |
| | | <el-table-column label="è¡¥ææ°é" |
| | | min-width="150"> |
| | | <template #default="{ row }"> |
| | | <el-input-number v-model="row.newSupplementQty" |
| | | :min="0" |
| | | :precision="3" |
| | | :step="1" |
| | | controls-position="right" |
| | | placeholder="è¾å
¥è¡¥ææ°é" |
| | | style="width: 100%;" /> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="è¡¥æåå " |
| | | min-width="200"> |
| | | <template #default="{ row }"> |
| | | <el-input v-model="row.newSupplementReason" |
| | | placeholder="è¾å
¥è¡¥æåå " |
| | | maxlength="200" |
| | | show-word-limit /> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | <template #footer> |
| | | <span class="dialog-footer"> |
| | | <el-button type="primary" |
| | | :loading="submitting" |
| | | @click="handleSubmit">ç¡® å®</el-button> |
| | | <el-button @click="dialogVisible = false">å æ¶</el-button> |
| | | </span> |
| | | </template> |
| | | </el-dialog> |
| | | </template> |
| | | |
| | | <script setup> |
| | | import { computed, ref, watch } from "vue"; |
| | | import { ElMessage } from "element-plus"; |
| | | import { |
| | | listMaterialPickingDetail, |
| | | updateMaterialPickingLedger, |
| | | } from "@/api/productionManagement/productionOrder.js"; |
| | | |
| | | const props = defineProps({ |
| | | modelValue: { type: Boolean, default: false }, |
| | | orderRow: { type: Object, default: null }, |
| | | }); |
| | | const emit = defineEmits(["update:modelValue", "saved"]); |
| | | |
| | | const dialogVisible = computed({ |
| | | get: () => props.modelValue, |
| | | set: val => emit("update:modelValue", val), |
| | | }); |
| | | |
| | | const loading = ref(false); |
| | | const submitting = ref(false); |
| | | const tableData = ref([]); |
| | | |
| | | const loadData = async () => { |
| | | if (!props.orderRow?.id) return; |
| | | loading.value = true; |
| | | try { |
| | | const res = await listMaterialPickingDetail(props.orderRow.id); |
| | | tableData.value = (res.data || []).map(item => ({ |
| | | ...item, |
| | | newSupplementQty: 0, |
| | | newSupplementReason: "", |
| | | })); |
| | | } catch (e) { |
| | | console.error("è·åç©ææç»å¤±è´¥ï¼", e); |
| | | ElMessage.error("è·åç©ææç»å¤±è´¥"); |
| | | } finally { |
| | | loading.value = false; |
| | | } |
| | | }; |
| | | |
| | | watch( |
| | | () => dialogVisible.value, |
| | | visible => { |
| | | if (visible) { |
| | | loadData(); |
| | | } |
| | | } |
| | | ); |
| | | |
| | | const handleClose = () => { |
| | | tableData.value = []; |
| | | }; |
| | | |
| | | const handleSubmit = async () => { |
| | | const supplementList = tableData.value.filter( |
| | | item => item.newSupplementQty > 0 |
| | | ); |
| | | if (supplementList.length === 0) { |
| | | ElMessage.warning("请è³å°è¾å
¥ä¸æ¡è¡¥ææ°é"); |
| | | return; |
| | | } |
| | | |
| | | const invalidRow = supplementList.find(item => !item.newSupplementReason); |
| | | if (invalidRow) { |
| | | ElMessage.warning("请è¾å
¥è¡¥æåå "); |
| | | return; |
| | | } |
| | | |
| | | submitting.value = true; |
| | | try { |
| | | await updateMaterialPickingLedger({ |
| | | productionOrderId: props.orderRow.id, |
| | | productionOrderPickDto: tableData.value.map(item => ({ |
| | | id: item.id, |
| | | technologyOperationId: item.technologyOperationId, |
| | | operationName: item.operationName, |
| | | bom: item.bom === true, |
| | | productModelId: item.productModelId, |
| | | demandedQuantity: item.demandedQuantity, |
| | | unit: item.unit, |
| | | pickQuantity: item.pickQuantity, |
| | | batchNo: item.batchNo, |
| | | feedingQuantity: item.newSupplementQty || 0, |
| | | feedingReason: item.newSupplementReason || "", |
| | | pickType: 2, |
| | | })), |
| | | }); |
| | | ElMessage.success("è¡¥ææå"); |
| | | dialogVisible.value = false; |
| | | emit("saved"); |
| | | } catch (e) { |
| | | console.error("è¡¥æå¤±è´¥ï¼", e); |
| | | ElMessage.error("è¡¥æå¤±è´¥"); |
| | | } finally { |
| | | submitting.value = false; |
| | | } |
| | | }; |
| | | </script> |
| | | |
| | | <style scoped lang="scss"> |
| | | </style> |