import {BasicColumn} from '/@/components/Table';
import {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: 'projectType',
    customRender: ({ text }) => {
      return render.renderDict(text, 'proProjectType');
    },
    width:100
   },
   {
    title: '项目说明',
    align:"left",
    dataIndex: 'projectDes',
    width:250
   },
   {
    title: '启动日期',
    align:"center",
    dataIndex: 'startDate',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text)
    },
    width:130
   },
   {
    title: '当前状态',
    align:"center",
    dataIndex: 'status',
    customRender: ({ text }) => {
      const color = text == '1' ? 'green' : text == '0' ? 'red' : 'gray';
      return render.renderTag(render.renderDict(text, 'proStatus'), color);
    },
    width:80
   },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: '外包商名称',
    field: 'outsourcerName',
    component: 'Input',
  },
  {
    label: '外包商分类',
    field: 'projectType',
    component: 'JSearchSelect',
    componentProps:{
      dict: "proProjectType"
    },
    colProps: {lg: 12},
  },
  {
    label: '当前状态',
    field: 'status',
    component: 'JSearchSelect',
    componentProps:{
      dict: "proStatus"
    },
    colProps: {lg: 12},
  },
];
//表单数据
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: ({values}) => {
      if(values.showFooter===undefined||values.showFooter){
        return [
          { required: true, message: '请选择项目名称'},
        ];
      }
      return [];
    },
  },
  {
    label: '项目类型',
    field: 'projectType',
    component: 'JSearchSelect',
    componentProps:{
      dict: "proProjectType"
    },
   colProps: {lg: 12},
   itemProps:{labelCol:{xs: {span: 24},sm: {span: 6},},wrapperCol:{xs: {span: 24},sm: {span: 18},}},
    dynamicRules: ({values}) => {
      if(values.showFooter===undefined||values.showFooter){
        return [
          { required: true, message: '请选择项目类型'},
        ];
      }
      return [];
    },
  },
  {
    label: '启动日期',
    field: 'startDate',
    component: 'DatePicker',
    colProps: {lg: 12},
   itemProps:{labelCol:{xs: {span: 24},sm: {span: 6},},wrapperCol:{xs: {span: 24},sm: {span: 18},}},
    dynamicRules: ({values}) => {
      if(values.showFooter===undefined||values.showFooter){
        return [
          { required: true, message: '请选择启动日期'},
        ];
      }
      return [];
    },
  },
  {
    label: '当前状态',
    field: 'status',
    component: 'JSearchSelect',
    componentProps:{
      dict: "proStatus"
    },
    colProps: {lg: 12},
    itemProps:{labelCol:{xs: {span: 24},sm: {span: 6},},wrapperCol:{xs: {span: 24},sm: {span: 18},}},
    dynamicRules: ({values}) => {
      if(values.showFooter===undefined||values.showFooter){
        return [
          { required: true, message: '请选择当前状态'},
        ];
      }
      return [];
    },
  },
  {
    label: '项目说明',
    field: 'projectDes',
    component: 'InputTextArea',
    itemProps:{labelCol:{xs: {span: 24},sm: {span: 3},},wrapperCol:{xs: {span: 24},sm: {span: 21},}},
    dynamicRules: ({values}) => {
      if(values.showFooter===undefined||values.showFooter){
        return [
          { required: true, message: '请选择项目说明'},
        ];
      }
      return [];
    },
    componentProps: {
      rows: 5
    }
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
  {
	  label: '',
	  field: 'showFooter',
	  component: 'Input',
	  show: false
	},
];



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