修改机构显示
This commit is contained in:
parent
2ac04ba97e
commit
e23ab0f6d3
@ -33,11 +33,12 @@ import { onLoad } from "@dcloudio/uni-app";
|
||||
import { storeToRefs } from "pinia";
|
||||
import useAccount from "@/store/account";
|
||||
import api from "@/utils/api";
|
||||
import { set } from "@/utils/cache";
|
||||
import { get, set } from "@/utils/cache";
|
||||
import { toast } from "@/utils/widget";
|
||||
import { normalizeCorpId } from "@/utils/api-base-config";
|
||||
import FullPage from "@/components/full-page.vue";
|
||||
|
||||
const HOME_CURRENT_TEAM_CACHE_KEY = "home-current-team-info";
|
||||
const RIGHTS_SELECTION_CACHE_KEY = "experience-coupon-rights-selection";
|
||||
const { account } = storeToRefs(useAccount());
|
||||
const { getTeams } = useAccount();
|
||||
@ -50,10 +51,6 @@ const currentCustomerId = ref("");
|
||||
const mode = ref("back");
|
||||
const target = ref("");
|
||||
|
||||
function pickCorpName(team = {}) {
|
||||
return team.licenseHospitalName || team.leaderCorp || team.corpName || "-";
|
||||
}
|
||||
|
||||
function maskMobile(mobile = "") {
|
||||
const value = String(mobile || "").trim();
|
||||
if (!value) return "";
|
||||
@ -77,16 +74,6 @@ function buildMetaText(customer = {}) {
|
||||
return parts.length ? parts.join(",") : "暂无档案信息";
|
||||
}
|
||||
|
||||
function dedupeByCorp(list = []) {
|
||||
const map = new Map();
|
||||
list.forEach((team) => {
|
||||
const corpId = normalizeCorpId(team.corpId);
|
||||
if (!corpId || map.has(corpId)) return;
|
||||
map.set(corpId, { ...team, corpId });
|
||||
});
|
||||
return Array.from(map.values());
|
||||
}
|
||||
|
||||
function buildTargetUrl(item) {
|
||||
const corp = encodeURIComponent(item.corpId || "");
|
||||
const team = encodeURIComponent(item.teamId || "");
|
||||
@ -120,34 +107,48 @@ async function loadArchives() {
|
||||
loading.value = true;
|
||||
try {
|
||||
const teams = (await getTeams()) || [];
|
||||
const corpTeams = dedupeByCorp(teams);
|
||||
const responses = await Promise.all(
|
||||
corpTeams.map(async (team) => {
|
||||
try {
|
||||
const res = await api("getMiniAppCustomers", { miniAppId, corpId: team.corpId }, false);
|
||||
const customers = res?.success && Array.isArray(res.data) ? res.data : [];
|
||||
return customers.map((customer) => ({ team, customer }));
|
||||
} catch (e) {
|
||||
console.warn(e);
|
||||
return [];
|
||||
}
|
||||
})
|
||||
const currentTeam = get(HOME_CURRENT_TEAM_CACHE_KEY) || {};
|
||||
const selectedCorpId = normalizeCorpId(currentTeam.corpId || currentCorpId.value);
|
||||
const selectedTeamId = currentTeam.teamId || currentTeamId.value;
|
||||
const selectedTeam = teams.find(
|
||||
(team) =>
|
||||
normalizeCorpId(team.corpId) === selectedCorpId &&
|
||||
(!selectedTeamId || team.teamId === selectedTeamId)
|
||||
);
|
||||
|
||||
const list = responses
|
||||
.flat()
|
||||
.map(({ team, customer }) => ({
|
||||
key: `${team.corpId}_${customer._id}`,
|
||||
corpId: team.corpId,
|
||||
teamId: team.teamId || "",
|
||||
if (!selectedCorpId || !selectedTeam) {
|
||||
options.value = [];
|
||||
return;
|
||||
}
|
||||
|
||||
const [corpRes, customerRes] = await Promise.all([
|
||||
api("getCorpInfo", { corpId: selectedCorpId }, false),
|
||||
api(
|
||||
"getTeamCustomers",
|
||||
{
|
||||
miniAppId,
|
||||
corpId: selectedCorpId,
|
||||
teamId: selectedTeam.teamId,
|
||||
},
|
||||
false
|
||||
),
|
||||
]);
|
||||
const corp = Array.isArray(corpRes?.data) ? corpRes.data[0] : null;
|
||||
const archiveCorpName = corp?.corp_name || corp?.corpName || "-";
|
||||
const customers = customerRes?.success && Array.isArray(customerRes.data) ? customerRes.data : [];
|
||||
const list = customers
|
||||
.map((customer) => ({
|
||||
key: `${selectedCorpId}_${customer._id}`,
|
||||
corpId: selectedCorpId,
|
||||
teamId: selectedTeam.teamId || "",
|
||||
customerId: customer._id || "",
|
||||
name: customer.name || "",
|
||||
relationship: customer.relationship || "",
|
||||
metaText: buildMetaText(customer),
|
||||
idCardText: maskIdCard(customer.idCard),
|
||||
corpName: pickCorpName(team),
|
||||
corpName: archiveCorpName,
|
||||
}))
|
||||
.filter((item) => item.corpId && item.customerId)
|
||||
.filter((item) => item.customerId)
|
||||
.sort((a, b) => {
|
||||
const aScore =
|
||||
(a.corpId === currentCorpId.value ? 4 : 0) +
|
||||
|
||||
@ -21,6 +21,7 @@ const urlsConfig = {
|
||||
recordBusinessCardBehavior: 'recordBusinessCardBehavior',
|
||||
getJoinedTeams: 'getJoinedTeams',
|
||||
getCorpBusinessCardStatus: 'getCorpBusinessCardStatus',
|
||||
getCorpInfo: 'getCorpInfo',
|
||||
},
|
||||
|
||||
knowledgeBase: {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user