feat(mes): 更新条码相关功能,优化业务类型处理及描述字段
parent
93024d0061
commit
2a7051cceb
|
|
@ -8,7 +8,7 @@ export namespace MesWmMiscIssueApi {
|
|||
id?: number; // 编号
|
||||
code?: string; // 出库单编号
|
||||
name?: string; // 出库单名称
|
||||
type?: string; // 业务类型
|
||||
type?: number; // 业务类型
|
||||
sourceDocType?: string; // 来源单据类型
|
||||
sourceDocId?: number; // 来源单据编号
|
||||
sourceDocCode?: string; // 来源单据编码
|
||||
|
|
|
|||
|
|
@ -5,20 +5,12 @@ import type { MesWmBarcodeApi } from '#/api/mes/wm/barcode';
|
|||
|
||||
import { ref } from 'vue';
|
||||
|
||||
import { DICT_TYPE } from '@vben/constants';
|
||||
|
||||
import {
|
||||
Button,
|
||||
Descriptions,
|
||||
Empty,
|
||||
message,
|
||||
Modal,
|
||||
Tooltip,
|
||||
} from 'ant-design-vue';
|
||||
import { Button, Empty, message, Modal, Tooltip } from 'ant-design-vue';
|
||||
|
||||
import { createBarcode, getBarcodeByBusiness } from '#/api/mes/wm/barcode';
|
||||
import { DictTag } from '#/components/dict-tag';
|
||||
import { useDescription } from '#/components/description';
|
||||
|
||||
import { useBarcodeDetailSchema } from '../data';
|
||||
import MesWmBarcode from './barcode.vue';
|
||||
|
||||
defineOptions({ name: 'MesWmBarcodeDetail' });
|
||||
|
|
@ -27,6 +19,13 @@ const open = ref(false);
|
|||
const barcodeRef = ref<InstanceType<typeof Barcode>>();
|
||||
const barcodeData = ref<Partial<MesWmBarcodeApi.Barcode>>({});
|
||||
|
||||
const [Descriptions] = useDescription({
|
||||
bordered: true,
|
||||
column: 1,
|
||||
schema: useBarcodeDetailSchema(),
|
||||
useCard: false,
|
||||
});
|
||||
|
||||
function openModal(row: Partial<MesWmBarcodeApi.Barcode>) {
|
||||
open.value = true;
|
||||
barcodeData.value = { ...row };
|
||||
|
|
@ -146,22 +145,8 @@ async function handleGenerate() {
|
|||
</div>
|
||||
<Empty v-else description="暂无条码数据" />
|
||||
</div>
|
||||
<Descriptions :column="1" bordered>
|
||||
<Descriptions.Item label="条码格式">
|
||||
<DictTag
|
||||
v-if="barcodeData.format"
|
||||
:type="DICT_TYPE.MES_WM_BARCODE_FORMAT"
|
||||
:value="barcodeData.format"
|
||||
/>
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="业务类型">
|
||||
<DictTag
|
||||
v-if="barcodeData.bizType"
|
||||
:type="DICT_TYPE.MES_WM_BARCODE_BIZ_TYPE"
|
||||
:value="barcodeData.bizType"
|
||||
/>
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="条码内容">
|
||||
<Descriptions :data="barcodeData">
|
||||
<template #content>
|
||||
<Tooltip :title="barcodeData.content">
|
||||
<span
|
||||
class="inline-block max-w-75 overflow-hidden text-ellipsis whitespace-nowrap"
|
||||
|
|
@ -169,23 +154,7 @@ async function handleGenerate() {
|
|||
{{ barcodeData.content }}
|
||||
</span>
|
||||
</Tooltip>
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="业务编码">
|
||||
{{ barcodeData.bizCode || '-' }}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="业务名称">
|
||||
{{ barcodeData.bizName || '-' }}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="状态">
|
||||
<DictTag
|
||||
v-if="barcodeData.status !== undefined"
|
||||
:type="DICT_TYPE.COMMON_STATUS"
|
||||
:value="barcodeData.status"
|
||||
/>
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="创建时间">
|
||||
{{ barcodeData.createTime || '-' }}
|
||||
</Descriptions.Item>
|
||||
</template>
|
||||
</Descriptions>
|
||||
</div>
|
||||
<template #footer>
|
||||
|
|
|
|||
|
|
@ -1,8 +1,12 @@
|
|||
import type { VbenFormSchema } from '#/adapter/form';
|
||||
|
||||
import { h } from 'vue';
|
||||
|
||||
import { CommonStatusEnum, DICT_TYPE } from '@vben/constants';
|
||||
import { getDictOptions } from '@vben/hooks';
|
||||
|
||||
import { Button, message } from 'ant-design-vue';
|
||||
|
||||
import { z } from '#/adapter/form';
|
||||
|
||||
/** 表单 */
|
||||
|
|
@ -74,8 +78,18 @@ export function useFormSchema(): VbenFormSchema[] {
|
|||
label: '默认打印模板',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入打印模板',
|
||||
placeholder: '请选择打印模板',
|
||||
readonly: true,
|
||||
},
|
||||
// TODO @芋艿:后续对接 UReport 报表选择器,实现打印模板选择功能
|
||||
suffix: () =>
|
||||
h(
|
||||
Button,
|
||||
{
|
||||
onClick: () => message.warning('打印模板选择功能暂未实现,敬请期待'),
|
||||
},
|
||||
{ default: () => '设置' },
|
||||
),
|
||||
},
|
||||
{
|
||||
fieldName: 'status',
|
||||
|
|
|
|||
|
|
@ -2,14 +2,17 @@ import type { VbenFormApi, VbenFormSchema } from '#/adapter/form';
|
|||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { MesWmBarcodeApi } from '#/api/mes/wm/barcode';
|
||||
import type { MesWmBarcodeConfigApi } from '#/api/mes/wm/barcode/config';
|
||||
import type { DescriptionItemSchema } from '#/components/description';
|
||||
|
||||
import { markRaw } from 'vue';
|
||||
import { h, markRaw } from 'vue';
|
||||
|
||||
import { CommonStatusEnum, DICT_TYPE } from '@vben/constants';
|
||||
import { getDictOptions } from '@vben/hooks';
|
||||
import { formatDateTime } from '@vben/utils';
|
||||
|
||||
import { z } from '#/adapter/form';
|
||||
import { generateBarcodeContent } from '#/api/mes/wm/barcode';
|
||||
import { DictTag } from '#/components/dict-tag';
|
||||
import DvMachinerySelect from '#/views/mes/dv/machinery/components/dv-machinery-select.vue';
|
||||
import MdClientSelect from '#/views/mes/md/client/components/md-client-select.vue';
|
||||
import MdItemSelect from '#/views/mes/md/item/components/md-item-select.vue';
|
||||
|
|
@ -21,6 +24,7 @@ import TmToolSelect from '#/views/mes/tm/tool/components/tm-tool-select.vue';
|
|||
import { BarcodeBizTypeEnum } from '#/views/mes/utils/constants';
|
||||
|
||||
import WmMaterialStockSelect from './../materialstock/components/wm-material-stock-select.vue';
|
||||
import { WmPackageSelect } from './../packages/components';
|
||||
import {
|
||||
WmWarehouseAreaSelect,
|
||||
WmWarehouseLocationSelect,
|
||||
|
|
@ -50,19 +54,20 @@ async function syncBizDetail(
|
|||
if (bizType === BarcodeBizTypeEnum.STOCK) {
|
||||
bizCode = item.itemCode;
|
||||
bizName = item.itemName;
|
||||
} else if (bizType === BarcodeBizTypeEnum.PACKAGE) {
|
||||
bizCode = item.code;
|
||||
bizName = item.clientName || item.code;
|
||||
} else {
|
||||
bizCode = item.code || item.username;
|
||||
bizName = item.name || item.nickname;
|
||||
}
|
||||
let content: string | undefined;
|
||||
// 先回填业务编码、名称并清空旧条码内容
|
||||
await formApi.setValues({ bizCode, bizName, content: undefined });
|
||||
// 再根据业务类型 + 业务编码生成条码内容
|
||||
if (bizType && bizCode) {
|
||||
try {
|
||||
content = await generateBarcodeContent(bizType, bizCode);
|
||||
} catch (error) {
|
||||
console.error('生成条码内容失败:', error);
|
||||
}
|
||||
const content = await generateBarcodeContent(bizType, bizCode);
|
||||
await formApi.setFieldValue('content', content);
|
||||
}
|
||||
await formApi.setValues({ bizCode, bizName, content });
|
||||
}
|
||||
|
||||
/** 新增/修改条码的表单 */
|
||||
|
|
@ -309,6 +314,20 @@ export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
|
|||
},
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
fieldName: 'bizId',
|
||||
label: '装箱单',
|
||||
component: markRaw(WmPackageSelect),
|
||||
componentProps: {
|
||||
childableOnly: true,
|
||||
onChange: (item: any) => syncBizDetail(formApi, item),
|
||||
},
|
||||
dependencies: {
|
||||
triggerFields: ['bizType'],
|
||||
show: (values) => values.bizType === BarcodeBizTypeEnum.PACKAGE,
|
||||
},
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
fieldName: 'bizId',
|
||||
label: '业务编号',
|
||||
|
|
@ -328,6 +347,7 @@ export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
|
|||
BarcodeBizTypeEnum.ITEM,
|
||||
BarcodeBizTypeEnum.LOCATION,
|
||||
BarcodeBizTypeEnum.MACHINERY,
|
||||
BarcodeBizTypeEnum.PACKAGE,
|
||||
BarcodeBizTypeEnum.STOCK,
|
||||
BarcodeBizTypeEnum.TOOL,
|
||||
BarcodeBizTypeEnum.VENDOR,
|
||||
|
|
@ -346,6 +366,7 @@ export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
|
|||
disabled: true,
|
||||
placeholder: '自动填充',
|
||||
},
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
fieldName: 'bizName',
|
||||
|
|
@ -355,6 +376,7 @@ export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
|
|||
disabled: true,
|
||||
placeholder: '自动填充',
|
||||
},
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
fieldName: 'content',
|
||||
|
|
@ -596,3 +618,53 @@ export function useConfigGridColumns(
|
|||
},
|
||||
];
|
||||
}
|
||||
|
||||
/** 条码详情的描述字段 */
|
||||
export function useBarcodeDetailSchema(): DescriptionItemSchema[] {
|
||||
return [
|
||||
{
|
||||
field: 'format',
|
||||
label: '条码格式',
|
||||
render: (value) =>
|
||||
value == null
|
||||
? '-'
|
||||
: h(DictTag, { type: DICT_TYPE.MES_WM_BARCODE_FORMAT, value }),
|
||||
},
|
||||
{
|
||||
field: 'bizType',
|
||||
label: '业务类型',
|
||||
render: (value) =>
|
||||
value == null
|
||||
? '-'
|
||||
: h(DictTag, { type: DICT_TYPE.MES_WM_BARCODE_BIZ_TYPE, value }),
|
||||
},
|
||||
{
|
||||
field: 'content',
|
||||
label: '条码内容',
|
||||
slot: 'content',
|
||||
},
|
||||
{
|
||||
field: 'bizCode',
|
||||
label: '业务编码',
|
||||
render: (value) => value || '-',
|
||||
},
|
||||
{
|
||||
field: 'bizName',
|
||||
label: '业务名称',
|
||||
render: (value) => value || '-',
|
||||
},
|
||||
{
|
||||
field: 'status',
|
||||
label: '状态',
|
||||
render: (value) =>
|
||||
value == null
|
||||
? '-'
|
||||
: h(DictTag, { type: DICT_TYPE.COMMON_STATUS, value }),
|
||||
},
|
||||
{
|
||||
field: 'createTime',
|
||||
label: '创建时间',
|
||||
render: (value) => formatDateTime(value) || '-',
|
||||
},
|
||||
];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,24 +49,17 @@ async function loadCascadeData(data: MesWmBarcodeApi.Barcode) {
|
|||
if (!data.bizType || !data.bizId) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
if (data.bizType === BarcodeBizTypeEnum.LOCATION) {
|
||||
const location = await getWarehouseLocation(data.bizId);
|
||||
if (location?.warehouseId) {
|
||||
await formApi.setFieldValue(
|
||||
'locationWarehouseId',
|
||||
location.warehouseId,
|
||||
);
|
||||
}
|
||||
} else if (data.bizType === BarcodeBizTypeEnum.AREA) {
|
||||
const area = await getWarehouseArea(data.bizId);
|
||||
await formApi.setValues({
|
||||
areaWarehouseId: area?.warehouseId,
|
||||
areaLocationId: area?.locationId,
|
||||
});
|
||||
if (data.bizType === BarcodeBizTypeEnum.LOCATION) {
|
||||
const location = await getWarehouseLocation(data.bizId);
|
||||
if (location?.warehouseId) {
|
||||
await formApi.setFieldValue('locationWarehouseId', location.warehouseId);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('加载级联数据失败:', error);
|
||||
} else if (data.bizType === BarcodeBizTypeEnum.AREA) {
|
||||
const area = await getWarehouseArea(data.bizId);
|
||||
await formApi.setValues({
|
||||
areaWarehouseId: area?.warehouseId,
|
||||
areaLocationId: area?.locationId,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue