Commit 6bc40041 authored by Samir Sadyhov's avatar Samir Sadyhov 🤔

update UTILS (parse dict)

parent 41cbd785
......@@ -365,6 +365,30 @@ UTILS.detectBrowser = () => {
}
}
const getDictValue = (item, id) => {
return item.values.find(x => x.columnID == id)?.value || null;
}
UTILS.parseDict = dict => {
const result = [];
try {
if(!dict) throw new Error('Не передан справочник');
dict.items.forEach(item => {
const tmp = {};
tmp.itemID = item.itemID;
dict.columns.forEach(col => {
tmp[col.code] = getDictValue(item, col.columnID);
});
result.push(tmp);
});
return result;
} catch (err) {
return result;
}
}
//выпиливыние из массива повторяющихся елементов
Array.prototype.uniq = function() {
return this.filter(function(v, i, a){ return i == a.indexOf(v) });
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment