331 lines
9.8 KiB
JavaScript
331 lines
9.8 KiB
JavaScript
// Single source of status defaults.
|
||
// Runtime config is loaded from backend via /api/internal-statuses.
|
||
|
||
const DEFAULT_MARKS_CONFIG = [
|
||
{
|
||
key: 'needs_reply',
|
||
chipClass: 'chip-reply',
|
||
chipLabel: 'Нужен ответ',
|
||
chipDotColor: '#ff4d4f',
|
||
badgeClass: 'sb-reply',
|
||
label: 'Нужен ответ',
|
||
sseLabel: 'Нужно ответить',
|
||
exportLabel: 'Клиент ждет ответа',
|
||
btnClass: 'mbtn-reply',
|
||
rowClass: 'row-reply',
|
||
btnIcon: '✉',
|
||
btnLabel: 'Нужно ответить',
|
||
ispColor: '#ff4d4f',
|
||
kbColor: '#ff4d4f',
|
||
kbShortcut: '1',
|
||
clearOnUpdate: true,
|
||
colorBg: '#fff1f0',
|
||
colorBorder: '#ffa39e',
|
||
colorText: '#cf1322',
|
||
colorDot: '#ff4d4f',
|
||
is_system: true,
|
||
system_role: 'needs_reply',
|
||
sort_order: 10,
|
||
is_active: true,
|
||
},
|
||
{
|
||
key: 'wait_client',
|
||
chipClass: 'chip-wait',
|
||
chipLabel: 'Ждем клиента',
|
||
chipDotColor: '#fa8c16',
|
||
badgeClass: 'sb-wait',
|
||
label: 'Ждем клиента',
|
||
sseLabel: 'Ждем клиента',
|
||
exportLabel: 'Ждем клиента',
|
||
btnClass: 'mbtn-wait',
|
||
rowClass: 'row-wait',
|
||
btnIcon: '⏳',
|
||
btnLabel: 'Ждем клиента',
|
||
ispColor: '#fa8c16',
|
||
kbColor: '#fa8c16',
|
||
kbShortcut: '2',
|
||
clearOnUpdate: false,
|
||
colorBg: '#fff7e6',
|
||
colorBorder: '#ffd591',
|
||
colorText: '#d46b08',
|
||
colorDot: '#fa8c16',
|
||
is_system: true,
|
||
system_role: 'wait_client',
|
||
sort_order: 20,
|
||
is_active: true,
|
||
},
|
||
{
|
||
key: 'resolved',
|
||
chipClass: 'chip-resolved',
|
||
chipLabel: 'Выполнена',
|
||
chipDotColor: '#52c41a',
|
||
badgeClass: 'sb-resolved',
|
||
label: 'Выполнена',
|
||
sseLabel: 'Выполнена',
|
||
exportLabel: 'Выполнена',
|
||
btnClass: 'mbtn-resolve',
|
||
rowClass: 'row-resolved',
|
||
btnIcon: '✓',
|
||
btnLabel: 'Выполнена',
|
||
ispColor: '#52c41a',
|
||
kbColor: '#52c41a',
|
||
kbShortcut: '3',
|
||
clearOnUpdate: false,
|
||
colorBg: '#f6ffed',
|
||
colorBorder: '#b7eb8f',
|
||
colorText: '#389e0d',
|
||
colorDot: '#52c41a',
|
||
is_system: true,
|
||
system_role: 'done',
|
||
sort_order: 30,
|
||
is_active: true,
|
||
},
|
||
{
|
||
key: 'vyezdnye',
|
||
chipClass: 'chip-vyezdnye',
|
||
chipLabel: 'Не наша',
|
||
chipDotColor: '#722ed1',
|
||
badgeClass: 'sb-vyezdnye',
|
||
label: 'Не наша',
|
||
sseLabel: 'Не наша',
|
||
exportLabel: 'Не наша',
|
||
btnClass: 'mbtn-vyezdnye',
|
||
rowClass: 'row-vyezdnye',
|
||
btnIcon: '🚗',
|
||
btnLabel: 'Не наша',
|
||
ispColor: '#722ed1',
|
||
kbColor: '#722ed1',
|
||
kbShortcut: '4',
|
||
clearOnUpdate: false,
|
||
colorBg: '#f9f0ff',
|
||
colorBorder: '#d3adf7',
|
||
colorText: '#531dab',
|
||
colorDot: '#722ed1',
|
||
is_system: false,
|
||
system_role: null,
|
||
sort_order: 40,
|
||
is_active: true,
|
||
},
|
||
{
|
||
key: 'hidden',
|
||
chipClass: 'chip-hidden',
|
||
chipLabel: 'Скрытые',
|
||
chipDotColor: 'var(--text2)',
|
||
badgeClass: 'sb-hidden',
|
||
label: 'Скрыто',
|
||
sseLabel: 'Скрыто',
|
||
exportLabel: 'Скрыто',
|
||
btnClass: 'mbtn-hidden',
|
||
rowClass: 'row-hidden',
|
||
btnIcon: '⊘',
|
||
btnLabel: 'Скрыть',
|
||
ispColor: '#bbb',
|
||
kbColor: '#bbb',
|
||
kbShortcut: '6',
|
||
clearOnUpdate: false,
|
||
colorBg: '#f5f5f5',
|
||
colorBorder: '#d9d9d9',
|
||
colorText: '#888',
|
||
colorDot: '#bbb',
|
||
is_system: false,
|
||
system_role: null,
|
||
sort_order: 50,
|
||
is_active: true,
|
||
},
|
||
{
|
||
key: 'oborudovanie-fix',
|
||
chipClass: 'chip-oborudovanie-fix',
|
||
chipLabel: 'Клиент отправил',
|
||
chipDotColor: '#fa541c',
|
||
badgeClass: 'sb-oborudovanie-fix',
|
||
label: 'Клиент отправил оборудование',
|
||
sseLabel: 'Клиент отправил оборудование',
|
||
exportLabel: 'Клиент отправил оборудование',
|
||
btnClass: 'mbtn-oborudovanie-fix',
|
||
rowClass: 'row-oborudovanie-fix',
|
||
btnIcon: '📤',
|
||
btnLabel: 'Клиент отправил',
|
||
ispColor: '#fa541c',
|
||
kbColor: '#fa541c',
|
||
kbShortcut: '7',
|
||
clearOnUpdate: false,
|
||
colorBg: '#fff2e8',
|
||
colorBorder: '#ffbb96',
|
||
colorText: '#d4380d',
|
||
colorDot: '#fa541c',
|
||
is_system: false,
|
||
system_role: null,
|
||
sort_order: 60,
|
||
is_active: true,
|
||
},
|
||
{
|
||
key: 'oborudovanie-in-repair',
|
||
chipClass: 'chip-oborudovanie-in-repair',
|
||
chipLabel: 'В ремонте',
|
||
chipDotColor: '#13c2c2',
|
||
badgeClass: 'sb-oborudovanie-in-repair',
|
||
label: 'Оборудование в ремонте',
|
||
sseLabel: 'Оборудование в ремонте',
|
||
exportLabel: 'Оборудование в ремонте',
|
||
btnClass: 'mbtn-oborudovanie-in-repair',
|
||
rowClass: 'row-oborudovanie-in-repair',
|
||
btnIcon: '🔧',
|
||
btnLabel: 'В ремонте',
|
||
ispColor: '#13c2c2',
|
||
kbColor: '#13c2c2',
|
||
kbShortcut: '8',
|
||
clearOnUpdate: false,
|
||
colorBg: '#e6fffb',
|
||
colorBorder: '#87e8de',
|
||
colorText: '#08979c',
|
||
colorDot: '#13c2c2',
|
||
is_system: false,
|
||
system_role: null,
|
||
sort_order: 70,
|
||
is_active: true,
|
||
},
|
||
{
|
||
key: 'oborudovanie-repair-done',
|
||
chipClass: 'chip-oborudovanie-repair-done',
|
||
chipLabel: 'Ремонт окончен',
|
||
chipDotColor: '#52c41a',
|
||
badgeClass: 'sb-oborudovanie-repair-done',
|
||
label: 'Ремонт окончен - ждет отправки',
|
||
sseLabel: 'Ремонт окончен - ждет отправки',
|
||
exportLabel: 'Ремонт окончен - ждет отправки',
|
||
btnClass: 'mbtn-oborudovanie-repair-done',
|
||
rowClass: 'row-oborudovanie-repair-done',
|
||
btnIcon: '✅',
|
||
btnLabel: 'Ремонт окончен',
|
||
ispColor: '#52c41a',
|
||
kbColor: '#52c41a',
|
||
kbShortcut: '9',
|
||
clearOnUpdate: false,
|
||
colorBg: '#f6ffed',
|
||
colorBorder: '#b7eb8f',
|
||
colorText: '#389e0d',
|
||
colorDot: '#52c41a',
|
||
is_system: false,
|
||
system_role: null,
|
||
sort_order: 80,
|
||
is_active: true,
|
||
},
|
||
{
|
||
key: 'oborudovanie-send-back',
|
||
chipClass: 'chip-oborudovanie-send-back',
|
||
chipLabel: 'Отправлено клиенту',
|
||
chipDotColor: '#1677ff',
|
||
badgeClass: 'sb-oborudovanie-send-back',
|
||
label: 'Оборудование отправлено клиенту',
|
||
sseLabel: 'Оборудование отправлено клиенту',
|
||
exportLabel: 'Оборудование отправлено клиенту',
|
||
btnClass: 'mbtn-oborudovanie-send-back',
|
||
rowClass: 'row-oborudovanie-send-back',
|
||
btnIcon: '🚚',
|
||
btnLabel: 'Отправлено клиенту',
|
||
ispColor: '#1677ff',
|
||
kbColor: '#1677ff',
|
||
kbShortcut: '0',
|
||
clearOnUpdate: false,
|
||
colorBg: '#e6f4ff',
|
||
colorBorder: '#91caff',
|
||
colorText: '#0958d9',
|
||
colorDot: '#1677ff',
|
||
is_system: false,
|
||
system_role: null,
|
||
sort_order: 90,
|
||
is_active: true,
|
||
},
|
||
{
|
||
key: 'oborudovanie-returned',
|
||
chipClass: 'chip-oborudovanie-returned',
|
||
chipLabel: 'Клиент получил',
|
||
chipDotColor: '#722ed1',
|
||
badgeClass: 'sb-oborudovanie-returned',
|
||
label: 'Клиент получил оборудование',
|
||
sseLabel: 'Клиент получил оборудование',
|
||
exportLabel: 'Клиент получил оборудование',
|
||
btnClass: 'mbtn-oborudovanie-returned',
|
||
rowClass: 'row-oborudovanie-returned',
|
||
btnIcon: '🏠',
|
||
btnLabel: 'Клиент получил',
|
||
ispColor: '#722ed1',
|
||
kbColor: '#722ed1',
|
||
kbShortcut: '',
|
||
clearOnUpdate: false,
|
||
colorBg: '#f9f0ff',
|
||
colorBorder: '#d3adf7',
|
||
colorText: '#531dab',
|
||
colorDot: '#722ed1',
|
||
is_system: false,
|
||
system_role: null,
|
||
sort_order: 100,
|
||
is_active: true,
|
||
},
|
||
];
|
||
|
||
function cloneDefaultConfig() {
|
||
return DEFAULT_MARKS_CONFIG.map((item) => ({ ...item }));
|
||
}
|
||
|
||
function normalizeStatusConfig(item, index) {
|
||
const key = String(item?.key || '').trim();
|
||
const label = String(item?.label || item?.chipLabel || key || `Статус ${index + 1}`);
|
||
const colorDot = item?.colorDot || item?.chipDotColor || item?.ispColor || '#1677ff';
|
||
const colorBg = item?.colorBg || 'var(--surface2)';
|
||
const colorBorder = item?.colorBorder || 'var(--border2)';
|
||
const colorText = item?.colorText || 'var(--text2)';
|
||
const sortOrder = Number.isFinite(Number(item?.sort_order)) ? Number(item.sort_order) : index + 1;
|
||
|
||
return {
|
||
key,
|
||
chipClass: item?.chipClass || `chip-${key}`,
|
||
chipLabel: item?.chipLabel || label,
|
||
chipDotColor: item?.chipDotColor || colorDot,
|
||
badgeClass: item?.badgeClass || 'sb-custom',
|
||
label,
|
||
sseLabel: item?.sseLabel || label,
|
||
exportLabel: item?.exportLabel || label,
|
||
btnClass: item?.btnClass || 'mbtn-custom',
|
||
rowClass: item?.rowClass || '',
|
||
btnIcon: item?.btnIcon || '•',
|
||
btnLabel: item?.btnLabel || label,
|
||
ispColor: item?.ispColor || colorDot,
|
||
kbColor: item?.kbColor || colorDot,
|
||
kbShortcut: item?.kbShortcut || '',
|
||
clearOnUpdate: !!item?.clearOnUpdate,
|
||
colorBg,
|
||
colorBorder,
|
||
colorText,
|
||
colorDot,
|
||
is_system: !!item?.is_system,
|
||
system_role: item?.system_role || null,
|
||
sort_order: sortOrder,
|
||
is_active: item?.is_active !== false,
|
||
};
|
||
}
|
||
|
||
let MARKS_CONFIG = cloneDefaultConfig().map(normalizeStatusConfig);
|
||
|
||
function setMarksConfig(nextConfig) {
|
||
const sourceRaw = Array.isArray(nextConfig) && nextConfig.length ? nextConfig : cloneDefaultConfig();
|
||
const source = sourceRaw.filter((item) => item?.is_active !== false);
|
||
MARKS_CONFIG = source.map(normalizeStatusConfig);
|
||
if (typeof window !== 'undefined') {
|
||
window.MARKS_CONFIG = MARKS_CONFIG;
|
||
if (typeof window.onMarksConfigChanged === 'function') {
|
||
window.onMarksConfigChanged();
|
||
}
|
||
}
|
||
return MARKS_CONFIG;
|
||
}
|
||
|
||
if (typeof window !== 'undefined') {
|
||
window.DEFAULT_MARKS_CONFIG = cloneDefaultConfig();
|
||
window.MARKS_CONFIG = MARKS_CONFIG;
|
||
window.setMarksConfig = setMarksConfig;
|
||
}
|
||
|
||
if (typeof module !== 'undefined') {
|
||
module.exports = cloneDefaultConfig();
|
||
}
|