| | |
| | | <el-input v-model="formState.unit" |
| | | disabled /> |
| | | </el-form-item> |
| | | <el-form-item label="厂家" |
| | | prop="manufacturerId"> |
| | | <el-form-item v-if="shouldSelectSupplier" |
| | | label="供应商" |
| | | prop="supplierId" |
| | | :rules="[ |
| | | { |
| | | required: true, |
| | | message: '请选择供应商', |
| | | trigger: 'change', |
| | | } |
| | | ]"> |
| | | <el-select v-model="formState.supplierId" |
| | | placeholder="请选择供应商" |
| | | clearable |
| | | filterable |
| | | style="width: 100%"> |
| | | <el-option v-for="item in supplierOptions" |
| | | :key="item.value ?? item.id ?? item.supplierId" |
| | | :label="item.label ?? item.supplierName ?? item.name" |
| | | :value="item.value ?? item.id ?? item.supplierId" /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item v-if="shouldSelectManufacturer" |
| | | label="厂家" |
| | | prop="manufacturerId" |
| | | :rules="[ |
| | | { |
| | | required: true, |
| | | message: '请选择厂家', |
| | | trigger: 'change', |
| | | } |
| | | ]"> |
| | | <el-select v-model="formState.manufacturerId" |
| | | placeholder="请选择厂家" |
| | | clearable |
| | |
| | | </template> |
| | | |
| | | <script setup> |
| | | import { ref, computed, watch, getCurrentInstance, onMounted } from "vue"; |
| | | import { ref, computed, watch, getCurrentInstance } from "vue"; |
| | | import ProductSelectDialog from "@/views/basicData/product/ProductSelectDialog.vue"; |
| | | import { addStockInRecordOnly } from "@/api/inventoryManagement/stockInventory.js"; |
| | | import { createStockUnInventory } from "@/api/inventoryManagement/stockUninventory.js"; |
| | | import { getManufacturerOptions } from "@/api/inspectionManagement/manufacturerManageFile.js"; |
| | | import { getOptions as getSupplierOptions } from "@/api/procurementManagement/procurementLedger.js"; |
| | | |
| | | const props = defineProps({ |
| | | visible: { |
| | |
| | | unit: "", |
| | | type: undefined, |
| | | manufacturerId: "", |
| | | supplierId: "", |
| | | source: "", |
| | | qualitity: 0, |
| | | batchNo: null, |
| | |
| | | |
| | | const handleTypeChange = val => { |
| | | formState.value.source = ""; |
| | | formState.value.manufacturerId = ""; |
| | | formState.value.supplierId = ""; |
| | | }; |
| | | |
| | | const isShow = computed({ |
| | |
| | | |
| | | const showProductSelectDialog = ref(false); |
| | | const manufacturerOptions = ref([]); |
| | | const supplierOptions = ref([]); |
| | | |
| | | const shouldSelectSupplier = computed(() => { |
| | | return ( |
| | | formState.value.type === "qualified" && |
| | | formState.value.source === "purchaseReceipt" |
| | | ); |
| | | }); |
| | | |
| | | const shouldSelectManufacturer = computed(() => { |
| | | return ( |
| | | formState.value.type === "qualified" && |
| | | formState.value.source === "outsourcedReceipt" |
| | | ); |
| | | }); |
| | | |
| | | const loadManufacturerOptions = () => { |
| | | getManufacturerOptions().then(res => { |
| | |
| | | }); |
| | | }; |
| | | |
| | | onMounted(() => { |
| | | loadManufacturerOptions(); |
| | | }); |
| | | const loadSupplierOptions = () => { |
| | | getSupplierOptions({}) |
| | | .then(res => { |
| | | const raw = res?.data; |
| | | if (Array.isArray(raw)) { |
| | | supplierOptions.value = raw; |
| | | return; |
| | | } |
| | | supplierOptions.value = raw?.records || raw?.list || []; |
| | | }) |
| | | .catch(() => { |
| | | supplierOptions.value = []; |
| | | }); |
| | | }; |
| | | |
| | | watch( |
| | | () => shouldSelectManufacturer.value, |
| | | val => { |
| | | if (val && manufacturerOptions.value.length === 0) { |
| | | loadManufacturerOptions(); |
| | | } |
| | | }, |
| | | { immediate: true } |
| | | ); |
| | | |
| | | watch( |
| | | () => shouldSelectSupplier.value, |
| | | val => { |
| | | if (val && supplierOptions.value.length === 0) { |
| | | loadSupplierOptions(); |
| | | } |
| | | }, |
| | | { immediate: true } |
| | | ); |
| | | |
| | | watch( |
| | | () => formState.value.source, |
| | | () => { |
| | | formState.value.manufacturerId = ""; |
| | | formState.value.supplierId = ""; |
| | | } |
| | | ); |
| | | |
| | | // 批号为空时转为 null |
| | | watch( |
| | |
| | | unit: "", |
| | | type: undefined, |
| | | manufacturerId: "", |
| | | supplierId: "", |
| | | source: "", |
| | | qualitity: 0, |
| | | batchNo: null, |