import { BasicColumn, FormSchema } from '/@/components/Table';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '问题项',
    align: 'left',
    dataIndex: 'problemItem',
    width: 120,
  },
  {
    title: '问题示例',
    align: 'left',
    dataIndex: 'problemExample',
    width: 180,
  },
  {
    title: '活动编号',
    align: 'left',
    dataIndex: 'caNo',
    width: 80,
  },
  {
    title: '控制活动名称',
    align: 'left',
    dataIndex: 'caName',
    width: 100,
  },

  // {
  //   title: "问题改进建议",
  //   align:"left",
  //   dataIndex: 'problemAdvise',
  //   width:100
  // },

  {
    title: '所属领域',
    align: 'left',
    dataIndex: 'domainName',
    width: 130,
  },
  {
    title: '风险事件类型',
    align: 'center',
    dataIndex: 'riskEventTp',
    sorter: true,
    width: 80,
    customRender: ({ text }) => {
      return render.renderDict(text, 'eventclassify');
    },
  },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: '控制活动',
    field: 'caName',
    component: 'JInput',
    colProps: { span: 6 },
  },
  {
    label: '问题项',
    field: 'problemItem',
    component: 'JInput',
    colProps: { span: 6 },
  },
  {
    label: '问题示例',
    field: 'problemExample',
    component: 'JInput',
    colProps: { span: 6 },
  },
  {
    label: '所属领域',
    field: 'domainCodeMore',
    component: 'JInput',
    colProps: { span: 6 },
  },
  {
    label: '标签',
    field: 'lableName',
    component: 'JInput',
    colProps: { span: 6 },
  },
  {
    label: '风险事件类型',
    field: 'riskEventTp',
    component: 'JSearchSelect',
    componentProps: {
      dict: 'eventclassify',
    },
  },
];
//表单数据
export const formSchema: FormSchema[] = [
  // {
  //   label: '控制活动编号',
  //   field: 'caNo',
  //   dynamicDisabled: true,
  //   component: 'Input',
  //   colProps: { lg: 12 },
  //   itemProps: { labelCol: { xs: { span: 24 }, sm: { span: 6 } }, wrapperCol: { xs: { span: 24 }, sm: { span: 18 } } },
  // },
  // {
  //   label: '控制活动名称',
  //   field: 'caName',
  //   dynamicDisabled: true,
  //   component: 'Input',
  //   colProps: { lg: 12 },
  //   itemProps: { labelCol: { xs: { span: 24 }, sm: { span: 6 } }, wrapperCol: { xs: { span: 24 }, sm: { span: 18 } } },
  // },
  {
    label: '问题项',
    field: 'problemItem',
    component: 'InputTextArea',
    itemProps: { labelCol: { xs: { span: 24 }, sm: { span: 3 } }, wrapperCol: { xs: { span: 24 }, sm: { span: 21 } } },
    dynamicRules: ({ model, schema }) => {
      return [{ required: true, message: '请输入问题项!' }];
    },
    componentProps: {
      rows: 2,
    },
  },
  {
    label: '问题示例',
    field: 'problemExample',
    component: 'InputTextArea',
    itemProps: { labelCol: { xs: { span: 24 }, sm: { span: 3 } }, wrapperCol: { xs: { span: 24 }, sm: { span: 21 } } },
    dynamicRules: ({ model, schema }) => {
      return [{ required: true, message: '请输入问题示例!' }];
    },
    componentProps: {
      rows: 4,
    },
  },
  {
    label: '改进建议',
    field: 'problemAdvise',
    component: 'InputTextArea',
    itemProps: { labelCol: { xs: { span: 24 }, sm: { span: 3 } }, wrapperCol: { xs: { span: 24 }, sm: { span: 21 } } },
    componentProps: {
      rows: 4,
    },
  },
  // {
  //   label: '风险事件类型',
  //   field: 'riskEventTp',
  //   component: 'JSearchSelect',
  //   componentProps: {
  //     dict: 'eventclassify',
  //     stringToNumber: true,
  //   },
  //   colProps: { lg: 12 },
  //   itemProps: { labelCol: { xs: { span: 24 }, sm: { span: 6 } }, wrapperCol: { xs: { span: 24 }, sm: { span: 18 } } },
  // },
  // TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false,
  },
];

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