data.js 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482
  1. /* 模拟数据只存在于页面内存。内部下标从 0 开始,页面上的序号从 1 开始。 */
  2. const TODAY = "2026-10-15";
  3. /* 区域三级:大区 / 市 / 区县。客户可挂在任一层,只能挂一个节点。 */
  4. const LEVEL_NAMES = ["大区", "市", "区县"];
  5. const SEED = {
  6. setting: { defaultReconcileDay: 5, perAccountFee: 80 },
  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. operators: [
  21. { name: "联通", region: "sh", reconcileDay: null, payCycle: "按月", notify: "notice@unicorn.example" },
  22. { name: "电信", region: "east", reconcileDay: null, payCycle: "按年", notify: "notice@ict-telecom.example" },
  23. { name: "移动", region: "east", reconcileDay: 8, payCycle: "按月", notify: "notice@mobile.example" },
  24. { name: "广东电信", region: "south", reconcileDay: null, payCycle: "按季度", notify: "notice@gd-ict.example" },
  25. { name: "苏州移动", region: "su", reconcileDay: 12, payCycle: "按季度", notify: "notice@sz-mobile.example" },
  26. { name: "广州移动", region: "gz", reconcileDay: null, payCycle: "按月", notify: "notice@gz-mobile.example" },
  27. ],
  28. partners: [
  29. { name: "邹合", region: "east", title: "华东渠道", notify: "zouhe@example", scope: { regions: ["east"], enterprises: [] } },
  30. { name: "何南", region: "gz", title: "华南渠道", notify: "henan@example", scope: { regions: ["th"], enterprises: [2] } },
  31. ],
  32. teams: [
  33. { name: "华东常规运维", type: "常规", mode: "手工", scope: { regions: ["sh", "su"], enterprises: [] } },
  34. { name: "沪东施工", type: "施工", mode: "自动平均", scope: { regions: ["pd"], enterprises: [1] } },
  35. ],
  36. /* hq: true 为系统内置的总运营团队:不限所属区域(region 为空),负责范围覆盖全国,列表置顶且不可删除。
  37. 该团队的默认主账号即总运营账号(见 users 中 builtin: true 的一条),不再另设运营团队账号。 */
  38. regOpsTeams: [
  39. { name: "总运营团队", region: "", hq: true, scope: { regions: ["east", "south"], enterprises: [] }, desc: "总部平台级团队,不限所属区域,覆盖全国全部客户" },
  40. { name: "华东运营", region: "east", scope: { regions: ["east"], enterprises: [] }, desc: "覆盖华东大区全部下挂客户" },
  41. { name: "华南运营", region: "south", scope: { regions: ["south"], enterprises: [] }, desc: "覆盖华南大区全部下挂客户" },
  42. { name: "上海运营", region: "sh", scope: { regions: ["sh"], enterprises: [] }, desc: "覆盖上海市及其下级区域" },
  43. ],
  44. members: [
  45. { name: "周宁", team: 0, type: "常规", scope: [0, 1, 2, 4] },
  46. { name: "李可", team: 0, type: "常规", scope: [0, 3, 4] },
  47. { name: "赵工", team: 1, type: "施工", scope: [0, 1, 3] },
  48. { name: "钱工", team: 1, type: "施工", scope: [0, 1, 3] },
  49. { name: "陈录", team: 0, type: "录入", scope: [0, 1, 2, 3, 4] },
  50. ],
  51. awards: [
  52. { member: 2, at: "2026-09-20", kind: "奖励", text: "浦东园区割接提前 1 天完成,客户零投诉", amount: 200 },
  53. { member: 2, at: "2026-10-11", kind: "扣罚", text: "临港上门未按约定时间到达,扣罚只作考核,费用在线下处理", amount: -100 },
  54. ],
  55. enterprises: [
  56. {
  57. no: "KL-2026-0001",
  58. name: "澄澜科技有限公司",
  59. subject: "企业",
  60. materials: "营业执照、客户名称、合同、电话",
  61. files: ["oss://materials/KL-2026-0001/营业执照.pdf", "oss://materials/KL-2026-0001/受理单.pdf"],
  62. phone: "021-66001001",
  63. region: "pd",
  64. operator: 0,
  65. partner: 0,
  66. teams: { 常规: 0, 施工: 1 },
  67. status: "在用",
  68. quota: 5,
  69. costSel: [],
  70. history: [
  71. { at: "2026-08-10 10:20", field: "挂载区域", before: "未挂载", after: "华东大区 / 上海市 / 浦东新区", by: "林管" },
  72. { at: "2026-03-20 16:40", field: "账户状态", before: "未开通", after: "在用(实际开通日 2026-03-20)", by: "周宁回填" },
  73. ],
  74. },
  75. {
  76. no: "KL-2026-0008",
  77. name: "临港跨境贸易",
  78. subject: "企业",
  79. materials: "营业执照、客户名称、合同、电话",
  80. files: ["oss://materials/KL-2026-0008/营业执照.pdf", "oss://materials/KL-2026-0008/ICT合同.pdf"],
  81. phone: "021-66002008",
  82. region: "lg",
  83. operator: 1,
  84. partner: null,
  85. teams: { 常规: 0 },
  86. status: "未开通",
  87. quota: 8,
  88. costSel: [],
  89. history: [
  90. { at: "2026-09-02 09:05", field: "挂载区域", before: "未挂载", after: "华东大区 / 上海市 / 临港新片区", by: "林管" },
  91. ],
  92. },
  93. {
  94. no: "KL-2026-0012",
  95. name: "陈阿福",
  96. subject: "个体工商户",
  97. materials: "身份证、手机号",
  98. files: ["oss://materials/KL-2026-0012/身份证.jpg"],
  99. phone: "13800001112",
  100. region: "ks",
  101. operator: 2,
  102. partner: 1,
  103. teams: { 常规: 0 },
  104. status: "在用",
  105. quota: 1,
  106. costSel: [],
  107. history: [
  108. { at: "2026-08-28 14:10", field: "挂载区域", before: "未挂载", after: "华东大区 / 苏州市 / 昆山市", by: "林管" },
  109. ],
  110. },
  111. {
  112. no: "KL-2026-0019",
  113. name: "王敏",
  114. subject: "个人",
  115. materials: "身份证、手机号",
  116. files: ["oss://materials/KL-2026-0019/身份证.jpg"],
  117. phone: "13900001019",
  118. region: "pd",
  119. operator: 2,
  120. partner: 1,
  121. teams: { 常规: 0, 施工: 1 },
  122. status: "在用",
  123. quota: 2,
  124. costSel: [1, 2],
  125. history: [
  126. { at: "2026-08-20 11:30", field: "挂载区域", before: "华东大区 / 苏州市 / 昆山市", after: "华东大区 / 上海市 / 浦东新区", by: "林管" },
  127. { at: "2026-08-20 11:32", field: "合伙人", before: "无", after: "何南(华南渠道,直接多选客户)", by: "林管" },
  128. ],
  129. },
  130. {
  131. no: "KL-2026-0023",
  132. name: "海岚跨境电商(上海)",
  133. subject: "企业",
  134. materials: "营业执照、客户名称、合同、电话",
  135. files: ["oss://materials/KL-2026-0023/营业执照.pdf", "oss://materials/KL-2026-0023/续约合同.pdf"],
  136. phone: "021-54002023",
  137. region: "mh",
  138. operator: 0,
  139. partner: 0,
  140. teams: { 常规: 0 },
  141. status: "在用",
  142. quota: 2,
  143. costSel: [3],
  144. history: [
  145. { at: "2026-09-12 15:00", field: "挂载区域", before: "未挂载", after: "华东大区 / 上海市 / 闵行区", by: "林管" },
  146. { at: "2025-10-01 10:00", field: "账户状态", before: "未开通", after: "在用(实际开通日 2025-10-01)", by: "周宁回填" },
  147. ],
  148. },
  149. ],
  150. packages: [
  151. { name: "跨境带宽基础版", yearPrice: 9600, monthPrice: 800, quota: 3, bw: "50Mbps", custom: null },
  152. { name: "跨境带宽标准版", yearPrice: 12000, monthPrice: 1000, quota: 5, bw: "100Mbps", custom: null },
  153. { name: "跨境带宽尊享版", yearPrice: 24000, monthPrice: 2000, quota: 10, bw: "200Mbps", custom: null },
  154. { name: "国际资源叠加包", yearPrice: 3600, monthPrice: 300, quota: 0, bw: "30Mbps", custom: null },
  155. { name: "临港 ICT 定制套餐", yearPrice: 24000, monthPrice: 2000, quota: 8, bw: "150Mbps", custom: 1 },
  156. ],
  157. subs: [
  158. { enterprise: 0, name: "跨境带宽基础版", kind: "升级前", status: "已到期", start: "2025-03-18", end: "2026-03-17", yearPrice: 9600, monthPrice: 800, openedOn: "2025-03-20", contractNo: "HT-CL-20250318", files: ["oss://contracts/HT-CL-20250318.pdf"] },
  159. { enterprise: 0, name: "跨境带宽标准版", kind: "正式", status: "生效中", start: "2026-03-18", end: "2027-03-17", yearPrice: 12000, monthPrice: 1000, openedOn: "2026-03-20", contractNo: "HT-CL-20260318", files: ["oss://contracts/HT-CL-20260318.pdf"] },
  160. { 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"] },
  161. { enterprise: 2, name: "跨境带宽基础版", kind: "正式", status: "生效中", start: "2026-09-01", end: "2026-10-31", yearPrice: 9600, monthPrice: 800, openedOn: "2026-09-01", contractNo: "HT-CFA-20260901", files: ["oss://contracts/HT-CFA-20260901.pdf"] },
  162. { enterprise: 3, name: "跨境带宽标准版", kind: "正式", status: "生效中", start: "2026-06-01", end: "2027-05-31", yearPrice: 12000, monthPrice: 1000, openedOn: "2026-06-01", contractNo: "HT-WM-20260601", files: ["oss://contracts/HT-WM-20260601.pdf"] },
  163. { enterprise: 3, name: "国际资源叠加包", kind: "叠加", status: "生效中", start: "2026-08-01", end: "2027-07-31", yearPrice: 3600, monthPrice: 300, openedOn: "2026-08-01", contractNo: "HT-WM-20260801", files: ["oss://contracts/HT-WM-20260801.pdf"] },
  164. { enterprise: 4, name: "跨境带宽标准版", kind: "正式", status: "已到期", start: "2025-10-01", end: "2026-09-30", yearPrice: 12000, monthPrice: 1000, openedOn: "2025-10-01", contractNo: "HT-HL-20251001", files: ["oss://contracts/HT-HL-20251001.pdf"] },
  165. { enterprise: 4, name: "跨境带宽标准版(续订)", kind: "正式", status: "待生效", start: "2026-11-01", end: "2027-10-31", yearPrice: 12000, monthPrice: 1000, openedOn: null, contractNo: "HT-HL-20261101", files: ["oss://contracts/HT-HL-20261101.pdf"] },
  166. ],
  167. accounts: [
  168. { enterprise: 0, name: "张敏", status: "在用", usage: "正式", openedOn: "2026-03-20" },
  169. { enterprise: 0, name: "李航", status: "在用", usage: "正式", openedOn: "2026-03-20" },
  170. { enterprise: 0, name: "联调测试", status: "在用", usage: "测试", openedOn: "2026-04-01" },
  171. { enterprise: 0, name: "待开通席位", status: "未开通", usage: "正式", openedOn: null },
  172. { enterprise: 1, name: "临港-财务", status: "未开通", usage: "正式", openedOn: null },
  173. { enterprise: 1, name: "临港-关务", status: "未开通", usage: "正式", openedOn: null },
  174. { enterprise: 3, name: "王敏本人", status: "在用", usage: "正式", openedOn: "2026-06-01" },
  175. { enterprise: 4, name: "海岚-小王", status: "在用", usage: "正式", openedOn: "2025-10-01" },
  176. ],
  177. /* 开停记录与工单一一对应;状态:待执行 / 执行成功 / 执行失败 */
  178. actions: [
  179. { id: "A-20261007-08", enterprise: 1, type: "开户", status: "待执行", ticket: 0, created: "2026-10-07", doneOn: null, extendUntil: null, by: null },
  180. { id: "A-20261009-23", enterprise: 4, type: "到期停机", status: "待执行", ticket: 7, created: "2026-10-09", doneOn: null, extendUntil: null, by: null },
  181. ],
  182. tickets: [
  183. { type: "开户", enterprise: 1, account: null, team: 0, assignee: null, status: "待处理", created: "2026-10-07", text: "合同套餐已建立,网络侧尚未开通。本工单只开通客户本身,不含下属分账号;分账号在套餐订阅时按额度对齐开通。", logs: ["2026-10-07 生成待执行开户记录(A-20261007-08)"], closeReason: null, materials: [] },
  184. { 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: [] },
  185. { type: "故障", enterprise: 0, account: null, team: 1, assignee: null, status: "待处理", created: "2026-10-14", text: "机房侧线路需要现场复查(现场施工类)。", logs: ["2026-10-14 常规团队转施工团队,尚未分派"], closeReason: null, materials: [] },
  186. { 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"] },
  187. { type: "故障", enterprise: 3, account: null, team: 1, assignee: 2, status: "待处理", created: "2026-10-13", text: "上门后用户不在,待再次上门。", logs: ["2026-10-13 分派给赵工"], closeReason: null, materials: [] },
  188. { type: "售后", enterprise: 0, account: null, team: 0, assignee: 1, status: "已完成", created: "2026-09-28", text: "补充开通说明并回传配置手册。", logs: ["2026-09-29 李可填写处理记录并完成"], closeReason: null, materials: [] },
  189. { 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: [] },
  190. { 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: [] },
  191. { 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: [] },
  192. ],
  193. /* 分成规则挂在渠道与客户的关系上,两种方式二选一:按总金额比例(rate,0-1)或按总客户账号数(per,每账号分成金额,精确到分)。
  194. mode 缺省为按总金额比例。两层都没有时分成计 0。合同增补优先于区域常规。 */
  195. rules: [
  196. { ch: "operator", ref: 0, ent: 0, layer: "区域常规", rate: 0.2 },
  197. { ch: "team", ref: 0, ent: 0, layer: "合同增补", mode: "按总客户账号数", per: 50 },
  198. { ch: "team", ref: 1, ent: 0, layer: "区域常规", rate: 0.05 },
  199. { ch: "partner", ref: 0, ent: 0, layer: "区域常规", rate: 0.05 },
  200. { ch: "operator", ref: 2, ent: 3, layer: "区域常规", rate: 0.15 },
  201. { ch: "team", ref: 0, ent: 3, layer: "区域常规", rate: 0.1 },
  202. { ch: "team", ref: 1, ent: 3, layer: "区域常规", rate: 0.05 },
  203. { ch: "partner", ref: 1, ent: 3, layer: "合同增补", rate: 0.08 },
  204. { ch: "operator", ref: 0, ent: 4, layer: "区域常规", rate: 0.2 },
  205. { ch: "team", ref: 0, ent: 4, layer: "区域常规", rate: 0.1 },
  206. { ch: "partner", ref: 0, ent: 4, layer: "区域常规", rate: 0.05 },
  207. ],
  208. /* 应扣除成本:线路投入不扣基数;国际资源按摊销扣;项目费用一次性。设备同一项目只选比例或固定金额之一。
  209. costSel 记该客户勾选要计入分成基数扣除的成本项下标;未勾选的成本项本月不扣。 */
  210. costs: [
  211. { ent: 0, sub: 1, kind: "国际资源", name: "国际出口带宽月摊销", amount: 80, repeat: "每月" },
  212. { ent: 3, sub: 4, kind: "国际资源", name: "国家 IP 地址月摊销", amount: 50, repeat: "每月" },
  213. { ent: 3, sub: 5, kind: "国际资源", name: "国际云主机月摊销", amount: 30, repeat: "每月" },
  214. { ent: 4, sub: 6, kind: "国际资源", name: "国家 IP 地址月摊销", amount: 40, repeat: "每月" },
  215. ],
  216. settlements: [
  217. {
  218. enterprise: 0, sub: 1, month: "2026-03", days: 12, monthDays: 31, partial: true, std: 1000, amount: 387.1, tail: false, exact: 387.1,
  219. costs: [], base: 387.1,
  220. shares: [
  221. { who: "联通", mode: "按总金额比例", rate: 0.2, amount: 77.42 },
  222. { who: "华东常规运维", mode: "按总客户账号数", per: 50, accounts: 2, amount: 38.71 },
  223. { who: "沪东施工", mode: "按总金额比例", rate: 0.05, amount: 19.36 },
  224. { who: "华东合伙人", mode: "按总金额比例", rate: 0.05, amount: 19.36 },
  225. ],
  226. opsFee: 61.94, acctDays: [{ name: "张敏", days: 12, fee: 30.97 }, { name: "李航", days: 12, fee: 30.97 }],
  227. attrs: "联通 / 邹合(华东) / 华东常规运维 / 沪东施工", batch: null,
  228. },
  229. {
  230. enterprise: 0, sub: 1, month: "2026-04", days: 30, monthDays: 30, partial: false, std: 1000, amount: 1000, tail: false, exact: 1000,
  231. costs: [], base: 1000,
  232. shares: [
  233. { who: "联通", mode: "按总金额比例", rate: 0.2, amount: 200 },
  234. { who: "华东常规运维", mode: "按总客户账号数", per: 50, accounts: 2, amount: 100 },
  235. { who: "沪东施工", mode: "按总金额比例", rate: 0.05, amount: 50 },
  236. { who: "华东合伙人", mode: "按总金额比例", rate: 0.05, amount: 50 },
  237. ],
  238. opsFee: 160, acctDays: [{ name: "张敏", days: 30, fee: 80 }, { name: "李航", days: 30, fee: 80 }],
  239. attrs: "联通 / 邹合(华东) / 华东常规运维 / 沪东施工", batch: null,
  240. },
  241. {
  242. enterprise: 0, sub: 1, month: "2026-09", days: 30, monthDays: 30, partial: false, std: 1000, amount: 1000, tail: false, exact: 1000,
  243. costs: [], base: 1000,
  244. shares: [
  245. { who: "联通", mode: "按总金额比例", rate: 0.2, amount: 200 },
  246. { who: "华东常规运维", mode: "按总客户账号数", per: 50, accounts: 2, amount: 100 },
  247. { who: "沪东施工", mode: "按总金额比例", rate: 0.05, amount: 50 },
  248. { who: "华东合伙人", mode: "按总金额比例", rate: 0.05, amount: 50 },
  249. ],
  250. opsFee: 160, acctDays: [{ name: "张敏", days: 30, fee: 80 }, { name: "李航", days: 30, fee: 80 }],
  251. attrs: "联通 / 邹合(华东) / 华东常规运维 / 沪东施工", batch: 0,
  252. },
  253. {
  254. enterprise: 3, sub: 4, month: "2026-09", days: 30, monthDays: 30, partial: false, std: 1000, amount: 1000, tail: false, exact: 1000,
  255. costs: [{ name: "国家 IP 地址月摊销", amount: 50 }], base: 950,
  256. shares: [
  257. { who: "移动", mode: "按总金额比例", rate: 0.15, amount: 142.5 },
  258. { who: "华东常规运维", mode: "按总金额比例", rate: 0.1, amount: 95 },
  259. { who: "沪东施工", mode: "按总金额比例", rate: 0.05, amount: 47.5 },
  260. { who: "华南合伙人", mode: "合同增补 · 比例", rate: 0.08, amount: 76 },
  261. ],
  262. opsFee: 80, acctDays: [{ name: "王敏本人", days: 30, fee: 80 }],
  263. attrs: "移动 / 何南(华南) / 华东常规运维 / 沪东施工", batch: 1,
  264. },
  265. {
  266. enterprise: 3, sub: 5, month: "2026-09", days: 30, monthDays: 30, partial: false, std: 300, amount: 300, tail: false, exact: 300,
  267. costs: [{ name: "国际云主机月摊销", amount: 30 }], base: 270,
  268. shares: [
  269. { who: "移动", mode: "按总金额比例", rate: 0.15, amount: 40.5 },
  270. { who: "华东常规运维", mode: "按总金额比例", rate: 0.1, amount: 27 },
  271. { who: "沪东施工", mode: "按总金额比例", rate: 0.05, amount: 13.5 },
  272. { who: "华南合伙人", mode: "合同增补 · 比例", rate: 0.08, amount: 21.6 },
  273. ],
  274. opsFee: 0, acctDays: [],
  275. attrs: "移动 / 何南(华南) / 华东常规运维 / 沪东施工(叠加订阅各算各的)", batch: 1,
  276. },
  277. {
  278. enterprise: 4, sub: 6, month: "2026-09", days: 30, monthDays: 30, partial: false, std: 1000, amount: 1000, tail: true, exact: 1000,
  279. costs: [{ name: "国家 IP 地址月摊销", amount: 40 }], base: 960,
  280. shares: [
  281. { who: "联通", mode: "按总金额比例", rate: 0.2, amount: 192 },
  282. { who: "华东常规运维", mode: "按总金额比例", rate: 0.1, amount: 96 },
  283. { who: "沪东施工(未配置,计 0)", mode: "—", rate: 0, amount: 0 },
  284. { who: "华东合伙人", mode: "按总金额比例", rate: 0.05, amount: 48 },
  285. ],
  286. opsFee: 80, acctDays: [{ name: "海岚-小王", days: 30, fee: 80 }],
  287. attrs: "联通 / 邹合(华东) / 华东常规运维 / 无施工团队", batch: 0,
  288. },
  289. ],
  290. scopes: [
  291. { kind: "运营商", ref: 0, enabled: true },
  292. { kind: "运营商", ref: 1, enabled: true },
  293. { kind: "运营商", ref: 2, enabled: true },
  294. { kind: "合伙人", ref: 0, enabled: true },
  295. { kind: "合伙人", ref: 1, enabled: false },
  296. { kind: "运维", ref: 0, enabled: true },
  297. { kind: "运维", ref: 1, enabled: false },
  298. ],
  299. batches: [
  300. { no: "PC-20261005-LT", day: "2026-10-05", month: "2026-09", scope: "联通 · 运营商范围", trigger: "自动", status: "已执行", by: "系统", at: "2026-10-05 06:00", rows: [2, 5], warning: "" },
  301. { no: "PC-20261008-YD", day: "2026-10-08", month: "2026-09", scope: "移动 · 运营商范围", trigger: "自动", status: "已执行", by: "系统", at: "2026-10-08 06:00", rows: [3, 4], warning: "" },
  302. { no: "PC-20260905-DX", day: "2026-09-05", month: "2026-08", scope: "电信 · 运营商范围", trigger: "自动", status: "已打回", by: "系统", at: "2026-09-05 06:00", rows: [], warning: "分成比例误录,运营商尚未付款" },
  303. { no: "PC-20260912-DX-R", day: "2026-09-12", month: "2026-08", scope: "电信 · 运营商范围", trigger: "人工", status: "已执行", by: "林管", at: "2026-09-12 10:20", rows: [], warning: "打回后重做,新明细成为 8 月唯一有效应收" },
  304. { no: "PC-20260605-LT", day: "2026-06-05", month: "2026-05", scope: "联通 · 运营商范围", trigger: "自动", status: "执行失败", by: "系统", at: "2026-06-05 06:00", rows: [], warning: "出账任务异常中断,等待人工补跑" },
  305. ],
  306. notes: [
  307. { level: "严重", bill: "澄澜科技 2026-03", text: "3 月比例曾按 0.18 录入,核验后从 4 月起改为 0.20。3 月账单已递交运营商,原明细保留不改。", by: "林管", at: "2026-04-06 09:30" },
  308. { level: "严重", bill: "电信范围 2026-08(PC-20260905-DX)", text: "批次分成比例误录,运营商尚未付款,批次打回重做;重做批次 PC-20260912-DX-R 核验通过。", by: "林管", at: "2026-09-12 10:15" },
  309. ],
  310. feedback: [
  311. { no: "KL-UNKNOWN-3", action: "开户", date: "2026-10-11", state: "nomatch", result: "主体号匹配不到任何待执行记录,待人工处理。不自动创建客户,不改账户状态。", handled: false },
  312. { 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" },
  313. { no: "KL-2026-0019", action: "开户", date: "2026-10-13", state: "conflict", result: "该客户开户记录已于 2026-06-01 回填成功,反馈与现状冲突,不覆盖,待人工确认。", handled: false },
  314. ],
  315. collections: [
  316. { partner: 0, enterprise: 0, amount: 8000, date: "2026-04-18", note: "运营商已收,仅作区域核对,不回写应收" },
  317. ],
  318. /* 审计日志只追加。区域树维护仅总运营可见。 */
  319. auditLogs: [
  320. { at: "2026-08-01 09:12", by: "林管", type: "新建区域", object: "华东大区 / 上海市 / 浦东新区", before: "", after: "新建三级节点" },
  321. { at: "2026-08-01 09:20", by: "林管", type: "新建区域", object: "华东大区 / 上海市 / 临港新片区", before: "", after: "新建区县节点" },
  322. { at: "2026-08-02 14:02", by: "林管", type: "新建区域", object: "华东大区 / 苏州市 / 昆山市", before: "", after: "新建区县节点" },
  323. { at: "2026-08-05 10:40", by: "林管", type: "重命名区域", object: "华东大区 / 上海市 / 临港新片区", before: "南汇新城区", after: "临港新片区" },
  324. { at: "2026-08-10 10:20", by: "林管", type: "客户挂载", object: "澄澜科技有限公司", before: "未挂载", after: "华东大区 / 上海市 / 浦东新区" },
  325. { at: "2026-08-20 11:30", by: "林管", type: "客户改挂区域", object: "王敏", before: "华东大区 / 苏州市 / 昆山市", after: "华东大区 / 上海市 / 浦东新区" },
  326. { at: "2026-08-21 16:00", by: "林管", type: "合伙人负责范围首次配置", object: "邹合(华东渠道)", before: "(空)", after: "澄澜科技、临港跨境、陈阿福、王敏、海岚跨境(选定华东大区,含其下级全部客户)" },
  327. { at: "2026-09-02 09:10", by: "林管", type: "运维团队负责范围调整", object: "沪东施工", before: "澄澜科技、王敏", after: "澄澜科技、临港跨境、王敏(新增直接多选客户:临港跨境)" },
  328. { at: "2026-10-05 15:20", by: "林管", type: "合伙人负责范围调整", object: "何南(华南渠道)", before: "(空)", after: "天河区(暂无直属客户);直接多选客户:陈阿福" },
  329. { at: "2026-10-05 15:25", by: "林管", type: "结算范围启用", object: "合伙人范围 · 何南(华南渠道)", before: "未启用", after: "未启用(拟首次应收后再启用)" },
  330. ],
  331. /* 登录账号:login 为登录名,acctStatus 在用 / 停用(停用的不出现在「换身份」列表),
  332. mustChange 为下次登录是否必须改密,pwdResetOn 为最近一次重置密码日期。
  333. role=operator 是运营商的对账查看账号(只读),与运营商档案一比一。
  334. builtin: true 为系统内置账号:总运营账号即总运营团队的默认主账号,必须存在、不能删除,主账号身份也不可转交。
  335. phone 为绑定手机号:选填,可更换,但全站唯一(一个手机号至多绑定一个账号),
  336. 绑定后可用手机号代替登录名登录;未填时只能用登录名登录。 */
  337. users: [
  338. { name: "林管", role: "admin", regTeam: 0, primary: true, builtin: true, title: "总运营团队主账号", phone: "13900000001", acctStatus: "在用", mustChange: false },
  339. { name: "周运营", role: "regAdmin", regTeam: 1, primary: true, title: "华东运营 · 团队主账号", login: "zhouyun@example", phone: "13900000101", acctStatus: "在用", mustChange: false, pwdResetOn: "2026-09-20" },
  340. { name: "许芸", role: "regAdmin", regTeam: 1, title: "华东运营 · 子账号(客户建档)", login: "xuyun@example", acctStatus: "在用", mustChange: true, pwdResetOn: "2026-10-09" },
  341. { name: "郑南", role: "regAdmin", regTeam: 2, primary: true, title: "华南运营 · 团队主账号", login: "zhengnan@example", phone: "13900000102", acctStatus: "在用", mustChange: false, pwdResetOn: "2026-08-28" },
  342. { name: "吴队", role: "teamLead", team: 0, title: "华东常规运维 · 团队主账号", login: "wudui@example", phone: "13900000103", acctStatus: "在用", mustChange: false, pwdResetOn: "2026-09-06" },
  343. { name: "周宁", role: "ops", member: 0, title: "常规运维 · 开停回填", login: "zhouning@example", phone: "13900000104", acctStatus: "在用", mustChange: false, pwdResetOn: "2026-09-18" },
  344. { name: "孙队", role: "teamLead", team: 1, title: "沪东施工 · 团队主账号", login: "sundui@example", phone: "13900000105", acctStatus: "在用", mustChange: false, pwdResetOn: "2026-09-02" },
  345. { name: "赵工", role: "worker", member: 2, title: "施工人员", login: "zhaogong@example", phone: "13900000106", acctStatus: "在用", mustChange: false, pwdResetOn: "2026-09-21" },
  346. { name: "陈录", role: "entry", member: 4, title: "录入人员 · 电信/移动 ICT 代录", login: "chenlu@example", acctStatus: "在用", mustChange: false, pwdResetOn: "2026-09-25" },
  347. { name: "澄澜科技有限公司", role: "enterprise", enterprise: 0, title: "客户主账号", login: "chenglan-keji", phone: "13900000200", acctStatus: "在用", mustChange: false, pwdResetOn: "2026-09-11" },
  348. { name: "张敏", role: "sub", enterprise: 0, account: 0, title: "下属分账号" },
  349. { name: "邹合", role: "partner", partner: 0, title: "华东渠道", login: "zouhe@example", phone: "13900000107", acctStatus: "在用", mustChange: false, pwdResetOn: "2026-09-12" },
  350. { name: "何南", role: "partner", partner: 1, title: "华南渠道", login: "henan@example", phone: "13900000108", acctStatus: "停用", mustChange: false, pwdResetOn: "2026-08-05" },
  351. { name: "联通对账", role: "operator", operator: 0, title: "联通 · 对账查看账号", login: "unicom-dz@example", phone: "13900000109", acctStatus: "在用", mustChange: false, pwdResetOn: "2026-09-26" },
  352. ],
  353. };
  354. function cloneSeed() {
  355. return JSON.parse(JSON.stringify(SEED));
  356. }
  357. function money(n) {
  358. return Number(n || 0).toLocaleString("zh-CN", { minimumFractionDigits: 2, maximumFractionDigits: 2 });
  359. }
  360. function pct(n) {
  361. const v = Math.round(Number(n || 0) * 10000) / 100;
  362. return String(v) + "%";
  363. }
  364. function daysBetween(start, end) {
  365. const a = new Date(start + "T00:00:00");
  366. const b = new Date(end + "T00:00:00");
  367. return Math.round((b - a) / 86400000) + 1;
  368. }
  369. function addDays(date, n) {
  370. const d = new Date(date + "T00:00:00");
  371. d.setDate(d.getDate() + n);
  372. const pad = (x) => String(x).padStart(2, "0");
  373. return d.getFullYear() + "-" + pad(d.getMonth() + 1) + "-" + pad(d.getDate());
  374. }
  375. function overdueAction(action) {
  376. if (!action || action.status !== "待执行") return false;
  377. const limit = action.extendUntil || addDays(action.created, 7);
  378. return TODAY > limit;
  379. }
  380. function unfinished(db, memberIndex) {
  381. return db.tickets.filter((t) => t.assignee === memberIndex && (t.status === "待处理" || t.status === "处理中")).length;
  382. }
  383. function ticketTypeOfTeam(team) {
  384. return team.type === "施工" ? "施工" : "常规";
  385. }
  386. function eligible(db, ticket) {
  387. const team = db.teams[ticket.team];
  388. const need = ticketTypeOfTeam(team);
  389. return db.members
  390. .map((m, index) => ({ ...m, index }))
  391. .filter((m) => m.team === ticket.team && m.type === need && m.scope.includes(ticket.enterprise));
  392. }
  393. function pickEven(db, ticket) {
  394. const list = eligible(db, ticket);
  395. if (!list.length) return null;
  396. list.sort((a, b) => unfinished(db, a.index) - unfinished(db, b.index) || a.index - b.index);
  397. return list[0].index;
  398. }
  399. /* ---- 区域与范围工具 ---- */
  400. function regionNode(db, id) {
  401. return db.regions.find((r) => r.id === id) || null;
  402. }
  403. function regionPath(db, id) {
  404. const names = [];
  405. let cur = regionNode(db, id);
  406. while (cur) {
  407. names.unshift(cur.name);
  408. cur = cur.parent ? regionNode(db, cur.parent) : null;
  409. }
  410. return names.join(" / ");
  411. }
  412. function descendantIds(db, id) {
  413. const out = [id];
  414. let added = true;
  415. while (added) {
  416. added = false;
  417. db.regions.forEach((r) => {
  418. if (r.parent && out.includes(r.parent) && !out.includes(r.id)) {
  419. out.push(r.id);
  420. added = true;
  421. }
  422. });
  423. }
  424. return out;
  425. }
  426. function enterprisesUnderRegion(db, id) {
  427. const ids = new Set(descendantIds(db, id));
  428. return db.enterprises.map((e, i) => i).filter((i) => ids.has(db.enterprises[i].region));
  429. }
  430. function scopeEnterpriseSet(db, scope) {
  431. const set = new Set();
  432. (scope.regions || []).forEach((rid) => enterprisesUnderRegion(db, rid).forEach((i) => set.add(i)));
  433. (scope.enterprises || []).forEach((i) => set.add(i));
  434. return set;
  435. }
  436. function scopeEnterprises(db, scope) {
  437. return Array.from(scopeEnterpriseSet(db, scope)).sort((a, b) => a - b);
  438. }
  439. function scopeSummary(db, scope) {
  440. const parts = [];
  441. (scope.regions || []).forEach((rid) => {
  442. const n = regionNode(db, rid);
  443. if (n) parts.push(`${n.name}(含下级 ${enterprisesUnderRegion(db, rid).length} 家客户)`);
  444. });
  445. const fromRegion = new Set();
  446. (scope.regions || []).forEach((rid) => enterprisesUnderRegion(db, rid).forEach((i) => fromRegion.add(i)));
  447. const extra = (scope.enterprises || []).filter((i) => !fromRegion.has(i));
  448. if (extra.length) parts.push(`直接多选:${extra.map((i) => db.enterprises[i].name).join("、")}`);
  449. return parts.length ? parts.join(";") : "(空)";
  450. }
  451. function regionReferenced(db, id) {
  452. const refs = [];
  453. db.teams.forEach((t, i) => { if ((t.scope.regions || []).includes(id)) refs.push(`运维团队「${t.name}」负责范围`); });
  454. db.partners.forEach((p, i) => {
  455. if (p.region === id) refs.push(`合伙人「${p.name}」所属区域`);
  456. if ((p.scope.regions || []).includes(id)) refs.push(`合伙人「${p.name}」负责范围`);
  457. });
  458. db.operators.forEach((o) => { if (o.region === id) refs.push(`运营商「${o.name}」所属区域`); });
  459. db.regOpsTeams.forEach((t) => { if (t.region === id) refs.push(`运营团队「${t.name}」所属区域`); });
  460. return refs;
  461. }