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: '模板名称',
  //   width:120,
  //   align:"left",
  //   dataIndex: 'tplName'
  //  },
  //  {
  //   title: '模板项目名称',
  //   align:"left",
  //   width:120,
  //   dataIndex: 'tplItemName'
  //  },
  //  {
  //   title: '填报项目名称',
  //   align:"left",
  //   width:200,
  //   dataIndex: 'itemDtName'
  //  },
  {
    title: '显示标题',
    align: 'left',
    width: 100,
    edit: true,
    dataIndex: 'showName',
  },
  {
    title: '值',
    align: 'center',
    dataIndex: 'defaultVal',
    edit: true,
    width: 80,
  },
  {
    title: '单位',
    align: 'center',
    dataIndex: 'unit',
    edit: true,
    width: 60,
  },
  {
    title: '图标',
    align: 'center',
    dataIndex: 'defaultIcon',
    edit: true,
    width: 80,
  },
  {
    title: '分类',
    align: 'center',
    dataIndex: 'tp',
    sorter: true,
    width: 80,
    customRender: ({ text }) => {
      const color = text == '1' ? 'green' : 'red';
      const strText = text == '1' ? '机构概况' : '科技概况';
      return render.renderTag(strText, color);
    },
  },
  {
    title: '顺序号',
    align: 'center',
    dataIndex: 'showSort',
    edit: true,
    width: 80,
  },
  {
    title: '',
    align: 'center',
    dataIndex: 'id',
    width: 1,
    ifShow: true,
  },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: '标题名称',
    field: 'showName',
    component: 'Input',
  },
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '分类',
    field: 'tp',
    component: 'Select',
    required: true,
    defaultValue: 1,
    componentProps: {
      type: 'radio',
      options: [
        {
          label: '机构概况',
          value: 1,
        },
        {
          label: '科技概况',
          value: 2,
        },
      ],
    },
  },
  {
    label: '标题名称',
    field: 'showName',
    component: 'Input',
    required: true,
  },
  {
    label: '数据来源',
    field: 'tplItemDtId',
    component: 'JSelectFxcTplTree',
    componentProps: {
      labelKey: 'title',
      rowKey: 'id',
    },
    ifShow: false,
  },
  {
    label: '显示顺序',
    field: 'showSort',
    component: 'InputNumber',
  },
  {
    label: '图标',
    field: 'defaultIcon',
    component: 'Input',
  },
  {
    label: '默认值',
    field: 'defaultVal',
    component: 'Input',
  },
  {
    label: '单位',
    field: 'unit',
    component: 'Input',
  },
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false,
  },
];

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