/**
 * 灾害预警信息表单配置
 */
import type { FormConfig } from '@/types/basic-form';
import { IS_EMERGENCY } from '@/views/disaster/constant';

// 通用表单信息
const BASIC_FROM_CONFIG = {
  DISASTER_LEVEL: {
    label: '灾害等级：',
    prop: 'disasterLevel',
    slot: 'disasterLevel',
  },
  IS_PUSH: {
    label: '是否推送：',
    prop: 'isPush',
    slot: 'isPush',
  },
  CREATE_USER: {
    label: '创建人：',
    prop: 'realname',
    component: 'ElInput',
    componentProps: {
      disabled: true,
    },
  },
};

// 预警信息表单信息
export const WARNING_INFO_FROM_CONFIG: FormConfig[] = [
  {
    label: '预警类型：',
    prop: 'disasterType',
    slot: 'disasterType',
  },
  BASIC_FROM_CONFIG.DISASTER_LEVEL,
  {
    label: '预警时间：',
    prop: 'warnTime',
    component: 'ElDatePicker',
    componentProps: {
      placeholder: '请选择预警时间',
      type: 'datetime',
      format: 'YYYY-MM-DD HH:mm',
      dateFormat: 'MMM DD, YYYY',
      timeFormat: 'HH:mm',
      valueFormat: 'YYYY-MM-DD HH:mm',
    },
  },
  {
    label: '信息来源：',
    prop: 'source',
    component: 'ElInput',
    componentProps: {
      placeholder: '请输入信息来源',
      maxlength: 200,
      showWordLimit: true,
    },
  },
  {
    label: '发布内容：',
    prop: 'content',
    component: 'ElInput',
    componentProps: {
      placeholder: '请输入发布内容',
      type: 'textarea',
      rows: 5,
    },
  },
  {
    label: '启动应急事件：',
    prop: 'isEmergency',
    slot: 'isEmergency',
  },
  {
    label: '应急事件类型：',
    prop: 'eventType',
    slot: 'eventType',
  },
  BASIC_FROM_CONFIG.IS_PUSH,
  BASIC_FROM_CONFIG.CREATE_USER,
];

// 防御通知表单信息
export const DEFENSE_NOTICE_FROM_CONFIG: FormConfig[] = [
  {
    label: '灾害类型：',
    prop: 'disasterType',
    slot: 'disasterType',
  },
  BASIC_FROM_CONFIG.DISASTER_LEVEL,
  {
    label: '标题：',
    prop: 'title',
    component: 'ElInput',
    componentProps: {
      placeholder: '请输入标题',
      maxlength: 200,
      showWordLimit: true,
    },
  },
  {
    label: '内容：',
    prop: 'content',
    component: 'ElInput',
    componentProps: {
      placeholder: '请输入内容',
      type: 'textarea',
      rows: 5,
      maxlength: 1000,
      showWordLimit: true,
    },
  },
  {
    label: '文件：',
    prop: 'attachmentListRes',
    slot: 'attachmentListRes',
  },
  BASIC_FROM_CONFIG.IS_PUSH,
  BASIC_FROM_CONFIG.CREATE_USER,
];

// 通用表单数据
const BASIC_FROM_DATA = {
  disasterType: '',
  disasterLevel: '',
  content: '',
  userGroupList: [],
  isPush: null,
  realname: '',
};

// 预警信息表单数据
export const WARNING_INFO_FROM_DATA = {
  ...BASIC_FROM_DATA,
  warnTime: '',
  source: '',
  isEmergency: IS_EMERGENCY.EMERGENCY,
  eventType: '',
};

// 防御通知表单数据
export const DEFENSE_NOTICE_FROM_DATA = {
  ...BASIC_FROM_DATA,
  title: '',
  attachmentListRes: [],
  pushTime: '',
  createdAt: '',
};

// 通用表单规则
const BASIC_FROM_RULES = {
  userGroupList: [{ required: true, message: '请选择用户组', trigger: 'change' }],
  isPush: [{ required: true, message: '请选择是否推送', trigger: 'change' }],
};

// 预警信息表单规则
export const WARNING_INFO_FROM_RULES = {
  disasterType: [{ required: true, message: '请选择预警类型', trigger: 'change' }],
  disasterLevel: [
    {
      required: true,
      message: '请选择灾害等级',
      trigger: 'change',
    },
  ],
  ...BASIC_FROM_RULES,
  warnTime: [{ required: true, message: '请选择预警时间', trigger: 'change' }],
  source: [{ required: true, message: '请输入信息来源', trigger: 'blur' }],
  isEmergency: [{ required: true, message: '请选择是否启动应急事件', trigger: 'change' }],
  eventType: [{ required: true, message: '请选择应急事件类型', trigger: 'change' }],
};

// 防御通知表单规则
export const DEFENSE_NOTICE_FROM_RULES = {
  ...BASIC_FROM_RULES,
  title: [{ required: true, message: '请输入标题', trigger: 'blur' }],
};
