x
This commit is contained in:
+1
-67
@@ -2503,22 +2503,6 @@ const InventoryView = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const editProductBom = async (product) => {
|
|
||||||
try {
|
|
||||||
await loadMaterials();
|
|
||||||
const bom = await apiRequest(`/api/products/${product.id}/materials`);
|
|
||||||
state.modalType = 'productBom';
|
|
||||||
state.editingItem = product;
|
|
||||||
state.productBomItems = (bom.items || []).map(item => ({
|
|
||||||
material_id: item.material_id,
|
|
||||||
quantity: item.quantity
|
|
||||||
}));
|
|
||||||
state.showModal = true;
|
|
||||||
} catch (e) {
|
|
||||||
handleApiError(e, '加载产品 BOM');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const addBomItem = () => {
|
const addBomItem = () => {
|
||||||
state.productBomItems.push({
|
state.productBomItems.push({
|
||||||
material_id: state.materials[0]?.id || null,
|
material_id: state.materials[0]?.id || null,
|
||||||
@@ -2530,20 +2514,6 @@ const InventoryView = {
|
|||||||
state.productBomItems.splice(idx, 1);
|
state.productBomItems.splice(idx, 1);
|
||||||
};
|
};
|
||||||
|
|
||||||
const saveProductBom = async () => {
|
|
||||||
try {
|
|
||||||
await apiRequest(`/api/products/${state.editingItem.id}/materials`, {
|
|
||||||
method: 'PUT',
|
|
||||||
body: JSON.stringify({ items: state.productBomItems })
|
|
||||||
});
|
|
||||||
addNotification('产品BOM保存成功', 'success');
|
|
||||||
closeModal();
|
|
||||||
loadProducts();
|
|
||||||
} catch (e) {
|
|
||||||
handleApiError(e, '保存产品BOM');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const saveSupplier = async () => {
|
const saveSupplier = async () => {
|
||||||
try {
|
try {
|
||||||
if (state.editingItem) {
|
if (state.editingItem) {
|
||||||
@@ -2966,10 +2936,8 @@ const InventoryView = {
|
|||||||
openDateTimePicker,
|
openDateTimePicker,
|
||||||
saveProduct,
|
saveProduct,
|
||||||
deleteProduct,
|
deleteProduct,
|
||||||
editProductBom,
|
|
||||||
addBomItem,
|
addBomItem,
|
||||||
removeBomItem,
|
removeBomItem,
|
||||||
saveProductBom,
|
|
||||||
saveSupplier,
|
saveSupplier,
|
||||||
deleteSupplier,
|
deleteSupplier,
|
||||||
saveCustomer,
|
saveCustomer,
|
||||||
@@ -3631,7 +3599,7 @@ const InventoryView = {
|
|||||||
<div v-if="state.showModal" class="modal-overlay" @click.self="closeModal">
|
<div v-if="state.showModal" class="modal-overlay" @click.self="closeModal">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
<div class="modal-header">
|
<div class="modal-header">
|
||||||
<h3>{{ state.editingItem ? '编辑' : '新增' }}{{ state.modalType === 'product' ? (state.form.item_type === 'finished' ? '成品' : '物料') : state.modalType === 'productBom' ? '产品物料' : state.modalType === 'inventoryItem' ? '物料库存' : state.modalType === 'salesOrder' ? '销售订单' : state.modalType === 'purchaseOrder' ? '采购订单' : state.modalType === 'purchaseReceive' ? '采购到货入库' : state.modalType === 'supplier' ? '供应商' : '客户' }}</h3>
|
<h3>{{ (state.editingItem ? '编辑' : '新增') + (state.modalType === 'product' ? (state.form.item_type === 'finished' ? '成品' : '物料') : state.modalType === 'inventoryItem' ? '物料库存' : state.modalType === 'salesOrder' ? '销售订单' : state.modalType === 'purchaseOrder' ? '采购订单' : state.modalType === 'purchaseReceive' ? '采购到货入库' : state.modalType === 'supplier' ? '供应商' : '客户') }}</h3>
|
||||||
<button class="modal-close" @click="closeModal">×</button>
|
<button class="modal-close" @click="closeModal">×</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
@@ -3956,40 +3924,6 @@ const InventoryView = {
|
|||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<form v-else-if="state.modalType === 'productBom'" @submit.prevent="saveProductBom">
|
|
||||||
<div class="table-header" style="margin-bottom: 12px;">
|
|
||||||
<button type="button" class="btn btn-secondary" @click="addBomItem">+ 添加物料</button>
|
|
||||||
</div>
|
|
||||||
<div class="table-container">
|
|
||||||
<table class="data-table">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>物料</th>
|
|
||||||
<th>数量</th>
|
|
||||||
<th>操作</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<tr v-for="(item, idx) in state.productBomItems" :key="'bom-item-' + idx">
|
|
||||||
<td>
|
|
||||||
<select v-model.number="item.material_id" class="form-input" required>
|
|
||||||
<option v-for="material in state.materials" :key="'bom-material-' + material.id" :value="material.id">
|
|
||||||
{{ material.sku }} - {{ material.name }}
|
|
||||||
</option>
|
|
||||||
</select>
|
|
||||||
</td>
|
|
||||||
<td><input v-model.number="item.quantity" type="number" min="0.0001" step="0.0001" class="form-input" required /></td>
|
|
||||||
<td><button type="button" class="btn btn-sm btn-danger" @click="removeBomItem(idx)">删除</button></td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
<div class="modal-footer">
|
|
||||||
<button type="button" class="btn btn-secondary" @click="closeModal">取消</button>
|
|
||||||
<button type="submit" class="btn btn-primary">保存BOM</button>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
|
|
||||||
<!-- 供应商表单 -->
|
<!-- 供应商表单 -->
|
||||||
<form v-else-if="state.modalType === 'supplier'" @submit.prevent="saveSupplier">
|
<form v-else-if="state.modalType === 'supplier'" @submit.prevent="saveSupplier">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
|
|||||||
Reference in New Issue
Block a user