import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '问题编号',
    align: 'center',
    dataIndex: 'problemNo',
    ifShow: true,
    width: 100,
  },
  {
    title: '问题来源',
    align: 'center',
    dataIndex: 'problemSource',
    resizable: true,
    width: 150,
  },
  {
    title: '所属领域',
    align: 'center',
    dataIndex: 'domain',
    width: 120,
  },
  {
    title: '问题描述',
    align: 'center',
    dataIndex: 'problemDes',
    resizable: true,
    ifShow: false,
  },
  {
    title: '严重程度',
    align: 'center',
    dataIndex: 'severity',
    width: 100,
    customRender: ({ text }) => {
      return render.renderDict(text, 'severity');
    },
  },
  {
    title: '整改状态',
    align: 'center',
    dataIndex: 'bpmStatus',
    width: 100,
    customRender: ({ text }) => {
      return render.renderDict(text, 'bpm_status');
    },
  },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: '问题来源',
    field: 'problemSource',
    component: 'Input',
    colProps: { span: 6 },
  },
  {
    label: '所属领域',
    field: 'domain',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: 'rate_domain',
    },
    colProps: { span: 6 },
  },
  {
    label: '问题描述',
    field: 'problemDes',
    component: 'Input',
    colProps: { span: 6 },
  },
  {
    label: '严重程度',
    field: 'severity',
    component: 'JSearchSelect',
    componentProps: {
      dict: 'severity',
    },
    colProps: { span: 6 },
  },
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '问题编号',
    field: 'problemNo',
    component: 'Input',
    required: true,
  },
  {
    label: '问题发现方',
    field: 'findUserId',
    component: 'Input',
    required: true,
  },
  {
    label: '问题来源',
    field: 'problemSource',
    component: 'Input',
    required: true,
  },
  {
    label: '所属领域',
    field: 'domain',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: 'rate_domain',
    },
    required: true,
  },
  {
    label: '严重程度',
    field: 'severity',
    component: 'JSearchSelect',
    required: true,
    componentProps: {
      dict: 'severity',
    },
    colProps: { lg: 24 },
  },
  {
    label: '风险等级',
    field: 'riskLevel',
    component: 'JSearchSelect',
    required: true,
    componentProps: {
      dict: 'risk_level',
    },
    colProps: { lg: 24 },
  },
  {
    label: '问题描述',
    field: 'problemDes',
    component: 'InputTextArea',
    required: true,
    componentProps: {
      rows: 3,
    },
  },
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false,
  },
];
// 整改计划
export const planFormSchema: FormSchema[] = [
  {
    label: '问题编号',
    field: 'problemNo',
    component: 'Input',
    dynamicDisabled: true,
  },
  {
    label: '成因分析',
    field: 'causeAnalysis',
    component: 'InputTextArea',
    componentProps: {
      rows: 3,
    },
    required: true,
  },
  {
    label: '整改方案',
    field: 'rectifyPlan',
    component: 'InputTextArea',
    componentProps: {
      rows: 3,
    },
    required: true,
  },
  {
    label: '计划开始日期',
    field: 'planStartDate',
    component: 'DatePicker',
    required: true,
  },
  {
    label: '计划完成日期',
    field: 'planEndDate',
    component: 'DatePicker',
    required: true,
  },
  {
    label: '负责部门',
    field: 'headDepCode',
    component: 'JSelectDept',
    componentProps: {
      multiple: false,
      labelKey: 'departName',
      rowKey: 'orgCode',
    },
    required: true,
  },
  {
    field: 'headUserId',
    component: 'JSelectUser',
    label: '负责人',
    componentProps: {
      multiple: false,
      labelKey: 'realname',
      rowKey: 'id',
    },
    required: true,
  },
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false,
  },
];
// 整改执行
export const executeFormSchema: FormSchema[] = [
  {
    label: '问题编号',
    field: 'problemNo',
    component: 'Input',
    dynamicDisabled: true,
  },
  {
    field: 'execDepCode',
    component: 'JSelectDept',
    label: '执行部门',
    required: true,
    componentProps: {
      multiple: false,
      labelKey: 'departName',
      rowKey: 'orgCode',
    },
  },
  {
    field: 'execUserId',
    component: 'JSelectUser',
    label: '负责人',
    required: true,
    componentProps: {
      multiple: false,
      labelKey: 'realname',
      rowKey: 'id',
    },
  },
  {
    label: '实际开始日期',
    field: 'execStartDate',
    component: 'DatePicker',
    required: true,
  },
  {
    label: '实际完成日期',
    field: 'execEndDate',
    component: 'DatePicker',
    required: true,
  },
  {
    label: '整改落实情况',
    field: 'execRemark',
    component: 'InputTextArea',
    componentProps: {
      rows: 5,
    },
    required: true,
  },
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false,
  },
];
// 整改审核
export const reviewFormSchema: FormSchema[] = [
  {
    label: '问题编号',
    field: 'problemNo',
    component: 'Input',
    dynamicDisabled: true,
  },
  {
    label: '审核意见',
    field: 'reviewComment',
    component: 'InputTextArea',
    componentProps: {
      rows: 5,
    },
  },
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false,
  },
];

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

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

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