更新
This commit is contained in:
@@ -102,7 +102,11 @@
|
||||
<el-tag v-else type="danger">禁用</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="创建时间" prop="create_time" min-width="160" />
|
||||
<el-table-column label="创建时间" prop="create_time" min-width="160">
|
||||
<template #default="{ row }">
|
||||
<span>{{ formatDateTime(row.create_time) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="240" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<el-button type="primary" link @click="handleDetail(row.id)">
|
||||
@@ -139,6 +143,14 @@
|
||||
@click="handleAppointment(row)"
|
||||
>
|
||||
挂号
|
||||
</el-button>
|
||||
<el-button
|
||||
v-perms="['tcm.diagnosis/guahao']"
|
||||
type="success"
|
||||
link
|
||||
@click="handleMiniProgramQRCode(row)"
|
||||
>
|
||||
小程序二维码
|
||||
</el-button>
|
||||
<el-button type="primary" link @click="handleEdit(row.id)" v-perms="['tcm.diagnosis/edit']">
|
||||
编辑
|
||||
@@ -159,6 +171,39 @@
|
||||
<video-call ref="videoCallRef" />
|
||||
<appointment-popup ref="appointmentRef" @success="getLists" />
|
||||
|
||||
<!-- 小程序二维码弹窗 -->
|
||||
<el-dialog
|
||||
v-model="qrcodeDialogVisible"
|
||||
title="小程序二维码"
|
||||
width="400px"
|
||||
:close-on-click-modal="false"
|
||||
>
|
||||
<div class="flex flex-col items-center justify-center py-4">
|
||||
<div v-if="qrcodeLoading" class="text-center">
|
||||
<el-icon class="is-loading" :size="40">
|
||||
<Loading />
|
||||
</el-icon>
|
||||
<div class="mt-4 text-gray-500">生成中...</div>
|
||||
</div>
|
||||
<div v-else-if="qrcodeUrl" class="text-center">
|
||||
<img :src="qrcodeUrl" alt="小程序二维码" class="w-64 h-64 border border-gray-200 rounded" />
|
||||
<div class="mt-4 text-sm text-gray-600">
|
||||
<div>患者:{{ currentQRCodePatient?.patient_name }}</div>
|
||||
<div class="mt-2">请使用微信扫描二维码</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else class="text-center text-gray-500">
|
||||
生成失败,请重试
|
||||
</div>
|
||||
</div>
|
||||
<template #footer>
|
||||
<el-button @click="qrcodeDialogVisible = false">关闭</el-button>
|
||||
<el-button v-if="!qrcodeLoading" type="primary" @click="handleRegenerateQRCode">
|
||||
重新生成
|
||||
</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<!-- 批量指派医助弹窗 -->
|
||||
<el-dialog
|
||||
v-model="assignDialogVisible"
|
||||
@@ -208,14 +253,26 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts" name="tcmDiagnosis">
|
||||
import { tcmDiagnosisLists, tcmDiagnosisDelete, tcmDiagnosisAssign, getAssistants } from '@/api/tcm'
|
||||
import { tcmDiagnosisLists, tcmDiagnosisDelete, tcmDiagnosisAssign, getAssistants, generateMiniProgramQrcode } from '@/api/tcm'
|
||||
import { usePaging } from '@/hooks/usePaging'
|
||||
import { getDictData } from '@/api/app'
|
||||
import { getWeappConfig } from '@/api/channel/weapp'
|
||||
import feedback from '@/utils/feedback'
|
||||
import { Loading } from '@element-plus/icons-vue'
|
||||
import EditPopup from './edit.vue'
|
||||
import DetailPopup from './detail.vue'
|
||||
import VideoCall from '@/components/video-call/index.vue'
|
||||
import AppointmentPopup from './appointment.vue'
|
||||
import useUserStore from '@/stores/modules/user'
|
||||
import dayjs from 'dayjs'
|
||||
|
||||
// 格式化时间戳为日期时间
|
||||
const formatDateTime = (timestamp: number | string) => {
|
||||
if (!timestamp) return '-'
|
||||
// 如果是秒级时间戳(10位),转换为毫秒级
|
||||
const ts = String(timestamp).length === 10 ? Number(timestamp) * 1000 : Number(timestamp)
|
||||
return dayjs(ts).format('YYYY-MM-DD HH:mm:ss')
|
||||
}
|
||||
|
||||
const formData = ref({
|
||||
patient_name: '',
|
||||
@@ -284,6 +341,13 @@ const editRef = ref()
|
||||
const detailRef = ref()
|
||||
const videoCallRef = ref()
|
||||
const appointmentRef = ref()
|
||||
const userStore = useUserStore()
|
||||
|
||||
// 小程序二维码相关
|
||||
const qrcodeDialogVisible = ref(false)
|
||||
const qrcodeLoading = ref(false)
|
||||
const qrcodeUrl = ref('')
|
||||
const currentQRCodePatient = ref<any>(null)
|
||||
|
||||
// 批量指派相关
|
||||
const selectedIds = ref<number[]>([])
|
||||
@@ -433,6 +497,58 @@ const handleAppointment = (row: any) => {
|
||||
appointmentRef.value?.open(row)
|
||||
}
|
||||
|
||||
// 生成小程序二维码
|
||||
const handleMiniProgramQRCode = async (row: any) => {
|
||||
if (!row.patient_id) {
|
||||
feedback.msgWarning('患者信息不完整')
|
||||
return
|
||||
}
|
||||
|
||||
currentQRCodePatient.value = row
|
||||
qrcodeDialogVisible.value = true
|
||||
qrcodeLoading.value = true
|
||||
qrcodeUrl.value = ''
|
||||
|
||||
try {
|
||||
// 获取小程序配置
|
||||
const config = await getWeappConfig()
|
||||
|
||||
if (!config?.app_id) {
|
||||
feedback.msgError('小程序未配置,请先配置小程序信息')
|
||||
qrcodeDialogVisible.value = false
|
||||
return
|
||||
}
|
||||
|
||||
// 获取当前登录用户信息
|
||||
const currentUser = userStore.userInfo
|
||||
|
||||
// 调用生成二维码接口
|
||||
const result = await generateMiniProgramQrcode({
|
||||
diagnosis_id: row.id,
|
||||
patient_id: row.patient_id,
|
||||
share_user_id: currentUser?.id || ''
|
||||
})
|
||||
|
||||
if (result?.qrcode_url) {
|
||||
qrcodeUrl.value = result.qrcode_url
|
||||
} else {
|
||||
feedback.msgError('二维码生成失败')
|
||||
}
|
||||
} catch (error: any) {
|
||||
console.error('生成小程序二维码失败:', error)
|
||||
feedback.msgError(error?.msg || '生成二维码失败,请重试')
|
||||
} finally {
|
||||
qrcodeLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 重新生成二维码
|
||||
const handleRegenerateQRCode = () => {
|
||||
if (currentQRCodePatient.value) {
|
||||
handleMiniProgramQRCode(currentQRCodePatient.value)
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
await getDictOptions()
|
||||
getLists()
|
||||
|
||||
Reference in New Issue
Block a user