Compare commits
No commits in common. "1c3aca8700558681ad6047546319e282398e52a4" and "9d549afaa466f46a27b33948684c5444b8db8aee" have entirely different histories.
1c3aca8700
...
9d549afaa4
@ -174,6 +174,48 @@ function normalizeDigits(value) {
|
|||||||
return s.replace(/\D/g, '');
|
return s.replace(/\D/g, '');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isChinaMobile(value) {
|
||||||
|
const digits = normalizeDigits(value);
|
||||||
|
return /^1[3-9]\d{9}$/.test(digits);
|
||||||
|
}
|
||||||
|
|
||||||
|
function isLikelyArchiveNo(value) {
|
||||||
|
const s = normalizeText(value);
|
||||||
|
if (!s) return false;
|
||||||
|
if (/[\u4e00-\u9fa5]/.test(s)) return false; // 中文一般是姓名
|
||||||
|
if (isChinaMobile(s)) return false;
|
||||||
|
// 病案号一般为数字/字母组合(或纯数字)
|
||||||
|
return /^[0-9A-Za-z-]{3,}$/.test(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
function matchesAnyArchiveNo(patient, q) {
|
||||||
|
const needle = normalizeText(q).toLowerCase();
|
||||||
|
if (!needle) return false;
|
||||||
|
const values = [
|
||||||
|
patient?.customerNumber,
|
||||||
|
patient?.customerProfileNo2,
|
||||||
|
patient?.customerProfileNo3,
|
||||||
|
patient?.hospitalId,
|
||||||
|
].map((v) => normalizeText(v).toLowerCase()).filter(Boolean);
|
||||||
|
|
||||||
|
// 优先精确匹配
|
||||||
|
if (values.some((v) => v === needle)) return true;
|
||||||
|
// 兜底:包含匹配(部分医院病案号前后可能带前缀/后缀)
|
||||||
|
return values.some((v) => v.includes(needle));
|
||||||
|
}
|
||||||
|
|
||||||
|
function matchesAnyMobile(patient, q) {
|
||||||
|
const needle = normalizeDigits(q);
|
||||||
|
if (!needle) return false;
|
||||||
|
const mobiles = [
|
||||||
|
patient?.mobile,
|
||||||
|
...(Array.isArray(patient?.mobiles) ? patient.mobiles : []),
|
||||||
|
patient?.phone,
|
||||||
|
patient?.phone1,
|
||||||
|
].map(normalizeDigits).filter(Boolean);
|
||||||
|
return mobiles.some((m) => m === needle);
|
||||||
|
}
|
||||||
|
|
||||||
async function fetchList(params) {
|
async function fetchList(params) {
|
||||||
const res = await api('searchCorpCustomerForCaseList', params);
|
const res = await api('searchCorpCustomerForCaseList', params);
|
||||||
if (!res?.success) {
|
if (!res?.success) {
|
||||||
@ -212,11 +254,44 @@ const doSearch = useDebounce(async () => {
|
|||||||
const seq = (searchSeq.value += 1);
|
const seq = (searchSeq.value += 1);
|
||||||
searching.value = true;
|
searching.value = true;
|
||||||
try {
|
try {
|
||||||
|
if (isChinaMobile(q)) {
|
||||||
|
const digits = normalizeDigits(q);
|
||||||
const list = await fetchList({
|
const list = await fetchList({
|
||||||
corpId,
|
corpId,
|
||||||
userId,
|
userId,
|
||||||
teamId,
|
teamId,
|
||||||
keyword: q,
|
page: 1,
|
||||||
|
pageSize: 50,
|
||||||
|
mobile: digits,
|
||||||
|
});
|
||||||
|
if (seq !== searchSeq.value) return;
|
||||||
|
|
||||||
|
// 后端为包含匹配,这里做一次精确过滤,避免“部分号段”带来误命中
|
||||||
|
searchResultsRaw.value = list.filter((p) => matchesAnyMobile(p, digits));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isLikelyArchiveNo(q)) {
|
||||||
|
const list = await fetchList({
|
||||||
|
corpId,
|
||||||
|
userId,
|
||||||
|
teamId,
|
||||||
|
page: 1,
|
||||||
|
pageSize: 50,
|
||||||
|
archiveNo: q,
|
||||||
|
});
|
||||||
|
if (seq !== searchSeq.value) return;
|
||||||
|
|
||||||
|
// 兜底:后端字段不全时,仍然做一次本地匹配(包含 customerNumber/2/3)
|
||||||
|
searchResultsRaw.value = list.filter((p) => matchesAnyArchiveNo(p, q));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const list = await fetchList({
|
||||||
|
corpId,
|
||||||
|
userId,
|
||||||
|
teamId,
|
||||||
|
name: q,
|
||||||
page: 1,
|
page: 1,
|
||||||
pageSize: 50,
|
pageSize: 50,
|
||||||
});
|
});
|
||||||
|
|||||||
@ -7,7 +7,7 @@
|
|||||||
<FormTemplate v-if="temp" ref="formRef" :items="showItems" :form="forms" @change="onChange" />
|
<FormTemplate v-if="temp" ref="formRef" :items="showItems" :form="forms" @change="onChange" />
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="scroll-gap" />
|
<view style="height: 240rpx;"></view>
|
||||||
</scroll-view>
|
</scroll-view>
|
||||||
|
|
||||||
<view class="footer">
|
<view class="footer">
|
||||||
@ -301,6 +301,7 @@ async function remove() {
|
|||||||
.page {
|
.page {
|
||||||
min-height: 100vh;
|
min-height: 100vh;
|
||||||
background: #f5f6f8;
|
background: #f5f6f8;
|
||||||
|
padding-bottom: calc(152rpx + env(safe-area-inset-bottom));
|
||||||
}
|
}
|
||||||
.body {
|
.body {
|
||||||
height: 100vh;
|
height: 100vh;
|
||||||
@ -309,10 +310,6 @@ async function remove() {
|
|||||||
}
|
}
|
||||||
.scroll {
|
.scroll {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
min-height: 0;
|
|
||||||
}
|
|
||||||
.scroll-gap {
|
|
||||||
height: calc(240rpx + env(safe-area-inset-bottom));
|
|
||||||
}
|
}
|
||||||
.header {
|
.header {
|
||||||
background: #fff;
|
background: #fff;
|
||||||
|
|||||||
@ -2,19 +2,7 @@
|
|||||||
<view class="container">
|
<view class="container">
|
||||||
<!-- Header -->
|
<!-- Header -->
|
||||||
<view class="header">
|
<view class="header">
|
||||||
<picker
|
<view class="team-selector" @click="toggleTeamPopup">
|
||||||
v-if="useTeamPicker"
|
|
||||||
mode="selector"
|
|
||||||
:range="teamNameRange"
|
|
||||||
:value="teamPickerIndex"
|
|
||||||
@change="onTeamPickerChange"
|
|
||||||
>
|
|
||||||
<view class="team-selector">
|
|
||||||
<text class="team-name">{{ teamDisplay }}</text>
|
|
||||||
<text class="team-icon">⇌</text>
|
|
||||||
</view>
|
|
||||||
</picker>
|
|
||||||
<view v-else class="team-selector" @click="toggleTeamPopup">
|
|
||||||
<text class="team-name">{{ teamDisplay }}</text>
|
<text class="team-name">{{ teamDisplay }}</text>
|
||||||
<text class="team-icon">⇌</text>
|
<text class="team-icon">⇌</text>
|
||||||
</view>
|
</view>
|
||||||
@ -151,10 +139,6 @@ const currentTeam = ref(null);
|
|||||||
const currentTabKey = ref('all');
|
const currentTabKey = ref('all');
|
||||||
const scrollIntoId = ref('');
|
const scrollIntoId = ref('');
|
||||||
const teamGroups = ref([]);
|
const teamGroups = ref([]);
|
||||||
const useTeamPicker = computed(() => (Array.isArray(teams.value) ? teams.value.length : 0) > 6);
|
|
||||||
const teamNameRange = computed(() => (Array.isArray(teams.value) ? teams.value.map((t) => t?.name || '') : []));
|
|
||||||
const teamPickerIndex = ref(0);
|
|
||||||
const suppressTabReload = ref(false);
|
|
||||||
const tabs = computed(() => {
|
const tabs = computed(() => {
|
||||||
const base = [
|
const base = [
|
||||||
{ key: 'all', label: '全部', kind: 'all' },
|
{ key: 'all', label: '全部', kind: 'all' },
|
||||||
@ -200,18 +184,12 @@ const BATCH_CUSTOMER_IDS_KEY = 'ykt_case_batch_customer_ids';
|
|||||||
|
|
||||||
const page = ref(1);
|
const page = ref(1);
|
||||||
const pages = ref(0);
|
const pages = ref(0);
|
||||||
const pageSize = ref(200);
|
const pageSize = ref(50);
|
||||||
const totalFromApi = ref(0);
|
const totalFromApi = ref(0);
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
const rawPatients = ref([]);
|
const rawPatients = ref([]);
|
||||||
const more = computed(() => page.value < pages.value);
|
const more = computed(() => page.value < pages.value);
|
||||||
const currentTab = computed(() => tabs.value.find((t) => t.key === currentTabKey.value) || tabs.value[0]);
|
const currentTab = computed(() => tabs.value.find((t) => t.key === currentTabKey.value) || tabs.value[0]);
|
||||||
const lastTeamsLoadOk = ref(true);
|
|
||||||
const lastGroupsLoadOk = ref(true);
|
|
||||||
const lastPatientsLoadOk = ref(true);
|
|
||||||
const loadedGroupsTeamId = ref('');
|
|
||||||
let enterRefreshInflight = null;
|
|
||||||
const hasEnteredOnce = ref(false);
|
|
||||||
|
|
||||||
const accountStore = useAccountStore();
|
const accountStore = useAccountStore();
|
||||||
const { account, doctorInfo } = storeToRefs(accountStore);
|
const { account, doctorInfo } = storeToRefs(accountStore);
|
||||||
@ -220,92 +198,10 @@ const { withInfo } = useInfoCheck();
|
|||||||
|
|
||||||
const teamDisplay = computed(() => `${currentTeam.value?.name || ''}`);
|
const teamDisplay = computed(() => `${currentTeam.value?.name || ''}`);
|
||||||
|
|
||||||
watch(
|
|
||||||
[teams, currentTeam],
|
|
||||||
() => {
|
|
||||||
const list = Array.isArray(teams.value) ? teams.value : [];
|
|
||||||
const tid = currentTeam.value?.teamId ? String(currentTeam.value.teamId) : '';
|
|
||||||
const idx = tid ? list.findIndex((t) => String(t?.teamId || '') === tid) : -1;
|
|
||||||
teamPickerIndex.value = idx >= 0 ? idx : 0;
|
|
||||||
},
|
|
||||||
{ immediate: true }
|
|
||||||
);
|
|
||||||
|
|
||||||
function asArray(value) {
|
function asArray(value) {
|
||||||
return Array.isArray(value) ? value : [];
|
return Array.isArray(value) ? value : [];
|
||||||
}
|
}
|
||||||
|
|
||||||
function sleep(ms) {
|
|
||||||
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
||||||
}
|
|
||||||
|
|
||||||
async function getNetworkTypeSafe() {
|
|
||||||
try {
|
|
||||||
return await new Promise((resolve) => {
|
|
||||||
let done = false;
|
|
||||||
const timer = setTimeout(() => {
|
|
||||||
if (done) return;
|
|
||||||
done = true;
|
|
||||||
resolve('unknown');
|
|
||||||
}, 800);
|
|
||||||
|
|
||||||
uni.getNetworkType({
|
|
||||||
success: (res) => {
|
|
||||||
if (done) return;
|
|
||||||
done = true;
|
|
||||||
clearTimeout(timer);
|
|
||||||
resolve(String(res?.networkType || 'unknown'));
|
|
||||||
},
|
|
||||||
fail: () => {
|
|
||||||
if (done) return;
|
|
||||||
done = true;
|
|
||||||
clearTimeout(timer);
|
|
||||||
resolve('unknown');
|
|
||||||
},
|
|
||||||
});
|
|
||||||
});
|
|
||||||
} catch {
|
|
||||||
return 'unknown';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function pickPageSizeByNetwork(type) {
|
|
||||||
const t = String(type || '').toLowerCase();
|
|
||||||
if (t === '2g') return 100;
|
|
||||||
if (t === '3g') return 150;
|
|
||||||
if (t === '4g') return 250;
|
|
||||||
if (t === '5g' || t === 'wifi') return 300;
|
|
||||||
return 200;
|
|
||||||
}
|
|
||||||
|
|
||||||
async function apiWithRetry(urlId, data, showLoading = true, opts = {}) {
|
|
||||||
const retries = Number(opts?.retries ?? 1);
|
|
||||||
const baseDelay = Number(opts?.baseDelay ?? 350);
|
|
||||||
const shouldRetryMessage = (msg) =>
|
|
||||||
/timeout|timed out|超时|网络|network|fail|connect|ECONN|ENOTFOUND/i.test(String(msg || ''));
|
|
||||||
|
|
||||||
for (let i = 0; i <= retries; i += 1) {
|
|
||||||
try {
|
|
||||||
const res = await api(urlId, data, showLoading);
|
|
||||||
if (res?.success) return res;
|
|
||||||
const message = String(res?.message || '');
|
|
||||||
if (i < retries && shouldRetryMessage(message)) {
|
|
||||||
await sleep(Math.min(baseDelay * Math.pow(2, i), 1500));
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
} catch (e) {
|
|
||||||
if (i < retries) {
|
|
||||||
await sleep(Math.min(baseDelay * Math.pow(2, i), 1500));
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return { success: false, message: '请求失败' };
|
|
||||||
}
|
|
||||||
|
|
||||||
function normalizeUserId(value) {
|
function normalizeUserId(value) {
|
||||||
if (value === null || value === undefined) return '';
|
if (value === null || value === undefined) return '';
|
||||||
if (typeof value === 'object') {
|
if (typeof value === 'object') {
|
||||||
@ -765,24 +661,11 @@ async function loadGroups() {
|
|||||||
const teamId = getTeamId();
|
const teamId = getTeamId();
|
||||||
if (!corpId || !teamId) return;
|
if (!corpId || !teamId) return;
|
||||||
const projection = { _id: 1, groupName: 1, parentGroupId: 1, sortOrder: 1 };
|
const projection = { _id: 1, groupName: 1, parentGroupId: 1, sortOrder: 1 };
|
||||||
let res;
|
const res = await api('getGroups', { corpId, teamId, page: 1, pageSize: 1000, projection, countGroupMember: false });
|
||||||
try {
|
|
||||||
res = await apiWithRetry(
|
|
||||||
'getGroups',
|
|
||||||
{ corpId, teamId, page: 1, pageSize: 1000, projection, countGroupMember: false },
|
|
||||||
false,
|
|
||||||
{ retries: 1 }
|
|
||||||
);
|
|
||||||
} catch {
|
|
||||||
res = null;
|
|
||||||
}
|
|
||||||
if (!res?.success) {
|
if (!res?.success) {
|
||||||
lastGroupsLoadOk.value = false;
|
teamGroups.value = [];
|
||||||
if (!loadedGroupsTeamId.value || loadedGroupsTeamId.value !== teamId) teamGroups.value = [];
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
lastGroupsLoadOk.value = true;
|
|
||||||
loadedGroupsTeamId.value = teamId;
|
|
||||||
const list = Array.isArray(res.data) ? res.data : Array.isArray(res.data?.data) ? res.data.data : [];
|
const list = Array.isArray(res.data) ? res.data : Array.isArray(res.data?.data) ? res.data.data : [];
|
||||||
teamGroups.value = sortGroupList(list);
|
teamGroups.value = sortGroupList(list);
|
||||||
|
|
||||||
@ -1129,7 +1012,7 @@ function groupByLetter(list) {
|
|||||||
return letters.map((letter) => ({ letter, data: map.get(letter) || [] }));
|
return letters.map((letter) => ({ letter, data: map.get(letter) || [] }));
|
||||||
}
|
}
|
||||||
|
|
||||||
async function loadTeams(opts = {}) {
|
async function loadTeams() {
|
||||||
if (!doctorInfo.value && account.value?.openid) {
|
if (!doctorInfo.value && account.value?.openid) {
|
||||||
try {
|
try {
|
||||||
await getDoctorInfo();
|
await getDoctorInfo();
|
||||||
@ -1146,22 +1029,15 @@ async function loadTeams(opts = {}) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let res;
|
const res = await api('getTeamBymember', { corpId, corpUserId: userId });
|
||||||
try {
|
|
||||||
res = await apiWithRetry('getTeamBymember', { corpId, corpUserId: userId }, !opts?.silent, { retries: 2 });
|
|
||||||
} catch {
|
|
||||||
res = null;
|
|
||||||
}
|
|
||||||
if (!res?.success) {
|
if (!res?.success) {
|
||||||
lastTeamsLoadOk.value = false;
|
toast(res?.message || '获取团队失败');
|
||||||
if (!opts?.silent) toast(res?.message || '获取团队失败');
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const list = Array.isArray(res?.data) ? res.data : Array.isArray(res?.data?.data) ? res.data.data : [];
|
const list = Array.isArray(res?.data) ? res.data : Array.isArray(res?.data?.data) ? res.data.data : [];
|
||||||
const normalized = list.map(normalizeTeam).filter(Boolean);
|
const normalized = list.map(normalizeTeam).filter(Boolean);
|
||||||
teams.value = normalized;
|
teams.value = normalized;
|
||||||
lastTeamsLoadOk.value = true;
|
|
||||||
|
|
||||||
const saved = uni.getStorageSync(CURRENT_TEAM_STORAGE_KEY);
|
const saved = uni.getStorageSync(CURRENT_TEAM_STORAGE_KEY);
|
||||||
const savedTeamId = saved?.teamId ? String(saved.teamId) : '';
|
const savedTeamId = saved?.teamId ? String(saved.teamId) : '';
|
||||||
@ -1169,9 +1045,9 @@ async function loadTeams(opts = {}) {
|
|||||||
if (currentTeam.value) uni.setStorageSync(CURRENT_TEAM_STORAGE_KEY, currentTeam.value);
|
if (currentTeam.value) uni.setStorageSync(CURRENT_TEAM_STORAGE_KEY, currentTeam.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function reload(reset = true, opts = {}) {
|
async function reload(reset = true) {
|
||||||
if (!currentTeam.value) return false;
|
if (!currentTeam.value) return;
|
||||||
if (loading.value) return false;
|
if (loading.value) return;
|
||||||
|
|
||||||
await ensureDoctorForQuery();
|
await ensureDoctorForQuery();
|
||||||
const userId = getUserId();
|
const userId = getUserId();
|
||||||
@ -1182,27 +1058,19 @@ async function reload(reset = true, opts = {}) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const keepOnFail = Boolean(opts?.keepOnFail);
|
if (reset) {
|
||||||
const targetPage = reset ? 1 : page.value;
|
|
||||||
|
|
||||||
if (reset && !keepOnFail) {
|
|
||||||
page.value = 1;
|
page.value = 1;
|
||||||
rawPatients.value = [];
|
rawPatients.value = [];
|
||||||
pages.value = 0;
|
pages.value = 0;
|
||||||
totalFromApi.value = 0;
|
totalFromApi.value = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (reset) {
|
|
||||||
const net = await getNetworkTypeSafe();
|
|
||||||
pageSize.value = pickPageSizeByNetwork(net);
|
|
||||||
}
|
|
||||||
|
|
||||||
const query = {
|
const query = {
|
||||||
corpId,
|
corpId,
|
||||||
userId,
|
userId,
|
||||||
teamId,
|
teamId,
|
||||||
page: targetPage,
|
page: page.value,
|
||||||
pageSize: pageSize.value, // 按首字母排序时,按网络自适应加载数量
|
pageSize: 1000, // 按首字母排序时,一次加载更多数据以显示完整的字母分组
|
||||||
sortByFirstLetter: true, // 按姓名首字母排序
|
sortByFirstLetter: true, // 按姓名首字母排序
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1218,24 +1086,14 @@ async function reload(reset = true, opts = {}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
let res;
|
const res = await api('searchCorpCustomerForCaseList', query);
|
||||||
try {
|
|
||||||
res = await apiWithRetry('searchCorpCustomerForCaseList', query, !opts?.silent, { retries: 1 });
|
|
||||||
} catch {
|
|
||||||
res = null;
|
|
||||||
} finally {
|
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
}
|
|
||||||
|
|
||||||
if (!res?.success) {
|
if (!res?.success) {
|
||||||
lastPatientsLoadOk.value = false;
|
toast(res?.message || '获取患者列表失败');
|
||||||
if (!opts?.silent || (rawPatients.value || []).length === 0) toast(res?.message || '获取患者列表失败');
|
return;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (reset) page.value = 1;
|
|
||||||
lastPatientsLoadOk.value = true;
|
|
||||||
|
|
||||||
const payload =
|
const payload =
|
||||||
res && typeof res === 'object'
|
res && typeof res === 'object'
|
||||||
? res.data && typeof res.data === 'object' && !Array.isArray(res.data)
|
? res.data && typeof res.data === 'object' && !Array.isArray(res.data)
|
||||||
@ -1244,7 +1102,7 @@ async function reload(reset = true, opts = {}) {
|
|||||||
: {};
|
: {};
|
||||||
const list = Array.isArray(payload.list) ? payload.list : Array.isArray(payload.data) ? payload.data : [];
|
const list = Array.isArray(payload.list) ? payload.list : Array.isArray(payload.data) ? payload.data : [];
|
||||||
const next = list.map(formatPatient);
|
const next = list.map(formatPatient);
|
||||||
rawPatients.value = targetPage === 1 ? next : [...rawPatients.value, ...next];
|
rawPatients.value = page.value === 1 ? next : [...rawPatients.value, ...next];
|
||||||
// 补齐创建人/新增人姓名(部分创建人不在当前团队成员列表中)
|
// 补齐创建人/新增人姓名(部分创建人不在当前团队成员列表中)
|
||||||
void prefetchUserNamesFromPatients(next).catch(() => {});
|
void prefetchUserNamesFromPatients(next).catch(() => {});
|
||||||
pages.value = Number(payload.pages || 0) || 0;
|
pages.value = Number(payload.pages || 0) || 0;
|
||||||
@ -1258,8 +1116,6 @@ async function reload(reset = true, opts = {}) {
|
|||||||
totalFromApi.value ||
|
totalFromApi.value ||
|
||||||
0
|
0
|
||||||
) || (totalFromApi.value || 0);
|
) || (totalFromApi.value || 0);
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const handlePatientClick = (patient) => {
|
const handlePatientClick = (patient) => {
|
||||||
@ -1335,40 +1191,8 @@ const scrollToLetter = (letter) => {
|
|||||||
scrollIntoId.value = letterToDomId(letter);
|
scrollIntoId.value = letterToDomId(letter);
|
||||||
};
|
};
|
||||||
|
|
||||||
async function applyTeamSelection(nextTeam) {
|
|
||||||
if (!nextTeam) return;
|
|
||||||
const nextId = String(nextTeam?.teamId || '');
|
|
||||||
if (nextId && nextId === getTeamId()) return;
|
|
||||||
|
|
||||||
suppressTabReload.value = true;
|
|
||||||
try {
|
|
||||||
currentTeam.value = nextTeam;
|
|
||||||
if (currentTeam.value) uni.setStorageSync(CURRENT_TEAM_STORAGE_KEY, currentTeam.value);
|
|
||||||
currentTabKey.value = 'all';
|
|
||||||
|
|
||||||
await loadGroups();
|
|
||||||
await loadTeamMembers();
|
|
||||||
await reload(true);
|
|
||||||
} finally {
|
|
||||||
suppressTabReload.value = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function onTeamPickerChange(e) {
|
|
||||||
const prev = teamPickerIndex.value;
|
|
||||||
if (checkBatchMode()) {
|
|
||||||
teamPickerIndex.value = prev;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const idx = Number(e?.detail?.value ?? prev);
|
|
||||||
if (!Number.isFinite(idx)) return;
|
|
||||||
teamPickerIndex.value = idx;
|
|
||||||
await applyTeamSelection((Array.isArray(teams.value) ? teams.value : [])[idx]);
|
|
||||||
}
|
|
||||||
|
|
||||||
const toggleTeamPopup = () => {
|
const toggleTeamPopup = () => {
|
||||||
if (checkBatchMode()) return;
|
if (checkBatchMode()) return;
|
||||||
if (useTeamPicker.value) return;
|
|
||||||
if (!teams.value.length) {
|
if (!teams.value.length) {
|
||||||
toast('暂无可选团队');
|
toast('暂无可选团队');
|
||||||
return;
|
return;
|
||||||
@ -1376,7 +1200,12 @@ const toggleTeamPopup = () => {
|
|||||||
uni.showActionSheet({
|
uni.showActionSheet({
|
||||||
itemList: teams.value.map((i) => i.name),
|
itemList: teams.value.map((i) => i.name),
|
||||||
success: async (res) => {
|
success: async (res) => {
|
||||||
await applyTeamSelection(teams.value[res.tapIndex] || teams.value[0] || null);
|
currentTeam.value = teams.value[res.tapIndex] || teams.value[0] || null;
|
||||||
|
if (currentTeam.value) uni.setStorageSync(CURRENT_TEAM_STORAGE_KEY, currentTeam.value);
|
||||||
|
currentTabKey.value = 'all';
|
||||||
|
await loadGroups();
|
||||||
|
await loadTeamMembers();
|
||||||
|
await reload(true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@ -1603,6 +1432,7 @@ async function transferToCustomerPool(customerIds) {
|
|||||||
}
|
}
|
||||||
toast('操作成功');
|
toast('操作成功');
|
||||||
cancelBatch();
|
cancelBatch();
|
||||||
|
await reload(true);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
toast('操作失败');
|
toast('操作失败');
|
||||||
} finally {
|
} finally {
|
||||||
@ -1665,6 +1495,7 @@ async function transferToOtherTeam(customerIds) {
|
|||||||
}
|
}
|
||||||
toast('操作成功');
|
toast('操作成功');
|
||||||
cancelBatch();
|
cancelBatch();
|
||||||
|
await reload(true);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
toast('操作失败');
|
toast('操作失败');
|
||||||
} finally {
|
} finally {
|
||||||
@ -1705,12 +1536,10 @@ const handleShare = () => {
|
|||||||
uni.navigateTo({ url: '/pages/case/batch-share' });
|
uni.navigateTo({ url: '/pages/case/batch-share' });
|
||||||
};
|
};
|
||||||
|
|
||||||
async function loadMore() {
|
function loadMore() {
|
||||||
if (!more.value || loading.value) return;
|
if (!more.value || loading.value) return;
|
||||||
const nextPage = page.value + 1;
|
page.value += 1;
|
||||||
page.value = nextPage;
|
reload(false);
|
||||||
const ok = await reload(false, { silent: true });
|
|
||||||
if (!ok) page.value = nextPage - 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
watch(currentTeam, (t) => {
|
watch(currentTeam, (t) => {
|
||||||
@ -1720,7 +1549,6 @@ watch(currentTeam, (t) => {
|
|||||||
|
|
||||||
watch(currentTabKey, () => {
|
watch(currentTabKey, () => {
|
||||||
if (!currentTeam.value) return;
|
if (!currentTeam.value) return;
|
||||||
if (suppressTabReload.value) return;
|
|
||||||
loadTeamMembers();
|
loadTeamMembers();
|
||||||
reload(true);
|
reload(true);
|
||||||
});
|
});
|
||||||
@ -1734,53 +1562,36 @@ function onTabClick(tab) {
|
|||||||
currentTabKey.value = tab.key;
|
currentTabKey.value = tab.key;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function refreshOnEnter() {
|
onLoad(async () => {
|
||||||
if (enterRefreshInflight) return enterRefreshInflight;
|
await loadTeams();
|
||||||
|
|
||||||
enterRefreshInflight = (async () => {
|
|
||||||
const silent = hasEnteredOnce.value;
|
|
||||||
let didLoadSomething = false;
|
|
||||||
|
|
||||||
// 低网/离线时尽量用缓存的当前团队兜底
|
|
||||||
if (!currentTeam.value) {
|
|
||||||
const saved = uni.getStorageSync(CURRENT_TEAM_STORAGE_KEY);
|
|
||||||
if (saved && saved.teamId) currentTeam.value = saved;
|
|
||||||
}
|
|
||||||
|
|
||||||
await loadTeams({ silent });
|
|
||||||
if (lastTeamsLoadOk.value) didLoadSomething = true;
|
|
||||||
if (currentTeam.value) {
|
if (currentTeam.value) {
|
||||||
await loadGroups();
|
await loadGroups();
|
||||||
await loadTeamMembers();
|
await loadTeamMembers();
|
||||||
const ok = await reload(true, { silent, keepOnFail: true });
|
await reload(true);
|
||||||
if (ok) didLoadSomething = true;
|
|
||||||
}
|
}
|
||||||
await refreshVerifyStatus();
|
await refreshVerifyStatus();
|
||||||
if (didLoadSomething) hasEnteredOnce.value = true;
|
|
||||||
})().finally(() => {
|
|
||||||
enterRefreshInflight = null;
|
|
||||||
});
|
|
||||||
|
|
||||||
return enterRefreshInflight;
|
|
||||||
}
|
|
||||||
|
|
||||||
onLoad(async () => {
|
|
||||||
await refreshOnEnter();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
onShow(async () => {
|
onShow(async () => {
|
||||||
const need = uni.getStorageSync(NEED_RELOAD_STORAGE_KEY);
|
const need = uni.getStorageSync(NEED_RELOAD_STORAGE_KEY);
|
||||||
if (need) {
|
if (need) {
|
||||||
uni.removeStorageSync(NEED_RELOAD_STORAGE_KEY);
|
uni.removeStorageSync(NEED_RELOAD_STORAGE_KEY);
|
||||||
|
await reload(true);
|
||||||
// 批量操作完成后回到列表,默认退出批量态
|
// 批量操作完成后回到列表,默认退出批量态
|
||||||
isBatchMode.value = false;
|
isBatchMode.value = false;
|
||||||
selectedItems.value = [];
|
selectedItems.value = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
const needGroups = uni.getStorageSync(GROUPS_RELOAD_KEY);
|
const needGroups = uni.getStorageSync(GROUPS_RELOAD_KEY);
|
||||||
if (needGroups) uni.removeStorageSync(GROUPS_RELOAD_KEY);
|
if (needGroups) {
|
||||||
|
uni.removeStorageSync(GROUPS_RELOAD_KEY);
|
||||||
await refreshOnEnter();
|
await loadGroups();
|
||||||
|
await reload(true);
|
||||||
|
} else {
|
||||||
|
await loadGroups();
|
||||||
|
}
|
||||||
|
await loadTeamMembers();
|
||||||
|
await refreshVerifyStatus();
|
||||||
});
|
});
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user