|
|
@@ -683,7 +683,8 @@ function visibleTickets() {
|
|
|
if (u.role === "teamLead") return t.team === teamOfUser(u);
|
|
|
if (isTeamManager(u)) return t.team === teamOfUser(u) && t.assignee === u.member;
|
|
|
if (u.role === "enterprise") return t.enterprise === u.enterprise;
|
|
|
- if (u.role === "sub") return t.enterprise === u.enterprise && t.account === u.account;
|
|
|
+ /* ✅ 2026-11-05:分账号可见本公司全部(customer_id 匹配),报障人判定在 ticketSubmittedBy 里 */
|
|
|
+ if (u.role === "sub") return t.enterprise === u.enterprise;
|
|
|
return false;
|
|
|
});
|
|
|
}
|
|
|
@@ -959,16 +960,18 @@ function autoCloseStaleTickets() {
|
|
|
t.logs.push(`${on} 系统自动闭环:提交方自完成日起 ${CONFIRM_CLOSE_DAYS} 个自然日内未确认关闭`);
|
|
|
});
|
|
|
}
|
|
|
-/* 运维代建/系统自动的单(submitter ∈ {运维代建, 系统自动})没有客户侧确认入口:这类非主线工单由运维
|
|
|
- 标记已完成的当天即同事务转「已闭环」,不停在「已完成」等确认(F1 定案 ④)。客户主账号/下属分账号
|
|
|
- 提交的单仍走提交方确认关闭或超时自动闭环。由「标记已完成」在同一事务内调用,返回是否已当场闭环。 */
|
|
|
+/* ✅ 2026-11-05 改判:只有"系统自动"和"联通侧"的非主线工单在 mark_done 同事务当场闭环
|
|
|
+ (无确定报障人,没人点确认);"运维报障"、"运维代客报障"、"客户主账号报障"、"下属分账号报障"
|
|
|
+ 都有确定的 reporter_account_id,都进等待确认态 + AUTO-CLOSE 超时扫描 */
|
|
|
function closeTicketOnDoneWithoutSubmitter(t) {
|
|
|
if (!t || t.status !== "已完成" || needClosure(t)) return false;
|
|
|
const who = submitterOf(t);
|
|
|
- if (who === "客户主账号" || who === "下属分账号") return false;
|
|
|
- t.status = "已闭环";
|
|
|
- t.logs.push(`${TODAY} ${user() ? user().name : "运维"}:提交方为${who},本单无客户侧确认环节,标记已完成即同事务闭环`);
|
|
|
- return true;
|
|
|
+ if (who === "系统自动" || who === "联通侧") {
|
|
|
+ t.status = "已闭环";
|
|
|
+ t.logs.push(`${TODAY} ${user() ? user().name : "运维"}:${who}工单已完成,无报障人需确认,标记已完成即同事务闭环`);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
}
|
|
|
/* 未完成三态:待派单(还没有责任人)/ 待处理(已分派、责任人尚未打开详情或做任何修改)/ 处理中(责任人已阅读或已修改)
|
|
|
已完成、已闭环、已关闭都是终态。
|
|
|
@@ -1275,24 +1278,46 @@ const STOP_TYPE = "服务停用";
|
|
|
/* 停机类工单:到期停机与服务停用同口径(带开停记录、停机回填从简、成功整户改停用) */
|
|
|
function isStopTicket(t) { return !!t && (t.type === "到期停机" || t.type === STOP_TYPE); }
|
|
|
|
|
|
-/* 建单。source 是运维代客建单的来源渠道,普通报障不传 */
|
|
|
-function submitTicket(enterpriseIndex, accountIndex, type, text, source, materials) {
|
|
|
+/* 建单。reporterAccount 是代报障场景传入的被代报账号(分账号索引);不传或 null 时
|
|
|
+ 后台自动填入当前登录人的账号:运维登录=运维索引,客户主账号=enterprise索引,分账号=account索引
|
|
|
+ source 是运维代客建单的来源渠道,普通报障不传 */
|
|
|
+function submitTicket(enterpriseIndex, reporterAccount, type, text, source, materials) {
|
|
|
const ent = db.enterprises[enterpriseIndex];
|
|
|
- const team = ticketTeamFor(db, ent, type);
|
|
|
+ const u = user();
|
|
|
const docs = materials || [];
|
|
|
- const by = source
|
|
|
- ? `运维人员${user().name}代建(来源:${source})`
|
|
|
- : `${accountIndex === null ? "客户主账号" : "下属分账号"}在系统内提交(${docs.length ? `文字与 ${docs.length} 份材料` : "文字"})`;
|
|
|
+ /* ✅ 2026-11-05 定案:reporter_account_id NOT NULL + 后台自动填充 */
|
|
|
+ let reporterId = reporterAccount;
|
|
|
+ if (reporterId === null || reporterId === undefined) {
|
|
|
+ if (u.role === "ops") reporterId = { kind: "ops", id: db.members.indexOf(u) }; // 运维自报
|
|
|
+ else if (u.role === "enterprise") reporterId = { kind: "enterprise", id: enterpriseIndex }; // 主账号自报
|
|
|
+ else reporterId = { kind: "sub", id: u.account }; // 分账号自报
|
|
|
+ }
|
|
|
+ /* submitter_type 四值,不再存展示值 */
|
|
|
+ let submitterType;
|
|
|
+ if (source) submitterType = "ops"; // 运维代建
|
|
|
+ else if (u.role === "ops") submitterType = "ops";
|
|
|
+ else submitterType = "customer";
|
|
|
+ const reporterLabel = reporterId.kind === "sub"
|
|
|
+ ? `下属分账号${db.subAccounts[reporterId.id]?.name || ""}`
|
|
|
+ : reporterId.kind === "enterprise"
|
|
|
+ ? "客户主账号"
|
|
|
+ : `运维${db.members[reporterId.id]?.name || ""}`;
|
|
|
+ const submitterLabel = source
|
|
|
+ ? `运维人员${u.name}代建(来源:${source})`
|
|
|
+ : reporterLabel;
|
|
|
const mainline = type === "开户" || isStopTicket({ type });
|
|
|
const liveSub = db.subs.find((x) => x.enterprise === enterpriseIndex && x.status === "生效中");
|
|
|
const ticket = {
|
|
|
no: nextTicketNo(), contractNo: mainline && liveSub ? liveSub.contractNo : null,
|
|
|
- type, enterprise: enterpriseIndex, account: accountIndex, team, assignee: null,
|
|
|
- status: "待派单", created: TODAY, doneOn: null, text, logs: [`${TODAY} ${by}`],
|
|
|
+ type, enterprise: enterpriseIndex,
|
|
|
+ /* ✅ 2026-11-05 改名:account → reporter */
|
|
|
+ reporter: reporterId,
|
|
|
+ submitter_type: submitterType,
|
|
|
+ team, assignee: null,
|
|
|
+ status: "待派单", created: TODAY, doneOn: null, text, logs: [`${TODAY} ${submitterLabel}提交`],
|
|
|
/* 客户上传的补充材料只记文档名与体积(正式实现按 `material_grant` 直传后登记 `ticket_material`,
|
|
|
对象存储全键留在后台);⛔ 客户侧工单详情不回显这份清单 */
|
|
|
closeReason: null, materials: docs.map((m) => `客户上传:${m.name}${m.size ? ` · ${docSize(m.size)}` : ""}`),
|
|
|
- submitter: source ? "运维代建" : accountIndex === null ? "客户主账号" : "下属分账号",
|
|
|
};
|
|
|
db.tickets.push(ticket);
|
|
|
const idx = db.tickets.length - 1;
|
|
|
@@ -1307,23 +1332,71 @@ function submitTicket(enterpriseIndex, accountIndex, type, text, source, materia
|
|
|
say(db.teams[team].mode === "手工" ? `工单已到${db.teams[team].name},等待主账号分派` : "工单已自动分派");
|
|
|
}
|
|
|
|
|
|
-/* ---- 提交方对自家工单的两类关闭 ---- */
|
|
|
+/* ---- 报障人对自家工单的两类关闭(撤回 + 闭环确认)---- */
|
|
|
|
|
|
-/* 提交方是谁:工单上的 submitter 是建单时写死的口径。历史数据没有这个字段时按类型与报障账号推:
|
|
|
- 系统自动带出的开停与服务开通类不算客户提交,其余按报障账号落在主账号还是分账号上 */
|
|
|
-function submitterOf(t) {
|
|
|
- if (t.submitter) return t.submitter;
|
|
|
- if (t.type === "开户" || isStopTicket(t) || isSvcTicket(t)) return "系统自动";
|
|
|
- return t.account === null || t.account === undefined ? "客户主账号" : "下属分账号";
|
|
|
+/* ✅ 2026-11-05:reporter 标签——从 reporter.kind/id 派生显示名 */
|
|
|
+function reporterLabel(t) {
|
|
|
+ const r = t.reporter;
|
|
|
+ if (!r) return "";
|
|
|
+ if (r.kind === "sub") { const s = db.subAccounts[r.id]; return s ? s.name : ""; }
|
|
|
+ if (r.kind === "enterprise") return "主账号";
|
|
|
+ if (r.kind === "ops") { const m = db.members[r.id]; return m ? m.name : ""; }
|
|
|
+ return "";
|
|
|
+}
|
|
|
+
|
|
|
+/* ✅ 2026-11-05:主账号可选代某分账号报障——构造"报障账号"下拉 HTML
|
|
|
+ 仅主账号登录 + 类型=故障时显示;选项 = 在用分账号 + "我自己(主账号)"作缺省 */
|
|
|
+function reporterSelectHtml(enterpriseIndex) {
|
|
|
+ const subs = db.subAccounts
|
|
|
+ .map((s, i) => ({ s, i }))
|
|
|
+ .filter(({ s }) => s.enterprise === enterpriseIndex && s.status !== "已停用" && s.status !== "已删除");
|
|
|
+ const opts = [`<option value="__self__">我自己(主账号)</option>`];
|
|
|
+ subs.forEach(({ s, i }) => {
|
|
|
+ opts.push(`<option value="${i}">${esc(s.name)}${s.title ? `(${esc(s.title)})` : ""}</option>`);
|
|
|
+ });
|
|
|
+ return `<label>报障账号${qTip(`选择"我自己(主账号)"表示以主账号身份报障;选择某分账号表示代其报障——工单列表与详情的类型标注会显示"故障 · 张敏"这类后缀,撤回与闭环确认权限归被代报的分账号本人或其主账号上级。<br><br>留空默认=我自己(主账号),不选就是以主账号身份报障。`, true)}(可选)</label>
|
|
|
+ <select id="reporterAcct">${opts.join("")}</select>`;
|
|
|
}
|
|
|
|
|
|
-/* 是不是本人提交的工单:客户主账号看主账号口径的自建单,
|
|
|
- 下属分账号只看报障账号是自己的那几张。运维代客建的单提交方是运维,客户不撤回也不确认闭环 */
|
|
|
+/* ✅ 2026-11-05 重写:提交方展示值由 submitter_type + reporter 联合派生(6 个展示值)
|
|
|
+ 不再靠 account === null 来区分 */
|
|
|
+function submitterOf(t) {
|
|
|
+ const st = t.submitter_type;
|
|
|
+ const r = t.reporter;
|
|
|
+ /* 系统/联通直接返回 */
|
|
|
+ if (st === "system") return "系统自动";
|
|
|
+ if (st === "unicom") return "联通侧";
|
|
|
+ /* 运维侧:看 reporter 是不是运维(运维自报)还是客户侧账号(代客报障) */
|
|
|
+ if (st === "ops") {
|
|
|
+ if (r?.kind === "ops") return "运维报障";
|
|
|
+ return "运维代客报障";
|
|
|
+ }
|
|
|
+ /* 客户侧:看 reporter 的 kind */
|
|
|
+ if (r?.kind === "enterprise") return "客户主账号报障";
|
|
|
+ if (r?.kind === "sub") return "下属分账号报障";
|
|
|
+ /* 兜底:历史数据缺 reporter */
|
|
|
+ return "未记录";
|
|
|
+}
|
|
|
+
|
|
|
+/* ✅ 2026-11-05 重写:简化为一段谓词
|
|
|
+ 报障人本人(reporter_account_id 匹配当前登录账号)OR reporter 的主账号上级 */
|
|
|
function ticketSubmittedBy(t, u) {
|
|
|
- if (!t || t.enterprise !== u.enterprise) return false;
|
|
|
- const s = submitterOf(t);
|
|
|
- if (u.role === "enterprise") return s === "客户主账号";
|
|
|
- if (u.role === "sub") return s === "下属分账号" && t.account === u.account;
|
|
|
+ if (!t) return false;
|
|
|
+ /* 系统/联通的单:客户侧无报障人入口 */
|
|
|
+ if (t.submitter_type === "system" || t.submitter_type === "unicom") return false;
|
|
|
+ const r = t.reporter;
|
|
|
+ if (!r) return false; /* 历史数据缺 reporter → 入口不出现 */
|
|
|
+ /* reporter 就是当前登录人本人 */
|
|
|
+ if (r.kind === u.role) {
|
|
|
+ if (r.kind === "sub" && r.id === u.account) return true;
|
|
|
+ if (r.kind === "enterprise" && r.id === u.enterprise) return true;
|
|
|
+ if (r.kind === "ops" && r.id === db.members.indexOf(u)) return true;
|
|
|
+ }
|
|
|
+ /* reporter 是分账号,当前人是该分账号所属企业的主账号上级 */
|
|
|
+ if (r.kind === "sub" && u.role === "enterprise") {
|
|
|
+ const sub = db.subAccounts[r.id];
|
|
|
+ if (sub && sub.enterprise === u.enterprise) return true;
|
|
|
+ }
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
@@ -1851,7 +1924,7 @@ function ticketTable(list, assignable, startAt) {
|
|
|
return `<tr class="clickable" data-go="ticket" data-id="${t.i}">
|
|
|
<td>${no}</td>
|
|
|
<td>${t.no ? esc(t.no) : `第 ${seq(t.i)} 号`}</td>
|
|
|
- <td>${esc(t.type)}${t.account !== undefined && t.account !== null ? " · " + esc(db.accounts[t.account].name) : ""}</td>
|
|
|
+ <td>${esc(t.type)}${reporterLabel(t) ? " · " + esc(reporterLabel(t)) : ""}</td>
|
|
|
${hideEnt ? "" : `<td>${esc(entName(t.enterprise))}</td>`}
|
|
|
<td>${esc(teamName(t.team))}</td>
|
|
|
<td>${esc(memberName(t.assignee))}</td>
|
|
|
@@ -7569,7 +7642,8 @@ function saveModal() {
|
|
|
};
|
|
|
db.settlements.forEach((x) => { x.sub = shiftRef(x.sub, removedSubs); });
|
|
|
db.tickets.forEach((x) => { x.sub = removedSubs.has(x.sub) ? null : shiftRef(x.sub, removedSubs); });
|
|
|
- db.tickets.forEach((t) => { t.account = shiftRef(t.account, removedAccts); });
|
|
|
+ /* ✅ 2026-11-05:t.account → t.reporter.id(仅 kind=sub 时偏移) */
|
|
|
+ db.tickets.forEach((t) => { if (t.reporter && t.reporter.kind === "sub") t.reporter.id = shiftRef(t.reporter.id, removedAccts); });
|
|
|
db.users.forEach((u) => { u.account = shiftRef(u.account, removedAccts); });
|
|
|
/* 客户主账号与下属分账号的登录账号行随客户注销 */
|
|
|
const me = session === null ? null : db.users[session];
|
|
|
@@ -10218,7 +10292,7 @@ function ticketMatches(t, st) {
|
|
|
if (dayFrom && t.created < dayFrom) return false;
|
|
|
if (dayTo && t.created > dayTo) return false;
|
|
|
if (q) {
|
|
|
- const acct = t.account !== undefined && t.account !== null ? db.accounts[t.account].name : "";
|
|
|
+ const acct = reporterLabel(t);
|
|
|
const c = ticketContract(t);
|
|
|
const extNo = (c && c.extNo) || "";
|
|
|
const fbs = db.feedback.filter((f) => f.ticket === t.i).map((f) => `${f.extNo} ${f.conclusion} ${FB_STATE_TEXT[f.state] || f.state}`).join(" ");
|
|
|
@@ -10467,7 +10541,7 @@ function pageTicket() {
|
|
|
</tbody></table>
|
|
|
<p class="note">${cw.receipt ? "联通已回执,本工单以回执为闭环依据;已闭环的工单不再开放处理与关闭入口。" : "竣工单已回传联通,联通回执确认前一直保持「已完成」;未回执不关闭。"}</p>`
|
|
|
: `<p class="note">${t.status === "已完成" ? `回填已成功且必填组齐全,下一步${canSendClosure ? "生成竣工单回传联通" : "由本团队主账号或总运营生成竣工单回传联通"};联通回执确认后才进「已闭环」。` : "回填成功后才生成竣工单回传联通;竣工回传 + 联通回执确认才进「已闭环」,未回执不关闭。"}</p>`}`;
|
|
|
- return layout(`${t.type} · ${entName(t.enterprise)}${t.account !== undefined && t.account !== null ? " · " + esc(db.accounts[t.account].name) : ""}`, `${t.no || `第 ${seq(focus)} 号`} · ${teamName(t.team)} · ${memberName(t.assignee)}`, `
|
|
|
+ return layout(`${t.type} · ${entName(t.enterprise)}${reporterLabel(t) ? " · " + esc(reporterLabel(t)) : ""}`, `${t.no || `第 ${seq(focus)} 号`} · ${teamName(t.team)} · ${memberName(t.assignee)}`, `
|
|
|
<div class="split">
|
|
|
<div class="panel">
|
|
|
<p>${pill(t.status)} <span class="note">创建于 ${esc(t.created)}${t.doneOn ? ` · 完成于 ${esc(t.doneOn)}` : ""}${action ? ` · 开停记录 ${esc(action.id)} · ${esc(action.status)}${action.doneOn ? "(" + esc(action.doneOn) + ")" : ""}` : ""}${isSvc && t.extendUntil ? ` · 提醒已延期至 ${esc(t.extendUntil)}` : ""}</span>${late ? " " + pill("超 7 日") : ""}</p>
|
|
|
@@ -10658,9 +10732,16 @@ function syncPortalDocs() {
|
|
|
const PORTAL_DOC_MAX = 9;
|
|
|
|
|
|
function pageSubmit() {
|
|
|
+ const u = user();
|
|
|
+ const isEnt = u.role === "enterprise";
|
|
|
+ /* ✅ 2026-11-05:报障账号下拉——仅主账号登录时渲染(控件 ID = reporterAcct,DOM 常驻,类型=售后时 hidden=true) */
|
|
|
+ const reporterSelect = isEnt
|
|
|
+ ? reporterSelectHtml(u.enterprise)
|
|
|
+ : "";
|
|
|
return layout("提交故障或售后", `填写遇到的问题,可附图片或语音后生成工单,先落到客户挂接的、承接故障工单的运维团队再分派。自己提交的工单,在运维处理完成前可以到工单详情里撤回关闭;运维标记已完成后,要在同一张详情里点击确认关闭形成闭环,自完成日起 ${CONFIRM_CLOSE_DAYS} 个自然日内未确认的由系统自动闭环。不能分派、不能关闭别人提交的单、不能发起开停。`, `
|
|
|
<div class="panel">
|
|
|
- <label>类型</label><select id="faultType"><option>故障</option><option>售后</option></select>
|
|
|
+ <label>类型</label><select id="faultType"${isEnt ? ' data-toggle-reporter="reporterAcct"' : ''}><option value="故障">故障</option><option value="售后">售后</option></select>
|
|
|
+ ${reporterSelect ? `<div id="reporterAcctWrap">${reporterSelect}</div>` : ""}
|
|
|
<label>内容<span class="req">*</span></label><textarea id="faultText" placeholder="请描述遇到的问题;如需补充,可添加图片或语音。"></textarea>
|
|
|
<div class="doc-pick">
|
|
|
<label>补充材料(可选 · 图片或语音 · 最多 ${PORTAL_DOC_MAX} 份)</label>
|
|
|
@@ -11177,13 +11258,25 @@ document.body.addEventListener("click", (event) => {
|
|
|
const text = document.getElementById("faultText").value.trim();
|
|
|
if (!text) { say("请填写内容"); return; }
|
|
|
const u = user();
|
|
|
- submitTicket(u.enterprise, u.role === "sub" ? u.account : null, document.getElementById("faultType").value, text, undefined, portalDocs);
|
|
|
+ /* ✅ 2026-11-05:主账号登录 + 类型=故障时读下拉值
|
|
|
+ "__self__" = 主账号自报 → 传 null 让后台自动填充;
|
|
|
+ 数字 = 选中的分账号索引 → 代该分账号报障;
|
|
|
+ 分账号登录或类型=售后 → 下拉不存在或隐藏 → 传 null 让后台填充 */
|
|
|
+ let reporterArg = null;
|
|
|
+ if (u.role === "enterprise" && document.getElementById("faultType").value === "故障") {
|
|
|
+ const sel = document.getElementById("reporterAcct");
|
|
|
+ if (sel && sel.value !== "__self__") reporterArg = Number(sel.value);
|
|
|
+ }
|
|
|
+ submitTicket(u.enterprise, reporterArg, document.getElementById("faultType").value, text, undefined, portalDocs);
|
|
|
/* 提交成功即清空页面级材料清单与文件控件,避免下一张工单重复带上本单的材料 */
|
|
|
portalDocs = [];
|
|
|
const picker = document.getElementById("portalFaultDoc");
|
|
|
if (picker) picker.value = "";
|
|
|
syncPortalDocs();
|
|
|
document.getElementById("faultText").value = "";
|
|
|
+ /* 恢复报障账号下拉到缺省 */
|
|
|
+ const repSel = document.getElementById("reporterAcct");
|
|
|
+ if (repSel) repSel.value = "__self__";
|
|
|
return;
|
|
|
}
|
|
|
if (d.create !== undefined) {
|
|
|
@@ -12626,6 +12719,18 @@ document.body.addEventListener("click", (event) => {
|
|
|
render();
|
|
|
});
|
|
|
|
|
|
+/* ✅ 2026-11-05:门户建单页类型切换 → 报障账号下拉显隐
|
|
|
+ 类型=故障时显示下拉(允许主账号代分账号报障),类型=售后时隐藏(售后单不关联报障账号)
|
|
|
+ DOM 常驻(hidden=true/false),不销毁(避免重绘丢失已选项) */
|
|
|
+document.body.addEventListener("change", (event) => {
|
|
|
+ const t = event.target;
|
|
|
+ const toggleId = t && t.dataset && t.dataset.toggleReporter;
|
|
|
+ if (toggleId) {
|
|
|
+ const wrap = document.getElementById("reporterAcctWrap");
|
|
|
+ if (wrap) wrap.hidden = t.value !== "故障";
|
|
|
+ }
|
|
|
+});
|
|
|
+
|
|
|
/* 负责范围形态切换(抽屉与新增/编辑弹窗共用):切形态只改草稿,控件随之换一套;
|
|
|
弹窗切形态前先把已填的姓名、可处理类型与账号字段收进 draft,重绘后不回到默认值 */
|
|
|
document.body.addEventListener("change", (event) => {
|