feat(mes): 优化 generateAutoCode 的调用,减少 try catch

pull/350/head
YunaiV 2026-05-29 21:22:14 +08:00
parent f79dffcf2e
commit b4e7573d10
62 changed files with 239 additions and 419 deletions

View File

@ -55,12 +55,8 @@ export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
{
type: 'default',
onClick: async () => {
try {
const code = await generateAutoCode(MesAutoCodeRuleCode.CAL_PLAN_CODE);
await formApi?.setFieldValue('code', code);
} catch (error) {
console.error(error);
}
const code = await generateAutoCode(MesAutoCodeRuleCode.CAL_PLAN_CODE);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '生成' },

View File

@ -42,12 +42,8 @@ export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
{
type: 'default',
onClick: async () => {
try {
const code = await generateAutoCode(MesAutoCodeRuleCode.CAL_TEAM_CODE);
await formApi?.setFieldValue('code', code);
} catch (error) {
console.error(error);
}
const code = await generateAutoCode(MesAutoCodeRuleCode.CAL_TEAM_CODE);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '生成' },

View File

@ -55,12 +55,8 @@ export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
{
type: 'default',
onClick: async () => {
try {
const code = await generateAutoCode(MesAutoCodeRuleCode.DV_CHECK_PLAN_CODE);
await formApi?.setFieldValue('code', code);
} catch (error) {
console.error(error);
}
const code = await generateAutoCode(MesAutoCodeRuleCode.DV_CHECK_PLAN_CODE);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '生成' },

View File

@ -48,12 +48,8 @@ export function useFormSchema(formType: FormType, formApi?: VbenFormApi): VbenFo
{
type: 'default',
onClick: async () => {
try {
const code = await generateAutoCode(MesAutoCodeRuleCode.DV_MACHINERY_CODE);
await formApi?.setFieldValue('code', code);
} catch (error) {
console.error(error);
}
const code = await generateAutoCode(MesAutoCodeRuleCode.DV_MACHINERY_CODE);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '生成' },

View File

@ -59,12 +59,8 @@ export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
{
type: 'default',
onClick: async () => {
try {
const code = await generateAutoCode(MesAutoCodeRuleCode.DV_MACHINERY_TYPE_CODE);
await formApi?.setFieldValue('code', code);
} catch (error) {
console.error(error);
}
const code = await generateAutoCode(MesAutoCodeRuleCode.DV_MACHINERY_TYPE_CODE);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '生成' },

View File

@ -55,12 +55,8 @@ export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
{
type: 'default',
onClick: async () => {
try {
const code = await generateAutoCode(MesAutoCodeRuleCode.DV_REPAIR_CODE);
await formApi?.setFieldValue('code', code);
} catch (error) {
console.error(error);
}
const code = await generateAutoCode(MesAutoCodeRuleCode.DV_REPAIR_CODE);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '生成' },

View File

@ -41,12 +41,8 @@ export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
{
type: 'default',
onClick: async () => {
try {
const code = await generateAutoCode(MesAutoCodeRuleCode.DV_SUBJECT_CODE);
await formApi?.setFieldValue('code', code);
} catch (error) {
console.error(error);
}
const code = await generateAutoCode(MesAutoCodeRuleCode.DV_SUBJECT_CODE);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '生成' },

View File

@ -47,14 +47,10 @@ export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
{
type: 'default',
onClick: async () => {
try {
const code = await generateAutoCode(
MesAutoCodeRuleCode.MD_CLIENT_CODE,
);
await formApi?.setFieldValue('code', code);
} catch (error) {
console.error(error);
}
const code = await generateAutoCode(
MesAutoCodeRuleCode.MD_CLIENT_CODE,
);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '自动生成' },

View File

@ -45,14 +45,10 @@ export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
{
type: 'default',
onClick: async () => {
try {
const code = await generateAutoCode(
MesAutoCodeRuleCode.MD_ITEM_CODE,
);
await formApi?.setFieldValue('code', code);
} catch (error) {
console.error(error);
}
const code = await generateAutoCode(
MesAutoCodeRuleCode.MD_ITEM_CODE,
);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '生成' },

View File

@ -69,14 +69,10 @@ export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
{
type: 'default',
onClick: async () => {
try {
const code = await generateAutoCode(
MesAutoCodeRuleCode.MD_ITEM_TYPE_CODE,
);
await formApi?.setFieldValue('code', code);
} catch (error) {
console.error(error);
}
const code = await generateAutoCode(
MesAutoCodeRuleCode.MD_ITEM_TYPE_CODE,
);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '自动生成' },

View File

@ -47,14 +47,10 @@ export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
{
type: 'default',
onClick: async () => {
try {
const code = await generateAutoCode(
MesAutoCodeRuleCode.MD_VENDOR_CODE,
);
await formApi?.setFieldValue('code', code);
} catch (error) {
console.error(error);
}
const code = await generateAutoCode(
MesAutoCodeRuleCode.MD_VENDOR_CODE,
);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '自动生成' },

View File

@ -53,14 +53,10 @@ export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
{
type: 'default',
onClick: async () => {
try {
const code = await generateAutoCode(
MesAutoCodeRuleCode.MD_WORKSTATION_CODE,
);
await formApi?.setFieldValue('code', code);
} catch (error) {
console.error(error);
}
const code = await generateAutoCode(
MesAutoCodeRuleCode.MD_WORKSTATION_CODE,
);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '生成' },

View File

@ -48,14 +48,10 @@ export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
{
type: 'default',
onClick: async () => {
try {
const code = await generateAutoCode(
MesAutoCodeRuleCode.MD_WORKSHOP_CODE,
);
await formApi?.setFieldValue('code', code);
} catch (error) {
console.error(error);
}
const code = await generateAutoCode(
MesAutoCodeRuleCode.MD_WORKSHOP_CODE,
);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '生成' },

View File

@ -43,14 +43,10 @@ export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
{
type: 'default',
onClick: async () => {
try {
const code = await generateAutoCode(
MesAutoCodeRuleCode.PRO_PROCESS_CODE,
);
await formApi?.setFieldValue('code', code);
} catch (error) {
console.error(error);
}
const code = await generateAutoCode(
MesAutoCodeRuleCode.PRO_PROCESS_CODE,
);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '生成' },

View File

@ -48,14 +48,10 @@ export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
{
type: 'default',
onClick: async () => {
try {
const code = await generateAutoCode(
MesAutoCodeRuleCode.PRO_ROUTE_CODE,
);
await formApi?.setFieldValue('code', code);
} catch (error) {
console.error(error);
}
const code = await generateAutoCode(
MesAutoCodeRuleCode.PRO_ROUTE_CODE,
);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '生成' },

View File

@ -1,5 +1,4 @@
<script lang="ts" setup>
// TODO @AI使 description
import type { MesWmBatchApi } from '#/api/mes/wm/batch';
import { ref } from 'vue';
@ -14,8 +13,6 @@ const detailData = ref<MesWmBatchApi.Batch>(); // 当前批次详情
const subTabsName = ref<'backward' | 'forward'>('forward'); //
const [Modal, modalApi] = useVbenModal({
showCancelButton: false,
showConfirmButton: false,
onOpenChange(isOpen) {
if (!isOpen) {
detailData.value = undefined;
@ -28,7 +25,12 @@ const [Modal, modalApi] = useVbenModal({
</script>
<template>
<Modal title="批次追溯" class="w-4/5">
<Modal
title="批次追溯"
class="w-4/5"
:show-cancel-button="false"
:show-confirm-button="false"
>
<div class="mx-4 mt-2">
<Descriptions :column="3" bordered size="small">
<Descriptions.Item label="批次编号">
@ -75,7 +77,7 @@ const [Modal, modalApi] = useVbenModal({
<Tabs
v-if="detailData?.code"
v-model:active-key="subTabsName"
class="mx-4 mt-4"
class="mx-4! mt-4!"
type="card"
>
<Tabs.TabPane key="forward" tab="向前追溯">

View File

@ -2,7 +2,7 @@
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { MesWmBatchApi } from '#/api/mes/wm/batch';
import { ref, watch } from 'vue';
import { watch } from 'vue';
import { useVbenVxeGrid } from '#/adapter/vxe-table';
import {
@ -17,13 +17,9 @@ const props = defineProps<{
direction: 'backward' | 'forward'; // forward=backward=
}>();
const list = ref<MesWmBatchApi.Batch[]>([]); //
// TODO @AI
const [Grid, gridApi] = useVbenVxeGrid({
gridOptions: {
columns: useTraceGridColumns(),
data: list.value,
minHeight: 240,
pagerConfig: { enabled: false },
rowConfig: { isHover: true, keyField: 'id' },
@ -33,20 +29,18 @@ const [Grid, gridApi] = useVbenVxeGrid({
});
/** 加载追溯列表 */
// TODO @AI useVbenVxeGrid
async function getList() {
if (!props.batchCode) {
list.value = [];
gridApi.setGridOptions({ data: list.value });
await gridApi.grid?.loadData([]);
return;
}
gridApi.setLoading(true);
try {
list.value =
const list =
props.direction === 'forward'
? await getForwardBatchList(props.batchCode)
: await getBackwardBatchList(props.batchCode);
gridApi.setGridOptions({ data: list.value });
await gridApi.grid?.loadData(list);
} finally {
gridApi.setLoading(false);
}

View File

@ -37,14 +37,10 @@ export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
{
type: 'default',
onClick: async () => {
try {
const code = await generateAutoCode(
MesAutoCodeRuleCode.QC_DEFECT_CODE,
);
await formApi?.setFieldValue('code', code);
} catch (error) {
console.error(error);
}
const code = await generateAutoCode(
MesAutoCodeRuleCode.QC_DEFECT_CODE,
);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '自动生成' },

View File

@ -42,14 +42,10 @@ export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
{
type: 'default',
onClick: async () => {
try {
const code = await generateAutoCode(
MesAutoCodeRuleCode.QC_INDICATOR_CODE,
);
await formApi?.setFieldValue('code', code);
} catch (error) {
console.error(error);
}
const code = await generateAutoCode(
MesAutoCodeRuleCode.QC_INDICATOR_CODE,
);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '自动生成' },

View File

@ -39,14 +39,10 @@ export function useQcIndicatorResultFormSchema(
{
type: 'default',
onClick: async () => {
try {
const code = await generateAutoCode(
MesAutoCodeRuleCode.QC_INDICATOR_RESULT_CODE,
);
await formApi?.setFieldValue('code', code);
} catch (error) {
console.error(error);
}
const code = await generateAutoCode(
MesAutoCodeRuleCode.QC_INDICATOR_RESULT_CODE,
);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '生成' },

View File

@ -41,7 +41,10 @@ function syncUnqualified(formApi?: VbenFormApi) {
}
/** 新增/修改的表单 */
export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
export function useFormSchema(
formType: FormType,
formApi?: VbenFormApi,
): VbenFormSchema[] {
return [
{
fieldName: 'id',
@ -87,16 +90,13 @@ export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
h(
Button,
{
disabled: formType === 'detail',
type: 'default',
onClick: async () => {
try {
const code = await generateAutoCode(
MesAutoCodeRuleCode.QC_IPQC_CODE,
);
await formApi?.setFieldValue('code', code);
} catch (error) {
console.error(error);
}
const code = await generateAutoCode(
MesAutoCodeRuleCode.QC_IPQC_CODE,
);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '生成' },

View File

@ -151,7 +151,6 @@ const [Modal, modalApi] = useVbenModal({
originalSnapshot.value = '';
return;
}
formApi.setState({ schema: useFormSchema(formApi) });
subTabsName.value = 'line';
//
const data = modalApi.getData<{
@ -160,6 +159,7 @@ const [Modal, modalApi] = useVbenModal({
prefill?: MesQcIpqcApi.Ipqc;
}>();
formType.value = data.formType;
formApi.setState({ schema: useFormSchema(formType.value, formApi) });
formApi.setDisabled(formType.value === 'detail');
modalApi.setState({ showConfirmButton: formType.value !== 'detail' });
if (data?.id) {

View File

@ -21,7 +21,10 @@ import { MesAutoCodeRuleCode } from '#/views/mes/utils/constants';
export type FormType = 'create' | 'detail' | 'update';
/** 新增/修改的表单 */
export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
export function useFormSchema(
formType: FormType,
formApi?: VbenFormApi,
): VbenFormSchema[] {
return [
{
fieldName: 'id',
@ -67,16 +70,13 @@ export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
h(
Button,
{
disabled: formType === 'detail',
type: 'default',
onClick: async () => {
try {
const code = await generateAutoCode(
MesAutoCodeRuleCode.QC_IQC_CODE,
);
await formApi?.setFieldValue('code', code);
} catch (error) {
console.error(error);
}
const code = await generateAutoCode(
MesAutoCodeRuleCode.QC_IQC_CODE,
);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '生成' },

View File

@ -156,7 +156,6 @@ const [Modal, modalApi] = useVbenModal({
originalSnapshot.value = '';
return;
}
formApi.setState({ schema: useFormSchema(formApi) });
subTabsName.value = 'line';
//
const data = modalApi.getData<{
@ -165,6 +164,7 @@ const [Modal, modalApi] = useVbenModal({
prefill?: MesQcIqcApi.Iqc;
}>();
formType.value = data.formType;
formApi.setState({ schema: useFormSchema(formType.value, formApi) });
formApi.setDisabled(formType.value === 'detail');
modalApi.setState({ showConfirmButton: formType.value !== 'detail' });
if (data?.id) {

View File

@ -20,7 +20,10 @@ import { MesAutoCodeRuleCode } from '#/views/mes/utils/constants';
export type FormType = 'create' | 'detail' | 'update';
/** 新增/修改的表单 */
export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
export function useFormSchema(
formType: FormType,
formApi?: VbenFormApi,
): VbenFormSchema[] {
return [
{
fieldName: 'id',
@ -66,16 +69,13 @@ export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
h(
Button,
{
disabled: formType === 'detail',
type: 'default',
onClick: async () => {
try {
const code = await generateAutoCode(
MesAutoCodeRuleCode.QC_OQC_CODE,
);
await formApi?.setFieldValue('code', code);
} catch (error) {
console.error(error);
}
const code = await generateAutoCode(
MesAutoCodeRuleCode.QC_OQC_CODE,
);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '生成' },

View File

@ -150,7 +150,6 @@ const [Modal, modalApi] = useVbenModal({
originalSnapshot.value = '';
return;
}
formApi.setState({ schema: useFormSchema(formApi) });
subTabsName.value = 'line';
//
const data = modalApi.getData<{
@ -159,6 +158,7 @@ const [Modal, modalApi] = useVbenModal({
prefill?: MesQcOqcApi.Oqc;
}>();
formType.value = data.formType;
formApi.setState({ schema: useFormSchema(formType.value, formApi) });
formApi.setDisabled(formType.value === 'detail');
modalApi.setState({ showConfirmButton: formType.value !== 'detail' });
if (data?.id) {

View File

@ -33,7 +33,10 @@ function getRqcSourceDocTypeOptions() {
}
/** 新增/修改的表单 */
export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
export function useFormSchema(
formType: FormType,
formApi?: VbenFormApi,
): VbenFormSchema[] {
return [
{
fieldName: 'id',
@ -79,16 +82,13 @@ export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
h(
Button,
{
disabled: formType === 'detail',
type: 'default',
onClick: async () => {
try {
const code = await generateAutoCode(
MesAutoCodeRuleCode.QC_RQC_CODE,
);
await formApi?.setFieldValue('code', code);
} catch (error) {
console.error(error);
}
const code = await generateAutoCode(
MesAutoCodeRuleCode.QC_RQC_CODE,
);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '生成' },

View File

@ -150,7 +150,6 @@ const [Modal, modalApi] = useVbenModal({
originalSnapshot.value = '';
return;
}
formApi.setState({ schema: useFormSchema(formApi) });
subTabsName.value = 'line';
//
const data = modalApi.getData<{
@ -159,6 +158,7 @@ const [Modal, modalApi] = useVbenModal({
prefill?: MesQcRqcApi.Rqc;
}>();
formType.value = data.formType;
formApi.setState({ schema: useFormSchema(formType.value, formApi) });
formApi.setDisabled(formType.value === 'detail');
modalApi.setState({ showConfirmButton: formType.value !== 'detail' });
if (data?.id) {

View File

@ -46,14 +46,10 @@ export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
{
type: 'default',
onClick: async () => {
try {
const code = await generateAutoCode(
MesAutoCodeRuleCode.QC_TEMPLATE_CODE,
);
await formApi?.setFieldValue('code', code);
} catch (error) {
console.error(error);
}
const code = await generateAutoCode(
MesAutoCodeRuleCode.QC_TEMPLATE_CODE,
);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '自动生成' },

View File

@ -80,14 +80,10 @@ export function useFormSchema(
{
type: 'default',
onClick: async () => {
try {
const code = await generateAutoCode(
MesAutoCodeRuleCode.WM_AREA_CODE,
);
await formApi?.setFieldValue('code', code);
} catch (error) {
console.error(error);
}
const code = await generateAutoCode(
MesAutoCodeRuleCode.WM_AREA_CODE,
);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '自动生成' },

View File

@ -52,14 +52,10 @@ export function useFormSchema(
{
type: 'default',
onClick: async () => {
try {
const code = await generateAutoCode(
MesAutoCodeRuleCode.WM_WAREHOUSE_CODE,
);
await formApi?.setFieldValue('code', code);
} catch (error) {
console.error(error);
}
const code = await generateAutoCode(
MesAutoCodeRuleCode.WM_WAREHOUSE_CODE,
);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '自动生成' },

View File

@ -49,14 +49,10 @@ export function useFormSchema(
{
type: 'default',
onClick: async () => {
try {
const code = await generateAutoCode(
MesAutoCodeRuleCode.WM_LOCATION_CODE,
);
await formApi?.setFieldValue('code', code);
} catch (error) {
console.error(error);
}
const code = await generateAutoCode(
MesAutoCodeRuleCode.WM_LOCATION_CODE,
);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '自动生成' },

View File

@ -55,12 +55,8 @@ export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
{
type: 'default',
onClick: async () => {
try {
const code = await generateAutoCode(MesAutoCodeRuleCode.CAL_PLAN_CODE);
await formApi?.setFieldValue('code', code);
} catch (error) {
console.error(error);
}
const code = await generateAutoCode(MesAutoCodeRuleCode.CAL_PLAN_CODE);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '生成' },

View File

@ -42,12 +42,8 @@ export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
{
type: 'default',
onClick: async () => {
try {
const code = await generateAutoCode(MesAutoCodeRuleCode.CAL_TEAM_CODE);
await formApi?.setFieldValue('code', code);
} catch (error) {
console.error(error);
}
const code = await generateAutoCode(MesAutoCodeRuleCode.CAL_TEAM_CODE);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '生成' },

View File

@ -55,12 +55,8 @@ export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
{
type: 'default',
onClick: async () => {
try {
const code = await generateAutoCode(MesAutoCodeRuleCode.DV_CHECK_PLAN_CODE);
await formApi?.setFieldValue('code', code);
} catch (error) {
console.error(error);
}
const code = await generateAutoCode(MesAutoCodeRuleCode.DV_CHECK_PLAN_CODE);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '生成' },

View File

@ -48,12 +48,8 @@ export function useFormSchema(formType: FormType, formApi?: VbenFormApi): VbenFo
{
type: 'default',
onClick: async () => {
try {
const code = await generateAutoCode(MesAutoCodeRuleCode.DV_MACHINERY_CODE);
await formApi?.setFieldValue('code', code);
} catch (error) {
console.error(error);
}
const code = await generateAutoCode(MesAutoCodeRuleCode.DV_MACHINERY_CODE);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '生成' },

View File

@ -58,12 +58,8 @@ export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
{
type: 'default',
onClick: async () => {
try {
const code = await generateAutoCode(MesAutoCodeRuleCode.DV_MACHINERY_TYPE_CODE);
await formApi?.setFieldValue('code', code);
} catch (error) {
console.error(error);
}
const code = await generateAutoCode(MesAutoCodeRuleCode.DV_MACHINERY_TYPE_CODE);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '生成' },

View File

@ -55,12 +55,8 @@ export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
{
type: 'default',
onClick: async () => {
try {
const code = await generateAutoCode(MesAutoCodeRuleCode.DV_REPAIR_CODE);
await formApi?.setFieldValue('code', code);
} catch (error) {
console.error(error);
}
const code = await generateAutoCode(MesAutoCodeRuleCode.DV_REPAIR_CODE);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '生成' },

View File

@ -41,12 +41,8 @@ export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
{
type: 'default',
onClick: async () => {
try {
const code = await generateAutoCode(MesAutoCodeRuleCode.DV_SUBJECT_CODE);
await formApi?.setFieldValue('code', code);
} catch (error) {
console.error(error);
}
const code = await generateAutoCode(MesAutoCodeRuleCode.DV_SUBJECT_CODE);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '生成' },

View File

@ -46,14 +46,10 @@ export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
ElButton,
{
onClick: async () => {
try {
const code = await generateAutoCode(
MesAutoCodeRuleCode.MD_CLIENT_CODE,
);
await formApi?.setFieldValue('code', code);
} catch (error) {
console.error(error);
}
const code = await generateAutoCode(
MesAutoCodeRuleCode.MD_CLIENT_CODE,
);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '自动生成' },

View File

@ -45,14 +45,10 @@ export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
{
type: 'default',
onClick: async () => {
try {
const code = await generateAutoCode(
MesAutoCodeRuleCode.MD_ITEM_CODE,
);
await formApi?.setFieldValue('code', code);
} catch (error) {
console.error(error);
}
const code = await generateAutoCode(
MesAutoCodeRuleCode.MD_ITEM_CODE,
);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '生成' },

View File

@ -69,14 +69,10 @@ export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
{
type: 'default',
onClick: async () => {
try {
const code = await generateAutoCode(
MesAutoCodeRuleCode.MD_ITEM_TYPE_CODE,
);
await formApi?.setFieldValue('code', code);
} catch (error) {
console.error(error);
}
const code = await generateAutoCode(
MesAutoCodeRuleCode.MD_ITEM_TYPE_CODE,
);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '自动生成' },

View File

@ -46,14 +46,10 @@ export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
ElButton,
{
onClick: async () => {
try {
const code = await generateAutoCode(
MesAutoCodeRuleCode.MD_VENDOR_CODE,
);
await formApi?.setFieldValue('code', code);
} catch (error) {
console.error(error);
}
const code = await generateAutoCode(
MesAutoCodeRuleCode.MD_VENDOR_CODE,
);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '自动生成' },

View File

@ -52,14 +52,10 @@ export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
ElButton,
{
onClick: async () => {
try {
const code = await generateAutoCode(
MesAutoCodeRuleCode.MD_WORKSTATION_CODE,
);
await formApi?.setFieldValue('code', code);
} catch (error) {
console.error(error);
}
const code = await generateAutoCode(
MesAutoCodeRuleCode.MD_WORKSTATION_CODE,
);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '生成' },

View File

@ -47,14 +47,10 @@ export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
ElButton,
{
onClick: async () => {
try {
const code = await generateAutoCode(
MesAutoCodeRuleCode.MD_WORKSHOP_CODE,
);
await formApi?.setFieldValue('code', code);
} catch (error) {
console.error(error);
}
const code = await generateAutoCode(
MesAutoCodeRuleCode.MD_WORKSHOP_CODE,
);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '生成' },

View File

@ -43,14 +43,10 @@ export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
{
type: 'default',
onClick: async () => {
try {
const code = await generateAutoCode(
MesAutoCodeRuleCode.PRO_PROCESS_CODE,
);
await formApi?.setFieldValue('code', code);
} catch (error) {
console.error(error);
}
const code = await generateAutoCode(
MesAutoCodeRuleCode.PRO_PROCESS_CODE,
);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '生成' },

View File

@ -48,14 +48,10 @@ export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
{
type: 'default',
onClick: async () => {
try {
const code = await generateAutoCode(
MesAutoCodeRuleCode.PRO_ROUTE_CODE,
);
await formApi?.setFieldValue('code', code);
} catch (error) {
console.error(error);
}
const code = await generateAutoCode(
MesAutoCodeRuleCode.PRO_ROUTE_CODE,
);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '生成' },

View File

@ -36,14 +36,10 @@ export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
ElButton,
{
onClick: async () => {
try {
const code = await generateAutoCode(
MesAutoCodeRuleCode.QC_DEFECT_CODE,
);
await formApi?.setFieldValue('code', code);
} catch (error) {
console.error(error);
}
const code = await generateAutoCode(
MesAutoCodeRuleCode.QC_DEFECT_CODE,
);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '自动生成' },

View File

@ -41,14 +41,10 @@ export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
ElButton,
{
onClick: async () => {
try {
const code = await generateAutoCode(
MesAutoCodeRuleCode.QC_INDICATOR_CODE,
);
await formApi?.setFieldValue('code', code);
} catch (error) {
console.error(error);
}
const code = await generateAutoCode(
MesAutoCodeRuleCode.QC_INDICATOR_CODE,
);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '自动生成' },

View File

@ -38,14 +38,10 @@ export function useQcIndicatorResultFormSchema(
ElButton,
{
onClick: async () => {
try {
const code = await generateAutoCode(
MesAutoCodeRuleCode.QC_INDICATOR_RESULT_CODE,
);
await formApi?.setFieldValue('code', code);
} catch (error) {
console.error(error);
}
const code = await generateAutoCode(
MesAutoCodeRuleCode.QC_INDICATOR_RESULT_CODE,
);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '生成' },

View File

@ -41,7 +41,10 @@ function syncUnqualified(formApi?: VbenFormApi) {
}
/** 新增/修改的表单 */
export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
export function useFormSchema(
formType: FormType,
formApi?: VbenFormApi,
): VbenFormSchema[] {
return [
{
fieldName: 'id',
@ -87,15 +90,12 @@ export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
h(
ElButton,
{
disabled: formType === 'detail',
onClick: async () => {
try {
const code = await generateAutoCode(
MesAutoCodeRuleCode.QC_IPQC_CODE,
);
await formApi?.setFieldValue('code', code);
} catch (error) {
console.error(error);
}
const code = await generateAutoCode(
MesAutoCodeRuleCode.QC_IPQC_CODE,
);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '生成' },

View File

@ -157,7 +157,6 @@ const [Modal, modalApi] = useVbenModal({
originalSnapshot.value = '';
return;
}
formApi.setState({ schema: useFormSchema(formApi) });
subTabsName.value = 'line';
//
const data = modalApi.getData<{
@ -166,6 +165,7 @@ const [Modal, modalApi] = useVbenModal({
prefill?: MesQcIpqcApi.Ipqc;
}>();
formType.value = data.formType;
formApi.setState({ schema: useFormSchema(formType.value, formApi) });
formApi.setDisabled(formType.value === 'detail');
modalApi.setState({ showConfirmButton: formType.value !== 'detail' });
if (data?.id) {

View File

@ -21,7 +21,10 @@ import { MesAutoCodeRuleCode } from '#/views/mes/utils/constants';
export type FormType = 'create' | 'detail' | 'update';
/** 新增/修改的表单 */
export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
export function useFormSchema(
formType: FormType,
formApi?: VbenFormApi,
): VbenFormSchema[] {
return [
{
fieldName: 'id',
@ -67,15 +70,12 @@ export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
h(
ElButton,
{
disabled: formType === 'detail',
onClick: async () => {
try {
const code = await generateAutoCode(
MesAutoCodeRuleCode.QC_IQC_CODE,
);
await formApi?.setFieldValue('code', code);
} catch (error) {
console.error(error);
}
const code = await generateAutoCode(
MesAutoCodeRuleCode.QC_IQC_CODE,
);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '生成' },

View File

@ -158,7 +158,6 @@ const [Modal, modalApi] = useVbenModal({
originalSnapshot.value = '';
return;
}
formApi.setState({ schema: useFormSchema(formApi) });
subTabsName.value = 'line';
//
const data = modalApi.getData<{
@ -167,6 +166,7 @@ const [Modal, modalApi] = useVbenModal({
prefill?: MesQcIqcApi.Iqc;
}>();
formType.value = data.formType;
formApi.setState({ schema: useFormSchema(formType.value, formApi) });
formApi.setDisabled(formType.value === 'detail');
modalApi.setState({ showConfirmButton: formType.value !== 'detail' });
if (data?.id) {

View File

@ -20,7 +20,10 @@ import { MesAutoCodeRuleCode } from '#/views/mes/utils/constants';
export type FormType = 'create' | 'detail' | 'update';
/** 新增/修改的表单 */
export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
export function useFormSchema(
formType: FormType,
formApi?: VbenFormApi,
): VbenFormSchema[] {
return [
{
fieldName: 'id',
@ -66,15 +69,12 @@ export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
h(
ElButton,
{
disabled: formType === 'detail',
onClick: async () => {
try {
const code = await generateAutoCode(
MesAutoCodeRuleCode.QC_OQC_CODE,
);
await formApi?.setFieldValue('code', code);
} catch (error) {
console.error(error);
}
const code = await generateAutoCode(
MesAutoCodeRuleCode.QC_OQC_CODE,
);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '生成' },

View File

@ -157,7 +157,6 @@ const [Modal, modalApi] = useVbenModal({
originalSnapshot.value = '';
return;
}
formApi.setState({ schema: useFormSchema(formApi) });
subTabsName.value = 'line';
//
const data = modalApi.getData<{
@ -166,6 +165,7 @@ const [Modal, modalApi] = useVbenModal({
prefill?: MesQcOqcApi.Oqc;
}>();
formType.value = data.formType;
formApi.setState({ schema: useFormSchema(formType.value, formApi) });
formApi.setDisabled(formType.value === 'detail');
modalApi.setState({ showConfirmButton: formType.value !== 'detail' });
if (data?.id) {

View File

@ -33,7 +33,10 @@ function getRqcSourceDocTypeOptions() {
}
/** 新增/修改的表单 */
export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
export function useFormSchema(
formType: FormType,
formApi?: VbenFormApi,
): VbenFormSchema[] {
return [
{
fieldName: 'id',
@ -79,15 +82,12 @@ export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
h(
ElButton,
{
disabled: formType === 'detail',
onClick: async () => {
try {
const code = await generateAutoCode(
MesAutoCodeRuleCode.QC_RQC_CODE,
);
await formApi?.setFieldValue('code', code);
} catch (error) {
console.error(error);
}
const code = await generateAutoCode(
MesAutoCodeRuleCode.QC_RQC_CODE,
);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '生成' },

View File

@ -157,7 +157,6 @@ const [Modal, modalApi] = useVbenModal({
originalSnapshot.value = '';
return;
}
formApi.setState({ schema: useFormSchema(formApi) });
subTabsName.value = 'line';
//
const data = modalApi.getData<{
@ -166,6 +165,7 @@ const [Modal, modalApi] = useVbenModal({
prefill?: MesQcRqcApi.Rqc;
}>();
formType.value = data.formType;
formApi.setState({ schema: useFormSchema(formType.value, formApi) });
formApi.setDisabled(formType.value === 'detail');
modalApi.setState({ showConfirmButton: formType.value !== 'detail' });
if (data?.id) {

View File

@ -45,14 +45,10 @@ export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
ElButton,
{
onClick: async () => {
try {
const code = await generateAutoCode(
MesAutoCodeRuleCode.QC_TEMPLATE_CODE,
);
await formApi?.setFieldValue('code', code);
} catch (error) {
console.error(error);
}
const code = await generateAutoCode(
MesAutoCodeRuleCode.QC_TEMPLATE_CODE,
);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '自动生成' },

View File

@ -82,14 +82,10 @@ export function useFormSchema(
ElButton,
{
onClick: async () => {
try {
const code = await generateAutoCode(
MesAutoCodeRuleCode.WM_AREA_CODE,
);
await formApi?.setFieldValue('code', code);
} catch (error) {
console.error(error);
}
const code = await generateAutoCode(
MesAutoCodeRuleCode.WM_AREA_CODE,
);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '自动生成' },

View File

@ -51,14 +51,10 @@ export function useFormSchema(
ElButton,
{
onClick: async () => {
try {
const code = await generateAutoCode(
MesAutoCodeRuleCode.WM_WAREHOUSE_CODE,
);
await formApi?.setFieldValue('code', code);
} catch (error) {
console.error(error);
}
const code = await generateAutoCode(
MesAutoCodeRuleCode.WM_WAREHOUSE_CODE,
);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '自动生成' },

View File

@ -51,14 +51,10 @@ export function useFormSchema(
ElButton,
{
onClick: async () => {
try {
const code = await generateAutoCode(
MesAutoCodeRuleCode.WM_LOCATION_CODE,
);
await formApi?.setFieldValue('code', code);
} catch (error) {
console.error(error);
}
const code = await generateAutoCode(
MesAutoCodeRuleCode.WM_LOCATION_CODE,
);
await formApi?.setFieldValue('code', code);
},
},
{ default: () => '自动生成' },