import Dialog from "../../../BaseDialog/index"; import cy_tabs from "../../Element/cy_html_tabs"; let _DialogObject const openNodeListById = async (that, id) => { if (_DialogObject && !_DialogObject.isDestroy) { _DialogObject.close() _DialogObject = null } let currentData = [] const createTableContent = () => { let trsElm = '' for (let i = 0; i < currentData.length; i++) { let trElm = '' let tdElm = '' if ('fid' in currentData[i].properties) { tdElm = `
${currentData[i].properties.fid}
` } for (let key in currentData[i].properties) { if (key !== 'id' && key !== 'ID' && key !== 'fid') { tdElm = tdElm + `
${currentData[i].properties[key]}
` } } trElm = trElm + tdElm + '' trsElm = trsElm + trElm } return trsElm } let flag = false for (let i = 0; i < that.geojson.features.length; i++) { if (that.geojson.features[i].properties.id && that.geojson.features[i].properties.id == id) { currentData = [that.geojson.features[i]] flag = true break } } if (!flag) { window.ELEMENT && window.ELEMENT.Message({ message: '数据不存在!', type: 'warning', duration: 1500 }); return } _DialogObject = await new Dialog(that.viewer._container, { title: id, left: '17%', top: '100px' }) await _DialogObject.init() let trsElm = createTableContent(that) let box = document.createElement('div') box.style.height = '100%' let talbeElm = '
' let headerElm = '
' let hcolgroupElm = '' let theadElm = '' let bodyElm = '
' let bcolgroupElm = '' let i = 1 // thead if ('fid' in that.geojson.features[0].properties) { hcolgroupElm = hcolgroupElm + `` bcolgroupElm = bcolgroupElm + `` theadElm = theadElm + `` i++ } for (let key in that.geojson.features[0].properties) { if (key !== 'id' && key !== 'ID' && key !== 'fid') { hcolgroupElm = hcolgroupElm + `` bcolgroupElm = bcolgroupElm + `` theadElm = theadElm + `` i++ } } //tbody let tbodyElm = '' tbodyElm = tbodyElm + trsElm + '' hcolgroupElm = hcolgroupElm + '' bcolgroupElm = bcolgroupElm + '' theadElm = theadElm + '' headerElm = headerElm + hcolgroupElm + theadElm + '
fid
${key}
' bodyElm = bodyElm + bcolgroupElm + tbodyElm + '
' talbeElm = talbeElm + headerElm + bodyElm + '' let tabsElm = ` ${talbeElm + ''} ` if (currentData[0].content && currentData[0].content.richTextContent) { let tabPaneElm = ` ${currentData[0].content.richTextContent} ` tabsElm = tabsElm + tabPaneElm } if (currentData[0].content && currentData[0].content.link && currentData[0].content.link.content && currentData[0].content.link.content.length > 0) { for (let i = 0; i < currentData[0].content.link.content.length; i++) { let url = currentData[0].content.link.content[i].url let tabPaneElm = ` ` tabsElm = tabsElm + tabPaneElm } } tabsElm = tabsElm + '' box.innerHTML = tabsElm // that.viewer._container.appendChild(box) _DialogObject.contentAppChild(box) new cy_tabs('shp-list-id-tabs') let tabsNode = box.getElementsByClassName('DIV-cy-tabs')[0] tabsNode.style.height = '100%' tabsNode.style.display = 'flex' tabsNode.style.flexDirection = 'column'; tabsNode.getElementsByClassName('DIV-cy-tab-content')[0].style.flex = '1' let tabContentPane = tabsNode.getElementsByClassName('DIV-cy-tab-content-pane') for (let i = 0; i < tabContentPane.length; i++) { tabContentPane[i].style.height = '100%' } let headerWrapper = box.getElementsByClassName('el-table__header-wrapper')[0] let bodyWrapper = box.getElementsByClassName('el-table__body-wrapper')[0] bodyWrapper.addEventListener('scroll', function (e) { headerWrapper.scrollLeft = e.target.scrollLeft }); _DialogObject._element.title.style.height = '40px' _DialogObject._element.body.style.width = '65%' _DialogObject._element.body.style.height = '80%' _DialogObject._element.content.style.height = 'calc(100% - 40px)' _DialogObject._element.foot.style.display = 'none' bodyWrapper.style.height = `calc(100% - ${headerWrapper.offsetHeight}px)` } export { openNodeListById }