import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
   {
    title: '系统名称',
    align:"center",
    dataIndex: 'sysName',
    width:150
   },
   {
    title: '系统类型',
    align:"center",
    dataIndex: 'sysType',
    customRender: ({ text }) => {
      return render.renderDict(text, 'sysType');
    },
    width:100
   },
   {
    title: '系统说明',
    align:"center",
    dataIndex: 'sysDes',
    width:250
   },
   {
    title: '上线日期',
    align:"center",
    dataIndex: 'onLineDate',
    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, 'sysStatus'), color);
    },
    width:80
   },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: '系统名称',
    field: 'sysName',
    component: 'Input',
  },
  {
    label: '系统类型',
    field: 'sysType',
    component: 'JSearchSelect',
    componentProps:{
      dict: "sysType"
    },
    colProps: {lg: 12},
  },
  {
    label: '当前状态',
    field: 'status',
    component: 'JSearchSelect',
    componentProps:{
      dict: "sysStatus"
    },
    colProps: {lg: 12},
  },
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '系统名称',
    field: 'sysName',
    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: 'sysType',
    component: 'JSearchSelect',
    componentProps:{
      dict: "sysType"
    },
    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: 'onLineDate',
    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: "sysStatus"
    },
    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: 'sysDes',
    itemProps:{labelCol:{xs: {span: 24},sm: {span: 3},},wrapperCol:{xs: {span: 24},sm: {span: 21},}},
    component: 'InputTextArea',
    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;
}