
/**以table表来配置展示字段配置
 * @param label 配置表名称
 * @param tableColumns TableColumns
 * @param sort 非必传 [id,name] 名称按数组顺序排序
 * */ 
function TableConfigFun(params:{label:string,tableColumns:()=>any,sort?:string[]}){
    let {label,tableColumns,sort=[]} = params
    let list =[{
        label,
    }]
    if(typeof tableColumns === 'function'){
      let data: any[]= []
      if(sort.length > 0){
        tableColumns()?.forEach((item: any,index:number)=>{
                let eq = sort.findIndex(d=>d===item.dataIndex) +1
                data[index] =  { title: item.title, dataIndex: item.dataIndex, label, default:eq}
          })
      }else{
        tableColumns()?.forEach((item: any,index:number)=>{
            let eq = index +1
            data[index] =  { title: item.title, dataIndex: item.dataIndex, label, default:eq}
      })
      }
      list[0]['data'] = data
    }
    return list
}
export default TableConfigFun