From 1411d87dcb794763f5e422351141dcec2f0d7225 Mon Sep 17 00:00:00 2001
From: liu <2021943741@qq.com>
Date: 星期四, 17 九月 2026 13:43:10 +0800
Subject: [PATCH] fix(mes): 生产排产页放开写死的自行生产工单类型过滤
---
src/views/mes/cal/scheduleDetail/data.ts | 252 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 252 insertions(+), 0 deletions(-)
diff --git a/src/views/mes/cal/scheduleDetail/data.ts b/src/views/mes/cal/scheduleDetail/data.ts
new file mode 100644
index 0000000..64d47dc
--- /dev/null
+++ b/src/views/mes/cal/scheduleDetail/data.ts
@@ -0,0 +1,252 @@
+import type { VbenFormSchema } from '#/adapter/form';
+import type { VxeTableGridOptions } from '#/adapter/vxe-table';
+import type { MesCalScheduleDetailApi } from '#/api/mes/cal/scheduleDetail';
+
+import { getPlanPage } from '#/api/mes/cal/plan';
+import { getTeamList } from '#/api/mes/cal/team';
+import { getSimpleUserList } from '#/api/system/user';
+import { getRangePickerDefaultProps } from '#/utils';
+
+/** 涓嬫媺閫夐」 */
+export interface OptionItem {
+ label: string;
+ value: number;
+}
+
+/** 鏉ユ簮锛氳嚜鍔ㄧ敓鎴� */
+export const SOURCE_AUTO = 1;
+/** 鏉ユ簮锛氫汉宸ヨ皟鏁� */
+export const SOURCE_MANUAL = 2;
+
+/** 杩濊绫诲瀷鎻忚堪 */
+export const issueTypeMap: Record<number, string> = {
+ 1: '鍗曟棩鐤戜技杩炵画宸ユ椂瓒呴暱',
+ 2: '鐩搁偦鐝闂翠紤鎭笉瓒�',
+};
+
+/** 鎺掔彮璁″垝閫夐」缂撳瓨锛堟悳绱㈣〃鍗曚笌鍒楄〃鍚嶇О鍥炴樉鍏辩敤锛� */
+let planOptionsCache: OptionItem[] | undefined;
+
+export async function fetchPlanOptions(): Promise<OptionItem[]> {
+ if (planOptionsCache) {
+ return planOptionsCache;
+ }
+ const page = await getPlanPage({ pageNo: 1, pageSize: 100 });
+ planOptionsCache = page.list.map((item) => ({
+ label: item.name!,
+ value: item.id!,
+ }));
+ return planOptionsCache;
+}
+
+/** 鐝粍閫夐」缂撳瓨 */
+let teamOptionsCache: OptionItem[] | undefined;
+
+export async function fetchTeamOptions(): Promise<OptionItem[]> {
+ if (teamOptionsCache) {
+ return teamOptionsCache;
+ }
+ const list = await getTeamList();
+ teamOptionsCache = list.map((item) => ({
+ label: item.name!,
+ value: item.id!,
+ }));
+ return teamOptionsCache;
+}
+
+/** 鍛樺伐閫夐」缂撳瓨 */
+let userOptionsCache: OptionItem[] | undefined;
+
+export async function fetchUserOptions(): Promise<OptionItem[]> {
+ if (userOptionsCache) {
+ return userOptionsCache;
+ }
+ const list = await getSimpleUserList();
+ userOptionsCache = list.map((item) => ({
+ label: item.nickname!,
+ value: item.id!,
+ }));
+ return userOptionsCache;
+}
+
+/** 鐢熸垚鎺掔彮鏄庣粏鐨勮〃鍗� */
+export function useGenerateFormSchema(): VbenFormSchema[] {
+ return [
+ {
+ fieldName: 'planId',
+ label: '鎺掔彮璁″垝',
+ component: 'ApiSelect',
+ componentProps: {
+ allowClear: true,
+ api: fetchPlanOptions,
+ optionFilterProp: 'label',
+ placeholder: '璇烽�夋嫨鎺掔彮璁″垝',
+ showSearch: true,
+ },
+ rules: 'selectRequired',
+ help: '鎸夎璁″垝涓嬬殑鐝粍鎺掔彮灞曞紑涓哄憳宸ョ骇鏄庣粏锛岄噸澶嶇敓鎴愪細鍏堟竻鐞嗘棫鏄庣粏',
+ },
+ ];
+}
+
+/** 浜哄伐璋冩暣鎺掔彮鏄庣粏鐨勮〃鍗� */
+export function useFormSchema(): VbenFormSchema[] {
+ return [
+ {
+ fieldName: 'id',
+ component: 'Input',
+ dependencies: {
+ triggerFields: [''],
+ show: () => false,
+ },
+ },
+ {
+ fieldName: 'shiftId',
+ component: 'Input',
+ dependencies: {
+ triggerFields: [''],
+ show: () => false,
+ },
+ },
+ {
+ fieldName: 'shiftName',
+ label: '鐝鍚嶇О',
+ component: 'Input',
+ componentProps: {
+ placeholder: '璇疯緭鍏ョ彮娆″悕绉�',
+ },
+ rules: 'required',
+ },
+ {
+ fieldName: 'startTime',
+ label: '寮�濮嬫椂闂�',
+ component: 'TimePicker',
+ componentProps: {
+ class: '!w-full',
+ format: 'HH:mm',
+ placeholder: '璇烽�夋嫨寮�濮嬫椂闂�',
+ valueFormat: 'HH:mm',
+ },
+ rules: 'required',
+ },
+ {
+ fieldName: 'endTime',
+ label: '缁撴潫鏃堕棿',
+ component: 'TimePicker',
+ componentProps: {
+ class: '!w-full',
+ format: 'HH:mm',
+ placeholder: '璇烽�夋嫨缁撴潫鏃堕棿',
+ valueFormat: 'HH:mm',
+ },
+ rules: 'required',
+ },
+ {
+ fieldName: 'remark',
+ label: '澶囨敞',
+ component: 'Textarea',
+ componentProps: {
+ placeholder: '璇疯緭鍏ュ娉�',
+ rows: 3,
+ },
+ },
+ ];
+}
+
+/** 鍒楄〃鐨勬悳绱㈣〃鍗� */
+export function useGridFormSchema(): VbenFormSchema[] {
+ return [
+ {
+ fieldName: 'planId',
+ label: '鎺掔彮璁″垝',
+ component: 'ApiSelect',
+ componentProps: {
+ allowClear: true,
+ api: fetchPlanOptions,
+ optionFilterProp: 'label',
+ placeholder: '璇烽�夋嫨鎺掔彮璁″垝',
+ showSearch: true,
+ },
+ },
+ {
+ fieldName: 'teamId',
+ label: '鐝粍',
+ component: 'ApiSelect',
+ componentProps: {
+ allowClear: true,
+ api: fetchTeamOptions,
+ optionFilterProp: 'label',
+ placeholder: '璇烽�夋嫨鐝粍',
+ showSearch: true,
+ },
+ },
+ {
+ fieldName: 'userId',
+ label: '鍛樺伐',
+ component: 'ApiSelect',
+ componentProps: {
+ allowClear: true,
+ api: fetchUserOptions,
+ optionFilterProp: 'label',
+ placeholder: '璇烽�夋嫨鍛樺伐',
+ showSearch: true,
+ },
+ },
+ {
+ fieldName: 'day',
+ label: '鏃ユ湡',
+ component: 'RangePicker',
+ componentProps: {
+ ...getRangePickerDefaultProps(),
+ },
+ },
+ ];
+}
+
+/** 鍒楄〃鐨勫瓧娈� */
+export function useGridColumns(): VxeTableGridOptions<MesCalScheduleDetailApi.Detail>['columns'] {
+ return [
+ {
+ field: 'day',
+ title: '鏃ユ湡',
+ minWidth: 120,
+ formatter: 'formatDate',
+ },
+ {
+ field: 'planId',
+ title: '鎺掔彮璁″垝',
+ minWidth: 150,
+ slots: { default: 'planId' },
+ },
+ {
+ field: 'teamId',
+ title: '鐝粍',
+ minWidth: 120,
+ slots: { default: 'teamId' },
+ },
+ {
+ field: 'userId',
+ title: '鍛樺伐',
+ minWidth: 100,
+ slots: { default: 'userId' },
+ },
+ { field: 'shiftName', title: '鐝鍚嶇О', minWidth: 110 },
+ { field: 'startTime', title: '寮�濮嬫椂闂�', width: 100 },
+ { field: 'endTime', title: '缁撴潫鏃堕棿', width: 100 },
+ {
+ field: 'source',
+ title: '鏉ユ簮',
+ width: 110,
+ slots: { default: 'source' },
+ },
+ { field: 'remark', title: '澶囨敞', minWidth: 140 },
+ {
+ title: '鎿嶄綔',
+ width: 180,
+ fixed: 'right',
+ slots: {
+ default: 'actions',
+ },
+ },
+ ];
+}
--
Gitblit v1.9.3