data.js 48 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569
  1. /* 模拟数据只存在于页面内存。内部下标从 0 开始,页面上的序号从 1 开始。 */
  2. const TODAY = "2026-10-15";
  3. /* 区域三级:大区 / 市 / 区县。客户可挂在任一层,只能挂一个节点。 */
  4. const LEVEL_NAMES = ["大区", "市", "区县"];
  5. const SEED = {
  6. setting: { defaultReconcileDay: 5 },
  7. regions: [
  8. { id: "east", name: "华东大区", level: 0, parent: null },
  9. { id: "south", name: "华南大区", level: 0, parent: null },
  10. { id: "sh", name: "上海市", level: 1, parent: "east" },
  11. { id: "su", name: "苏州市", level: 1, parent: "east" },
  12. { id: "gz", name: "广州市", level: 1, parent: "south" },
  13. { id: "pd", name: "浦东新区", level: 2, parent: "sh" },
  14. { id: "lg", name: "临港新片区", level: 2, parent: "sh" },
  15. { id: "mh", name: "闵行区", level: 2, parent: "sh" },
  16. { id: "ks", name: "昆山市", level: 2, parent: "su" },
  17. { id: "th", name: "天河区", level: 2, parent: "gz" },
  18. ],
  19. /* 运营商按所属区域建档(region 为区域节点 id,含下级生效);客户只归属唯一运营商。
  20. shareMode 为档案级分成方式(按比例 / 按金额 / 按每账号,三选一),shareValue 随方式而定:
  21. 按比例时为 0-1 的比例(列表显示为百分比),按金额时为每月固定分成的人民币元(列表显示为金额/月),
  22. 按每账号时为每个账号的人民币金额(结算时分成金额 = 账号数 × 每账号金额)。在各自编辑界面配置。 */
  23. operators: [
  24. { name: "联通", region: "sh", reconcileDay: null, payCycle: "按月", notify: "notice@unicorn.example", shareMode: "按比例", shareValue: 0.2 },
  25. { name: "电信", region: "east", reconcileDay: null, payCycle: "按年", notify: "notice@ict-telecom.example", shareMode: "按比例", shareValue: 0.18 },
  26. { name: "移动", region: "east", reconcileDay: 8, payCycle: "按月", notify: "notice@mobile.example", shareMode: "按比例", shareValue: 0.15 },
  27. { name: "广东电信", region: "south", reconcileDay: null, payCycle: "按季度", notify: "notice@gd-ict.example", shareMode: "按金额", shareValue: 60 },
  28. { name: "苏州移动", region: "su", reconcileDay: 12, payCycle: "按季度", notify: "notice@sz-mobile.example", shareMode: "按每账号", shareValue: 3.5 },
  29. { name: "广州移动", region: "gz", reconcileDay: null, payCycle: "按月", notify: "notice@gz-mobile.example", shareMode: "按比例", shareValue: 0.12 },
  30. ],
  31. partners: [
  32. { name: "邹合", region: "east", title: "华东渠道", notify: "zouhe@example", scope: { regions: ["east"], enterprises: [] }, shareMode: "按比例", shareValue: 0.05 },
  33. { name: "何南", region: "gz", title: "华南渠道", notify: "henan@example", scope: { regions: ["th"], enterprises: [2] }, shareMode: "按每账号", shareValue: 6 },
  34. ],
  35. /* 运维团队按所属区域建档(region 为建档区域节点 id,列表显示全路径),负责范围另在「配置范围」里勾;
  36. type 为团队类型(常规 / 施工,各占一个 tab),mode 为团队内工单分派方式,
  37. shareMode 与 shareValue 为档案级分成配置,口径与运营商、合伙人、运营团队一致。 */
  38. teams: [
  39. { name: "华东常规运维", region: "east", type: "常规", mode: "手工", scope: { regions: ["sh", "su"], enterprises: [] }, shareMode: "按金额", shareValue: 50 },
  40. { name: "沪东施工", region: "sh", type: "施工", mode: "自动平均", scope: { regions: ["pd"], enterprises: [1] }, shareMode: "按每账号", shareValue: 4 },
  41. ],
  42. /* hq: true 为系统内置的总运营团队:不限所属区域(region 为空),负责范围覆盖全国,列表置顶且不可删除。
  43. 该团队的默认主账号即总运营账号(见 users 中 builtin: true 的一条),不再另设运营团队账号。 */
  44. regOpsTeams: [
  45. { name: "总运营团队", region: "", hq: true, scope: { regions: ["east", "south"], enterprises: [] }, desc: "总部平台级团队,不限所属区域,覆盖全国全部客户", shareMode: "按比例", shareValue: 0.1 },
  46. { name: "华东运营", region: "east", scope: { regions: ["east"], enterprises: [] }, desc: "覆盖华东大区全部下挂客户", shareMode: "按比例", shareValue: 0.08 },
  47. { name: "华南运营", region: "south", scope: { regions: ["south"], enterprises: [] }, desc: "覆盖华南大区全部下挂客户", shareMode: "按金额", shareValue: 30 },
  48. { name: "上海运营", region: "sh", scope: { regions: ["sh"], enterprises: [] }, desc: "覆盖上海市及其下级区域", shareMode: "按每账号", shareValue: 2.5 },
  49. ],
  50. members: [
  51. { name: "周宁", team: 0, type: "常规", scope: [0, 1, 2, 4] },
  52. { name: "李可", team: 0, type: "常规", scope: [0, 3, 4] },
  53. { name: "赵工", team: 1, type: "施工", scope: [0, 1, 3] },
  54. { name: "钱工", team: 1, type: "施工", scope: [0, 1, 3] },
  55. { name: "陈录", team: 0, type: "录入", scope: [0, 1, 2, 3, 4] },
  56. ],
  57. awards: [
  58. { member: 2, at: "2026-09-20", kind: "奖励", text: "浦东园区割接提前 1 天完成,客户零投诉", amount: 200 },
  59. { member: 2, at: "2026-10-11", kind: "扣罚", text: "临港上门未按约定时间到达,扣罚只作考核,费用在线下处理", amount: -100 },
  60. ],
  61. enterprises: [
  62. {
  63. no: "KL-2026-0001",
  64. name: "澄澜科技有限公司",
  65. subject: "企业",
  66. materials: "营业执照、企业名称、经办联系人、地址、合同、电话",
  67. files: ["oss://materials/KL-2026-0001/营业执照.pdf", "oss://materials/KL-2026-0001/受理单.pdf", "oss://materials/KL-2026-0001/联通交接单.pdf"],
  68. contact: "沈澄",
  69. address: "上海市浦东新区金港路 300 号 6 号楼 3 层",
  70. phone: "021-66001001",
  71. region: "pd",
  72. operator: 0,
  73. partner: 0,
  74. teams: { 常规: 0, 施工: 1 },
  75. status: "在用",
  76. quota: 5,
  77. history: [
  78. { at: "2026-08-10 10:20", field: "挂载区域", before: "未挂载", after: "华东大区 / 上海市 / 浦东新区", by: "林管" },
  79. { at: "2026-03-20 16:40", field: "账户状态", before: "未开通", after: "在用(实际开通日 2026-03-20)", by: "周宁回填" },
  80. ],
  81. },
  82. {
  83. no: "KL-2026-0008",
  84. name: "临港跨境贸易",
  85. subject: "企业",
  86. materials: "营业执照、企业名称、经办联系人、地址、合同、电话",
  87. files: ["oss://materials/KL-2026-0008/营业执照.pdf", "oss://materials/KL-2026-0008/ICT合同.pdf", "oss://materials/KL-2026-0008/联通交接单.pdf"],
  88. contact: "陆港",
  89. address: "上海市浦东新区环湖西二路 800 号 A 座 11 层",
  90. phone: "021-66002008",
  91. region: "lg",
  92. operator: 1,
  93. partner: null,
  94. teams: { 常规: 0 },
  95. status: "未开通",
  96. quota: 8,
  97. history: [
  98. { at: "2026-09-02 09:05", field: "挂载区域", before: "未挂载", after: "华东大区 / 上海市 / 临港新片区", by: "林管" },
  99. ],
  100. },
  101. {
  102. no: "KL-2026-0012",
  103. name: "陈阿福",
  104. subject: "个体工商户",
  105. materials: "身份证、姓名、手机号、地址",
  106. files: ["oss://materials/KL-2026-0012/身份证.jpg"],
  107. contact: "陈阿福",
  108. address: "江苏省昆山市玉山镇中华园东路 58 号 2 单元 402",
  109. phone: "13800001112",
  110. region: "ks",
  111. operator: 2,
  112. partner: 1,
  113. teams: { 常规: 0 },
  114. status: "在用",
  115. quota: 1,
  116. history: [
  117. { at: "2026-08-28 14:10", field: "挂载区域", before: "未挂载", after: "华东大区 / 苏州市 / 昆山市", by: "林管" },
  118. ],
  119. },
  120. {
  121. no: "KL-2026-0019",
  122. name: "王敏",
  123. subject: "个人",
  124. materials: "身份证、姓名、手机号、地址",
  125. files: ["oss://materials/KL-2026-0019/身份证.jpg"],
  126. contact: "王敏",
  127. address: "上海市浦东新区张杨路 1200 弄 12 号 1802 室",
  128. phone: "13900001019",
  129. region: "pd",
  130. operator: 2,
  131. partner: 1,
  132. teams: { 常规: 0, 施工: 1 },
  133. status: "在用",
  134. quota: 2,
  135. history: [
  136. { at: "2026-08-20 11:30", field: "挂载区域", before: "华东大区 / 苏州市 / 昆山市", after: "华东大区 / 上海市 / 浦东新区", by: "林管" },
  137. { at: "2026-08-20 11:32", field: "合伙人", before: "无", after: "何南(华南渠道,直接多选客户)", by: "林管" },
  138. ],
  139. },
  140. {
  141. no: "KL-2026-0023",
  142. name: "海岚跨境电商(上海)",
  143. subject: "企业",
  144. materials: "营业执照、企业名称、经办联系人、地址、合同、电话",
  145. files: ["oss://materials/KL-2026-0023/营业执照.pdf", "oss://materials/KL-2026-0023/续约合同.pdf"],
  146. contact: "周岚",
  147. address: "上海市闵行区申长路 988 号 3 号楼 5 层",
  148. phone: "021-54002023",
  149. region: "mh",
  150. operator: 0,
  151. partner: 0,
  152. teams: { 常规: 0 },
  153. status: "在用",
  154. quota: 2,
  155. history: [
  156. { at: "2026-09-12 15:00", field: "挂载区域", before: "未挂载", after: "华东大区 / 上海市 / 闵行区", by: "林管" },
  157. { at: "2025-10-01 10:00", field: "账户状态", before: "未开通", after: "在用(实际开通日 2025-10-01)", by: "周宁回填" },
  158. ],
  159. },
  160. ],
  161. /* 固定套餐口径取自 docs/原始文档/跨境网络报价单.pdf:
  162. 使用规模 10 人左右分「通用办公 / 直播高需求 / AI 应用」三组共 8 档,另设「单独境外 IP」按个叠加档;
  163. 使用规模 30 人及以上走定制化,报价单不列固定单价,由区域运营为具体客户配自定义套餐承接
  164. (跨境养号的云手机租赁同为按需报价,同样走自定义套餐)。
  165. cat 为用途分类,目录按它分组;desc 为报价单权益口径。
  166. 报价单按月报价,首期只做按年订阅,年订阅价格 = 月价 × 12。
  167. 分账号额度报价单未给出,按用途推定(办公档 10;直播 A 单链接单流 2、B 单链接多流 5、C 顶配 10;
  168. AI 5M 档 3、10M 档 5;按个叠加的增值项不占额度记 0),运营可在目录内直接改。
  169. costs 为该档位随附的成本项:名称取自「成本管理」里的全局应扣除成本项清单,金额默认沿用清单上的本期摊销额、可在档位上改写,
  170. 计算方式与周期取全局成本项上的口径,档位上不新建成本项。计算方式为「每份」的项再多一个 qty:本档位实际配了几份这项资源就摊几份
  171. (例如该档配了 2 台境外云主机记 qty: 2),不填按 1 份;「每客户」「每账号」的项不带 qty,也不按份数放大。
  172. 成本项本身是全局口径,不挂在客户或订阅上,客户本月计入哪几笔由其在用订阅引用的档位决定。 */
  173. packages: [
  174. { name: "跨境办公 · 基础档", cat: "通用办公", yearPrice: 1080, monthPrice: 90, quota: 10, bw: "不承诺带宽", desc: "一般访问流量,无固定境外 IP,不承诺带宽", custom: null },
  175. { name: "跨境办公 · 标准档", cat: "通用办公", yearPrice: 1440, monthPrice: 120, quota: 10, bw: "下行 10M / 上行 1M", desc: "店铺管理、一般办公、视频会议、ERP 等,比基础档速度更快更稳定", custom: null },
  176. { name: "跨境办公 · 独立 IP 档", cat: "通用办公", yearPrice: 1920, monthPrice: 160, quota: 10, bw: "下行 5M / 上行 2M", desc: "单独境外 IP 配置,通过 CPE 组织网络管理平台", custom: null, costs: [{ name: "国家 IP 地址月摊销", amount: 40, qty: 1 }] },
  177. { name: "直播高需求 · A 类", cat: "直播高需求", yearPrice: 10800, monthPrice: 900, quota: 2, bw: "上下行 10M", desc: "单链接、单流;单独境外 IP 另购,80 元/个", custom: null },
  178. { name: "直播高需求 · B 类", cat: "直播高需求", yearPrice: 32400, monthPrice: 2700, quota: 5, bw: "上下行 30M", desc: "单链接、多流;团队内部运营如后台管理、看播等已包含", custom: null },
  179. { name: "直播高需求 · C 类", cat: "直播高需求", yearPrice: 62400, monthPrice: 5200, quota: 10, bw: "上下行 50M", desc: "直播高需求顶配档;链接数与流数按合同另定", custom: null },
  180. { name: "AI 应用 · 5M 档", cat: "AI 应用", yearPrice: 5760, monthPrice: 480, quota: 3, bw: "上下行 5M", desc: "面向 AI 应用访问的固定上下行带宽档", custom: null, costs: [{ name: "国家 IP 地址月摊销", amount: 50, qty: 1 }] },
  181. { name: "AI 应用 · 10M 档", cat: "AI 应用", yearPrice: 10800, monthPrice: 900, quota: 5, bw: "上下行 10M", desc: "面向 AI 应用访问的固定上下行带宽档", custom: null },
  182. { name: "单独境外 IP(按个叠加)", cat: "叠加增值", yearPrice: 960, monthPrice: 80, quota: 0, bw: "按个计,不占带宽", desc: "80 元/个/月,与主档叠加订阅、各自计费;个数与单价在订阅上按合同改写", custom: null, costs: [{ name: "国际云主机月摊销", amount: 30, qty: 1 }] },
  183. { name: "临港 ICT 定制套餐", cat: "定制化", yearPrice: 24000, monthPrice: 2000, quota: 8, bw: "150Mbps", desc: "使用规模 30 人及以上,业务分析与需求摸排调研后定制;临港跨境贸易专项档", custom: 1, costs: [{ name: "国际出口带宽月摊销", amount: 80 }, { name: "国际云主机月摊销", amount: 30, qty: 2 }] }, /* 每份:该档配了 2 台境外云主机,按 30 × 2 = 60 摊 */
  184. ],
  185. /* 订阅一律按名称引用「套餐目录」中的档位,签约时把目录价冻结到订阅上(目录改价不影响存量订阅)。
  186. 示例覆盖全部用途分类:通用办公(基础 / 标准 / 独立 IP 档)、直播高需求(A 类)、AI 应用(5M 档)、
  187. 叠加增值(单独境外 IP ×2 个:80 元/个/月 × 2 × 12)、定制化(临港 ICT 自定义档)。 */
  188. subs: [
  189. { enterprise: 0, name: "跨境办公 · 基础档", kind: "升降配前", status: "已到期", start: "2025-03-18", end: "2026-03-17", yearPrice: 1080, monthPrice: 90, openedOn: "2025-03-20", contractNo: "HT-CL-20250318", files: ["oss://contracts/HT-CL-20250318.pdf"] },
  190. { enterprise: 0, name: "跨境办公 · 标准档", kind: "正式", status: "生效中", start: "2026-03-18", end: "2027-03-17", yearPrice: 1440, monthPrice: 120, openedOn: "2026-03-20", contractNo: "HT-CL-20260318", files: ["oss://contracts/HT-CL-20260318.pdf"] },
  191. { enterprise: 1, name: "临港 ICT 定制套餐", kind: "正式", status: "生效中", start: "2026-09-02", end: "2027-09-01", yearPrice: 24000, monthPrice: 2000, openedOn: null, contractNo: "ICT-LG-20260902", files: ["oss://contracts/ICT-LG-20260902.pdf"] },
  192. { enterprise: 2, name: "直播高需求 · A 类", kind: "正式", status: "生效中", start: "2026-09-01", end: "2026-10-31", yearPrice: 10800, monthPrice: 900, openedOn: "2026-09-01", contractNo: "HT-CFA-20260901", files: ["oss://contracts/HT-CFA-20260901.pdf"] },
  193. { enterprise: 3, name: "AI 应用 · 5M 档", kind: "正式", status: "生效中", start: "2026-06-01", end: "2027-05-31", yearPrice: 5760, monthPrice: 480, openedOn: "2026-06-01", contractNo: "HT-WM-20260601", files: ["oss://contracts/HT-WM-20260601.pdf"] },
  194. { enterprise: 3, name: "单独境外 IP(按个叠加)", kind: "叠加", status: "生效中", start: "2026-08-01", end: "2027-07-31", yearPrice: 1920, monthPrice: 160, openedOn: "2026-08-01", contractNo: "HT-WM-20260801", files: ["oss://contracts/HT-WM-20260801.pdf"] },
  195. { enterprise: 4, name: "跨境办公 · 独立 IP 档", kind: "正式", status: "已到期", start: "2025-10-01", end: "2026-09-30", yearPrice: 1920, monthPrice: 160, openedOn: "2025-10-01", contractNo: "HT-HL-20251001", files: ["oss://contracts/HT-HL-20251001.pdf"] },
  196. { enterprise: 4, name: "跨境办公 · 独立 IP 档", kind: "正式", status: "待生效", start: "2026-11-01", end: "2027-10-31", yearPrice: 1920, monthPrice: 160, openedOn: null, contractNo: "HT-HL-20261101", files: ["oss://contracts/HT-HL-20261101.pdf"] },
  197. /* 客户已在用时新增的叠加订阅:保存时自动生成「服务开通」工单(见 tickets 末条),实际开通日尚未回填 */
  198. { enterprise: 3, name: "单独境外 IP(按个叠加)", kind: "叠加", status: "生效中", start: "2026-10-08", end: "2027-10-07", yearPrice: 1920, monthPrice: 160, openedOn: null, contractNo: "HT-WM-20261008", files: ["oss://contracts/HT-WM-20261008.pdf"] },
  199. ],
  200. /* 下属分账号:login 为账号名,规则是「客户主账号登录名-n」,n 为该客户的分账号序号,从 1 起,
  201. 正式与临时测试共用一个序号池;netLogin 为零信任客户端上的账号名,选填、可改、不校验唯一。
  202. 正式数量由套餐额度决定,示例里未建满的部分由启动时的 alignSubAccounts 按额度自动补齐。 */
  203. accounts: [
  204. { enterprise: 0, name: "张敏", login: "clkj-1", status: "在用", usage: "正式", openedOn: "2026-03-20", netLogin: "zhangmin@clkj" },
  205. { enterprise: 0, name: "李航", login: "clkj-2", status: "在用", usage: "正式", openedOn: "2026-03-20", netLogin: "" },
  206. { enterprise: 0, name: "联调测试", login: "clkj-3", status: "在用", usage: "测试", openedOn: "2026-04-01", netLogin: "uat-liantiao@clkj" },
  207. { enterprise: 0, name: "待开通席位", login: "clkj-4", status: "未开通", usage: "正式", openedOn: null, netLogin: "" },
  208. { enterprise: 1, name: "临港-财务", login: "lgkjmy-1", status: "未开通", usage: "正式", openedOn: null, netLogin: "" },
  209. { enterprise: 1, name: "临港-关务", login: "lgkjmy-2", status: "未开通", usage: "正式", openedOn: null, netLogin: "customs-01@lingang" },
  210. { enterprise: 3, name: "王敏本人", login: "wm-1", status: "在用", usage: "正式", openedOn: "2026-06-01", netLogin: "wangmin@wm" },
  211. { enterprise: 4, name: "海岚-小王", login: "hlkjdssh-1", status: "在用", usage: "正式", openedOn: "2025-10-01", netLogin: "" },
  212. ],
  213. /* 开停记录与工单一一对应;状态:待执行 / 执行成功 / 执行失败 */
  214. actions: [
  215. { id: "A-20261007-08", enterprise: 1, type: "开户", status: "待执行", ticket: 0, created: "2026-10-07", doneOn: null, extendUntil: null, by: null },
  216. { id: "A-20261009-23", enterprise: 4, type: "到期停机", status: "待执行", ticket: 7, created: "2026-10-09", doneOn: null, extendUntil: null, by: null },
  217. ],
  218. tickets: [
  219. { type: "开户", enterprise: 1, account: null, team: 0, assignee: null, status: "待处理", created: "2026-10-07", text: "合同套餐已建立,网络侧尚未开通。本工单只开通客户本身,不含下属分账号;分账号在套餐订阅时按额度对齐开通。", logs: ["2026-10-07 生成待执行开户记录(A-20261007-08)", "2026-10-07 林管登记联通交接单的开通准备资料(办公应用 6 个账号;中国香港 10 兆固定 IP 2 个)"], closeReason: null, materials: ["oss://materials/KL-2026-0008/联通交接单.pdf"],
  220. prep: {
  221. apps: { 浏览应用: 0, 办公应用: 6, 运营应用: 0, 直播应用: 0, 定制应用: 0 },
  222. ips: [{ country: "中国香港", bw: "10兆", count: 2 }],
  223. agent: "临港联通 · 张工", agentPhone: "13601700208", handoverOn: "2026-10-06",
  224. } },
  225. { type: "故障", enterprise: 0, account: null, team: 0, assignee: 0, status: "处理中", created: "2026-10-12", text: "办公网晚高峰丢包,疑似国际出口拥塞。", logs: ["2026-10-12 客户主账号在系统内提交(文字)", "2026-10-12 吴队分派给周宁"], closeReason: null, materials: [] },
  226. { type: "故障", enterprise: 0, account: null, team: 1, assignee: null, status: "待处理", created: "2026-10-14", text: "机房侧线路需要现场复查(现场施工类)。", logs: ["2026-10-14 常规团队转施工团队,尚未分派"], closeReason: null, materials: [] },
  227. { type: "故障", enterprise: 0, account: null, team: 1, assignee: 2, status: "处理中", created: "2026-10-10", text: "园区弱电井跳纤,现场施工。", logs: ["2026-10-10 自动平均分派给赵工"], closeReason: null, materials: ["oss://tickets/T-1010/现场照片-1.jpg"] },
  228. { type: "故障", enterprise: 3, account: null, team: 1, assignee: 2, status: "待处理", created: "2026-10-13", text: "上门后用户不在,待再次上门。", logs: ["2026-10-13 分派给赵工"], closeReason: null, materials: [] },
  229. { type: "售后", enterprise: 0, account: null, team: 0, assignee: 1, status: "已完成", created: "2026-09-28", text: "补充开通说明并回传配置手册。", logs: ["2026-09-29 李可填写处理记录并完成"], closeReason: null, materials: [] },
  230. { type: "故障", enterprise: 0, account: 0, team: 0, assignee: 0, status: "处理中", created: "2026-10-14", text: "我的座位网络登不上。", logs: ["2026-10-14 下属分账号张敏在系统内提交", "2026-10-14 吴队分派给周宁"], closeReason: null, materials: [] },
  231. { type: "到期停机", enterprise: 4, account: null, team: 0, assignee: 0, status: "待处理", created: "2026-10-09", text: "订阅于 2026-09-30 到期,次日生成到期停机记录。停机不把计费延长过结束日。", logs: ["2026-10-09 日任务生成待执行到期停机记录(A-20261009-23)", "2026-10-09 吴队分派给周宁"], closeReason: null, materials: [] },
  232. { type: "故障", enterprise: 0, account: null, team: 0, assignee: 1, status: "已关闭", created: "2026-10-08", text: "重复报修:办公网丢包。", logs: ["2026-10-08 客户主账号在系统内提交", "2026-10-08 分派给李可", "2026-10-09 吴队关闭:与 10-12 晚高峰丢包工单重复,合并处理"], closeReason: "与同期晚高峰丢包工单重复,合并处理。", materials: [] },
  233. /* 客户已在用时新增订阅 → 服务开通工单:不带开停记录、不改客户账户状态,按套餐带出的服务清单逐条核对,
  234. 全部核对后填实际开通日完成,实际开通日写回 sub 指向的订阅。创建满 7 个自然日仍未完成即进超期提醒。 */
  235. { type: "服务开通", enterprise: 3, account: null, team: 0, assignee: 1, status: "处理中", created: "2026-10-07", sub: 8, extendUntil: null,
  236. text: "HT-WM-20261008 新增叠加订阅「单独境外 IP(按个叠加)」,客户已在用,请在网络侧开通下列 3 项服务。",
  237. logs: ["2026-10-07 林管 新增叠加订阅,自动生成服务开通工单", "2026-10-08 吴队分派给李可"], closeReason: null, materials: [],
  238. svcItems: [
  239. { text: "网络带宽:按个计,不占带宽", done: false },
  240. { text: "单独境外 IP(按个叠加):个数与单价以合同为准(本条订阅年价 1920 元),不补建分账号档案", done: false },
  241. { text: "套餐权益:80 元/个/月,与主档叠加订阅、各自计费;个数与单价在订阅上按合同改写", done: false },
  242. ] },
  243. ],
  244. /* 分成规则挂在渠道与客户的关系上,两种方式二选一:按总金额比例(rate,0-1)或按总客户账号数(per,每账号分成金额,精确到分)。
  245. mode 缺省为按总金额比例。两层都没有时分成计 0。合同增补优先于区域常规。 */
  246. rules: [
  247. { ch: "operator", ref: 0, ent: 0, layer: "区域常规", rate: 0.2 },
  248. { ch: "team", ref: 0, ent: 0, layer: "合同增补", mode: "按总客户账号数", per: 50 },
  249. { ch: "team", ref: 1, ent: 0, layer: "区域常规", rate: 0.05 },
  250. { ch: "partner", ref: 0, ent: 0, layer: "区域常规", rate: 0.05 },
  251. { ch: "operator", ref: 2, ent: 3, layer: "区域常规", rate: 0.15 },
  252. { ch: "team", ref: 0, ent: 3, layer: "区域常规", rate: 0.1 },
  253. { ch: "team", ref: 1, ent: 3, layer: "区域常规", rate: 0.05 },
  254. { ch: "partner", ref: 1, ent: 3, layer: "合同增补", rate: 0.08 },
  255. { ch: "operator", ref: 0, ent: 4, layer: "区域常规", rate: 0.2 },
  256. { ch: "team", ref: 0, ent: 4, layer: "区域常规", rate: 0.1 },
  257. { ch: "partner", ref: 0, ent: 4, layer: "区域常规", rate: 0.05 },
  258. ],
  259. /* 应扣除成本项是全局清单,不挂在客户或订阅名下:一条只描述这项成本本身,客户与订阅上不录入、不勾选。
  260. deduct 是是否从分成基数中扣除:勾选的按摊销额从基数中扣除;不勾选的本期只做登记,
  261. 设备采买与项目费用约定的固定金额直接记入分成结果属会议约定的口径,本期不实现。
  262. calc 是计算方式:每客户按客户整体计一次,每账号按该客户在期分账号数逐账号计,
  263. 每份按数量逐份摊销(amount 是单份的摊销额,份数取套餐档上这条随附成本项的 qty),用于成本随数量走的项目,
  264. 例如国家 IP 地址与国际云主机按每个 IP / 每台云主机摊一份。
  265. repeat 是周期:本期只有「每月」一个取值,逐月摊销计入;一次性取值待固定金额记入口径沟通确定后再加。
  266. 线路投入按约定比例分成、不扣基数,不登记为成本项;临时成本增补不建数据。
  267. 某客户本月计入哪几笔由其在用订阅引用的套餐档随附成本项决定(见 packages.costs),出账时冻结成该期的成本快照。 */
  268. costs: [
  269. { kind: "国际资源", name: "国家 IP 地址月摊销", amount: 50, repeat: "每月", calc: "每份", deduct: true },
  270. { kind: "国际资源", name: "国际云主机月摊销", amount: 30, repeat: "每月", calc: "每份", deduct: true },
  271. { kind: "国际资源", name: "国际出口带宽月摊销", amount: 80, repeat: "每月", calc: "每账号", deduct: true },
  272. { kind: "项目费用", name: "园区机房改造项目月摊销", amount: 1200, repeat: "每月", calc: "每客户", deduct: false },
  273. ],
  274. /* 客户应收结算记录:一条 = 一份生效订阅 × 一个自然月,是计费的原始依据。
  275. shares 每条带 ch / ref 标明该笔分成的分成方,对账明细与对账批次即按此围绕分成方展开;
  276. 「未配置,计 0」的占位行不带 ch / ref,不进对账。 */
  277. settlements: [
  278. {
  279. enterprise: 0, sub: 1, month: "2026-03", days: 12, monthDays: 31, partial: true, std: 120, amount: 46.45, tail: false, exact: 46.45,
  280. costs: [], base: 46.45,
  281. shares: [
  282. { ch: "operator", ref: 0, who: "联通", mode: "按总金额比例", rate: 0.2, amount: 9.29 },
  283. { ch: "team", ref: 0, who: "华东常规运维", mode: "按总客户账号数", per: 50, accounts: 5, amount: 112.90 },
  284. { ch: "team", ref: 1, who: "沪东施工", mode: "按总金额比例", rate: 0.05, amount: 2.32 },
  285. { ch: "partner", ref: 0, who: "邹合", mode: "按总金额比例", rate: 0.05, amount: 2.32 },
  286. ],
  287. attrs: "联通 / 邹合(华东) / 华东常规运维 / 沪东施工",
  288. },
  289. {
  290. enterprise: 0, sub: 1, month: "2026-04", days: 30, monthDays: 30, partial: false, std: 120, amount: 120, tail: false, exact: 120,
  291. costs: [], base: 120,
  292. shares: [
  293. { ch: "operator", ref: 0, who: "联通", mode: "按总金额比例", rate: 0.2, amount: 24 },
  294. { ch: "team", ref: 0, who: "华东常规运维", mode: "按总客户账号数", per: 50, accounts: 5, amount: 250 },
  295. { ch: "team", ref: 1, who: "沪东施工", mode: "按总金额比例", rate: 0.05, amount: 6 },
  296. { ch: "partner", ref: 0, who: "邹合", mode: "按总金额比例", rate: 0.05, amount: 6 },
  297. ],
  298. attrs: "联通 / 邹合(华东) / 华东常规运维 / 沪东施工",
  299. },
  300. {
  301. enterprise: 0, sub: 1, month: "2026-09", days: 30, monthDays: 30, partial: false, std: 120, amount: 120, tail: false, exact: 120,
  302. costs: [], base: 120,
  303. shares: [
  304. { ch: "operator", ref: 0, who: "联通", mode: "按总金额比例", rate: 0.2, amount: 24 },
  305. { ch: "team", ref: 0, who: "华东常规运维", mode: "按总客户账号数", per: 50, accounts: 5, amount: 250 },
  306. { ch: "team", ref: 1, who: "沪东施工", mode: "按总金额比例", rate: 0.05, amount: 6 },
  307. { ch: "partner", ref: 0, who: "邹合", mode: "按总金额比例", rate: 0.05, amount: 6 },
  308. ],
  309. attrs: "联通 / 邹合(华东) / 华东常规运维 / 沪东施工",
  310. },
  311. {
  312. enterprise: 3, sub: 4, month: "2026-09", days: 30, monthDays: 30, partial: false, std: 480, amount: 480, tail: false, exact: 480,
  313. costs: [{ name: "国家 IP 地址月摊销", amount: 50 }], base: 430,
  314. shares: [
  315. { ch: "operator", ref: 2, who: "移动", mode: "按总金额比例", rate: 0.15, amount: 64.5 },
  316. { ch: "team", ref: 0, who: "华东常规运维", mode: "按总金额比例", rate: 0.1, amount: 43 },
  317. { ch: "team", ref: 1, who: "沪东施工", mode: "按总金额比例", rate: 0.05, amount: 21.5 },
  318. { ch: "partner", ref: 1, who: "何南", mode: "合同增补 · 比例", rate: 0.08, amount: 34.4 },
  319. ],
  320. attrs: "移动 / 何南(华南) / 华东常规运维 / 沪东施工",
  321. },
  322. {
  323. enterprise: 3, sub: 5, month: "2026-09", days: 30, monthDays: 30, partial: false, std: 160, amount: 160, tail: false, exact: 160,
  324. costs: [{ name: "国际云主机月摊销", amount: 30 }], base: 130,
  325. shares: [
  326. { ch: "operator", ref: 2, who: "移动", mode: "按总金额比例", rate: 0.15, amount: 19.5 },
  327. { ch: "team", ref: 0, who: "华东常规运维", mode: "按总金额比例", rate: 0.1, amount: 13 },
  328. { ch: "team", ref: 1, who: "沪东施工", mode: "按总金额比例", rate: 0.05, amount: 6.5 },
  329. { ch: "partner", ref: 1, who: "何南", mode: "合同增补 · 比例", rate: 0.08, amount: 10.4 },
  330. ],
  331. attrs: "移动 / 何南(华南) / 华东常规运维 / 沪东施工(叠加订阅各算各的;叠加增值不占分账号额度)",
  332. },
  333. {
  334. enterprise: 4, sub: 6, month: "2026-09", days: 30, monthDays: 30, partial: false, std: 160, amount: 160, tail: true, exact: 160,
  335. costs: [{ name: "国家 IP 地址月摊销", amount: 40 }], base: 120,
  336. shares: [
  337. { ch: "operator", ref: 0, who: "联通", mode: "按总金额比例", rate: 0.2, amount: 24 },
  338. { ch: "team", ref: 0, who: "华东常规运维", mode: "按总金额比例", rate: 0.1, amount: 12 },
  339. { who: "沪东施工(未配置,计 0)", mode: "—", rate: 0, amount: 0 },
  340. { ch: "partner", ref: 0, who: "邹合", mode: "按总金额比例", rate: 0.05, amount: 6 },
  341. ],
  342. attrs: "联通 / 邹合(华东) / 华东常规运维 / 无施工团队",
  343. },
  344. ],
  345. /* 对账批次:一条 = 一个分成方 × 一个已结束自然月。对账是与分成方(运营商 / 合伙人 / 运维团队)进行的,
  346. 不是与客户,故批次只挂 ch / ref(分成方类型与档案下标),客户与该分成方的对应关系逐条落在 rows 指向的
  347. 应收结算记录里。同一个结算记录会同时进入多个分成方的批次(各算各的)。
  348. 运营商按档案上的对账日出批次(无覆盖时按系统默认对账日),合伙人与运维团队按系统默认对账日出批次。 */
  349. batches: [
  350. { no: "DZ-20261005-LT", day: "2026-10-05", month: "2026-09", ch: "operator", ref: 0, trigger: "自动", status: "已执行", by: "系统", at: "2026-10-05 06:00", rows: [2, 5], warning: "" },
  351. { no: "DZ-20261008-YD", day: "2026-10-08", month: "2026-09", ch: "operator", ref: 2, trigger: "自动", status: "已执行", by: "系统", at: "2026-10-08 06:00", rows: [3, 4], warning: "" },
  352. { no: "DZ-20261005-ZH", day: "2026-10-05", month: "2026-09", ch: "partner", ref: 0, trigger: "自动", status: "已执行", by: "系统", at: "2026-10-05 06:00", rows: [2, 5], warning: "" },
  353. { no: "DZ-20261005-YW0", day: "2026-10-05", month: "2026-09", ch: "team", ref: 0, trigger: "自动", status: "已执行", by: "系统", at: "2026-10-05 06:00", rows: [2, 3, 4, 5], warning: "" },
  354. { no: "DZ-20261005-SG1", day: "2026-10-05", month: "2026-09", ch: "team", ref: 1, trigger: "自动", status: "已执行", by: "系统", at: "2026-10-05 06:00", rows: [2, 3, 4], warning: "海岚跨境未挂施工团队,该分成方本月不计分成" },
  355. { no: "DZ-20260905-DX", day: "2026-09-05", month: "2026-08", ch: "operator", ref: 1, trigger: "自动", status: "已打回", by: "系统", at: "2026-09-05 06:00", rows: [], warning: "分成比例误录,运营商尚未付款" },
  356. { no: "DZ-20260912-DX-R", day: "2026-09-12", month: "2026-08", ch: "operator", ref: 1, trigger: "人工", status: "已执行", by: "林管", at: "2026-09-12 10:20", rows: [], warning: "打回后重做,新明细成为 8 月唯一有效分成" },
  357. { no: "DZ-20260605-LT", day: "2026-06-05", month: "2026-05", ch: "operator", ref: 0, trigger: "自动", status: "执行失败", by: "系统", at: "2026-06-05 06:00", rows: [], warning: "对账任务异常中断,等待人工补跑" },
  358. { no: "DZ-20260905-HN", day: "2026-09-05", month: "2026-08", ch: "partner", ref: 1, trigger: "自动", status: "已执行", by: "系统", at: "2026-09-05 06:00", rows: [], warning: "何南(华南渠道)8 月尚无生效分成规则,本批 0 条明细" },
  359. ],
  360. /* 客户批量导入批次(见需求规格说明 4.8):一次上传一个文件生成一个批次,批次号贯穿行级结果、续传与按批次导出。
  361. rows 每行记 line 行编号、cells 模板 14 列原文、status 成功 / 失败、reason 失败原因、
  362. ent 导入生成的客户下标(未成功为 null)。行级明细持久保留,是续传与按批次导出的依据;批次不删除、不撤销。 */
  363. importBatches: [
  364. {
  365. no: "IMP-2026-0001", file: "闵行区客户建档-20261008.csv", by: "林管", at: "2026-10-08 10:05",
  366. status: "已完成",
  367. rows: [
  368. { line: "1", cells: ["1", "海岚跨境电商(上海)", "企业", "周岚", "021-54002023", "上海市闵行区申长路 988 号 3 号楼 5 层", "闵行区", "联通", "邹合", "华东常规运维", "", "跨境办公 · 独立 IP 档", "hlkjdssh", ""], status: "成功", reason: "", ent: 4 },
  369. ],
  370. },
  371. {
  372. no: "IMP-2026-0002", file: "临港与张江客户-20261012.csv", by: "周运营", at: "2026-10-12 09:40",
  373. status: "有失败待续传",
  374. rows: [
  375. { line: "1", cells: ["1", "临港跨境贸易", "企业", "陆港", "021-66002008", "上海市浦东新区环湖西二路 800 号 A 座 11 层", "临港新片区", "电信", "", "华东常规运维", "", "", "lgkjmy", ""], status: "成功", reason: "", ent: 1 },
  376. { line: "2", cells: ["2", "澄澜科技有限公司", "企业", "沈澄", "021-66001001", "上海市浦东新区金港路 300 号 6 号楼 3 层", "浦东新区", "联通", "邹合", "华东常规运维", "", "跨境办公 · 标准档", "", ""], status: "失败", reason: "客户名称与已有客户「澄澜科技有限公司」(KL-2026-0001)重复,不覆盖已有客户", ent: null },
  377. { line: "3", cells: ["3", "张江芯创半导体", "企业", "何工", "021-50003301", "上海市浦东新区祖冲之路 887 号 2 号楼", "张江区", "联通", "", "华东常规运维", "", "", "", "13900000331"], status: "失败", reason: "所挂区域「张江区」匹配不到,填区域名称原文且需在负责范围内", ent: null },
  378. { line: "4", cells: ["4", "陆家嘴外贸服务中心", "个体工商户", "王经理", "021-58002277", "上海市浦东新区世纪大道 100 号 18 层", "浦东新区", "联通", "", "华东常规运维", "", "", "clkj", ""], status: "失败", reason: "主账号登录名 clkj 已被占用,系统不自动加后缀,请改写后重新上传", ent: null },
  379. ],
  380. },
  381. ],
  382. notes: [
  383. { level: "严重", bill: "澄澜科技 2026-03", text: "3 月比例曾按 0.18 录入,核验后从 4 月起改为 0.20。3 月账单已递交运营商,原明细保留不改。", by: "林管", at: "2026-04-06 09:30" },
  384. { level: "严重", bill: "电信 2026-08 对账批次(DZ-20260905-DX)", text: "批次分成比例误录,运营商尚未付款,批次打回重做;重做批次 DZ-20260912-DX-R 核验通过。", by: "林管", at: "2026-09-12 10:15" },
  385. ],
  386. feedback: [
  387. { no: "KL-UNKNOWN-3", action: "开户", date: "2026-10-11", state: "nomatch", result: "主体号匹配不到任何待执行记录,待人工处理。不自动创建客户,不改账户状态。", handled: false },
  388. { no: "KL-2026-0008", action: "开户", date: "2026-10-14", state: "pending", result: "匹配到待执行记录 A-20261007-08,反馈实际开通日 2026-10-14,可据此回填(与人工回填等效)。", handled: false, actionId: "A-20261007-08", fillDate: "2026-10-14" },
  389. { no: "KL-2026-0019", action: "开户", date: "2026-10-13", state: "conflict", result: "该客户开户记录已于 2026-06-01 回填成功,反馈与现状冲突,不覆盖,待人工确认。", handled: false },
  390. ],
  391. collections: [
  392. { partner: 0, enterprise: 0, amount: 8000, date: "2026-04-18", note: "运营商已收,仅作区域核对,不回写应收" },
  393. ],
  394. /* 审计日志只追加。区域树维护仅总运营可见。 */
  395. auditLogs: [
  396. { at: "2026-08-01 09:12", by: "林管", type: "新建区域", object: "华东大区 / 上海市 / 浦东新区", before: "", after: "新建三级节点" },
  397. { at: "2026-08-01 09:20", by: "林管", type: "新建区域", object: "华东大区 / 上海市 / 临港新片区", before: "", after: "新建区县节点" },
  398. { at: "2026-08-02 14:02", by: "林管", type: "新建区域", object: "华东大区 / 苏州市 / 昆山市", before: "", after: "新建区县节点" },
  399. { at: "2026-08-05 10:40", by: "林管", type: "重命名区域", object: "华东大区 / 上海市 / 临港新片区", before: "南汇新城区", after: "临港新片区" },
  400. { at: "2026-08-10 10:20", by: "林管", type: "客户挂载", object: "澄澜科技有限公司", before: "未挂载", after: "华东大区 / 上海市 / 浦东新区" },
  401. { at: "2026-08-20 11:30", by: "林管", type: "客户改挂区域", object: "王敏", before: "华东大区 / 苏州市 / 昆山市", after: "华东大区 / 上海市 / 浦东新区" },
  402. { at: "2026-08-21 16:00", by: "林管", type: "合伙人负责范围首次配置", object: "邹合(华东渠道)", before: "(空)", after: "澄澜科技、临港跨境、陈阿福、王敏、海岚跨境(选定华东大区,含其下级全部客户)" },
  403. { at: "2026-09-02 09:10", by: "林管", type: "运维团队负责范围调整", object: "沪东施工", before: "澄澜科技、王敏", after: "澄澜科技、临港跨境、王敏(新增直接多选客户:临港跨境)" },
  404. { at: "2026-10-05 15:20", by: "林管", type: "合伙人负责范围调整", object: "何南(华南渠道)", before: "(空)", after: "天河区(暂无直属客户);直接多选客户:陈阿福" },
  405. { at: "2026-10-05 15:25", by: "林管", type: "分成规则新建", object: "何南(华南渠道)× 王敏", before: "(无规则,分成计 0)", after: "合同增补 · 按总金额比例 0.08" },
  406. { at: "2026-10-05 06:00", by: "系统", type: "对账批次自动执行", object: "DZ-20261005-LT · 联通 · 2026-09", before: "待执行", after: "已执行(2 条明细)" },
  407. ],
  408. /* 登录账号:login 为登录名,acctStatus 在用 / 停用(停用的不出现在「换身份」列表),
  409. mustChange 为下次登录是否必须改密,pwdResetOn 为最近一次重置密码日期。
  410. role=operator 是运营商的对账查看账号(只读),与运营商档案一比一。
  411. builtin: true 为系统内置账号:总运营账号即总运营团队的默认主账号,必须存在、不能删除,主账号身份也不可转交。
  412. phone 为绑定手机号:选填,可更换,但全站唯一(一个手机号至多绑定一个账号),
  413. 绑定后可用手机号代替登录名登录;未填时只能用登录名登录。
  414. 客户主账号不用初始密码,改用一次性激活码激活(acctOpenOn 开通日、claimOn 当前码生成日、
  415. claimExpireOn 有效期截止日:导出交付时才写,未交付为空、不判过期、claimStatus 未激活 / 已激活 /
  416. 已过期;已激活时 claimCode 置空)。 */
  417. users: [
  418. { name: "林管", role: "admin", regTeam: 0, primary: true, builtin: true, title: "总运营团队主账号", phone: "13900000001", acctStatus: "在用", mustChange: false },
  419. { name: "周运营", role: "regAdmin", regTeam: 1, primary: true, title: "华东运营 · 团队主账号", login: "zhouyun@example", phone: "13900000101", acctStatus: "在用", mustChange: false, pwdResetOn: "2026-09-20" },
  420. { name: "许芸", role: "regAdmin", regTeam: 1, title: "华东运营 · 子账号(客户建档)", login: "xuyun@example", acctStatus: "在用", mustChange: true, pwdResetOn: "2026-10-09" },
  421. { name: "吴队", role: "teamLead", team: 0, title: "华东常规运维 · 团队主账号", login: "wudui@example", phone: "13900000103", acctStatus: "在用", mustChange: false, pwdResetOn: "2026-09-06" },
  422. { name: "周宁", role: "ops", member: 0, title: "常规运维 · 开停回填", login: "zhouning@example", phone: "13900000104", acctStatus: "在用", mustChange: false, pwdResetOn: "2026-09-18" },
  423. { name: "孙队", role: "teamLead", team: 1, title: "沪东施工 · 团队主账号", login: "sundui@example", phone: "13900000105", acctStatus: "在用", mustChange: false, pwdResetOn: "2026-09-02" },
  424. { name: "赵工", role: "worker", member: 2, title: "施工人员", login: "zhaogong@example", phone: "13900000106", acctStatus: "在用", mustChange: false, pwdResetOn: "2026-09-21" },
  425. { name: "陈录", role: "entry", member: 4, title: "录入人员 · 电信/移动 ICT 代录", login: "chenlu@example", acctStatus: "在用", mustChange: false, pwdResetOn: "2026-09-25" },
  426. /* 客户主账号登录名取客户名称的拼音首字母(见《需求规格说明》3.2),不照抄中文客户名称。
  427. 激活状态只有三种,样例:未激活且已交付还在有效期内(临港)、已激活(澄澜)、
  428. 截止日已过按当天即时判为已过期(陈阿福、海岚,导出时会自动重置出新码)、
  429. 刚建档还没导出交付(王敏,没有截止日、不判过期) */
  430. { name: "澄澜科技有限公司", role: "enterprise", enterprise: 0, title: "客户主账号", login: "clkj", phone: "13900000200", acctStatus: "在用", mustChange: false, pwdResetOn: "2026-09-11", acctOpenOn: "2026-09-11", claimStatus: "已激活", claimCode: "", claimOn: "2026-09-11", claimExpireOn: "2026-09-25" },
  431. { name: "临港跨境贸易", role: "enterprise", enterprise: 1, title: "客户主账号", login: "lgkjmy", acctStatus: "在用", mustChange: false, acctOpenOn: "2026-10-12", claimStatus: "未激活", claimCode: "KQF7HRM2XW", claimOn: "2026-10-12", claimExpireOn: "2026-10-26" },
  432. { name: "陈阿福", role: "enterprise", enterprise: 2, title: "客户主账号", login: "caf", phone: "13900000212", acctStatus: "在用", mustChange: false, acctOpenOn: "2026-09-20", claimStatus: "未激活", claimCode: "TBW4KJN6QD", claimOn: "2026-09-20", claimExpireOn: "2026-10-04" },
  433. { name: "王敏", role: "enterprise", enterprise: 3, title: "客户主账号", login: "wm", acctStatus: "在用", mustChange: false, acctOpenOn: "2026-10-15", claimStatus: "未激活", claimCode: "PMXZ3RTV8H", claimOn: "2026-10-15", claimExpireOn: "" },
  434. { name: "海岚跨境电商(上海)", role: "enterprise", enterprise: 4, title: "客户主账号", login: "hlkjdssh", acctStatus: "在用", mustChange: false, acctOpenOn: "2026-10-08", claimStatus: "未激活", claimCode: "GHY2NQSC5F", claimOn: "2026-10-08", claimExpireOn: "2026-10-13" },
  435. { name: "张敏", role: "sub", enterprise: 0, account: 0, title: "下属分账号" },
  436. { name: "邹合", role: "partner", partner: 0, title: "华东渠道", login: "zouhe@example", phone: "13900000107", acctStatus: "在用", mustChange: false, pwdResetOn: "2026-09-12" },
  437. { name: "何南", role: "partner", partner: 1, title: "华南渠道", login: "henan@example", phone: "13900000108", acctStatus: "停用", mustChange: false, pwdResetOn: "2026-08-05" },
  438. { name: "联通对账", role: "operator", operator: 0, title: "联通 · 对账查看账号", login: "unicom-dz@example", phone: "13900000109", acctStatus: "在用", mustChange: false, pwdResetOn: "2026-09-26" },
  439. ],
  440. };
  441. function cloneSeed() {
  442. return JSON.parse(JSON.stringify(SEED));
  443. }
  444. function money(n) {
  445. return Number(n || 0).toLocaleString("zh-CN", { minimumFractionDigits: 2, maximumFractionDigits: 2 });
  446. }
  447. function pct(n) {
  448. const v = Math.round(Number(n || 0) * 10000) / 100;
  449. return String(v) + "%";
  450. }
  451. function daysBetween(start, end) {
  452. const a = new Date(start + "T00:00:00");
  453. const b = new Date(end + "T00:00:00");
  454. return Math.round((b - a) / 86400000) + 1;
  455. }
  456. function addDays(date, n) {
  457. const d = new Date(date + "T00:00:00");
  458. d.setDate(d.getDate() + n);
  459. const pad = (x) => String(x).padStart(2, "0");
  460. return d.getFullYear() + "-" + pad(d.getMonth() + 1) + "-" + pad(d.getDate());
  461. }
  462. function overdueAction(action) {
  463. if (!action || action.status !== "待执行") return false;
  464. const limit = action.extendUntil || addDays(action.created, 7);
  465. return TODAY > limit;
  466. }
  467. function unfinished(db, memberIndex) {
  468. return db.tickets.filter((t) => t.assignee === memberIndex && (t.status === "待处理" || t.status === "处理中")).length;
  469. }
  470. function ticketTypeOfTeam(team) {
  471. return team.type === "施工" ? "施工" : "常规";
  472. }
  473. function eligible(db, ticket) {
  474. const team = db.teams[ticket.team];
  475. const need = ticketTypeOfTeam(team);
  476. return db.members
  477. .map((m, index) => ({ ...m, index }))
  478. .filter((m) => m.team === ticket.team && m.type === need && m.scope.includes(ticket.enterprise));
  479. }
  480. function pickEven(db, ticket) {
  481. const list = eligible(db, ticket);
  482. if (!list.length) return null;
  483. list.sort((a, b) => unfinished(db, a.index) - unfinished(db, b.index) || a.index - b.index);
  484. return list[0].index;
  485. }
  486. /* ---- 区域与范围工具 ---- */
  487. function regionNode(db, id) {
  488. return db.regions.find((r) => r.id === id) || null;
  489. }
  490. function regionPath(db, id) {
  491. const names = [];
  492. let cur = regionNode(db, id);
  493. while (cur) {
  494. names.unshift(cur.name);
  495. cur = cur.parent ? regionNode(db, cur.parent) : null;
  496. }
  497. return names.join(" / ");
  498. }
  499. function descendantIds(db, id) {
  500. const out = [id];
  501. let added = true;
  502. while (added) {
  503. added = false;
  504. db.regions.forEach((r) => {
  505. if (r.parent && out.includes(r.parent) && !out.includes(r.id)) {
  506. out.push(r.id);
  507. added = true;
  508. }
  509. });
  510. }
  511. return out;
  512. }
  513. function enterprisesUnderRegion(db, id) {
  514. const ids = new Set(descendantIds(db, id));
  515. return db.enterprises.map((e, i) => i).filter((i) => ids.has(db.enterprises[i].region));
  516. }
  517. function scopeEnterpriseSet(db, scope) {
  518. const set = new Set();
  519. (scope.regions || []).forEach((rid) => enterprisesUnderRegion(db, rid).forEach((i) => set.add(i)));
  520. (scope.enterprises || []).forEach((i) => set.add(i));
  521. return set;
  522. }
  523. function scopeEnterprises(db, scope) {
  524. return Array.from(scopeEnterpriseSet(db, scope)).sort((a, b) => a - b);
  525. }
  526. function scopeSummary(db, scope) {
  527. const parts = [];
  528. (scope.regions || []).forEach((rid) => {
  529. const n = regionNode(db, rid);
  530. if (n) parts.push(`${n.name}(含下级 ${enterprisesUnderRegion(db, rid).length} 家客户)`);
  531. });
  532. const fromRegion = new Set();
  533. (scope.regions || []).forEach((rid) => enterprisesUnderRegion(db, rid).forEach((i) => fromRegion.add(i)));
  534. const extra = (scope.enterprises || []).filter((i) => !fromRegion.has(i));
  535. if (extra.length) parts.push(`直接多选:${extra.map((i) => db.enterprises[i].name).join("、")}`);
  536. return parts.length ? parts.join(";") : "(空)";
  537. }
  538. function regionReferenced(db, id) {
  539. const refs = [];
  540. db.teams.forEach((t, i) => { if ((t.scope.regions || []).includes(id)) refs.push(`运维团队「${t.name}」负责范围`); });
  541. db.partners.forEach((p, i) => {
  542. if (p.region === id) refs.push(`合伙人「${p.name}」所属区域`);
  543. if ((p.scope.regions || []).includes(id)) refs.push(`合伙人「${p.name}」负责范围`);
  544. });
  545. db.operators.forEach((o) => { if (o.region === id) refs.push(`运营商「${o.name}」所属区域`); });
  546. db.regOpsTeams.forEach((t) => { if (t.region === id) refs.push(`运营团队「${t.name}」所属区域`); });
  547. return refs;
  548. }