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