fix(mes): 修复 MES 迁移 review 发现的问题(B001-B032)

系统性修复 MES migration review(INDEX.md,MES-R001~R042)发现的迁移问题,
覆盖 web-antd 与 web-ele 两端,按严重级别从 P0 到 P3。

P0
- B001: DICT_TYPE/BarcodeBizTypeEnum 等常量从 'vue' 误导入致 TS2305/运行时崩溃,
  改从 @vben/constants 导入(20 个文件)。

P1
- B002 itemreceipt 入库单名称误必填;B003 条码工单选择补 CONFIRMED 过滤;
  B004 库存台账冻结开关补更新权限禁用;B005 returnsales 上架明细批次号误必填;
  B006 checkrecord/maintenrecord 计划/执行人误必填;B007 returnsales 退货行
  rqcCheckFlag 默认改回 false;B019 OQC 预填 checkQuantity 缺省取 outQuantity;
  B024 repair 完成维修态放开 finishDate 录入;B025 tool 编码管理类型库存数量锁定为 1;
  B027 详情态自动编码按钮隐藏/禁用(md/cal/dv/tm 13 模块)。

P2
- B008 IPQC 废品数量补 0 默认值;B009 共享选择器去掉 catch+console.error 吞错;
  B011 route 自定义 SFC 改 markRaw;B012 ele 自动编码按钮去 type:'default';
  B014 md 编辑态编码字段误禁用;B015 dv/subject 选择器仅展示启用项(保留历史回显);
  B016 盘点结果回填 batchId;B017 源 vue3 miscissue 业务类型字典误用 getStrDictOptions;
  B018 stocktaking/plan 盘点条件表单 schema 化;B020 清理 TODO @AI;
  B026 repair 验收信息字段按状态门控只读。

P3
- B010 QcIndicatorSelect 去吞错;B013/B019/B030/B031 componentProps、列对象多行化等
  code style;B021 自动编码循环方式列条件展示;B022 盘点结果选中清单行后字段禁用;
  B023 质检指标 resultSpecification 抽 ResultSpecificationInput 消除重复 fieldName;
  B032 barcode/batch/sn API 字段补注释。

风格统一
- getTitle 统一为「特殊态 if 提前 return + create/update 三元」(pro/card、
  stocktaking/task、repair);headerReadonly 抽 isHeaderReadonly 辅助函数对齐
  pro/workorder/transfer 写法;computed 解释注释移入 computed 内部。

验证:
- 两端 pnpm exec eslint 改动文件通过
- 两端 pnpm -F @vben/web-antd / @vben/web-ele exec vue-tsc 过滤 src/views/mes、
  api/mes 无报错
- git diff --check 通过

备注:R037(defectrecord 命名漂移)经复核为原 finding 前提有误(两端本就一致),
已 rejected,未占 MES-B 编号。R008/R009 为 disputed 待裁决。
本提交仅含 src/views/mes 与 src/api/mes 下文件,排除 .env.development、vite.config.ts、
infra/codegen、docs changelog 等无关旁支改动。
pull/351/MERGE
YunaiV 2026-05-31 10:21:23 +08:00
parent 4dff39ddc5
commit 61172b9a68
88 changed files with 1465 additions and 654 deletions

View File

@ -5,17 +5,17 @@ import { requestClient } from '#/api/request';
export namespace MesWmBarcodeApi {
/** MES 条码清单 */
export interface Barcode {
id?: number;
configId?: number;
format?: number;
bizType?: number;
content?: string;
bizId?: number;
bizCode?: string;
bizName?: string;
status?: number;
remark?: string;
createTime?: Date;
id?: number; // 条码编号
configId?: number; // 条码配置编号
format?: number; // 条码格式
bizType?: number; // 业务类型
content?: string; // 条码内容
bizId?: number; // 业务对象编号
bizCode?: string; // 业务对象编码
bizName?: string; // 业务对象名称
status?: number; // 状态
remark?: string; // 备注
createTime?: Date; // 创建时间
}
}

View File

@ -39,22 +39,22 @@ export namespace MesWmBatchApi {
/** MES 批次分页查询参数 */
export interface PageParams extends PageParam {
code?: string;
itemId?: number;
vendorId?: number;
clientId?: number;
workOrderId?: number;
taskId?: number;
workstationId?: number;
toolId?: number;
moldId?: number;
salesOrderCode?: string;
purchaseOrderCode?: string;
lotNumber?: string;
qualityStatus?: number;
produceDate?: string[];
expireDate?: string[];
receiptDate?: string[];
code?: string; // 批次号
itemId?: number; // 物料编号
vendorId?: number; // 供应商编号
clientId?: number; // 客户编号
workOrderId?: number; // 工单编号
taskId?: number; // 生产任务编号
workstationId?: number; // 工作站编号
toolId?: number; // 工具编号
moldId?: number; // 模具编号
salesOrderCode?: string; // 销售订单号
purchaseOrderCode?: string; // 采购订单号
lotNumber?: string; // 批号
qualityStatus?: number; // 质量状态
produceDate?: string[]; // 生产日期
expireDate?: string[]; // 过期日期
receiptDate?: string[]; // 入库日期
}
}

View File

@ -27,11 +27,11 @@ export namespace MesWmSnApi {
/** MES SN 码分组分页查询参数 */
export interface PageParams extends PageParam {
uuid?: string;
code?: string;
itemId?: number;
batchCode?: string;
createTime?: string[];
uuid?: string; // 分组 UUID
code?: string; // SN 码
itemId?: number; // 物料编号
batchCode?: string; // 批次号
createTime?: string[]; // 创建时间
}
}

View File

@ -16,7 +16,10 @@ import { getRangePickerDefaultProps } from '#/utils';
export type FormType = 'create' | 'detail' | 'update';
/** 新增/修改排班计划的表单 */
export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
export function useFormSchema(
formType: FormType,
formApi?: VbenFormApi,
): VbenFormSchema[] {
return [
{
fieldName: 'id',
@ -43,18 +46,21 @@ export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
placeholder: '请输入计划编码',
},
rules: 'required',
suffix: () =>
h(
Button,
{
type: 'default',
onClick: async () => {
const code = await generateAutoCode(MesAutoCodeRuleCode.CAL_PLAN_CODE);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '生成' },
),
suffix:
formType === 'detail'
? undefined
: () =>
h(
Button,
{
type: 'default',
onClick: async () => {
const code = await generateAutoCode(MesAutoCodeRuleCode.CAL_PLAN_CODE);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '生成' },
),
},
{
fieldName: 'name',

View File

@ -103,11 +103,11 @@ const [Modal, modalApi] = useVbenModal({
formData.value = undefined;
return;
}
formApi.setState({ schema: useFormSchema(formApi) });
subTabsName.value = 'shift';
//
const data = modalApi.getData<{ formType: FormType; id?: number }>();
formType.value = data.formType;
formApi.setState({ schema: useFormSchema(data.formType, formApi) });
formApi.setDisabled(formType.value === 'detail');
modalApi.setState({ showConfirmButton: formType.value !== 'detail' });
if (!data?.id) {

View File

@ -16,7 +16,10 @@ import { generateAutoCode } from '#/api/mes/md/autocode/record';
export type FormType = 'create' | 'detail' | 'update';
/** 新增/修改班组的表单 */
export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
export function useFormSchema(
formType: FormType,
formApi?: VbenFormApi,
): VbenFormSchema[] {
return [
{
fieldName: 'id',
@ -35,18 +38,21 @@ export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
placeholder: '请输入班组编码',
},
rules: z.string().min(1, '班组编码不能为空').max(64),
suffix: () =>
h(
Button,
{
type: 'default',
onClick: async () => {
const code = await generateAutoCode(MesAutoCodeRuleCode.CAL_TEAM_CODE);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '生成' },
),
suffix:
formType === 'detail'
? undefined
: () =>
h(
Button,
{
type: 'default',
onClick: async () => {
const code = await generateAutoCode(MesAutoCodeRuleCode.CAL_TEAM_CODE);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '生成' },
),
},
{
fieldName: 'name',

View File

@ -79,11 +79,11 @@ const [Modal, modalApi] = useVbenModal({
formData.value = undefined;
return;
}
formApi.setState({ schema: useFormSchema(formApi) });
subTabsName.value = 'member';
//
const data = modalApi.getData<{ formType: FormType; id?: number }>();
formType.value = data.formType;
formApi.setState({ schema: useFormSchema(data.formType, formApi) });
formApi.setDisabled(formType.value === 'detail');
modalApi.setState({ showConfirmButton: formType.value !== 'detail' });
if (!data?.id) {

View File

@ -17,7 +17,10 @@ import { getRangePickerDefaultProps } from '#/utils';
export type FormType = 'create' | 'detail' | 'update';
/** 新增/修改点检保养方案的表单 */
export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
export function useFormSchema(
formType: FormType,
formApi?: VbenFormApi,
): VbenFormSchema[] {
return [
{
fieldName: 'id',
@ -44,18 +47,21 @@ export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
placeholder: '请输入方案编码',
},
rules: 'required',
suffix: () =>
h(
Button,
{
type: 'default',
onClick: async () => {
const code = await generateAutoCode(MesAutoCodeRuleCode.DV_CHECK_PLAN_CODE);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '生成' },
),
suffix:
formType === 'detail'
? undefined
: () =>
h(
Button,
{
type: 'default',
onClick: async () => {
const code = await generateAutoCode(MesAutoCodeRuleCode.DV_CHECK_PLAN_CODE);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '生成' },
),
},
{
fieldName: 'name',

View File

@ -78,11 +78,11 @@ const [Modal, modalApi] = useVbenModal({
formData.value = undefined;
return;
}
formApi.setState({ schema: useFormSchema(formApi) });
subTabsName.value = 'machinery';
//
const data = modalApi.getData<{ formType: FormType; id?: number }>();
formType.value = data.formType;
formApi.setState({ schema: useFormSchema(data.formType, formApi) });
formApi.setDisabled(formType.value === 'detail');
modalApi.setState({ showConfirmButton: formType.value !== 'detail' });
if (!data?.id) {

View File

@ -41,18 +41,21 @@ export function useFormSchema(formType: FormType, formApi?: VbenFormApi): VbenFo
componentProps: (values) => ({ disabled: !!values.id }),
},
rules: 'required',
suffix: () =>
h(
Button,
{
type: 'default',
onClick: async () => {
const code = await generateAutoCode(MesAutoCodeRuleCode.DV_MACHINERY_CODE);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '生成' },
),
suffix:
formType === 'detail'
? undefined
: () =>
h(
Button,
{
type: 'default',
onClick: async () => {
const code = await generateAutoCode(MesAutoCodeRuleCode.DV_MACHINERY_CODE);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '生成' },
),
},
{
fieldName: 'name',

View File

@ -14,8 +14,14 @@ import { z } from '#/adapter/form';
import { getMachineryTypeList } from '#/api/mes/dv/machinery/type';
import { generateAutoCode } from '#/api/mes/md/autocode/record';
/** 表单类型 */
export type FormType = 'create' | 'detail' | 'update';
/** 新增/修改设备类型的表单 */
export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
export function useFormSchema(
formType: FormType,
formApi?: VbenFormApi,
): VbenFormSchema[] {
return [
{
fieldName: 'id',
@ -52,18 +58,23 @@ export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
placeholder: '请输入类型编码',
},
rules: z.string().min(1, '类型编码不能为空').max(64),
suffix: () =>
h(
Button,
{
type: 'default',
onClick: async () => {
const code = await generateAutoCode(MesAutoCodeRuleCode.DV_MACHINERY_TYPE_CODE);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '生成' },
),
suffix:
formType === 'detail'
? undefined
: () =>
h(
Button,
{
type: 'default',
onClick: async () => {
const code = await generateAutoCode(
MesAutoCodeRuleCode.DV_MACHINERY_TYPE_CODE,
);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '生成' },
),
},
{
fieldName: 'name',

View File

@ -64,9 +64,11 @@ const [Modal, modalApi] = useVbenModal({
formData.value = undefined;
return;
}
formApi.setState({ schema: useFormSchema(formApi) });
//
const data = modalApi.getData<MesDvMachineryTypeApi.MachineryType>();
formApi.setState({
schema: useFormSchema(data?.id ? 'update' : 'create', formApi),
});
if (!data || !data.id) {
formData.value = data || undefined;
if (data) {

View File

@ -16,8 +16,17 @@ import { DvMachinerySelect } from '#/views/mes/dv/machinery/components';
/** 表单类型 */
export type FormType = 'confirm' | 'create' | 'detail' | 'finish' | 'update';
/** 表头是否只读完成维修、验收、详情态finishDate 在 confirm 单独放开) */
function isHeaderReadonly(formType: FormType): boolean {
return ['confirm', 'detail', 'finish'].includes(formType);
}
/** 新增/修改维修工单的表单 */
export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
export function useFormSchema(
formType: FormType,
formApi?: VbenFormApi,
): VbenFormSchema[] {
const headerReadonly = isHeaderReadonly(formType);
return [
{
fieldName: 'id',
@ -45,27 +54,30 @@ export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
},
dependencies: {
triggerFields: ['id'],
componentProps: (values) => ({ disabled: !!values.id }),
componentProps: (values) => ({ disabled: headerReadonly || !!values.id }),
},
rules: 'required',
suffix: () =>
h(
Button,
{
type: 'default',
onClick: async () => {
const code = await generateAutoCode(MesAutoCodeRuleCode.DV_REPAIR_CODE);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '生成' },
),
suffix: headerReadonly
? undefined
: () =>
h(
Button,
{
type: 'default',
onClick: async () => {
const code = await generateAutoCode(MesAutoCodeRuleCode.DV_REPAIR_CODE);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '生成' },
),
},
{
fieldName: 'name',
label: '维修单名称',
component: 'Input',
componentProps: {
disabled: headerReadonly,
placeholder: '请输入维修单名称',
},
rules: 'required',
@ -75,6 +87,7 @@ export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
label: '设备',
component: markRaw(DvMachinerySelect),
componentProps: {
disabled: headerReadonly,
placeholder: '请选择设备',
},
rules: 'selectRequired',
@ -84,6 +97,7 @@ export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
label: '报修日期',
component: 'DatePicker',
componentProps: {
disabled: headerReadonly,
format: 'YYYY-MM-DD HH:mm:ss',
placeholder: '请选择报修日期',
showTime: true,
@ -98,10 +112,18 @@ export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
componentProps: {
allowClear: true,
api: getSimpleUserList,
disabled: true,
labelField: 'nickname',
placeholder: '请选择维修人',
valueField: 'id',
},
// 维修人为待验收(≥APPROVING)态自动产生的只读回显字段
dependencies: {
triggerFields: ['status'],
if: (values) =>
values.status != null &&
values.status >= MesDvRepairStatusEnum.APPROVING,
},
},
{
fieldName: 'finishDate',
@ -113,6 +135,15 @@ export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
showTime: true,
valueFormat: 'x',
},
// 维修中(≥CONFIRMED)态展示;仅"完成维修"弹窗可编辑并必填,其余态只读回显
dependencies: {
triggerFields: ['status'],
if: (values) =>
values.status != null &&
values.status >= MesDvRepairStatusEnum.CONFIRMED,
disabled: formType !== 'confirm',
rules: () => (formType === 'confirm' ? 'required' : null),
},
},
{
fieldName: 'confirmUserId',
@ -121,21 +152,37 @@ export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
componentProps: {
allowClear: true,
api: getSimpleUserList,
disabled: true,
labelField: 'nickname',
placeholder: '请选择验收人',
valueField: 'id',
},
// 验收信息为已确认(≥FINISHED)态自动产生的只读回显字段
dependencies: {
triggerFields: ['status'],
if: (values) =>
values.status != null &&
values.status >= MesDvRepairStatusEnum.FINISHED,
},
},
{
fieldName: 'confirmDate',
label: '验收日期',
component: 'DatePicker',
componentProps: {
disabled: true,
format: 'YYYY-MM-DD HH:mm:ss',
placeholder: '请选择验收日期',
showTime: true,
valueFormat: 'x',
},
// 验收信息为已确认(≥FINISHED)态自动产生的只读回显字段
dependencies: {
triggerFields: ['status'],
if: (values) =>
values.status != null &&
values.status >= MesDvRepairStatusEnum.FINISHED,
},
},
{
fieldName: 'result',
@ -143,9 +190,17 @@ export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
component: 'RadioGroup',
componentProps: {
buttonStyle: 'solid',
disabled: true,
optionType: 'button',
options: getDictOptions(DICT_TYPE.MES_DV_REPAIR_RESULT, 'number'),
},
// 验收信息为已确认(≥FINISHED)态自动产生的只读回显字段
dependencies: {
triggerFields: ['status'],
if: (values) =>
values.status != null &&
values.status >= MesDvRepairStatusEnum.FINISHED,
},
},
{
fieldName: 'remark',
@ -153,6 +208,7 @@ export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
component: 'Textarea',
formItemClass: 'col-span-3',
componentProps: {
disabled: headerReadonly,
placeholder: '请输入备注',
rows: 3,
},

View File

@ -28,20 +28,29 @@ const emit = defineEmits(['success']);
const formType = ref<FormType>('create');
const formData = ref<MesDvRepairApi.Repair>();
const isDetail = computed(() => formType.value === 'detail');
const isReadonly = computed(() => ['confirm', 'detail', 'finish'].includes(formType.value));
const isLineReadonly = computed(() =>
// //
['confirm', 'detail', 'finish'].includes(formType.value),
);
const isFormDisabled = computed(() =>
// / finishDate schema
['detail', 'finish'].includes(formType.value),
);
const canSubmit = computed(
() => formType.value === 'update' && formData.value?.status === MesDvRepairStatusEnum.PREPARE,
);
const getTitle = computed(
() =>
({
create: '新增维修工单',
update: '修改维修工单',
confirm: '完成维修',
finish: '验收维修',
detail: '查看维修工单',
})[formType.value],
);
const getTitle = computed(() => {
if (formType.value === 'detail') {
return '查看维修工单';
}
if (formType.value === 'confirm') {
return '完成维修';
}
if (formType.value === 'finish') {
return '验收维修';
}
return formType.value === 'update' ? '修改维修工单' : '新增维修工单';
});
const [Form, formApi] = useVbenForm({
commonConfig: {
@ -161,11 +170,11 @@ const [Modal, modalApi] = useVbenModal({
formData.value = undefined;
return;
}
formApi.setState({ schema: useFormSchema(formApi) });
//
const data = modalApi.getData<{ formType: FormType; id?: number }>();
formType.value = data.formType;
formApi.setDisabled(isReadonly.value);
formApi.setState({ schema: useFormSchema(data.formType, formApi) });
formApi.setDisabled(isFormDisabled.value);
modalApi.setState({ showConfirmButton: ['create', 'update'].includes(formType.value) });
if (!data?.id) {
return;
@ -184,7 +193,7 @@ const [Modal, modalApi] = useVbenModal({
<template>
<Modal :title="getTitle" class="w-4/5">
<Form class="mx-4" />
<LineList v-if="formData?.id" :disabled="isReadonly" :repair-id="formData.id" />
<LineList v-if="formData?.id" :disabled="isLineReadonly" :repair-id="formData.id" />
<template #prepend-footer>
<div class="flex flex-auto items-center gap-2">
<Popconfirm

View File

@ -21,7 +21,10 @@ import { generateAutoCode } from '#/api/mes/md/autocode/record';
export type FormType = 'create' | 'detail' | 'update';
/** 新增/修改点检保养项目的表单 */
export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
export function useFormSchema(
formType: FormType,
formApi?: VbenFormApi,
): VbenFormSchema[] {
return [
{
fieldName: 'id',
@ -39,18 +42,21 @@ export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
placeholder: '请输入项目编码',
},
rules: 'required',
suffix: () =>
h(
Button,
{
type: 'default',
onClick: async () => {
const code = await generateAutoCode(MesAutoCodeRuleCode.DV_SUBJECT_CODE);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '生成' },
),
suffix:
formType === 'detail'
? undefined
: () =>
h(
Button,
{
type: 'default',
onClick: async () => {
const code = await generateAutoCode(MesAutoCodeRuleCode.DV_SUBJECT_CODE);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '生成' },
),
},
{
fieldName: 'name',

View File

@ -66,10 +66,10 @@ const [Modal, modalApi] = useVbenModal({
if (!isOpen) {
return;
}
formApi.setState({ schema: useFormSchema(formApi) });
//
const data = modalApi.getData<{ formType: FormType; id?: number }>();
formType.value = data.formType;
formApi.setState({ schema: useFormSchema(data.formType, formApi) });
formApi.setDisabled(formType.value === 'detail');
modalApi.setState({ showConfirmButton: formType.value !== 'detail' });
if (!data?.id) {

View File

@ -16,7 +16,10 @@ import { generateAutoCode } from '#/api/mes/md/autocode/record';
export type FormType = 'create' | 'detail' | 'update';
/** 新增/修改客户的表单 */
export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
export function useFormSchema(
formType: FormType,
formApi?: VbenFormApi,
): VbenFormSchema[] {
return [
{
fieldName: 'id',
@ -34,20 +37,23 @@ export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
placeholder: '请输入客户编码',
},
rules: 'required',
suffix: () =>
h(
Button,
{
type: 'default',
onClick: async () => {
const code = await generateAutoCode(
MesAutoCodeRuleCode.MD_CLIENT_CODE,
);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '自动生成' },
),
suffix:
formType === 'detail'
? undefined
: () =>
h(
Button,
{
type: 'default',
onClick: async () => {
const code = await generateAutoCode(
MesAutoCodeRuleCode.MD_CLIENT_CODE,
);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '自动生成' },
),
},
{
fieldName: 'name',

View File

@ -72,11 +72,11 @@ const [Modal, modalApi] = useVbenModal({
formData.value = undefined;
return;
}
formApi.setState({ schema: useFormSchema(formApi) });
subTabsName.value = 'productSalesLine';
//
const data = modalApi.getData<{ formType: FormType; id?: number }>();
formType.value = data.formType;
formApi.setState({ schema: useFormSchema(data.formType, formApi) });
formApi.setDisabled(formType.value === 'detail');
modalApi.setState({ showConfirmButton: formType.value !== 'detail' });
if (!data?.id) {

View File

@ -33,11 +33,31 @@ const [Grid] = useVbenVxeGrid({
width: 140,
slots: { default: 'itemCode' },
},
{ field: 'itemName', title: '物料名称', minWidth: 150 },
{ field: 'specification', title: '规格型号', minWidth: 140 },
{ field: 'unitMeasureName', title: '单位', width: 100 },
{ field: 'quantity', title: '出库数量', width: 120 },
{ field: 'batchCode', title: '批次号', minWidth: 140 },
{
field: 'itemName',
title: '物料名称',
minWidth: 150,
},
{
field: 'specification',
title: '规格型号',
minWidth: 140,
},
{
field: 'unitMeasureName',
title: '单位',
width: 100,
},
{
field: 'quantity',
title: '出库数量',
width: 120,
},
{
field: 'batchCode',
title: '批次号',
minWidth: 140,
},
],
height: 320,
keepSource: true,

View File

@ -14,9 +14,21 @@ const props = defineProps<{
const [Grid] = useVbenVxeGrid({
gridOptions: {
columns: [
{ field: 'code', title: '出库单编号', minWidth: 160 },
{ field: 'name', title: '出库单名称', minWidth: 150 },
{ field: 'salesOrderCode', title: '销售订单编号', minWidth: 140 },
{
field: 'code',
title: '出库单编号',
minWidth: 160,
},
{
field: 'name',
title: '出库单名称',
minWidth: 150,
},
{
field: 'salesOrderCode',
title: '销售订单编号',
minWidth: 140,
},
{
field: 'salesDate',
title: '出库日期',

View File

@ -19,7 +19,10 @@ import { MdUnitMeasureSelect } from '#/views/mes/md/unitmeasure/components';
export type FormType = 'create' | 'detail' | 'update';
/** 新增/修改物料产品的表单 */
export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
export function useFormSchema(
formType: FormType,
formApi?: VbenFormApi,
): VbenFormSchema[] {
return [
{
fieldName: 'id',
@ -38,20 +41,23 @@ export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
placeholder: '请输入物料编码',
},
rules: z.string().min(1, '物料编码不能为空').max(64),
suffix: () =>
h(
Button,
{
type: 'default',
onClick: async () => {
const code = await generateAutoCode(
MesAutoCodeRuleCode.MD_ITEM_CODE,
);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '生成' },
),
suffix:
formType === 'detail'
? undefined
: () =>
h(
Button,
{
type: 'default',
onClick: async () => {
const code = await generateAutoCode(
MesAutoCodeRuleCode.MD_ITEM_CODE,
);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '生成' },
),
},
{
fieldName: 'name',

View File

@ -100,11 +100,11 @@ const [Modal, modalApi] = useVbenModal({
formData.value = undefined;
return;
}
formApi.setState({ schema: useFormSchema(formApi) });
subTabsName.value = 'bom';
//
const data = modalApi.getData<{ formType: FormType; id?: number }>();
formType.value = data.formType;
formApi.setState({ schema: useFormSchema(data.formType, formApi) });
formApi.setDisabled(formType.value === 'detail');
modalApi.setState({ showConfirmButton: formType.value !== 'detail' });
if (!data?.id) {

View File

@ -68,38 +68,54 @@ const [Form, formApi] = useVbenForm({
fieldName: 'bomItemCode',
label: 'BOM 物料编码',
component: 'Input',
componentProps: { disabled: true },
componentProps: {
disabled: true,
},
},
{
fieldName: 'bomItemName',
label: 'BOM 物料名称',
component: 'Input',
componentProps: { disabled: true },
componentProps: {
disabled: true,
},
},
{
fieldName: 'bomItemSpecification',
label: '规格型号',
component: 'Input',
componentProps: { disabled: true },
componentProps: {
disabled: true,
},
},
{
fieldName: 'unitMeasureName',
label: '单位',
component: 'Input',
componentProps: { disabled: true },
componentProps: {
disabled: true,
},
},
{
fieldName: 'quantity',
label: '用量比例',
component: 'InputNumber',
componentProps: { class: '!w-full', min: 0, precision: 4, step: 0.1 },
componentProps: {
class: '!w-full',
min: 0,
precision: 4,
step: 0.1,
},
rules: z.number().default(1),
},
{
fieldName: 'remark',
label: '备注',
component: 'Textarea',
componentProps: { placeholder: '请输入备注', rows: 3 },
componentProps: {
placeholder: '请输入备注',
rows: 3,
},
},
],
showDefaultActions: false,

View File

@ -79,21 +79,30 @@ const [Form, formApi] = useVbenForm({
fieldName: 'title',
label: '标题',
component: 'Input',
componentProps: { placeholder: '请输入标题' },
componentProps: {
placeholder: '请输入标题',
},
rules: 'required',
},
{
fieldName: 'sort',
label: '展示顺序',
component: 'InputNumber',
componentProps: { class: '!w-full', min: 0, precision: 0 },
componentProps: {
class: '!w-full',
min: 0,
precision: 0,
},
rules: z.number().default(0),
},
{
fieldName: 'description',
label: '内容说明',
component: 'Textarea',
componentProps: { placeholder: '请输入详细描述', rows: 3 },
componentProps: {
placeholder: '请输入详细描述',
rows: 3,
},
},
{
fieldName: 'processId',
@ -104,13 +113,19 @@ const [Form, formApi] = useVbenForm({
fieldName: 'url',
label: '图片',
component: markRaw(ImageUpload),
componentProps: { maxNumber: 1, showDescription: false },
componentProps: {
maxNumber: 1,
showDescription: false,
},
},
{
fieldName: 'remark',
label: '备注',
component: 'Textarea',
componentProps: { placeholder: '请输入备注', rows: 3 },
componentProps: {
placeholder: '请输入备注',
rows: 3,
},
},
],
showDefaultActions: false,

View File

@ -19,8 +19,14 @@ import { z } from '#/adapter/form';
import { generateAutoCode } from '#/api/mes/md/autocode/record';
import { getItemTypeList } from '#/api/mes/md/item/type';
/** 表单类型 */
export type FormType = 'create' | 'detail' | 'update';
/** 新增/修改物料分类的表单 */
export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
export function useFormSchema(
formType: FormType,
formApi?: VbenFormApi,
): VbenFormSchema[] {
return [
{
fieldName: 'id',
@ -64,20 +70,23 @@ export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
placeholder: '请输入分类编码',
},
rules: z.string().min(1, '分类编码不能为空').max(64),
suffix: () =>
h(
Button,
{
type: 'default',
onClick: async () => {
const code = await generateAutoCode(
MesAutoCodeRuleCode.MD_ITEM_TYPE_CODE,
);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '自动生成' },
),
suffix:
formType === 'detail'
? undefined
: () =>
h(
Button,
{
type: 'default',
onClick: async () => {
const code = await generateAutoCode(
MesAutoCodeRuleCode.MD_ITEM_TYPE_CODE,
);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '自动生成' },
),
},
{
fieldName: 'name',

View File

@ -62,9 +62,11 @@ const [Modal, modalApi] = useVbenModal({
formData.value = undefined;
return;
}
formApi.setState({ schema: useFormSchema(formApi) });
//
const data = modalApi.getData<MesMdItemTypeApi.ItemType>();
formApi.setState({
schema: useFormSchema(data?.id ? 'update' : 'create', formApi),
});
if (!data || !data.id) {
formData.value = data || undefined;
if (data) {

View File

@ -16,7 +16,10 @@ import { generateAutoCode } from '#/api/mes/md/autocode/record';
export type FormType = 'create' | 'detail' | 'update';
/** 新增/修改供应商的表单 */
export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
export function useFormSchema(
formType: FormType,
formApi?: VbenFormApi,
): VbenFormSchema[] {
return [
{
fieldName: 'id',
@ -34,20 +37,23 @@ export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
placeholder: '请输入供应商编码',
},
rules: 'required',
suffix: () =>
h(
Button,
{
type: 'default',
onClick: async () => {
const code = await generateAutoCode(
MesAutoCodeRuleCode.MD_VENDOR_CODE,
);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '自动生成' },
),
suffix:
formType === 'detail'
? undefined
: () =>
h(
Button,
{
type: 'default',
onClick: async () => {
const code = await generateAutoCode(
MesAutoCodeRuleCode.MD_VENDOR_CODE,
);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '自动生成' },
),
},
{
fieldName: 'name',

View File

@ -74,11 +74,11 @@ const [Modal, modalApi] = useVbenModal({
formData.value = undefined;
return;
}
formApi.setState({ schema: useFormSchema(formApi) });
subTabsName.value = 'itemReceiptLine';
//
const data = modalApi.getData<{ formType: FormType; id?: number }>();
formType.value = data.formType;
formApi.setState({ schema: useFormSchema(data.formType, formApi) });
formApi.setDisabled(formType.value === 'detail');
modalApi.setState({ showConfirmButton: formType.value !== 'detail' });
if (!data?.id) {

View File

@ -31,12 +31,36 @@ function formatDate(value: Date | number | string | undefined) {
const [Grid, gridApi] = useVbenVxeGrid({
gridOptions: {
columns: [
{ field: 'itemCode', title: '物料编码', width: 140 },
{ field: 'itemName', title: '物料名称', minWidth: 150 },
{ field: 'specification', title: '规格型号', minWidth: 140 },
{ field: 'unitMeasureName', title: '单位', width: 100 },
{ field: 'receivedQuantity', title: '入库数量', width: 120 },
{ field: 'batchCode', title: '批次号', minWidth: 140 },
{
field: 'itemCode',
title: '物料编码',
width: 140,
},
{
field: 'itemName',
title: '物料名称',
minWidth: 150,
},
{
field: 'specification',
title: '规格型号',
minWidth: 140,
},
{
field: 'unitMeasureName',
title: '单位',
width: 100,
},
{
field: 'receivedQuantity',
title: '入库数量',
width: 120,
},
{
field: 'batchCode',
title: '批次号',
minWidth: 140,
},
],
height: 280,
keepSource: true,

View File

@ -33,11 +33,31 @@ const [Grid] = useVbenVxeGrid({
width: 140,
slots: { default: 'itemCode' },
},
{ field: 'itemName', title: '物料名称', minWidth: 150 },
{ field: 'specification', title: '规格型号', minWidth: 140 },
{ field: 'unitMeasureName', title: '单位', width: 100 },
{ field: 'receivedQuantity', title: '入库数量', width: 120 },
{ field: 'batchCode', title: '批次号', minWidth: 140 },
{
field: 'itemName',
title: '物料名称',
minWidth: 150,
},
{
field: 'specification',
title: '规格型号',
minWidth: 140,
},
{
field: 'unitMeasureName',
title: '单位',
width: 100,
},
{
field: 'receivedQuantity',
title: '入库数量',
width: 120,
},
{
field: 'batchCode',
title: '批次号',
minWidth: 140,
},
],
height: 320,
keepSource: true,

View File

@ -36,12 +36,36 @@ const [Grid] = useVbenVxeGrid({
minWidth: 160,
slots: { default: 'receiptCode' },
},
{ field: 'purchaseOrderCode', title: '采购订单号', minWidth: 150 },
{ field: 'itemCode', title: '物料编码', width: 140 },
{ field: 'itemName', title: '物料名称', minWidth: 150 },
{ field: 'specification', title: '规格型号', minWidth: 140 },
{ field: 'unitMeasureName', title: '单位', width: 100 },
{ field: 'receivedQuantity', title: '入库数量', width: 120 },
{
field: 'purchaseOrderCode',
title: '采购订单号',
minWidth: 150,
},
{
field: 'itemCode',
title: '物料编码',
width: 140,
},
{
field: 'itemName',
title: '物料名称',
minWidth: 150,
},
{
field: 'specification',
title: '规格型号',
minWidth: 140,
},
{
field: 'unitMeasureName',
title: '单位',
width: 100,
},
{
field: 'receivedQuantity',
title: '入库数量',
width: 120,
},
],
height: 320,
keepSource: true,

View File

@ -22,7 +22,10 @@ import { MdWorkshopSelect } from './components';
export type FormType = 'create' | 'detail' | 'update';
/** 新增/修改工作站的表单 */
export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
export function useFormSchema(
formType: FormType,
formApi?: VbenFormApi,
): VbenFormSchema[] {
return [
{
fieldName: 'id',
@ -40,20 +43,23 @@ export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
placeholder: '请输入工作站编码',
},
rules: 'required',
suffix: () =>
h(
Button,
{
type: 'default',
onClick: async () => {
const code = await generateAutoCode(
MesAutoCodeRuleCode.MD_WORKSTATION_CODE,
);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '生成' },
),
suffix:
formType === 'detail'
? undefined
: () =>
h(
Button,
{
type: 'default',
onClick: async () => {
const code = await generateAutoCode(
MesAutoCodeRuleCode.MD_WORKSTATION_CODE,
);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '生成' },
),
},
{
fieldName: 'name',

View File

@ -99,11 +99,11 @@ const [Modal, modalApi] = useVbenModal({
formData.value = undefined;
return;
}
formApi.setState({ schema: useFormSchema(formApi) });
subTabsName.value = 'machine';
//
const data = modalApi.getData<{ formType: FormType; id?: number }>();
formType.value = data.formType;
formApi.setState({ schema: useFormSchema(data.formType, formApi) });
formApi.setDisabled(formType.value === 'detail');
modalApi.setState({ showConfirmButton: formType.value !== 'detail' });
if (!data?.id) {

View File

@ -78,7 +78,10 @@ const [Form, formApi] = useVbenForm({
fieldName: 'remark',
label: '备注',
component: 'Textarea',
componentProps: { placeholder: '请输入备注', rows: 3 },
componentProps: {
placeholder: '请输入备注',
rows: 3,
},
},
],
showDefaultActions: false,
@ -89,10 +92,26 @@ const [Grid, gridApi] = useVbenVxeGrid({
autoResize: true,
border: true,
columns: [
{ field: 'machineryCode', title: '设备编码', width: 140 },
{ field: 'machineryName', title: '设备名称', minWidth: 160 },
{ field: 'quantity', title: '数量', width: 100 },
{ field: 'remark', title: '备注', minWidth: 160 },
{
field: 'machineryCode',
title: '设备编码',
width: 140,
},
{
field: 'machineryName',
title: '设备名称',
minWidth: 160,
},
{
field: 'quantity',
title: '数量',
width: 100,
},
{
field: 'remark',
title: '备注',
minWidth: 160,
},
{
title: '操作',
width: 90,

View File

@ -89,7 +89,10 @@ const [Form, formApi] = useVbenForm({
fieldName: 'remark',
label: '备注',
component: 'Textarea',
componentProps: { placeholder: '请输入备注', rows: 3 },
componentProps: {
placeholder: '请输入备注',
rows: 3,
},
},
],
showDefaultActions: false,
@ -100,10 +103,26 @@ const [Grid, gridApi] = useVbenVxeGrid({
autoResize: true,
border: true,
columns: [
{ field: 'toolTypeId', title: '工具类型编号', width: 140 },
{ field: 'toolTypeName', title: '工具类型名称', minWidth: 160 },
{ field: 'quantity', title: '数量', width: 100 },
{ field: 'remark', title: '备注', minWidth: 160 },
{
field: 'toolTypeId',
title: '工具类型编号',
width: 140,
},
{
field: 'toolTypeName',
title: '工具类型名称',
minWidth: 160,
},
{
field: 'quantity',
title: '数量',
width: 100,
},
{
field: 'remark',
title: '备注',
minWidth: 160,
},
{
title: '操作',
width: 130,

View File

@ -85,7 +85,10 @@ const [Form, formApi] = useVbenForm({
fieldName: 'remark',
label: '备注',
component: 'Textarea',
componentProps: { placeholder: '请输入备注', rows: 3 },
componentProps: {
placeholder: '请输入备注',
rows: 3,
},
},
],
showDefaultActions: false,
@ -96,10 +99,26 @@ const [Grid, gridApi] = useVbenVxeGrid({
autoResize: true,
border: true,
columns: [
{ field: 'postId', title: '岗位编号', width: 140 },
{ field: 'postName', title: '岗位名称', minWidth: 160 },
{ field: 'quantity', title: '数量', width: 100 },
{ field: 'remark', title: '备注', minWidth: 160 },
{
field: 'postId',
title: '岗位编号',
width: 140,
},
{
field: 'postName',
title: '岗位名称',
minWidth: 160,
},
{
field: 'quantity',
title: '数量',
width: 100,
},
{
field: 'remark',
title: '备注',
minWidth: 160,
},
{
title: '操作',
width: 130,

View File

@ -17,7 +17,10 @@ import { getSimpleUserList } from '#/api/system/user';
export type FormType = 'create' | 'detail' | 'update';
/** 新增/修改车间的表单 */
export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
export function useFormSchema(
formType: FormType,
formApi?: VbenFormApi,
): VbenFormSchema[] {
return [
{
fieldName: 'id',
@ -41,20 +44,23 @@ export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
}),
},
rules: 'required',
suffix: () =>
h(
Button,
{
type: 'default',
onClick: async () => {
const code = await generateAutoCode(
MesAutoCodeRuleCode.MD_WORKSHOP_CODE,
);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '生成' },
),
suffix:
formType === 'detail'
? undefined
: () =>
h(
Button,
{
type: 'default',
onClick: async () => {
const code = await generateAutoCode(
MesAutoCodeRuleCode.MD_WORKSHOP_CODE,
);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '生成' },
),
},
{
fieldName: 'name',

View File

@ -89,10 +89,10 @@ const [Modal, modalApi] = useVbenModal({
formData.value = undefined;
return;
}
formApi.setState({ schema: useFormSchema(formApi) });
//
const data = modalApi.getData<{ formType: FormType; id?: number }>();
formType.value = data.formType;
formApi.setState({ schema: useFormSchema(data.formType, formApi) });
formApi.setDisabled(formType.value === 'detail');
modalApi.setState({ showConfirmButton: formType.value !== 'detail' });
if (!data?.id) {

View File

@ -327,7 +327,9 @@ export function useFormSchema(
fieldName: 'itemCode',
label: '产品编码',
component: 'Input',
componentProps: { disabled: true },
componentProps: {
disabled: true,
},
dependencies: {
triggerFields: ['itemCode'],
show: (values) => !!values.itemCode,
@ -337,7 +339,9 @@ export function useFormSchema(
fieldName: 'itemName',
label: '产品名称',
component: 'Input',
componentProps: { disabled: true },
componentProps: {
disabled: true,
},
dependencies: {
triggerFields: ['itemCode'],
show: (values) => !!values.itemCode,
@ -347,7 +351,9 @@ export function useFormSchema(
fieldName: 'unitMeasureName',
label: '单位',
component: 'Input',
componentProps: { disabled: true },
componentProps: {
disabled: true,
},
dependencies: {
triggerFields: ['itemCode'],
show: (values) => !!values.itemCode,
@ -357,7 +363,9 @@ export function useFormSchema(
fieldName: 'itemSpecification',
label: '规格',
component: 'Input',
componentProps: { disabled: true },
componentProps: {
disabled: true,
},
dependencies: {
triggerFields: ['itemCode'],
show: (values) => !!values.itemCode,
@ -367,7 +375,11 @@ export function useFormSchema(
fieldName: 'feedbackQuantity',
label: '报工数量',
component: 'InputNumber',
componentProps: { class: 'w-full', min: 0, precision: 2 },
componentProps: {
class: 'w-full',
min: 0,
precision: 2,
},
dependencies: {
triggerFields: ['checkFlag'],
// 非质检工序时,报工数量 = 合格 + 不良,禁用直接编辑

View File

@ -5,7 +5,7 @@ import type { MesProRouteProcessApi } from '#/api/mes/pro/route/process';
import type { MesProRouteProductApi } from '#/api/mes/pro/route/product';
import type { MesProRouteProductBomApi } from '#/api/mes/pro/route/productbom';
import { h } from 'vue';
import { h, markRaw } from 'vue';
import { CommonStatusEnum, DICT_TYPE, MesAutoCodeRuleCode } from '@vben/constants';
import { getDictOptions } from '@vben/hooks';
@ -98,13 +98,19 @@ export function useGridFormSchema(): VbenFormSchema[] {
fieldName: 'code',
label: '路线编码',
component: 'Input',
componentProps: { allowClear: true, placeholder: '请输入路线编码' },
componentProps: {
allowClear: true,
placeholder: '请输入路线编码',
},
},
{
fieldName: 'name',
label: '路线名称',
component: 'Input',
componentProps: { allowClear: true, placeholder: '请输入路线名称' },
componentProps: {
allowClear: true,
placeholder: '请输入路线名称',
},
},
{
fieldName: 'status',
@ -186,7 +192,11 @@ export function useRouteProcessFormSchema(
fieldName: 'sort',
label: '序号',
component: 'InputNumber',
componentProps: { class: '!w-full', min: 1, precision: 0 },
componentProps: {
class: '!w-full',
min: 1,
precision: 0,
},
rules: z.number().default(1),
},
{
@ -221,28 +231,42 @@ export function useRouteProcessFormSchema(
fieldName: 'keyFlag',
label: '是否关键工序',
component: 'Switch',
componentProps: { checkedChildren: '是', unCheckedChildren: '否' },
componentProps: {
checkedChildren: '是',
unCheckedChildren: '否',
},
rules: z.boolean().default(false),
},
{
fieldName: 'checkFlag',
label: '是否质检确认',
component: 'Switch',
componentProps: { checkedChildren: '是', unCheckedChildren: '否' },
componentProps: {
checkedChildren: '是',
unCheckedChildren: '否',
},
rules: z.boolean().default(false),
},
{
fieldName: 'prepareTime',
label: '准备时间(分)',
component: 'InputNumber',
componentProps: { class: '!w-full', min: 0, precision: 0 },
componentProps: {
class: '!w-full',
min: 0,
precision: 0,
},
rules: z.number().default(0),
},
{
fieldName: 'waitTime',
label: '等待时间(分)',
component: 'InputNumber',
componentProps: { class: '!w-full', min: 0, precision: 0 },
componentProps: {
class: '!w-full',
min: 0,
precision: 0,
},
rules: z.number().default(0),
},
{
@ -250,7 +274,11 @@ export function useRouteProcessFormSchema(
label: '备注',
component: 'Textarea',
formItemClass: 'col-span-2',
componentProps: { maxLength: 250, placeholder: '请输入备注', rows: 2 },
componentProps: {
maxLength: 250,
placeholder: '请输入备注',
rows: 2,
},
},
];
}
@ -369,7 +397,7 @@ export function useRouteProductFormSchema(
{
fieldName: 'itemId',
label: '产品',
component: MdItemSelect as any,
component: markRaw(MdItemSelect),
componentProps: {
onChange: onItemChange,
},
@ -380,14 +408,22 @@ export function useRouteProductFormSchema(
fieldName: 'quantity',
label: '生产数量',
component: 'InputNumber',
componentProps: { class: '!w-full', min: 1, precision: 0 },
componentProps: {
class: '!w-full',
min: 1,
precision: 0,
},
rules: z.number().default(1),
},
{
fieldName: 'productionTime',
label: '生产用时',
component: 'InputNumber',
componentProps: { class: '!w-full', min: 0, precision: 2 },
componentProps: {
class: '!w-full',
min: 0,
precision: 2,
},
rules: z.number().default(1),
},
{
@ -406,7 +442,11 @@ export function useRouteProductFormSchema(
label: '备注',
component: 'Textarea',
formItemClass: 'col-span-2',
componentProps: { maxLength: 250, placeholder: '请输入备注', rows: 2 },
componentProps: {
maxLength: 250,
placeholder: '请输入备注',
rows: 2,
},
},
];
}
@ -441,7 +481,7 @@ export function useRouteProductBomFormSchema(
{
fieldName: 'itemId',
label: 'BOM 物料',
component: MdProductBomSelect as any,
component: markRaw(MdProductBomSelect),
componentProps: () => ({
itemId: itemId(),
onChange: onBomChange,
@ -453,14 +493,22 @@ export function useRouteProductBomFormSchema(
fieldName: 'quantity',
label: '用料比例',
component: 'InputNumber',
componentProps: { class: '!w-full', min: 0, precision: 2 },
componentProps: {
class: '!w-full',
min: 0,
precision: 2,
},
rules: z.number().default(1),
},
{
fieldName: 'remark',
label: '备注',
component: 'Textarea',
componentProps: { maxLength: 250, placeholder: '请输入备注', rows: 2 },
componentProps: {
maxLength: 250,
placeholder: '请输入备注',
rows: 2,
},
},
];
}

View File

@ -19,7 +19,10 @@ import { TmToolTypeSelect } from './type/components';
export type FormType = 'create' | 'detail' | 'update';
/** 新增/修改工具的表单 */
export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
export function useFormSchema(
formType: FormType,
formApi?: VbenFormApi,
): VbenFormSchema[] {
return [
{
fieldName: 'id',
@ -29,6 +32,15 @@ export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
show: () => false,
},
},
{
// 选中工具类型是否「编码管理」,用于锁定库存数量为 1隐藏字段
fieldName: 'codeFlag',
component: 'Input',
dependencies: {
triggerFields: [''],
show: () => false,
},
},
{
fieldName: 'code',
label: '工具编码',
@ -41,18 +53,21 @@ export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
componentProps: (values) => ({ disabled: !!values.id }),
},
rules: 'required',
suffix: () =>
h(
Button,
{
type: 'default',
onClick: async () => {
const code = await generateAutoCode(MesAutoCodeRuleCode.TM_TOOL_CODE);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '生成' },
),
suffix:
formType === 'detail'
? undefined
: () =>
h(
Button,
{
type: 'default',
onClick: async () => {
const code = await generateAutoCode(MesAutoCodeRuleCode.TM_TOOL_CODE);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '生成' },
),
},
{
fieldName: 'name',
@ -70,7 +85,9 @@ export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
componentProps: {
placeholder: '请选择工具类型',
onChange: async (row: any) => {
if (row?.codeFlag) {
// 记录是否编码管理;编码管理类型库存数量锁定为 1
await formApi?.setFieldValue('codeFlag', row?.codeFlag === true);
if (row?.codeFlag === true) {
await formApi?.setFieldValue('quantity', 1);
await formApi?.setFieldValue('availableQuantity', 1);
}
@ -110,6 +127,13 @@ export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
precision: 0,
},
rules: 'required',
// 编码管理类型库存数量锁定为 1禁止修改
dependencies: {
triggerFields: ['codeFlag'],
componentProps: (values) => ({
disabled: values.codeFlag === true,
}),
},
},
{
fieldName: 'availableQuantity',

View File

@ -87,10 +87,10 @@ const [Modal, modalApi] = useVbenModal({
formData.value = undefined;
return;
}
formApi.setState({ schema: useFormSchema(formApi) });
//
const data = modalApi.getData<{ formType: FormType; id?: number }>();
formType.value = data.formType;
formApi.setState({ schema: useFormSchema(data.formType, formApi) });
formApi.setDisabled(formType.value === 'detail');
modalApi.setState({ showConfirmButton: formType.value !== 'detail' });
if (!data?.id) {

View File

@ -16,7 +16,10 @@ import { generateAutoCode } from '#/api/mes/md/autocode/record';
export type FormType = 'create' | 'detail' | 'update';
/** 新增/修改工具类型的表单 */
export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
export function useFormSchema(
formType: FormType,
formApi?: VbenFormApi,
): VbenFormSchema[] {
return [
{
fieldName: 'id',
@ -34,18 +37,21 @@ export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
placeholder: '请输入类型编码',
},
rules: 'required',
suffix: () =>
h(
Button,
{
type: 'default',
onClick: async () => {
const code = await generateAutoCode(MesAutoCodeRuleCode.TM_TOOL_TYPE_CODE);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '生成' },
),
suffix:
formType === 'detail'
? undefined
: () =>
h(
Button,
{
type: 'default',
onClick: async () => {
const code = await generateAutoCode(MesAutoCodeRuleCode.TM_TOOL_TYPE_CODE);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '生成' },
),
},
{
fieldName: 'name',

View File

@ -71,10 +71,10 @@ const [Modal, modalApi] = useVbenModal({
formData.value = undefined;
return;
}
formApi.setState({ schema: useFormSchema(formApi) });
//
const data = modalApi.getData<{ formType: FormType; id?: number }>();
formType.value = data.formType;
formApi.setState({ schema: useFormSchema(data.formType, formApi) });
formApi.setDisabled(formType.value === 'detail');
modalApi.setState({ showConfirmButton: formType.value !== 'detail' });
if (!data?.id) {

View File

@ -5,17 +5,17 @@ import { requestClient } from '#/api/request';
export namespace MesWmBarcodeApi {
/** MES 条码清单 */
export interface Barcode {
id?: number;
configId?: number;
format?: number;
bizType?: number;
content?: string;
bizId?: number;
bizCode?: string;
bizName?: string;
status?: number;
remark?: string;
createTime?: Date;
id?: number; // 条码编号
configId?: number; // 条码配置编号
format?: number; // 条码格式
bizType?: number; // 业务类型
content?: string; // 条码内容
bizId?: number; // 业务对象编号
bizCode?: string; // 业务对象编码
bizName?: string; // 业务对象名称
status?: number; // 状态
remark?: string; // 备注
createTime?: Date; // 创建时间
}
}

View File

@ -39,22 +39,22 @@ export namespace MesWmBatchApi {
/** MES 批次分页查询参数 */
export interface PageParams extends PageParam {
code?: string;
itemId?: number;
vendorId?: number;
clientId?: number;
workOrderId?: number;
taskId?: number;
workstationId?: number;
toolId?: number;
moldId?: number;
salesOrderCode?: string;
purchaseOrderCode?: string;
lotNumber?: string;
qualityStatus?: number;
produceDate?: string[];
expireDate?: string[];
receiptDate?: string[];
code?: string; // 批次号
itemId?: number; // 物料编号
vendorId?: number; // 供应商编号
clientId?: number; // 客户编号
workOrderId?: number; // 工单编号
taskId?: number; // 生产任务编号
workstationId?: number; // 工作站编号
toolId?: number; // 工具编号
moldId?: number; // 模具编号
salesOrderCode?: string; // 销售订单号
purchaseOrderCode?: string; // 采购订单号
lotNumber?: string; // 批号
qualityStatus?: number; // 质量状态
produceDate?: string[]; // 生产日期
expireDate?: string[]; // 过期日期
receiptDate?: string[]; // 入库日期
}
}

View File

@ -27,11 +27,11 @@ export namespace MesWmSnApi {
/** MES SN 码分组分页查询参数 */
export interface PageParams extends PageParam {
uuid?: string;
code?: string;
itemId?: number;
batchCode?: string;
createTime?: string[];
uuid?: string; // 分组 UUID
code?: string; // SN 码
itemId?: number; // 物料编号
batchCode?: string; // 批次号
createTime?: string[]; // 创建时间
}
}

View File

@ -16,7 +16,10 @@ import { getRangePickerDefaultProps } from '#/utils';
export type FormType = 'create' | 'detail' | 'update';
/** 新增/修改排班计划的表单 */
export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
export function useFormSchema(
formType: FormType,
formApi?: VbenFormApi,
): VbenFormSchema[] {
return [
{
fieldName: 'id',
@ -43,17 +46,20 @@ export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
placeholder: '请输入计划编码',
},
rules: 'required',
suffix: () =>
h(
ElButton,
{
onClick: async () => {
const code = await generateAutoCode(MesAutoCodeRuleCode.CAL_PLAN_CODE);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '生成' },
),
suffix:
formType === 'detail'
? undefined
: () =>
h(
ElButton,
{
onClick: async () => {
const code = await generateAutoCode(MesAutoCodeRuleCode.CAL_PLAN_CODE);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '生成' },
),
},
{
fieldName: 'name',

View File

@ -104,11 +104,11 @@ const [Modal, modalApi] = useVbenModal({
formData.value = undefined;
return;
}
formApi.setState({ schema: useFormSchema(formApi) });
subTabsName.value = 'shift';
//
const data = modalApi.getData<{ formType: FormType; id?: number }>();
formType.value = data.formType;
formApi.setState({ schema: useFormSchema(data.formType, formApi) });
formApi.setDisabled(formType.value === 'detail');
modalApi.setState({ showConfirmButton: formType.value !== 'detail' });
if (!data?.id) {

View File

@ -16,7 +16,10 @@ import { generateAutoCode } from '#/api/mes/md/autocode/record';
export type FormType = 'create' | 'detail' | 'update';
/** 新增/修改班组的表单 */
export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
export function useFormSchema(
formType: FormType,
formApi?: VbenFormApi,
): VbenFormSchema[] {
return [
{
fieldName: 'id',
@ -35,17 +38,20 @@ export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
placeholder: '请输入班组编码',
},
rules: z.string().min(1, '班组编码不能为空').max(64),
suffix: () =>
h(
ElButton,
{
onClick: async () => {
const code = await generateAutoCode(MesAutoCodeRuleCode.CAL_TEAM_CODE);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '生成' },
),
suffix:
formType === 'detail'
? undefined
: () =>
h(
ElButton,
{
onClick: async () => {
const code = await generateAutoCode(MesAutoCodeRuleCode.CAL_TEAM_CODE);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '生成' },
),
},
{
fieldName: 'name',

View File

@ -79,11 +79,11 @@ const [Modal, modalApi] = useVbenModal({
formData.value = undefined;
return;
}
formApi.setState({ schema: useFormSchema(formApi) });
subTabsName.value = 'member';
//
const data = modalApi.getData<{ formType: FormType; id?: number }>();
formType.value = data.formType;
formApi.setState({ schema: useFormSchema(data.formType, formApi) });
formApi.setDisabled(formType.value === 'detail');
modalApi.setState({ showConfirmButton: formType.value !== 'detail' });
if (!data?.id) {

View File

@ -17,7 +17,10 @@ import { getRangePickerDefaultProps } from '#/utils';
export type FormType = 'create' | 'detail' | 'update';
/** 新增/修改点检保养方案的表单 */
export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
export function useFormSchema(
formType: FormType,
formApi?: VbenFormApi,
): VbenFormSchema[] {
return [
{
fieldName: 'id',
@ -44,17 +47,20 @@ export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
placeholder: '请输入方案编码',
},
rules: 'required',
suffix: () =>
h(
ElButton,
{
onClick: async () => {
const code = await generateAutoCode(MesAutoCodeRuleCode.DV_CHECK_PLAN_CODE);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '生成' },
),
suffix:
formType === 'detail'
? undefined
: () =>
h(
ElButton,
{
onClick: async () => {
const code = await generateAutoCode(MesAutoCodeRuleCode.DV_CHECK_PLAN_CODE);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '生成' },
),
},
{
fieldName: 'name',

View File

@ -78,11 +78,11 @@ const [Modal, modalApi] = useVbenModal({
formData.value = undefined;
return;
}
formApi.setState({ schema: useFormSchema(formApi) });
subTabsName.value = 'machinery';
//
const data = modalApi.getData<{ formType: FormType; id?: number }>();
formType.value = data.formType;
formApi.setState({ schema: useFormSchema(data.formType, formApi) });
formApi.setDisabled(formType.value === 'detail');
modalApi.setState({ showConfirmButton: formType.value !== 'detail' });
if (!data?.id) {

View File

@ -41,17 +41,20 @@ export function useFormSchema(formType: FormType, formApi?: VbenFormApi): VbenFo
componentProps: (values) => ({ disabled: !!values.id }),
},
rules: 'required',
suffix: () =>
h(
ElButton,
{
onClick: async () => {
const code = await generateAutoCode(MesAutoCodeRuleCode.DV_MACHINERY_CODE);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '生成' },
),
suffix:
formType === 'detail'
? undefined
: () =>
h(
ElButton,
{
onClick: async () => {
const code = await generateAutoCode(MesAutoCodeRuleCode.DV_MACHINERY_CODE);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '生成' },
),
},
{
fieldName: 'name',

View File

@ -14,8 +14,14 @@ import { z } from '#/adapter/form';
import { getMachineryTypeList } from '#/api/mes/dv/machinery/type';
import { generateAutoCode } from '#/api/mes/md/autocode/record';
/** 表单类型 */
export type FormType = 'create' | 'detail' | 'update';
/** 新增/修改设备类型的表单 */
export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
export function useFormSchema(
formType: FormType,
formApi?: VbenFormApi,
): VbenFormSchema[] {
return [
{
fieldName: 'id',
@ -51,17 +57,22 @@ export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
placeholder: '请输入类型编码',
},
rules: z.string().min(1, '类型编码不能为空').max(64),
suffix: () =>
h(
ElButton,
{
onClick: async () => {
const code = await generateAutoCode(MesAutoCodeRuleCode.DV_MACHINERY_TYPE_CODE);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '生成' },
),
suffix:
formType === 'detail'
? undefined
: () =>
h(
ElButton,
{
onClick: async () => {
const code = await generateAutoCode(
MesAutoCodeRuleCode.DV_MACHINERY_TYPE_CODE,
);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '生成' },
),
},
{
fieldName: 'name',

View File

@ -64,9 +64,11 @@ const [Modal, modalApi] = useVbenModal({
formData.value = undefined;
return;
}
formApi.setState({ schema: useFormSchema(formApi) });
//
const data = modalApi.getData<MesDvMachineryTypeApi.MachineryType>();
formApi.setState({
schema: useFormSchema(data?.id ? 'update' : 'create', formApi),
});
if (!data || !data.id) {
formData.value = data || undefined;
if (data) {

View File

@ -16,8 +16,17 @@ import { DvMachinerySelect } from '#/views/mes/dv/machinery/components';
/** 表单类型 */
export type FormType = 'confirm' | 'create' | 'detail' | 'finish' | 'update';
/** 表头是否只读完成维修、验收、详情态finishDate 在 confirm 单独放开) */
function isHeaderReadonly(formType: FormType): boolean {
return ['confirm', 'detail', 'finish'].includes(formType);
}
/** 新增/修改维修工单的表单 */
export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
export function useFormSchema(
formType: FormType,
formApi?: VbenFormApi,
): VbenFormSchema[] {
const headerReadonly = isHeaderReadonly(formType);
return [
{
fieldName: 'id',
@ -45,26 +54,29 @@ export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
},
dependencies: {
triggerFields: ['id'],
componentProps: (values) => ({ disabled: !!values.id }),
componentProps: (values) => ({ disabled: headerReadonly || !!values.id }),
},
rules: 'required',
suffix: () =>
h(
ElButton,
{
onClick: async () => {
const code = await generateAutoCode(MesAutoCodeRuleCode.DV_REPAIR_CODE);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '生成' },
),
suffix: headerReadonly
? undefined
: () =>
h(
ElButton,
{
onClick: async () => {
const code = await generateAutoCode(MesAutoCodeRuleCode.DV_REPAIR_CODE);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '生成' },
),
},
{
fieldName: 'name',
label: '维修单名称',
component: 'Input',
componentProps: {
disabled: headerReadonly,
placeholder: '请输入维修单名称',
},
rules: 'required',
@ -74,6 +86,7 @@ export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
label: '设备',
component: markRaw(DvMachinerySelect),
componentProps: {
disabled: headerReadonly,
placeholder: '请选择设备',
},
rules: 'selectRequired',
@ -84,6 +97,7 @@ export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
component: 'DatePicker',
componentProps: {
class: '!w-full',
disabled: headerReadonly,
format: 'YYYY-MM-DD HH:mm:ss',
placeholder: '请选择报修日期',
showTime: true,
@ -98,10 +112,18 @@ export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
componentProps: {
clearable: true,
api: getSimpleUserList,
disabled: true,
labelField: 'nickname',
placeholder: '请选择维修人',
valueField: 'id',
},
// 维修人为待验收(≥APPROVING)态自动产生的只读回显字段
dependencies: {
triggerFields: ['status'],
if: (values) =>
values.status != null &&
values.status >= MesDvRepairStatusEnum.APPROVING,
},
},
{
fieldName: 'finishDate',
@ -114,6 +136,15 @@ export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
showTime: true,
valueFormat: 'x',
},
// 维修中(≥CONFIRMED)态展示;仅"完成维修"弹窗可编辑并必填,其余态只读回显
dependencies: {
triggerFields: ['status'],
if: (values) =>
values.status != null &&
values.status >= MesDvRepairStatusEnum.CONFIRMED,
disabled: formType !== 'confirm',
rules: () => (formType === 'confirm' ? 'required' : null),
},
},
{
fieldName: 'confirmUserId',
@ -122,10 +153,18 @@ export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
componentProps: {
clearable: true,
api: getSimpleUserList,
disabled: true,
labelField: 'nickname',
placeholder: '请选择验收人',
valueField: 'id',
},
// 验收信息为已确认(≥FINISHED)态自动产生的只读回显字段
dependencies: {
triggerFields: ['status'],
if: (values) =>
values.status != null &&
values.status >= MesDvRepairStatusEnum.FINISHED,
},
},
{
fieldName: 'confirmDate',
@ -133,19 +172,35 @@ export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
component: 'DatePicker',
componentProps: {
class: '!w-full',
disabled: true,
format: 'YYYY-MM-DD HH:mm:ss',
placeholder: '请选择验收日期',
showTime: true,
valueFormat: 'x',
},
// 验收信息为已确认(≥FINISHED)态自动产生的只读回显字段
dependencies: {
triggerFields: ['status'],
if: (values) =>
values.status != null &&
values.status >= MesDvRepairStatusEnum.FINISHED,
},
},
{
fieldName: 'result',
label: '维修结果',
component: 'RadioGroup',
componentProps: {
disabled: true,
options: getDictOptions(DICT_TYPE.MES_DV_REPAIR_RESULT, 'number'),
},
// 验收信息为已确认(≥FINISHED)态自动产生的只读回显字段
dependencies: {
triggerFields: ['status'],
if: (values) =>
values.status != null &&
values.status >= MesDvRepairStatusEnum.FINISHED,
},
},
{
fieldName: 'remark',
@ -153,6 +208,7 @@ export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
component: 'Textarea',
formItemClass: 'col-span-3',
componentProps: {
disabled: headerReadonly,
placeholder: '请输入备注',
rows: 3,
},

View File

@ -28,20 +28,29 @@ const emit = defineEmits(['success']);
const formType = ref<FormType>('create');
const formData = ref<MesDvRepairApi.Repair>();
const isDetail = computed(() => formType.value === 'detail');
const isReadonly = computed(() => ['confirm', 'detail', 'finish'].includes(formType.value));
const isLineReadonly = computed(() =>
// //
['confirm', 'detail', 'finish'].includes(formType.value),
);
const isFormDisabled = computed(() =>
// / finishDate schema
['detail', 'finish'].includes(formType.value),
);
const canSubmit = computed(
() => formType.value === 'update' && formData.value?.status === MesDvRepairStatusEnum.PREPARE,
);
const getTitle = computed(
() =>
({
create: '新增维修工单',
update: '修改维修工单',
confirm: '完成维修',
finish: '验收维修',
detail: '查看维修工单',
})[formType.value],
);
const getTitle = computed(() => {
if (formType.value === 'detail') {
return '查看维修工单';
}
if (formType.value === 'confirm') {
return '完成维修';
}
if (formType.value === 'finish') {
return '验收维修';
}
return formType.value === 'update' ? '修改维修工单' : '新增维修工单';
});
const [Form, formApi] = useVbenForm({
commonConfig: {
@ -161,11 +170,11 @@ const [Modal, modalApi] = useVbenModal({
formData.value = undefined;
return;
}
formApi.setState({ schema: useFormSchema(formApi) });
//
const data = modalApi.getData<{ formType: FormType; id?: number }>();
formType.value = data.formType;
formApi.setDisabled(isReadonly.value);
formApi.setState({ schema: useFormSchema(data.formType, formApi) });
formApi.setDisabled(isFormDisabled.value);
modalApi.setState({ showConfirmButton: ['create', 'update'].includes(formType.value) });
if (!data?.id) {
return;
@ -184,7 +193,7 @@ const [Modal, modalApi] = useVbenModal({
<template>
<Modal :title="getTitle" class="w-4/5">
<Form class="mx-4" />
<LineList v-if="formData?.id" :disabled="isReadonly" :repair-id="formData.id" />
<LineList v-if="formData?.id" :disabled="isLineReadonly" :repair-id="formData.id" />
<template #prepend-footer>
<div class="flex flex-auto items-center gap-2">
<ElPopconfirm

View File

@ -21,7 +21,10 @@ import { generateAutoCode } from '#/api/mes/md/autocode/record';
export type FormType = 'create' | 'detail' | 'update';
/** 新增/修改点检保养项目的表单 */
export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
export function useFormSchema(
formType: FormType,
formApi?: VbenFormApi,
): VbenFormSchema[] {
return [
{
fieldName: 'id',
@ -39,17 +42,20 @@ export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
placeholder: '请输入项目编码',
},
rules: 'required',
suffix: () =>
h(
ElButton,
{
onClick: async () => {
const code = await generateAutoCode(MesAutoCodeRuleCode.DV_SUBJECT_CODE);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '生成' },
),
suffix:
formType === 'detail'
? undefined
: () =>
h(
ElButton,
{
onClick: async () => {
const code = await generateAutoCode(MesAutoCodeRuleCode.DV_SUBJECT_CODE);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '生成' },
),
},
{
fieldName: 'name',

View File

@ -66,10 +66,10 @@ const [Modal, modalApi] = useVbenModal({
if (!isOpen) {
return;
}
formApi.setState({ schema: useFormSchema(formApi) });
//
const data = modalApi.getData<{ formType: FormType; id?: number }>();
formType.value = data.formType;
formApi.setState({ schema: useFormSchema(data.formType, formApi) });
formApi.setDisabled(formType.value === 'detail');
modalApi.setState({ showConfirmButton: formType.value !== 'detail' });
if (!data?.id) {

View File

@ -16,7 +16,10 @@ import { generateAutoCode } from '#/api/mes/md/autocode/record';
export type FormType = 'create' | 'detail' | 'update';
/** 新增/修改客户的表单 */
export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
export function useFormSchema(
formType: FormType,
formApi?: VbenFormApi,
): VbenFormSchema[] {
return [
{
fieldName: 'id',
@ -34,19 +37,22 @@ export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
placeholder: '请输入客户编码',
},
rules: 'required',
suffix: () =>
h(
ElButton,
{
onClick: async () => {
const code = await generateAutoCode(
MesAutoCodeRuleCode.MD_CLIENT_CODE,
);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '自动生成' },
),
suffix:
formType === 'detail'
? undefined
: () =>
h(
ElButton,
{
onClick: async () => {
const code = await generateAutoCode(
MesAutoCodeRuleCode.MD_CLIENT_CODE,
);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '自动生成' },
),
},
{
fieldName: 'name',

View File

@ -72,11 +72,11 @@ const [Modal, modalApi] = useVbenModal({
formData.value = undefined;
return;
}
formApi.setState({ schema: useFormSchema(formApi) });
subTabsName.value = 'productSalesLine';
//
const data = modalApi.getData<{ formType: FormType; id?: number }>();
formType.value = data.formType;
formApi.setState({ schema: useFormSchema(data.formType, formApi) });
formApi.setDisabled(formType.value === 'detail');
modalApi.setState({ showConfirmButton: formType.value !== 'detail' });
if (!data?.id) {

View File

@ -33,11 +33,31 @@ const [Grid] = useVbenVxeGrid({
width: 140,
slots: { default: 'itemCode' },
},
{ field: 'itemName', title: '物料名称', minWidth: 150 },
{ field: 'specification', title: '规格型号', minWidth: 140 },
{ field: 'unitMeasureName', title: '单位', width: 100 },
{ field: 'quantity', title: '出库数量', width: 120 },
{ field: 'batchCode', title: '批次号', minWidth: 140 },
{
field: 'itemName',
title: '物料名称',
minWidth: 150,
},
{
field: 'specification',
title: '规格型号',
minWidth: 140,
},
{
field: 'unitMeasureName',
title: '单位',
width: 100,
},
{
field: 'quantity',
title: '出库数量',
width: 120,
},
{
field: 'batchCode',
title: '批次号',
minWidth: 140,
},
],
height: 320,
keepSource: true,

View File

@ -14,9 +14,21 @@ const props = defineProps<{
const [Grid] = useVbenVxeGrid({
gridOptions: {
columns: [
{ field: 'code', title: '出库单编号', minWidth: 160 },
{ field: 'name', title: '出库单名称', minWidth: 150 },
{ field: 'salesOrderCode', title: '销售订单编号', minWidth: 140 },
{
field: 'code',
title: '出库单编号',
minWidth: 160,
},
{
field: 'name',
title: '出库单名称',
minWidth: 150,
},
{
field: 'salesOrderCode',
title: '销售订单编号',
minWidth: 140,
},
{
field: 'salesDate',
title: '出库日期',

View File

@ -19,7 +19,10 @@ import { MdUnitMeasureSelect } from '#/views/mes/md/unitmeasure/components';
export type FormType = 'create' | 'detail' | 'update';
/** 新增/修改物料产品的表单 */
export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
export function useFormSchema(
formType: FormType,
formApi?: VbenFormApi,
): VbenFormSchema[] {
return [
{
fieldName: 'id',
@ -38,19 +41,22 @@ export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
placeholder: '请输入物料编码',
},
rules: z.string().min(1, '物料编码不能为空').max(64),
suffix: () =>
h(
ElButton,
{
onClick: async () => {
const code = await generateAutoCode(
MesAutoCodeRuleCode.MD_ITEM_CODE,
);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '生成' },
),
suffix:
formType === 'detail'
? undefined
: () =>
h(
ElButton,
{
onClick: async () => {
const code = await generateAutoCode(
MesAutoCodeRuleCode.MD_ITEM_CODE,
);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '生成' },
),
},
{
fieldName: 'name',

View File

@ -100,11 +100,11 @@ const [Modal, modalApi] = useVbenModal({
formData.value = undefined;
return;
}
formApi.setState({ schema: useFormSchema(formApi) });
subTabsName.value = 'bom';
//
const data = modalApi.getData<{ formType: FormType; id?: number }>();
formType.value = data.formType;
formApi.setState({ schema: useFormSchema(data.formType, formApi) });
formApi.setDisabled(formType.value === 'detail');
modalApi.setState({ showConfirmButton: formType.value !== 'detail' });
if (!data?.id) {

View File

@ -68,25 +68,33 @@ const [Form, formApi] = useVbenForm({
fieldName: 'bomItemCode',
label: 'BOM 物料编码',
component: 'Input',
componentProps: { disabled: true },
componentProps: {
disabled: true,
},
},
{
fieldName: 'bomItemName',
label: 'BOM 物料名称',
component: 'Input',
componentProps: { disabled: true },
componentProps: {
disabled: true,
},
},
{
fieldName: 'bomItemSpecification',
label: '规格型号',
component: 'Input',
componentProps: { disabled: true },
componentProps: {
disabled: true,
},
},
{
fieldName: 'unitMeasureName',
label: '单位',
component: 'Input',
componentProps: { disabled: true },
componentProps: {
disabled: true,
},
},
{
fieldName: 'quantity',
@ -105,7 +113,10 @@ const [Form, formApi] = useVbenForm({
fieldName: 'remark',
label: '备注',
component: 'Textarea',
componentProps: { placeholder: '请输入备注', rows: 3 },
componentProps: {
placeholder: '请输入备注',
rows: 3,
},
},
],
showDefaultActions: false,

View File

@ -78,7 +78,9 @@ const [Form, formApi] = useVbenForm({
fieldName: 'title',
label: '标题',
component: 'Input',
componentProps: { placeholder: '请输入标题' },
componentProps: {
placeholder: '请输入标题',
},
rules: 'required',
},
{
@ -97,7 +99,10 @@ const [Form, formApi] = useVbenForm({
fieldName: 'description',
label: '内容说明',
component: 'Textarea',
componentProps: { placeholder: '请输入详细描述', rows: 3 },
componentProps: {
placeholder: '请输入详细描述',
rows: 3,
},
},
{
fieldName: 'processId',
@ -108,13 +113,19 @@ const [Form, formApi] = useVbenForm({
fieldName: 'url',
label: '图片',
component: markRaw(ImageUpload),
componentProps: { maxNumber: 1, showDescription: false },
componentProps: {
maxNumber: 1,
showDescription: false,
},
},
{
fieldName: 'remark',
label: '备注',
component: 'Textarea',
componentProps: { placeholder: '请输入备注', rows: 3 },
componentProps: {
placeholder: '请输入备注',
rows: 3,
},
},
],
showDefaultActions: false,

View File

@ -19,8 +19,14 @@ import { z } from '#/adapter/form';
import { generateAutoCode } from '#/api/mes/md/autocode/record';
import { getItemTypeList } from '#/api/mes/md/item/type';
/** 表单类型 */
export type FormType = 'create' | 'detail' | 'update';
/** 新增/修改物料分类的表单 */
export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
export function useFormSchema(
formType: FormType,
formApi?: VbenFormApi,
): VbenFormSchema[] {
return [
{
fieldName: 'id',
@ -64,19 +70,22 @@ export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
placeholder: '请输入分类编码',
},
rules: z.string().min(1, '分类编码不能为空').max(64),
suffix: () =>
h(
ElButton,
{
onClick: async () => {
const code = await generateAutoCode(
MesAutoCodeRuleCode.MD_ITEM_TYPE_CODE,
);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '自动生成' },
),
suffix:
formType === 'detail'
? undefined
: () =>
h(
ElButton,
{
onClick: async () => {
const code = await generateAutoCode(
MesAutoCodeRuleCode.MD_ITEM_TYPE_CODE,
);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '自动生成' },
),
},
{
fieldName: 'name',

View File

@ -62,9 +62,11 @@ const [Modal, modalApi] = useVbenModal({
formData.value = undefined;
return;
}
formApi.setState({ schema: useFormSchema(formApi) });
//
const data = modalApi.getData<MesMdItemTypeApi.ItemType>();
formApi.setState({
schema: useFormSchema(data?.id ? 'update' : 'create', formApi),
});
if (!data || !data.id) {
formData.value = data || undefined;
if (data) {

View File

@ -16,7 +16,10 @@ import { generateAutoCode } from '#/api/mes/md/autocode/record';
export type FormType = 'create' | 'detail' | 'update';
/** 新增/修改供应商的表单 */
export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
export function useFormSchema(
formType: FormType,
formApi?: VbenFormApi,
): VbenFormSchema[] {
return [
{
fieldName: 'id',
@ -34,19 +37,22 @@ export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
placeholder: '请输入供应商编码',
},
rules: 'required',
suffix: () =>
h(
ElButton,
{
onClick: async () => {
const code = await generateAutoCode(
MesAutoCodeRuleCode.MD_VENDOR_CODE,
);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '自动生成' },
),
suffix:
formType === 'detail'
? undefined
: () =>
h(
ElButton,
{
onClick: async () => {
const code = await generateAutoCode(
MesAutoCodeRuleCode.MD_VENDOR_CODE,
);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '自动生成' },
),
},
{
fieldName: 'name',

View File

@ -74,11 +74,11 @@ const [Modal, modalApi] = useVbenModal({
formData.value = undefined;
return;
}
formApi.setState({ schema: useFormSchema(formApi) });
subTabsName.value = 'itemReceiptLine';
//
const data = modalApi.getData<{ formType: FormType; id?: number }>();
formType.value = data.formType;
formApi.setState({ schema: useFormSchema(data.formType, formApi) });
formApi.setDisabled(formType.value === 'detail');
modalApi.setState({ showConfirmButton: formType.value !== 'detail' });
if (!data?.id) {

View File

@ -31,12 +31,36 @@ function formatDate(value: Date | number | string | undefined) {
const [Grid, gridApi] = useVbenVxeGrid({
gridOptions: {
columns: [
{ field: 'itemCode', title: '物料编码', width: 140 },
{ field: 'itemName', title: '物料名称', minWidth: 150 },
{ field: 'specification', title: '规格型号', minWidth: 140 },
{ field: 'unitMeasureName', title: '单位', width: 100 },
{ field: 'receivedQuantity', title: '入库数量', width: 120 },
{ field: 'batchCode', title: '批次号', minWidth: 140 },
{
field: 'itemCode',
title: '物料编码',
width: 140,
},
{
field: 'itemName',
title: '物料名称',
minWidth: 150,
},
{
field: 'specification',
title: '规格型号',
minWidth: 140,
},
{
field: 'unitMeasureName',
title: '单位',
width: 100,
},
{
field: 'receivedQuantity',
title: '入库数量',
width: 120,
},
{
field: 'batchCode',
title: '批次号',
minWidth: 140,
},
],
height: 280,
keepSource: true,

View File

@ -33,11 +33,31 @@ const [Grid] = useVbenVxeGrid({
width: 140,
slots: { default: 'itemCode' },
},
{ field: 'itemName', title: '物料名称', minWidth: 150 },
{ field: 'specification', title: '规格型号', minWidth: 140 },
{ field: 'unitMeasureName', title: '单位', width: 100 },
{ field: 'receivedQuantity', title: '入库数量', width: 120 },
{ field: 'batchCode', title: '批次号', minWidth: 140 },
{
field: 'itemName',
title: '物料名称',
minWidth: 150,
},
{
field: 'specification',
title: '规格型号',
minWidth: 140,
},
{
field: 'unitMeasureName',
title: '单位',
width: 100,
},
{
field: 'receivedQuantity',
title: '入库数量',
width: 120,
},
{
field: 'batchCode',
title: '批次号',
minWidth: 140,
},
],
height: 320,
keepSource: true,

View File

@ -36,12 +36,36 @@ const [Grid] = useVbenVxeGrid({
minWidth: 160,
slots: { default: 'receiptCode' },
},
{ field: 'purchaseOrderCode', title: '采购订单号', minWidth: 150 },
{ field: 'itemCode', title: '物料编码', width: 140 },
{ field: 'itemName', title: '物料名称', minWidth: 150 },
{ field: 'specification', title: '规格型号', minWidth: 140 },
{ field: 'unitMeasureName', title: '单位', width: 100 },
{ field: 'receivedQuantity', title: '入库数量', width: 120 },
{
field: 'purchaseOrderCode',
title: '采购订单号',
minWidth: 150,
},
{
field: 'itemCode',
title: '物料编码',
width: 140,
},
{
field: 'itemName',
title: '物料名称',
minWidth: 150,
},
{
field: 'specification',
title: '规格型号',
minWidth: 140,
},
{
field: 'unitMeasureName',
title: '单位',
width: 100,
},
{
field: 'receivedQuantity',
title: '入库数量',
width: 120,
},
],
height: 320,
keepSource: true,

View File

@ -22,7 +22,10 @@ import { MdWorkshopSelect } from './components';
export type FormType = 'create' | 'detail' | 'update';
/** 新增/修改工作站的表单 */
export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
export function useFormSchema(
formType: FormType,
formApi?: VbenFormApi,
): VbenFormSchema[] {
return [
{
fieldName: 'id',
@ -40,19 +43,22 @@ export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
placeholder: '请输入工作站编码',
},
rules: 'required',
suffix: () =>
h(
ElButton,
{
onClick: async () => {
const code = await generateAutoCode(
MesAutoCodeRuleCode.MD_WORKSTATION_CODE,
);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '生成' },
),
suffix:
formType === 'detail'
? undefined
: () =>
h(
ElButton,
{
onClick: async () => {
const code = await generateAutoCode(
MesAutoCodeRuleCode.MD_WORKSTATION_CODE,
);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '生成' },
),
},
{
fieldName: 'name',

View File

@ -99,11 +99,11 @@ const [Modal, modalApi] = useVbenModal({
formData.value = undefined;
return;
}
formApi.setState({ schema: useFormSchema(formApi) });
subTabsName.value = 'machine';
//
const data = modalApi.getData<{ formType: FormType; id?: number }>();
formType.value = data.formType;
formApi.setState({ schema: useFormSchema(data.formType, formApi) });
formApi.setDisabled(formType.value === 'detail');
modalApi.setState({ showConfirmButton: formType.value !== 'detail' });
if (!data?.id) {

View File

@ -79,7 +79,10 @@ const [Form, formApi] = useVbenForm({
fieldName: 'remark',
label: '备注',
component: 'Textarea',
componentProps: { placeholder: '请输入备注', rows: 3 },
componentProps: {
placeholder: '请输入备注',
rows: 3,
},
},
],
showDefaultActions: false,
@ -90,10 +93,26 @@ const [Grid, gridApi] = useVbenVxeGrid({
autoResize: true,
border: true,
columns: [
{ field: 'machineryCode', title: '设备编码', width: 140 },
{ field: 'machineryName', title: '设备名称', minWidth: 160 },
{ field: 'quantity', title: '数量', width: 100 },
{ field: 'remark', title: '备注', minWidth: 160 },
{
field: 'machineryCode',
title: '设备编码',
width: 140,
},
{
field: 'machineryName',
title: '设备名称',
minWidth: 160,
},
{
field: 'quantity',
title: '数量',
width: 100,
},
{
field: 'remark',
title: '备注',
minWidth: 160,
},
{
title: '操作',
width: 90,

View File

@ -90,7 +90,10 @@ const [Form, formApi] = useVbenForm({
fieldName: 'remark',
label: '备注',
component: 'Textarea',
componentProps: { placeholder: '请输入备注', rows: 3 },
componentProps: {
placeholder: '请输入备注',
rows: 3,
},
},
],
showDefaultActions: false,
@ -101,10 +104,26 @@ const [Grid, gridApi] = useVbenVxeGrid({
autoResize: true,
border: true,
columns: [
{ field: 'toolTypeId', title: '工具类型编号', width: 140 },
{ field: 'toolTypeName', title: '工具类型名称', minWidth: 160 },
{ field: 'quantity', title: '数量', width: 100 },
{ field: 'remark', title: '备注', minWidth: 160 },
{
field: 'toolTypeId',
title: '工具类型编号',
width: 140,
},
{
field: 'toolTypeName',
title: '工具类型名称',
minWidth: 160,
},
{
field: 'quantity',
title: '数量',
width: 100,
},
{
field: 'remark',
title: '备注',
minWidth: 160,
},
{
title: '操作',
width: 130,

View File

@ -86,7 +86,10 @@ const [Form, formApi] = useVbenForm({
fieldName: 'remark',
label: '备注',
component: 'Textarea',
componentProps: { placeholder: '请输入备注', rows: 3 },
componentProps: {
placeholder: '请输入备注',
rows: 3,
},
},
],
showDefaultActions: false,
@ -97,10 +100,26 @@ const [Grid, gridApi] = useVbenVxeGrid({
autoResize: true,
border: true,
columns: [
{ field: 'postId', title: '岗位编号', width: 140 },
{ field: 'postName', title: '岗位名称', minWidth: 160 },
{ field: 'quantity', title: '数量', width: 100 },
{ field: 'remark', title: '备注', minWidth: 160 },
{
field: 'postId',
title: '岗位编号',
width: 140,
},
{
field: 'postName',
title: '岗位名称',
minWidth: 160,
},
{
field: 'quantity',
title: '数量',
width: 100,
},
{
field: 'remark',
title: '备注',
minWidth: 160,
},
{
title: '操作',
width: 130,

View File

@ -17,7 +17,10 @@ import { getSimpleUserList } from '#/api/system/user';
export type FormType = 'create' | 'detail' | 'update';
/** 新增/修改车间的表单 */
export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
export function useFormSchema(
formType: FormType,
formApi?: VbenFormApi,
): VbenFormSchema[] {
return [
{
fieldName: 'id',
@ -41,19 +44,22 @@ export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
}),
},
rules: 'required',
suffix: () =>
h(
ElButton,
{
onClick: async () => {
const code = await generateAutoCode(
MesAutoCodeRuleCode.MD_WORKSHOP_CODE,
);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '生成' },
),
suffix:
formType === 'detail'
? undefined
: () =>
h(
ElButton,
{
onClick: async () => {
const code = await generateAutoCode(
MesAutoCodeRuleCode.MD_WORKSHOP_CODE,
);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '生成' },
),
},
{
fieldName: 'name',

View File

@ -89,10 +89,10 @@ const [Modal, modalApi] = useVbenModal({
formData.value = undefined;
return;
}
formApi.setState({ schema: useFormSchema(formApi) });
//
const data = modalApi.getData<{ formType: FormType; id?: number }>();
formType.value = data.formType;
formApi.setState({ schema: useFormSchema(data.formType, formApi) });
formApi.setDisabled(formType.value === 'detail');
modalApi.setState({ showConfirmButton: formType.value !== 'detail' });
if (!data?.id) {

View File

@ -326,7 +326,9 @@ export function useFormSchema(
fieldName: 'itemCode',
label: '产品编码',
component: 'Input',
componentProps: { disabled: true },
componentProps: {
disabled: true,
},
dependencies: {
triggerFields: ['itemCode'],
show: (values) => !!values.itemCode,
@ -336,7 +338,9 @@ export function useFormSchema(
fieldName: 'itemName',
label: '产品名称',
component: 'Input',
componentProps: { disabled: true },
componentProps: {
disabled: true,
},
dependencies: {
triggerFields: ['itemCode'],
show: (values) => !!values.itemCode,
@ -346,7 +350,9 @@ export function useFormSchema(
fieldName: 'unitMeasureName',
label: '单位',
component: 'Input',
componentProps: { disabled: true },
componentProps: {
disabled: true,
},
dependencies: {
triggerFields: ['itemCode'],
show: (values) => !!values.itemCode,
@ -356,7 +362,9 @@ export function useFormSchema(
fieldName: 'itemSpecification',
label: '规格',
component: 'Input',
componentProps: { disabled: true },
componentProps: {
disabled: true,
},
dependencies: {
triggerFields: ['itemCode'],
show: (values) => !!values.itemCode,

View File

@ -5,7 +5,7 @@ import type { MesProRouteProcessApi } from '#/api/mes/pro/route/process';
import type { MesProRouteProductApi } from '#/api/mes/pro/route/product';
import type { MesProRouteProductBomApi } from '#/api/mes/pro/route/productbom';
import { h } from 'vue';
import { h, markRaw } from 'vue';
import { CommonStatusEnum, DICT_TYPE, MesAutoCodeRuleCode } from '@vben/constants';
import { getDictOptions } from '@vben/hooks';
@ -97,13 +97,19 @@ export function useGridFormSchema(): VbenFormSchema[] {
fieldName: 'code',
label: '路线编码',
component: 'Input',
componentProps: { clearable: true, placeholder: '请输入路线编码' },
componentProps: {
clearable: true,
placeholder: '请输入路线编码',
},
},
{
fieldName: 'name',
label: '路线名称',
component: 'Input',
componentProps: { clearable: true, placeholder: '请输入路线名称' },
componentProps: {
clearable: true,
placeholder: '请输入路线名称',
},
},
{
fieldName: 'status',
@ -225,14 +231,20 @@ export function useRouteProcessFormSchema(
fieldName: 'keyFlag',
label: '是否关键工序',
component: 'Switch',
componentProps: { activeText: '是', inactiveText: '否' },
componentProps: {
activeText: '是',
inactiveText: '否',
},
rules: z.boolean().default(false),
},
{
fieldName: 'checkFlag',
label: '是否质检确认',
component: 'Switch',
componentProps: { activeText: '是', inactiveText: '否' },
componentProps: {
activeText: '是',
inactiveText: '否',
},
rules: z.boolean().default(false),
},
{
@ -264,7 +276,11 @@ export function useRouteProcessFormSchema(
label: '备注',
component: 'Textarea',
formItemClass: 'col-span-2',
componentProps: { maxLength: 250, placeholder: '请输入备注', rows: 2 },
componentProps: {
maxLength: 250,
placeholder: '请输入备注',
rows: 2,
},
},
];
}
@ -383,7 +399,7 @@ export function useRouteProductFormSchema(
{
fieldName: 'itemId',
label: '产品',
component: MdItemSelect as any,
component: markRaw(MdItemSelect),
componentProps: {
onChange: onItemChange,
},
@ -430,7 +446,11 @@ export function useRouteProductFormSchema(
label: '备注',
component: 'Textarea',
formItemClass: 'col-span-2',
componentProps: { maxLength: 250, placeholder: '请输入备注', rows: 2 },
componentProps: {
maxLength: 250,
placeholder: '请输入备注',
rows: 2,
},
},
];
}
@ -465,7 +485,7 @@ export function useRouteProductBomFormSchema(
{
fieldName: 'itemId',
label: 'BOM 物料',
component: MdProductBomSelect as any,
component: markRaw(MdProductBomSelect),
componentProps: () => ({
itemId: itemId(),
onChange: onBomChange,
@ -489,7 +509,11 @@ export function useRouteProductBomFormSchema(
fieldName: 'remark',
label: '备注',
component: 'Textarea',
componentProps: { maxLength: 250, placeholder: '请输入备注', rows: 2 },
componentProps: {
maxLength: 250,
placeholder: '请输入备注',
rows: 2,
},
},
];
}

View File

@ -19,7 +19,10 @@ import { TmToolTypeSelect } from './type/components';
export type FormType = 'create' | 'detail' | 'update';
/** 新增/修改工具的表单 */
export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
export function useFormSchema(
formType: FormType,
formApi?: VbenFormApi,
): VbenFormSchema[] {
return [
{
fieldName: 'id',
@ -29,6 +32,15 @@ export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
show: () => false,
},
},
{
// 选中工具类型是否「编码管理」,用于锁定库存数量为 1隐藏字段
fieldName: 'codeFlag',
component: 'Input',
dependencies: {
triggerFields: [''],
show: () => false,
},
},
{
fieldName: 'code',
label: '工具编码',
@ -41,17 +53,20 @@ export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
componentProps: (values) => ({ disabled: !!values.id }),
},
rules: 'required',
suffix: () =>
h(
ElButton,
{
onClick: async () => {
const code = await generateAutoCode(MesAutoCodeRuleCode.TM_TOOL_CODE);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '生成' },
),
suffix:
formType === 'detail'
? undefined
: () =>
h(
ElButton,
{
onClick: async () => {
const code = await generateAutoCode(MesAutoCodeRuleCode.TM_TOOL_CODE);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '生成' },
),
},
{
fieldName: 'name',
@ -69,7 +84,9 @@ export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
componentProps: {
placeholder: '请选择工具类型',
onChange: async (row: any) => {
if (row?.codeFlag) {
// 记录是否编码管理;编码管理类型库存数量锁定为 1
await formApi?.setFieldValue('codeFlag', row?.codeFlag === true);
if (row?.codeFlag === true) {
await formApi?.setFieldValue('quantity', 1);
await formApi?.setFieldValue('availableQuantity', 1);
}
@ -110,6 +127,13 @@ export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
precision: 0,
},
rules: 'required',
// 编码管理类型库存数量锁定为 1禁止修改
dependencies: {
triggerFields: ['codeFlag'],
componentProps: (values) => ({
disabled: values.codeFlag === true,
}),
},
},
{
fieldName: 'availableQuantity',

View File

@ -87,10 +87,10 @@ const [Modal, modalApi] = useVbenModal({
formData.value = undefined;
return;
}
formApi.setState({ schema: useFormSchema(formApi) });
//
const data = modalApi.getData<{ formType: FormType; id?: number }>();
formType.value = data.formType;
formApi.setState({ schema: useFormSchema(data.formType, formApi) });
formApi.setDisabled(formType.value === 'detail');
modalApi.setState({ showConfirmButton: formType.value !== 'detail' });
if (!data?.id) {

View File

@ -16,7 +16,10 @@ import { generateAutoCode } from '#/api/mes/md/autocode/record';
export type FormType = 'create' | 'detail' | 'update';
/** 新增/修改工具类型的表单 */
export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
export function useFormSchema(
formType: FormType,
formApi?: VbenFormApi,
): VbenFormSchema[] {
return [
{
fieldName: 'id',
@ -34,17 +37,20 @@ export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
placeholder: '请输入类型编码',
},
rules: 'required',
suffix: () =>
h(
ElButton,
{
onClick: async () => {
const code = await generateAutoCode(MesAutoCodeRuleCode.TM_TOOL_TYPE_CODE);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '生成' },
),
suffix:
formType === 'detail'
? undefined
: () =>
h(
ElButton,
{
onClick: async () => {
const code = await generateAutoCode(MesAutoCodeRuleCode.TM_TOOL_TYPE_CODE);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '生成' },
),
},
{
fieldName: 'name',

View File

@ -71,10 +71,10 @@ const [Modal, modalApi] = useVbenModal({
formData.value = undefined;
return;
}
formApi.setState({ schema: useFormSchema(formApi) });
//
const data = modalApi.getData<{ formType: FormType; id?: number }>();
formType.value = data.formType;
formApi.setState({ schema: useFormSchema(data.formType, formApi) });
formApi.setDisabled(formType.value === 'detail');
modalApi.setState({ showConfirmButton: formType.value !== 'detail' });
if (!data?.id) {