This commit is contained in:
2025-09-10 10:31:58 +08:00
parent d20db7c91b
commit 89b52af2d6
6 changed files with 366 additions and 295 deletions

View File

@ -5,77 +5,78 @@ import MouseEvent from '../Event/index'
import MouseTip from '../MouseTip'
import Tools from '../Tools'
let _DialogObject
let tip
let event
const open = async (sdk, closeCallBack) => {
let topls = new Tools()
let proj = new Proj()
let tip
let event
if (_DialogObject && _DialogObject.close) {
_DialogObject.close()
_DialogObject = null
}
_DialogObject = await new Dialog(sdk.viewer._container, {
title: '投影转换', left: '180px', top: '100px',
closeCallBack: () => {
closeCallBack && closeCallBack()
},
})
await _DialogObject.init()
// if (_DialogObject && _DialogObject.close) {
// _DialogObject.close()
// _DialogObject = null
// }
// _DialogObject = await new Dialog(sdk.viewer._container, {
// title: '投影转换', left: '180px', top: '100px',
// closeCallBack: () => {
// closeCallBack && closeCallBack()
// },
// })
// await _DialogObject.init()
let html = `
<span class="custom-divider"></span>
<div style="width: 540px;display: flex;">
<div class="row left" style="flex: 1;margin-bottom: 0;">
<div style="margin: 10px 0;flex: 1;display: flex;align-items: center;flex: 1;justify-content: space-between;">
<span class="lable-left-line">源坐标</span>
<button class="btn pick" style="margin-left: 20px;"><svg class="icon-edit"><use xlink:href="#yj-icon-edit"></use></svg>坐标拾取</button>
</div>
<div>
<div style="display: flex;margin-bottom: 12px;align-items: center;">
<span class="label" style="flex: 0 0 60px;">椭圆基准</span>
<div class="datalist_left"></div>
</div>
<div style="display: flex;margin-bottom: 12px;align-items: center;">
<span class="label" style="flex: 0 0 60px;">经度(x)</span>
<input class="input left-x" type="number" title="">
</div>
<div style="display: flex;margin-bottom: 10px;align-items: center;">
<span class="label" style="flex: 0 0 60px;">纬度(y)</span>
<input class="input left-y" type="number" title="">
</div>
</div>
</div>
<div style="display: flex;flex-direction: column;justify-content: center;margin: 28px 15px 0 15px;">
<button class="btn convert">坐标转换<i style="margin-top: 2px;margin-left: 5px;" class="el-icon-right"></i></button>
</div>
<div class="row right" style="flex: 1;margin-bottom: 0;">
<div style="margin: 10px 0;height: 32px; display: flex;align-items: center;flex: 1;justify-content: space-between;">
<span class="lable-left-line">目标坐标</span>
<button class="btn copy" data-clipboard-action="copy" data-clipboard-target=".input" style="margin-left: 20px;"><svg class="icon-copy"><use xlink:href="#yj-icon-copy"></use></svg>复制</button>
</div>
<div>
<div style="display: flex;margin-bottom: 12px;align-items: center;">
<span class="label" style="flex: 0 0 60px;">椭圆基准</span>
<div class="datalist_right"></div>
</div>
<div style="display: flex;margin-bottom: 12px;align-items: center;">
<span class="label" style="flex: 0 0 60px;">经度(x)</span>
<input class="input right-x" readonly="readonly">
</div>
<div style="display: flex;margin-bottom: 10px;align-items: center;">
<span class="label" style="flex: 0 0 60px;">纬度(y)</span>
<input class="input right-y" readonly="readonly">
</div>
</div>
</div>
</div>
<span class="custom-divider"></span>
`
let contentElm = document.createElement('div');
contentElm.innerHTML = html
_DialogObject.contentAppChild(contentElm)
// let html = `
// <span class="custom-divider"></span>
// <div style="width: 540px;display: flex;">
// <div class="row left" style="flex: 1;margin-bottom: 0;">
// <div style="margin: 10px 0;flex: 1;display: flex;align-items: center;flex: 1;justify-content: space-between;">
// <span class="lable-left-line">源坐标</span>
// <button class="btn pick" style="margin-left: 20px;"><svg class="icon-edit"><use xlink:href="#yj-icon-edit"></use></svg>坐标拾取</button>
// </div>
// <div>
// <div style="display: flex;margin-bottom: 12px;align-items: center;">
// <span class="label" style="flex: 0 0 60px;">椭圆基准</span>
// <div class="datalist_left"></div>
// </div>
// <div style="display: flex;margin-bottom: 12px;align-items: center;">
// <span class="label" style="flex: 0 0 60px;">经度(x)</span>
// <input class="input left-x" type="number" title="">
// </div>
// <div style="display: flex;margin-bottom: 10px;align-items: center;">
// <span class="label" style="flex: 0 0 60px;">纬度(y)</span>
// <input class="input left-y" type="number" title="">
// </div>
// </div>
// </div>
// <div style="display: flex;flex-direction: column;justify-content: center;margin: 28px 15px 0 15px;">
// <button class="btn convert">坐标转换<i style="margin-top: 2px;margin-left: 5px;" class="el-icon-right"></i></button>
// </div>
// <div class="row right" style="flex: 1;margin-bottom: 0;">
// <div style="margin: 10px 0;height: 32px; display: flex;align-items: center;flex: 1;justify-content: space-between;">
// <span class="lable-left-line">目标坐标</span>
// <button class="btn copy" data-clipboard-action="copy" data-clipboard-target=".input" style="margin-left: 20px;"><svg class="icon-copy"><use xlink:href="#yj-icon-copy"></use></svg>复制</button>
// </div>
// <div>
// <div style="display: flex;margin-bottom: 12px;align-items: center;">
// <span class="label" style="flex: 0 0 60px;">椭圆基准</span>
// <div class="datalist_right"></div>
// </div>
// <div style="display: flex;margin-bottom: 12px;align-items: center;">
// <span class="label" style="flex: 0 0 60px;">经度(x)</span>
// <input class="input right-x" readonly="readonly">
// </div>
// <div style="display: flex;margin-bottom: 10px;align-items: center;">
// <span class="label" style="flex: 0 0 60px;">纬度(y)</span>
// <input class="input right-y" readonly="readonly">
// </div>
// </div>
// </div>
// </div>
// <span class="custom-divider"></span>
// `
// let contentElm = document.createElement('div');
// contentElm.innerHTML = html
// _DialogObject.contentAppChild(contentElm)
// legp(contentElm, ".datalist").legp_search(tagData)
let contentElm = document.getElementsByClassName('projection-convert')[0].getElementsByClassName('content')[0]
let tagData = []
let i = 0
@ -95,6 +96,7 @@ const open = async (sdk, closeCallBack) => {
let pickElm = contentElm.getElementsByClassName('pick')[0]
let copyElm = contentElm.getElementsByClassName('copy')[0]
let sourceCopyElm = contentElm.getElementsByClassName('sourceCopy')[0]
let datalistLeftInput = contentElm.getElementsByClassName('datalist_left')[0].getElementsByTagName('input')[0]
datalistLeftInput.value = tagData[0].value
legpObjectLeft.legp_searchActive(tagData[0].value)
@ -137,11 +139,7 @@ const open = async (sdk, closeCallBack) => {
if (!leftXElm.value || !leftYElm.value) {
rightXElm.value = ''
rightYElm.value = ''
window.ELEMENT && window.ELEMENT.Message({
message: '请输入源坐标',
type: 'warning',
duration: 1500
});
topls.message({ type: 'warning', text: '请输入源坐标' })
return
}
let result = proj.convert([{ x: Number(leftXElm.value), y: Number(leftYElm.value) }], datalistLeftInput.value, datalistRightInput.value)
@ -150,11 +148,7 @@ const open = async (sdk, closeCallBack) => {
rightYElm.value = result.points[0].y
}
else {
window.ELEMENT && window.ELEMENT.Message({
message: result.message,
type: 'warning',
duration: 1500
});
topls.message({ type: 'warning', text: result.message })
}
})
@ -164,11 +158,7 @@ const open = async (sdk, closeCallBack) => {
if (!rightXElm.value || !rightYElm.value) {
rightXElm.value = ''
rightYElm.value = ''
window.ELEMENT && window.ELEMENT.Message({
message: '复制失败,目标坐标为空!',
type: 'warning',
duration: 1500
});
topls.message({ type: 'warning', text: '复制失败,目标坐标为空!' })
}
else {
let text = `${rightXElm.value},${rightYElm.value}`
@ -177,13 +167,26 @@ const open = async (sdk, closeCallBack) => {
}
});
clipboard.on('success', function (e) {
window.ELEMENT &&
window.ELEMENT.Message({
message: '已复制到剪切板',
type: 'success',
duration: 1500
})
topls.message({ text: '已复制到剪切板' })
});
let sourcelipboard = new ClipboardJS(sourceCopyElm, {
text: (trigger) => {
if (!leftXElm.value || !leftYElm.value) {
leftXElm.value = ''
leftYElm.value = ''
topls.message({ type: 'warning', text: '复制失败,目标坐标为空!' })
}
else {
let text = `${leftXElm.value},${leftYElm.value}`
return text;
}
}
});
sourcelipboard.on('success', function (e) {
topls.message({ text: '已复制到剪切板' })
});
}
@ -192,6 +195,8 @@ const close = () => {
_DialogObject.close()
_DialogObject = null
}
tip && tip.destroy()
event && event.destroy()
}
export { open, close }
export { open, close }