From 7a5c5250b66cc6faffbcac9e192073473c50f79f Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期五, 28 八月 2026 17:02:04 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/dev_pro2.0' into dev_pro2.0

---
 src/views/hrm/shift/data.ts |  186 ++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 186 insertions(+), 0 deletions(-)

diff --git a/src/views/hrm/shift/data.ts b/src/views/hrm/shift/data.ts
new file mode 100644
index 0000000..123b748
--- /dev/null
+++ b/src/views/hrm/shift/data.ts
@@ -0,0 +1,186 @@
+import type { VbenFormSchema } from '#/adapter/form';
+import type { VxeTableGridOptions } from '#/adapter/vxe-table';
+import type { HrmShiftApi } from '#/api/hrm/shift';
+
+import { DICT_TYPE } from '#/packages/constants/src';
+import { getDictOptions } from '#/packages/effects/hooks/src';
+
+/** 琛ㄥ崟绫诲瀷 */
+export type FormType = 'create' | 'update' | 'detail';
+
+/** 鐝鏍囩棰滆壊棰勮 */
+export const SHIFT_COLORS = [
+  { label: '钃濊壊', value: '#1677ff' },
+  { label: '缁胯壊', value: '#52c41a' },
+  { label: '姗欒壊', value: '#fa8c16' },
+  { label: '绱壊', value: '#722ed1' },
+  { label: '绮夎壊', value: '#eb2f96' },
+  { label: '榛勮壊', value: '#faad14' },
+  { label: '闈掕壊', value: '#13c2c2' },
+  { label: '鐏拌壊', value: '#8c8c8c' },
+];
+
+/** 鏂板/缂栬緫/鏌ョ湅鐝鐨勮〃鍗� */
+export function useFormSchema(formType: FormType): VbenFormSchema[] {
+  return [
+    {
+      fieldName: 'id',
+      component: 'Input',
+      dependencies: {
+        triggerFields: [''],
+        show: () => false,
+      },
+    },
+    {
+      fieldName: 'name',
+      label: '鐝鍚嶇О',
+      component: 'Input',
+      componentProps: {
+        placeholder: '璇疯緭鍏ョ彮娆″悕绉帮紝濡傦細鐧界彮銆佸鐝�',
+        maxlength: 50,
+      },
+      rules: 'required',
+    },
+    {
+      fieldName: 'startTime',
+      label: '涓婄彮鏃堕棿',
+      component: 'TimePicker',
+      componentProps: {
+        placeholder: '閫夋嫨涓婄彮鏃堕棿',
+        valueFormat: 'HH:mm:ss',
+        format: 'HH:mm:ss',
+        style: { width: '100%' },
+      },
+      rules: 'required',
+    },
+    {
+      fieldName: 'endTime',
+      label: '涓嬬彮鏃堕棿',
+      component: 'TimePicker',
+      componentProps: {
+        placeholder: '閫夋嫨涓嬬彮鏃堕棿',
+        valueFormat: 'HH:mm:ss',
+        format: 'HH:mm:ss',
+        style: { width: '100%' },
+      },
+      rules: 'required',
+    },
+    {
+      fieldName: 'workHours',
+      label: '鏍囧噯宸ユ椂(灏忔椂)',
+      component: 'InputNumber',
+      componentProps: {
+        placeholder: '濡� 8銆�8.5',
+        min: 0.5,
+        max: 24,
+        precision: 2,
+        style: { width: '100%' },
+      },
+    },
+    {
+      fieldName: 'crossDay',
+      label: '鏄惁璺ㄥぉ',
+      component: 'Switch',
+      componentProps: {
+        checkedValue: true,
+        unCheckedValue: false,
+      },
+    },
+    {
+      fieldName: 'color',
+      label: '鏍囩棰滆壊',
+      component: 'Select',
+      componentProps: {
+        options: SHIFT_COLORS,
+        placeholder: '璇烽�夋嫨棰滆壊',
+        style: { width: '100%' },
+      },
+    },
+    {
+      fieldName: 'status',
+      label: '鐘舵��',
+      component: 'RadioGroup',
+      componentProps: {
+        options: getDictOptions(DICT_TYPE.COMMON_STATUS, 'number'),
+      },
+    },
+    {
+      fieldName: 'remark',
+      label: '澶囨敞',
+      component: 'Textarea',
+      formItemClass: 'col-span-2',
+      componentProps: {
+        placeholder: '璇疯緭鍏ュ娉�',
+        rows: 2,
+        maxlength: 500,
+        showCount: true,
+      },
+    },
+  ];
+}
+
+/** 鍒楄〃鐨勬悳绱㈣〃鍗� */
+export function useGridFormSchema(): VbenFormSchema[] {
+  return [
+    {
+      fieldName: 'name',
+      label: '鐝鍚嶇О',
+      component: 'Input',
+      componentProps: {
+        allowClear: true,
+        placeholder: '璇疯緭鍏ョ彮娆″悕绉�',
+      },
+    },
+    {
+      fieldName: 'status',
+      label: '鐘舵��',
+      component: 'Select',
+      componentProps: {
+        allowClear: true,
+        options: getDictOptions(DICT_TYPE.COMMON_STATUS, 'number'),
+        placeholder: '璇烽�夋嫨鐘舵��',
+      },
+    },
+  ];
+}
+
+/** 鍒楄〃鐨勫瓧娈� */
+export function useGridColumns(): VxeTableGridOptions<HrmShiftApi.Shift>['columns'] {
+  return [
+    { field: 'name', title: '鐝鍚嶇О', minWidth: 120 },
+    { field: 'startTime', title: '涓婄彮鏃堕棿', width: 100 },
+    { field: 'endTime', title: '涓嬬彮鏃堕棿', width: 100 },
+    { field: 'workHours', title: '鏍囧噯宸ユ椂(h)', width: 110 },
+    {
+      field: 'crossDay',
+      title: '璺ㄥぉ',
+      width: 80,
+      formatter: ({ cellValue }) => (cellValue ? '鏄�' : '鍚�'),
+    },
+    {
+      field: 'color',
+      title: '鏍囩棰滆壊',
+      width: 110,
+      slots: {
+        default: 'color',
+      },
+    },
+    {
+      field: 'status',
+      title: '鐘舵��',
+      width: 90,
+      cellRender: {
+        name: 'CellDict',
+        props: { type: DICT_TYPE.COMMON_STATUS },
+      },
+    },
+    {
+      title: '鎿嶄綔',
+      width: 150,
+      fixed: 'right',
+      slots: {
+        default: 'actions',
+      },
+    },
+  ];
+}

--
Gitblit v1.9.3