|
|
@@ -10,6 +10,7 @@ import {
|
|
|
} from "../lib/organization-demo";
|
|
|
import * as bos from "../lib/api/bos";
|
|
|
import { OrganizationAccountInline } from "./OrganizationAccountInline";
|
|
|
+import { OpsTag } from "./OperationsKit";
|
|
|
import { MAINTENANCE_TICKET_TYPES, OPS_ACCOUNT_REQUIRED_TYPE, TICKET_TYPES, typeLabel } from "../lib/api/ticket";
|
|
|
|
|
|
function countText(v?: number | null) {
|
|
|
@@ -75,8 +76,10 @@ function MemberModeOptions<T extends string>({ name, options, value, onChange }:
|
|
|
</div>;
|
|
|
}
|
|
|
|
|
|
-function MemberFormDialog({ title, onClose, busy, centered = true, children }: {
|
|
|
+function MemberFormDialog({ title, subtitle, className, onClose, busy, centered = true, children }: {
|
|
|
title: string;
|
|
|
+ subtitle?: string;
|
|
|
+ className?: string;
|
|
|
onClose: () => void;
|
|
|
busy: boolean;
|
|
|
centered?: boolean;
|
|
|
@@ -84,9 +87,9 @@ function MemberFormDialog({ title, onClose, busy, centered = true, children }: {
|
|
|
}) {
|
|
|
const close = () => { if (!busy) onClose(); };
|
|
|
return <div className={centered ? "org-dialog-backdrop org-centered-backdrop" : "org-dialog-backdrop"} onMouseDown={close} role="presentation">
|
|
|
- <section aria-label={title} aria-modal="true" className={centered ? "org-dialog org-editor-modal org-member-dialog" : "org-dialog org-member-dialog"} onMouseDown={(event) => event.stopPropagation()} role="dialog">
|
|
|
+ <section aria-label={subtitle ? `${title} · ${subtitle}` : title} aria-modal="true" className={["org-dialog org-member-dialog", centered && "org-editor-modal", className].filter(Boolean).join(" ")} onMouseDown={(event) => event.stopPropagation()} role="dialog">
|
|
|
<header>
|
|
|
- <h2>{title}</h2>
|
|
|
+ <div><h2>{title}</h2>{subtitle && <p className="org-dialog-subtitle">{subtitle}</p>}</div>
|
|
|
<button aria-label="关闭" className="org-icon-button" disabled={busy} onClick={close} type="button"><X size={18} /></button>
|
|
|
</header>
|
|
|
{children}
|
|
|
@@ -186,7 +189,7 @@ export function MemberEditDialog({ team, member, onClose, centered = false }: {
|
|
|
const knownRegionIds = new Set(regionOptions.map((region) => region.id));
|
|
|
const regionChoices = [
|
|
|
...regionOptions.map((region) => ({ id: region.id, label: regionPath(data, region.id) })),
|
|
|
- ...(member.scopeRegions ?? []).filter((id) => !knownRegionIds.has(id)).map((id) => ({ id, label: id })),
|
|
|
+ ...(member.scopeRegions ?? []).filter((id) => !knownRegionIds.has(id)).map((id) => ({ id, label: regionPath(data, id) || id })),
|
|
|
];
|
|
|
const coveredSet = new Set(covered);
|
|
|
const customerChoices = [...new Set([...covered, ...(member.enterprises ?? []).filter((index) => !coveredSet.has(index) && data.enterprises[index])])];
|
|
|
@@ -250,18 +253,72 @@ export function MemberEditDialog({ team, member, onClose, centered = false }: {
|
|
|
setBusy(false);
|
|
|
setDone(notes);
|
|
|
}
|
|
|
- const heading = `编辑运维成员 · ${member.name}`;
|
|
|
- return <MemberFormDialog title={heading} onClose={onClose} busy={busy} centered={centered}>
|
|
|
- {done ? <><div className="org-dialog-content"><p className="org-account-notice" role="status">成员资料已保存</p><ul>{done.map((note) => <li key={note}>{note}</li>)}</ul></div><footer><button className="org-button" onClick={onClose} type="button">完成</button></footer></> : <form onSubmit={save}><div className="org-dialog-content">
|
|
|
- <div className="org-member-contact-fields">
|
|
|
- <label className="org-field"><span>姓名 <em>*</em></span><input aria-required="true" autoFocus autoComplete="off" maxLength={64} onChange={(event) => { setName(event.target.value); setError(""); }} placeholder="例如 徐云" value={name} /></label>
|
|
|
- <label className="org-field"><span>手机号</span><input inputMode="tel" maxLength={11} onChange={(event) => { setPhone(event.target.value); setError(""); }} placeholder={member.phone ? `当前 ${member.phone}(脱敏),留空不修改` : "未绑定手机号,留空不修改"} value={phone} /></label>
|
|
|
+ return <MemberFormDialog title="编辑运维成员" subtitle={`${member.name} · ${team.name}`} className="org-maintenance-member-editor" onClose={onClose} busy={busy} centered={centered}>
|
|
|
+ {done ? <>
|
|
|
+ <div className="org-dialog-content">
|
|
|
+ <p className="org-account-notice" role="status">成员资料已保存</p>
|
|
|
+ <ul>{done.map((note) => <li key={note}>{note}</li>)}</ul>
|
|
|
</div>
|
|
|
- {member.primary ? <p className="org-helper">主账号跟随团队的工单类型:{teamTypes.map(typeLabel).join("、") || FIELD_UNAVAILABLE}</p> : member.ticketTypes === undefined ? <p className="org-helper">暂未获取到工单类型,无法编辑。</p> : <fieldset className="org-scope-editor"><legend>可处理工单类型</legend><MemberModeOptions name="member-edit-ticket-mode" options={memberTicketOptions} value={ticketMode} onChange={setTicketMode} />{ticketMode === "follow_team" ? <p className="org-helper">当前团队类型:{teamTypes.map(typeLabel).join("、") || FIELD_UNAVAILABLE}</p> : <><p>全部留空时,该成员不接单。</p><div className="org-check-grid">{teamTypes.map((value) => <label key={value}><input checked={ticketTypes.includes(value)} onChange={() => setTicketTypes((current) => current.includes(value) ? current.filter((type) => type !== value) : [...current, value])} type="checkbox" />{typeLabel(value)}</label>)}</div></>}</fieldset>}
|
|
|
- <fieldset className="org-scope-editor"><legend>负责范围</legend><MemberModeOptions name="member-edit-scope-mode" options={memberScopeOptions} value={scopeMode} onChange={setScopeMode} />{scopeMode === "region" && <div className="org-check-grid">{regionChoices.map((choice) => <label key={choice.id}><input checked={scopeRegions.includes(choice.id)} onChange={() => setScopeRegions((current) => current.includes(choice.id) ? current.filter((id) => id !== choice.id) : [...current, choice.id])} type="checkbox" />{choice.label}</label>)}</div>}{scopeMode === "customer" && <div className="org-check-grid">{customerChoices.map((index) => <label key={index}><input checked={enterprises.includes(index)} onChange={() => setEnterprises((current) => current.includes(index) ? current.filter((value) => value !== index) : [...current, index])} type="checkbox" />{data.enterprises[index].name}</label>)}</div>}{!covered.length && <p>团队尚未配置负责范围,成员只能跟随团队。</p>}</fieldset>
|
|
|
- <OrganizationAccountInline account={member} />
|
|
|
- {error && <p className="org-form-error" role="alert">{error}</p>}
|
|
|
- </div><footer><button className="org-button org-button-quiet" disabled={busy} onClick={onClose} type="button">取消</button><button className="org-button" disabled={busy} type="submit">保存修改</button></footer></form>}
|
|
|
+ <footer><button className="org-button" onClick={onClose} type="button">完成</button></footer>
|
|
|
+ </> : <form onSubmit={save}>
|
|
|
+ <div className="org-dialog-content">
|
|
|
+ <section className="org-member-profile">
|
|
|
+ <h3>成员资料</h3>
|
|
|
+ <div className="org-member-contact-fields">
|
|
|
+ <label className="org-field">
|
|
|
+ <span>姓名 <em>*</em></span>
|
|
|
+ <input aria-required="true" autoFocus autoComplete="off" maxLength={64} onChange={(event) => { setName(event.target.value); setError(""); }} placeholder="例如 徐云" value={name} />
|
|
|
+ </label>
|
|
|
+ <label className="org-field">
|
|
|
+ <span>手机号</span>
|
|
|
+ <input inputMode="tel" maxLength={11} onChange={(event) => { setPhone(event.target.value); setError(""); }} placeholder={member.phone ? `当前 ${member.phone},留空不修改` : "输入手机号,留空不修改"} value={phone} />
|
|
|
+ </label>
|
|
|
+ </div>
|
|
|
+ </section>
|
|
|
+ <div className="org-member-config">
|
|
|
+ <fieldset className="org-member-config-panel">
|
|
|
+ <legend>可处理工单类型</legend>
|
|
|
+ {typesEditable && <MemberModeOptions name="member-edit-ticket-mode" options={memberTicketOptions} value={ticketMode} onChange={setTicketMode} />}
|
|
|
+ {member.primary && <p className="org-helper">主账号跟随团队</p>}
|
|
|
+ {!member.primary && !typesEditable ? <p className="org-helper">暂未获取到工单类型,无法编辑。</p>
|
|
|
+ : ticketMode === "follow_team" ? <div className="org-member-team-types">
|
|
|
+ {teamTypes.length ? teamTypes.map((type) => <OpsTag tone="neutral" key={type}>{typeLabel(type)}</OpsTag>) : <p className="org-helper">{FIELD_UNAVAILABLE}</p>}
|
|
|
+ </div> : teamTypes.length ? <>
|
|
|
+ <div className="org-check-grid org-member-config-choices">
|
|
|
+ {teamTypes.map((type) => <label key={type}>
|
|
|
+ <input checked={ticketTypes.includes(type)} onChange={() => setTicketTypes((current) => current.includes(type) ? current.filter((value) => value !== type) : [...current, type])} type="checkbox" />
|
|
|
+ <span>{typeLabel(type)}</span>
|
|
|
+ </label>)}
|
|
|
+ </div>
|
|
|
+ {!ticketTypes.length && <p className="org-helper">未勾选工单类型时,该成员不接单。</p>}
|
|
|
+ </> : <p className="org-helper">团队暂无可选工单类型。</p>}
|
|
|
+ </fieldset>
|
|
|
+ <fieldset className="org-member-config-panel">
|
|
|
+ <legend>负责范围</legend>
|
|
|
+ <MemberModeOptions name="member-edit-scope-mode" options={memberScopeOptions} value={scopeMode} onChange={setScopeMode} />
|
|
|
+ {scopeMode === "follow_team" && <p className="org-helper">成员跟随团队的客户负责范围。</p>}
|
|
|
+ {scopeMode === "region" && (regionChoices.length ? <div className="org-check-grid org-member-config-choices org-member-scope-choices">
|
|
|
+ {regionChoices.map(({ id, label }) => <label key={id}>
|
|
|
+ <input checked={scopeRegions.includes(id)} onChange={() => setScopeRegions((current) => current.includes(id) ? current.filter((value) => value !== id) : [...current, id])} type="checkbox" />
|
|
|
+ <span>{label}</span>
|
|
|
+ </label>)}
|
|
|
+ </div> : <p className="org-helper">暂无可选区域。</p>)}
|
|
|
+ {scopeMode === "customer" && (customerChoices.length ? <div className="org-check-grid org-member-config-choices org-member-scope-choices">
|
|
|
+ {customerChoices.map((index) => <label key={index}>
|
|
|
+ <input checked={enterprises.includes(index)} onChange={() => setEnterprises((current) => current.includes(index) ? current.filter((value) => value !== index) : [...current, index])} type="checkbox" />
|
|
|
+ <span>{data.enterprises[index].name}</span>
|
|
|
+ </label>)}
|
|
|
+ </div> : <p className="org-helper">暂无可选客户。</p>)}
|
|
|
+ </fieldset>
|
|
|
+ </div>
|
|
|
+ <OrganizationAccountInline account={member} />
|
|
|
+ {error && <p className="org-form-error" role="alert">{error}</p>}
|
|
|
+ </div>
|
|
|
+ <footer>
|
|
|
+ <button className="org-button org-button-quiet" disabled={busy} onClick={onClose} type="button">取消</button>
|
|
|
+ <button className="org-button" disabled={busy} type="submit">{busy ? "保存中…" : "保存修改"}</button>
|
|
|
+ </footer>
|
|
|
+ </form>}
|
|
|
</MemberFormDialog>;
|
|
|
}
|
|
|
|