| | |
| | | @close="handleClose"> |
| | | <div class="material-toolbar"> |
| | | <el-button type="primary" |
| | | plain |
| | | @click="handleAddPurchase">新增采购</el-button> |
| | | <el-button type="primary" |
| | | @click="handleAddMaterialRow">新增</el-button> |
| | | </div> |
| | | <el-table v-loading="materialTableLoading" |
| | | :data="materialTableData" |
| | | border |
| | | @selection-change="handleMaterialSelectionChange" |
| | | row-key="tempId"> |
| | | <el-table-column align="center" |
| | | type="selection" |
| | | width="55" /> |
| | | <el-table-column label="工序名称" |
| | | min-width="100"> |
| | | <template #default="{ row }"> |
| | |
| | | <ProductSelectDialog v-model="materialProductDialogVisible" |
| | | @confirm="handleMaterialProductConfirm" |
| | | single /> |
| | | <PurchaseLedgerAddDialog ref="purchaseLedgerAddDialogRef" |
| | | v-model="purchaseLedgerDialogVisible" /> |
| | | <!-- request-url="/stockInventory/rawMaterials" --> |
| | | </div> |
| | | </template> |
| | |
| | | import { computed, ref, watch } from "vue"; |
| | | import { ElMessage } from "element-plus"; |
| | | import ProductSelectDialog from "@/views/basicData/product/ProductSelectDialog.vue"; |
| | | import PurchaseLedgerAddDialog from "./PurchaseLedgerAddDialog.vue"; |
| | | import { findProductProcessRouteItemList } from "@/api/productionManagement/productProcessRoute.js"; |
| | | import { getStockInventoryByModelId } from "@/api/inventoryManagement/stockInventory.js"; |
| | | import { |
| | |
| | | const materialTableLoading = ref(false); |
| | | const materialSaving = ref(false); |
| | | const materialTableData = ref([]); |
| | | const selectedMaterialRows = ref([]); |
| | | const purchaseLedgerDialogVisible = ref(false); |
| | | const purchaseLedgerAddDialogRef = ref(null); |
| | | |
| | | const isSaveDisabled = computed(() => { |
| | | if (materialTableLoading.value) return true; |
| | |
| | | |
| | | const handleClose = () => { |
| | | materialTableData.value = []; |
| | | selectedMaterialRows.value = []; |
| | | currentMaterialSelectRowIndex.value = -1; |
| | | }; |
| | | |
| | |
| | | materialTableData.value.push(createMaterialRow()); |
| | | }; |
| | | |
| | | const handleMaterialSelectionChange = selection => { |
| | | selectedMaterialRows.value = selection; |
| | | }; |
| | | |
| | | const handleAddPurchase = () => { |
| | | if (selectedMaterialRows.value.length === 0) { |
| | | ElMessage.warning("请选择需要新增采购的原料行"); |
| | | return; |
| | | } |
| | | const rowsWithModel = selectedMaterialRows.value.filter( |
| | | row => row.materialModelId |
| | | ); |
| | | if (rowsWithModel.length === 0) { |
| | | ElMessage.warning("所选行缺少原料型号,请先选择原料后再新增采购"); |
| | | return; |
| | | } |
| | | const productRows = rowsWithModel.map(row => ({ |
| | | productModelId: row.materialModelId, |
| | | productCategory: row.materialName, |
| | | specificationModel: row.materialModel, |
| | | unit: row.unit, |
| | | isChecked: false, |
| | | })); |
| | | purchaseLedgerAddDialogRef.value?.open(productRows); |
| | | }; |
| | | |
| | | const handleDeleteMaterialRow = index => { |
| | | materialTableData.value.splice(index, 1); |
| | | }; |