fix(mes): 修正安灯迁移的配置角色显示和记录只读字段

pull/349/head
YunaiV 2026-05-26 00:08:46 +08:00
parent 9c7986d230
commit 4a92762d44
6 changed files with 242 additions and 166 deletions

View File

@ -9,6 +9,7 @@ export namespace MesProAndonConfigApi {
reason?: string; // 呼叫原因 reason?: string; // 呼叫原因
level?: number; // 级别 level?: number; // 级别
handlerRoleId?: number; // 处置角色编号 handlerRoleId?: number; // 处置角色编号
handlerRoleName?: string; // 处置角色名称
handlerUserId?: number; // 处置人编号 handlerUserId?: number; // 处置人编号
handlerUserNickname?: string; // 处置人昵称 handlerUserNickname?: string; // 处置人昵称
remark?: string; // 备注 remark?: string; // 备注

View File

@ -1,7 +1,6 @@
import type { VbenFormSchema } from '#/adapter/form'; import type { VbenFormSchema } from '#/adapter/form';
import type { VxeTableGridOptions } from '#/adapter/vxe-table'; import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { MesProAndonConfigApi } from '#/api/mes/pro/andon/config'; import type { MesProAndonConfigApi } from '#/api/mes/pro/andon/config';
import type { SystemRoleApi } from '#/api/system/role';
import { DICT_TYPE } from '@vben/constants'; import { DICT_TYPE } from '@vben/constants';
import { getDictOptions } from '@vben/hooks'; import { getDictOptions } from '@vben/hooks';
@ -10,10 +9,6 @@ import { z } from '#/adapter/form';
import { getSimpleRoleList } from '#/api/system/role'; import { getSimpleRoleList } from '#/api/system/role';
import { getSimpleUserList } from '#/api/system/user'; import { getSimpleUserList } from '#/api/system/user';
/** 关联数据 */
let roleList: SystemRoleApi.Role[] = [];
getSimpleRoleList().then((data) => (roleList = data));
/** 安灯配置列表的字段 */ /** 安灯配置列表的字段 */
export function useGridColumns(): VxeTableGridOptions<MesProAndonConfigApi.AndonConfig>['columns'] { export function useGridColumns(): VxeTableGridOptions<MesProAndonConfigApi.AndonConfig>['columns'] {
return [ return [
@ -27,13 +22,7 @@ export function useGridColumns(): VxeTableGridOptions<MesProAndonConfigApi.Andon
props: { type: DICT_TYPE.MES_PRO_ANDON_LEVEL }, props: { type: DICT_TYPE.MES_PRO_ANDON_LEVEL },
}, },
}, },
{ { field: 'handlerRoleName', title: '处置角色', width: 140 },
field: 'handlerRoleId',
title: '处置角色',
width: 140,
formatter: ({ cellValue }) =>
roleList.find((role) => role.id === cellValue)?.name ?? '',
},
{ field: 'handlerUserNickname', title: '处置人', width: 140 }, { field: 'handlerUserNickname', title: '处置人', width: 140 },
{ field: 'remark', title: '备注', minWidth: 160 }, { field: 'remark', title: '备注', minWidth: 160 },
{ {

View File

@ -128,7 +128,7 @@ export function useGridColumns(): VxeTableGridOptions<MesProAndonRecordApi.Andon
* // * //
* *
* - create///// * - create/////
* - update// * - updateworkstationName/workOrderCode/processName/reason//
* - detail * - detail
*/ */
export function useFormSchema( export function useFormSchema(
@ -143,64 +143,104 @@ export function useFormSchema(
component: 'Input', component: 'Input',
dependencies: { triggerFields: [''], show: () => false }, dependencies: { triggerFields: [''], show: () => false },
}, },
{ isCreate
fieldName: 'workstationId', ? {
label: '工作站', fieldName: 'workstationId',
component: markRaw(MdWorkstationSelect), label: '工作站',
componentProps: { component: markRaw(MdWorkstationSelect),
disabled: !isCreate, componentProps: {
placeholder: '请选择工作站', placeholder: '请选择工作站',
}, },
rules: 'selectRequired', rules: 'selectRequired',
}, }
{ : {
fieldName: 'userId', fieldName: 'workstationName',
label: '发起人', label: '工作站',
component: 'ApiSelect', component: 'Input',
componentProps: { componentProps: {
allowClear: true, disabled: true,
api: getSimpleUserList, },
disabled: !isCreate, },
labelField: 'nickname', isCreate
placeholder: '请选择发起人', ? {
valueField: 'id', fieldName: 'userId',
}, label: '发起人',
}, component: 'ApiSelect',
{ componentProps: {
fieldName: 'workOrderId', allowClear: true,
label: '生产工单', api: getSimpleUserList,
component: markRaw(ProWorkOrderSelect), labelField: 'nickname',
componentProps: { placeholder: '请选择发起人',
disabled: !isCreate, valueField: 'id',
placeholder: '请选择工单(可选)', },
status: MesProWorkOrderStatusEnum.CONFIRMED, }
}, : {
}, fieldName: 'userNickname',
{ label: '发起人',
fieldName: 'processId', component: 'Input',
label: '工序', componentProps: {
component: markRaw(ProProcessSelect), disabled: true,
componentProps: { },
disabled: !isCreate, },
placeholder: '请选择工序(可选)', isCreate
}, ? {
}, fieldName: 'workOrderId',
{ label: '生产工单',
fieldName: 'configId', component: markRaw(ProWorkOrderSelect),
label: '呼叫原因', componentProps: {
component: markRaw(AndonConfigSelect), placeholder: '请选择工单(可选)',
componentProps: { status: MesProWorkOrderStatusEnum.CONFIRMED,
disabled: !isCreate, },
// 选择呼叫原因后,自动填充对应的级别 }
onChange: async (config?: MesProAndonConfigApi.AndonConfig) => { : {
await formApi?.setValues({ fieldName: 'workOrderCode',
level: config?.level, label: '生产工单',
reason: config?.reason, component: 'Input',
}); componentProps: {
disabled: true,
},
},
isCreate
? {
fieldName: 'processId',
label: '工序',
component: markRaw(ProProcessSelect),
componentProps: {
placeholder: '请选择工序(可选)',
},
}
: {
fieldName: 'processName',
label: '工序',
component: 'Input',
componentProps: {
disabled: true,
},
},
isCreate
? {
fieldName: 'configId',
label: '呼叫原因',
component: markRaw(AndonConfigSelect),
componentProps: {
// 选择呼叫原因后,自动填充对应的级别
onChange: async (config?: MesProAndonConfigApi.AndonConfig) => {
await formApi?.setValues({
level: config?.level,
reason: config?.reason,
});
},
},
rules: 'selectRequired',
}
: {
fieldName: 'reason',
label: '呼叫原因',
component: 'Input',
componentProps: {
disabled: true,
},
}, },
},
rules: 'selectRequired',
},
{ {
fieldName: 'level', fieldName: 'level',
label: '级别', label: '级别',
@ -239,19 +279,27 @@ export function useFormSchema(
valueFormat: 'x', valueFormat: 'x',
}, },
}, },
{ isUpdate
fieldName: 'handlerUserId', ? {
label: '处置人', fieldName: 'handlerUserId',
component: 'ApiSelect', label: '处置人',
componentProps: { component: 'ApiSelect',
allowClear: true, componentProps: {
api: getSimpleUserList, allowClear: true,
disabled: !isUpdate, api: getSimpleUserList,
labelField: 'nickname', labelField: 'nickname',
placeholder: '请选择处置人', placeholder: '请选择处置人',
valueField: 'id', valueField: 'id',
}, },
}, }
: {
fieldName: 'handlerUserNickname',
label: '处置人',
component: 'Input',
componentProps: {
disabled: true,
},
},
] as VbenFormSchema[])), ] as VbenFormSchema[])),
{ {
fieldName: 'remark', fieldName: 'remark',

View File

@ -9,6 +9,7 @@ export namespace MesProAndonConfigApi {
reason?: string; // 呼叫原因 reason?: string; // 呼叫原因
level?: number; // 级别 level?: number; // 级别
handlerRoleId?: number; // 处置角色编号 handlerRoleId?: number; // 处置角色编号
handlerRoleName?: string; // 处置角色名称
handlerUserId?: number; // 处置人编号 handlerUserId?: number; // 处置人编号
handlerUserNickname?: string; // 处置人昵称 handlerUserNickname?: string; // 处置人昵称
remark?: string; // 备注 remark?: string; // 备注

View File

@ -1,7 +1,6 @@
import type { VbenFormSchema } from '#/adapter/form'; import type { VbenFormSchema } from '#/adapter/form';
import type { VxeTableGridOptions } from '#/adapter/vxe-table'; import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { MesProAndonConfigApi } from '#/api/mes/pro/andon/config'; import type { MesProAndonConfigApi } from '#/api/mes/pro/andon/config';
import type { SystemRoleApi } from '#/api/system/role';
import { DICT_TYPE } from '@vben/constants'; import { DICT_TYPE } from '@vben/constants';
import { getDictOptions } from '@vben/hooks'; import { getDictOptions } from '@vben/hooks';
@ -10,10 +9,6 @@ import { z } from '#/adapter/form';
import { getSimpleRoleList } from '#/api/system/role'; import { getSimpleRoleList } from '#/api/system/role';
import { getSimpleUserList } from '#/api/system/user'; import { getSimpleUserList } from '#/api/system/user';
/** 关联数据 */
let roleList: SystemRoleApi.Role[] = [];
getSimpleRoleList().then((data) => (roleList = data));
/** 安灯配置列表的字段 */ /** 安灯配置列表的字段 */
export function useGridColumns(): VxeTableGridOptions<MesProAndonConfigApi.AndonConfig>['columns'] { export function useGridColumns(): VxeTableGridOptions<MesProAndonConfigApi.AndonConfig>['columns'] {
return [ return [
@ -27,13 +22,7 @@ export function useGridColumns(): VxeTableGridOptions<MesProAndonConfigApi.Andon
props: { type: DICT_TYPE.MES_PRO_ANDON_LEVEL }, props: { type: DICT_TYPE.MES_PRO_ANDON_LEVEL },
}, },
}, },
{ { field: 'handlerRoleName', title: '处置角色', width: 140 },
field: 'handlerRoleId',
title: '处置角色',
width: 140,
formatter: ({ cellValue }) =>
roleList.find((role) => role.id === cellValue)?.name ?? '',
},
{ field: 'handlerUserNickname', title: '处置人', width: 140 }, { field: 'handlerUserNickname', title: '处置人', width: 140 },
{ field: 'remark', title: '备注', minWidth: 160 }, { field: 'remark', title: '备注', minWidth: 160 },
{ {

View File

@ -128,7 +128,7 @@ export function useGridColumns(): VxeTableGridOptions<MesProAndonRecordApi.Andon
* // * //
* *
* - create///// * - create/////
* - update// * - updateworkstationName/workOrderCode/processName/reason//
* - detail * - detail
*/ */
export function useFormSchema( export function useFormSchema(
@ -143,64 +143,104 @@ export function useFormSchema(
component: 'Input', component: 'Input',
dependencies: { triggerFields: [''], show: () => false }, dependencies: { triggerFields: [''], show: () => false },
}, },
{ isCreate
fieldName: 'workstationId', ? {
label: '工作站', fieldName: 'workstationId',
component: markRaw(MdWorkstationSelect), label: '工作站',
componentProps: { component: markRaw(MdWorkstationSelect),
disabled: !isCreate, componentProps: {
placeholder: '请选择工作站', placeholder: '请选择工作站',
}, },
rules: 'selectRequired', rules: 'selectRequired',
}, }
{ : {
fieldName: 'userId', fieldName: 'workstationName',
label: '发起人', label: '工作站',
component: 'ApiSelect', component: 'Input',
componentProps: { componentProps: {
api: getSimpleUserList, disabled: true,
clearable: true, },
disabled: !isCreate, },
labelField: 'nickname', isCreate
placeholder: '请选择发起人', ? {
valueField: 'id', fieldName: 'userId',
}, label: '发起人',
}, component: 'ApiSelect',
{ componentProps: {
fieldName: 'workOrderId', api: getSimpleUserList,
label: '生产工单', clearable: true,
component: markRaw(ProWorkOrderSelect), labelField: 'nickname',
componentProps: { placeholder: '请选择发起人',
disabled: !isCreate, valueField: 'id',
placeholder: '请选择工单(可选)', },
status: MesProWorkOrderStatusEnum.CONFIRMED, }
}, : {
}, fieldName: 'userNickname',
{ label: '发起人',
fieldName: 'processId', component: 'Input',
label: '工序', componentProps: {
component: markRaw(ProProcessSelect), disabled: true,
componentProps: { },
disabled: !isCreate, },
placeholder: '请选择工序(可选)', isCreate
}, ? {
}, fieldName: 'workOrderId',
{ label: '生产工单',
fieldName: 'configId', component: markRaw(ProWorkOrderSelect),
label: '呼叫原因', componentProps: {
component: markRaw(AndonConfigSelect), placeholder: '请选择工单(可选)',
componentProps: { status: MesProWorkOrderStatusEnum.CONFIRMED,
disabled: !isCreate, },
// 选择呼叫原因后,自动填充对应的级别 }
onChange: async (config?: MesProAndonConfigApi.AndonConfig) => { : {
await formApi?.setValues({ fieldName: 'workOrderCode',
level: config?.level, label: '生产工单',
reason: config?.reason, component: 'Input',
}); componentProps: {
disabled: true,
},
},
isCreate
? {
fieldName: 'processId',
label: '工序',
component: markRaw(ProProcessSelect),
componentProps: {
placeholder: '请选择工序(可选)',
},
}
: {
fieldName: 'processName',
label: '工序',
component: 'Input',
componentProps: {
disabled: true,
},
},
isCreate
? {
fieldName: 'configId',
label: '呼叫原因',
component: markRaw(AndonConfigSelect),
componentProps: {
// 选择呼叫原因后,自动填充对应的级别
onChange: async (config?: MesProAndonConfigApi.AndonConfig) => {
await formApi?.setValues({
level: config?.level,
reason: config?.reason,
});
},
},
rules: 'selectRequired',
}
: {
fieldName: 'reason',
label: '呼叫原因',
component: 'Input',
componentProps: {
disabled: true,
},
}, },
},
rules: 'selectRequired',
},
{ {
fieldName: 'level', fieldName: 'level',
label: '级别', label: '级别',
@ -240,19 +280,27 @@ export function useFormSchema(
valueFormat: 'x', valueFormat: 'x',
}, },
}, },
{ isUpdate
fieldName: 'handlerUserId', ? {
label: '处置人', fieldName: 'handlerUserId',
component: 'ApiSelect', label: '处置人',
componentProps: { component: 'ApiSelect',
api: getSimpleUserList, componentProps: {
clearable: true, api: getSimpleUserList,
disabled: !isUpdate, clearable: true,
labelField: 'nickname', labelField: 'nickname',
placeholder: '请选择处置人', placeholder: '请选择处置人',
valueField: 'id', valueField: 'id',
}, },
}, }
: {
fieldName: 'handlerUserNickname',
label: '处置人',
component: 'Input',
componentProps: {
disabled: true,
},
},
] as VbenFormSchema[])), ] as VbenFormSchema[])),
{ {
fieldName: 'remark', fieldName: 'remark',