// 不显示的信息点数组 import text from "@/utils/handsontable/mainText" import tools from "@/utils/scan/tools" let InputModeArr = ["A1", "A2", "B1", "C5", "D1", "D2", "E1", "L", "L1", "L2", "F1", "F2", "M", "Own"] //在编辑模式下并且勾选隐藏自动填充的信息点不显示的字段 let noShowArr = [ "Brand", "Specification", "Manufacturer", "Supplier", "SupplierContactor", "SupplierPhone", "SupplierEmail", "SupplierWeb", "SupplierFax", "Maintainer", "MaintainerContactor", "MaintainerPhone", "MaintainerEmail", "MaintainerWeb", "Principal", "MaintainerFax", "Insurer", "InsurerContactor", "InsurerPhone", "InsurerEmail", "InsurerWeb", "InsurerFax", "InsuranceFile", "EquipID", "EquipName", ] //在编辑模式下不显示的字段 let cantShow = [ "EquipQRCode", "EquipID", "EquipName", "BIMLocation", "Brand", "Specification", "Manufacturer", "Supplier", "SupplierContactor", "SupplierPhone", "SupplierEmail", "SupplierWeb", "SupplierFax", "Maintainer", "MaintainerContactor", "MaintainerPhone", "MaintainerEmail", "MaintainerWeb", "Principal", "MaintainerFax", "Insurer", "InsurerContactor", "InsurerPhone", "InsurerEmail", "InsurerWeb", "InsurerFax", "InsuranceFile", "EquipID", "EquipName", "SpaceCount", "SpaceList", "TenantID", "ShaftID" ] let cutArr = [{ name: "品牌型号", code: "DPManufacturerID", num: 2, }, { name: "供应商信息", code: "DPSupplierID", num: 5 }, { name: "维修商信息", code: "DPMaintainerID", num: 19 }, { name: "保险公司信息", code: "DPInsurerID", num: 25 }] let newData = [{ name: "品牌型号", code: "DPManufacturerID", num: 2, }, { name: "供应商信息", code: "DPSupplierID", num: 8 }, { name: "维修商信息", code: "DPMaintainerID", num: 35 }, { name: "保险公司信息", code: "DPInsurerID", num: 42 }] //创建部件固定不显示-管理部件固定不显示(即编辑模式) let partsAddNoShow = [ 'EquipID', 'EquipName', 'EquipQRCode', 'BIMID', 'BIMLocation', 'Brand', 'Specification', 'Manufacturer', 'Supplier', 'SupplierContactor', 'SupplierPhone', 'SupplierEmail', 'SupplierWeb', 'SupplierFax', 'Maintainer', 'MaintainerContactor', 'MaintainerPhone', 'MaintainerEmail', 'MaintainerWeb', 'MaintainerFax', 'Insurer', "InsurerContactor", "InsurerPhone", "InsurerEmail", "InsurerWeb", "InsurerFax", ] const showTools = { addArr: () => { return cutArr }, cantShow: (code) => { let falg = true cantShow.map(item => { if (item == code) { falg = false } }) return falg }, fixedNoShowField: (noShowList, code) => { let flag = true noShowList.map(item => { if (item == code) { flag = false } }) return flag }, //几种类型不显示 technologyParam: (item) => { if ( item.FirstTag == "控制参数" && item.FirstTag == "设定参数" && item.FirstTag == "运行参数" ) { return undefined } }, isShow: (code) => { let falg = true noShowArr.map(item => { if (item == code) { falg = false } }) return falg }, //插入需要的关系 insertionRea: (data) => { cutArr.map(item => { data.splice(item.num, 0, item.name) }) return data }, insertionRea2: (data) => { newData.map(item => { data.splice(item.num, 0, item.name) }) return data }, insertionType: (data, callback) => { cutArr.map(item => { data.splice(item.num, 0, { data: "infos." + item.code, renderer: callback, readOnly: false }) }) return data }, insertionType2: (data, callback) => { newData.map(item => { data.splice(item.num, 0, { data: "infos." + item.code, renderer: callback, readOnly: false }) }) return data }, arrToArr(arr) { let first = 0, scound = 0, three = 0, four = 0 arr.find(function(value, index, arr) { if ( (value.InfoPointName == "品牌" || value.InfoPointName == "设备型号" || value.InfoPointName == "生产厂家") && !first ) { first = index } if ( (value.InfoPointName == "供应商单位名称" || value.InfoPointName == "供应商联系人" || value.InfoPointName == "供应商电子邮件" || value.InfoPointName == "供应商网址" || value.InfoPointName == "供应商传真" || value.InfoPointName == "供应商联系电话") && !scound ) { scound = index } if ( (value.InfoPointName == "维修商单位名称" || value.InfoPointName == "维修商联系人" || value.InfoPointName == "维修商联系电话" || value.InfoPointName == "维修商电子邮件" || value.InfoPointName == "维修商网址" || value.InfoPointName == "维修商传真") && !three ) { three = index } if ( (value.InfoPointName == "保险公司名称" || value.InfoPointName == "保险公司联系人" || value.InfoPointName == "保险公司联系电话" || value.InfoPointName == "保险公司电子邮件" || value.InfoPointName == "保险公司网址" || value.InfoPointName == "保险公司传真") && !four ) { four = index } }) let numList = [first, scound, three, four] numList.reverse().map((item, index) => { if (!!item) { if (index == 0) { arr.splice(item, 0, { InfoPointName: "保险公司信息", InfoPointCode: "DPInsurerID", Path: 'DPInsurerID', InputMode: "Own", Unit: "", SecondTag: "", FirstTag: "", Visible: true, }) } else if (index == 1) { arr.splice(item, 0, { InfoPointName: "维修商信息", InfoPointCode: "DPMaintainerID", Path: 'DPMaintainerID', InputMode: "Own", Unit: "", SecondTag: "", FirstTag: "", Visible: true, }) } else if (index == 2) { arr.splice(item, 0, { InfoPointName: "供应商信息", InfoPointCode: "DPSupplierID", Path: 'DPSupplierID', InputMode: "Own", Unit: "", SecondTag: "", FirstTag: "", Visible: true, }) } else if (index == 3) { arr.splice(item, 0, { InfoPointName: "品牌型号", InfoPointCode: "DPManufacturerID", Path: 'DPManufacturerID', InputMode: "Own", Unit: "", SecondTag: "", FirstTag: "", Visible: true, }) } } }) return arr }, changeTypes(arr, onlyRead, isWatch, allMess, falg = false, taizhang = false) { let data = arr.map(item => { if (falg) { if (item.FirstTag == "控制参数" || item.FirstTag == "设定参数" || item.FirstTag == "运行参数") { return undefined } } if (item.InfoPointCode == "BIMLocation") { return undefined } if (onlyRead || InputModeArr.indexOf(item.InputMode) > -1) { if (item.Visible || !allMess) { //固定不显示的code if (!showTools.cantShow(item.InfoPointCode) && !onlyRead && !taizhang) { return undefined } if (!showTools.isShow(item.InfoPointCode) && !taizhang && !taizhang) { if (isWatch && !onlyRead) { return undefined } } if (item.InfoPointCode == "EquipQRCode") { return { data: "Infos." + item.InfoPointCode, renderer: text.lookQRCode, readOnly: true } } if (item.InputMode == "D1") { return { data: "Infos." + item.InfoPointCode, renderer: tools.customDropdownRenderer, editor: "chosen", chosenOptions: { // multiple: true,//多选 data: item.DataSource || "" } }; } else if (item.InputMode == "A1" || item.InputMode == "A2") { return { data: "Infos." + item.InfoPointCode, type: "numeric", numericFormat: { pattern: "0,0.00" // culture: 'de-DE' // use this for EUR (German), // more cultures available on http://numbrojs.com/languages.html } }; } else if (item.InputMode == "C5") { return { data: "Infos." + item.InfoPointCode, type: "date", dateFormat: "YYYY-MM-DD", correctFormat: true }; } else if ( item.InputMode == "B1" || item.InputMode == "L" || item.InputMode == "L1" || item.InputMode == "L2" || item.InputMode == "M" ) { return { data: "Infos." + item.InfoPointCode }; } else if ( item.InputMode == "X" // item.InputMode == "L1" || // item.InputMode == "L2" ) { // return undefined return { data: "Infos." + item.InfoPointCode, readOnly: true }; } else if (item.InputMode == "D2") { return { data: "Infos." + item.InfoPointCode, renderer: tools.customDropdownRenderer, editor: "chosen", chosenOptions: { multiple: true, //多选 data: item.DataSource || "" } }; } else if (item.InputMode == "Own" && !onlyRead) { return { data: "Infos." + item.InfoPointCode, renderer: text.idType, } } else { return { data: "infos." + item.InfoPointCode } } } else { return undefined } } else { return false } }).filter(item => item); return data }, showTypes(arr, onlyRead, isWatch, allMess, falg = false, typeArr = false) { let data = arr.map(item => { if (falg) { if (item.FirstTag == "控制参数" || item.FirstTag == "设定参数" || item.FirstTag == "运行参数") { return undefined } } if (item.InfoPointCode == "BIMLocation") { return undefined } if (onlyRead || InputModeArr.indexOf(item.InputMode) > -1) { if (item.Visible || !allMess) { //固定不显示的code if (!showTools.cantShow(item.InfoPointCode) && !onlyRead) { return undefined } if (!showTools.isShow(item.InfoPointCode) && !onlyRead) { if (isWatch && !onlyRead) { return undefined } } if (item.InfoPointCode == "EquipQRCode" || item.InfoPointCode == "RoomQRCode") { return { data: "infos." + item.InfoPointCode, renderer: text.lookQRCode, readOnly: true } } //图片类型 if ( item.InfoPointCode == "InstallPic" || item.InfoPointCode == "InstallDrawing" || item.InfoPointCode == "Nameplate" || item.InfoPointCode == "Pic" || item.InfoPointCode == "Drawing" ) { return { data: "infos." + item.InfoPointCode, renderer: text.picType, readOnly: true } } //文件类型 if (item.InfoPointCode == "InsuranceFile" || item.InfoPointCode == "Archive" || item.InfoPointCode == "CheckReport") { return { data: "infos." + item.InfoPointCode, renderer: text.fileType, readOnly: true } } if (item.InputMode == "D1") { return { data: "infos." + item.InfoPointCode, renderer: tools.customDropdownRenderer, editor: "chosen", chosenOptions: { // multiple: true,//多选 data: item.DataSource || "" } }; } else if (item.InputMode == "A1" || item.InputMode == "A2") { return { data: "infos." + item.InfoPointCode, type: "numeric", numericFormat: { pattern: "0,0.00" // culture: 'de-DE' // use this for EUR (German), // more cultures available on http://numbrojs.com/languages.html } }; } else if (item.InputMode == "C5") { return { data: "infos." + item.InfoPointCode, type: "date", dateFormat: "YYYY-MM-DD", correctFormat: true }; } else if ( item.InputMode == "B1" || item.InputMode == "L" || item.InputMode == "L1" || item.InputMode == "L2" || item.InputMode == "M" ) { return { data: "infos." + item.InfoPointCode } } else if ( item.InputMode == "X" || item.InputMode == "F2" ) { return { data: "infos." + item.InfoPointCode, readOnly: true }; } else if (item.InputMode == "D2") { return { data: "infos." + item.InfoPointCode, renderer: tools.customDropdownRenderer, editor: "chosen", chosenOptions: { multiple: true, //多选 data: item.DataSource || "" } }; } else if (item.InputMode == "Own" && !onlyRead) { return { data: "infos." + item.InfoPointCode, renderer: text.idType, } } else { return { data: "infos." + item.InfoPointCode } } } else { return undefined } } else { return undefined } }).filter(item => item); return data }, changeHeader(arr, readArr, onlyRead, isWatch, allMess, falg = false, taizhang = false) { let data = arr.map(item => { if (falg) { if (item.FirstTag == "控制参数" || item.FirstTag == "设定参数" || item.FirstTag == "运行参数") { return undefined } } if (item.InfoPointCode == "BIMLocation") { return undefined } if (onlyRead || InputModeArr.indexOf(item.InputMode) > -1) { if (item.Visible || !allMess) { if (!showTools.cantShow(item.InfoPointCode) && !onlyRead && !taizhang) { return undefined } if (!showTools.isShow(item.InfoPointCode) && !taizhang) { if (isWatch && !onlyRead) { return undefined } } if (!item.Unit || item.Unit == "") { return item.InfoPointName; } else { return item.InfoPointName + "(" + item.Unit + ")"; } } else { return undefined } } else { return undefined } }).filter(d => d); return data }, showHeaderTypes(arr, typeArr, onlyRead, isWatch, allMess, falg = false) { let data = arr.map(item => { if (falg) { if (item.FirstTag == "控制参数" || item.FirstTag == "设定参数" || item.FirstTag == "运行参数") { return undefined } } if (item.InfoPointCode == "BIMLocation") { return undefined } if (onlyRead || InputModeArr.indexOf(item.InputMode) > -1) { if (item.Visible || !allMess) { //固定不显示的code if (!showTools.cantShow(item.InfoPointCode) && !onlyRead) { return undefined } if (!showTools.isShow(item.InfoPointCode)) { if (isWatch && !onlyRead) { return undefined } } if (item.InfoPointCode == "EquipQRCode") { return { data: item.Path, renderer: text.lookQRCode, readOnly: onlyRead } } //图片类型 if ( item.InfoPointCode == "InstallPic" || item.InfoPointCode == "InstallDrawing" || item.InfoPointCode == "Nameplate" || item.InfoPointCode == "Pic" || item.InfoPointCode == "Drawing" ) { return { data: item.Path, renderer: text.picType, readOnly: onlyRead } } //文件类型 if (item.InfoPointCode == "InsuranceFile" || item.InfoPointCode == "Archive" || item.InfoPointCode == "CheckReport") { return { data: item.Path, renderer: text.fileType, readOnly: onlyRead } } if (item.InputMode == "D1" || item.InputMode == "E1") { //单选 return { data: item.Path, renderer: tools.customDropdownRenderer, editor: "chosen", readOnly: onlyRead, chosenOptions: { data: item.DataSource ? tools.formatDataSource(item.DataSource) : "" } }; } else if (item.InputMode == "D2") { return { data: item.Path, renderer: tools.customDropdownRenderer, editor: "chosen", readOnly: onlyRead, chosenOptions: { multiple: true, //多选 data: item.DataSource ? tools.formatDataSource(item.DataSource) : "" } }; } else if (item.InputMode == "A1" || item.InputMode == "A2") { return { data: item.Path, type: "numeric", readOnly: onlyRead, numericFormat: { pattern: "0,0.00" // culture: 'de-DE' // use this for EUR (German), // more cultures available on http://numbrojs.com/languages.html } }; } else if (item.InputMode == "C5") { return { data: item.Path, type: "date", dateFormat: "YYYY-MM-DD", readOnly: onlyRead, correctFormat: true }; } else if (item.InputMode == "Own" && !onlyRead) { return { data: item.Path, renderer: text.idType, readOnly: onlyRead } } else { return { data: item.Path, readOnly: onlyRead }; } } else { return undefined } } else { return undefined } }).filter(item => item); return data }, tableHeadFilter(arr, readArr, onlyRead, isWatch, allMess, falg = false, taizhang = false) { if (!taizhang) { arr = showTools.arrToArr(arr) } let data = arr.map(item => { if (falg) { if (item.FirstTag == "控制参数" || item.FirstTag == "设定参数" || item.FirstTag == "运行参数") { return undefined } } if (item.InfoPointCode == "BIMLocation") { return undefined } if (onlyRead || InputModeArr.indexOf(item.InputMode) > -1) { if (item.Visible || !allMess) { if (!showTools.fixedNoShowField(partsAddNoShow, item.InfoPointCode) && !onlyRead && !taizhang) { return undefined } if (!showTools.isShow(item.InfoPointCode) && !taizhang) { if (isWatch && !onlyRead) { return undefined } } if (!item.Unit || item.Unit == "") { return item.InfoPointName; } else { return item.InfoPointName + "(" + item.Unit + ")"; } } else { return undefined } } else { return undefined; } }).filter(d => d); return data }, tableHeaderTypes(arr, typeArr, onlyRead, isWatch, allMess, falg = false, taizhang = false) { if (!taizhang) { arr = showTools.arrToArr(arr) } let data = arr.map(item => { if (falg) { if (item.FirstTag == "控制参数" || item.FirstTag == "设定参数" || item.FirstTag == "运行参数") { return undefined } } if (item.Path == "BIMLocation") { return undefined } if (onlyRead || InputModeArr.indexOf(item.InputMode) > -1) { if (item.Visible || !allMess) { //固定不显示的code if (!showTools.fixedNoShowField(partsAddNoShow, item.InfoPointCode) && !onlyRead && !taizhang) { return undefined } if (!showTools.isShow(item.InfoPointCode) && !taizhang) { if (isWatch && !onlyRead) { return undefined } } if (item.InfoPointCode == "EquipQRCode") { return { data: item.Path, renderer: text.lookQRCode, readOnly: onlyRead } } //图片类型 if ( item.InfoPointCode == "InstallPic" || item.InfoPointCode == "InstallDrawing" || item.InfoPointCode == "Nameplate" || item.InfoPointCode == "Pic" || item.InfoPointCode == "Drawing" ) { return { data: item.Path, renderer: text.picType, readOnly: onlyRead } } //文件类型 if (item.InfoPointCode == "InsuranceFile" || item.InfoPointCode == "Archive" || item.InfoPointCode == "CheckReport") { return { data: item.Path, renderer: text.fileType, readOnly: onlyRead } } if (item.InputMode == "D1" || item.InputMode == "E1") { //单选 return { data: item.Path, renderer: tools.customDropdownRenderer, editor: "chosen", readOnly: onlyRead, chosenOptions: { data: item.DataSource ? tools.formatDataSource(item.DataSource) : "" } }; } else if (item.InputMode == "D2") { return { data: item.Path, renderer: tools.customDropdownRenderer, editor: "chosen", readOnly: onlyRead, chosenOptions: { multiple: true, //多选 data: item.DataSource ? tools.formatDataSource(item.DataSource) : "" } }; } else if (item.InputMode == "A1" || item.InputMode == "A2") { return { data: item.Path, type: "numeric", readOnly: onlyRead, numericFormat: { pattern: "0,0.00" } }; } else if (item.InputMode == "C5") { return { data: item.Path, type: "date", dateFormat: "YYYY-MM-DD", readOnly: onlyRead, correctFormat: true }; } else if (item.InputMode == "Own" && !onlyRead) { return { data: item.Path, renderer: text.idType, readOnly: onlyRead } } else { return { data: item.Path, readOnly: onlyRead }; } } else { return undefined } } else { return undefined } }).filter(item => item); return data }, } export default showTools