fix: some
All checks were successful
构建并部署前端到测试环境 / deploy (push) Successful in 54s

This commit is contained in:
luo
2026-10-28 15:18:44 +08:00
parent 06684e1fc0
commit f2614d8efb
99 changed files with 11511 additions and 132 deletions

View File

@@ -0,0 +1,284 @@
<template>
<ElCard shadow="never" class="silence-detail">
<div class="detail-header"
><ElButton @click="router.back()">返回</ElButton
><h2>{{ kind === 'orders' ? '延期订单详情' : '延期批次详情' }}</h2
><ElButton :loading="loading" @click="load">刷新</ElButton></div
>
<ElAlert
v-if="error || actionError"
:title="error || actionError"
type="error"
:closable="false"
/>
<template v-if="data">
<ElDescriptions :column="width < 640 ? 1 : 2" border
><ElDescriptionsItem v-for="field in fields" :key="field.prop" :label="field.label">{{
silenceDisplay(data, field.prop)
}}</ElDescriptionsItem></ElDescriptions
>
<div
v-if="kind === 'orders' && data.status === 'pending_payment' && data.qr_content"
class="silence-qr"
><QrcodeVue :value="data.qr_content" :size="200" /><p
>支付截止:{{ data.expire_at ? formatDateTime(data.expire_at) : '-' }}</p
></div
>
<ElAlert
v-if="kind === 'orders' && data.status === 'pending_approval'"
title="审批中,尚未生效。请以订单完成状态及实际截止日为准。"
type="warning"
:closable="false"
/>
<ElButton v-if="data.package_usage_id" @click="recordsId = data.package_usage_id"
>沉默期流水</ElButton
>
<SilenceTable
v-if="kind === 'batches'"
:rows="data.items || []"
:definitions="itemFields"
@refresh="load"
><ElTableColumn label="异常处理" width="190"
><template #default="{ row }"
><template
v-if="
allowed &&
hasAuth(P.exception) &&
(row.failure_code || row.failure_summary || row.status === 'exception')
"
><ElButton link :disabled="handling" @click="handle(row, 'retry')">重试</ElButton
><ElButton link type="danger" :disabled="handling" @click="handle(row, 'close')"
>关闭</ElButton
></template
></template
></ElTableColumn
></SilenceTable
>
<h3 v-if="data.evidence_refs?.length">申请依据</h3
><PaymentVoucherDialog
v-if="data.evidence_refs?.length"
inline
:file-keys="data.evidence_refs"
/>
<h3 v-if="data.payment_voucher_keys?.length">付款凭证</h3
><PaymentVoucherDialog
v-if="data.payment_voucher_keys?.length"
inline
:file-keys="data.payment_voucher_keys"
/>
</template>
<SilenceRecordsDialog
v-if="recordsId"
:usage-id="recordsId"
:allowed="allowed"
@close="recordsId = undefined"
/>
</ElCard>
</template>
<script setup lang="ts">
import { computed, ref, onMounted, onBeforeUnmount, onDeactivated, watch } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import { useWindowSize } from '@vueuse/core'
import { ElMessageBox } from 'element-plus'
import QrcodeVue from 'qrcode.vue'
import { PackageSilenceService as Service } from '@/api/modules/packageSilence'
import {
SILENCE_PAGES,
PACKAGE_SILENCE_PERMISSIONS as P
} from '@/config/constants/packageSilence'
import { useAuth } from '@/composables/useAuth'
import { useUserStore } from '@/store/modules/user'
import { useSchedulerRequest } from '@/composables/useSchedulerRequest'
import { silenceData, silenceDisplay, silenceId } from '@/utils/business/silenceExtension'
import { pollingScope } from '@/utils/business/pollingScheduler'
import { gatewayError, requireGatewayAccess } from '@/utils/business/gateway'
import { formatDateTime } from '@/utils/business/format'
import PaymentVoucherDialog from '@/components/business/PaymentVoucherDialog.vue'
import SilenceRecordsDialog from './SilenceRecordsDialog.vue'
import SilenceTable from './SilenceTable.vue'
const props = defineProps<{ kind: 'orders' | 'batches' }>(),
route = useRoute(),
router = useRouter(),
{ width } = useWindowSize(),
{ hasAuth } = useAuth(),
user = useUserStore()
const allowed = computed(() => {
const p = SILENCE_PAGES[props.kind]
return hasAuth(p.page) && hasAuth(p.detailPage) && hasAuth(p.detail)
})
const { data, error, loading, load } = useSchedulerRequest<Record<string, any>>(
async () => {
const id = silenceId(Number(route.params.id))
return props.kind === 'orders'
? silenceData(await Service.order(id))
: silenceData(await Service.batch(id))
},
() => allowed.value
)
const recordsId = ref<number>(),
actionError = ref(''),
handling = ref(false)
const maps = {
orders: [
['order_no', '订单号'],
['status_name', '状态'],
['asset_identifier', '资产'],
['package_name', '套餐'],
['package_usage_id', '套餐记录 ID'],
['source_name', '来源'],
['input_days', '输入天数'],
['extension_days', '实际延长天数'],
['amount', '应付金额'],
['paid_amount', '实收金额'],
['payment_method', '支付方式'],
['payment_merchant_name', '收款商户'],
['third_party_trade_no', '交易流水号'],
['offline_payment_method_name', '线下收款方式'],
['offline_trade_no', '线下交易单号'],
['paid_at', '支付时间'],
['before_deadline_at', '原截止时间'],
['expected_deadline_at', '预计新截止'],
['completed_at', '实际生效时间'],
['policy_name', '政策快照'],
['approval_required', '需要审批'],
['approval_instance_id', '审批实例'],
['exception_code', '异常码'],
['exception_summary', '异常说明'],
['refund_no', '退款单号'],
['refund_amount', '退款金额'],
['refunded_at', '退款时间'],
['created_at', '创建时间']
],
batches: [
['batch_no', '批次号'],
['path', '办理路径'],
['extension_type', '延期类型'],
['status', '批次状态'],
['approval_required', '需要审批'],
['approval_status', '审批状态'],
['approval_instance_id', '审批实例'],
['reason', '原因'],
['basis', '依据'],
['amount', '费用合计'],
['requested_count', '明细数'],
['succeeded_count', '成功数'],
['failed_count', '失败数'],
['requested_by', '发起人'],
['requested_at', '发起时间'],
['completed_at', '完成时间']
]
}
const fields = computed(() => maps[props.kind].map(([prop, label]) => ({ prop, label })))
const itemFields = [
['row_no', '行号'],
['id', '明细 ID'],
['asset_identifier', '资产标识'],
['package_name', '套餐'],
['extension_type', '延期类型'],
['extension_days', '延长天数'],
['amount', '金额'],
['status', '明细状态'],
['before_deadline_at', '原截止'],
['after_deadline_at', '实际新截止'],
['executed_at', '执行时间'],
['failure_code', '异常码'],
['failure_summary', '异常原因']
].map(([prop, label]) => ({ prop, label }))
let timer: ReturnType<typeof setTimeout> | undefined,
active = true
function stop() {
if (timer) clearTimeout(timer)
timer = undefined
}
watch(data, (value) => {
stop()
if (
active &&
props.kind === 'orders' &&
['pending_payment', 'paid'].includes(value?.status) &&
allowed.value
)
timer = setTimeout(() => void load(), 3000)
})
watch(
() => [route.fullPath, allowed.value, pollingScope(user)],
() => {
stop()
recordsId.value = undefined
actionError.value = ''
void load()
}
)
async function handle(row: Record<string, any>, action: 'retry' | 'close') {
if (handling.value) return
const scope = pollingScope(user),
path = route.fullPath,
id = silenceId(row.id)
handling.value = true
try {
requireGatewayAccess(allowed.value && hasAuth(P.exception))
const { value } = await ElMessageBox.prompt(
action === 'close'
? '填写关闭原因。在线订单关闭可能按冻结商户原路退款,请确认后继续。'
: '填写重试原因,将按原快照重新执行。',
'异常处理',
{ inputValidator: (value) => !!value?.trim() || '请填写原因', type: 'warning' }
)
requireGatewayAccess(
active &&
allowed.value &&
hasAuth(P.exception) &&
scope === pollingScope(user) &&
path === route.fullPath
)
silenceData(await Service.handle(id, { id, action, reason: value.trim() }))
if (active && scope === pollingScope(user) && path === route.fullPath) await load()
} catch (e) {
if (active && e !== 'cancel' && e !== 'close') actionError.value = gatewayError(e)
} finally {
handling.value = false
}
}
onMounted(load)
onDeactivated(() => {
active = false
stop()
})
onBeforeUnmount(() => {
active = false
stop()
})
</script>
<style scoped>
.silence-detail {
margin: 16px;
}
.detail-header {
display: flex;
flex-wrap: wrap;
gap: 16px;
align-items: center;
margin-bottom: 16px;
}
.detail-header h2 {
margin: 0;
font-size: 20px;
}
.silence-qr {
padding: 16px;
text-align: center;
}
:deep(.el-descriptions__cell) {
overflow-wrap: anywhere;
}
@media (width <= 640px) {
.silence-detail {
margin: 4px;
}
}
</style>