import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
   {
    title: '外包商名称',
    align:"left",
    dataIndex: 'outsourcerName',
    width:150
   },
   {
    title: '外包商分类',
    align:"left",
    dataIndex: 'outsourcerClassify',
    customRender: ({ text }) => {
      return render.renderDict(text, 'outsourcerClassify');
    },
    width:100
   },
   {
    title: '外包商说明',
    align:"left",
    dataIndex: 'outsourcerDes',
    width:150
   },
   {
    title: '登记日期',
    align:"center",
    dataIndex: 'registDate',
    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, 'outStatus'), color);
    },
    width:100
   },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: '外包商名称',
    field: 'outsourcerName',
    component: 'Input',
  },
  {
    label: '外包商分类',
    field: 'outsourcerClassify',
    component: 'JSearchSelect',
    componentProps:{
      dict: "outsourcerClassify"
    },
    colProps: {lg: 12},
  },
  {
    label: '当前状态',
    field: 'status',
    component: 'JSearchSelect',
    componentProps:{
      dict: "outStatus"
    },
    colProps: {lg: 12},
  },
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '外包商名称',
    field: 'outsourcerName',
    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: 'outsourcerClassify',
    component: 'JSearchSelect',
    componentProps:{
      dict: "outsourcerClassify"
    },
    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: 'registDate',
    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: "outStatus"
    },
    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: 'outsourcerDes',
    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;
}