data.js 32 KB

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