feat(mes):新增“安灯(pro_andon)”的 review
parent
6b6228bc9c
commit
f4e71137e0
|
|
@ -1,21 +1,27 @@
|
|||
import type { PageParam, PageResult } from '@vben/request';
|
||||
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
export namespace MesProAndonConfigApi {
|
||||
/** MES 安灯配置 */
|
||||
export interface AndonConfig {
|
||||
id?: number;
|
||||
id?: number; // 编号
|
||||
reason?: string; // 呼叫原因
|
||||
level?: number; // 级别
|
||||
handlerRoleId?: number; // 处置角色编号
|
||||
handlerRoleName?: string; // 处置角色名称(前端通过角色精简列表回显)
|
||||
handlerUserId?: number; // 处置人编号
|
||||
handlerUserNickname?: string; // 处置人姓名(详情回显)
|
||||
remark?: string;
|
||||
handlerUserNickname?: string; // 处置人昵称
|
||||
remark?: string; // 备注
|
||||
}
|
||||
}
|
||||
|
||||
/** 查询安灯配置分页 */
|
||||
export function getAndonConfigPage(params: any) {
|
||||
return requestClient.get('/mes/pro/andon-config/page', { params });
|
||||
export function getAndonConfigPage(params: PageParam) {
|
||||
return requestClient.get<PageResult<MesProAndonConfigApi.AndonConfig>>(
|
||||
'/mes/pro/andon-config/page',
|
||||
{ params },
|
||||
);
|
||||
}
|
||||
|
||||
/** 查询安灯配置列表 */
|
||||
|
|
|
|||
|
|
@ -37,7 +37,6 @@ const [Form, formApi] = useVbenForm({
|
|||
showDefaultActions: false,
|
||||
});
|
||||
|
||||
// TODO @AI:注释缺少
|
||||
const [Modal, modalApi] = useVbenModal({
|
||||
async onConfirm() {
|
||||
const { valid } = await formApi.validate();
|
||||
|
|
|
|||
|
|
@ -13,18 +13,20 @@ import {
|
|||
deleteAndonConfig,
|
||||
getAndonConfigList,
|
||||
} from '#/api/mes/pro/andon/config';
|
||||
import { getSimpleRoleList } from '#/api/system/role';
|
||||
import { $t } from '#/locales';
|
||||
|
||||
import { useConfigGridColumns } from '../../record/data';
|
||||
import ConfigForm from './config-form.vue';
|
||||
|
||||
const list = ref<MesProAndonConfigApi.AndonConfig[]>([]);
|
||||
const list = ref<MesProAndonConfigApi.AndonConfig[]>([]); // 安灯配置列表(已回填处置角色名称)
|
||||
|
||||
const [ConfigFormModal, configFormModalApi] = useVbenModal({
|
||||
connectedComponent: ConfigForm,
|
||||
destroyOnClose: true,
|
||||
});
|
||||
|
||||
// TODO @AI:这个格式,是不是有问题?应该要换行?看看别的模块也是;
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
gridOptions: {
|
||||
autoResize: true,
|
||||
|
|
@ -39,11 +41,22 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
|||
} as VxeTableGridOptions<MesProAndonConfigApi.AndonConfig>,
|
||||
});
|
||||
|
||||
/** 加载安灯配置列表 */
|
||||
/** 加载安灯配置列表,并通过角色精简列表回填处置角色名称 */
|
||||
// TODO @AI:这里需要 getAndonConfigList、getSimpleRoleList 么?通过 data.ts 里处理,是不是更主流???
|
||||
async function getList() {
|
||||
gridApi.setLoading(true);
|
||||
try {
|
||||
list.value = (await getAndonConfigList()) || [];
|
||||
const [configList, roleList] = await Promise.all([
|
||||
getAndonConfigList(),
|
||||
getSimpleRoleList(),
|
||||
]);
|
||||
const roleMap = new Map(roleList.map((role) => [role.id!, role.name!]));
|
||||
list.value = (configList || []).map((item) => ({
|
||||
...item,
|
||||
handlerRoleName: item.handlerRoleId
|
||||
? roleMap.get(item.handlerRoleId)
|
||||
: undefined,
|
||||
}));
|
||||
gridApi.setGridOptions({ data: list.value });
|
||||
} finally {
|
||||
gridApi.setLoading(false);
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import { DICT_TYPE } from '@vben/constants';
|
|||
import { getDictOptions } from '@vben/hooks';
|
||||
|
||||
import { z } from '#/adapter/form';
|
||||
import { getSimpleRoleList } from '#/api/system/role';
|
||||
import { getSimpleUserList } from '#/api/system/user';
|
||||
import { MdWorkstationSelect } from '#/views/mes/md/workstation/components';
|
||||
import { ProProcessSelect } from '#/views/mes/pro/process/components';
|
||||
|
|
@ -64,6 +65,10 @@ export function useGridFormSchema(): VbenFormSchema[] {
|
|||
component: 'RangePicker',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
defaultTime: [
|
||||
new Date(2000, 0, 1, 0, 0, 0),
|
||||
new Date(2000, 0, 1, 23, 59, 59),
|
||||
],
|
||||
format: 'YYYY-MM-DD HH:mm:ss',
|
||||
showTime: true,
|
||||
valueFormat: 'YYYY-MM-DD HH:mm:ss',
|
||||
|
|
@ -293,6 +298,7 @@ export function useConfigGridColumns(): VxeTableGridOptions<MesProAndonConfigApi
|
|||
props: { type: DICT_TYPE.MES_PRO_ANDON_LEVEL },
|
||||
},
|
||||
},
|
||||
{ field: 'handlerRoleName', title: '处置角色', width: 140 },
|
||||
{ field: 'handlerUserNickname', title: '处置人', width: 140 },
|
||||
{ field: 'remark', title: '备注', minWidth: 160 },
|
||||
{
|
||||
|
|
@ -339,8 +345,7 @@ export function useConfigFormSchema(): VbenFormSchema[] {
|
|||
component: 'ApiSelect',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
api: () =>
|
||||
import('#/api/system/role').then((m) => m.getSimpleRoleList()),
|
||||
api: getSimpleRoleList,
|
||||
labelField: 'name',
|
||||
placeholder: '请选择角色(与处置人至少填一个)',
|
||||
valueField: 'id',
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ import { computed, ref } from 'vue';
|
|||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
import { useUserStore } from '@vben/stores';
|
||||
import { formatDate } from '@vben/utils';
|
||||
|
||||
import { Button, message } from 'ant-design-vue';
|
||||
|
||||
|
|
@ -22,8 +21,8 @@ import { MesProAndonStatusEnum } from '#/views/mes/utils/constants';
|
|||
import { useFormSchema } from '../data';
|
||||
|
||||
const emit = defineEmits(['success']);
|
||||
const formType = ref<'create' | 'detail' | 'update'>('create'); // 表单类型
|
||||
const formData = ref<MesProAndonRecordApi.AndonRecord>({}); // 表单数据
|
||||
const formType = ref<'create' | 'detail' | 'update'>('create'); // 表单当前模式:新增 / 处置 / 详情
|
||||
const formData = ref<MesProAndonRecordApi.AndonRecord>();
|
||||
const userStore = useUserStore();
|
||||
|
||||
const dialogTitle = computed(() => {
|
||||
|
|
@ -83,6 +82,7 @@ async function handleCreate() {
|
|||
}
|
||||
|
||||
/** 处置:保存(保持 ACTIVE) */
|
||||
// TODO @AI:这里写下注释;
|
||||
async function handleSave() {
|
||||
modalApi.lock();
|
||||
try {
|
||||
|
|
@ -91,7 +91,7 @@ async function handleSave() {
|
|||
await updateAndonRecord({
|
||||
handlerUserId: values.handlerUserId,
|
||||
handleTime: values.handleTime,
|
||||
id: formData.value.id,
|
||||
id: formData.value?.id,
|
||||
remark: values.remark,
|
||||
status: MesProAndonStatusEnum.ACTIVE,
|
||||
});
|
||||
|
|
@ -104,6 +104,7 @@ async function handleSave() {
|
|||
}
|
||||
|
||||
/** 处置:标记已处置 */
|
||||
// TODO @AI:这里写下注释;
|
||||
async function handleFinish() {
|
||||
const values =
|
||||
(await formApi.getValues()) as MesProAndonRecordApi.AndonRecord;
|
||||
|
|
@ -120,7 +121,7 @@ async function handleFinish() {
|
|||
await updateAndonRecord({
|
||||
handlerUserId: values.handlerUserId,
|
||||
handleTime: values.handleTime,
|
||||
id: formData.value.id,
|
||||
id: formData.value?.id,
|
||||
remark: values.remark,
|
||||
status: MesProAndonStatusEnum.HANDLED,
|
||||
});
|
||||
|
|
@ -132,12 +133,11 @@ async function handleFinish() {
|
|||
}
|
||||
}
|
||||
|
||||
// TODO @AI:注释缺少
|
||||
// TODO @AI:代码风格,貌似和别的模块不同;
|
||||
// TODO @AI:这里的代码风格?!!
|
||||
const [Modal, modalApi] = useVbenModal({
|
||||
async onOpenChange(isOpen: boolean) {
|
||||
if (!isOpen) {
|
||||
formData.value = {};
|
||||
formData.value = undefined;
|
||||
return;
|
||||
}
|
||||
const data = modalApi.getData<{
|
||||
|
|
@ -167,10 +167,10 @@ const [Modal, modalApi] = useVbenModal({
|
|||
try {
|
||||
formData.value = await getAndonRecord(data.id);
|
||||
const initial: MesProAndonRecordApi.AndonRecord = { ...formData.value };
|
||||
// 处置模式下,默认填充处置时间和处置人
|
||||
// 处置模式下,默认填充处置时间和处置人,方便快速保存
|
||||
if (data.type === 'update') {
|
||||
if (!initial.handleTime) {
|
||||
initial.handleTime = formatDate(new Date(), 'YYYY-MM-DD HH:mm:ss');
|
||||
initial.handleTime = Date.now();
|
||||
}
|
||||
if (!initial.handlerUserId) {
|
||||
initial.handlerUserId = userStore.userInfo?.id;
|
||||
|
|
|
|||
Loading…
Reference in New Issue