Skip to content

Commit 91f7e26

Browse files
committed
【SDK】【行业标绘数据转换】
1 parent 96787e5 commit 91f7e26

File tree

1 file changed

+39
-4
lines changed

1 file changed

+39
-4
lines changed

src/service/PlotBase/SymbolManager/SymbolManager.js

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ export default class SymbolManager {
2121

2222
const {fontURL = '', baseUrl = ''} = options;
2323

24-
if(!window._mapgisSymanagerConfig_) {
24+
if (!window._mapgisSymanagerConfig_) {
2525
window._mapgisSymanagerConfig_ = {};
2626
}
2727

28-
if(fontURL) {
28+
if (fontURL) {
2929
window._mapgisSymanagerConfig_._fontURL = fontURL;
3030
}
3131

32-
if(baseUrl) {
32+
if (baseUrl) {
3333
window._mapgisSymanagerConfig_._baseUrl = baseUrl;
3434
}
3535

@@ -41,14 +41,49 @@ export default class SymbolManager {
4141
return SymbolManager.instance;
4242
}
4343

44+
formatData(data) {
45+
const {symbols} = data;
46+
let result = [];
47+
for (let i = 0; i < symbols.length; i++) {
48+
result.push({
49+
title: symbols[i].name,
50+
children: []
51+
});
52+
const {items} = symbols[i];
53+
for (let j = 0; j < items.length; j++) {
54+
if (items[j].type === 'folder') {
55+
result[i].children.push({
56+
type: items[j].name,
57+
children: []
58+
});
59+
let icons = items[j].items;
60+
for (let k = 0; k < icons.length; k++) {
61+
result[i].children[j].children.push({
62+
"id": icons[k].id,
63+
"name": icons[k].name,
64+
"type": icons[k].type,
65+
"src": icons[k].path
66+
});
67+
}
68+
}
69+
}
70+
}
71+
72+
return {
73+
name: data.name,
74+
children: result
75+
};
76+
}
77+
4478
async getSymbols() {
4579
if (this._symbols) return this._symbols;
4680

4781
try {
4882
const res = await axios.get(this._symbolsUrl);
4983
this._symbols = new SymbolCatalog();
50-
this._symbols.fromJson(res.data);
84+
this._symbols.fromJson(this.formatData(res.data));
5185
this._leaves = this._symbols.getAllLeaves();
86+
this._symbols._config = res.data;
5287
return this._symbols;
5388
} catch (err) {
5489
const res = await getAction("/symbol/catalog/queryTreeListByPid");

0 commit comments

Comments
 (0)