const text = {

    //图片类型
    picType: (instance, td, row, col, prop, value, cellProperties) => {
        td.style.color = "#409EFF";
        td.style.cursor = "pointer";
        if (value instanceof Array && value.length > 0) {
            let i = 0
            value.map(item => {
                // if (item.type == "image" || item.type == "video") {
                    i++
                // }
            })
            td.innerHTML = "已上传:" + i;
        } else {
            td.innerHTML = "点击上传"
        }
        return td;
    },
    // 文件类型
    fileType: (instance, td, row, col, prop, value, cellProperties) => {
        td.style.color = "#409EFF";
        td.style.cursor = "pointer";
        if (value instanceof Array && value.length > 0) {
            td.innerHTML = "已上传:" + value.length;
        } else {
            td.innerHTML = "点击上传"
        }
        return td;
    },
    //系统类型
    systemList: (instance, td, row, col, prop, value, cellProperties) => {
        td.style.color = "#409EFF";
        td.style.cursor = "pointer";
        if (value instanceof Array && value.length > 0) {
            if (value.length == 1) {
                td.innerHTML = !!value[0].infos ? (value[0].infos.SysLocalName || value[0].infos.SysName) : (value[0].SysLocalName || value[0].SysName)
            } else {
                let text = ""
                for (let i = 0; i < value.length; i++) {
                    if (!!value[i].SysLocalName || !!value[i].SysName) {
                        if (i == value.length) {
                            text += value[i].SysLocalName || value[i].SysName
                        } else {
                            text = value[i].SysLocalName || value[i].SysName + "、" + text
                        }
                    } else {
                        if (i == value.length) {
                            text += value[i].infos.SysLocalName || value[i].infos.SysName
                        } else {
                            text = value[i].infos.SysLocalName || value[i].infos.SysName + "、" + text
                        }
                    }
                }
                td.innerHTML = text.substring(0, 40) + "..."
            }
        } else {
            td.innerHTML = "无关联系统"
        }
        return td;
    },
    //四大厂商
    idType: (instance, td, row, col, prop, value, cellProperties) => {
        let html = ''
        switch (prop){
            case 'DPManufacturerID':
                html = instance.getDataAtRowProp(row,'LedgerParam.EquipManufactor.Specification') + '/' + instance.getDataAtRowProp(row,'LedgerParam.EquipManufactor.Brand')
                break;
            case 'DPSupplierID':
                html = instance.getDataAtRowProp(row,'LedgerParam.SupplyPurchase.Supplier')
                break;
            case 'DPMaintainerID':
                html = instance.getDataAtRowProp(row,'LedgerParam.OperationMainte.Maintainer')
                break;
            case 'DPInsurerID':
                html = instance.getDataAtRowProp(row,'LedgerParam.InsuranceDoc.Insurer')
                break;
            default:
                break;
        }
        td.style.color = "#409EFF";
        td.style.cursor = "pointer";
        if (!!value) {
            // let data = value.split("-")[1] || "空名"
            td.innerHTML = html
        } else {
            td.innerHTML = "点击选择"
        }
        return td
    },

    //查看二维码
    lookQRCode: (instance, td, row, col, prop, value, cellProperties) => {
        td.style.color = "#409EFF";
        td.style.cursor = "pointer";
        td.innerHTML = "查看二维码"
        return td
    },

    //系统所属建筑楼层
    sysInBuildFloor: (instance, td, row, col, prop, value, cellProperties) => {
        td.style.color = "#409EFF";
        td.style.cursor = "pointer";
        if (value instanceof Array && value.length > 0) {
            let text = ""
            for (let i = 0; i < value.length; i++) {
                if(value[i].BuildID && value[i].FloorID){
                    text += `${value[i].BuildLocalName || value[i].BuildName}-${value[i].FloorLocalName || value[i].FloorName }、`
                } else {
                    text += `${value[i].BuildLocalName || value[i].BuildName}、`
                }
            }
            text = text.substring(0,text.length-1);
            if(text.length>15){
                text = text.substring(0,15)+ "...";
            }
            td.innerHTML = text;
        } else {
            td.innerHTML = "无所属建筑楼层"
        }
        return td;
    },
}

export default text