[PRISM] Комната: количества, доп. потребности из графа, RCH40 E2/VCH51/WPP, человеческие роли
This commit is contained in:
1 parent
e3b2cd6ac5
commit
037f1abbb4
5 files changed
+160
-48
No files matched your search
@@ -2694,11 +2694,11 @@ devices:
|
|||||||
aliases:
|
aliases:
|
||||||
- RCH40pRCH40 E2
|
- RCH40pRCH40 E2
|
||||||
- RCH40&RCH40 E2
|
- RCH40&RCH40 E2
|
||||||
domain: infra
|
domain: vcs
|
||||||
line: infrastructure.switch
|
line: infrastructure.switch
|
||||||
group: E_infra
|
group: E_infra
|
||||||
role: switch
|
role: sharing_hub
|
||||||
form_factor: switch
|
form_factor: accessory
|
||||||
native_vcs: false
|
native_vcs: false
|
||||||
protocols: []
|
protocols: []
|
||||||
protocols_status: unknown
|
protocols_status: unknown
|
||||||
@@ -2706,8 +2706,8 @@ devices:
|
|||||||
kind: catalog
|
kind: catalog
|
||||||
verified: false
|
verified: false
|
||||||
version: '2026-11-18'
|
version: '2026-11-18'
|
||||||
solution_class: infrastructure.network
|
solution_class: vcs.accessory
|
||||||
analog_group: infrastructure.network
|
analog_group: vcs.accessory
|
||||||
sales_scope: own
|
sales_scope: own
|
||||||
sip_context: none
|
sip_context: none
|
||||||
name: RCH40 E2
|
name: RCH40 E2
|
||||||
@@ -2717,11 +2717,11 @@ devices:
|
|||||||
model: RCH80
|
model: RCH80
|
||||||
aliases:
|
aliases:
|
||||||
- RCH80
|
- RCH80
|
||||||
domain: infra
|
domain: vcs
|
||||||
line: infrastructure.switch
|
line: infrastructure.switch
|
||||||
group: E_infra
|
group: E_infra
|
||||||
role: switch
|
role: sharing_hub
|
||||||
form_factor: switch
|
form_factor: accessory
|
||||||
native_vcs: false
|
native_vcs: false
|
||||||
protocols: []
|
protocols: []
|
||||||
protocols_status: unknown
|
protocols_status: unknown
|
||||||
@@ -2729,8 +2729,8 @@ devices:
|
|||||||
kind: catalog
|
kind: catalog
|
||||||
verified: false
|
verified: false
|
||||||
version: '2026-11-18'
|
version: '2026-11-18'
|
||||||
solution_class: infrastructure.network
|
solution_class: vcs.accessory
|
||||||
analog_group: infrastructure.network
|
analog_group: vcs.accessory
|
||||||
sales_scope: own
|
sales_scope: own
|
||||||
sip_context: none
|
sip_context: none
|
||||||
name: RCH80
|
name: RCH80
|
||||||
@@ -2740,11 +2740,11 @@ devices:
|
|||||||
model: RCH240
|
model: RCH240
|
||||||
aliases:
|
aliases:
|
||||||
- RCH240
|
- RCH240
|
||||||
domain: infra
|
domain: vcs
|
||||||
line: infrastructure.switch
|
line: infrastructure.switch
|
||||||
group: E_infra
|
group: E_infra
|
||||||
role: switch
|
role: sharing_hub
|
||||||
form_factor: switch
|
form_factor: accessory
|
||||||
native_vcs: false
|
native_vcs: false
|
||||||
protocols: []
|
protocols: []
|
||||||
protocols_status: unknown
|
protocols_status: unknown
|
||||||
@@ -2752,8 +2752,8 @@ devices:
|
|||||||
kind: catalog
|
kind: catalog
|
||||||
verified: false
|
verified: false
|
||||||
version: '2026-11-18'
|
version: '2026-11-18'
|
||||||
solution_class: infrastructure.network
|
solution_class: vcs.accessory
|
||||||
analog_group: infrastructure.network
|
analog_group: vcs.accessory
|
||||||
sales_scope: own
|
sales_scope: own
|
||||||
sip_context: none
|
sip_context: none
|
||||||
name: RCH240
|
name: RCH240
|
||||||
|
|||||||
@@ -2693,11 +2693,11 @@ devices:
|
|||||||
aliases:
|
aliases:
|
||||||
- RCH40pRCH40 E2
|
- RCH40pRCH40 E2
|
||||||
- RCH40&RCH40 E2
|
- RCH40&RCH40 E2
|
||||||
domain: infra
|
domain: vcs
|
||||||
line: infrastructure.switch
|
line: infrastructure.switch
|
||||||
group: E_infra
|
group: E_infra
|
||||||
role: switch
|
role: sharing_hub
|
||||||
form_factor: switch
|
form_factor: accessory
|
||||||
native_vcs: false
|
native_vcs: false
|
||||||
protocols: []
|
protocols: []
|
||||||
protocols_status: unknown
|
protocols_status: unknown
|
||||||
@@ -2705,8 +2705,8 @@ devices:
|
|||||||
kind: catalog
|
kind: catalog
|
||||||
verified: false
|
verified: false
|
||||||
version: '2026-11-18'
|
version: '2026-11-18'
|
||||||
solution_class: infrastructure.network
|
solution_class: vcs.accessory
|
||||||
analog_group: infrastructure.network
|
analog_group: vcs.accessory
|
||||||
sales_scope: own
|
sales_scope: own
|
||||||
sip_context: none
|
sip_context: none
|
||||||
name: RCH40 E2
|
name: RCH40 E2
|
||||||
@@ -2716,11 +2716,11 @@ devices:
|
|||||||
model: RCH80
|
model: RCH80
|
||||||
aliases:
|
aliases:
|
||||||
- RCH80
|
- RCH80
|
||||||
domain: infra
|
domain: vcs
|
||||||
line: infrastructure.switch
|
line: infrastructure.switch
|
||||||
group: E_infra
|
group: E_infra
|
||||||
role: switch
|
role: sharing_hub
|
||||||
form_factor: switch
|
form_factor: accessory
|
||||||
native_vcs: false
|
native_vcs: false
|
||||||
protocols: []
|
protocols: []
|
||||||
protocols_status: unknown
|
protocols_status: unknown
|
||||||
@@ -2728,8 +2728,8 @@ devices:
|
|||||||
kind: catalog
|
kind: catalog
|
||||||
verified: false
|
verified: false
|
||||||
version: '2026-11-18'
|
version: '2026-11-18'
|
||||||
solution_class: infrastructure.network
|
solution_class: vcs.accessory
|
||||||
analog_group: infrastructure.network
|
analog_group: vcs.accessory
|
||||||
sales_scope: own
|
sales_scope: own
|
||||||
sip_context: none
|
sip_context: none
|
||||||
name: RCH80
|
name: RCH80
|
||||||
@@ -2739,11 +2739,11 @@ devices:
|
|||||||
model: RCH240
|
model: RCH240
|
||||||
aliases:
|
aliases:
|
||||||
- RCH240
|
- RCH240
|
||||||
domain: infra
|
domain: vcs
|
||||||
line: infrastructure.switch
|
line: infrastructure.switch
|
||||||
group: E_infra
|
group: E_infra
|
||||||
role: switch
|
role: sharing_hub
|
||||||
form_factor: switch
|
form_factor: accessory
|
||||||
native_vcs: false
|
native_vcs: false
|
||||||
protocols: []
|
protocols: []
|
||||||
protocols_status: unknown
|
protocols_status: unknown
|
||||||
@@ -2751,8 +2751,8 @@ devices:
|
|||||||
kind: catalog
|
kind: catalog
|
||||||
verified: false
|
verified: false
|
||||||
version: '2026-11-18'
|
version: '2026-11-18'
|
||||||
solution_class: infrastructure.network
|
solution_class: vcs.accessory
|
||||||
analog_group: infrastructure.network
|
analog_group: vcs.accessory
|
||||||
sales_scope: own
|
sales_scope: own
|
||||||
sip_context: none
|
sip_context: none
|
||||||
name: RCH240
|
name: RCH240
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""RCH* — VCS-инфраструктура, а не unknown."""
|
||||||
|
import os
|
||||||
|
import yaml
|
||||||
|
|
||||||
|
paths = [
|
||||||
|
"/opt/work-hub/compat/catalog.yaml",
|
||||||
|
"/root/buryan-infra/ops/combine/catalog-p0-2026-11-18.yaml",
|
||||||
|
]
|
||||||
|
names = {"RCH40 E2", "RCH80", "RCH240"}
|
||||||
|
for p in paths:
|
||||||
|
if not os.path.exists(p):
|
||||||
|
continue
|
||||||
|
d = yaml.safe_load(open(p, encoding="utf-8"))
|
||||||
|
n = 0
|
||||||
|
for x in d.get("devices") or []:
|
||||||
|
if (x.get("name") or x.get("model")) in names:
|
||||||
|
x["domain"] = "vcs"
|
||||||
|
x["group"] = "E_infra"
|
||||||
|
x["line"] = "infrastructure.switch"
|
||||||
|
x["role"] = "sharing_hub"
|
||||||
|
x["solution_class"] = "vcs.accessory"
|
||||||
|
x["analog_group"] = "vcs.accessory"
|
||||||
|
x["form_factor"] = "accessory"
|
||||||
|
n += 1
|
||||||
|
yaml.safe_dump(d, open(p, "w", encoding="utf-8"), allow_unicode=True, sort_keys=False)
|
||||||
|
print(p, "fixed", n)
|
||||||
+58
-11
@@ -74,6 +74,9 @@ ROLE_LABELS = {
|
|||||||
"touch": "Панель", "display": "Дисплей", "mount": "Крепление",
|
"touch": "Панель", "display": "Дисплей", "mount": "Крепление",
|
||||||
"sharing_hub": "Презентация", "phone": "Телефон", "headset": "Гарнитура",
|
"sharing_hub": "Презентация", "phone": "Телефон", "headset": "Гарнитура",
|
||||||
"power": "Питание", "unknown": "Не разобрано", "accessory": "Аксессуар",
|
"power": "Питание", "unknown": "Не разобрано", "accessory": "Аксессуар",
|
||||||
|
"terminal": "Терминал / ПК", "infra": "Инфраструктура",
|
||||||
|
"sharing": "Презентация / BYOD", "mic": "Микрофоны", "panel": "Панель",
|
||||||
|
"extra": "Дополнительно",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1366,6 +1369,31 @@ def room_roles():
|
|||||||
]}
|
]}
|
||||||
|
|
||||||
|
|
||||||
|
def room_needs(host):
|
||||||
|
d = find_device(host)
|
||||||
|
if not d:
|
||||||
|
return {"error": "not_found", "host": host}
|
||||||
|
groups = []
|
||||||
|
if norm(_dev_name(d)) in D.devices:
|
||||||
|
try:
|
||||||
|
groups = D.groups(_dev_name(d), []).get("groups") or []
|
||||||
|
except Exception:
|
||||||
|
groups = []
|
||||||
|
# дополнительные BYOD/презентационные аксессуары, если их нет в графе
|
||||||
|
if not any(g.get("id") == "sharing" for g in groups):
|
||||||
|
sharing = []
|
||||||
|
for x in D.analog_devices:
|
||||||
|
if x.get("vendor") != d.get("vendor") or x.get("domain") != "vcs":
|
||||||
|
continue
|
||||||
|
if x.get("solution_class") == "vcs.sharing":
|
||||||
|
sharing.append({"model": _dev_name(x), "role": x.get("role") or "sharing_hub",
|
||||||
|
"max_qty": 1, "condition": "проверить совместимость"})
|
||||||
|
if sharing:
|
||||||
|
groups.append({"id": "sharing", "name": "Презентация / BYOD", "items": sharing[:10]})
|
||||||
|
return {"host": _dev_name(d), "vendor": d.get("vendor"),
|
||||||
|
"archived": is_archived(d), "groups": groups}
|
||||||
|
|
||||||
|
|
||||||
def compose_room(payload):
|
def compose_room(payload):
|
||||||
seats = int(payload.get("seats") or 8)
|
seats = int(payload.get("seats") or 8)
|
||||||
roles = payload.get("roles") or {}
|
roles = payload.get("roles") or {}
|
||||||
@@ -1375,30 +1403,46 @@ def compose_room(payload):
|
|||||||
expected = {"terminal": ("codec", "pc", "kit"), "camera": ("camera",),
|
expected = {"terminal": ("codec", "pc", "kit"), "camera": ("camera",),
|
||||||
"audio": ("audio", "speaker"), "touch": ("touch",),
|
"audio": ("audio", "speaker"), "touch": ("touch",),
|
||||||
"display": ("display",), "mount": ("mount",)}
|
"display": ("display",), "mount": ("mount",)}
|
||||||
items, warnings, seen = [], [], set()
|
items, warnings, seen = [], [], {}
|
||||||
for rid, model in roles.items():
|
|
||||||
|
def add_item(rid, model, qty=1):
|
||||||
if not model:
|
if not model:
|
||||||
continue
|
return
|
||||||
|
try:
|
||||||
|
qty = max(1, min(99, int(qty or 1)))
|
||||||
|
except Exception:
|
||||||
|
qty = 1
|
||||||
d = find_device(model)
|
d = find_device(model)
|
||||||
if not d:
|
if not d:
|
||||||
warnings.append({"level": "warning", "text": "не найдено: %s" % model})
|
warnings.append({"level": "warning", "text": "не найдено: %s" % model})
|
||||||
continue
|
return
|
||||||
if d.get("domain") != "vcs":
|
if d.get("domain") != "vcs":
|
||||||
warnings.append({"level": "blocker", "text": "%s не из VCS — нельзя в комнату" % _dev_name(d)})
|
warnings.append({"level": "blocker", "text": "%s не из VCS — нельзя в комнату" % _dev_name(d)})
|
||||||
continue
|
return
|
||||||
if rid in expected and d.get("role") not in expected[rid]:
|
if rid in expected and d.get("role") not in expected[rid]:
|
||||||
warnings.append({"level": "warning", "text": "%s не подходит на роль %s" % (_dev_name(d), rid)})
|
warnings.append({"level": "warning", "text": "%s не подходит на роль %s" % (_dev_name(d), rid)})
|
||||||
k = _key(d)
|
k = _key(d)
|
||||||
if k in seen:
|
if k in seen:
|
||||||
continue
|
seen[k]["qty"] += qty
|
||||||
seen.add(k)
|
return
|
||||||
items.append({"role": rid, "key": k, "name": _dev_name(d), "vendor": d.get("vendor"),
|
item = {"role": rid, "key": k, "name": _dev_name(d), "vendor": d.get("vendor"),
|
||||||
"solution_class": d.get("solution_class"), "class_label": class_label(d.get("solution_class")),
|
"solution_class": d.get("solution_class"), "class_label": class_label(d.get("solution_class")),
|
||||||
"role_label": role_label(rid), "form_factor": d.get("form_factor"),
|
"role_label": role_label(rid), "form_factor": d.get("form_factor"),
|
||||||
"archived": is_archived(d), "purchasable": not is_archived(d)})
|
"qty": qty, "archived": is_archived(d), "purchasable": not is_archived(d)}
|
||||||
|
seen[k] = item
|
||||||
|
items.append(item)
|
||||||
if is_archived(d):
|
if is_archived(d):
|
||||||
warnings.append({"level": "warning",
|
warnings.append({"level": "warning",
|
||||||
"text": "%s снято с продажи — в проект можно, купить нельзя" % _dev_name(d)})
|
"text": "%s снято с продажи — в проект можно, купить нельзя" % _dev_name(d)})
|
||||||
|
|
||||||
|
for rid, val in roles.items():
|
||||||
|
if isinstance(val, dict):
|
||||||
|
add_item(rid, val.get("model"), val.get("qty") or 1)
|
||||||
|
else:
|
||||||
|
add_item(rid, val, 1)
|
||||||
|
for e in (payload.get("extras") or []):
|
||||||
|
if isinstance(e, dict):
|
||||||
|
add_item(e.get("role") or "extra", e.get("model"), e.get("qty") or 1)
|
||||||
terminal = next((x for x in items if x["role"] == "terminal"), None)
|
terminal = next((x for x in items if x["role"] == "terminal"), None)
|
||||||
if not terminal:
|
if not terminal:
|
||||||
warnings.append({"level": "blocker", "text": "нет терминала/ПК"})
|
warnings.append({"level": "blocker", "text": "нет терминала/ПК"})
|
||||||
@@ -1420,6 +1464,7 @@ def compose_room(payload):
|
|||||||
if d and (d.get("role") == "pc" or d.get("solution_class") == "vcs.byod.kit" or d.get("deployment") == "byod"):
|
if d and (d.get("role") == "pc" or d.get("solution_class") == "vcs.byod.kit" or d.get("deployment") == "byod"):
|
||||||
deployment = "byod"
|
deployment = "byod"
|
||||||
return {"seats": seats, "vendor": vendor, "deployment": deployment, "items": items,
|
return {"seats": seats, "vendor": vendor, "deployment": deployment, "items": items,
|
||||||
|
"total_qty": sum(x.get("qty", 1) for x in items),
|
||||||
"purchasable": all(x.get("purchasable", True) for x in items),
|
"purchasable": all(x.get("purchasable", True) for x in items),
|
||||||
"warnings": warnings, "ready": not any(w["level"] == "blocker" for w in warnings),
|
"warnings": warnings, "ready": not any(w["level"] == "blocker" for w in warnings),
|
||||||
"note": "Вендор — жёсткая граница: аксессуары и компоненты только этого вендора. Порты — в классическом конструкторе."}
|
"note": "Вендор — жёсткая граница: аксессуары и компоненты только этого вендора. Порты — в классическом конструкторе."}
|
||||||
@@ -1525,6 +1570,8 @@ class H(BaseHTTPRequestHandler):
|
|||||||
return self._out({"items": archived_items()})
|
return self._out({"items": archived_items()})
|
||||||
if p == "/api/room-roles":
|
if p == "/api/room-roles":
|
||||||
return self._out(room_roles())
|
return self._out(room_roles())
|
||||||
|
if p == "/api/room-needs":
|
||||||
|
return self._out(room_needs(q.get("host", [""])[0]))
|
||||||
if p == "/api/hosts":
|
if p == "/api/hosts":
|
||||||
return self._out(D.hosts())
|
return self._out(D.hosts())
|
||||||
if p == "/api/requirements":
|
if p == "/api/requirements":
|
||||||
|
|||||||
@@ -85,6 +85,8 @@ main{max-width:1560px;margin:0 auto;padding:22px 26px 70px}.view{display:none}.v
|
|||||||
<div class="muted">Роли, а не SKU. Вендор — жёсткая граница: аксессуары другого вендора не подходят.</div>
|
<div class="muted">Роли, а не SKU. Вендор — жёсткая граница: аксессуары другого вендора не подходят.</div>
|
||||||
<div class="bar" style="margin-top:10px"><label class="tiny">Вендор <select id="roomVendor" onchange="setRoomVendor(this.value)"></select></label><label class="tiny">Мест <input id="seats" type="number" value="8" min="2" max="40" style="width:80px"></label><button class="btn" onclick="runRoom()">Проверить и BOM</button></div>
|
<div class="bar" style="margin-top:10px"><label class="tiny">Вендор <select id="roomVendor" onchange="setRoomVendor(this.value)"></select></label><label class="tiny">Мест <input id="seats" type="number" value="8" min="2" max="40" style="width:80px"></label><button class="btn" onclick="runRoom()">Проверить и BOM</button></div>
|
||||||
<div class="roomgrid" id="roomgrid"></div>
|
<div class="roomgrid" id="roomgrid"></div>
|
||||||
|
<div id="roomneeds" style="margin-top:14px"></div>
|
||||||
|
<div id="extraslist" style="margin-top:10px"></div>
|
||||||
<div class="hint">BYOD: ПК + камера. Native: кодеки/бары с интегрированным терминалом. Порты проверяются в классическом конструкторе.</div>
|
<div class="hint">BYOD: ПК + камера. Native: кодеки/бары с интегрированным терминалом. Порты проверяются в классическом конструкторе.</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="roomout" style="margin-top:14px"></div>
|
<div id="roomout" style="margin-top:14px"></div>
|
||||||
@@ -110,10 +112,10 @@ main{max-width:1560px;margin:0 auto;padding:22px 26px 70px}.view{display:none}.v
|
|||||||
</section>
|
</section>
|
||||||
</main>
|
</main>
|
||||||
<script>
|
<script>
|
||||||
const S = {q:'', vendor:'all', domain:'vcs', cls:'', protocol:'', feature:false, data:null, product:null, roomOpts:{}, room:{}, roomVendor:'' };
|
const S = {q:'', vendor:'all', domain:'vcs', cls:'', protocol:'', feature:false, data:null, product:null, roomOpts:{}, room:{}, roomQty:{}, roomVendor:'', extras:[] };
|
||||||
const DL={vcs:'ВКС',telephony:'Телефония',pro_av:'PRO AV',infrastructure:'Инфраструктура',passive:'Пассив',software:'Софт',unknown:'Не разобрано'};
|
const DL={vcs:'ВКС',telephony:'Телефония',pro_av:'PRO AV',infrastructure:'Инфраструктура',passive:'Пассив',software:'Софт',unknown:'Не разобрано'};
|
||||||
const CL={'vcs.bar.compact':'Компакт-бар','vcs.bar.room':'Видеобар для переговорной','vcs.board':'Интерактивная панель','vcs.terminal.room':'Терминал / кодек','vcs.terminal.pc':'ПК-терминал','vcs.byod.kit':'BYOD-комплект','vcs.kit.room':'Комплект ВКС','vcs.camera.usb':'USB-камера','vcs.camera.ptz':'PTZ-камера','vcs.audio':'Аудио / микрофоны','vcs.control.touch':'Панель управления','vcs.sharing':'Презентация / BYOD','vcs.accessory':'Аксессуар','vcs.other':'Прочее','telephony.sip.desk':'SIP-телефон','telephony.sip.conference':'Конференц-телефон','telephony.dect':'DECT-телефон','telephony.headset':'Гарнитура','telephony.accessory':'Аксессуар телефонии','passive.display':'Дисплей','passive.mount':'Крепление','passive.power':'Питание','infrastructure.network':'Сеть / инфраструктура'};
|
const CL={'vcs.bar.compact':'Компакт-бар','vcs.bar.room':'Видеобар для переговорной','vcs.board':'Интерактивная панель','vcs.terminal.room':'Терминал / кодек','vcs.terminal.pc':'ПК-терминал','vcs.byod.kit':'BYOD-комплект','vcs.kit.room':'Комплект ВКС','vcs.camera.usb':'USB-камера','vcs.camera.ptz':'PTZ-камера','vcs.audio':'Аудио / микрофоны','vcs.control.touch':'Панель управления','vcs.sharing':'Презентация / BYOD','vcs.accessory':'Аксессуар','vcs.other':'Прочее','telephony.sip.desk':'SIP-телефон','telephony.sip.conference':'Конференц-телефон','telephony.dect':'DECT-телефон','telephony.headset':'Гарнитура','telephony.accessory':'Аксессуар телефонии','passive.display':'Дисплей','passive.mount':'Крепление','passive.power':'Питание','infrastructure.network':'Сеть / инфраструктура'};
|
||||||
const RL={codec:'Кодек / терминал',pc:'ПК',kit:'Комплект',camera:'Камера',audio:'Аудио',speaker:'Спикер',touch:'Панель',display:'Дисплей',mount:'Крепление',sharing_hub:'Презентация',phone:'Телефон',headset:'Гарнитура',power:'Питание',unknown:'Не разобрано',accessory:'Аксессуар'};
|
const RL={codec:'Кодек / терминал',pc:'ПК',kit:'Комплект',camera:'Камера',audio:'Аудио',speaker:'Спикер',touch:'Панель',display:'Дисплей',mount:'Крепление',sharing_hub:'Презентация',phone:'Телефон',headset:'Гарнитура',power:'Питание',unknown:'Не разобрано',accessory:'Аксессуар',terminal:'Терминал / ПК',infra:'Инфраструктура',sharing:'Презентация / BYOD',mic:'Микрофоны',panel:'Панель',extra:'Дополнительно'};
|
||||||
const TG={desk_phone:'SIP-телефон',conference:'Конференц-телефон',conference_phone:'Конференц-телефон',dect:'DECT-телефон',dect_phone:'DECT-телефон',headset:'Гарнитура',wireless_headset:'Гарнитура',accessory:'Аксессуар',video_phone:'Видеотелефон'};
|
const TG={desk_phone:'SIP-телефон',conference:'Конференц-телефон',conference_phone:'Конференц-телефон',dect:'DECT-телефон',dect_phone:'DECT-телефон',headset:'Гарнитура',wireless_headset:'Гарнитура',accessory:'Аксессуар',video_phone:'Видеотелефон'};
|
||||||
const dl=v=>DL[v]||v||'—', cl=v=>CL[v]||String(v||'—').replace(/\./g,' · ').replace(/_/g,' '), rl=v=>RL[v]||v||'—';
|
const dl=v=>DL[v]||v||'—', cl=v=>CL[v]||String(v||'—').replace(/\./g,' · ').replace(/_/g,' '), rl=v=>RL[v]||v||'—';
|
||||||
const $ = s => document.querySelector(s);
|
const $ = s => document.querySelector(s);
|
||||||
@@ -280,16 +282,52 @@ async function loadRoomOptions(){
|
|||||||
cache[role.id]=arr;
|
cache[role.id]=arr;
|
||||||
}
|
}
|
||||||
S.roomOpts=cache;
|
S.roomOpts=cache;
|
||||||
$('#roomgrid').innerHTML = roles.map(role=>`<div><label>${esc(role.name)}</label><select id="room-${role.id}" onchange="S.room['${role.id}']=this.value"><option value="">— не выбрано —</option>${(cache[role.id]||[]).map(x=>`<option value="${esc(x.name)}" ${S.room[role.id]===x.name?'selected':''}>${esc(x.vendor)} · ${esc(x.name)}</option>`).join('')}</select></div>`).join('');
|
$('#roomgrid').innerHTML = roles.map(role=>`<div><label>${esc(role.name)}</label><div style="display:flex;gap:6px">
|
||||||
|
<select id="room-${role.id}" onchange="S.room['${role.id}']=this.value;${role.id==='terminal'?'roomTerminalChanged()':''}"><option value="">— не выбрано —</option>${(cache[role.id]||[]).map(x=>`<option value="${esc(x.name)}" ${S.room[role.id]===x.name?'selected':''}>${esc(x.vendor)} · ${esc(x.name)}</option>`).join('')}</select>
|
||||||
|
<input id="qty-${role.id}" type="number" min="1" max="99" value="${S.roomQty[role.id]||1}" title="Количество" style="width:64px" onchange="S.roomQty['${role.id}']=+this.value">
|
||||||
|
</div></div>`).join('');
|
||||||
|
if(S.room.terminal) roomTerminalChanged();
|
||||||
|
}
|
||||||
|
async function roomTerminalChanged(){
|
||||||
|
const host=S.room.terminal;
|
||||||
|
if(!host){$('#roomneeds').innerHTML='';return;}
|
||||||
|
const r=await api('/api/room-needs?host='+encodeURIComponent(host));
|
||||||
|
if(r.error){$('#roomneeds').innerHTML='<div class="muted">для этой модели нет графа потребностей</div>';return;}
|
||||||
|
S.extras=[];
|
||||||
|
const groups=(r.groups||[]).filter(g=>(g.items||[]).length);
|
||||||
|
let h='<div class="card"><h3>Дополнительные потребности</h3><div class="muted tiny">Подсказки из графа совместимости. Количество и состав проверяются вручную.</div>';
|
||||||
|
h+=groups.map(g=>`<div style="margin-top:9px"><b class="tiny">${esc(g.name)}</b>
|
||||||
|
<div style="display:flex;gap:6px;margin-top:4px">
|
||||||
|
<select id="need-${g.id}" style="flex:1">${g.items.map(i=>`<option value="${esc(i.model)}">${esc(i.model)}${i.max_qty?' · до '+i.max_qty:''}</option>`).join('')}</select>
|
||||||
|
<input id="needq-${g.id}" type="number" min="1" max="99" value="1" style="width:58px">
|
||||||
|
<button class="btn sm" onclick="addExtra('${g.id}','${esc(g.name)}')">+</button>
|
||||||
|
</div></div>`).join('');
|
||||||
|
h+='</div>';
|
||||||
|
$('#roomneeds').innerHTML=h;
|
||||||
|
renderExtras();
|
||||||
|
}
|
||||||
|
function addExtra(gid,gname){
|
||||||
|
const sel=$('#need-'+gid), qty=$('#needq-'+gid);
|
||||||
|
if(!sel||!sel.value)return;
|
||||||
|
const n=Math.max(1,Math.min(99,+qty.value||1));
|
||||||
|
const found=S.extras.find(x=>x.model===sel.value);
|
||||||
|
if(found)found.qty+=n; else S.extras.push({role:gid,group:gname,model:sel.value,qty:n});
|
||||||
|
renderExtras();
|
||||||
|
}
|
||||||
|
function renderExtras(){
|
||||||
|
if(!S.extras.length){$('#extraslist').innerHTML='';return;}
|
||||||
|
$('#extraslist').innerHTML=`<div class="card"><h3>Добавлено дополнительно</h3><table class="bom"><thead><tr><th>Группа</th><th>Модель</th><th>Кол-во</th><th></th></tr></thead><tbody>
|
||||||
|
${S.extras.map((x,i)=>`<tr><td class="muted">${esc(x.group)}</td><td>${esc(x.model)}</td><td><input type="number" min="1" max="99" value="${x.qty}" style="width:58px" onchange="S.extras[${i}].qty=+this.value"></td><td><button class="btn ghost sm" onclick="S.extras.splice(${i},1);renderExtras()">✕</button></td></tr>`).join('')}
|
||||||
|
</tbody></table></div>`;
|
||||||
}
|
}
|
||||||
async function runRoom(){
|
async function runRoom(){
|
||||||
if(!S.roomVendor){alert('Выберите вендора комнаты');return;}
|
if(!S.roomVendor){alert('Выберите вендора комнаты');return;}
|
||||||
const roles={}; for(const k of ['terminal','camera','audio','touch','display','mount']){const el=$('#room-'+k); if(el&&el.value)roles[k]=el.value;}
|
const roles={}; for(const k of ['terminal','camera','audio','touch','display','mount']){const el=$('#room-'+k); if(el&&el.value)roles[k]={model:el.value,qty:S.roomQty[k]||1};}
|
||||||
const r = await post('/api/room',{seats:+$('#seats').value,vendor:S.roomVendor,roles});
|
const r = await post('/api/room',{seats:+$('#seats').value,vendor:S.roomVendor,roles,extras:S.extras});
|
||||||
const bom=(r.items||[]).map(x=>`<tr><td>${esc(x.role_label||rl(x.role))}</td><td><b>${esc(x.name)}</b>${x.archived?' <span class="badge-archive">снято</span>':''}</td><td>${esc(x.vendor)}</td><td>${esc(cl(x.solution_class))}</td></tr>`).join('');
|
const bom=(r.items||[]).map(x=>`<tr><td>${esc(x.role_label||rl(x.role))}</td><td><b>${esc(x.name)}</b>${x.archived?' <span class="badge-archive">снято</span>':''}</td><td>${esc(x.vendor)}</td><td>${esc(cl(x.solution_class))}</td><td>${x.qty||1}</td></tr>`).join('');
|
||||||
$('#roomout').innerHTML = `<div class="card"><h3>${r.ready?'✅ Компоновка валидна':'⚠ Требует внимания'} · ${esc(r.deployment)} · ${esc(r.vendor||'')}${r.purchasable===false?' · <span style="color:#e0b341">есть снятое, купить нельзя</span>':''}</h3>
|
$('#roomout').innerHTML = `<div class="card"><h3>${r.ready?'✅ Компоновка валидна':'⚠ Требует внимания'} · ${esc(r.deployment)} · ${esc(r.vendor||'')}${r.purchasable===false?' · <span style="color:#e0b341">есть снятое, купить нельзя</span>':''}</h3>
|
||||||
${(r.warnings||[]).map(w=>`<div class="warn ${w.level==='blocker'?'bad':''}">${esc(w.text)}</div>`).join('')}
|
${(r.warnings||[]).map(w=>`<div class="warn ${w.level==='blocker'?'bad':''}">${esc(w.text)}</div>`).join('')}
|
||||||
<table class="bom"><thead><tr><th>Роль</th><th>Модель</th><th>Вендор</th><th>Класс</th></tr></thead><tbody>${bom||'<tr><td colspan=4 class="muted">пусто</td></tr>'}</tbody></table>
|
<table class="bom"><thead><tr><th>Роль</th><th>Модель</th><th>Вендор</th><th>Класс</th><th>Кол-во</th></tr></thead><tbody>${bom||'<tr><td colspan=5 class="muted">пусто</td></tr>'}</tbody></table>
|
||||||
<div class="hint">${esc(r.note||'')}</div></div>`;
|
<div class="hint">${esc(r.note||'')}</div></div>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user