import type {
  ProColumns,
  ProDescriptionsItemProps,
  ProFormColumnsType,
} from '@ant-design/pro-components';
import dayjs from 'dayjs';
import type { SmsChannelVO } from '@/services/system/message/sms/channel';
export const baseTenantColumns: ProColumns<SmsChannelVO>[] = [
  {
    title: '编号',
    dataIndex: 'id',
    width: 100,
    hideInSearch: true, // 在搜索表单中隐藏
  },
  {
    title: '短信签名',
    dataIndex: 'signature',
  },

  {
    title: '渠道编码',
    dataIndex: 'code',
    hideInSearch: true, // 在搜索表单中隐藏
  },
  {
    title: '启用状态',
    dataIndex: 'status',
    valueType: 'select',
  },
  {
    title: '备注',
    dataIndex: 'remark',
    hideInSearch: true, // 在搜索表单中隐藏
  },
  {
    title: '短信 API 的账号',
    dataIndex: 'apiKey',
    hideInSearch: true, // 在搜索表单中隐藏
  },

  {
    title: '短信 API 的密钥',
    dataIndex: 'apiSecret',
    hideInSearch: true, // 在搜索表单中隐藏
  },
  {
    title: '短信发送回调 URL',
    dataIndex: 'callbackUrl',
    hideInSearch: true,
  },
  {
    title: '创建时间',
    dataIndex: 'createTime',
    valueType: 'dateRange',
    search: {
      transform: (value) => {
        return {
          [`createTime[0]`]: dayjs(value[0])
            .startOf('day')
            .format('YYYY-MM-DD HH:mm:ss'),
          [`createTime[1]`]: dayjs(value[1])
            .endOf('day')
            .format('YYYY-MM-DD HH:mm:ss'),
        };
      },
    },
    render: (_, record: SmsChannelVO) =>
      dayjs(record.createTime).format('YYYY-MM-DD HH:mm:ss'),
  },
];

export const formColumns = (type: string): ProFormColumnsType[] => [
  {
    title: '短信签名',
    dataIndex: 'signature',
    formItemProps: {
      rules: [
        {
          required: true,
          message: '请输入用户名',
        },
      ],
    },
  },
  {
    title: '渠道编码',
    dataIndex: 'code',
    valueType: 'select',
    formItemProps: {
      rules: [
        {
          required: true,
          message: '请输入用户名',
        },
      ],
    },
  },
  {
    title: '启用状态',
    dataIndex: 'status',
    valueType: 'radio',
  },
  {
    title: '备注',
    dataIndex: 'remark',
  },
  {
    title: '短信 API 的账号',
    dataIndex: 'apiKey',
    formItemProps: {
      rules: [
        {
          required: true,
          message: '请输入用户名',
        },
      ],
    },
  },
  {
    title: '短信 API 的密钥',
    dataIndex: 'apiSecret',
  },
  {
    title: '短信发送回调 URL',
    dataIndex: 'callbackUrl',
  },
];
