|
|
|
|
@ -12,14 +12,27 @@
|
|
|
|
|
<el-table-column label="产品" min-width="150">
|
|
|
|
|
<template #default="{ row, $index }">
|
|
|
|
|
<el-form-item :prop="`${$index}.productId`" :rules="formRules.productId" class="mb-0px!">
|
|
|
|
|
<el-input v-model="row.productId" placeholder="请输入产品ID" />
|
|
|
|
|
<el-select
|
|
|
|
|
v-model="row.productId"
|
|
|
|
|
clearable
|
|
|
|
|
filterable
|
|
|
|
|
@change="onChangeProduct($event, row)"
|
|
|
|
|
placeholder="请选择产品"
|
|
|
|
|
>
|
|
|
|
|
<el-option
|
|
|
|
|
v-for="item in productList"
|
|
|
|
|
:key="item.id"
|
|
|
|
|
:label="item.name"
|
|
|
|
|
:value="item.id"
|
|
|
|
|
/>
|
|
|
|
|
</el-select>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
|
|
|
|
<el-table-column label="单位" min-width="150">
|
|
|
|
|
<template #default="{ row, $index }">
|
|
|
|
|
<el-form-item :prop="`${$index}.unitId`" :rules="formRules.unitId" class="mb-0px!">
|
|
|
|
|
<el-select v-model="row.unitId" clearable placeholder="请选择单位" class="w-1/1">
|
|
|
|
|
<el-select v-model="row.unitId" clearable filterable placeholder="请选择单位" class="w-1/1">
|
|
|
|
|
<el-option
|
|
|
|
|
v-for="unit in unitList"
|
|
|
|
|
:key="unit.id"
|
|
|
|
|
@ -67,8 +80,10 @@
|
|
|
|
|
|
|
|
|
|
import { BomApi } from '@/api/mes/bom'
|
|
|
|
|
import { ProductUnitApi, ProductUnitVO } from '@/api/erp/product/unit'
|
|
|
|
|
const unitList = ref<ProductUnitVO[]>([]) // 产品单位列表
|
|
|
|
|
import {ProductApi, ProductVO} from "@/api/erp/product/product";
|
|
|
|
|
|
|
|
|
|
const unitList = ref<ProductUnitVO[]>([]) // 产品单位列表
|
|
|
|
|
const productList = ref<ProductVO[]>([]) // 产品列表
|
|
|
|
|
const props = defineProps<{
|
|
|
|
|
bomId: undefined // BOM ID(主表的关联字段)
|
|
|
|
|
}>()
|
|
|
|
|
@ -81,6 +96,17 @@ const formRules = reactive({
|
|
|
|
|
})
|
|
|
|
|
const formRef = ref() // 表单 Ref
|
|
|
|
|
|
|
|
|
|
/** 初始化 */
|
|
|
|
|
onMounted(async () => {
|
|
|
|
|
// 产品单位
|
|
|
|
|
unitList.value = await ProductUnitApi.getProductUnitSimpleList()
|
|
|
|
|
productList.value = await ProductApi.getProductSimpleList()
|
|
|
|
|
// 默认添加一个
|
|
|
|
|
if (formData.value.length === 0) {
|
|
|
|
|
handleAdd()
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
/** 监听主表的关联字段的变化,加载对应的子表数据 */
|
|
|
|
|
watch(
|
|
|
|
|
() => props.bomId,
|
|
|
|
|
@ -97,8 +123,6 @@ watch(
|
|
|
|
|
} finally {
|
|
|
|
|
formLoading.value = false
|
|
|
|
|
}
|
|
|
|
|
// 产品单位
|
|
|
|
|
unitList.value = await ProductUnitApi.getProductUnitSimpleList()
|
|
|
|
|
},
|
|
|
|
|
{ immediate: true }
|
|
|
|
|
|
|
|
|
|
@ -136,4 +160,14 @@ const getData = () => {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
defineExpose({ validate, getData })
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
/** 处理产品变更 */
|
|
|
|
|
const onChangeProduct = (productId, row) => {
|
|
|
|
|
const product = productList.value.find((item) => item.id === productId)
|
|
|
|
|
if (product) {
|
|
|
|
|
// row.productUnitName = product.unitName
|
|
|
|
|
}
|
|
|
|
|
// // 加载库存
|
|
|
|
|
// setStockCount(row)
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|