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; // 呼叫原因
level?: number; // 级别
handlerRoleId?: number; // 处置角色编号
handlerRoleName?: string; // 处置角色名称
handlerUserId?: number; // 处置人编号
handlerUserNickname?: string; // 处置人昵称
remark?: string; // 备注

View File

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

View File

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

View File

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

View File

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

View File

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