修复数量不显示问题

This commit is contained in:
zhx 2026-05-12 20:08:48 +08:00
parent c39b9dc240
commit cb04a0fb23
7 changed files with 56 additions and 8 deletions

View File

@ -84,11 +84,13 @@ const rolePriority = {
bd: 3, bd: 3,
bdLeader: 4, bdLeader: 4,
freightAgent: 5, freightAgent: 5,
admin: 6 yumiManager: 6,
admin: 7
}; };
const roleDefaultPages = { const roleDefaultPages = {
admin: "/admin-center", admin: "/admin-center",
yumiManager: "/admin-center",
freightAgent: "/coin-seller", freightAgent: "/coin-seller",
agent: "/agency-center", agent: "/agency-center",
bdLeader: "/bd-leader-center", bdLeader: "/bd-leader-center",
@ -98,6 +100,19 @@ const roleDefaultPages = {
}; };
const rolePages = { const rolePages = {
yumiManager: [
"/admin-center",
"/invite-bd-leader",
"/invite-bd",
"/invite-recharge-agency",
"/invite-agency",
"/item-distribution",
"/my-BDLeader-teams",
"/my-BD-teams",
"/my-agency-teams",
"/my-recharge-agency",
"/admin-policy"
],
admin: [ admin: [
"/admin-center", "/admin-center",
"/invite-bd-leader", "/invite-bd-leader",
@ -416,6 +431,7 @@ function getIdentityRoles(identity) {
if (identity.bdLeader) roles.push("bdLeader"); if (identity.bdLeader) roles.push("bdLeader");
if (identity.bd) roles.push("bd"); if (identity.bd) roles.push("bd");
if (identity.anchor) roles.push("anchor"); if (identity.anchor) roles.push("anchor");
if (identity.yumi_manager || identity.yumiManager) roles.push("yumiManager");
if (identity.admin) roles.push("admin"); if (identity.admin) roles.push("admin");
return roles.length ? roles : ["guest"]; return roles.length ? roles : ["guest"];
} }

View File

@ -412,6 +412,7 @@ function calculateRoles(identity) {
if (identity.bdLeader) roles.push("bdLeader"); if (identity.bdLeader) roles.push("bdLeader");
if (identity.bd) roles.push("bd"); if (identity.bd) roles.push("bd");
if (identity.anchor) roles.push("anchor"); if (identity.anchor) roles.push("anchor");
if (identity.yumi_manager || identity.yumiManager) roles.push("yumiManager");
if (identity.admin) roles.push("admin"); if (identity.admin) roles.push("admin");
return roles.length ? roles : ["guest"]; return roles.length ? roles : ["guest"];
} }
@ -424,7 +425,8 @@ function getPrimaryRole(roles) {
bd: 3, bd: 3,
bdLeader: 4, bdLeader: 4,
freightAgent: 5, freightAgent: 5,
admin: 6 yumiManager: 6,
admin: 7
}; };
return roles.reduce((current, role) => (weight[role] > weight[current] ? role : current), "guest"); return roles.reduce((current, role) => (weight[role] > weight[current] ? role : current), "guest");
} }
@ -432,6 +434,7 @@ function getPrimaryRole(roles) {
function getDefaultPage(role) { function getDefaultPage(role) {
return { return {
admin: "/admin-center", admin: "/admin-center",
yumiManager: "/admin-center",
freightAgent: "/coin-seller", freightAgent: "/coin-seller",
agent: "/agency-center", agent: "/agency-center",
bdLeader: "/bd-leader-center", bdLeader: "/bd-leader-center",

View File

@ -242,6 +242,7 @@ function calculateRoles(identity) {
if (identity.bdLeader) roles.push("bdLeader"); if (identity.bdLeader) roles.push("bdLeader");
if (identity.bd) roles.push("bd"); if (identity.bd) roles.push("bd");
if (identity.anchor) roles.push("anchor"); if (identity.anchor) roles.push("anchor");
if (identity.yumi_manager || identity.yumiManager) roles.push("yumiManager");
if (identity.admin) roles.push("admin"); if (identity.admin) roles.push("admin");
return roles.length ? roles : ["guest"]; return roles.length ? roles : ["guest"];
} }
@ -254,7 +255,8 @@ function getPrimaryRole(roles) {
bd: 3, bd: 3,
bdLeader: 4, bdLeader: 4,
freightAgent: 5, freightAgent: 5,
admin: 6 yumiManager: 6,
admin: 7
}; };
return roles.reduce((current, role) => (weight[role] > weight[current] ? role : current), "guest"); return roles.reduce((current, role) => (weight[role] > weight[current] ? role : current), "guest");
} }
@ -262,6 +264,7 @@ function getPrimaryRole(roles) {
function getDefaultPage(role) { function getDefaultPage(role) {
return { return {
admin: "/admin-center", admin: "/admin-center",
yumiManager: "/admin-center",
freightAgent: "/coin-seller", freightAgent: "/coin-seller",
agent: "/agency-center", agent: "/agency-center",
bdLeader: "/bd-leader-center", bdLeader: "/bd-leader-center",

View File

@ -341,6 +341,8 @@
if (!identity) return false; if (!identity) return false;
return isTruthyIdentityValue(identity.agent) || return isTruthyIdentityValue(identity.agent) ||
isTruthyIdentityValue(identity.freightAgent) || isTruthyIdentityValue(identity.freightAgent) ||
isTruthyIdentityValue(identity.yumi_manager) ||
isTruthyIdentityValue(identity.yumiManager) ||
isTruthyIdentityValue(identity.admin); isTruthyIdentityValue(identity.admin);
} }

View File

@ -116,6 +116,6 @@
<div class="toast" id="toast" role="status" aria-live="polite" hidden></div> <div class="toast" id="toast" role="status" aria-live="polite" hidden></div>
</div> </div>
<script src="./script.js?v=20260429-0205" defer></script> <script src="./script.js?v=20260512-1830" defer></script>
</body> </body>
</html> </html>

View File

@ -369,6 +369,24 @@
return String(value); return String(value);
} }
function firstPresentValue(values) {
return values.find((value) => value !== null && value !== undefined && value !== "");
}
function firstPositiveCount(values) {
return values.find((value) => Number(value) > 0) ?? firstPresentValue(values);
}
function agencyCount(data, members = []) {
return firstPositiveCount([
data?.agencyNumber,
data?.bdHistoryCO?.agencyNumber,
data?.bdHistory?.agencyNumber,
data?.memberCount,
members.length
]);
}
function pickSpecialAccount(profile) { function pickSpecialAccount(profile) {
return profile?.ownSpecialId?.account || profile?.specialId?.account || profile?.specialAccount || profile?.shortAccount || profile?.shortId || ""; return profile?.ownSpecialId?.account || profile?.specialId?.account || profile?.specialAccount || profile?.shortAccount || profile?.shortId || "";
} }
@ -434,7 +452,7 @@
const members = Array.isArray(bill.memberBillList) ? bill.memberBillList : []; const members = Array.isArray(bill.memberBillList) ? bill.memberBillList : [];
const bdNumber = document.querySelector("#bdNumber"); const bdNumber = document.querySelector("#bdNumber");
const teamSalary = document.querySelector("#teamSalary"); const teamSalary = document.querySelector("#teamSalary");
if (bdNumber) bdNumber.textContent = formatCount(bill.memberCount ?? bill.bdNumber ?? members.length); if (bdNumber) bdNumber.textContent = formatCount(agencyCount(bill, members));
if (teamSalary) teamSalary.textContent = formatMoney(bill.totalSalary ?? bill.teamSalary ?? 0); if (teamSalary) teamSalary.textContent = formatMoney(bill.totalSalary ?? bill.teamSalary ?? 0);
renderMembers(members); renderMembers(members);
} }
@ -528,7 +546,13 @@
} }
function hasTeamListData(data) { function hasTeamListData(data) {
return Boolean(data && (Array.isArray(data.memberBillList) || data.memberCount !== undefined)); return Boolean(data && (
Array.isArray(data.memberBillList) ||
data.memberCount !== undefined ||
data.agencyNumber !== undefined ||
data?.bdHistoryCO?.agencyNumber !== undefined ||
data?.bdHistory?.agencyNumber !== undefined
));
} }
function createSummaryCell(label, value) { function createSummaryCell(label, value) {
@ -555,7 +579,7 @@
if (summary) { if (summary) {
const cells = type === "agency" const cells = type === "agency"
? [ ? [
createSummaryCell(message("agency_number"), formatCount(data.memberCount ?? members.length)), createSummaryCell(message("agency_number"), formatCount(agencyCount(data, members))),
createSummaryCell(message("team_salary"), `$${formatMoney(data.totalSalary || 0)}`), createSummaryCell(message("team_salary"), `$${formatMoney(data.totalSalary || 0)}`),
createSummaryCell(message("team_recharge"), `$${formatMoney(data.totalRecharge || 0)}`) createSummaryCell(message("team_recharge"), `$${formatMoney(data.totalRecharge || 0)}`)
] ]

File diff suppressed because one or more lines are too long