From 27c8277d717b34b55f3ea967027b53b067f77df3 Mon Sep 17 00:00:00 2001
From: xiaoyi <908147524@qq.com>
Date: 星期四, 20 八月 2026 16:58:49 +0800
Subject: [PATCH] feat 功能变更

---
 src/views/mes/pro/maintenancecalendar/data.ts |  246 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 246 insertions(+), 0 deletions(-)

diff --git a/src/views/mes/pro/maintenancecalendar/data.ts b/src/views/mes/pro/maintenancecalendar/data.ts
new file mode 100644
index 0000000..f578aac
--- /dev/null
+++ b/src/views/mes/pro/maintenancecalendar/data.ts
@@ -0,0 +1,246 @@
+import type { VbenFormApi, VbenFormSchema } from '#/adapter/form';
+import type { VxeTableGridOptions } from '#/adapter/vxe-table';
+
+import { markRaw } from 'vue';
+
+import { DICT_TYPE } from '@vben/constants';
+import { getDictOptions } from '@vben/hooks';
+
+import { CalTeamSelect } from '#/views/mes/cal/team/components';
+
+/** 琛ㄥ崟绫诲瀷 */
+export type FormType = 'create' | 'detail' | 'edit';
+
+/** 鐘舵�佸父閲� */
+export const CAL_STATUS = {
+  DRAFT: 0,
+  PUBLISHED: 10,
+};
+
+/** 琛ㄥ崟鐨勯厤缃」 */
+export function useFormSchema(formType: FormType, formApi?: VbenFormApi): VbenFormSchema[] {
+  const isReadonly = formType === 'detail';
+  return [
+    {
+      fieldName: 'id',
+      component: 'Input',
+      dependencies: {
+        triggerFields: [''],
+        show: () => false,
+      },
+    },
+    {
+      fieldName: 'code',
+      label: '鏃ュ巻缂栫爜',
+      component: 'Input',
+      componentProps: {
+        placeholder: '绯荤粺鑷姩鐢熸垚',
+        disabled: true,
+      },
+    },
+    {
+      fieldName: 'name',
+      label: '鏃ュ巻鍚嶇О',
+      component: 'Input',
+      componentProps: {
+        placeholder: '璇疯緭鍏ユ棩鍘嗗悕绉�',
+        disabled: isReadonly,
+      },
+      rules: 'required',
+    },
+    {
+      fieldName: 'workDate',
+      label: '浣滀笟鏃ユ湡',
+      component: 'DatePicker',
+      componentProps: {
+        placeholder: '璇烽�夋嫨浣滀笟鏃ユ湡',
+        valueFormat: 'YYYY-MM-DD',
+        disabled: isReadonly,
+      },
+      rules: 'required',
+    },
+    {
+      fieldName: 'shift',
+      label: '鐝',
+      component: 'Select',
+      componentProps: {
+        options: getDictOptions(DICT_TYPE.MES_CAL_SHIFT_TYPE, 'number'),
+        placeholder: '璇烽�夋嫨鐝',
+        disabled: isReadonly,
+      },
+    },
+    {
+      fieldName: 'workType',
+      label: '浣滀笟绫诲瀷',
+      component: 'Select',
+      componentProps: {
+        options: getDictOptions(DICT_TYPE.MES_PRO_CALENDAR_WORK_TYPE, 'number'),
+        placeholder: '璇烽�夋嫨浣滀笟绫诲瀷',
+        disabled: isReadonly,
+      },
+    },
+    {
+      fieldName: 'region',
+      label: '浣滀笟鍖哄煙/绾胯矾',
+      component: 'Input',
+      componentProps: {
+        placeholder: '濡傦細110kV 鍩庡尯绾�',
+        disabled: isReadonly,
+      },
+    },
+    {
+      fieldName: 'teamId',
+      label: '鍊肩彮鐝粍',
+      component: markRaw(CalTeamSelect),
+      componentProps: {
+        placeholder: '璇烽�夋嫨鍊肩彮鐝粍',
+        disabled: isReadonly,
+        onChange: (item: { name?: string } | undefined) => {
+          formApi?.setFieldValue('teamName', item?.name ?? '');
+        },
+      },
+    },
+    {
+      fieldName: 'personnel',
+      label: '鍊肩彮浜哄憳',
+      component: 'Input',
+      componentProps: {
+        placeholder: '濡傦細寮犱笁,鏉庡洓',
+        disabled: isReadonly,
+      },
+    },
+    {
+      fieldName: 'remark',
+      label: '澶囨敞',
+      component: 'Textarea',
+      componentProps: {
+        placeholder: '璇疯緭鍏ュ娉�',
+        autoSize: { minRows: 1, maxRows: 1 },
+        disabled: isReadonly,
+      },
+      formItemClass: 'col-span-3',
+    },
+  ];
+}
+
+/** 鍒楄〃鐨勬悳绱㈣〃鍗� */
+export function useGridFormSchema(): VbenFormSchema[] {
+  return [
+    {
+      fieldName: 'code',
+      label: '鏃ュ巻缂栫爜',
+      component: 'Input',
+      componentProps: {
+        placeholder: '璇疯緭鍏ユ棩鍘嗙紪鐮�',
+      },
+    },
+    {
+      fieldName: 'name',
+      label: '鏃ュ巻鍚嶇О',
+      component: 'Input',
+      componentProps: {
+        placeholder: '璇疯緭鍏ユ棩鍘嗗悕绉�',
+      },
+    },
+    {
+      fieldName: 'workType',
+      label: '浣滀笟绫诲瀷',
+      component: 'Select',
+      componentProps: {
+        allowClear: true,
+        options: getDictOptions(DICT_TYPE.MES_PRO_CALENDAR_WORK_TYPE, 'number'),
+        placeholder: '璇烽�夋嫨浣滀笟绫诲瀷',
+      },
+    },
+    {
+      fieldName: 'status',
+      label: '鐘舵��',
+      component: 'Select',
+      componentProps: {
+        allowClear: true,
+        options: [
+          { label: '鑽夌', value: CAL_STATUS.DRAFT },
+          { label: '宸插彂甯�', value: CAL_STATUS.PUBLISHED },
+        ],
+        placeholder: '璇烽�夋嫨鐘舵��',
+      },
+    },
+  ];
+}
+
+/** 鍒楄〃鐨勮〃鏍煎垪 */
+export function useGridColumns(): VxeTableGridOptions['columns'] {
+  return [
+    { type: 'checkbox', width: 50 },
+    { type: 'seq', title: '搴忓彿', width: 60 },
+    {
+      field: 'code',
+      title: '鏃ュ巻缂栫爜',
+      minWidth: 150,
+      slots: { default: 'code' },
+    },
+    {
+      field: 'name',
+      title: '鏃ュ巻鍚嶇О',
+      minWidth: 180,
+    },
+    {
+      field: 'workDate',
+      title: '浣滀笟鏃ユ湡',
+      width: 120,
+      formatter: 'formatDate',
+    },
+    {
+      field: 'shift',
+      title: '鐝',
+      width: 100,
+      cellRender: {
+        name: 'CellDict',
+        props: { type: DICT_TYPE.MES_CAL_SHIFT_TYPE },
+      },
+    },
+    {
+      field: 'workType',
+      title: '浣滀笟绫诲瀷',
+      width: 110,
+      cellRender: {
+        name: 'CellDict',
+        props: { type: DICT_TYPE.MES_PRO_CALENDAR_WORK_TYPE },
+      },
+    },
+    {
+      field: 'region',
+      title: '浣滀笟鍖哄煙/绾胯矾',
+      minWidth: 140,
+    },
+    {
+      field: 'teamName',
+      title: '鍊肩彮鐝粍',
+      minWidth: 130,
+    },
+    {
+      field: 'personnel',
+      title: '鍊肩彮浜哄憳',
+      minWidth: 140,
+    },
+    {
+      field: 'status',
+      title: '鐘舵��',
+      width: 100,
+      slots: { default: 'status' },
+    },
+    {
+      field: 'createTime',
+      title: '鍒涘缓鏃堕棿',
+      width: 170,
+      formatter: 'formatDateTime',
+    },
+    {
+      field: 'action',
+      title: '鎿嶄綔',
+      width: 260,
+      fixed: 'right',
+      slots: { default: 'actions' },
+    },
+  ];
+}

--
Gitblit v1.9.3