import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { rules } from '/@/utils/helper/validator';
import { list } from '../substationTabel/substation.api';
export const columns: BasicColumn[] = [
  {
    title: '名称',
    dataIndex: 'strname',
    width: 120,
  },
  {
    title: '安装位置',
    dataIndex: 'strinstallpos',
    width: 100,
  },
  {
    title: '是否为常闭型',
    dataIndex: 'bnormalclose',
    width: 100,
    // customRender: render.renderAvatar,
  },
  {
    title: '净宽',
    dataIndex: 'fclearwidth',
    width: 80,
    sorter: true,
  },
  {
    title: '净高',
    dataIndex: 'fclearheight',
    width: 100,
    sorter: true,
  },
  {
    title: '风门道数',
    dataIndex: 'ndoorcount',
    width: 100,
  },
  {
    title: '所属分站',
    width: 150,
    dataIndex: 'stationname',
  },
  {
    title: '点表',
    width: 100,
    dataIndex: 'strtype_dictText',
  },
  {
    title: '是否开启监测',
    dataIndex: 'monitorflag_dictText',
    width: 100,
  },
  {
    title: '是否模拟数据',
    dataIndex: 'testflag_dictText',
    width: 100,
  },
];

export const recycleColumns: BasicColumn[] = [
  {
    title: '名称',
    dataIndex: 'strname',
    width: 100,
  },
  {
    title: '是否为常闭型',
    dataIndex: 'bnormalclose',
    width: 100,
  },
];

export const searchFormSchema: FormSchema[] = [
  {
    label: '名称',
    field: 'strname',
    component: 'Input',
    colProps: { span: 6 },
  },
  {
    label: '安装位置',
    field: 'strinstallpos',
    component: 'Input',
    colProps: { span: 6 },
  },
  {
    label: '是否为常闭型',
    field: 'bnormalclose',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: 'user_status',
      placeholder: '请选择读写类型',
      stringToNumber: true,
    },
    colProps: { span: 6 },
  },
];

export const formSchema: FormSchema[] = [
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false,
  },
  {
    label: '名称',
    field: 'strname',
    component: 'Input',
  },
  {
    label: '安装位置',
    field: 'strinstallpos',
    component: 'Input',
  },
  {
    label: '是否为常闭型',
    field: 'bnormalclose',
    component: 'RadioGroup',
    defaultValue: 1,
    componentProps: () => {
      return {
        options: [
          { label: '是', value: 1, key: '1' },
          { label: '否', value: 0, key: '2' },
        ],
      };
    },
  },
  {
    label: '净宽',
    field: 'fclearwidth',
    component: 'Input',
  },
  {
    label: '净高',
    field: 'fclearheight',
    component: 'Input',
  },
  {
    label: '风门道数',
    field: 'ndoorcount',
    component: 'Input',
  },
  {
    label: '所属分站',
    field: 'nsubstationid',
    component: 'ApiSelect',
    componentProps: {
      api: list,
      labelField: 'strname',
      valueField: 'nsubstationid',
    },
  },
  {
    label: '点表',
    field: 'strtype',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: 'strtype',
      placeholder: '请选择状态',
    },
  },
  {
    label: '监测类型',
    field: 'monitorflag',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: 'devicekind',
      placeholder: '请选择状态',
    },
  },
  {
    label: '是否开启监测',
    field: 'monitorflag',
    component: 'RadioGroup',
    defaultValue: 1,
    componentProps: () => {
      return {
        options: [
          { label: '是', value: 1, key: '1' },
          { label: '否', value: 0, key: '2' },
        ],
      };
    },
  },
  {
    label: '是否模拟数据',
    field: 'testflag',
    component: 'RadioGroup',
    defaultValue: 1,
    componentProps: () => {
      return {
        options: [
          { label: '是', value: 1, key: '1' },
          { label: '否', value: 0, key: '2' },
        ],
      };
    },
  },
];

export const formPasswordSchema: FormSchema[] = [
  {
    label: '用户账号',
    field: 'username',
    component: 'Input',
    componentProps: { readOnly: true },
  },
  {
    label: '登录密码',
    field: 'password',
    component: 'StrengthMeter',
    componentProps: {
      placeholder: '请输入登录密码',
    },
    rules: [
      {
        required: true,
        message: '请输入登录密码',
      },
    ],
  },
  {
    label: '确认密码',
    field: 'confirmPassword',
    component: 'InputPassword',
    dynamicRules: ({ values }) => rules.confirmPassword(values, true),
  },
];

export const formAgentSchema: FormSchema[] = [
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false,
  },
  {
    field: 'userName',
    label: '用户名',
    component: 'Input',
    componentProps: {
      readOnly: true,
      allowClear: false,
    },
  },
  {
    field: 'agentUserName',
    label: '代理人用户名',
    required: true,
    component: 'JSelectUser',
    componentProps: {
      rowKey: 'username',
      labelKey: 'realname',
      maxSelectCount: 10,
    },
  },
  {
    field: 'startTime',
    label: '代理开始时间',
    component: 'DatePicker',
    required: true,
    componentProps: {
      showTime: true,
      valueFormat: 'YYYY-MM-DD HH:mm:ss',
      placeholder: '请选择代理开始时间',
    },
  },
  {
    field: 'endTime',
    label: '代理结束时间',
    component: 'DatePicker',
    required: true,
    componentProps: {
      showTime: true,
      valueFormat: 'YYYY-MM-DD HH:mm:ss',
      placeholder: '请选择代理结束时间',
    },
  },
  {
    field: 'status',
    label: '状态',
    component: 'JDictSelectTag',
    defaultValue: '1',
    componentProps: {
      dictCode: 'valid_status',
      type: 'radioButton',
    },
  },
];
