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: 'tp',
    resizable:true,
    width:100,
    customRender: ({ text }) => {
      return render.renderDict(text, 'wb_api_tp');
    },

   },
   {
    title: '接口名称',
    align:"left",
    dataIndex: 'name',
    resizable:true,
    width:150,
   },
   {
    title: '接口地址',
    align:"left",
    dataIndex: 'url',
    resizable:true,
    width:250,
   },
   {
    title: '接口ID',
    align:"left",
    dataIndex: 'apiId',
    sorter: true,
    width:100,
   },
   {
    title: '请求方法',
    align:"left",
    dataIndex: 'reqMethod',
    width:100,
   },
   {
    title: '返回格式',
    align:"left",
    dataIndex: 'resFormat',
    width:100,
   },
   {
    title: '是否分页',
    align:"left",
    dataIndex: 'hasPage',
    width:100,
    sorter: true,
    customRender:({text}) =>{
      return (text==1?"是":"否")
    },
   },
   {
    title: '权重',
    align:"center",
    dataIndex: 'weight',
    width:80,
    sorter: true,
   }
];
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: '接口名称',
    field: 'name',
    component: 'Input',
  },{
    label: '接口分类',
    field: 'tp',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: 'wb_api_tp',
      stringToNumber: true,
    },
  }
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '接口名称',
    field: 'name',
    component: 'Input',
  },{
    label: '接口分类',
    field: 'tp',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: 'wb_api_tp',
      stringToNumber: true,
    },
  }, {
    label: '接口地址',
    field: 'url',
    component: 'Input',
  },
  {
    label: '接口ID',
    field: 'apiId',
    component: 'Input',
  },
  {
    label: '请求方法',
    field: 'reqMethod',
    component: 'Input',
  },
  {
    label: '响应格式',
    field: 'resFormat',
    component: 'Input',
  },
  {
    label: '是否分页',
    field: 'hasPage',
    component: 'ApiRadioGroup',
    defaultValue:"1",
    componentProps: {
      options: [
        {label:"是",value:1},
        {label:"否",value:0},
      ],
      placeholder: '请选择'
    },
  },
  {
    label: '权重',
    field: 'weight',
    component: 'Input',
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];


export const columnsPull: BasicColumn[] = [
  {
   title: '接口分类',
   align:"left",
   dataIndex: 'tp',
   resizable:true,
   width:100,
   customRender: ({ text }) => {
    return render.renderDict(text, 'wb_api_tp');
  },
  },
  {
   title: '接口名称',
   align:"left",
   dataIndex: 'name',
   resizable:true,
   width:150,
  },
  {
   title: '优先级',
   align:"center",
   dataIndex: 'weight',
   width:80,
   sorter: true,
  },
  {
    title: '状态码',
    align:"left",
    dataIndex: 'pulled',
    width:100,
   },

   {
    title: '状态信息',
    align:"left",
    dataIndex: 'staMsg',
    width:130,
   },
];



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