raintee-maputils 1.0.21 → 1.0.22
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 +64 -1
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
package/dist/index.js
CHANGED
|
@@ -5856,11 +5856,74 @@ const GenerateUniqueId = (
|
|
|
5856
5856
|
0,
|
|
5857
5857
|
2
|
|
5858
5858
|
)}-${groupId.slice(0, 2)}-${hexHash}`;
|
|
5859
|
-
};
|
|
5859
|
+
};
|
|
5860
|
+
/**
|
|
5861
|
+
* 生成一个带斑马纹、固定宽高、支持滚动条的键值对表格 HTML 字符串
|
|
5862
|
+
* @param {Array<{label: string, value: string}>} data - 键值对数组,如 [{label: '姓名', value: '张三'}, ...]
|
|
5863
|
+
* @param {Object} [options] - 可选配置
|
|
5864
|
+
* @param {number} [options.width=600] - 表格容器宽度(像素)
|
|
5865
|
+
* @param {number} [options.height=400] - 表格容器高度(像素)
|
|
5866
|
+
* @returns {string} - 返回一个完整的 HTML 字符串,可直接插入到 innerHTML 中
|
|
5867
|
+
*/
|
|
5868
|
+
function generateKeyValueTableHTML(data, options = {}) {
|
|
5869
|
+
const { width = 600, height = 400 } = options;
|
|
5870
|
+
|
|
5871
|
+
// 开始拼接 HTML 字符串
|
|
5872
|
+
let html = `
|
|
5873
|
+
<div style="
|
|
5874
|
+
width: ${width}px;
|
|
5875
|
+
height: ${height}px;
|
|
5876
|
+
overflow: auto;
|
|
5877
|
+
border: 1px solid #ddd;
|
|
5878
|
+
border-radius: 4px;
|
|
5879
|
+
">
|
|
5880
|
+
<table style="
|
|
5881
|
+
width: 100%;
|
|
5882
|
+
border-collapse: collapse;
|
|
5883
|
+
font-family: Arial, sans-serif;
|
|
5884
|
+
font-size: 14px;
|
|
5885
|
+
">
|
|
5886
|
+
<tbody>
|
|
5887
|
+
`;
|
|
5888
|
+
|
|
5889
|
+
// 遍历键值对,生成行
|
|
5890
|
+
data.forEach((item, index) => {
|
|
5891
|
+
const bgColor = index % 2 === 0 ? '#ffffff' : '#f9f9f9'; // 斑马纹背景色
|
|
5892
|
+
const label = item.label || '';
|
|
5893
|
+
const value = item.value || '';
|
|
5894
|
+
|
|
5895
|
+
html += `
|
|
5896
|
+
<tr style="background-color: ${bgColor};">
|
|
5897
|
+
<td style="
|
|
5898
|
+
padding: 8px 12px;
|
|
5899
|
+
border: 1px solid #ccc;
|
|
5900
|
+
font-weight: bold;
|
|
5901
|
+
min-width: 100px;
|
|
5902
|
+
">${label}</td>
|
|
5903
|
+
<td style="
|
|
5904
|
+
padding: 8px 12px;
|
|
5905
|
+
border: 1px solid #ccc;
|
|
5906
|
+
word-break: break-word;
|
|
5907
|
+
">${value}</td>
|
|
5908
|
+
</tr>
|
|
5909
|
+
`;
|
|
5910
|
+
});
|
|
5911
|
+
|
|
5912
|
+
// 闭合标签
|
|
5913
|
+
html += `
|
|
5914
|
+
</tbody>
|
|
5915
|
+
</table>
|
|
5916
|
+
</div>
|
|
5917
|
+
`;
|
|
5918
|
+
|
|
5919
|
+
// 返回拼接好的 HTML 字符串
|
|
5920
|
+
return html;
|
|
5921
|
+
}
|
|
5860
5922
|
|
|
5861
5923
|
var RainteeSourceMapTool = /*#__PURE__*/Object.freeze({
|
|
5862
5924
|
__proto__: null,
|
|
5863
5925
|
GenerateUniqueId: GenerateUniqueId,
|
|
5926
|
+
generateKeyValueTableHTML: generateKeyValueTableHTML,
|
|
5864
5927
|
getLayerIdFidld: getLayerIdFidld,
|
|
5865
5928
|
treeDataAdapter: treeDataAdapter,
|
|
5866
5929
|
treeDataAdapterNext: treeDataAdapterNext
|