feat:财务和合同

This commit is contained in:
李伊帆
2026-11-05 13:50:25 +08:00
parent b0a711f70a
commit 31fcd273f1
173 changed files with 11040 additions and 1067 deletions

View File

@@ -1,44 +1,88 @@
<script setup lang="ts">
import { computed, ref } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import { BUSINESS_TYPE_OPTIONS } from '@/constants/business-types'
import { getProjectDetail } from '@/constants/project-detail'
import { onLoad, onShow } from '@dcloudio/uni-app'
import { getRequirementDetail, submitRequirementAfterSale, uploadRequirementAttachment } from '@/api/requirement'
import { useRequirementBusinessTypes } from '@/hooks/use-requirement-business-types'
import deleteIcon from '@/static/icons/X.png'
import pdfIcon from '@/static/icons/PDF.png'
import pngIcon from '@/static/icons/PNG.png'
import { ensureLoggedIn } from '@/utils/auth-guard'
import { getLoginPhoneNumber } from '@/utils/auth-storage'
import { buildAfterSaleActionBody } from '@/utils/build-after-sale-action'
import {
chooseLocalFiles,
REQUIREMENT_ATTACHMENT_MAX_COUNT,
} from '@/utils/choose-local-files'
import { navigateBackWithFallback } from '@/utils/navigate-back'
import { navigateToResultPage } from '@/utils/navigate-result'
const projectId = ref('1')
const { businessTypes, loadRequirementBusinessTypes } = useRequirementBusinessTypes()
const projectId = ref('')
const fallbackUrl = ref('/pages/project-center/index')
const businessType = ref('')
const businessTypeDropdownVisible = ref(false)
const businessTypeOptions = BUSINESS_TYPE_OPTIONS
const projectName = ref('')
const description = ref('')
const userName = ref('王永志')
const userPhone = ref('186****9618')
const userName = ref('')
const userPhone = ref('')
const remark = ref('')
const submitting = ref(false)
const uploadingAttachment = ref(false)
const attachments = ref([
{ id: '1', name: '需求文档.pdf', icon: pdfIcon },
{ id: '2', name: '系统....pdf', icon: pdfIcon },
{ id: '3', name: '参考图.png', icon: pngIcon },
])
interface AfterSaleAttachmentItem {
id: string
name: string
icon: string
ossId: string
}
const attachments = ref<AfterSaleAttachmentItem[]>([])
const descLength = computed(() => description.value.length)
onLoad((options) => {
const id = options?.id ? decodeURIComponent(String(options.id)) : '1'
projectId.value = id
fallbackUrl.value = `/pages/project-center/detail/index?id=${encodeURIComponent(id)}`
function resolveAttachmentIcon(name: string) {
const ext = name.split('.').pop()?.toLowerCase()
if (ext === 'png' || ext === 'jpg' || ext === 'jpeg')
return pngIcon
const detail = getProjectDetail(id)
if (detail) {
projectName.value = detail.title
if (BUSINESS_TYPE_OPTIONS.includes(detail.category))
businessType.value = detail.category
return pdfIcon
}
async function loadRequirement(id: string) {
try {
const detail = await getRequirementDetail(id)
projectName.value = detail.projectName || ''
if (detail.businessType)
businessType.value = detail.businessType
}
catch {
// 详情失败仍允许填写售后说明
}
}
onLoad((options) => {
if (!ensureLoggedIn())
return
const id = options?.id ? decodeURIComponent(String(options.id)) : ''
if (!id) {
uni.showToast({ title: '参数错误', icon: 'none' })
return
}
projectId.value = id
fallbackUrl.value = `/pages/project-center/detail/index?id=${encodeURIComponent(id)}&tab=aftersales`
loadRequirement(id)
})
onShow(() => {
if (!ensureLoggedIn())
return
loadRequirementBusinessTypes()
const phone = getLoginPhoneNumber()
if (phone && !userPhone.value)
userPhone.value = phone
})
function handleBack() {
@@ -63,23 +107,71 @@ function handleRemoveAttachment(id: string) {
attachments.value = attachments.value.filter(item => item.id !== id)
}
function handleAddAttachment() {
uni.showToast({ title: '附件上传开发中', icon: 'none' })
async function handleAddAttachment() {
if (!ensureLoggedIn())
return
if (uploadingAttachment.value)
return
const remain = REQUIREMENT_ATTACHMENT_MAX_COUNT - attachments.value.length
if (remain <= 0) {
uni.showToast({ title: `最多上传${REQUIREMENT_ATTACHMENT_MAX_COUNT}个附件`, icon: 'none' })
return
}
try {
const files = await chooseLocalFiles(remain)
if (!files.length)
return
uploadingAttachment.value = true
uni.showLoading({ title: '上传中...', mask: true })
for (const file of files) {
const uploaded = await uploadRequirementAttachment(file.path)
const ossId = uploaded.ossId ?? uploaded.id
if (ossId === undefined || ossId === null || ossId === '') {
uni.showToast({ title: '上传失败,未返回附件 ID', icon: 'none' })
continue
}
const ossIdText = String(ossId)
const name = uploaded.fileName || file.name
attachments.value.push({
id: ossIdText,
ossId: ossIdText,
name,
icon: resolveAttachmentIcon(name),
})
}
}
catch (error) {
const message = error instanceof Error ? error.message : '上传失败'
if (!/cancel/i.test(message))
uni.showToast({ title: message, icon: 'none' })
}
finally {
uploadingAttachment.value = false
uni.hideLoading()
}
}
function handleReset() {
description.value = ''
remark.value = ''
businessType.value = ''
const detail = getProjectDetail(projectId.value)
if (detail) {
projectName.value = detail.title
if (BUSINESS_TYPE_OPTIONS.includes(detail.category))
businessType.value = detail.category
}
attachments.value = []
if (projectId.value)
loadRequirement(projectId.value)
}
function handleSubmit() {
async function handleSubmit() {
if (submitting.value || !projectId.value)
return
if (!ensureLoggedIn())
return
if (!businessType.value) {
uni.showToast({ title: '请选择业务类型', icon: 'none' })
return
@@ -89,11 +181,39 @@ function handleSubmit() {
return
}
if (!description.value.trim()) {
uni.showToast({ title: '请填写核心需求描述', icon: 'none' })
uni.showToast({ title: '请填写问题描述', icon: 'none' })
return
}
navigateToResultPage('afterSalesSuccess', { id: projectId.value })
if (description.value.trim().length > 500) {
uni.showToast({ title: '问题描述不超过500字', icon: 'none' })
return
}
submitting.value = true
uni.showLoading({ title: '提交中...', mask: true })
try {
const body = buildAfterSaleActionBody({
requirementId: projectId.value,
reason: description.value,
remark: remark.value,
businessType: businessType.value,
contactName: userName.value,
contactPhone: userPhone.value,
attachmentOssIds: attachments.value.map(item => item.ossId || item.id),
})
await submitRequirementAfterSale(projectId.value, body)
navigateToResultPage('afterSalesSuccess', { id: projectId.value })
}
catch {
// request 层已 toast
}
finally {
submitting.value = false
uni.hideLoading()
}
}
</script>
@@ -152,7 +272,7 @@ function handleSubmit() {
@tap.stop
>
<view
v-for="option in businessTypeOptions"
v-for="option in businessTypes"
:key="option"
class="after-sales-apply__dropdown-item"
:class="{ 'after-sales-apply__dropdown-item--active': businessType === option }"
@@ -182,7 +302,7 @@ function handleSubmit() {
<view class="after-sales-apply__field">
<text class="after-sales-apply__label">
核心需求描述<text class="after-sales-apply__required">
问题描述<text class="after-sales-apply__required">
*
</text>
</text>

View File

@@ -182,4 +182,10 @@
color: #ffffff;
background: $color-primary;
border-radius: 12rpx;
&--ghost {
color: $color-primary;
background: #ffffff;
border: 2rpx solid $color-primary;
}
}

View File

@@ -1,12 +1,13 @@
<script setup lang="ts">
import { computed, ref } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import { getBill } from '@/constants/bill-list'
import { PAYMENT_PLAN_STATUS_LABEL } from '@/constants/project-detail'
import { getBillDetail } from '@/api/bill'
import { BILL_STATUS_LABEL } from '@/constants/bill-list'
import billPendingIcon from '@/static/icon/bill-pending.png'
import notDueIcon from '@/static/icon/not-due.png'
import successIcon from '@/static/icons/icon-register-success.png'
import type { BillItem } from '@/types/bill'
import { mapFinanceBillToItem } from '@/utils/map-bill'
import { navigateBackWithFallback } from '@/utils/navigate-back'
type PaymentMethod = 'wechat' | 'alipay'
@@ -17,7 +18,7 @@ const paymentMethod = ref<PaymentMethod>('wechat')
const statusLabel = computed(() => {
if (!bill.value)
return ''
return PAYMENT_PLAN_STATUS_LABEL[bill.value.status] || ''
return BILL_STATUS_LABEL[bill.value.status] || ''
})
const heroIcon = computed(() => {
@@ -33,8 +34,13 @@ const heroIcon = computed(() => {
const paymentMethodLabel = computed(() => {
if (!bill.value)
return ''
if (bill.value.status === 'paid')
return paymentMethod.value === 'wechat' ? '微信支付' : '支付宝'
if (bill.value.status === 'paid') {
if (bill.value.paidMethod === 'alipay' || paymentMethod.value === 'alipay')
return '支付宝'
if (bill.value.paidMethod === 'wechat' || paymentMethod.value === 'wechat')
return '微信支付'
return bill.value.payChannel || '--'
}
if (bill.value.status === 'pending' || bill.value.status === 'not_due')
return '微信支付'
return '--'
@@ -46,13 +52,15 @@ const paymentTime = computed(() => {
if (bill.value.paidAt)
return bill.value.paidAt
if (bill.value.status === 'pending' || bill.value.status === 'not_due')
return '2026-01-21 15:00:00'
return bill.value.dueDate || '--'
return '--'
})
const orderCardTitle = computed(() => {
if (bill.value?.status === 'paid' || bill.value?.status === 'pending')
if (bill.value?.status === 'paid')
return '已支付订单'
if (bill.value?.status === 'pending')
return '待支付订单'
if (bill.value?.status === 'not_due')
return '账单订单'
return '账单订单'
@@ -65,17 +73,33 @@ const showPaymentInfo = computed(() =>
)
const showPayFooter = computed(() => bill.value?.status === 'pending')
const showRefundFooter = computed(() => bill.value?.status === 'paid')
const showFooter = computed(() => showPayFooter.value || showRefundFooter.value)
onLoad((options) => {
const projectId = options?.projectId ? decodeURIComponent(String(options.projectId)) : '1'
const planId = options?.planId ? decodeURIComponent(String(options.planId)) : '1'
onLoad(async (options) => {
const id = options?.id
? decodeURIComponent(String(options.id))
: (options?.planId ? decodeURIComponent(String(options.planId)) : '')
const method = options?.method ? decodeURIComponent(String(options.method)) : 'wechat'
paymentMethod.value = method === 'alipay' ? 'alipay' : 'wechat'
bill.value = getBill(projectId, planId)
if (!bill.value) {
if (!id) {
uni.showToast({ title: '账单不存在', icon: 'none' })
setTimeout(() => uni.navigateBack(), 1500)
return
}
uni.showLoading({ title: '加载中...', mask: true })
try {
const vo = await getBillDetail(id)
bill.value = mapFinanceBillToItem(vo)
}
catch {
bill.value = null
setTimeout(() => uni.navigateBack(), 1200)
}
finally {
uni.hideLoading()
}
})
@@ -84,7 +108,7 @@ function handleBack() {
}
function formatAmount(amount: number) {
return `¥ ${amount}`
return `¥ ${Number(amount || 0).toFixed(2)}`
}
function handlePayNow() {
@@ -92,7 +116,16 @@ function handlePayNow() {
return
uni.navigateTo({
url: `/pages/project-center/payment/index?projectId=${encodeURIComponent(bill.value.projectId)}&planId=${encodeURIComponent(bill.value.id)}`,
url: `/pages/project-center/payment/index?projectId=${encodeURIComponent(bill.value.projectId)}&planId=${encodeURIComponent(bill.value.id)}&billId=${encodeURIComponent(bill.value.id)}`,
})
}
function handleApplyRefund() {
if (!bill.value)
return
uni.navigateTo({
url: `/pages/project-center/refund-apply/index?billId=${encodeURIComponent(bill.value.id)}`,
})
}
</script>
@@ -101,7 +134,7 @@ function handlePayNow() {
<view
v-if="bill"
class="bill-detail"
:class="{ 'bill-detail--with-footer': showPayFooter }"
:class="{ 'bill-detail--with-footer': showFooter }"
>
<view class="bill-detail__navbar">
<view
@@ -203,15 +236,23 @@ function handlePayNow() {
</scroll-view>
<view
v-if="showPayFooter"
v-if="showFooter"
class="bill-detail__footer"
>
<view
v-if="showPayFooter"
class="bill-detail__pay-btn"
@tap="handlePayNow"
>
立即支付
</view>
<view
v-if="showRefundFooter"
class="bill-detail__pay-btn bill-detail__pay-btn--ghost"
@tap="handleApplyRefund"
>
申请退款
</view>
</view>
</view>
</template>

View File

@@ -0,0 +1,166 @@
@import '@/styles/variables.scss';
.bill-generate {
display: flex;
flex-direction: column;
min-height: 100vh;
background: $color-bg-section;
}
.bill-generate__navbar {
display: flex;
align-items: center;
justify-content: space-between;
flex-shrink: 0;
padding: calc(var(--status-bar-height, 44px) + 12rpx) 24rpx 20rpx;
background: $color-bg-page;
}
.bill-generate__back {
display: flex;
align-items: center;
justify-content: center;
width: 64rpx;
height: 64rpx;
}
.bill-generate__back-icon {
width: 40rpx;
height: 40rpx;
}
.bill-generate__navbar-title {
font-size: 34rpx;
font-weight: 600;
color: $color-text-primary;
}
.bill-generate__navbar-placeholder {
width: 64rpx;
height: 64rpx;
}
.bill-generate__scroll {
flex: 1;
height: 0;
padding: 20rpx 24rpx;
box-sizing: border-box;
}
.bill-generate__card {
padding: 28rpx 24rpx;
background: $color-bg-page;
border-radius: 20rpx;
}
.bill-generate__field {
margin-bottom: 28rpx;
&:last-child {
margin-bottom: 0;
}
}
.bill-generate__label {
display: block;
margin-bottom: 16rpx;
font-size: 28rpx;
font-weight: 500;
color: $color-text-primary;
}
.bill-generate__required {
color: $color-text-primary;
}
.bill-generate__label-row {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 16rpx;
.bill-generate__label {
margin-bottom: 0;
}
}
.bill-generate__hint {
font-size: 22rpx;
color: $color-text-secondary;
}
.bill-generate__input,
.bill-generate__picker {
height: 80rpx;
padding: 0 24rpx;
background: $color-bg-page;
border: 1rpx solid #e8eaef;
border-radius: 12rpx;
box-sizing: border-box;
}
.bill-generate__input {
width: 100%;
font-size: 28rpx;
color: $color-text-primary;
}
.bill-generate__picker {
display: flex;
align-items: center;
justify-content: space-between;
}
.bill-generate__picker-text {
font-size: 28rpx;
color: $color-text-primary;
&--placeholder {
color: $color-text-placeholder;
}
}
.bill-generate__picker-arrow {
font-size: 24rpx;
color: $color-text-secondary;
}
.bill-generate__placeholder {
color: $color-text-placeholder;
}
.bill-generate__textarea {
width: 100%;
min-height: 160rpx;
padding: 20rpx 24rpx;
font-size: 28rpx;
color: $color-text-primary;
background: $color-bg-page;
border: 1rpx solid #e8eaef;
border-radius: 12rpx;
box-sizing: border-box;
}
.bill-generate__footer {
flex-shrink: 0;
padding: 16rpx 24rpx calc(16rpx + env(safe-area-inset-bottom));
background: $color-bg-page;
border-top: 1rpx solid #f0f0f0;
}
.bill-generate__submit {
display: flex;
align-items: center;
justify-content: center;
height: 88rpx;
font-size: 30rpx;
font-weight: 600;
color: #ffffff;
background: $color-primary;
border-radius: 12rpx;
&--disabled {
opacity: 0.55;
pointer-events: none;
}
}

View File

@@ -0,0 +1,318 @@
<script setup lang="ts">
import { computed, ref } from 'vue'
import { generateBill } from '@/api/bill'
import {
BILL_BIZ_TYPE_OPTIONS,
BILL_TYPE_OPTIONS,
} from '@/constants/bill-list'
import type { BillGenerateBo } from '@/types/bill-api'
import { ensureLoggedIn } from '@/utils/auth-guard'
import { navigateBackWithFallback } from '@/utils/navigate-back'
const submitting = ref(false)
const bizTypeIndex = ref(-1)
const billTypeIndex = ref(-1)
const periodName = ref('')
const periodRatio = ref('')
const amount = ref('')
const dueDate = ref('')
const contractId = ref('')
const remark = ref('')
const bizTypeLabels = computed(() => BILL_BIZ_TYPE_OPTIONS.map(item => item.label))
const billTypeLabels = computed(() => BILL_TYPE_OPTIONS.map(item => item.label))
const selectedBizType = computed(() => {
if (bizTypeIndex.value < 0)
return ''
return BILL_BIZ_TYPE_OPTIONS[bizTypeIndex.value]?.label || ''
})
const selectedBillType = computed(() => {
if (billTypeIndex.value < 0)
return ''
return BILL_TYPE_OPTIONS[billTypeIndex.value]?.label || ''
})
function handleBack() {
navigateBackWithFallback('/pages/project-center/bill-list/index')
}
function handleBizTypeChange(event: { detail: { value: string } }) {
bizTypeIndex.value = Number(event.detail.value)
}
function handleBillTypeChange(event: { detail: { value: string } }) {
billTypeIndex.value = Number(event.detail.value)
}
function handleDueDateChange(event: { detail: { value: string } }) {
dueDate.value = event.detail.value
}
function validateForm() {
if (billTypeIndex.value < 0) {
uni.showToast({ title: '请选择账单类型', icon: 'none' })
return false
}
if (!periodName.value.trim()) {
uni.showToast({ title: '请输入期次名称', icon: 'none' })
return false
}
const amountNum = Number(amount.value)
if (!amount.value.trim() || !Number.isFinite(amountNum) || amountNum <= 0) {
uni.showToast({ title: '请输入正确金额', icon: 'none' })
return false
}
if (periodRatio.value.trim()) {
const ratio = Number(periodRatio.value)
if (!Number.isFinite(ratio) || ratio < 0 || ratio > 100) {
uni.showToast({ title: '比例需在 0-100 之间', icon: 'none' })
return false
}
}
if (contractId.value.trim() && !/^\d+$/.test(contractId.value.trim())) {
uni.showToast({ title: '合同 ID 需为数字', icon: 'none' })
return false
}
return true
}
function buildPayload(): BillGenerateBo {
const payload: BillGenerateBo = {
sourceType: 'MANUAL',
billType: BILL_TYPE_OPTIONS[billTypeIndex.value]?.value,
periodName: periodName.value.trim(),
amount: Number(amount.value),
}
const biz = BILL_BIZ_TYPE_OPTIONS[bizTypeIndex.value]
if (biz)
payload.bizType = biz.value
if (periodRatio.value.trim())
payload.periodRatio = Number(periodRatio.value)
if (dueDate.value)
payload.dueDate = dueDate.value
if (contractId.value.trim())
payload.contractId = contractId.value.trim()
if (remark.value.trim())
payload.supplementaryRemark = remark.value.trim()
return payload
}
async function handleSubmit() {
if (!ensureLoggedIn() || submitting.value || !validateForm())
return
submitting.value = true
uni.showLoading({ title: '生成中...', mask: true })
try {
const id = await generateBill(buildPayload())
uni.showToast({ title: '账单已生成', icon: 'none' })
setTimeout(() => {
if (id != null && String(id)) {
uni.redirectTo({
url: `/pages/project-center/bill-detail/index?id=${encodeURIComponent(String(id))}`,
})
return
}
uni.navigateBack()
}, 600)
}
catch {
// request 统一提示(无权限等)
}
finally {
submitting.value = false
uni.hideLoading()
}
}
</script>
<template>
<view class="bill-generate">
<view class="bill-generate__navbar">
<view
class="bill-generate__back"
@tap="handleBack"
>
<image
class="bill-generate__back-icon"
src="/static/icons/icon-back.svg"
mode="aspectFit"
/>
</view>
<text class="bill-generate__navbar-title">
手动建账
</text>
<view class="bill-generate__navbar-placeholder" />
</view>
<scroll-view
class="bill-generate__scroll"
scroll-y
:show-scrollbar="false"
>
<view class="bill-generate__card">
<view class="bill-generate__field">
<text class="bill-generate__label">
账单类型<text class="bill-generate__required">*</text>
</text>
<picker
mode="selector"
:range="billTypeLabels"
:value="billTypeIndex < 0 ? 0 : billTypeIndex"
@change="handleBillTypeChange"
>
<view class="bill-generate__picker">
<text
class="bill-generate__picker-text"
:class="{ 'bill-generate__picker-text--placeholder': !selectedBillType }"
>
{{ selectedBillType || '请选择账单类型' }}
</text>
<text class="bill-generate__picker-arrow">
▾
</text>
</view>
</picker>
</view>
<view class="bill-generate__field">
<text class="bill-generate__label">
期次名称<text class="bill-generate__required">*</text>
</text>
<input
v-model="periodName"
class="bill-generate__input"
placeholder="如:第1期·预付款"
placeholder-class="bill-generate__placeholder"
>
</view>
<view class="bill-generate__field">
<text class="bill-generate__label">
账单金额(元)<text class="bill-generate__required">*</text>
</text>
<input
v-model="amount"
class="bill-generate__input"
type="digit"
placeholder="请输入金额"
placeholder-class="bill-generate__placeholder"
>
</view>
<view class="bill-generate__field">
<text class="bill-generate__label">
业务类型
</text>
<picker
mode="selector"
:range="bizTypeLabels"
:value="bizTypeIndex < 0 ? 0 : bizTypeIndex"
@change="handleBizTypeChange"
>
<view class="bill-generate__picker">
<text
class="bill-generate__picker-text"
:class="{ 'bill-generate__picker-text--placeholder': !selectedBizType }"
>
{{ selectedBizType || '请选择业务类型' }}
</text>
<text class="bill-generate__picker-arrow">
▾
</text>
</view>
</picker>
</view>
<view class="bill-generate__field">
<text class="bill-generate__label">
占比(%)
</text>
<input
v-model="periodRatio"
class="bill-generate__input"
type="digit"
placeholder="可选,如 30"
placeholder-class="bill-generate__placeholder"
>
</view>
<view class="bill-generate__field">
<text class="bill-generate__label">
到期日
</text>
<picker
mode="date"
:value="dueDate"
@change="handleDueDateChange"
>
<view class="bill-generate__picker">
<text
class="bill-generate__picker-text"
:class="{ 'bill-generate__picker-text--placeholder': !dueDate }"
>
{{ dueDate || '请选择到期日' }}
</text>
<text class="bill-generate__picker-arrow">
▾
</text>
</view>
</picker>
</view>
<view class="bill-generate__field">
<view class="bill-generate__label-row">
<text class="bill-generate__label">
关联合同 ID
</text>
<text class="bill-generate__hint">
与期次名一起可防重
</text>
</view>
<input
v-model="contractId"
class="bill-generate__input"
type="number"
placeholder="可选"
placeholder-class="bill-generate__placeholder"
>
</view>
<view class="bill-generate__field">
<text class="bill-generate__label">
补充备注
</text>
<textarea
v-model="remark"
class="bill-generate__textarea"
maxlength="200"
placeholder="可选"
placeholder-class="bill-generate__placeholder"
/>
</view>
</view>
</scroll-view>
<view class="bill-generate__footer">
<view
class="bill-generate__submit"
:class="{ 'bill-generate__submit--disabled': submitting }"
@tap="handleSubmit"
>
生成账单
</view>
</view>
</view>
</template>
<style scoped lang="scss">
@import './index.scss';
</style>

View File

@@ -3,11 +3,14 @@
.bill-list {
display: flex;
flex-direction: column;
min-height: 100vh;
height: 100vh;
overflow: hidden;
background: $color-bg-section;
box-sizing: border-box;
}
.bill-list__navbar {
position: relative;
display: flex;
align-items: center;
justify-content: space-between;
@@ -17,6 +20,8 @@
}
.bill-list__back {
position: relative;
z-index: 1;
display: flex;
align-items: center;
justify-content: center;
@@ -30,9 +35,15 @@
}
.bill-list__navbar-title {
position: absolute;
left: 50%;
z-index: 0;
font-size: 34rpx;
font-weight: 600;
color: $color-text-primary;
transform: translateX(-50%);
pointer-events: none;
white-space: nowrap;
}
.bill-list__navbar-placeholder {
@@ -40,11 +51,32 @@
height: 64rpx;
}
.bill-list__navbar-actions {
position: relative;
z-index: 1;
display: flex;
align-items: center;
justify-content: flex-end;
gap: 24rpx;
min-width: 64rpx;
height: 64rpx;
padding: 0 4rpx;
}
.bill-list__navbar-action-text {
font-size: 28rpx;
color: $color-primary;
}
.bill-list__scroll {
flex: 1;
height: 0;
}
.bill-list--selecting .bill-list__content {
padding-bottom: calc(160rpx + env(safe-area-inset-bottom));
}
.bill-list__content {
padding: 24rpx 24rpx calc(32rpx + env(safe-area-inset-bottom));
}
@@ -102,11 +134,92 @@
color: $color-text-placeholder;
}
.bill-list__toolbar {
display: flex;
align-items: center;
justify-content: space-between;
gap: 16rpx;
margin-top: 20rpx;
padding: 18rpx 24rpx;
background: $color-bg-page;
border-radius: 16rpx;
}
.bill-list__toolbar-hint {
flex: 1;
min-width: 0;
font-size: 24rpx;
color: $color-text-secondary;
line-height: 1.4;
}
.bill-list__toolbar-action {
flex-shrink: 0;
font-size: 28rpx;
font-weight: 600;
color: $color-primary;
}
.bill-list__empty {
display: flex;
align-items: center;
justify-content: center;
padding: 80rpx 24rpx;
}
.bill-list__empty-text {
font-size: 28rpx;
color: $color-text-secondary;
}
.bill-list__card {
padding: 28rpx 24rpx;
margin-top: 24rpx;
background: $color-bg-page;
border: 2rpx solid transparent;
border-radius: 20rpx;
&--selected {
border-color: $color-primary;
background: rgba(37, 99, 235, 0.04);
}
}
.bill-list__card-main {
display: flex;
align-items: flex-start;
gap: 16rpx;
}
.bill-list__check {
display: flex;
flex-shrink: 0;
align-items: center;
justify-content: center;
width: 36rpx;
height: 36rpx;
margin-top: 6rpx;
border: 2rpx solid #d8dde6;
border-radius: 50%;
&--active {
background: $color-primary;
border-color: $color-primary;
}
&--disabled {
opacity: 0.35;
}
}
.bill-list__check-mark {
font-size: 20rpx;
color: #ffffff;
}
.bill-list__card-body-wrap {
flex: 1;
min-width: 0;
}
.bill-list__card-header {
@@ -146,6 +259,12 @@
background: #25eb9f;
border-radius: 40rpx;
}
&--cancelled {
color: #ffffff;
background: #9ca3af;
border-radius: 40rpx;
}
}
.bill-list__card-body {
@@ -186,3 +305,58 @@
background: $color-primary;
border-radius: 12rpx;
}
.bill-list__batch-footer {
position: fixed;
right: 0;
bottom: 0;
left: 0;
z-index: 30;
display: flex;
align-items: center;
justify-content: space-between;
gap: 20rpx;
padding: 16rpx 24rpx calc(16rpx + env(safe-area-inset-bottom));
background: $color-bg-page;
border-top: 1rpx solid #f0f0f0;
box-shadow: 0 -8rpx 24rpx rgba(15, 23, 42, 0.06);
}
.bill-list__batch-info {
display: flex;
flex: 1;
flex-direction: column;
min-width: 0;
}
.bill-list__batch-count {
font-size: 24rpx;
color: $color-text-secondary;
}
.bill-list__batch-amount {
margin-top: 6rpx;
font-size: 30rpx;
font-weight: 600;
color: $color-text-primary;
}
.bill-list__batch-btn {
display: flex;
flex-shrink: 0;
align-items: center;
justify-content: center;
min-width: 200rpx;
height: 80rpx;
padding: 0 28rpx;
font-size: 28rpx;
font-weight: 600;
color: #ffffff;
background: $color-primary;
border-radius: 12rpx;
&--disabled {
opacity: 0.45;
pointer-events: none;
}
}

View File

@@ -1,59 +1,244 @@
<script setup lang="ts">
import { computed, ref } from 'vue'
import { BILL_LIST, BILL_LIST_SUMMARY } from '@/constants/bill-list'
import { PAYMENT_PLAN_STATUS_LABEL } from '@/constants/project-detail'
import type { BillItem } from '@/types/bill'
import type { PaymentPlanStatus } from '@/types/project-detail'
import { computed, ref, watch } from 'vue'
import { onLoad, onShow } from '@dcloudio/uni-app'
import { getBillPage, getBillStatistics } from '@/api/bill'
import { BILL_PAGE_SIZE, BILL_STATUS_LABEL, EMPTY_BILL_SUMMARY } from '@/constants/bill-list'
import type { BillItem, BillListSummary } from '@/types/bill'
import type { FinanceBillStatus } from '@/types/bill-api'
import { ensureLoggedIn } from '@/utils/auth-guard'
import { chooseAndExportBills } from '@/utils/bill-export'
import { mapBillStatistics, mapFinanceBillsToItems } from '@/utils/map-bill'
import { navigateBackWithFallback } from '@/utils/navigate-back'
import LoadMoreFooter from '@/pages/case-library/components/LoadMoreFooter.vue'
const keyword = ref('')
const billList = ref(BILL_LIST.map(item => ({ ...item })))
const statusFilter = ref<FinanceBillStatus | ''>('')
const billList = ref<BillItem[]>([])
const summary = ref<BillListSummary>({ ...EMPTY_BILL_SUMMARY })
const totalCount = ref(0)
const pageNum = ref(1)
const loadingList = ref(false)
const loadingMore = ref(false)
const selectMode = ref(false)
const selectedIds = ref<string[]>([])
const filteredBills = computed(() => {
const text = keyword.value.trim()
if (!text)
return billList.value
let keywordTimer: ReturnType<typeof setTimeout> | null = null
return billList.value.filter(item =>
item.title.includes(text)
|| item.billNo.includes(text)
|| item.relatedProject.includes(text)
|| item.transactionNo.includes(text),
)
const hasMore = computed(() => billList.value.length < totalCount.value)
const loadFinished = computed(() => !hasMore.value && billList.value.length > 0)
const pendingBills = computed(() => billList.value.filter(item => item.status === 'pending'))
const selectedBills = computed(() =>
billList.value.filter(item => selectedIds.value.includes(item.id) && item.status === 'pending'),
)
const selectedCount = computed(() => selectedBills.value.length)
const selectedAmount = computed(() =>
selectedBills.value.reduce((sum, item) => sum + Number(item.amount || 0), 0),
)
function buildFilterParams() {
return {
keyword: keyword.value.trim() || undefined,
status: statusFilter.value || undefined,
}
}
async function fetchStatistics() {
try {
const vo = await getBillStatistics(buildFilterParams())
summary.value = mapBillStatistics(vo)
}
catch {
summary.value = { ...EMPTY_BILL_SUMMARY }
}
}
async function fetchBillList(reset = false) {
if (reset) {
pageNum.value = 1
billList.value = []
}
if (loadingList.value || loadingMore.value)
return
if (reset)
loadingList.value = true
else
loadingMore.value = true
try {
const result = await getBillPage({
...buildFilterParams(),
pageNum: pageNum.value,
pageSize: BILL_PAGE_SIZE,
})
const mapped = mapFinanceBillsToItems(result?.rows ?? [])
totalCount.value = Number(result?.total ?? 0)
billList.value = reset ? mapped : [...billList.value, ...mapped]
// 刷新后清理已不存在/不可支付的勾选
const pendingIdSet = new Set(
billList.value.filter(item => item.status === 'pending').map(item => item.id),
)
selectedIds.value = selectedIds.value.filter(id => pendingIdSet.has(id))
}
catch {
if (reset) {
billList.value = []
totalCount.value = 0
}
}
finally {
loadingList.value = false
loadingMore.value = false
}
}
async function refreshAll() {
await Promise.all([fetchStatistics(), fetchBillList(true)])
}
watch(keyword, () => {
if (keywordTimer)
clearTimeout(keywordTimer)
keywordTimer = setTimeout(() => {
refreshAll()
}, 400)
})
onLoad((options) => {
const rawStatus = options?.status ? decodeURIComponent(String(options.status)) : ''
if (rawStatus)
statusFilter.value = rawStatus.toUpperCase()
})
onShow(() => {
if (!ensureLoggedIn())
return
refreshAll()
})
function handleBack() {
navigateBackWithFallback('/pages/project-center/index')
if (selectMode.value) {
exitSelectMode()
return
}
navigateBackWithFallback('/pages/personal-center/finance/index')
}
function paymentStatusClass(status: PaymentPlanStatus) {
function handleExport() {
if (!ensureLoggedIn())
return
chooseAndExportBills(buildFilterParams())
}
function handleGenerate() {
if (!ensureLoggedIn())
return
uni.navigateTo({
url: '/pages/project-center/bill-generate/index',
})
}
function enterSelectMode() {
if (!pendingBills.value.length) {
uni.showToast({ title: '暂无待支付账单', icon: 'none' })
return
}
selectMode.value = true
}
function exitSelectMode() {
selectMode.value = false
selectedIds.value = []
}
function toggleSelectMode() {
if (selectMode.value)
exitSelectMode()
else
enterSelectMode()
}
function isSelected(id: string) {
return selectedIds.value.includes(id)
}
function toggleSelect(item: BillItem) {
if (item.status !== 'pending') {
uni.showToast({ title: '仅可选择待支付账单', icon: 'none' })
return
}
if (isSelected(item.id))
selectedIds.value = selectedIds.value.filter(id => id !== item.id)
else
selectedIds.value = [...selectedIds.value, item.id]
}
function statusClass(status: BillItem['status']) {
return `bill-list__tag--${status}`
}
function formatAmount(amount: number) {
return `¥ ${amount}`
return `¥ ${Number(amount || 0).toFixed(2)}`
}
function handleLoadMore() {
if (!hasMore.value || loadingList.value || loadingMore.value)
return
pageNum.value += 1
fetchBillList(false)
}
function handleBillTap(item: BillItem) {
if (item.status === 'pending' || item.status === 'paid' || item.status === 'not_due') {
const methodQuery = item.status === 'paid'
? `&method=${encodeURIComponent(item.paidMethod || 'wechat')}`
: ''
uni.navigateTo({
url: `/pages/project-center/bill-detail/index?projectId=${encodeURIComponent(item.projectId)}&planId=${encodeURIComponent(item.id)}${methodQuery}`,
})
if (selectMode.value) {
toggleSelect(item)
return
}
if (item.status === 'cancelled')
return
const methodQuery = item.status === 'paid' && item.paidMethod
? `&method=${encodeURIComponent(item.paidMethod)}`
: ''
uni.navigateTo({
url: `/pages/project-center/bill-detail/index?id=${encodeURIComponent(item.id)}&projectId=${encodeURIComponent(item.projectId)}&planId=${encodeURIComponent(item.id)}${methodQuery}`,
})
}
function handlePayNow(item: BillItem) {
uni.navigateTo({
url: `/pages/project-center/payment/index?projectId=${encodeURIComponent(item.projectId)}&planId=${encodeURIComponent(item.id)}`,
url: `/pages/project-center/payment/index?projectId=${encodeURIComponent(item.projectId)}&planId=${encodeURIComponent(item.id)}&billId=${encodeURIComponent(item.id)}`,
})
}
function handleBatchPay() {
if (!ensureLoggedIn())
return
if (selectedCount.value < 2) {
uni.showToast({ title: '请至少选择2笔待支付账单', icon: 'none' })
return
}
const ids = selectedBills.value.map(item => item.id).join(',')
uni.navigateTo({
url: `/pages/project-center/payment/index?ids=${encodeURIComponent(ids)}`,
})
}
</script>
<template>
<view class="bill-list">
<view
class="bill-list"
:class="{ 'bill-list--selecting': selectMode }"
>
<view class="bill-list__navbar">
<view
class="bill-list__back"
@@ -66,21 +251,41 @@ function handlePayNow(item: BillItem) {
/>
</view>
<text class="bill-list__navbar-title">
账单明细
{{ selectMode ? '选择账单' : '账单明细' }}
</text>
<view class="bill-list__navbar-placeholder" />
<view class="bill-list__navbar-actions">
<template v-if="!selectMode">
<text
class="bill-list__navbar-action-text"
@tap="handleGenerate"
>
建账
</text>
<text
class="bill-list__navbar-action-text"
@tap="handleExport"
>
导出
</text>
</template>
<view
v-else
class="bill-list__navbar-placeholder"
/>
</view>
</view>
<scroll-view
class="bill-list__scroll"
scroll-y
:show-scrollbar="false"
@scrolltolower="handleLoadMore"
>
<view class="bill-list__content">
<view class="bill-list__summary">
<view class="bill-list__summary-item">
<text class="bill-list__summary-value">
{{ BILL_LIST_SUMMARY.totalCount }}
{{ summary.totalCount }}
</text>
<text class="bill-list__summary-label">
总笔数
@@ -88,7 +293,7 @@ function handlePayNow(item: BillItem) {
</view>
<view class="bill-list__summary-item">
<text class="bill-list__summary-value">
¥ {{ BILL_LIST_SUMMARY.totalAmount }}
¥ {{ summary.totalAmount }}
</text>
<text class="bill-list__summary-label">
总金额
@@ -96,7 +301,7 @@ function handlePayNow(item: BillItem) {
</view>
<view class="bill-list__summary-item">
<text class="bill-list__summary-value">
{{ BILL_LIST_SUMMARY.pendingCount }}
{{ summary.pendingCount }}
</text>
<text class="bill-list__summary-label">
待支付
@@ -104,6 +309,18 @@ function handlePayNow(item: BillItem) {
</view>
</view>
<view class="bill-list__toolbar">
<text class="bill-list__toolbar-hint">
{{ selectMode ? '请勾选至少 2 笔待支付账单' : '可勾选多笔待支付账单合并付款' }}
</text>
<text
class="bill-list__toolbar-action"
@tap="toggleSelectMode"
>
{{ selectMode ? '取消' : '合并支付' }}
</text>
</view>
<view class="bill-list__search">
<image
class="bill-list__search-icon"
@@ -113,57 +330,126 @@ function handlePayNow(item: BillItem) {
<input
v-model="keyword"
class="bill-list__search-input"
placeholder="搜索案例标题、描述、标签..."
placeholder="搜索账单号、项目名、交易名称"
placeholder-class="bill-list__search-placeholder"
>
</view>
<view
v-for="item in filteredBills"
:key="`${item.projectId}-${item.id}`"
v-if="loadingList && !billList.length"
class="bill-list__empty"
>
<text class="bill-list__empty-text">
加载中...
</text>
</view>
<view
v-else-if="!billList.length"
class="bill-list__empty"
>
<text class="bill-list__empty-text">
暂无账单
</text>
</view>
<view
v-for="item in billList"
:key="item.id"
class="bill-list__card"
:class="{ 'bill-list__card--selected': selectMode && isSelected(item.id) }"
@tap="handleBillTap(item)"
>
<view class="bill-list__card-header">
<text class="bill-list__card-title">
{{ item.title }} {{ item.ratio }}
</text>
<text
class="bill-list__tag"
:class="paymentStatusClass(item.status)"
<view class="bill-list__card-main">
<view
v-if="selectMode"
class="bill-list__check"
:class="{
'bill-list__check--active': isSelected(item.id),
'bill-list__check--disabled': item.status !== 'pending',
}"
@tap.stop="toggleSelect(item)"
>
{{ PAYMENT_PLAN_STATUS_LABEL[item.status] }}
</text>
</view>
<view class="bill-list__card-body">
<view class="bill-list__card-meta">
<text
v-if="item.status === 'paid'"
class="bill-list__card-row"
v-if="isSelected(item.id)"
class="bill-list__check-mark"
>
交易流水号:{{ item.transactionNo }}
</text>
<text class="bill-list__card-row">
账单号:{{ item.billNo }}
</text>
<text class="bill-list__card-row">
关联项目:{{ item.relatedProject }}
✓
</text>
</view>
<text class="bill-list__card-amount">
{{ formatAmount(item.amount) }}
</text>
<view class="bill-list__card-body-wrap">
<view class="bill-list__card-header">
<text class="bill-list__card-title">
{{ item.title }} {{ item.ratio }}
</text>
<text
class="bill-list__tag"
:class="statusClass(item.status)"
>
{{ BILL_STATUS_LABEL[item.status] }}
</text>
</view>
<view class="bill-list__card-body">
<view class="bill-list__card-meta">
<text
v-if="item.status === 'paid' && item.transactionNo !== '-'"
class="bill-list__card-row"
>
交易流水号:{{ item.transactionNo }}
</text>
<text class="bill-list__card-row">
账单号:{{ item.billNo }}
</text>
<text class="bill-list__card-row">
关联项目:{{ item.relatedProject }}
</text>
</view>
<text class="bill-list__card-amount">
{{ formatAmount(item.amount) }}
</text>
</view>
</view>
</view>
<view
v-if="item.status === 'pending'"
v-if="!selectMode && item.status === 'pending'"
class="bill-list__pay-btn"
@tap.stop="handlePayNow(item)"
>
立即支付
</view>
</view>
<LoadMoreFooter
:loading="loadingMore"
:has-more="hasMore"
:finished="loadFinished"
@load-more="handleLoadMore"
/>
</view>
</scroll-view>
<view
v-if="selectMode"
class="bill-list__batch-footer"
>
<view class="bill-list__batch-info">
<text class="bill-list__batch-count">
已选 {{ selectedCount }} 笔
</text>
<text class="bill-list__batch-amount">
合计 {{ formatAmount(selectedAmount) }}
</text>
</view>
<view
class="bill-list__batch-btn"
:class="{ 'bill-list__batch-btn--disabled': selectedCount < 2 }"
@tap="handleBatchPay"
>
去支付
</view>
</view>
</view>
</template>

View File

@@ -25,12 +25,13 @@
.project-center-card__status {
flex-shrink: 0;
font-size: 24rpx;
color: $color-text-secondary;
color: #666666;
}
.project-center-card__meta {
display: flex;
align-items: center;
gap: 12rpx;
margin-top: 16rpx;
}
@@ -38,15 +39,14 @@
flex-shrink: 0;
padding: 4rpx 12rpx;
font-size: 20rpx;
color: $color-primary;
background: $color-primary-light;
border-radius: 6rpx;
color: white;
background: #2563EB;
border-radius: 188.93rpx 188.93rpx 188.93rpx 188.93rpx;
}
.project-center-card__no {
flex: 1;
min-width: 0;
margin-left: 12rpx;
font-size: 22rpx;
color: #666666;
white-space: nowrap;
@@ -82,15 +82,7 @@
}
.project-center-card__footer {
display: flex;
align-items: center;
justify-content: space-between;
margin-top: 20rpx;
&--simple {
justify-content: flex-end;
margin-top: 24rpx;
}
}
.project-center-card__time {
@@ -99,6 +91,7 @@
}
.project-center-card__detail {
flex-shrink: 0;
font-size: 24rpx;
color: #666666;
}

View File

@@ -1,13 +1,19 @@
<script setup lang="ts">
import { computed } from 'vue'
import type { ProjectCenterItem } from '@/types/project-center'
defineProps<{
const props = defineProps<{
item: ProjectCenterItem
}>()
const emit = defineEmits<{
detail: [id: string]
}>()
const showProgress = computed(() => {
const progress = props.item.progress
return progress !== undefined && progress > 0
})
</script>
<template>
@@ -28,10 +34,16 @@ const emit = defineEmits<{
<text class="project-center-card__no">
项目编号:{{ item.projectNo }}
</text>
<text
class="project-center-card__detail"
@tap.stop="emit('detail', item.id)"
>
查看详情 >
</text>
</view>
<view
v-if="item.status === '进行中' && item.progress !== undefined"
v-if="showProgress"
class="project-center-card__progress"
>
<view class="project-center-card__progress-bar">
@@ -46,21 +58,12 @@ const emit = defineEmits<{
</view>
<view
v-if="showProgress && item.updateTime"
class="project-center-card__footer"
:class="{ 'project-center-card__footer--simple': item.status !== '进行中' }"
>
<text
v-if="item.updateTime"
class="project-center-card__time"
>
<text class="project-center-card__time">
更新时间:{{ item.updateTime }}
</text>
<text
class="project-center-card__detail"
@tap.stop="emit('detail', item.id)"
>
查看详情 >
</text>
</view>
</view>
</template>

View File

@@ -1,15 +1,24 @@
<script setup lang="ts">
import { ref } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import { getProjectDetail, PAYMENT_PLAN_STATUS_LABEL } from '@/constants/project-detail'
import type { PaymentPlanStatus } from '@/types/project-detail'
import { onLoad, onShow } from '@dcloudio/uni-app'
import { getContractsByProjectNo } from '@/api/contract'
import { getRequirementDetail, withdrawRequirementAfterSale } from '@/api/requirement'
import { PAYMENT_PLAN_STATUS_LABEL } from '@/constants/project-detail'
import type { PaymentPlanStatus, ProjectFileItem } from '@/types/project-detail'
import afterSalesIcon from '@/static/icons/售后.png'
import cardBg from '@/static/icons/new-card.png'
import deleteIcon from '@/static/icons/X.png'
import type { ProjectDetail, ProjectDetailTab } from '@/types/project-detail'
import { ensureLoggedIn } from '@/utils/auth-guard'
import { openContractPreview } from '@/utils/contract-preview'
import { mapContractVosToProjectFiles } from '@/utils/map-contract'
import { navigateBackWithFallback } from '@/utils/navigate-back'
import { mapProjectRequirementToDetail } from '@/utils/map-requirement-detail'
const detail = ref<ProjectDetail | null>(null)
const requirementId = ref('')
const loading = ref(true)
const withdrawingAfterSale = ref(false)
const activeTab = ref<ProjectDetailTab>('progress')
const tabs: Array<{ key: ProjectDetailTab, label: string }> = [
@@ -19,19 +28,61 @@ const tabs: Array<{ key: ProjectDetailTab, label: string }> = [
{ key: 'aftersales', label: '售后信息' },
]
async function loadProjectContracts(projectNo?: string) {
if (!detail.value || !projectNo)
return
try {
const rows = await getContractsByProjectNo(projectNo)
detail.value.contractFiles = mapContractVosToProjectFiles(rows ?? [])
}
catch {
detail.value.contractFiles = []
}
}
async function loadDetail(id: string) {
loading.value = true
uni.showLoading({ title: '加载中...', mask: true })
try {
const data = await getRequirementDetail(id)
detail.value = mapProjectRequirementToDetail(data)
await loadProjectContracts(detail.value.projectNo)
}
catch {
detail.value = null
uni.showToast({ title: '加载失败', icon: 'none' })
setTimeout(() => {
navigateBackWithFallback('/pages/project-center/index')
}, 1500)
}
finally {
loading.value = false
uni.hideLoading()
}
}
onLoad((options) => {
const rawId = options?.id
const id = rawId ? decodeURIComponent(String(rawId)) : '1'
const id = rawId ? decodeURIComponent(String(rawId)) : ''
const tab = options?.tab ? decodeURIComponent(String(options.tab)) : ''
detail.value = getProjectDetail(id)
if (tab === 'aftersales' || tab === 'progress' || tab === 'files' || tab === 'finance')
activeTab.value = tab
if (!detail.value) {
uni.showToast({ title: '项目不存在', icon: 'none' })
setTimeout(() => uni.navigateBack(), 1500)
if (!id) {
loading.value = false
uni.showToast({ title: '参数错误', icon: 'none' })
return
}
requirementId.value = id
loadDetail(id)
})
onShow(() => {
ensureLoggedIn()
})
function handleBack() {
@@ -68,8 +119,72 @@ function handleApplyAfterSales() {
})
}
function handleOpenContractFile(file: ProjectFileItem) {
if (file.contractId) {
openContractPreview(file.contractId)
return
}
if (file.url) {
uni.downloadFile({
url: file.url,
success: (res) => {
if (res.statusCode !== 200) {
uni.showToast({ title: '打开失败', icon: 'none' })
return
}
uni.openDocument({
filePath: res.tempFilePath,
showMenu: true,
fail: () => uni.showToast({ title: '无法打开文件', icon: 'none' }),
})
},
fail: () => uni.showToast({ title: '打开失败', icon: 'none' }),
})
return
}
uni.showToast({ title: '暂无合同文件', icon: 'none' })
}
function handleCancelAfterSales() {
uni.showToast({ title: '取消售后功能开发中', icon: 'none' })
if (!detail.value || !requirementId.value || withdrawingAfterSale.value)
return
if (!ensureLoggedIn())
return
if (!detail.value.afterSales.processing) {
uni.showToast({ title: '当前没有进行中的售后申请', icon: 'none' })
return
}
uni.showModal({
title: '撤回售后',
content: '确定要撤回当前售后申请吗?',
confirmText: '撤回',
cancelText: '取消',
success: async (res) => {
if (!res.confirm)
return
withdrawingAfterSale.value = true
uni.showLoading({ title: '提交中...', mask: true })
try {
await withdrawRequirementAfterSale(requirementId.value, {
reason: '用户撤回售后申请',
})
uni.showToast({ title: '已撤回售后申请', icon: 'success' })
await loadDetail(requirementId.value)
}
catch {
// request 层已 toast
}
finally {
withdrawingAfterSale.value = false
uni.hideLoading()
}
},
})
}
function handleAddAfterSalesAttachment() {
@@ -378,19 +493,16 @@ function handleAddAfterSalesAttachment() {
<text class="project-detail__panel-title">
合同文件
</text>
<view class="project-detail__files">
<view
v-if="detail.contractFiles.length"
class="project-detail__files"
>
<view
v-for="file in detail.contractFiles"
:key="file.id"
class="project-detail__file"
@tap="handleOpenContractFile(file)"
>
<view class="project-detail__file-remove">
<image
class="project-detail__file-remove-icon"
:src="deleteIcon"
mode="aspectFit"
/>
</view>
<image
class="project-detail__file-icon"
:src="file.icon"
@@ -401,6 +513,12 @@ function handleAddAfterSalesAttachment() {
</text>
</view>
</view>
<text
v-else
class="project-detail__empty-text"
>
暂无合同
</text>
</view>
</view>
@@ -509,8 +627,29 @@ function handleAddAfterSalesAttachment() {
</view>
</scroll-view>
</view>
<view
v-else-if="!loading"
class="project-detail project-detail--empty"
>
<text class="project-detail__empty-text">
暂无详情
</text>
</view>
</template>
<style scoped lang="scss">
@import './index.scss';
.project-detail--empty {
display: flex;
align-items: center;
justify-content: center;
min-height: 100vh;
}
.project-detail__empty-text {
font-size: 28rpx;
color: #999999;
}
</style>

View File

@@ -1,38 +1,128 @@
<script setup lang="ts">
import { computed, ref } from 'vue'
import { computed, ref, watch } from 'vue'
import { onShow } from '@dcloudio/uni-app'
import { getRequirementList } from '@/api/requirement'
import AppTabBar from '@/components/AppTabBar.vue'
import { DEFAULT_CASE_FILTER } from '@/constants/case-library'
import {
PROJECT_CATEGORIES,
PROJECT_CENTER_LIST,
PROJECT_PAGE_SIZE,
} from '@/constants/project-center'
import { useRequirementBusinessTypes } from '@/hooks/use-requirement-business-types'
import filterIcon from '@/static/icons/icon-filter.svg'
import type { CaseFilterValues } from '@/types/case-library'
import type { ProjectCategory } from '@/types/project-center'
import type { ProjectCategory, ProjectCenterItem } from '@/types/project-center'
import { ensureLoggedIn } from '@/utils/auth-guard'
import { buildRequirementListQuery } from '@/utils/build-requirement-list-query'
import type { CaseFilterTarget } from '@/utils/case-filter'
import { cloneCaseFilter, matchCaseFilter } from '@/utils/case-filter'
import { ensureCaseBusinessTypeMap } from '@/utils/ensure-case-business-type-map'
import { fetchRequirementListByBusinessTypes } from '@/utils/fetch-requirement-by-types'
import { mapProjectRequirementsToCenterItems } from '@/utils/map-requirement'
import CaseFilterPanel from '../case-library/components/CaseFilterPanel.vue'
import LoadMoreFooter from '../case-library/components/LoadMoreFooter.vue'
import ProjectCenterCard from './components/ProjectCenterCard.vue'
const { businessTypes, loadRequirementBusinessTypes } = useRequirementBusinessTypes()
const keyword = ref('')
const activeCategory = ref<ProjectCategory>('全部')
const projectList = ref(PROJECT_CENTER_LIST.map(item => ({ ...item })))
const projectList = ref<ProjectCenterItem[]>([])
const totalCount = ref(0)
const pageNum = ref(1)
const loadingList = ref(false)
const loadingMore = ref(false)
const filterVisible = ref(false)
const appliedFilter = ref<CaseFilterValues>(cloneCaseFilter(DEFAULT_CASE_FILTER))
const filteredProjects = computed(() => {
const text = keyword.value.trim()
let keywordTimer: ReturnType<typeof setTimeout> | null = null
return projectList.value.filter((item) => {
const matchCategory = activeCategory.value === '全部' || item.category === activeCategory.value
const matchKeyword = !text
|| item.title.includes(text)
|| item.category.includes(text)
|| item.projectNo.includes(text)
|| item.status.includes(text)
|| item.industry.includes(text)
const matchFilter = matchCaseFilter(item, appliedFilter.value)
return matchCategory && matchKeyword && matchFilter
})
function toFilterTarget(item: ProjectCenterItem): CaseFilterTarget {
return {
industry: item.category,
scale: item.scale,
completedAt: item.completedAt,
}
}
const filterTargets = computed(() => projectList.value.map(toFilterTarget))
const filteredProjects = computed(() => {
return projectList.value.filter(item => matchCaseFilter(toFilterTarget(item), appliedFilter.value))
})
const hasMore = computed(() => projectList.value.length < totalCount.value)
const loadFinished = computed(() => !hasMore.value && projectList.value.length > 0)
async function fetchProjectList(reset = false) {
if (reset) {
pageNum.value = 1
projectList.value = []
}
if (loadingList.value || loadingMore.value)
return
if (reset)
loadingList.value = true
else
loadingMore.value = true
try {
await ensureCaseBusinessTypeMap()
const { query, businessTypeValues } = buildRequirementListQuery({
keyword: keyword.value,
activeCategory: activeCategory.value,
filter: appliedFilter.value,
pageNum: pageNum.value,
pageSize: PROJECT_PAGE_SIZE,
})
const result = businessTypeValues.length
? await fetchRequirementListByBusinessTypes(query, businessTypeValues)
: await getRequirementList(query)
const rows = result?.rows ?? []
const mapped = mapProjectRequirementsToCenterItems(rows)
totalCount.value = Number(result?.total ?? 0)
projectList.value = reset
? mapped
: [...projectList.value, ...mapped]
}
catch {
if (reset) {
projectList.value = []
totalCount.value = 0
}
}
finally {
loadingList.value = false
loadingMore.value = false
}
}
watch(keyword, () => {
if (keywordTimer)
clearTimeout(keywordTimer)
keywordTimer = setTimeout(() => {
fetchProjectList(true)
}, 400)
})
watch(activeCategory, () => {
fetchProjectList(true)
})
onShow(async () => {
if (!ensureLoggedIn())
return
await Promise.all([
loadRequirementBusinessTypes(),
ensureCaseBusinessTypeMap(),
])
fetchProjectList(true)
})
function handleSelectCategory(category: ProjectCategory) {
@@ -49,6 +139,15 @@ function handleCloseFilter() {
function handleConfirmFilter(value: CaseFilterValues) {
appliedFilter.value = cloneCaseFilter(value)
fetchProjectList(true)
}
function handleLoadMore() {
if (loadingMore.value || !hasMore.value)
return
pageNum.value += 1
fetchProjectList(false)
}
function handleViewDetail(id: string) {
@@ -74,7 +173,7 @@ function handleViewDetail(id: string) {
<input
v-model="keyword"
class="project-center__search-input"
placeholder="搜索案例标题、描述、标签..."
placeholder="搜索项目名称、编号、状态..."
placeholder-class="project-center__search-placeholder"
>
</view>
@@ -99,7 +198,7 @@ function handleViewDetail(id: string) {
<view class="project-center__toolbar">
<text class="project-center__count">
共 {{ filteredProjects.length }}
共 {{ totalCount }}
</text>
<view
class="project-center__filter"
@@ -121,6 +220,8 @@ function handleViewDetail(id: string) {
class="project-center__scroll"
scroll-y
:show-scrollbar="false"
:lower-threshold="120"
@scrolltolower="handleLoadMore"
>
<view class="project-center__list">
<ProjectCenterCard
@@ -129,6 +230,13 @@ function handleViewDetail(id: string) {
:item="item"
@detail="handleViewDetail"
/>
<LoadMoreFooter
:loading="loadingList || loadingMore"
:has-more="hasMore"
:finished="loadFinished"
@load-more="handleLoadMore"
/>
</view>
</scroll-view>
@@ -136,7 +244,9 @@ function handleViewDetail(id: string) {
<CaseFilterPanel
:visible="filterVisible"
:cases="projectList"
:cases="filterTargets"
:industries="businessTypes"
industry-label="业务类型"
:value="appliedFilter"
@close="handleCloseFilter"
@confirm="handleConfirmFilter"

View File

@@ -60,6 +60,14 @@
color: $color-text-primary;
}
.payment-success__order-block {
& + & {
margin-top: 20rpx;
padding-top: 20rpx;
border-top: 1rpx dashed #f0f0f0;
}
}
.payment-success__info-row {
display: flex;
align-items: flex-start;

View File

@@ -1,40 +1,119 @@
<script setup lang="ts">
import { computed, ref } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import { getPaymentPlan } from '@/constants/project-detail'
import { getBillDetail } from '@/api/bill'
import { queryPayResult } from '@/api/pay'
import successIcon from '@/static/icons/icon-register-success.png'
import type { PaymentPlanItem } from '@/types/project-detail'
import type { BillItem } from '@/types/bill'
import { mapFinanceBillToItem } from '@/utils/map-bill'
type PaymentMethod = 'wechat' | 'alipay'
const bills = ref<BillItem[]>([])
const billId = ref('')
const billIds = ref<string[]>([])
const projectId = ref('')
const channel = ref('WECHAT')
const paymentTime = ref('--')
const transactionNo = ref('--')
const displayAmount = ref(0)
const orderCount = ref(1)
const plan = ref<PaymentPlanItem | null>(null)
const projectId = ref('1')
const planId = ref('2')
const paymentMethod = ref<PaymentMethod>('wechat')
const paymentTime = ref('2026-01-21 15:00:00')
const transactionNo = ref('T20260819153035678K2M001')
const paymentMethodLabel = computed(() => {
const key = channel.value.toUpperCase()
if (key === 'ALIPAY')
return '支付宝'
if (key === 'BANK')
return '银行转账'
if (key === 'WORKWX')
return '企业微信'
return '微信支付'
})
const paymentMethodLabel = computed(() =>
paymentMethod.value === 'wechat' ? '微信支付' : '支付宝',
)
const isBatch = computed(() => orderCount.value > 1)
onLoad((options) => {
projectId.value = options?.projectId ? decodeURIComponent(String(options.projectId)) : '1'
planId.value = options?.planId ? decodeURIComponent(String(options.planId)) : '2'
const method = options?.method ? decodeURIComponent(String(options.method)) : 'wechat'
paymentMethod.value = method === 'alipay' ? 'alipay' : 'wechat'
plan.value = getPaymentPlan(projectId.value, planId.value)
onLoad(async (options) => {
const rawIds = options?.ids ? decodeURIComponent(String(options.ids)) : ''
const ids = rawIds
? rawIds.split(',').map(item => item.trim()).filter(Boolean)
: []
if (!plan.value) {
const id = options?.id
? decodeURIComponent(String(options.id))
: (options?.billId
? decodeURIComponent(String(options.billId))
: (options?.planId ? decodeURIComponent(String(options.planId)) : (ids[0] || '')))
if (id && !ids.includes(id))
ids.unshift(id)
billId.value = id
billIds.value = ids
projectId.value = options?.projectId ? decodeURIComponent(String(options.projectId)) : ''
channel.value = options?.channel
? decodeURIComponent(String(options.channel)).toUpperCase()
: (options?.method === 'alipay' ? 'ALIPAY' : 'WECHAT')
orderCount.value = Number(options?.count) || ids.length || 1
const amountFromQuery = Number(options?.amount)
if (Number.isFinite(amountFromQuery) && amountFromQuery > 0)
displayAmount.value = amountFromQuery
const outTradeNo = options?.outTradeNo
? decodeURIComponent(String(options.outTradeNo))
: ''
if (!ids.length) {
uni.showToast({ title: '订单不存在', icon: 'none' })
setTimeout(() => {
uni.redirectTo({ url: '/pages/project-center/index' })
}, 1500)
uni.redirectTo({ url: '/pages/project-center/bill-list/index' })
}, 1200)
return
}
uni.showLoading({ title: '加载中...', mask: true })
try {
const vos = await Promise.all(ids.map(itemId => getBillDetail(itemId)))
bills.value = vos.map(mapFinanceBillToItem)
if (!displayAmount.value)
displayAmount.value = bills.value.reduce((sum, item) => sum + Number(item.amount || 0), 0)
if (!projectId.value)
projectId.value = bills.value.find(item => item.projectId)?.projectId || ''
const firstPaid = bills.value.find(item => item.paidAt)
if (firstPaid?.paidAt)
paymentTime.value = firstPaid.paidAt
const firstTxn = bills.value.find(item => item.transactionNo && item.transactionNo !== '-')
if (firstTxn?.transactionNo)
transactionNo.value = firstTxn.transactionNo
if (outTradeNo) {
try {
const payResult = await queryPayResult(outTradeNo)
if (payResult.payTime)
paymentTime.value = payResult.payTime
if (payResult.transactionNo)
transactionNo.value = payResult.transactionNo
}
catch {
// 查询失败仍展示账单信息
}
}
}
catch {
bills.value = []
setTimeout(() => {
uni.redirectTo({ url: '/pages/project-center/bill-list/index' })
}, 1200)
}
finally {
uni.hideLoading()
}
})
function formatAmount(amount: number) {
return `¥ ${amount}`
return `¥ ${Number(amount || 0).toFixed(2)}`
}
function handleBackToList() {
@@ -43,14 +122,14 @@ function handleBackToList() {
function handleViewDetail() {
uni.redirectTo({
url: `/pages/project-center/bill-detail/index?projectId=${encodeURIComponent(projectId.value)}&planId=${encodeURIComponent(planId.value)}&method=${encodeURIComponent(paymentMethod.value)}`,
url: `/pages/project-center/bill-detail/index?id=${encodeURIComponent(billId.value || billIds.value[0] || '')}`,
})
}
</script>
<template>
<view
v-if="plan"
v-if="bills.length"
class="payment-success"
>
<scroll-view
@@ -69,7 +148,7 @@ function handleViewDetail() {
支付成功
</text>
<text class="payment-success__subtitle">
共1个订单,付款金额:{{ formatAmount(plan.amount) }}
共{{ orderCount }}个订单,付款金额:{{ formatAmount(displayAmount) }}
</text>
</view>
@@ -105,22 +184,28 @@ function handleViewDetail() {
<view class="payment-success__card">
<text class="payment-success__card-title">
已支付订单
{{ isBatch ? '已支付订单' : '已支付订单' }}
</text>
<view class="payment-success__order-row">
<text class="payment-success__order-title">
{{ plan.title }} {{ plan.ratio }}
<view
v-for="item in bills"
:key="item.id"
class="payment-success__order-block"
>
<view class="payment-success__order-row">
<text class="payment-success__order-title">
{{ item.title }} {{ item.ratio }}
</text>
<text class="payment-success__order-amount">
{{ formatAmount(item.amount) }}
</text>
</view>
<text class="payment-success__order-meta">
账单号:{{ item.billNo }}
</text>
<text class="payment-success__order-amount">
{{ formatAmount(plan.amount) }}
<text class="payment-success__order-meta">
关联项目:{{ item.relatedProject }}
</text>
</view>
<text class="payment-success__order-meta">
账单号:{{ plan.billNo }}
</text>
<text class="payment-success__order-meta">
关联项目:{{ plan.relatedProject }}
</text>
</view>
</view>
</scroll-view>

View File

@@ -77,6 +77,15 @@
margin-top: 24rpx;
}
.project-payment__order-block {
padding-top: 20rpx;
& + & {
margin-top: 16rpx;
border-top: 1rpx dashed #f0f0f0;
}
}
.project-payment__order-title {
flex: 1;
padding-right: 16rpx;
@@ -179,6 +188,29 @@
border-top: 1rpx solid #f0f0f0;
}
.project-payment__order-block {
padding-bottom: 20rpx;
margin-bottom: 20rpx;
border-bottom: 1rpx solid #f0f0f0;
&:last-of-type {
margin-bottom: 0;
border-bottom: none;
}
}
.project-payment__empty {
display: flex;
align-items: center;
justify-content: center;
padding: 32rpx 0 8rpx;
}
.project-payment__empty-text {
font-size: 26rpx;
color: $color-text-secondary;
}
.project-payment__confirm-btn {
display: flex;
align-items: center;
@@ -188,4 +220,9 @@
color: #ffffff;
background: $color-primary;
border-radius: 12rpx;
&--disabled {
opacity: 0.55;
pointer-events: none;
}
}

View File

@@ -1,34 +1,95 @@
<script setup lang="ts">
import { ref } from 'vue'
import { computed, ref } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import { getPaymentPlan } from '@/constants/project-detail'
import alipayIcon from '@/static/icons/支付宝.png'
import wechatIcon from '@/static/icons/微信.png'
import type { PaymentPlanItem } from '@/types/project-detail'
import { getBillDetail } from '@/api/bill'
import { getPayChannels, payBill, payBillBatch } from '@/api/pay'
import type { BillItem } from '@/types/bill'
import { ensureLoggedIn } from '@/utils/auth-guard'
import { invokePayFromResult } from '@/utils/invoke-pay'
import { mapFinanceBillToItem } from '@/utils/map-bill'
import { mapPayChannelsToOptions, type PayChannelOption } from '@/utils/map-pay'
import { navigateBackWithFallback } from '@/utils/navigate-back'
type PaymentMethod = 'wechat' | 'alipay'
const bills = ref<BillItem[]>([])
const billIds = ref<string[]>([])
const projectId = ref('')
const channels = ref<PayChannelOption[]>([])
const selectedChannel = ref('')
const loading = ref(false)
const paying = ref(false)
const fallbackUrl = ref('/pages/project-center/bill-list/index')
const plan = ref<PaymentPlanItem | null>(null)
const projectId = ref('1')
const planId = ref('2')
const paymentMethod = ref<PaymentMethod>('wechat')
const fallbackUrl = ref('/pages/project-center/index')
const isBatch = computed(() => billIds.value.length > 1)
const totalAmount = computed(() =>
bills.value.reduce((sum, item) => sum + Number(item.amount || 0), 0),
)
const allPayable = computed(() =>
bills.value.length > 0 && bills.value.every(item => item.status === 'pending'),
)
const selectedChannelName = computed(() => {
return channels.value.find(item => item.code === selectedChannel.value)?.name || ''
})
const paymentMethods: Array<{ key: PaymentMethod, label: string, icon: string }> = [
{ key: 'wechat', label: '微信支付', icon: wechatIcon },
{ key: 'alipay', label: '支付宝', icon: alipayIcon },
]
function parseIds(options?: Record<string, unknown>) {
const rawIds = options?.ids ? decodeURIComponent(String(options.ids)) : ''
if (rawIds) {
return rawIds
.split(',')
.map(item => item.trim())
.filter(Boolean)
}
onLoad((options) => {
projectId.value = options?.projectId ? decodeURIComponent(String(options.projectId)) : '1'
planId.value = options?.planId ? decodeURIComponent(String(options.planId)) : '2'
fallbackUrl.value = `/pages/project-center/detail/index?id=${encodeURIComponent(projectId.value)}`
plan.value = getPaymentPlan(projectId.value, planId.value)
const single = options?.billId
? decodeURIComponent(String(options.billId))
: (options?.id
? decodeURIComponent(String(options.id))
: (options?.planId ? decodeURIComponent(String(options.planId)) : ''))
if (!plan.value) {
uni.showToast({ title: '订单不存在', icon: 'none' })
setTimeout(() => uni.navigateBack(), 1500)
return single ? [single] : []
}
onLoad(async (options) => {
if (!ensureLoggedIn())
return
const ids = parseIds(options)
projectId.value = options?.projectId ? decodeURIComponent(String(options.projectId)) : ''
billIds.value = ids
fallbackUrl.value = ids.length === 1
? `/pages/project-center/bill-detail/index?id=${encodeURIComponent(ids[0])}`
: '/pages/project-center/bill-list/index'
if (!ids.length) {
uni.showToast({ title: '账单不存在', icon: 'none' })
setTimeout(() => uni.navigateBack(), 1200)
return
}
loading.value = true
uni.showLoading({ title: '加载中...', mask: true })
try {
const [channelRows, ...billVos] = await Promise.all([
getPayChannels(),
...ids.map(id => getBillDetail(id)),
])
bills.value = billVos.map(mapFinanceBillToItem)
if (!projectId.value)
projectId.value = bills.value.find(item => item.projectId)?.projectId || ''
channels.value = mapPayChannelsToOptions(channelRows)
selectedChannel.value = channels.value[0]?.code || ''
if (!allPayable.value)
uni.showToast({ title: '存在不可支付账单', icon: 'none' })
}
catch {
bills.value = []
setTimeout(() => uni.navigateBack(), 1200)
}
finally {
loading.value = false
uni.hideLoading()
}
})
@@ -36,24 +97,91 @@ function handleBack() {
navigateBackWithFallback(fallbackUrl.value)
}
function handleSelectMethod(method: PaymentMethod) {
paymentMethod.value = method
function handleSelectChannel(code: string) {
selectedChannel.value = code
}
function formatAmount(amount: number) {
return `¥ ${amount}`
return `¥ ${Number(amount || 0).toFixed(2)}`
}
function handleConfirmPay() {
function goSuccess(outTradeNo?: string, mergedAmount?: number) {
const first = bills.value[0]
if (!first)
return
const method = selectedChannel.value === 'ALIPAY' ? 'alipay' : 'wechat'
const query = [
`id=${encodeURIComponent(first.id)}`,
`ids=${encodeURIComponent(billIds.value.join(','))}`,
`projectId=${encodeURIComponent(first.projectId || projectId.value)}`,
`method=${encodeURIComponent(method)}`,
`channel=${encodeURIComponent(selectedChannel.value)}`,
`count=${encodeURIComponent(String(billIds.value.length))}`,
`amount=${encodeURIComponent(String(mergedAmount ?? totalAmount.value))}`,
]
if (outTradeNo)
query.push(`outTradeNo=${encodeURIComponent(outTradeNo)}`)
uni.redirectTo({
url: `/pages/project-center/payment-success/index?projectId=${encodeURIComponent(projectId.value)}&planId=${encodeURIComponent(planId.value)}&method=${encodeURIComponent(paymentMethod.value)}`,
url: `/pages/project-center/payment-success/index?${query.join('&')}`,
})
}
async function handleConfirmPay() {
if (!ensureLoggedIn() || paying.value || !bills.value.length)
return
if (!allPayable.value) {
uni.showToast({ title: '存在不可支付账单', icon: 'none' })
return
}
if (!selectedChannel.value) {
uni.showToast({ title: '请选择支付方式', icon: 'none' })
return
}
paying.value = true
uni.showLoading({ title: '提交中...', mask: true })
try {
const result = isBatch.value
? await payBillBatch({
ids: billIds.value,
payChannel: selectedChannel.value,
})
: await payBill({
id: billIds.value[0],
payChannel: selectedChannel.value,
})
uni.hideLoading()
try {
const invoked = await invokePayFromResult(result, selectedChannel.value)
if (invoked.mode === 'none' && !result.outTradeNo) {
uni.showToast({ title: '未返回支付调起参数', icon: 'none' })
return
}
goSuccess(result.outTradeNo, result.mergedAmount)
}
catch (error) {
const message = error instanceof Error ? error.message : '支付失败'
uni.showToast({ title: message, icon: 'none' })
}
}
catch {
// request 统一提示
}
finally {
paying.value = false
uni.hideLoading()
}
}
</script>
<template>
<view
v-if="plan"
v-if="bills.length"
class="project-payment"
>
<view class="project-payment__navbar">
@@ -68,7 +196,7 @@ function handleConfirmPay() {
/>
</view>
<text class="project-payment__navbar-title">
确认支付
{{ isBatch ? '合并支付' : '确认支付' }}
</text>
<view class="project-payment__navbar-placeholder" />
</view>
@@ -84,27 +212,35 @@ function handleConfirmPay() {
<text class="project-payment__card-title">
订单明细
</text>
<view class="project-payment__order-row">
<text class="project-payment__order-title">
{{ plan.title }} {{ plan.ratio }}
<view
v-for="item in bills"
:key="item.id"
class="project-payment__order-block"
>
<view class="project-payment__order-row">
<text class="project-payment__order-title">
{{ item.title }} {{ item.ratio }}
</text>
<text class="project-payment__order-amount">
{{ formatAmount(item.amount) }}
</text>
</view>
<text class="project-payment__order-meta">
账单号:{{ item.billNo }}
</text>
<text class="project-payment__order-amount">
{{ formatAmount(plan.amount) }}
<text class="project-payment__order-meta">
关联项目:{{ item.relatedProject }}
</text>
</view>
<text class="project-payment__order-meta">
账单号:{{ plan.billNo }}
</text>
<text class="project-payment__order-meta">
关联项目:{{ plan.relatedProject }}
</text>
<view class="project-payment__order-divider" />
<view class="project-payment__order-summary">
<text class="project-payment__order-summary-label">
已选 1笔订单,合计
已选 {{ bills.length }}笔订单,合计
</text>
<text class="project-payment__order-summary-amount">
{{ formatAmount(plan.amount) }}
{{ formatAmount(totalAmount) }}
</text>
</view>
</view>
@@ -115,11 +251,30 @@ function handleConfirmPay() {
<text class="project-payment__card-title">
选择支付方式
</text>
<view
v-for="method in paymentMethods"
:key="method.key"
v-if="loading && !channels.length"
class="project-payment__empty"
>
<text class="project-payment__empty-text">
加载支付方式...
</text>
</view>
<view
v-else-if="!channels.length"
class="project-payment__empty"
>
<text class="project-payment__empty-text">
暂无可用支付通道
</text>
</view>
<view
v-for="method in channels"
:key="method.code"
class="project-payment__method"
@tap="handleSelectMethod(method.key)"
@tap="handleSelectChannel(method.code)"
>
<view class="project-payment__method-left">
<image
@@ -128,15 +283,15 @@ function handleConfirmPay() {
mode="aspectFit"
/>
<text class="project-payment__method-label">
{{ method.label }}
{{ method.name }}
</text>
</view>
<view
class="project-payment__radio"
:class="{ 'project-payment__radio--active': paymentMethod === method.key }"
:class="{ 'project-payment__radio--active': selectedChannel === method.code }"
>
<text
v-if="paymentMethod === method.key"
v-if="selectedChannel === method.code"
class="project-payment__radio-check"
>
✓
@@ -151,9 +306,10 @@ function handleConfirmPay() {
<view class="project-payment__footer">
<view
class="project-payment__confirm-btn"
:class="{ 'project-payment__confirm-btn--disabled': paying || !selectedChannel || !allPayable }"
@tap="handleConfirmPay"
>
确认支付
{{ paying ? '支付中...' : `确认支付${selectedChannelName ? ` · ${selectedChannelName}` : ''}` }}
</view>
</view>
</view>

View File

@@ -0,0 +1,150 @@
@import '@/styles/variables.scss';
.refund-apply {
display: flex;
flex-direction: column;
min-height: 100vh;
background: $color-bg-section;
}
.refund-apply__navbar {
display: flex;
align-items: center;
justify-content: space-between;
flex-shrink: 0;
padding: calc(var(--status-bar-height, 44px) + 12rpx) 24rpx 20rpx;
background: $color-bg-page;
}
.refund-apply__back {
display: flex;
align-items: center;
justify-content: center;
width: 64rpx;
height: 64rpx;
}
.refund-apply__back-icon {
width: 40rpx;
height: 40rpx;
}
.refund-apply__navbar-title {
font-size: 34rpx;
font-weight: 600;
color: $color-text-primary;
}
.refund-apply__navbar-placeholder {
width: 64rpx;
height: 64rpx;
}
.refund-apply__scroll {
flex: 1;
height: 0;
padding: 20rpx 24rpx;
box-sizing: border-box;
}
.refund-apply__card {
padding: 28rpx 24rpx;
margin-bottom: 20rpx;
background: $color-bg-page;
border-radius: 20rpx;
&:last-child {
margin-bottom: 0;
}
}
.refund-apply__card-title {
display: block;
margin-bottom: 16rpx;
font-size: 30rpx;
font-weight: 600;
color: $color-text-primary;
}
.refund-apply__meta {
display: block;
margin-top: 12rpx;
font-size: 26rpx;
color: $color-text-secondary;
word-break: break-all;
}
.refund-apply__field {
margin-bottom: 28rpx;
&:last-child {
margin-bottom: 0;
}
}
.refund-apply__label {
display: block;
margin-bottom: 16rpx;
font-size: 28rpx;
font-weight: 500;
color: $color-text-primary;
}
.refund-apply__input {
width: 100%;
height: 80rpx;
padding: 0 24rpx;
font-size: 28rpx;
color: $color-text-primary;
background: $color-bg-page;
border: 1rpx solid #e8eaef;
border-radius: 12rpx;
box-sizing: border-box;
}
.refund-apply__textarea {
width: 100%;
min-height: 180rpx;
padding: 20rpx 24rpx;
font-size: 28rpx;
color: $color-text-primary;
background: $color-bg-page;
border: 1rpx solid #e8eaef;
border-radius: 12rpx;
box-sizing: border-box;
}
.refund-apply__placeholder {
color: $color-text-placeholder;
}
.refund-apply__hint {
display: block;
margin-top: 12rpx;
font-size: 22rpx;
color: $color-text-secondary;
}
.refund-apply__footer {
flex-shrink: 0;
padding: 16rpx 24rpx calc(16rpx + env(safe-area-inset-bottom));
background: $color-bg-page;
border-top: 1rpx solid #f0f0f0;
}
.refund-apply__submit {
display: flex;
align-items: center;
justify-content: center;
height: 88rpx;
font-size: 30rpx;
font-weight: 600;
color: #ffffff;
background: $color-primary;
border-radius: 12rpx;
&--disabled {
opacity: 0.55;
pointer-events: none;
}
}

View File

@@ -0,0 +1,210 @@
<script setup lang="ts">
import { computed, ref } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import { getBillDetail } from '@/api/bill'
import { applyRefund } from '@/api/pay'
import type { BillItem } from '@/types/bill'
import { ensureLoggedIn } from '@/utils/auth-guard'
import { mapFinanceBillToItem } from '@/utils/map-bill'
import { navigateBackWithFallback } from '@/utils/navigate-back'
const bill = ref<BillItem | null>(null)
const billId = ref('')
const amount = ref('')
const reason = ref('')
const submitting = ref(false)
const maxAmount = computed(() => Number(bill.value?.amount || 0))
onLoad(async (options) => {
if (!ensureLoggedIn())
return
const id = options?.billId
? decodeURIComponent(String(options.billId))
: (options?.id ? decodeURIComponent(String(options.id)) : '')
billId.value = id
if (!id) {
uni.showToast({ title: '账单不存在', icon: 'none' })
setTimeout(() => uni.navigateBack(), 1200)
return
}
uni.showLoading({ title: '加载中...', mask: true })
try {
const vo = await getBillDetail(id)
bill.value = mapFinanceBillToItem(vo)
amount.value = String(bill.value.amount || '')
if (bill.value.status !== 'paid') {
uni.showToast({ title: '仅已支付账单可申请退款', icon: 'none' })
}
}
catch {
bill.value = null
setTimeout(() => uni.navigateBack(), 1200)
}
finally {
uni.hideLoading()
}
})
function handleBack() {
navigateBackWithFallback(
billId.value
? `/pages/project-center/bill-detail/index?id=${encodeURIComponent(billId.value)}`
: '/pages/project-center/bill-list/index',
)
}
function formatAmount(value: number) {
return `¥ ${Number(value || 0).toFixed(2)}`
}
function validateForm() {
if (!bill.value || bill.value.status !== 'paid') {
uni.showToast({ title: '仅已支付账单可申请退款', icon: 'none' })
return false
}
const amountNum = Number(amount.value)
if (!amount.value.trim() || !Number.isFinite(amountNum) || amountNum <= 0) {
uni.showToast({ title: '请输入正确退款金额', icon: 'none' })
return false
}
if (amountNum > maxAmount.value + 1e-8) {
uni.showToast({ title: '退款金额不能超过账单金额', icon: 'none' })
return false
}
if (!reason.value.trim()) {
uni.showToast({ title: '请填写退款原因', icon: 'none' })
return false
}
return true
}
async function handleSubmit() {
if (!ensureLoggedIn() || submitting.value || !validateForm())
return
submitting.value = true
uni.showLoading({ title: '提交中...', mask: true })
try {
await applyRefund({
billId: billId.value,
amount: Number(amount.value),
reason: reason.value.trim(),
})
uni.showToast({ title: '已提交退款申请', icon: 'none' })
setTimeout(() => {
uni.redirectTo({
url: '/pages/project-center/refund-list/index',
})
}, 600)
}
catch {
// request 统一提示
}
finally {
submitting.value = false
uni.hideLoading()
}
}
</script>
<template>
<view
v-if="bill"
class="refund-apply"
>
<view class="refund-apply__navbar">
<view
class="refund-apply__back"
@tap="handleBack"
>
<image
class="refund-apply__back-icon"
src="/static/icons/icon-back.svg"
mode="aspectFit"
/>
</view>
<text class="refund-apply__navbar-title">
申请退款
</text>
<view class="refund-apply__navbar-placeholder" />
</view>
<scroll-view
class="refund-apply__scroll"
scroll-y
:show-scrollbar="false"
>
<view class="refund-apply__card">
<text class="refund-apply__card-title">
账单信息
</text>
<text class="refund-apply__meta">
{{ bill.title }} {{ bill.ratio }}
</text>
<text class="refund-apply__meta">
账单号:{{ bill.billNo }}
</text>
<text class="refund-apply__meta">
关联项目:{{ bill.relatedProject }}
</text>
<text class="refund-apply__meta">
账单金额:{{ formatAmount(bill.amount) }}
</text>
</view>
<view class="refund-apply__card">
<view class="refund-apply__field">
<text class="refund-apply__label">
退款金额(元)*
</text>
<input
v-model="amount"
class="refund-apply__input"
type="digit"
placeholder="请输入退款金额"
placeholder-class="refund-apply__placeholder"
>
<text class="refund-apply__hint">
不超过 {{ formatAmount(maxAmount) }}
</text>
</view>
<view class="refund-apply__field">
<text class="refund-apply__label">
退款原因*
</text>
<textarea
v-model="reason"
class="refund-apply__textarea"
maxlength="200"
placeholder="请说明退款原因"
placeholder-class="refund-apply__placeholder"
/>
</view>
</view>
</scroll-view>
<view class="refund-apply__footer">
<view
class="refund-apply__submit"
:class="{ 'refund-apply__submit--disabled': submitting || bill.status !== 'paid' }"
@tap="handleSubmit"
>
提交申请
</view>
</view>
</view>
</template>
<style scoped lang="scss">
@import './index.scss';
</style>

View File

@@ -0,0 +1,167 @@
@import '@/styles/variables.scss';
.refund-list {
display: flex;
flex-direction: column;
min-height: 100vh;
background: $color-bg-section;
}
.refund-list__navbar {
display: flex;
align-items: center;
justify-content: space-between;
flex-shrink: 0;
padding: calc(var(--status-bar-height, 44px) + 12rpx) 24rpx 20rpx;
background: $color-bg-page;
}
.refund-list__back {
display: flex;
align-items: center;
justify-content: center;
width: 64rpx;
height: 64rpx;
}
.refund-list__back-icon {
width: 40rpx;
height: 40rpx;
}
.refund-list__navbar-title {
font-size: 34rpx;
font-weight: 600;
color: $color-text-primary;
}
.refund-list__navbar-placeholder {
width: 64rpx;
height: 64rpx;
}
.refund-list__tabs {
flex-shrink: 0;
background: $color-bg-page;
border-bottom: 1rpx solid #f0f0f0;
}
.refund-list__tabs-inner {
display: flex;
gap: 12rpx;
padding: 12rpx 24rpx 20rpx;
white-space: nowrap;
}
.refund-list__tab {
flex-shrink: 0;
padding: 10rpx 24rpx;
font-size: 24rpx;
color: $color-text-secondary;
background: $color-bg-section;
border-radius: 999rpx;
&--active {
color: #ffffff;
background: $color-primary;
}
}
.refund-list__scroll {
flex: 1;
height: 0;
}
.refund-list__content {
padding: 20rpx 24rpx calc(32rpx + env(safe-area-inset-bottom));
}
.refund-list__empty {
display: flex;
align-items: center;
justify-content: center;
padding: 120rpx 24rpx;
}
.refund-list__empty-text {
font-size: 28rpx;
color: $color-text-secondary;
}
.refund-list__card {
padding: 28rpx 24rpx;
margin-bottom: 20rpx;
background: $color-bg-page;
border-radius: 20rpx;
}
.refund-list__card-header {
display: flex;
align-items: center;
justify-content: space-between;
gap: 16rpx;
}
.refund-list__refund-no {
flex: 1;
min-width: 0;
font-size: 28rpx;
font-weight: 600;
color: $color-text-primary;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.refund-list__tag {
flex-shrink: 0;
padding: 4rpx 12rpx;
font-size: 20rpx;
color: #ffffff;
border-radius: 40rpx;
background: #9ca3af;
&--applying {
background: #ff9a3d;
}
&--approved,
&--refunding {
background: $color-primary;
}
&--success {
background: #25eb9f;
}
&--rejected,
&--failed {
background: #ef4444;
}
}
.refund-list__row {
display: flex;
align-items: center;
justify-content: space-between;
margin-top: 20rpx;
}
.refund-list__label {
font-size: 24rpx;
color: $color-text-secondary;
}
.refund-list__amount {
font-size: 32rpx;
font-weight: 600;
color: $color-text-primary;
}
.refund-list__meta {
display: block;
margin-top: 12rpx;
font-size: 22rpx;
color: #666666;
word-break: break-all;
}

View File

@@ -0,0 +1,214 @@
<script setup lang="ts">
import { computed, ref, watch } from 'vue'
import { onShow } from '@dcloudio/uni-app'
import { getRefundPage } from '@/api/pay'
import { REFUND_PAGE_SIZE, REFUND_STATUS_TABS } from '@/constants/refund'
import type { FinanceRefundStatus } from '@/types/pay-api'
import { ensureLoggedIn } from '@/utils/auth-guard'
import { mapFinanceRefundsToItems, type RefundListItem } from '@/utils/map-refund'
import { navigateBackWithFallback } from '@/utils/navigate-back'
import LoadMoreFooter from '@/pages/case-library/components/LoadMoreFooter.vue'
const statusFilter = ref<'' | FinanceRefundStatus>('')
const list = ref<RefundListItem[]>([])
const totalCount = ref(0)
const pageNum = ref(1)
const loadingList = ref(false)
const loadingMore = ref(false)
const hasMore = computed(() => list.value.length < totalCount.value)
const loadFinished = computed(() => !hasMore.value && list.value.length > 0)
async function fetchList(reset = false) {
if (reset) {
pageNum.value = 1
list.value = []
}
if (loadingList.value || loadingMore.value)
return
if (reset)
loadingList.value = true
else
loadingMore.value = true
try {
const result = await getRefundPage({
status: statusFilter.value || undefined,
pageNum: pageNum.value,
pageSize: REFUND_PAGE_SIZE,
})
const mapped = mapFinanceRefundsToItems(result?.rows)
totalCount.value = Number(result?.total ?? 0)
list.value = reset ? mapped : [...list.value, ...mapped]
}
catch {
if (reset) {
list.value = []
totalCount.value = 0
}
}
finally {
loadingList.value = false
loadingMore.value = false
}
}
watch(statusFilter, () => {
fetchList(true)
})
onShow(() => {
if (!ensureLoggedIn())
return
fetchList(true)
})
function handleBack() {
navigateBackWithFallback('/pages/personal-center/finance/index')
}
function handleLoadMore() {
if (!hasMore.value || loadingList.value || loadingMore.value)
return
pageNum.value += 1
fetchList(false)
}
function formatAmount(amount: number) {
return `¥ ${Number(amount || 0).toFixed(2)}`
}
function statusClass(status: string) {
const key = status.toLowerCase()
return `refund-list__tag--${key}`
}
function handleOpenBill(item: RefundListItem) {
if (!item.billId || item.billId === '-')
return
uni.navigateTo({
url: `/pages/project-center/bill-detail/index?id=${encodeURIComponent(item.billId)}`,
})
}
</script>
<template>
<view class="refund-list">
<view class="refund-list__navbar">
<view
class="refund-list__back"
@tap="handleBack"
>
<image
class="refund-list__back-icon"
src="/static/icons/icon-back.svg"
mode="aspectFit"
/>
</view>
<text class="refund-list__navbar-title">
退款记录
</text>
<view class="refund-list__navbar-placeholder" />
</view>
<scroll-view
class="refund-list__tabs"
scroll-x
:show-scrollbar="false"
>
<view class="refund-list__tabs-inner">
<text
v-for="tab in REFUND_STATUS_TABS"
:key="tab.key || 'all'"
class="refund-list__tab"
:class="{ 'refund-list__tab--active': statusFilter === tab.key }"
@tap="statusFilter = tab.key"
>
{{ tab.label }}
</text>
</view>
</scroll-view>
<scroll-view
class="refund-list__scroll"
scroll-y
:show-scrollbar="false"
@scrolltolower="handleLoadMore"
>
<view class="refund-list__content">
<view
v-if="loadingList && !list.length"
class="refund-list__empty"
>
<text class="refund-list__empty-text">
加载中...
</text>
</view>
<view
v-else-if="!list.length"
class="refund-list__empty"
>
<text class="refund-list__empty-text">
暂无退款记录
</text>
</view>
<view
v-for="item in list"
:key="item.id"
class="refund-list__card"
@tap="handleOpenBill(item)"
>
<view class="refund-list__card-header">
<text class="refund-list__refund-no">
{{ item.refundNo }}
</text>
<text
class="refund-list__tag"
:class="statusClass(item.status)"
>
{{ item.statusLabel }}
</text>
</view>
<view class="refund-list__row">
<text class="refund-list__label">
退款金额
</text>
<text class="refund-list__amount">
{{ formatAmount(item.amount) }}
</text>
</view>
<text class="refund-list__meta">
原因:{{ item.reason }}
</text>
<text class="refund-list__meta">
通道:{{ item.payChannelLabel }}
</text>
<text class="refund-list__meta">
申请时间:{{ item.createTime }}
</text>
<text
v-if="item.auditRemark && item.auditRemark !== '-'"
class="refund-list__meta"
>
审核备注:{{ item.auditRemark }}
</text>
</view>
<LoadMoreFooter
:loading="loadingMore"
:has-more="hasMore"
:finished="loadFinished"
@load-more="handleLoadMore"
/>
</view>
</scroll-view>
</view>
</template>
<style scoped lang="scss">
@import './index.scss';
</style>