diff --git a/src/locales/en.ts b/src/locales/en.ts index 5193bb94..c8f429cc 100644 --- a/src/locales/en.ts +++ b/src/locales/en.ts @@ -562,6 +562,8 @@ export default { purchaseUnit: 'Purchase Unit', purchaseUnitConvertQuantity: 'Purchase Convert Qty', defaultSupplier: 'Supplier (Default)', + supplier: 'Supplier', + placeholderSupplier: 'Please select supplier', outboundPurpose: 'Outbound Purpose', outMode: 'Outbound Mode', outModeWholePallet: 'Whole Pallet', diff --git a/src/locales/zh-CN.ts b/src/locales/zh-CN.ts index 7e4e94ce..dfcf7e88 100644 --- a/src/locales/zh-CN.ts +++ b/src/locales/zh-CN.ts @@ -562,6 +562,8 @@ export default { purchaseUnit: '采购单位', purchaseUnitConvertQuantity: '采购换算数量', defaultSupplier: '供应商(默认)', + supplier: '供应商', + placeholderSupplier: '请选择供应商', outboundPurpose: '出库用途', outMode: '出库方式', outModeWholePallet: '整托出库', diff --git a/src/views/erp/stock/in/components/StockInItemForm.vue b/src/views/erp/stock/in/components/StockInItemForm.vue index 1fe22d22..1ddd4e28 100644 --- a/src/views/erp/stock/in/components/StockInItemForm.vue +++ b/src/views/erp/stock/in/components/StockInItemForm.vue @@ -118,10 +118,17 @@ - + @@ -228,9 +235,9 @@ - + @@ -245,6 +252,63 @@ + + + + + + + + + + + {{ t('common.query') }} + + {{ t('common.reset') }} + + + + + + + + + + + +
+ +
+ +
+
{{ t('ErpStock.Item.selectTaskOrder') }}
@@ -501,6 +565,7 @@ import { WarehouseAreaApi, WarehouseAreaVO } from '@/api/erp/stock/warehousearea import { StockApi } from '@/api/erp/stock/stock' import { TaskApi, TaskVO } from '@/api/mes/task' import { PalletApi, PalletVO } from '@/api/erp/stock/pallet' +import { SupplierApi } from '@/api/erp/purchase/supplier' import PalletForm from '../../pallet/PalletForm.vue' import { DICT_TYPE, getIntDictOptions } from '@/utils/dict' import { dateFormatter2 } from '@/utils/formatTime' @@ -557,6 +622,18 @@ const productQueryParams = reactive({ }) const currentSelectRow = ref() const selectedProductId = ref() +const supplierDialogVisible = ref(false) +const supplierDialogLoading = ref(false) +const supplierDialogList = ref([]) +const supplierDialogTotal = ref(0) +const supplierSearchFormRef = ref() +const selectedSupplierId = ref() +const supplierQueryParams = reactive({ + pageNo: 1, + pageSize: 10, + name: undefined, + mobile: undefined +}) const taskDialogVisible = ref(false) const taskDialogLoading = ref(false) const taskSchemeLoading = ref(false) @@ -709,6 +786,7 @@ const handleAdd = () => { productPrice: undefined, purchaseUnitId: undefined, purchaseUnitName: undefined, + supplierId: undefined, supplierName: undefined, purchaseUnitConvertQuantity: undefined, relateTask: false, @@ -807,7 +885,9 @@ const fillRowByProduct = (row: any, product: any) => { row.productName = product.name row.purchaseUnitId = product.purchaseUnitId row.purchaseUnitName = product.purchaseUnitName - row.supplierName = getDefaultSupplierName(product) + const supplier = getDefaultSupplier(product) + row.supplierId = supplier?.id + row.supplierName = supplier?.name row.purchaseUnitConvertQuantity = product.purchaseUnitConvertQuantity fillPackagingSchemeByProduct(row, product) normalizePackageCount(row) @@ -829,11 +909,21 @@ const fillPackagingSchemeByProduct = (row: any, product: any) => { row.palletTotalQuantity = scheme?.palletTotalQuantity } -const getDefaultSupplierName = (product: any) => { +const getDefaultSupplier = (product: any) => { if (!product) return undefined - if (product.supplierName) return product.supplierName + if (product.supplierId || product.supplierName) { + return { + id: product.supplierId, + name: product.supplierName + } + } const suppliers = Array.isArray(product.suppliers) ? product.suppliers : [] - return suppliers.find((item) => Number(item?.defaultStatus) === 1)?.supplierName + const supplier = suppliers.find((item) => Number(item?.defaultStatus) === 1) || suppliers[0] + if (!supplier) return undefined + return { + id: supplier.supplierId ?? supplier.id, + name: supplier.supplierName ?? supplier.name + } } const clearProduct = (row: any) => { @@ -845,6 +935,7 @@ const clearProduct = (row: any) => { row.productName = undefined row.purchaseUnitId = undefined row.purchaseUnitName = undefined + row.supplierId = undefined row.supplierName = undefined row.purchaseUnitConvertQuantity = undefined row.packagingSchemeRelationId = undefined @@ -916,6 +1007,60 @@ const confirmProductSelect = async () => { productDialogVisible.value = false } +const openSupplierSelectDialog = async (row: any) => { + if (props.disabled) return + currentSelectRow.value = row + selectedSupplierId.value = row.supplierId + supplierQueryParams.pageNo = 1 + supplierQueryParams.name = undefined + supplierQueryParams.mobile = undefined + supplierDialogVisible.value = true + await getSupplierDialogList() +} + +const getSupplierDialogList = async () => { + supplierDialogLoading.value = true + try { + const data = await SupplierApi.getSupplierPage({ + ...supplierQueryParams, + status: 0 + }) + supplierDialogList.value = data?.list || [] + supplierDialogTotal.value = data?.total || 0 + } finally { + supplierDialogLoading.value = false + } +} + +const handleSupplierDialogQuery = () => { + supplierQueryParams.pageNo = 1 + getSupplierDialogList() +} + +const resetSupplierDialogQuery = () => { + supplierSearchFormRef.value?.resetFields() + handleSupplierDialogQuery() +} + +const handleSupplierDialogRowClick = (row: any) => { + selectedSupplierId.value = row.id +} + +const confirmSupplierSelect = () => { + if (props.disabled) return + const supplier = supplierDialogList.value.find((item) => item.id === selectedSupplierId.value) + if (!supplier || !currentSelectRow.value) return + currentSelectRow.value.supplierId = supplier.id + currentSelectRow.value.supplierName = supplier.name + supplierDialogVisible.value = false +} + +const clearSupplier = (row: any) => { + if (props.disabled) return + row.supplierId = undefined + row.supplierName = undefined +} + const openTaskSelectDialog = async (row: any) => { currentSelectRow.value = row selectedTaskId.value = row.taskId @@ -1208,7 +1353,7 @@ const getInitialSelectedPalletRows = (row: any) => { } const getPalletPackageCount = (row: any, pallet: PalletVO) => { - return pallet.productCount ?? row?.palletPackageQuantity ?? row?.packageQuantity ?? row?.count + return row?.palletPackageQuantity ?? pallet.productCount ?? row?.packageQuantity ?? row?.count } const getSelectedPalletItemCountValue = (pallet: any) => { @@ -1336,7 +1481,9 @@ const fillProductNames = (rows: any[]) => { row.productPrice = row.productPrice ?? product.minPrice row.purchaseUnitId = row.purchaseUnitId ?? (product as any).purchaseUnitId row.purchaseUnitName = row.purchaseUnitName ?? (product as any).purchaseUnitName - row.supplierName = row.supplierName ?? getDefaultSupplierName(product) + const supplier = getDefaultSupplier(product) + row.supplierId = row.supplierId ?? supplier?.id + row.supplierName = row.supplierName ?? supplier?.name row.purchaseUnitConvertQuantity = row.purchaseUnitConvertQuantity ?? (product as any).purchaseUnitConvertQuantity normalizePackageCount(row) syncCountByPackageCount(row)