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:"center",
    dataIndex: 'mtrcNo',
    width:70,
    ifShow:false
   },
   {
      title: '开始填报时间',
      dataIndex: 'fillTime',
      editComponent: 'DatePicker',
      edit:true,
      editComponentProps: {
        valueFormat: 'YYYY-MM-DD',
        format: 'YYYY-MM-DD',
      },
      width: 120,
   },
   {
    title: '填报值',
    align:"center",
    editComponent: 'Input',
    dataIndex: 'fillVals',
    edit:true,
    width: 180,
    editComponentProps: {
      editComponentProps: {  
        onChange: (e) => {  
          const { value } = e.target; 
          const numberValue = parseFloat(value);  
          if (!isNaN(numberValue)) {  
            const decimalPart = value.split('.')[1];  
            if (decimalPart && decimalPart.length > 15) {  
              e.target.value = numberValue.toFixed(15); 
            }  
          }  
        },  
      },
    },
    editRule: async (text) => {
      if (!text&&text!=0) {
        return '请输入值';
      }
      if (isNaN(text)) {
        return '请输入数字';
      }
    }
   },
   {
    title: '备注',
    align:"center",
    dataIndex: 'des',
    // editRow: true,
    width: 100,
    edit:true,
   },
   {
    title: '状态',
    align:"center",
    dataIndex: 'riskLevel',
    width: 70,
    ifShow:true
   },
   {
    title: '',
    align:"center",
    dataIndex: 'id',
    width: 1,
    ifShow:true
   },
];
export const columnsreport: BasicColumn[] = [
  {
    title: '指标编号',
    align:"center",
    dataIndex: 'mtrcNo',
    width:80,
    ifShow:false
   },
   {
      title: '填报日期',
      dataIndex: 'fillTime',
      // editRow: true,
      editComponent: 'DatePicker',
      editComponentProps: {
        valueFormat: 'YYYY-MM-DD',
        format: 'YYYY-MM-DD',
      },
      width: 140,
      sorter: false,
      edit:false,
   },
   {
    title: '填报值',
    align:"center",
    editComponent: 'InputNumber',
    dataIndex: 'fillVals',
    // editRow: true,
    edit:false,
    width: 120,
   },
   {
    title: '备注',
    align:"center",
    dataIndex: 'des',
    // editRow: true,
    width: 150,
    edit:false,
   
   },
   {
    title: '状态',
    align:"center",
    dataIndex: 'riskLevel',
    width: 100,
    ifShow:true
   },
  //  {
  //   title: '填报人',
  //   align:"center",
  //   dataIndex: 'reporter',
  //   editRow: false,
  //   width: 120,
  //  },
   {
    title: '',
    align:"center",
    dataIndex: 'id',
    width: 1,
    ifShow:true
   },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: '开始日期',
    field: 'stFillTime',
    component: 'DatePicker',
    colProps: {xs: 12, sm: 12, md: 12, lg: 12, xl: 12},
    defaultValue: (new Date().getFullYear()-3) +"-"+ (new Date().getMonth()+1) +"-"+ (new Date().getDate()),
    itemProps:{labelCol:{xs: {span: 12},sm: {span: 12},},wrapperCol:{xs: {span: 12},sm: {span: 12},}},
  },
  {
    label: '结束日期',
    field: 'endFillTime',
    defaultValue:new Date(),
    component: 'DatePicker',
    colProps: {xs: 12, sm: 12, md: 12, lg: 12, xl: 12},
    itemProps:{labelCol:{xs: {span: 12},sm: {span: 12},},wrapperCol:{xs: {span: 12},sm: {span: 12},}},
  },
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '指标编码',
    field: 'mtrcNo',
    component: 'Input',
    dynamicDisabled:true
  },
  {
    label: '指标名称',
    field: 'mtrcName',
    component: 'Input',
    dynamicDisabled:true
  },
  {
    label: '指标定义',
    field: 'mtrcDes',
    component: 'InputTextArea',
    componentProps: {
      rows: 3
    },
    dynamicDisabled:true
  },
  {
    label: '填报时间',
    field: 'fillTime',
    component: 'DatePicker',
  },
  {
    label: '填报值',
    field: 'fillVals',
    component: 'InputNumber',
    
  },
  {
    label: '填报值单位',
    field: 'unit',
    component: 'InputNumber',
    dynamicDisabled:true
  },
  // {
  //   label: '填报人',
  //   field: 'reporter',
  //   component: 'Input',
  // },
  {
    label: '备注',
    field: 'des',
    component: 'InputTextArea',
    componentProps: {
      rows: 5
    }
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
  {
	  label: '',
	  field: 'riskLevel',
	  component: 'Input',
	  show: false
	},
];



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