fix: 修正出库单字典加载与详情标识

This commit is contained in:
zhouz
2026-07-22 15:43:26 +08:00
parent e5f56057c3
commit 88b70e6729
4 changed files with 56 additions and 6 deletions

View File

@@ -110,9 +110,9 @@ export function getIostorInvPage(params: PageParam) {
}
/** 查询出入库单主表详情 */
export function getIostorInv(id: number) {
export function getIostorInv(id: string) {
return requestClient.get<WmsIostorInvApi.IostorInv>(
`/wms/iostor-inv/get?id=${id}`,
`/wms/iostor-inv/get?id=${encodeURIComponent(id)}`,
);
}

View File

@@ -4,13 +4,12 @@ import type { WmsIostorInvApi } from '#/api/wms/iostorinv';
import { computed, ref } from 'vue';
import { useVbenModal } from '@vben/common-ui';
import { DICT_TYPE } from '@vben/constants';
import { getDictOptions } from '@vben/hooks';
import { Button, Input, InputNumber, message, Space, Table } from 'antdv-next';
import dayjs from 'dayjs';
import { useVbenForm } from '#/adapter/form';
import { getSimpleDictDataList } from '#/api/system/dict/data';
import { getBsrealStorAttrSimpleList } from '#/api/wms/bsrealstorattr';
import {
createOutbound,
@@ -25,6 +24,7 @@ import InventorySelectComponent from './inventory-select.vue';
import ManualDetailComponent from './manual-detail.vue';
import {
buildOutboundPayload,
filterOutboundBillTypeOptions,
mergeOutboundInventory,
type OutboundFormDetail,
shouldClearDetailsForWarehouseChange,
@@ -35,6 +35,7 @@ const formData = ref<WmsIostorInvApi.IostorInv>();
const details = ref<OutboundFormDetail[]>([]);
const currentStorId = ref<string>();
let manualRowSequence = 0;
let billTypeRequest: null | ReturnType<typeof getSimpleDictDataList> = null;
const isEdit = computed(() => Boolean(formData.value?.iostorinvId));
const getTitle = computed(() =>
@@ -103,7 +104,7 @@ const [OutboundForm, outboundFormApi] = useVbenForm({
component: 'Select',
componentProps: {
allowClear: true,
options: getDictOptions(DICT_TYPE.WMS_SHIPMENT_ORDER_TYPE, 'string'),
options: [],
placeholder: '请选择业务类型',
},
fieldName: 'billType',
@@ -159,6 +160,28 @@ const [ManualDetail, manualDetailApi] = useVbenModal({
destroyOnClose: true,
});
async function loadBillTypeOptions() {
billTypeRequest ??= getSimpleDictDataList();
const request = billTypeRequest;
try {
const dictItems = await request;
outboundFormApi.updateSchema([
{
componentProps: {
allowClear: true,
options: filterOutboundBillTypeOptions(dictItems),
placeholder: '请选择业务类型',
},
fieldName: 'billType',
},
]);
} catch {
message.error('出库业务类型加载失败,请稍后重试');
} finally {
if (billTypeRequest === request) billTypeRequest = null;
}
}
const columns = [
{ key: 'index', title: '序号', width: 60 },
{ dataIndex: 'materialCode', key: 'materialCode', title: '物料编码', width: 130 },
@@ -293,12 +316,13 @@ const [Modal, modalApi] = useVbenModal({
detailCount: 0,
totalWeight: '0.000',
});
await loadBillTypeOptions();
return;
}
modalApi.lock();
try {
formData.value = data;
formData.value = await getIostorInv(Number(data.iostorinvId));
formData.value = await getIostorInv(data.iostorinvId);
await legacyFormApi.setValues(formData.value);
} finally {
modalApi.unlock();

View File

@@ -2,10 +2,23 @@ import { describe, expect, it } from 'vitest';
import {
buildOutboundPayload,
filterOutboundBillTypeOptions,
mergeOutboundInventory,
shouldClearDetailsForWarehouseChange,
} from './outbound-form';
describe('filterOutboundBillTypeOptions', () => {
it('从冷缓存接口结果中只提取启用的出库业务类型', () => {
expect(
filterOutboundBillTypeOptions([
{ dictType: 'in_bill_type', label: '采购入库', status: 0, value: '100' },
{ dictType: 'out_bill_type', label: '销售出库', status: 0, value: '201' },
{ dictType: 'out_bill_type', label: '停用出库', status: 1, value: '299' },
]),
).toEqual([{ label: '销售出库', value: '201' }]);
});
});
describe('buildOutboundPayload', () => {
it('将业务日期转换成毫秒,并剥离所有仅展示字段和汇总字段', () => {
const bizDate = new Date('2026-07-22T08:30:00+08:00');

View File

@@ -1,5 +1,12 @@
import type { WmsIostorInvApi } from '#/api/wms/iostorinv';
export interface OutboundDictItem {
dictType: string;
label: string;
status?: number;
value: string;
}
export interface OutboundFormValues {
billType?: string;
bizDate?: number | string | { valueOf: () => number };
@@ -14,6 +21,12 @@ export interface OutboundFormDetail
rowKey?: string;
}
export function filterOutboundBillTypeOptions(items: OutboundDictItem[]) {
return items
.filter((item) => item.dictType === 'out_bill_type' && item.status !== 1)
.map(({ label, value }) => ({ label, value }));
}
export function buildOutboundPayload(
values: OutboundFormValues,
details: OutboundFormDetail[],