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