101 lines
4.6 KiB
Vue
101 lines
4.6 KiB
Vue
<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>
|
||
|
||
<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';
|
||
|
||
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;
|
||
if (!res?.success) return uni.showToast({ title: res?.message || '查询档案失败', icon: 'none' });
|
||
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') });
|
||
if (!res?.success) return uni.showToast({ title: res?.message || '创建失败', icon: 'none' });
|
||
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>
|