| | |
| | | <template> |
| | | <div> |
| | | <el-dialog v-model="dialogVisible" title="领料台账" width="1200px" @close="handleClose"> |
| | | <el-dialog v-model="dialogVisible" |
| | | title="领料台账" |
| | | width="1200px" |
| | | @close="handleClose"> |
| | | <div class="material-toolbar"> |
| | | <el-button type="primary" @click="handleAddMaterialRow">新增</el-button> |
| | | <el-button type="primary" |
| | | @click="handleAddMaterialRow">新增</el-button> |
| | | </div> |
| | | <el-table v-loading="materialTableLoading" :data="materialTableData" border row-key="tempId"> |
| | | <el-table-column label="工序名称" min-width="180"> |
| | | <el-table v-loading="materialTableLoading" |
| | | :data="materialTableData" |
| | | border |
| | | row-key="tempId"> |
| | | <el-table-column label="工序名称" |
| | | min-width="180"> |
| | | <template #default="{ row }"> |
| | | <span v-if="row.bom === true">{{ row.processName || "-" }}</span> |
| | | <el-select |
| | | v-else |
| | | <el-select v-else |
| | | v-model="row.processName" |
| | | placeholder="请选择工序" |
| | | clearable |
| | | filterable |
| | | style="width: 100%;" |
| | | @change="val => handleProcessNameChange(row, val)" |
| | | > |
| | | <el-option v-for="item in processOptions" :key="item.id" :label="item.name" :value="item.name" /> |
| | | @change="val => handleProcessNameChange(row, val)"> |
| | | <el-option v-for="item in processOptions" |
| | | :key="item.id" |
| | | :label="item.name" |
| | | :value="item.name" /> |
| | | </el-select> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="原料名称" min-width="160"> |
| | | <el-table-column label="原料名称" |
| | | min-width="160"> |
| | | <template #default="{ row }"> |
| | | <span v-if="row.bom === true">{{ row.materialName || "-" }}</span> |
| | | <el-button v-else type="primary" link @click="openMaterialProductSelect(row)"> |
| | | <el-button v-else |
| | | type="primary" |
| | | link |
| | | @click="openMaterialProductSelect(row)"> |
| | | {{ row.materialName || "选择原料" }} |
| | | </el-button> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="原料型号" min-width="180"> |
| | | <el-table-column label="原料型号" |
| | | min-width="180"> |
| | | <template #default="{ row }"> |
| | | {{ row.materialModel || "-" }} |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="需求数量" min-width="120"> |
| | | <el-table-column label="需求数量" |
| | | min-width="120"> |
| | | <template #default="{ row }"> |
| | | <span v-if="row.bom === true">{{ row.requiredQty ?? "-" }}</span> |
| | | <el-input-number |
| | | v-else |
| | | <el-input-number v-else |
| | | v-model="row.requiredQty" |
| | | :min="0" |
| | | :precision="3" |
| | | :step="1" |
| | | controls-position="right" |
| | | style="width: 100%;" |
| | | @change="val => handleRequiredQtyChange(row, val)" |
| | | /> |
| | | @change="val => handleRequiredQtyChange(row, val)" /> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="计量单位" width="120"> |
| | | <el-table-column label="计量单位" |
| | | width="120"> |
| | | <template #default="{ row }"> |
| | | {{ row.unit || "-" }} |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="领用数量" min-width="120"> |
| | | <el-table-column label="领用数量" |
| | | min-width="120"> |
| | | <template #default="{ row }"> |
| | | <el-input-number |
| | | v-model="row.pickQty" |
| | | <el-input-number v-model="row.pickQty" |
| | | :min="0" |
| | | :precision="3" |
| | | :step="1" |
| | | controls-position="right" |
| | | style="width: 100%;" |
| | | /> |
| | | style="width: 100%;" /> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="操作" width="90" fixed="right"> |
| | | <el-table-column label="操作" |
| | | width="90" |
| | | fixed="right"> |
| | | <template #default="{ $index, row }"> |
| | | <el-button v-if="row.bom !== true" type="danger" link @click="handleDeleteMaterialRow($index)">删除</el-button> |
| | | <el-button v-if="row.bom !== true" |
| | | type="danger" |
| | | link |
| | | @click="handleDeleteMaterialRow($index)">删除</el-button> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | <template #footer> |
| | | <span class="dialog-footer"> |
| | | <el-button type="primary" :loading="materialSaving" @click="handleMaterialSave">保存</el-button> |
| | | <el-button type="primary" |
| | | :loading="materialSaving" |
| | | @click="handleMaterialSave">保存</el-button> |
| | | <el-button @click="dialogVisible = false">取消</el-button> |
| | | </span> |
| | | </template> |
| | | </el-dialog> |
| | | |
| | | <ProductSelectDialog |
| | | v-model="materialProductDialogVisible" |
| | | <ProductSelectDialog v-model="materialProductDialogVisible" |
| | | @confirm="handleMaterialProductConfirm" |
| | | single |
| | | request-url="/stockInventory/rawMaterials" |
| | | /> |
| | | single /> |
| | | <!-- request-url="/stockInventory/rawMaterials" --> |
| | | </div> |
| | | </template> |
| | | |
| | |
| | | |
| | | const getProcessOptions = async () => { |
| | | if (!props.orderRow?.id) return; |
| | | const res = await findProductProcessRouteItemList({ orderId: props.orderRow.id }); |
| | | const routeList = Array.isArray(res?.data) ? res.data : res?.data?.records || []; |
| | | const res = await findProductProcessRouteItemList({ |
| | | orderId: props.orderRow.id, |
| | | }); |
| | | const routeList = Array.isArray(res?.data) |
| | | ? res.data |
| | | : res?.data?.records || []; |
| | | const processMap = new Map(); |
| | | routeList.forEach(item => { |
| | | const processId = item.processId; |
| | |
| | | materialTableData.value = []; |
| | | await getProcessOptions(); |
| | | try { |
| | | const detailRes = await listMaterialPickingDetail({ orderId: props.orderRow.id }); |
| | | const detailRes = await listMaterialPickingDetail({ |
| | | orderId: props.orderRow.id, |
| | | }); |
| | | const detailList = Array.isArray(detailRes?.data) |
| | | ? detailRes.data |
| | | : detailRes?.data?.records || []; |
| | |
| | | materialTableData.value = detailList.map(item => createMaterialRow(item)); |
| | | return; |
| | | } |
| | | const ledgerRes = await listMaterialPickingLedger({ orderId: props.orderRow.id }); |
| | | const ledgerRes = await listMaterialPickingLedger({ |
| | | orderId: props.orderRow.id, |
| | | }); |
| | | const ledgerList = Array.isArray(ledgerRes?.data) |
| | | ? ledgerRes.data |
| | | : ledgerRes?.data?.records || []; |
| | |
| | | }; |
| | | |
| | | const openMaterialProductSelect = row => { |
| | | currentMaterialSelectRowIndex.value = materialTableData.value.findIndex(item => item.tempId === row.tempId); |
| | | currentMaterialSelectRowIndex.value = materialTableData.value.findIndex( |
| | | item => item.tempId === row.tempId |
| | | ); |
| | | materialProductDialogVisible.value = true; |
| | | }; |
| | | |
| | |
| | | if (index < 0 || !materialTableData.value[index]) return; |
| | | const product = products[0]; |
| | | const row = materialTableData.value[index]; |
| | | row.materialModelId = product.materialModelId || product.modelId || product.id; |
| | | row.materialName = product.materialName || product.productName || product.name || ""; |
| | | row.materialModelId = |
| | | product.materialModelId || product.modelId || product.id; |
| | | row.materialName = |
| | | product.materialName || product.productName || product.name || ""; |
| | | row.materialModel = product.materialModel || product.model || ""; |
| | | row.unit = product.unit || product.measureUnit || ""; |
| | | currentMaterialSelectRowIndex.value = -1; |