liu
2026-10-26 910b2ead53df78a62a06d1bdfc3e05c8c5b5fc65
src/views/hrm/attendance/rule/data.ts
@@ -11,8 +11,18 @@
/** 表单类型 */
export type FormType = 'create' | 'update' | 'detail';
export interface LocationFormCallbacks {
  onLatitudeChange?: (value?: number) => void;
  onLocationRequiredChange?: (value: boolean) => void;
  onLongitudeChange?: (value?: number) => void;
  onRadiusChange?: (value?: number) => void;
}
/** 新增/编辑考勤规则的表单 */
export function useFormSchema(formType: FormType): VbenFormSchema[] {
export function useFormSchema(
  formType: FormType,
  locationCallbacks: LocationFormCallbacks = {},
): VbenFormSchema[] {
  return [
    {
      fieldName: 'id',
@@ -112,6 +122,7 @@
      defaultValue: false,
      componentProps: {
        checkedChildren: '启用',
        onChange: locationCallbacks.onLocationRequiredChange,
        unCheckedChildren: '关闭',
      },
    },
@@ -140,7 +151,13 @@
      fieldName: 'longitude',
      label: '经度(WGS84)',
      component: 'InputNumber',
      componentProps: { min: -180, max: 180, precision: 7, style: { width: '100%' } },
      componentProps: {
        min: -180,
        max: 180,
        onChange: locationCallbacks.onLongitudeChange,
        precision: 7,
        style: { width: '100%' },
      },
      dependencies: {
        triggerFields: ['locationRequired'],
        show: (values) => Boolean(values.locationRequired),
@@ -151,7 +168,13 @@
      fieldName: 'latitude',
      label: '纬度(WGS84)',
      component: 'InputNumber',
      componentProps: { min: -90, max: 90, precision: 7, style: { width: '100%' } },
      componentProps: {
        min: -90,
        max: 90,
        onChange: locationCallbacks.onLatitudeChange,
        precision: 7,
        style: { width: '100%' },
      },
      dependencies: {
        triggerFields: ['locationRequired'],
        show: (values) => Boolean(values.locationRequired),
@@ -162,8 +185,14 @@
      fieldName: 'radiusMeters',
      label: '打卡半径(米)',
      component: 'InputNumber',
      defaultValue: 100,
      componentProps: { min: 10, max: 5000, precision: 0, style: { width: '100%' } },
      defaultValue: 10,
      componentProps: {
        min: 10,
        max: 5000,
        onChange: locationCallbacks.onRadiusChange,
        precision: 0,
        style: { width: '100%' },
      },
      help: '最小可设 10 米;实际精度取决于手机 GPS 与环境',
      dependencies: {
        triggerFields: ['locationRequired'],