import { BasicColumn, FormSchema } from '/@/components/Table';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
   {
    title: '问题项',
    align: 'center',
    dataIndex: 'problemItem',
    width:150
   },
   {
    title: '问题来源',
    align: 'center',
    dataIndex: 'problemSourceFlag',
    width:150,
    customRender: ({ text }) => {
      return render.renderDict(text, 'problemSourceFlag');
    },

   },
   {
    title: '严重程度',
    align: 'center',
    dataIndex: 'severity',
    customRender:({text}) =>{
      let m = {"0001":"不严重","0002":"一般","0003":"严重","0004":"非常严重"}
      return m[text]
    },
    width:120
   },
   {
    title: '优先级',
    align: 'center',
    dataIndex: 'priorityFlag',
    customRender:({text}) =>{
      let m = {"0001":"低","0002":"中","0003":"高"}
      return m[text]
    },
    width:130
   },
   {
    title: '最晚完成时间',
    align: 'center',
    dataIndex: 'lateFinishTime',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text)
    },
    width:130
   },
   {
    title: '分配状态',
    align: 'center',
    dataIndex: 'assinStatus',
    width:100,
    customRender: ({ text }) => {
      return render.renderDict(text, 'assin_status');
    },
    
   },
   {
    title: '接收状态',
    align: 'center',
    dataIndex: 'receiveStatus',
    customRender:({text}) =>{
      return "0" == text? '未接收':("1"==text?'已接收':"2"==text?'已拒绝':'')
    },
    width:100
   },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: "问题项",
    field: 'problemItem',
    component: 'Input',
    colProps: {span: 6},
 },
{
    label: "问题来源",
    field: 'problemSourceFlag',
    component: 'Input',
    colProps: {span: 6},
 },
{
    label: "分配状态",
    field: 'assinStatus',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "assin_status",
      stringToNumber: false,
      placeholder:'请选择分配状态',
    },
    colProps: {span: 6},
 },
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '问题项',
    field: 'problemItem',
    component: 'Input',
    itemProps:{labelCol:{xs: {span: 24},sm: {span: 3},},wrapperCol:{xs: {span: 24},sm: {span: 21},}},
    dynamicRules: ({model,schema}) => {
      return [
             { required: true, message: '请输入问题项!'},
      ];
    },
  },
  {
    label: '问题描述',
    field: 'problemDes',
    component: 'InputTextArea',
    itemProps:{
      labelCol:{xs: {span: 24},sm: {span: 3},},
      wrapperCol:{xs: {span: 24},sm: {span: 21},
    }},
    componentProps:{
      rows: 7
    },
    dynamicRules: ({model,schema}) => {
      return [
          { required: true, message: '请输入问题描述,最长5000字!'},
          { max: 5000, message: '最大输入字数为5000' } 
      ];
    },
  },
  {
    label: '严重程度',
    field: 'severity',
    component: 'JSearchSelect',
    componentProps:{
      dict: "severity"
    },
    colProps: {lg: 8},
    itemProps:{labelCol:{xs: {span: 24},sm: {span: 9},},wrapperCol:{xs: {span: 24},sm: {span: 15},}},
    dynamicRules: ({model,schema}) => {
      return [
             { required: true, message: '请选择严重程度!'},
      ];
    },
  },
  {
    label: '优先级',
    field: 'priorityFlag',
    component: 'JSearchSelect',
    componentProps:{
      dict: "priorityFlag"
    },
    colProps: {lg: 8},
    itemProps:{labelCol:{xs: {span: 24},sm: {span: 6},},wrapperCol:{xs: {span: 24},sm: {span: 16},}},
    dynamicRules: ({model,schema}) => {
      return [
             { required: true, message: '请选择优先级!'},
      ];
    },
  },
  {
    label: '最晚完成时间',
    field: 'lateFinishTime',
    component: 'DatePicker',
    colProps: {lg: 8},
    itemProps:{labelCol:{xs: {span: 24},sm: {span: 9},},wrapperCol:{xs: {span: 24},sm: {span: 15},}},
    dynamicRules: ({model,schema}) => {
      return [
             { required: true, message: '请选择最晚完成时间!'},
      ];
    },
  },
  {
    label: '控制活动',
    field: 'actNo',
    slot: 'actNoSlot',
    component: 'Input',
    itemProps:{labelCol:{xs: {span: 24},sm: {span: 3},},wrapperCol:{xs: {span: 24},sm: {span: 21},}},
  },
	// TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'assinStatus',
    component: 'Input',
	  show: false
  },
  {
    label: '',
    field: 'receiveStatus',
    component: 'Input',
	  show: false
  },
  {
    label: '',
    field: 'problemSourceFlag',
    component: 'Input',
	  show: false
  },
  {
	  label: '',
	  field: 'pid',
	  component: 'Input',
	  show: false
	},
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];


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