raintee-maputils 1.0.22 → 1.0.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +120 -97
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -5754,74 +5754,74 @@ var RainteeGISUtil = /*#__PURE__*/Object.freeze({
|
|
|
5754
5754
|
});
|
|
5755
5755
|
|
|
5756
5756
|
const treeDataAdapter = (data) => {
|
|
5757
|
-
|
|
5758
|
-
|
|
5759
|
-
|
|
5760
|
-
|
|
5761
|
-
|
|
5762
|
-
|
|
5763
|
-
|
|
5764
|
-
|
|
5765
|
-
|
|
5766
|
-
|
|
5767
|
-
|
|
5768
|
-
|
|
5769
|
-
|
|
5770
|
-
|
|
5771
|
-
|
|
5772
|
-
|
|
5773
|
-
});
|
|
5774
|
-
i++;
|
|
5775
|
-
currentNode.push({
|
|
5776
|
-
id: i,
|
|
5777
|
-
label: layerName,
|
|
5778
|
-
fullLayerName: groups.length === 0 ? layerName : groups.join('-') + '-' + layerName,
|
|
5779
|
-
layerId: item.id,
|
|
5780
|
-
opacity: '1.0',
|
|
5781
|
-
});
|
|
5782
|
-
if (item.layout && item.layout.visibility == 'visible') {
|
|
5783
|
-
checkedKeys.push(i);
|
|
5784
|
-
}
|
|
5757
|
+
let i = 0;
|
|
5758
|
+
let treeData = [];
|
|
5759
|
+
let checkedKeys = [];
|
|
5760
|
+
data.forEach((item) => {
|
|
5761
|
+
let kvs = item.id.split(';').map(kvstr => kvstr.split('='));
|
|
5762
|
+
let groups = kvs.find(item => item[0] === 'Main')[1].split('/');
|
|
5763
|
+
let layerName = kvs.find(item => item[0] === 'CN')[1];
|
|
5764
|
+
let currentNode = treeData;
|
|
5765
|
+
groups.forEach((group, index) => {
|
|
5766
|
+
currentNode.find(item => item.label === group) || i++;
|
|
5767
|
+
currentNode.find(item => item.label === group) || currentNode.push({
|
|
5768
|
+
id: i,
|
|
5769
|
+
label: group,
|
|
5770
|
+
children: []
|
|
5771
|
+
});
|
|
5772
|
+
currentNode = currentNode.find(item => item.label === group).children;
|
|
5785
5773
|
});
|
|
5786
|
-
|
|
5774
|
+
i++;
|
|
5775
|
+
currentNode.push({
|
|
5776
|
+
id: i,
|
|
5777
|
+
label: layerName,
|
|
5778
|
+
fullLayerName: groups.length === 0 ? layerName : groups.join('-') + '-' + layerName,
|
|
5779
|
+
layerId: item.id,
|
|
5780
|
+
opacity: '1.0',
|
|
5781
|
+
});
|
|
5782
|
+
if (item.layout && item.layout.visibility == 'visible') {
|
|
5783
|
+
checkedKeys.push(i);
|
|
5784
|
+
}
|
|
5785
|
+
});
|
|
5786
|
+
return { treeData, checkedKeys }
|
|
5787
5787
|
};
|
|
5788
5788
|
const treeDataAdapterNext = (data) => {
|
|
5789
|
-
|
|
5790
|
-
|
|
5791
|
-
|
|
5792
|
-
|
|
5793
|
-
|
|
5794
|
-
|
|
5795
|
-
|
|
5796
|
-
|
|
5797
|
-
|
|
5798
|
-
|
|
5799
|
-
|
|
5800
|
-
|
|
5801
|
-
|
|
5802
|
-
|
|
5803
|
-
|
|
5804
|
-
|
|
5805
|
-
|
|
5806
|
-
});
|
|
5807
|
-
i++;
|
|
5808
|
-
currentNode.push({
|
|
5809
|
-
id: item.id,
|
|
5810
|
-
label: layerName,
|
|
5811
|
-
fullLayerName: getLayerIdFidld(item.id, 'Main') + '-' + getLayerIdFidld(item.id, 'CN'),
|
|
5812
|
-
layerId: item.id,
|
|
5813
|
-
opacity: '1.0',
|
|
5814
|
-
});
|
|
5815
|
-
if (item.layout && item.layout.visibility == 'visible') {
|
|
5816
|
-
checkedKeys.push(i);
|
|
5817
|
-
}
|
|
5789
|
+
let i = 0;
|
|
5790
|
+
let treeData = [];
|
|
5791
|
+
let checkedKeys = [];
|
|
5792
|
+
data.forEach((item) => {
|
|
5793
|
+
let kvs = item.id.split(';').map(kvstr => kvstr.split('='));
|
|
5794
|
+
let groups = kvs.find(item => item[0] === 'Main')[1].split('/');
|
|
5795
|
+
let layerName = kvs.find(item => item[0] === 'CN')[1];
|
|
5796
|
+
let currentNode = treeData;
|
|
5797
|
+
groups.length === 0 ? layerName : groups.join('-') + '-' + layerName;
|
|
5798
|
+
groups.forEach((group, index) => {
|
|
5799
|
+
currentNode.find(item => item.label === group) || i++;
|
|
5800
|
+
currentNode.find(item => item.label === group) || currentNode.push({
|
|
5801
|
+
id: `TreeId=${i};`,
|
|
5802
|
+
label: group,
|
|
5803
|
+
children: []
|
|
5804
|
+
});
|
|
5805
|
+
currentNode = currentNode.find(item => item.label === group).children;
|
|
5818
5806
|
});
|
|
5819
|
-
|
|
5807
|
+
i++;
|
|
5808
|
+
currentNode.push({
|
|
5809
|
+
id: item.id,
|
|
5810
|
+
label: layerName,
|
|
5811
|
+
fullLayerName: getLayerIdFidld(item.id, 'Main') + '-' + getLayerIdFidld(item.id, 'CN'),
|
|
5812
|
+
layerId: item.id,
|
|
5813
|
+
opacity: '1.0',
|
|
5814
|
+
});
|
|
5815
|
+
if (item.layout && item.layout.visibility == 'visible') {
|
|
5816
|
+
checkedKeys.push(i);
|
|
5817
|
+
}
|
|
5818
|
+
});
|
|
5819
|
+
return { treeData, checkedKeys }
|
|
5820
5820
|
};
|
|
5821
5821
|
const getLayerIdFidld = (str, field) => {
|
|
5822
|
-
|
|
5823
|
-
|
|
5824
|
-
|
|
5822
|
+
let kvs = str.split(';').map(kvstr => kvstr.split('='));
|
|
5823
|
+
let layerId = kvs.find(item => item[0] === field)[1];
|
|
5824
|
+
return layerId
|
|
5825
5825
|
};
|
|
5826
5826
|
/**
|
|
5827
5827
|
* 生成唯一ID字符串
|
|
@@ -5832,30 +5832,30 @@ const getLayerIdFidld = (str, field) => {
|
|
|
5832
5832
|
* @returns {string} 唯一ID字符串
|
|
5833
5833
|
*/
|
|
5834
5834
|
const GenerateUniqueId = (
|
|
5835
|
-
|
|
5836
|
-
|
|
5837
|
-
|
|
5838
|
-
|
|
5835
|
+
projectId,
|
|
5836
|
+
objectTypeId,
|
|
5837
|
+
groupId,
|
|
5838
|
+
objectId
|
|
5839
5839
|
) => {
|
|
5840
|
-
|
|
5841
|
-
|
|
5842
|
-
|
|
5843
|
-
|
|
5844
|
-
|
|
5845
|
-
|
|
5846
|
-
|
|
5847
|
-
|
|
5848
|
-
|
|
5849
|
-
|
|
5840
|
+
// 将参数组合成一个字符串
|
|
5841
|
+
const combinedString = `${projectId}|${objectTypeId}|${groupId}|${objectId}`;
|
|
5842
|
+
|
|
5843
|
+
// 使用简单的哈希函数生成固定长度的字符串
|
|
5844
|
+
let hash = 0;
|
|
5845
|
+
for (let i = 0; i < combinedString.length; i++) {
|
|
5846
|
+
const char = combinedString.charCodeAt(i);
|
|
5847
|
+
hash = (hash << 5) - hash + char;
|
|
5848
|
+
hash = hash & hash; // Convert to 32bit integer
|
|
5849
|
+
}
|
|
5850
5850
|
|
|
5851
|
-
|
|
5852
|
-
|
|
5851
|
+
// 转换为16进制字符串并补零到8位
|
|
5852
|
+
const hexHash = (hash >>> 0).toString(16).padStart(8, "0");
|
|
5853
5853
|
|
|
5854
|
-
|
|
5855
|
-
|
|
5856
|
-
|
|
5857
|
-
|
|
5858
|
-
|
|
5854
|
+
// 添加前缀和分隔符增强可读性
|
|
5855
|
+
return `UID-${projectId.slice(0, 2)}-${objectTypeId.slice(
|
|
5856
|
+
0,
|
|
5857
|
+
2
|
|
5858
|
+
)}-${groupId.slice(0, 2)}-${hexHash}`;
|
|
5859
5859
|
};
|
|
5860
5860
|
/**
|
|
5861
5861
|
* 生成一个带斑马纹、固定宽高、支持滚动条的键值对表格 HTML 字符串
|
|
@@ -5866,10 +5866,10 @@ const GenerateUniqueId = (
|
|
|
5866
5866
|
* @returns {string} - 返回一个完整的 HTML 字符串,可直接插入到 innerHTML 中
|
|
5867
5867
|
*/
|
|
5868
5868
|
function generateKeyValueTableHTML(data, options = {}) {
|
|
5869
|
-
|
|
5869
|
+
const { width = 600, height = 400 } = options;
|
|
5870
5870
|
|
|
5871
|
-
|
|
5872
|
-
|
|
5871
|
+
// 开始拼接 HTML 字符串
|
|
5872
|
+
let html = `
|
|
5873
5873
|
<div style="
|
|
5874
5874
|
width: ${width}px;
|
|
5875
5875
|
height: ${height}px;
|
|
@@ -5884,15 +5884,28 @@ function generateKeyValueTableHTML(data, options = {}) {
|
|
|
5884
5884
|
font-size: 14px;
|
|
5885
5885
|
">
|
|
5886
5886
|
<tbody>
|
|
5887
|
+
<tr style="background-color: '#f9f9f9';">
|
|
5888
|
+
<td style="
|
|
5889
|
+
padding: 8px 12px;
|
|
5890
|
+
border: 1px solid #ccc;
|
|
5891
|
+
font-weight: bold;
|
|
5892
|
+
min-width: 100px;
|
|
5893
|
+
">属性</td>
|
|
5894
|
+
<td style="
|
|
5895
|
+
padding: 8px 12px;
|
|
5896
|
+
border: 1px solid #ccc;
|
|
5897
|
+
word-break: break-word;
|
|
5898
|
+
">值</td>
|
|
5899
|
+
</tr>
|
|
5887
5900
|
`;
|
|
5888
5901
|
|
|
5889
|
-
|
|
5890
|
-
|
|
5891
|
-
|
|
5892
|
-
|
|
5893
|
-
|
|
5902
|
+
// 遍历键值对,生成行
|
|
5903
|
+
data.forEach((item, index) => {
|
|
5904
|
+
const bgColor = index % 2 === 0 ? '#ffffff' : '#f9f9f9'; // 斑马纹背景色
|
|
5905
|
+
const label = item.label || '';
|
|
5906
|
+
const value = item.value || '';
|
|
5894
5907
|
|
|
5895
|
-
|
|
5908
|
+
html += `
|
|
5896
5909
|
<tr style="background-color: ${bgColor};">
|
|
5897
5910
|
<td style="
|
|
5898
5911
|
padding: 8px 12px;
|
|
@@ -5907,22 +5920,32 @@ function generateKeyValueTableHTML(data, options = {}) {
|
|
|
5907
5920
|
">${value}</td>
|
|
5908
5921
|
</tr>
|
|
5909
5922
|
`;
|
|
5910
|
-
|
|
5923
|
+
});
|
|
5911
5924
|
|
|
5912
|
-
|
|
5913
|
-
|
|
5925
|
+
// 闭合标签
|
|
5926
|
+
html += `
|
|
5914
5927
|
</tbody>
|
|
5915
5928
|
</table>
|
|
5916
5929
|
</div>
|
|
5917
5930
|
`;
|
|
5918
5931
|
|
|
5919
|
-
|
|
5920
|
-
|
|
5932
|
+
// 返回拼接好的 HTML 字符串
|
|
5933
|
+
return html;
|
|
5934
|
+
}
|
|
5935
|
+
|
|
5936
|
+
function downloadByUrl(url, filename = '') {
|
|
5937
|
+
const a = document.createElement('a');
|
|
5938
|
+
a.href = url;
|
|
5939
|
+
a.download = filename || ''; // 为空则使用服务器返回的默认文件名
|
|
5940
|
+
document.body.appendChild(a);
|
|
5941
|
+
a.click();
|
|
5942
|
+
document.body.removeChild(a);
|
|
5921
5943
|
}
|
|
5922
5944
|
|
|
5923
5945
|
var RainteeSourceMapTool = /*#__PURE__*/Object.freeze({
|
|
5924
5946
|
__proto__: null,
|
|
5925
5947
|
GenerateUniqueId: GenerateUniqueId,
|
|
5948
|
+
downloadByUrl: downloadByUrl,
|
|
5926
5949
|
generateKeyValueTableHTML: generateKeyValueTableHTML,
|
|
5927
5950
|
getLayerIdFidld: getLayerIdFidld,
|
|
5928
5951
|
treeDataAdapter: treeDataAdapter,
|