import { BasicColumn, FormSchema, render } from '@jdlinker/ui';

//列表数据
export const columns: BasicColumn[] = [
  {
    title: '规则名称',
    align: 'center',
    dataIndex: 'name'
  },
  {
    title: '业务表',
    align: 'center',
    dataIndex: 'tableName'
  },
  {
    title: '规则字段',
    align: 'center',
    dataIndex: 'ruleCode'
  },
  {
    title: '规则值',
    align: 'center',
    dataIndex: 'ruleVal'
  },
  {
    title: '类型',
    align: 'center',
    dataIndex: 'ruleType',
    customRender: ({ text }) => {
      return text === 1 ? '自定义' : '系统';
    }
  },
  {
    title: '状态',
    align: 'center',
    dataIndex: 'status',
    customRender: ({ text }) => {
      return render.renderDict(text, 'dict_item_status');
    }
  },
  {
    title: '创建时间',
    align: 'center',
    dataIndex: 'createTime'
  }
];
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: '规则名称',
    field: 'name',
    component: 'Input'
  },
  {
    label: '规则字段',
    field: 'ruleCode',
    component: 'Input'
  },
  {
    label: '类型',
    field: 'ruleType',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: 'sys_rule_type',
      placeholder: '请选择类型',
      stringToNumber: true
    }
  }
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '规则名称',
    field: 'name',
    component: 'Input'
  },
  {
    label: '业务表',
    field: 'tableName',
    component: 'Input'
  },
  {
    label: '规则字段',
    field: 'ruleCode',
    component: 'Input'
  },
  {
    label: '规则值',
    field: 'ruleVal',
    component: 'Input'
  },
  {
    label: '类型',
    field: 'ruleType',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: 'sys_rule_type',
      placeholder: '请选择类型',
      stringToNumber: true
    }
  },
  {
    label: '选中字段',
    field: 'labelKey',
    component: 'Input'
  },
  {
    label: '搜索字段',
    field: 'searchColumn',
    component: 'InputTextArea'
  },
  {
    label: '列表字段',
    field: 'listColumn',
    component: 'InputTextArea'
  },
  {
    label: '字典字段',
    field: 'dictColumn',
    component: 'InputTextArea'
  },
  {
    label: '描述',
    field: 'description',
    component: 'Input'
  },
  {
    label: '状态',
    field: 'status',
    defaultValue: 1,
    component: 'JDictSelectTag',
    componentProps: {
      type: 'radioButton',
      dictCode: 'dict_item_status',
      stringToNumber: true
    }
  },
  // TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false
  }
];

/**
 * 流程表单调用这个方法获取formSchema
 * @param _formData
 */
export function getBpmFormSchema(_formData): FormSchema[] {
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}
