import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import { getDictItemsByCode } from '/@/utils/dict/index';

import { stubFalse } from 'lodash-es';
//列表数据
export const columns: BasicColumn[] = [
   {
    title: '模板ID',
    align:"left",
    dataIndex: 'tplid',
    sorter: true,
    ifShow:false
   },
   {
    title: '父编号',
    align:"center",
    dataIndex: 'pcode',
    resizable:true,
    width:100,
    sorter: true,
   },
   {
    title: '编号',
    align:"center",
    dataIndex: 'code',
    resizable:true,
    width:100,
    sorter: true,
   },
   {
    title: '模板(表名称)',
    align:"left",
    dataIndex: 'tplName',
    resizable:true,
    width:180,
    sorter: true,
   },
   {
    title: '标题',
    align:"left",
    dataIndex: 'title',
    resizable:true,
    width:350,
    sorter: true,
   },
   {
    title: '节点数',
    align:"center",
    dataIndex: 'childNum',
    resizable:true,
    width:120,
    sorter: true,
   },
   {
    title: '值类型',
    align:"center",
    dataIndex: 'tp',
    width:120,
    ifShow:true,
    customRender: ({ text }) => {
      return render.renderDict(text, 'fxc_value_tp');
    },
    filters:getDictItemsByCode("fxc_value_tp") || []
   },
   {
    title: '表单类型',
    align:"center",
    dataIndex: 'formTp',
    width:100,
    customRender: ({ text }) => {
      return render.renderDict(text, 'fxc_form_tp');
    },
    filters:getDictItemsByCode("fxc_form_tp") || [],
    ifShow:true
   },
   {
    title: '节点路径',
    align:"left",
    dataIndex: 'treepathName',
    resizable:true,
    sorter: true,
   },
   {
    title: '选项或单位',
    align:"left",
    dataIndex: 'options',
    resizable:true,
    width:180,
    sorter: true,
   },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: '模板表名',
    field: 'tplName',
    component: 'JInput',
  },
  {
    label: '标题',
    field: 'title',
    component: 'JInput',
  },
  {
    label: '父编码',
    field: 'pcode',
    component: 'Input',

    
  },
  // {
  //   label: '父编码',
  //   field: 'pcode',
  //   component: 'Input',
  // },

];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '标题',
    field: 'title',
    component: 'Input',
    required: true,
  },
  {
    label: '类型',
    field: 'tp',
    component: 'Select',
    componentProps: {
      type: 'radio',
      options: [{
        label:'数字',
        value:1
      },{
        label:'文本',
        value:2
      },{
        label:'日期',
        value:3
      },{
        label:'布尔',
        value:4
        
      },{
        label:'其它',
        value:0
      }]
    },
  },
  {
    label: '父编号',
    field: 'pcode',
    component: 'JInput',
    required: true,
    dynamicDisabled:true
  },
  {
    label: '编号',
    field: 'code',
    component: 'JInput',
    required: true,
    dynamicDisabled:true
  },
  {
    label: '备注',
    field: 'des',
    component: 'InputTextArea',
    componentProps: {
      rows: 3,
      showCount: true,
      maxlength: 256,
    },
    required: true,
  },
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
  {
    label: '',
    field: 'tplid',
    component: 'Input',
    show:false
  },
];



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

async function setFormTpOptions() {
  let allDict = await getAuthCache("UI_CACHE_DB_DICT_DATA") 
  formTpOptions.value  = allDict["fxc_form_tp"] 
  tpOptions.value  = allDict["fxc_value_tp"] 
}