Show norm cost breakdown and reference rates in finder
This commit is contained in:
+42
-15
@@ -21,6 +21,7 @@
|
||||
let searchPage = null;
|
||||
let browsePage = null;
|
||||
let catalogRows = [];
|
||||
let rateRows = [];
|
||||
let requestSeq = 0;
|
||||
let detailSeq = 0;
|
||||
let lastFamily = '';
|
||||
@@ -28,6 +29,8 @@
|
||||
let priceZones = [];
|
||||
const compared = new Map();
|
||||
const money = n => new Intl.NumberFormat('ru-RU', {minimumFractionDigits:2, maximumFractionDigits:2}).format(n) + ' ₽';
|
||||
const amount = n => Number.isFinite(n) ? money(n).replace(' ₽', '') : '—';
|
||||
const emptyTableCells = count => Array.from({length:count}, () => ['','']);
|
||||
|
||||
function node(tag, value, className) {
|
||||
const el = document.createElement(tag);
|
||||
@@ -134,7 +137,7 @@
|
||||
return row;
|
||||
}
|
||||
function sectionHeading(label) {
|
||||
return tableRow('norm-section-heading', [['',''],[label,''],['',''],['',''],['','']]);
|
||||
return tableRow('norm-section-heading', [['',''],[label,''],...emptyTableCells(7)]);
|
||||
}
|
||||
function selectVariant(row) {
|
||||
showRows([row]); browsePage = null; searchPage = null; $('more-results').hidden = true;
|
||||
@@ -144,11 +147,15 @@
|
||||
}
|
||||
function renderSearchItem(item, familyName) {
|
||||
const row = tableRow('norm-row', [['','norm-code-cell'],['','norm-name'],[item.unit || '—',''],['','num'],
|
||||
[item.cost != null ? money(item.cost).replace(' ₽', '') : '—','num']]);
|
||||
...[item.cost,item.salary,item.machines,item.salary_mach,item.materials]
|
||||
.map(value => [amount(value),'num'])]);
|
||||
row.dataset.key = key(item);
|
||||
row.cells[4].title = item.cost != null
|
||||
? 'Базисная стоимость, уровень ' + (item.price_level || 'не указан')
|
||||
: 'Прямые затраты для этой нормы в индексе не указаны';
|
||||
for (let index = 4; index < row.cells.length; index++) {
|
||||
row.cells[index].title = item.cost != null
|
||||
? 'Базисная стоимость ФЕР, уровень ' + (item.price_level || 'не указан')
|
||||
: 'В этой норме нет готовой единичной цены';
|
||||
}
|
||||
row.cells[7].title += '. ОТм входит в ЭМ, к ПЗ повторно не прибавляется';
|
||||
const codeCell = row.cells[0];
|
||||
const workToggle = node('button', '▸', 'norm-toggle');
|
||||
const resourceToggle = node('button', '▸', 'norm-toggle');
|
||||
@@ -174,8 +181,8 @@
|
||||
return detail;
|
||||
}
|
||||
function toolsRow() {
|
||||
const toolRow = tableRow('norm-tools-row', [['',''],['',''],['',''],['',''],['','']]);
|
||||
const cell = toolRow.cells[1]; cell.colSpan = 4;
|
||||
const toolRow = tableRow('norm-tools-row', emptyTableCells(9));
|
||||
const cell = toolRow.cells[1]; cell.colSpan = 8;
|
||||
while (toolRow.cells.length > 2) toolRow.deleteCell(2);
|
||||
const tools = node('div', null, 'norm-tools');
|
||||
const compare = node('button', compared.has(key(item)) ? 'Убрать из сравнения' : 'Сравнить', 'secondary');
|
||||
@@ -242,20 +249,28 @@
|
||||
if (which === 'work' && !workRows.length) {
|
||||
workRows = [sectionHeading('Состав работ')];
|
||||
for (const [index, line] of (data.content || []).entries())
|
||||
workRows.push(tableRow('norm-work-row', [[index + 1,'num'],[line,''],['',''],['',''],['','']]));
|
||||
if (workRows.length === 1) workRows.push(tableRow('norm-work-row', [['',''],['Состав работ в индексе не указан',''],['',''],['',''],['','']]));
|
||||
workRows.push(tableRow('norm-work-row', [[index + 1,'num'],[line,''],...emptyTableCells(7)]));
|
||||
if (workRows.length === 1) workRows.push(tableRow('norm-work-row',
|
||||
[['',''],['Состав работ в индексе не указан',''],...emptyTableCells(7)]));
|
||||
}
|
||||
if (which === 'resource' && !resourceRows.length) {
|
||||
resourceRows = [sectionHeading('Состав норматива')];
|
||||
for (const resource of data.resources || []) {
|
||||
const quantity = resource.quantity_note || (resource.quantity ?? '—');
|
||||
const price = !resource.quantity_note && Number.isFinite(resource.quantity)
|
||||
&& Number.isFinite(resource.base_price?.cost)
|
||||
? money(resource.quantity * resource.base_price.cost).replace(' ₽','') : '—';
|
||||
const numeric = !resource.quantity_note && Number.isFinite(resource.quantity);
|
||||
const price = numeric && Number.isFinite(resource.base_price?.cost)
|
||||
? amount(resource.quantity * resource.base_price.cost) : '—';
|
||||
const machinist = numeric && Number.isFinite(resource.base_price?.cost)
|
||||
&& Number.isFinite(resource.base_price?.salary_mach)
|
||||
? amount(resource.quantity * resource.base_price.salary_mach) : '—';
|
||||
const machine = /^91\./.test(String(resource.code || ''));
|
||||
const material = /^\d{2}\./.test(String(resource.code || '')) && !machine;
|
||||
resourceRows.push(tableRow('norm-resource-row', [[resource.code || '—',''],
|
||||
[resource.name || '—',''],[resource.unit || '—',''],[quantity,'num'],[price,'num']]));
|
||||
[resource.name || '—',''],[resource.unit || '—',''],[quantity,'num'],[price,'num'],
|
||||
['—','num'],[machine ? price : '—','num'],[machinist,'num'],[material ? price : '—','num']]));
|
||||
}
|
||||
if (resourceRows.length === 1) resourceRows.push(tableRow('norm-resource-row', [['',''],['Ресурсы в индексе не указаны',''],['',''],['',''],['','']]));
|
||||
if (resourceRows.length === 1) resourceRows.push(tableRow('norm-resource-row',
|
||||
[['',''],['Ресурсы в индексе не указаны',''],...emptyTableCells(7)]));
|
||||
resourceRows.push(toolsRow());
|
||||
}
|
||||
} catch (error) { status(error.message, true); return; }
|
||||
@@ -287,7 +302,7 @@
|
||||
const title = familyTitle(groups.get(family));
|
||||
if (family !== lastFamily) {
|
||||
$('results').append(tableRow('norm-family-row', [[String(item.code || '').replace(/-\d+$/, ''),''],
|
||||
[title,''],['',''],['',''],['','']]));
|
||||
[title,''],...emptyTableCells(7)]));
|
||||
lastFamily = family;
|
||||
}
|
||||
$('results').append(renderSearchItem(item, title));
|
||||
@@ -683,6 +698,11 @@
|
||||
'id', 'name', 'Выберите базу');
|
||||
if (bases.length) $('base').selectedIndex = 1;
|
||||
catalogRows = data.bases || [];
|
||||
rateRows = data.rates || [];
|
||||
fillSelect($('rate-type'), rateRows.map(row => ({id:row.id,
|
||||
name:row.id + ' · ' + row.name})), 'id', 'name', 'Выберите вид работ');
|
||||
$('rate-type').disabled = !rateRows.length;
|
||||
if (!rateRows.length) $('rate-type').options[0].textContent = 'Справочник НР/СП недоступен';
|
||||
fillBaseTypes();
|
||||
subjects = data.subjects || [];
|
||||
if (!publicMode) fillSelect($('subject'), subjects, 'id', 'name', 'Выберите регион');
|
||||
@@ -696,6 +716,13 @@
|
||||
? loadBrowse(browsePage.path, null, true) : search(event, true));
|
||||
$('base').addEventListener('change', () => { fillBaseTypes(); loadBrowse(); });
|
||||
$('base-type').addEventListener('change', () => loadBrowse());
|
||||
$('rate-type').addEventListener('change', () => {
|
||||
const selected = rateRows.find(row => row.id === $('rate-type').value);
|
||||
const values = selected
|
||||
? [selected.nr_code, selected.nr_pct + ' %', '—', '—', selected.sp_code, selected.sp_pct + ' %']
|
||||
: ['—', '—', '—', '—', '—', '—'];
|
||||
[...$('rate-values').cells].forEach((cell, index) => { cell.textContent = values[index]; });
|
||||
});
|
||||
$('catalog-mobile').addEventListener('click', () => {
|
||||
const tree = $('catalog-tree');
|
||||
tree.hidden = !tree.hidden;
|
||||
|
||||
Reference in New Issue
Block a user