import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
  
   {
    title: '接口名称',
    align:"left",
    dataIndex: 'apiName',
    resizable:true,
    ifShow:true,
    width:150
   },
  //  {
  //   title: '接口URL',
  //   align:"left",
  //   dataIndex: 'url',
  //   resizable:true,
  //   ifShow:true,
  //   width:200
  //  },
   {
    title: '返回值类型',
    align:"left",
    dataIndex: 'valueType',
    customRender: ({ text }) => {
      return render.renderDict(text, 'mtrc_api_valtp');
    },
    resizable:true,
    width:150
   },
   {
    title: '返回值名',
    align:"left",
    dataIndex: 'valueField',
    resizable:true,
    ifShow:true,
    width:100
   },
   {
    title: '登录账号',
    align:"left",
    dataIndex: 'accout',
    resizable:true,
    ifShow:false,
    width:100
   },
   {
    title: '登录密码',
    align:"center",
    dataIndex: 'pwd',
    width:100,
    ifShow:false,
    resizable:true,
   },
   {
    title: '关联指标',
    align:"left",
    dataIndex: 'mtrcNo_dictText',
    resizable:true,
    ifShow:true,
    width:150
   },
   {
    title: '接收消息人',
    align:"left",
    dataIndex: 'receiver',
    resizable:true,
    ifShow:true,
    width:100
   },
   {
    title: '开始日期',
    align:"left",
    dataIndex: 'stDate',
    resizable:true,
    ifShow:true,
    width:100
   },
   {
    title: '开始时点',
    align:"left",
    dataIndex: 'stTime',
    resizable:true,
    ifShow:true,
    width:80
   },
  //  {
  //   title: '倍数',
  //   align:"left",
  //   dataIndex: 'mult',
  //   resizable:true,
  //   ifShow:true,
  //   width:80
  //  },
   {
    title: 'id',
    align:"left",
    dataIndex: 'id',
    ifShow:false
   },

];
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: '接口名称',
    field: 'apiName',
    component: 'Input',
  },
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '接口名称',
    field: 'apiName',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入API接口名称!'},
          ];
     },
  },
  {
    label: '选择指标',
    field: 'mtrNo',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: 'mtrc_api_valtp',
      placeholder: '请选择',
      stringToNumber: true,
    },
    dynamicRules: ({model,schema}) => {
      return [
          { required: true, message: '请选择指标!'},
      ];
     },
  },

  {
    label: '接口URL',
    field: 'url',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入接口URL!'},
          ];
     },
  },
  {
    label: '返回值类型',
    field: 'valueType',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: 'mtrc_api_valtp',
      placeholder: '请选择',
      stringToNumber: true,
    },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请选择返回值类型!'},
      ];
     },
  },
  {
    label: '返回值名',
    field: 'valueField',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入返回值名!'},
      ];
     },
  },
  {
    label: '请求方法',
    field: 'requestMethod',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入请求方法!'},
          ];
     },
  },
  {
    label: '请求头',
    field: 'requestHeaders',
    component: 'Input',
  },
  {
    label: '登录账号',
    field: 'accout',
    component: 'Input',
  },
  {
    label: '登录密码',
    field: 'pwd',
    component: 'Input',
  },
  {
    label: '请求参数',
    field: 'params',
    component: 'Input',
  },
  {
    label: '关联指标',
    field: 'mtrcNo',
    component: 'Input',
    show: false
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];



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