102 lines
4.6 KiB
Vue
Raw Normal View History

2026-08-14 10:13:46 +08:00
<template>
<view class="page">
<template v-if="customers.length">
<view class="title">请选择本次咨询档案</view>
<view v-for="item in customers" :key="item._id" class="customer-card" @click="open(item)">
<view class="card-header">
<view class="customer-name">{{ item.name || '未命名' }}</view>
<view v-if="item.relationship" class="relationship">{{ item.relationship }}</view>
<view class="header-spacer" />
<view v-if="enableHis" :class="['his-status', item.isConnectHis ? 'connected' : 'unconnected']">
{{ item.isConnectHis ? '已关联院内档案' : '未关联院内档案' }}
</view>
</view>
<view class="card-body">
<view class="customer-info">
<text v-if="item.sex">{{ item.sex }}</text>
<text v-if="item.sex && item.age">/</text>
<text v-if="item.age">{{ item.age }}</text>
<text v-if="item.sex || item.age"></text>
<text v-if="item.mobile">{{ item.mobile }}</text>
</view>
<view class="customer-info">证件号{{ item.idCard || '--' }}</view>
</view>
<view class="card-footer">选择此档案咨询</view>
</view>
</template>
<view v-else-if="loaded" class="empty">正在前往建档...</view>
</view>
</template>
2026-08-07 09:35:21 +08:00
<script setup>
import { ref } from 'vue';
import { onLoad } from '@dcloudio/uni-app';
import api from '@/utils/api';
import useAccountStore from '@/store/account';
import { storeToRefs } from 'pinia';
2026-08-24 14:00:38 +08:00
import { removeAiLabel } from '@/utils/ai-consult-display';
2026-08-14 10:13:46 +08:00
const { account, openid } = storeToRefs(useAccountStore());
const corpId = ref('');
const teamId = ref('');
const assistantId = ref('');
const qrid = ref('');
const customers = ref([]);
const enableHis = ref(false);
const loaded = ref(false);
function getEntryUrl() {
return `/pages/ai-consult/entry?corpId=${corpId.value}&teamId=${teamId.value}&assistantId=${assistantId.value}&qrid=${qrid.value}`;
}
function toLogin() {
uni.redirectTo({ url: `/pages/login/login?redirectUrl=${encodeURIComponent(getEntryUrl())}` });
}
function toCreateArchive() {
uni.redirectTo({ url: `/pages/archive/edit-archive?corpId=${corpId.value}&teamId=${teamId.value}&redirectUrl=${encodeURIComponent(getEntryUrl())}` });
}
async function load() {
const miniAppId = openid.value || uni.getStorageSync('openid');
const res = await api('getMiniAppCustomers', { corpId: corpId.value, miniAppId }, false);
loaded.value = true;
2026-08-24 14:00:38 +08:00
if (!res?.success) return uni.showToast({ title: removeAiLabel(res?.message, '查询档案失败'), icon: 'none' });
2026-08-14 10:13:46 +08:00
customers.value = res.data || [];
enableHis.value = res.enableHis === true;
if (!customers.value.length) toCreateArchive();
}
async function open(customer) {
const res = await api('openAiConsultSession', { corpId: corpId.value, teamId: teamId.value, assistantId: assistantId.value, qrid: qrid.value, customerId: customer?._id || '', miniAppId: openid.value || uni.getStorageSync('openid') });
2026-08-24 14:00:38 +08:00
if (!res?.success) return uni.showToast({ title: removeAiLabel(res?.message, '创建失败'), icon: 'none' });
2026-08-14 10:13:46 +08:00
uni.redirectTo({ url: `/pages/ai-consult/chat?corpId=${corpId.value}&sessionId=${res.data.session._id}` });
}
onLoad((opts) => {
corpId.value = opts.corpId || '';
teamId.value = opts.teamId || '';
assistantId.value = opts.assistantId || '';
qrid.value = opts.qrid || '';
if (!account.value?.mobile) return toLogin();
load();
});
</script>
<style scoped>
.page { min-height: 100vh; background: #f7f8fa; padding: 28rpx; }
.title { font-size: 34rpx; font-weight: 600; margin-bottom: 20rpx; }
.customer-card { overflow: hidden; margin-bottom: 20rpx; background: #fff; border-radius: 16rpx; box-shadow: 0 8rpx 20rpx rgba(0, 0, 0, 0.1); }
.card-header { display: flex; align-items: center; padding: 24rpx 30rpx; border-bottom: 1rpx solid #eee; }
.customer-name { flex-shrink: 0; font-size: 32rpx; font-weight: 600; color: #333; }
.relationship { flex-shrink: 0; margin-left: 10rpx; padding: 2rpx 16rpx; border: 1rpx solid #1677ff; border-radius: 4rpx; color: #1677ff; font-size: 24rpx; }
.header-spacer { flex: 1; }
.his-status { padding: 8rpx 18rpx; border-radius: 6rpx; color: #fff; font-size: 24rpx; line-height: 1.3; }
.his-status.connected { background: #22a06b; }
.his-status.unconnected { background: #ff9d00; }
.card-body { padding: 20rpx 30rpx; border-bottom: 1rpx solid #eee; }
.customer-info { min-height: 38rpx; color: #333; font-size: 28rpx; line-height: 42rpx; }
.card-footer { padding: 20rpx 30rpx; color: #1677ff; font-size: 28rpx; text-align: right; }
.empty { padding-top: 100rpx; color: #888; font-size: 25rpx; text-align: center; }
</style>