import { message } from 'ant-design-vue';
import { BasicColumn, FormSchema } from '/@/components/Table';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '计划名称',
    align: 'left',
    dataIndex: 'projectName',
    width: 150,
  },
  {
    title: '类型',
    align: 'center',
    dataIndex: 'projectTypeName',
    width: 150,
  },
  {
    title: '执行部门',
    align: 'center',
    dataIndex: 'execDepName',
    width: 100,
  },
  {
    title: '负责人',
    align: 'center',
    dataIndex: 'headName',
    width: 100,
  },
  {
    title: '计划开始日期',
    align: 'center',
    dataIndex: 'planStartDate',
    customRender: ({ text }) => {
      return !text ? '' : text.length > 10 ? text.substr(0, 10) : text;
    },
    width: 130,
  },
  {
    title: '计划结束日期',
    align: 'center',
    dataIndex: 'planEndDate',
    customRender: ({ text }) => {
      return !text ? '' : text.length > 10 ? text.substr(0, 10) : text;
    },
    width: 130,
  },
  {
    title: '状态',
    align: 'center',
    dataIndex: 'statusName',
    width: 100,
  },
  {
    title: '执行规则',
    align: 'center',
    dataIndex: 'exeRule',
    customRender: ({ text }) => {
      return !text ? '' : text==1? "每发生": text==2?"周期性":"一次性";
    },
    width: 100,
  },
  {
    title: '流程状态',
    align: 'center',
    dataIndex: 'bpmStatus',
    width: 100,
    customRender: ({ text }) => {
      return render.renderDict(text, 'bpm_status');
    },
  },
  {
    title: '',
    align: 'center',
    dataIndex: 'projectType',
    width: 0,
  },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: '计划名称',
    field: 'projectName',
    component: 'Input',
    colProps: { span: 6 },
  },
  {
    label: '类型',
    field: 'projectType',
    component: 'Input',
    colProps: { span: 6 },
  },
  {
    label: '执行部门',
    field: 'execDepCode',
    component: 'Input',
    colProps: { span: 6 },
  },
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '计划名称',
    field: 'projectName',
    component: 'Input',
    colProps: { lg: 12 },
    itemProps: { labelCol: { xs: { span: 24 }, sm: { span: 6 } }, wrapperCol: { xs: { span: 24 }, sm: { span: 18 } } },
    dynamicRules: ({ model, schema }) => {
      return [{ required: true, message: '请输入项目名称!' }];
    },
  },
  {
    label: '类型',
    field: 'projectType',
    component: 'JCategorySelect',
    componentProps: {
      pcode: 'B09',
      valueType: 'code'
    },
    colProps: { lg: 12 },
    itemProps: { labelCol: { xs: { span: 24 }, sm: { span: 6 } }, wrapperCol: { xs: { span: 24 }, sm: { span: 18 } } },
    dynamicRules: ({ model, schema }) => {
      return [{ required: true, message: '请选择项目类型!' }];
    },
  },

  {
    label: '计划开始日期',
    field: 'planStartDate',
    component: 'DatePicker',
    colProps: { lg: 12 },
    itemProps: { labelCol: { xs: { span: 24 }, sm: { span: 6 } }, wrapperCol: { xs: { span: 24 }, sm: { span: 18 } } },
    dynamicRules: ({ model, schema }) => {
      return [{ required: false, message: '请选择计划开始日期!' }];
    },
  },
  {
    label: '计划结束日期',
    field: 'planEndDate',
    component: 'DatePicker',
    colProps: { lg: 12 },
    itemProps: { labelCol: { xs: { span: 24 }, sm: { span: 6 } }, wrapperCol: { xs: { span: 24 }, sm: { span: 18 } } },
    dynamicRules: ({ model, schema }) => {
      return [{ required: false, message: '请选择计划结束日期!' }];
    },
  },
  {
    label: '依据',
    field: 'planBasis',
    component: 'Input', // 使用基础组件类型
    slot: 'planBasis',
    itemProps: { 
      labelCol: { xs: { span: 24 }, sm: { span: 3 } }, 
      wrapperCol: { xs: { span: 24 }, sm: { span: 21 } } 
    }
  },
  {
    label: '要求',
    field: 'planRequest',
    component: 'InputTextArea',
    itemProps: { labelCol: { xs: { span: 24 }, sm: { span: 3 } }, wrapperCol: { xs: { span: 24 }, sm: { span: 21 } } },
    dynamicRules: ({ model, schema }) => {
      return [{ required: false, message: '请输入要求!' }];
    },
  },
  {
    label: '交付物',
    field: 'planDeliverable',
    component: 'Input',
    colProps: { lg: 12 },
    itemProps: { labelCol: { xs: { span: 24 }, sm: { span: 6 } }, wrapperCol: { xs: { span: 24 }, sm: { span: 18 } } },
    dynamicRules: ({ model, schema }) => {
      return [{ required: true, message: '请输入交付物!' }];
    },
  },
  // {
  //   label: '审核类型',
  //   field: 'executeType',
  //   component: 'Select',
  //   componentProps: {
  //     options: [
  //       { label: '流程A', value: 1 },
  //       { label: '流程B', value: 2 },
  //       { label: '流程C', value: 3 },
  //     ],
  //   },
  //   colProps: { lg: 12 },
  //   itemProps: { labelCol: { xs: { span: 24 }, sm: { span: 6 } }, wrapperCol: { xs: { span: 24 }, sm: { span: 18 } } },
  //   dynamicRules: ({ model, schema }) => {
  //     return [{ required: false, message: '请选择执行规则!' }];
  //   },
  // },
  {
    label: '描述',
    field: 'projectDesc',
    component: 'InputTextArea',
    itemProps: { labelCol: { xs: { span: 24 }, sm: { span: 3 } }, wrapperCol: { xs: { span: 24 }, sm: { span: 21 } } },
    dynamicRules: ({ model, schema }) => {
      return [{ required: false, message: '请输入项目描述!' }];
    },
  },
  {
    label: '相关附件',
    field: 'fileUploadPath',
    component: 'JUpload',
    itemProps: { labelCol: { xs: { span: 24 }, sm: { span: 3 } }, wrapperCol: { xs: { span: 24 }, sm: { span: 21 } } },
    componentProps: { desText: '支持扩展名: .rar .zip .doc .docx .pdf .jpg...' },
  },
  {
    label: '审核意见',
    field: 'approveDes',
    component: 'InputTextArea',
    itemProps: { labelCol: { xs: { span: 24 }, sm: { span: 3 } }, wrapperCol: { xs: { span: 24 }, sm: { span: 21 } } },
    show: false,
  },
  // TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false,
  },
];

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