import BaseDialog from '../../../BaseDialog'; class Dialog extends BaseDialog { constructor(sdk, info, options, only) { super(sdk.viewer._container, options); this.sdk = sdk this.viewer = sdk.viewer this.info = info if (only) { this.closeAll() } this._init() } async _init() { await this.init() await this._attribute() if (this.options.confirmCallBack) { let confirmBtn = document.createElement('button'); confirmBtn.className = 'confirm'; confirmBtn.innerHTML = '确认' this.footAppChild(confirmBtn) confirmBtn.addEventListener('click', () => { // console.log('确认') if (this.options.confirmCallBack) { this.options.confirmCallBack(this.info) } }); } if (this.options.removeCallBack) { let deleteBtn = document.createElement('button'); deleteBtn.className = 'delete'; deleteBtn.innerHTML = '删除' this.footAppChild(deleteBtn) deleteBtn.addEventListener('click', () => { // console.log('删除') this.close() if (this.options.removeCallBack) { this.options.removeCallBack() } }); } // if (this.options.resetCallBack) { // let resetBtn = document.createElement('button'); // resetBtn.className = 'reset'; // resetBtn.innerHTML = '重置' // this.footAppChild(resetBtn) // resetBtn.addEventListener('click', () => { // // console.log('重置') // if (this.options.resetCallBack) { // this.options.resetCallBack() // } // }); // } if (this.options.rotateCallBack) { let rotateBtn = document.createElement('button'); rotateBtn.className = 'rotate'; rotateBtn.innerHTML = '旋转' this.footAppChild(rotateBtn) rotateBtn.addEventListener('click', () => { // console.log('旋转') if (this.options.rotateCallBack) { this.options.rotateCallBack() } }); } if (this.options.translationalCallBack || this.options.updateHeightCallBack || this.options.secondaryEditCallBack) { let div = document.createElement('div'); div.style.position ='absolute' div.style.left ='24px' div.style.flet = '0' div.style.display = 'flex' this.footAppChild(div) if (this.options.updateHeightCallBack) { let heightBtn = document.createElement('button'); heightBtn.innerHTML = '更新高程' heightBtn.style.width = 'auto' heightBtn.addEventListener('click', () => { this.options.updateHeightCallBack() }) div.appendChild(heightBtn) } if (this.options.secondaryEditCallBack) { let secondaryEditBtn = document.createElement('button'); secondaryEditBtn.className = 'secondaryEdit'; secondaryEditBtn.innerHTML = '二次编辑' if (this.options.updateHeightCallBack) { secondaryEditBtn.style.marginLeft = '10px' } div.appendChild(secondaryEditBtn) secondaryEditBtn.addEventListener('click', () => { // console.log('二次编辑') if (this.options.secondaryEditCallBack) { this.options.secondaryEditCallBack() } }); } if (this.options.translationalCallBack) { let translationalBtn = document.createElement('button'); translationalBtn.className = 'translational'; translationalBtn.innerHTML = `平移` if (this.options.updateHeightCallBack || this.options.secondaryEditCallBack) { translationalBtn.style.marginLeft = '10px' } div.appendChild(translationalBtn) translationalBtn.addEventListener('click', () => { // console.log('平移') if (this.options.translationalCallBack) { this.options.translationalCallBack() } }); } } if (this.options.addFootElm) { for (let i = 0; i < this.options.addFootElm.length; i++) { let elm = document.createElement(this.options.addFootElm[i].tagName); elm.className = this.options.addFootElm[i].className elm.innerHTML = this.options.addFootElm[i].innerHTML if(this.options.addFootElm[i].event && this.options.addFootElm[i].event.length==2) { elm.addEventListener(this.options.addFootElm[i].event[0], this.options.addFootElm[i].event[1]) } this.footAppChild(elm) } } // if (this.options.showCallBack) { // let showBox = document.createElement('div'); // showBox.className = 'show'; // showBox.style = 'display: flex;align-items: center;' // showBox.innerHTML = `隐藏显示` // this.footAppChild(showBox) // let showBtn = showBox.querySelector("input[name='show']") // this.showBtn = showBtn // showBtn.checked = this.info.show // showBtn.addEventListener('input', (e) => { // this.info.show = e.target.checked // if (this.options.showCallBack) { // this.options.showCallBack(this.info.show) // } // }); // } } _attribute() { let attribute = this._element.content.getElementsByClassName('attribute')[0] if (!attribute || attribute.length === 0) { return } let attributeSelectOption = attribute.getElementsByClassName('attribute-select')[0].getElementsByTagName('option') for (let i = attributeSelectOption.length - 1; i >= 0; i--) { for (let key in this.info.attribute) { if (attributeSelectOption[i].value === key) { if (this.info.attribute[key].disabled) { attributeSelectOption[i].disabled = true } break } } } } } export default Dialog