更新
This commit is contained in:
@@ -49,6 +49,7 @@
|
||||
<el-option label="尾款费用" :value="5" />
|
||||
<el-option label="其他费用" :value="6" />
|
||||
<el-option label="全部费用" :value="7" />
|
||||
<el-option label="驼奶费用" :value="8" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
@@ -199,7 +200,7 @@
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column label="操作" width="280" fixed="right">
|
||||
<el-table-column label="操作" width="340" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<el-button
|
||||
v-perms="['order.order/detail']"
|
||||
@@ -217,6 +218,15 @@
|
||||
>
|
||||
编辑
|
||||
</el-button>
|
||||
<el-button
|
||||
v-if="row.status === 1 || row.status === 2 || (row.status === 5 && row.payment_method === 'fubei')"
|
||||
v-perms="['order.order/split']"
|
||||
type="primary"
|
||||
link
|
||||
@click="openSplitOrder(row)"
|
||||
>
|
||||
拆分
|
||||
</el-button>
|
||||
<el-button
|
||||
type="primary"
|
||||
v-perms="['order.order/wxQrcode']"
|
||||
@@ -542,6 +552,7 @@
|
||||
<el-option label="尾款费用" :value="5" />
|
||||
<el-option label="其他费用" :value="6" />
|
||||
<el-option label="全部费用" :value="7" />
|
||||
<el-option label="驼奶费用" :value="8" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
@@ -640,6 +651,7 @@
|
||||
<el-option label="尾款费用" :value="5" />
|
||||
<el-option label="其他费用" :value="6" />
|
||||
<el-option label="全部费用" :value="7" />
|
||||
<el-option label="驼奶费用" :value="8" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
@@ -648,6 +660,67 @@
|
||||
<el-button type="primary" :loading="editOrderLoading" @click="submitEditOrder">保存</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
<el-dialog v-model="splitDialogVisible" title="拆分订单" width="620px" destroy-on-close @closed="splitSource = null">
|
||||
<template v-if="splitSource">
|
||||
<p class="text-sm text-gray-600 mb-3">
|
||||
原订单号 <span class="font-mono">{{ splitSource.order_no }}</span>,金额
|
||||
<span class="text-red-500 font-semibold">¥{{ splitSource.amount }}</span
|
||||
>。每笔子单可分别选择<strong>订单类型</strong>;子单继承患者、创建人及企微收款信息;<strong>已支付</strong>子单继承支付方式、支付时间与交易号;原单将软删除;若已关联业务订单,关联会同步到全部子单。
|
||||
</p>
|
||||
<el-form label-width="88px" @submit.prevent>
|
||||
<el-form-item label="拆分管数">
|
||||
<el-input-number
|
||||
v-model="splitPartCount"
|
||||
:min="2"
|
||||
:max="20"
|
||||
:step="1"
|
||||
step-strictly
|
||||
@change="redistributeSplitAmounts"
|
||||
/>
|
||||
<span class="text-xs text-gray-400 ml-2">2~20 笔</span>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div class="space-y-2 mb-3 max-h-[320px] overflow-y-auto pr-1">
|
||||
<div v-for="(_amt, idx) in splitAmounts" :key="idx" class="flex items-center gap-2 flex-wrap">
|
||||
<span class="text-sm text-gray-500 w-14 shrink-0">第 {{ idx + 1 }} 笔</span>
|
||||
<el-select v-model="splitOrderTypes[idx]" placeholder="订单类型" class="w-[136px] shrink-0">
|
||||
<el-option label="挂号费" :value="1" />
|
||||
<el-option label="问诊费" :value="2" />
|
||||
<el-option label="药品费用" :value="3" />
|
||||
<el-option label="首付费用" :value="4" />
|
||||
<el-option label="尾款费用" :value="5" />
|
||||
<el-option label="其他费用" :value="6" />
|
||||
<el-option label="全部费用" :value="7" />
|
||||
<el-option label="驼奶费用" :value="8" />
|
||||
</el-select>
|
||||
<el-input-number
|
||||
v-model="splitAmounts[idx]"
|
||||
:min="0.01"
|
||||
:step="0.01"
|
||||
:precision="2"
|
||||
class="flex-1 min-w-[140px]"
|
||||
controls-position="right"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<el-alert
|
||||
:type="splitSumMatches ? 'success' : 'warning'"
|
||||
:closable="false"
|
||||
show-icon
|
||||
>
|
||||
<template #title>
|
||||
子单合计 ¥{{ splitSum.toFixed(2) }},
|
||||
{{ splitSumMatches ? '与原价一致,可提交' : '须与原价完全一致方可拆分' }}
|
||||
</template>
|
||||
</el-alert>
|
||||
</template>
|
||||
<template #footer>
|
||||
<el-button @click="splitDialogVisible = false">取消</el-button>
|
||||
<el-button type="primary" :loading="splitLoading" :disabled="!splitSumMatches" @click="submitSplitOrder">
|
||||
确定拆分
|
||||
</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
<!-- 小程序码弹窗 -->
|
||||
<el-dialog
|
||||
v-model="qrcodeDialogVisible"
|
||||
@@ -705,7 +778,8 @@ import {
|
||||
wechatPay,
|
||||
orderActionLogs,
|
||||
orderActionLogStats,
|
||||
orderBatchAssignAssistant
|
||||
orderBatchAssignAssistant,
|
||||
orderSplit
|
||||
} from '@/api/order'
|
||||
import { getAssistants } from '@/api/tcm'
|
||||
import { generateOrderQrcode } from '@/api/tcm'
|
||||
@@ -1109,8 +1183,9 @@ const getOrderTypeText = (type: number) => {
|
||||
3: '药品费用',
|
||||
4: '首付费用',
|
||||
5: '尾款费用',
|
||||
6:'其他费用',
|
||||
7:'全部费用',
|
||||
6: '其他费用',
|
||||
7: '全部费用',
|
||||
8: '驼奶费用',
|
||||
}
|
||||
return typeMap[type] || '未知'
|
||||
}
|
||||
@@ -1210,6 +1285,68 @@ const submitEditOrder = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
/** 拆分订单(待支付 / 已支付 / 付呗待审核) */
|
||||
const splitDialogVisible = ref(false)
|
||||
const splitSource = ref<any>(null)
|
||||
const splitPartCount = ref(2)
|
||||
const splitAmounts = ref<number[]>([])
|
||||
const splitOrderTypes = ref<number[]>([])
|
||||
const splitLoading = ref(false)
|
||||
|
||||
const redistributeSplitAmounts = () => {
|
||||
if (!splitSource.value) return
|
||||
const total = Number(splitSource.value.amount)
|
||||
const n = Math.max(2, Math.min(20, Math.floor(Number(splitPartCount.value) || 2)))
|
||||
splitPartCount.value = n
|
||||
const cents = Math.round(total * 100)
|
||||
const base = Math.floor(cents / n)
|
||||
const rem = cents % n
|
||||
const next: number[] = []
|
||||
for (let i = 0; i < n; i++) {
|
||||
const c = base + (i < rem ? 1 : 0)
|
||||
next.push(c / 100)
|
||||
}
|
||||
const prevTypes = [...splitOrderTypes.value]
|
||||
const defaultType = Number(splitSource.value.order_type ?? 6)
|
||||
splitOrderTypes.value = next.map((_, i) => (i < prevTypes.length ? prevTypes[i]! : defaultType))
|
||||
splitAmounts.value = next
|
||||
}
|
||||
|
||||
const openSplitOrder = (row: any) => {
|
||||
splitSource.value = row
|
||||
splitPartCount.value = 2
|
||||
redistributeSplitAmounts()
|
||||
splitDialogVisible.value = true
|
||||
}
|
||||
|
||||
const splitSum = computed(() => splitAmounts.value.reduce((s, x) => s + Number(x || 0), 0))
|
||||
|
||||
const splitSumMatches = computed(() => {
|
||||
if (!splitSource.value) return false
|
||||
const orig = Number(splitSource.value.amount)
|
||||
return Math.abs(splitSum.value - orig) < 0.0001
|
||||
})
|
||||
|
||||
const submitSplitOrder = async () => {
|
||||
if (!splitSource.value || !splitSumMatches.value) return
|
||||
splitLoading.value = true
|
||||
try {
|
||||
await orderSplit({
|
||||
id: splitSource.value.id,
|
||||
amounts: splitAmounts.value.map((x) => Number(x)),
|
||||
order_types: splitOrderTypes.value.map((x) => Number(x))
|
||||
})
|
||||
feedback.msgSuccess('拆分成功')
|
||||
splitDialogVisible.value = false
|
||||
getLists()
|
||||
fetchTodayRevenue()
|
||||
} catch (e: any) {
|
||||
if (e?.msg) feedback.msgError(e.msg)
|
||||
} finally {
|
||||
splitLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 查看详情
|
||||
const handleDetail = async (row: any) => {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user