转诊方优化
Some checks failed
CI / Test (ubuntu-latest) (push) Has been cancelled
CI / Test (windows-latest) (push) Has been cancelled
CI / Lint (ubuntu-latest) (push) Has been cancelled
CI / Lint (windows-latest) (push) Has been cancelled
CI / Check (ubuntu-latest) (push) Has been cancelled
CI / Check (windows-latest) (push) Has been cancelled
CI / CI OK (push) Has been cancelled
CodeQL / Analyze (javascript-typescript) (push) Has been cancelled
Deploy Website on push / Deploy Push Playground Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Docs Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Antd Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Element Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Naive Ftp (push) Has been cancelled
Release Drafter / update_release_draft (push) Has been cancelled
Some checks failed
CI / Test (ubuntu-latest) (push) Has been cancelled
CI / Test (windows-latest) (push) Has been cancelled
CI / Lint (ubuntu-latest) (push) Has been cancelled
CI / Lint (windows-latest) (push) Has been cancelled
CI / Check (ubuntu-latest) (push) Has been cancelled
CI / Check (windows-latest) (push) Has been cancelled
CI / CI OK (push) Has been cancelled
CodeQL / Analyze (javascript-typescript) (push) Has been cancelled
Deploy Website on push / Deploy Push Playground Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Docs Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Antd Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Element Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Naive Ftp (push) Has been cancelled
Release Drafter / update_release_draft (push) Has been cancelled
This commit is contained in:
@@ -6,6 +6,7 @@ import { Spin } from 'ant-design-vue';
|
||||
|
||||
import { useChatStore } from '../stores/chat.ts';
|
||||
import { useUserStore } from '../stores/user.ts';
|
||||
import { getTransferAssistantConfig } from '#/views/system/transfer-question/api';
|
||||
import MessageBubble from './MessageBubble.vue';
|
||||
|
||||
const userStore = useUserStore();
|
||||
@@ -20,22 +21,63 @@ const isLoading = ref(false); // 加载历史消息状态
|
||||
// const chatStore.hasMore = ref(true); // 是否有更多历史消息
|
||||
const oldScrollHeight = ref(0); // 已加载次数
|
||||
|
||||
// 助理配置缓存
|
||||
const assistantConfig = ref({
|
||||
name: '医生助理',
|
||||
avatar: '',
|
||||
});
|
||||
|
||||
// 加载助理配置
|
||||
const loadAssistantConfig = async () => {
|
||||
try {
|
||||
const res = await getTransferAssistantConfig();
|
||||
if (res?.result) {
|
||||
assistantConfig.value = {
|
||||
name: res.result.name || '医生助理',
|
||||
avatar: res.result.avatar || '',
|
||||
};
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('加载助理配置失败:', error);
|
||||
}
|
||||
};
|
||||
|
||||
// 初始化时加载助理配置
|
||||
onMounted(() => {
|
||||
loadAssistantConfig();
|
||||
});
|
||||
|
||||
// 获取发送者信息
|
||||
const getSenderInfo = (message) => {
|
||||
return message.senderId === userStore.currentUser.doctor_id
|
||||
? {
|
||||
nick_name: userStore.currentUser.nick_name,
|
||||
avatar: userStore.currentUser.nick_name.charAt(0),
|
||||
color: userStore.currentUser.color || '#4cc9f0',
|
||||
}
|
||||
: {
|
||||
nick_name: chatStore.currentFriend?.nick_name || '未知用户',
|
||||
avatar:
|
||||
chatStore.currentFriend?.avatar ||
|
||||
chatStore.currentFriend?.nick_name.charAt(0) ||
|
||||
'?',
|
||||
color: chatStore.currentFriend?.color || '#ff6b6b',
|
||||
};
|
||||
const senderId = message.sender_user_id || message.senderId;
|
||||
|
||||
// 如果是医生助理发送的消息
|
||||
if (senderId === 'doctor_assistant') {
|
||||
return {
|
||||
nick_name: assistantConfig.value.name,
|
||||
avatar: assistantConfig.value.avatar || assistantConfig.value.name.charAt(0),
|
||||
color: '#4cc9f0',
|
||||
};
|
||||
}
|
||||
|
||||
// 如果是当前医生发送的消息
|
||||
if (senderId === userStore.currentUser.doctor_id || senderId === `doctor-${userStore.currentUser.doctor_id}`) {
|
||||
return {
|
||||
nick_name: userStore.currentUser.nick_name,
|
||||
avatar: userStore.currentUser.nick_name.charAt(0),
|
||||
color: userStore.currentUser.color || '#4cc9f0',
|
||||
};
|
||||
}
|
||||
|
||||
// 其他情况(患者发送的消息)
|
||||
return {
|
||||
nick_name: chatStore.currentFriend?.nick_name || '未知用户',
|
||||
avatar:
|
||||
chatStore.currentFriend?.avatar ||
|
||||
chatStore.currentFriend?.nick_name.charAt(0) ||
|
||||
'?',
|
||||
color: chatStore.currentFriend?.color || '#ff6b6b',
|
||||
};
|
||||
};
|
||||
|
||||
// 滚动到底部
|
||||
|
||||
@@ -263,6 +263,7 @@ export const useChatStore = defineStore('chat', () => {
|
||||
return {
|
||||
id: message.id,
|
||||
sender_user_id: message.sender_user_id,
|
||||
senderId: message.sender_user_id, // 添加senderId字段用于兼容
|
||||
receiver_user_id: message.receiver_user_id,
|
||||
message_type: message.message_type,
|
||||
message_content: message.message_content,
|
||||
@@ -393,8 +394,8 @@ export const useChatStore = defineStore('chat', () => {
|
||||
isSent: isSent,
|
||||
};
|
||||
|
||||
// 检测挂号消息(message_type=10)或患者就诊经历消息(message_type=11),触发患者列表刷新通知
|
||||
if (messageData.message_type === 10 || messageData.message_type === 11) {
|
||||
// 检测挂号消息(message_type=10)、患者就诊经历消息(message_type=11)或转诊消息(message_type=14),触发患者列表刷新通知
|
||||
if (messageData.message_type === 10 || messageData.message_type === 11 || messageData.message_type === 14) {
|
||||
newRegisterNotification.value = {
|
||||
timestamp: Date.now(),
|
||||
data: messageData,
|
||||
|
||||
@@ -163,11 +163,12 @@ const convertDrugDataForImport = (drug) => {
|
||||
|
||||
// 一键导入处方到在线问诊(从前端数据导入)
|
||||
const handleImportToPrescription = async () => {
|
||||
if (!transferInfo.value?.transfer_id && !transferInfo.value?.id) {
|
||||
if (!transferInfo.value?.id && !transferInfo.value?.transfer_id) {
|
||||
message.warning('转接方信息不完整');
|
||||
return;
|
||||
}
|
||||
|
||||
// 优先使用props传入的registerId,如果没有则从transferInfo中获取
|
||||
const registerId = props.registerId || transferInfo.value.register_id;
|
||||
|
||||
if (!registerId) {
|
||||
@@ -182,6 +183,11 @@ const handleImportToPrescription = async () => {
|
||||
|
||||
importing.value = true;
|
||||
try {
|
||||
// 确保处方store已初始化(使用正确的registerId)
|
||||
if (!prescriptionStore.currentRegisterId || prescriptionStore.currentRegisterId !== registerId) {
|
||||
prescriptionStore.initializePrescription(registerId, false);
|
||||
}
|
||||
|
||||
// 先将处方类型设置为中药(1)
|
||||
prescriptionStore.changeCategory(1);
|
||||
|
||||
|
||||
@@ -212,6 +212,9 @@ const handleReceptionSuccess = (patient) => {
|
||||
// 初始化处方数据,但不获取患者信息(避免调用错误的API)
|
||||
prescriptionStore.initializePrescription(patient.register_id, false);
|
||||
}
|
||||
|
||||
// 刷新患者列表,更新接诊状态
|
||||
patientListRef.value?.fetchPatientList();
|
||||
};
|
||||
|
||||
// 结束接诊
|
||||
|
||||
@@ -41,3 +41,18 @@ export async function updateTransferQuestion(data: Record<string, any>) {
|
||||
export async function deleteTransferQuestion(data: Record<string, any>) {
|
||||
return requestClient.post<any>(`${prefix}delete`, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取转诊助理配置
|
||||
*/
|
||||
export async function getTransferAssistantConfig() {
|
||||
return requestClient.get<any>('transfer-assistant-config/get-config');
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新转诊助理配置
|
||||
* @param data
|
||||
*/
|
||||
export async function updateTransferAssistantConfig(data: Record<string, any>) {
|
||||
return requestClient.post<any>('transfer-assistant-config/update-config', data);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,100 @@
|
||||
<script lang="ts" setup>
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { message } from 'ant-design-vue';
|
||||
|
||||
import { useVbenForm } from '#/adapter/form';
|
||||
import { getTransferAssistantConfig, updateTransferAssistantConfig } from '../api';
|
||||
|
||||
// 表单配置
|
||||
const assistantFormProps = {
|
||||
wrapperClass: 'grid-cols-12',
|
||||
commonConfig: {
|
||||
formItemClass: 'col-span-12',
|
||||
componentProps: {
|
||||
class: 'w-full',
|
||||
},
|
||||
},
|
||||
layout: 'horizontal',
|
||||
showDefaultActions: false,
|
||||
schema: [
|
||||
{
|
||||
component: 'VbenInput',
|
||||
componentProps: {
|
||||
placeholder: '请输入助理名字',
|
||||
maxlength: 100,
|
||||
},
|
||||
fieldName: 'name',
|
||||
label: '助理名字',
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
component: 'Avatar',
|
||||
componentProps: {
|
||||
maxCount: 1,
|
||||
},
|
||||
fieldName: 'avatar',
|
||||
label: '助理头像',
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
const [Form, formApi] = useVbenForm(assistantFormProps);
|
||||
|
||||
const [Modal, modalApi] = useVbenModal({
|
||||
fullscreenButton: false,
|
||||
draggable: true,
|
||||
onCancel() {
|
||||
modalApi.close();
|
||||
},
|
||||
onConfirm: async () => {
|
||||
formApi.validate().then(async (e: any) => {
|
||||
if (e.valid) {
|
||||
const values = await formApi.getValues();
|
||||
modalApi.setState({ loading: true, confirmLoading: true });
|
||||
updateTransferAssistantConfig(values)
|
||||
.then(() => {
|
||||
message.success('保存成功');
|
||||
modalApi.close();
|
||||
})
|
||||
.catch((error) => {
|
||||
message.error(error?.message || '保存失败');
|
||||
})
|
||||
.finally(() => {
|
||||
modalApi.setState({ loading: false, confirmLoading: false });
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
onOpenChange(isOpen: boolean) {
|
||||
if (isOpen) {
|
||||
// 打开时加载当前配置
|
||||
loadConfig();
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
// 加载配置
|
||||
const loadConfig = async () => {
|
||||
try {
|
||||
const res = await getTransferAssistantConfig();
|
||||
// 接口返回的数据结构:{ data: { code: 0, result: {...}, message: '...' } }
|
||||
// 用户说接口返回的已经是 result 中的数据,所以直接使用 res.data.result
|
||||
const result = res;
|
||||
if (result) {
|
||||
formApi.setValues(result);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('加载助理配置失败:', error);
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal
|
||||
title="配置助理信息"
|
||||
class="w-[60%]"
|
||||
>
|
||||
<Form />
|
||||
</Modal>
|
||||
</template>
|
||||
@@ -12,6 +12,7 @@ import { TableAction } from '#/components/table-action';
|
||||
|
||||
import { deleteTransferQuestion } from './api';
|
||||
import FormModalDemo from './components/modal.vue';
|
||||
import AssistantConfigModalComponent from './components/AssistantConfigModal.vue';
|
||||
import { formOptions } from './config/search';
|
||||
import { gridOptions } from './config/table';
|
||||
|
||||
@@ -40,6 +41,10 @@ const [FormModal, formModalApi] = useVbenModal({
|
||||
connectedComponent: FormModalDemo,
|
||||
});
|
||||
|
||||
const [AssistantConfigModal, assistantConfigModalApi] = useVbenModal({
|
||||
connectedComponent: AssistantConfigModalComponent,
|
||||
});
|
||||
|
||||
const showModal = (data = {}, isUpdate = false) => {
|
||||
formModalApi.setData({
|
||||
// 表单值
|
||||
@@ -67,6 +72,7 @@ const deleteApi = (row: any) => {
|
||||
<template>
|
||||
<Page auto-content-height title="转诊问题配置">
|
||||
<FormModal />
|
||||
<AssistantConfigModal />
|
||||
<Grid>
|
||||
<template #toolbar-buttons>
|
||||
<TableAction
|
||||
@@ -77,6 +83,14 @@ const deleteApi = (row: any) => {
|
||||
icon: 'ant-design:plus-outlined',
|
||||
onClick: showModal.bind(null),
|
||||
},
|
||||
{
|
||||
label: '配置助理信息',
|
||||
type: 'default',
|
||||
icon: 'ant-design:user-outlined',
|
||||
onClick: () => {
|
||||
assistantConfigModalApi.open();
|
||||
},
|
||||
},
|
||||
]"
|
||||
:drop-down-actions="[
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user