

import { translate } from '@/common/utils/language/index'
export const create = async ({ fields, buttons, render, hasExpand, statusField }:any) => {
    //1,补全Columns参数
    await chackColumns({fields, hasExpand, statusField})
    render.value = true
}



// 补全Columns参数
const chackColumns = ({fields, hasExpand, statusField}:any) => {
    let newFields:any = []
    for( let item of fields.value ){
        if(item.render == false) continue
        newFields.push({
            field: item.field,
            field_id: item.field_id || item.field,
            show: item.show == undefined ? true : item.show,
            render: item.render == undefined ? true : item.render,
            invalid: item.invalid || false,
            field_style: item.field_style || '',
            alias: item.alias || '',
            label: translate(item.alias || item.field),
            lv: item.lv || '',
            showLabel: item.showLabel || false,
            grid: item.grid || '',
            expand: item.expand || false,
            isStatus: item.isStatus || false,
        })
        if(item.expand) hasExpand.value = true
        if(!statusField.value && item.isStatus) statusField.value = item.field
    }
    fields.value = newFields
}