diff --git a/pages/archive/edit-archive.vue b/pages/archive/edit-archive.vue index 7f89514..ec01701 100644 --- a/pages/archive/edit-archive.vue +++ b/pages/archive/edit-archive.vue @@ -141,6 +141,12 @@ async function addArchive() { externalUserId: externalUserId.value, realUnionid: account.value.unionid || '', } + if (externalUserId.value) { + const corpUserId = await getResponsiblePerson(); + if (corpUserId) { + params.personResponsibles = [{ corpUserId, teamId: teamId.value }] + } + } loading.value = false; const res = await api('addCustomer', { params }); if (res && res.success) { @@ -154,8 +160,18 @@ async function addArchive() { } } +async function getResponsiblePerson() { + const res = await api('getResponsiblePerson', { corpId: corpId.value, externalUserId: externalUserId.value, teamId: teamId.value }); + return res && res.data ? res.data : '' +} + async function bindArchive(customerId) { - const res = await api('bindMiniAppArchive', { id: customerId, corpId: corpId.value, teamId: teamId.value, miniAppId: account.value.openid }); + let responsiblePerson = ''; + if (externalUserId.value) { + const corpUserId = await getResponsiblePerson(); + responsiblePerson = corpUserId || ''; + } + const res = await api('bindMiniAppArchive', { id: customerId, corpId: corpId.value, teamId: teamId.value, miniAppId: account.value.openid, externalUserId: externalUserId.value, responsiblePerson }); if (res && res.success) { await toast('绑定成功'); uni.$emit('reloadTeamCustomers') diff --git a/pages/article/article-list.vue b/pages/article/article-list.vue index f37adaf..36112e1 100644 --- a/pages/article/article-list.vue +++ b/pages/article/article-list.vue @@ -169,7 +169,8 @@ const loadArticleList = async (reset = false) => { miniAppId, page: page.value, pageSize, - customerIds + customerIds, + teamId: teamId.value }; if (activeTab.value) params.customerIds = [activeTab.value]; diff --git a/pages/home/consult.vue b/pages/home/consult.vue index 0f3efeb..39c009e 100644 --- a/pages/home/consult.vue +++ b/pages/home/consult.vue @@ -173,7 +173,7 @@ async function getBadgeCount() { loading = false return } - const res = await api('getMiniAppHomeStats', { corpId: props.corpId, customerIds }) + const res = await api('getMiniAppHomeStats', { corpId: props.corpId, teamId: props.teamId, customerIds }) const data = res?.data || {}; const article = typeof data.article === 'number' ? data.article : 0; const survey = typeof data.survey === 'number' ? data.survey : 0; @@ -182,8 +182,7 @@ async function getBadgeCount() { loading = false; } -watch(() => props.customers, n => { - console.error('wwwwatch: ') +watch(() => [props.customers, props.teamId, props.corpId], n => { getBadgeCount() }, { immediate: true }) diff --git a/pages/home/customer-archive.vue b/pages/home/customer-archive.vue index f60b9dc..f6008db 100644 --- a/pages/home/customer-archive.vue +++ b/pages/home/customer-archive.vue @@ -93,6 +93,7 @@ const props = defineProps({ }); const emit = defineEmits(["update:customers"]); +let loading = false; const { account } = storeToRefs(useAccount()); const current = ref(null); @@ -177,10 +178,12 @@ async function auth() { } async function getCustomers() { + if (loading) return; + loading = true const res = await api("getMiniAppCustomers", { miniAppId: account.value.openid, corpId: props.corpId, - }); + }, false); if (res && res.success) { customers.value = res && Array.isArray(res.data) ? res.data : []; const customer = customers.value.find( @@ -192,6 +195,7 @@ async function getCustomers() { } else { toast(res.message || "获取档案失败"); } + loading = false } onMounted(() => { @@ -209,6 +213,10 @@ watch( }, { immediate: true } ); + +defineExpose({ + getCustomers, +})