This commit is contained in:
Your Name
2026-03-11 14:33:49 +08:00
parent 38ad60f4bb
commit 08dd9cd307
57 changed files with 9547 additions and 379 deletions
+11 -1
View File
@@ -7,7 +7,7 @@ export function orderLists(params: any) {
// 订单详情
export function orderDetail(params: any) {
return request.get({ url: '/order.order/detail', params })
return request.post({ url: '/order.order/detail', params })
}
// 创建订单
@@ -30,6 +30,16 @@ export function orderPay(params: any) {
return request.post({ url: '/order.order/pay', params })
}
// 支付宝支付
export function alipayPay(params: any) {
return request.post({ url: '/order.order/alipay', params })
}
// 微信支付
export function wechatPay(params: any) {
return request.post({ url: '/order.order/wechat', params })
}
// 取消订单
export function orderCancel(params: any) {
return request.post({ url: '/order.order/cancel', params })
+93 -174
View File
@@ -78,12 +78,12 @@
<el-table-column label="患者信息" min-width="150">
<template #default="{ row }">
<div>{{ row.patient_name }}</div>
<div class="text-xs text-gray-400">{{ row.patient_phone }}</div>
<div>{{ row.patient.patient_name }}</div>
<div class="text-xs text-gray-400">{{ row.patient.phone }}</div>
</template>
</el-table-column>
<el-table-column label="创建人" prop="creator_name" min-width="120" />
<el-table-column label="创建人" prop="creator.name" min-width="120" />
<el-table-column label="订单类型" width="100">
<template #default="{ row }">
@@ -195,13 +195,13 @@
</el-tag>
</el-descriptions-item>
<el-descriptions-item label="患者姓名">
{{ detailData.patient_name }}
{{ detailData.patient.patient_name }}
</el-descriptions-item>
<el-descriptions-item label="患者电话">
{{ detailData.patient_phone }}
{{ detailData.patient.phone }}
</el-descriptions-item>
<el-descriptions-item label="创建人">
{{ detailData.creator_name }}
{{ detailData.creator.name }}
</el-descriptions-item>
<el-descriptions-item label="订单类型">
<el-tag :type="getOrderTypeTag(detailData.order_type)">
@@ -224,27 +224,6 @@
{{ detailData.remark || '无' }}
</el-descriptions-item>
</el-descriptions>
<!-- 订单详情项 -->
<el-divider>订单详情</el-divider>
<el-table :data="detailData?.details || []" size="small">
<el-table-column label="关联类型" prop="related_type" width="100">
<template #default="{ row }">
{{ getRelatedTypeText(row.related_type) }}
</template>
</el-table-column>
<el-table-column label="数量" prop="quantity" width="80" />
<el-table-column label="单价" width="100">
<template #default="{ row }">
¥{{ row.unit_price }}
</template>
</el-table-column>
<el-table-column label="总价" width="100">
<template #default="{ row }">
¥{{ row.total_price }}
</template>
</el-table-column>
</el-table>
</el-dialog>
<!-- 支付弹窗 -->
@@ -254,17 +233,35 @@
width="500px"
>
<el-form :model="payForm" label-width="100px">
<el-form-item label="订单号">
<span>{{ payForm.order_no }}</span>
</el-form-item>
<el-form-item label="订单金额">
<span class="text-red-500 font-semibold">¥{{ payForm.amount }}</span>
<el-form-item label="支付类型" required>
<el-radio-group v-model="payForm.payType">
<!-- <el-radio label="normal">正常支付</el-radio> -->
<el-radio label="supplement">补单支付</el-radio>
</el-radio-group>
</el-form-item>
<template v-if="payForm.payType === 'normal'">
<el-form-item label="订单号">
<span>{{ payForm.order_no }}</span>
</el-form-item>
<el-form-item label="订单金额">
<span class="text-red-500 font-semibold">¥{{ payForm.amount }}</span>
</el-form-item>
</template>
<template v-if="payForm.payType === 'supplement'">
<el-form-item label="支付订单号" required>
<el-input
v-model="payForm.supplement_order_no"
placeholder="请输入支付订单号"
/>
</el-form-item>
</template>
<el-form-item label="支付方式" required>
<el-radio-group v-model="payForm.payment_method">
<el-radio label="alipay">支付宝</el-radio>
<el-radio label="wechat">微信</el-radio>
<el-radio label="bank">银行卡</el-radio>
</el-radio-group>
</el-form-item>
</el-form>
@@ -299,7 +296,7 @@
<el-option
v-for="item in patientList"
:key="item.id"
:label="`${item.nickname} (${item.mobile})`"
:label="`${item.patient_name} (${item.phone})`"
:value="item.id"
/>
</el-select>
@@ -331,81 +328,6 @@
placeholder="请输入备注(可选)"
/>
</el-form-item>
<el-form-item label="订单详情">
<div class="w-full">
<el-button
type="primary"
link
@click="addOrderDetail"
>
+ 添加订单项
</el-button>
<el-table :data="createForm.details" class="mt-3">
<el-table-column label="关联类型" width="120">
<template #default="{ row }">
<el-select
v-model="row.related_type"
placeholder="请选择"
size="small"
>
<el-option label="挂号" value="appointment" />
<el-option label="问诊" value="diagnosis" />
<el-option label="药品" value="medicine" />
</el-select>
</template>
</el-table-column>
<el-table-column label="关联ID" width="100">
<template #default="{ row }">
<el-input
v-model.number="row.related_id"
type="number"
placeholder="ID"
size="small"
/>
</template>
</el-table-column>
<el-table-column label="数量" width="80">
<template #default="{ row }">
<el-input-number
v-model="row.quantity"
:min="1"
size="small"
/>
</template>
</el-table-column>
<el-table-column label="单价" width="100">
<template #default="{ row, $index }">
<el-input-number
v-model="row.unit_price"
:min="0"
:step="0.01"
:precision="2"
size="small"
@change="updateDetailTotal($index)"
/>
</template>
</el-table-column>
<el-table-column label="总价" width="100">
<template #default="{ row }">
<span>{{ (row.quantity * row.unit_price).toFixed(2) }}</span>
</template>
</el-table-column>
<el-table-column label="操作" width="80">
<template #default="{ row, $index }">
<el-button
type="danger"
link
size="small"
@click="removeOrderDetail($index)"
>
删除
</el-button>
</template>
</el-table-column>
</el-table>
</div>
</el-form-item>
</el-form>
<template #footer>
@@ -420,7 +342,7 @@
<script setup lang="ts" name="orderList">
import { usePaging } from '@/hooks/usePaging'
import { orderLists, orderDetail, orderPay, orderCancel, orderDelete, orderRefund, orderExport, orderCreate, searchPatients as searchPatientsAPI } from '@/api/order'
import { orderLists, orderDetail, orderPay, orderCancel, orderDelete, orderRefund, orderExport, orderCreate, searchPatients as searchPatientsAPI, alipayPay, wechatPay } from '@/api/order'
import feedback from '@/utils/feedback'
const queryParams = reactive({
@@ -455,7 +377,9 @@ const payForm = ref({
order_id: 0,
order_no: '',
amount: 0,
payment_method: 'alipay'
payment_method: 'alipay',
payType: 'supplement',
supplement_order_no: ''
})
// 创建订单相关
@@ -469,8 +393,7 @@ const createForm = reactive({
patient_id: '',
order_type: '',
amount: 0,
remark: '',
details: [] as any[]
remark: ''
})
const createRules = {
@@ -500,35 +423,12 @@ const searchPatients = async (query: string) => {
}
}
// 添加订单项
const addOrderDetail = () => {
createForm.details.push({
related_type: '',
related_id: '',
quantity: 1,
unit_price: 0,
total_price: 0
})
}
// 删除订单项
const removeOrderDetail = (index: number) => {
createForm.details.splice(index, 1)
}
// 更新订单项总价
const updateDetailTotal = (index: number) => {
const detail = createForm.details[index]
detail.total_price = detail.quantity * detail.unit_price
}
// 重置创建表单
const resetCreateForm = () => {
createForm.patient_id = ''
createForm.order_type = ''
createForm.amount = 0
createForm.remark = ''
createForm.details = []
createFormRef.value?.clearValidate()
}
@@ -542,31 +442,14 @@ const handleCreate = () => {
const submitCreateOrder = async () => {
try {
await createFormRef.value?.validate()
if (createForm.details.length === 0) {
feedback.msgWarning('请至少添加一个订单项')
return
}
createLoading.value = true
// 计算总金额
const totalAmount = createForm.details.reduce((sum, detail) => {
return sum + (detail.quantity * detail.unit_price)
}, 0)
const params = {
patient_id: createForm.patient_id,
order_type: createForm.order_type,
amount: totalAmount,
remark: createForm.remark,
details: createForm.details.map(detail => ({
related_type: detail.related_type,
related_id: detail.related_id,
quantity: detail.quantity,
unit_price: detail.unit_price,
total_price: detail.quantity * detail.unit_price
}))
amount: createForm.amount,
remark: createForm.remark
}
await orderCreate(params)
@@ -627,22 +510,11 @@ const getPaymentMethodText = (method: string | null) => {
if (!method) return '-'
const methodMap: Record<string, string> = {
alipay: '支付宝',
wechat: '微信',
bank: '银行卡'
wechat: '微信'
}
return methodMap[method] || '未知'
}
// 获取关联类型文本
const getRelatedTypeText = (type: string) => {
const typeMap: Record<string, string> = {
appointment: '挂号',
diagnosis: '问诊',
medicine: '药品'
}
return typeMap[type] || '未知'
}
// 查看详情
const handleDetail = async (row: any) => {
try {
@@ -660,7 +532,9 @@ const handlePay = (row: any) => {
order_id: row.id,
order_no: row.order_no,
amount: row.amount,
payment_method: 'alipay'
payment_method: 'alipay',
payType: 'supplement',
supplement_order_no: ''
}
payDialogVisible.value = true
}
@@ -668,16 +542,61 @@ const handlePay = (row: any) => {
// 确认支付
const confirmPay = async () => {
try {
// 验证补单支付的订单号
if (payForm.value.payType === 'supplement' && !payForm.value.supplement_order_no) {
feedback.msgWarning('请输入支付订单号')
return
}
payLoading.value = true
await orderPay({
id: payForm.value.order_id,
payment_method: payForm.value.payment_method
})
feedback.msgSuccess('支付成功')
let payParams: any = {}
if (payForm.value.payType === 'normal') {
// 正常支付
payParams = {
id: payForm.value.order_id,
order_no: payForm.value.order_no,
amount: payForm.value.amount,
payment_method: payForm.value.payment_method
}
} else {
// 补单支付:直接填订单号,不需要校验
payParams = {
order_no: payForm.value.supplement_order_no,
payment_method: payForm.value.payment_method,
is_supplement: 1
}
}
// 调用对应的支付网关
let payResult: any
if (payForm.value.payment_method === 'alipay') {
payResult = await alipayPay(payParams)
} else if (payForm.value.payment_method === 'wechat') {
payResult = await wechatPay(payParams)
}
// 支付网关返回支付链接或二维码
if (payResult && payResult.pay_url) {
// 如果是支付宝,跳转到支付页面
if (payForm.value.payment_method === 'alipay') {
window.location.href = payResult.pay_url
} else if (payForm.value.payment_method === 'wechat') {
// 如果是微信,显示二维码或其他处理
feedback.msgSuccess('请扫描二维码进行支付')
// 可以在这里显示二维码弹窗
}
}
payDialogVisible.value = false
getLists()
// 延迟刷新列表,等待支付完成
setTimeout(() => {
getLists()
}, 2000)
} catch (error) {
console.error('支付失败:', error)
feedback.msgError('支付失败,请重试')
} finally {
payLoading.value = false
}
+44 -30
View File
@@ -13,34 +13,30 @@
class="mb-4"
>
<p>此页面用于测试音视频通话功能</p>
<p>使用方法</p>
<ol>
<li>在此页面初始化患者端</li>
<li>在另一个浏览器窗口登录医生端</li>
<li>医生端发起通话</li>
<li>此页面会收到来电提示</li>
</ol>
<p>页面打开后会自动初始化患者端等待医生端发起通话</p>
</el-alert>
<el-form :model="form" label-width="100px" v-if="!initialized">
<el-form-item label="患者ID">
<el-input
v-model="form.patientId"
placeholder="输入患者ID,如:1"
style="width: 300px;"
/>
</el-form-item>
<div v-if="!initialized" class="init-section">
<el-alert
type="info"
:closable="false"
class="mb-4"
>
<p><strong>当前登录用户:</strong> {{ currentUser.nickname || currentUser.name || '未知' }}</p>
<p><strong>用户ID:</strong> {{ currentUser.id || '未获取' }}</p>
<p><strong>状态:</strong> 正在初始化...</p>
</el-alert>
<el-form-item>
<el-button
type="primary"
@click="initPatient"
:loading="loading"
>
初始化患者端
</el-button>
</el-form-item>
</el-form>
<el-button
type="primary"
@click="initPatient"
:loading="loading"
size="large"
v-if="!loading"
>
重新初始化
</el-button>
</div>
<div v-if="initialized" class="status">
<el-alert
@@ -101,14 +97,18 @@
</template>
<script setup lang="ts">
import { ref, onUnmounted } from 'vue'
import { ref, onUnmounted, computed, onMounted } from 'vue'
import { Phone } from '@element-plus/icons-vue'
import { TUICallKitAPI, TUICallKit, STATUS } from '@trtc/calls-uikit-vue'
import { ElMessage, ElNotification } from 'element-plus'
import request from '@/utils/request'
import useUserStore from '@/stores/modules/user'
const userStore = useUserStore()
const currentUser = computed(() => userStore.userInfo)
const form = ref({
patientId: '1'
patientId: computed(() => currentUser.value.id?.toString() || '1')
})
const loading = ref(false)
@@ -117,6 +117,11 @@ const currentUserId = ref('')
const hasIncomingCall = ref(false)
const incomingCallInfo = ref<any>(null)
// 页面加载时自动初始化
onMounted(() => {
initPatient()
})
// 监听状态变化
const handleStatusChange = ({ oldStatus, newStatus }: any) => {
console.log('通话状态变化:', { oldStatus, newStatus })
@@ -150,13 +155,18 @@ const initPatient = async () => {
try {
loading.value = true
const patientId = currentUser.value.id
if (!patientId) {
throw new Error('未获取到当前用户ID,请重新登录')
}
ElMessage.info('正在获取签名...')
// 获取患者签名
const result = await request.get({
url: '/tcm.diagnosis/getPatientSignature',
url: '/tcm.diagnosis/getDoctorSignature',
params: {
patient_id: form.value.patientId
patient_id: patientId
}
})
@@ -234,7 +244,6 @@ const reset = () => {
currentUserId.value = ''
hasIncomingCall.value = false
incomingCallInfo.value = null
form.value.patientId = '1'
}
// 组件卸载时清理
@@ -262,6 +271,11 @@ onUnmounted(() => {
font-weight: bold;
}
.init-section {
text-align: center;
padding: 20px;
}
.status {
margin: 20px 0;
}