feat(components, types, views): 添加付款方式和现金折扣率相关功能

在`components.d.ts`中添加了VanRadio和VanRadioGroup组件的类型定义。
在`src/types/index.ts`中新增了PayMethod类型,用于表示不同的付款方式。
在`src/views/Detail/index.vue`中增加了付款方式、付款比例、付款说明以及现金折扣率选择的相关UI和逻辑处理。具体包括:
- 在订单详情中显示付款方式、付款比例和付款说明。
- 当任务名称包含“商务”且审批状态不为待审批时,显示现金折扣率选择区域。
- 新增getPayMethod函数,用于根据付款方式返回相应的描述。
- 在提交审批前检查是否选择了现金折扣率,并在需要时将其作为参数传递给后端。
- 更新样式文件以支持新的现金折扣率选择区域的样式。
```
master
chenhao 2025-09-18 17:31:04 +08:00
parent 92dd433eee
commit a29d0f589b
3 changed files with 136 additions and 7 deletions

2
components.d.ts vendored
View File

@ -20,6 +20,8 @@ declare module 'vue' {
VanNavBar: typeof import('vant/es')['NavBar'] VanNavBar: typeof import('vant/es')['NavBar']
VanPopup: typeof import('vant/es')['Popup'] VanPopup: typeof import('vant/es')['Popup']
VanPullRefresh: typeof import('vant/es')['PullRefresh'] VanPullRefresh: typeof import('vant/es')['PullRefresh']
VanRadio: typeof import('vant/es')['Radio']
VanRadioGroup: typeof import('vant/es')['RadioGroup']
VanSearch: typeof import('vant/es')['Search'] VanSearch: typeof import('vant/es')['Search']
VanStep: typeof import('vant/es')['Step'] VanStep: typeof import('vant/es')['Step']
VanSteps: typeof import('vant/es')['Steps'] VanSteps: typeof import('vant/es')['Steps']

View File

@ -15,6 +15,7 @@ export interface LoginParams {
// 订单状态类型 // 订单状态类型
export type OrderStatus = '0' | '1' | '2' // 待审批、已审批、已拒绝 export type OrderStatus = '0' | '1' | '2' // 待审批、已审批、已拒绝
export type PayMethod = '1-1' | '1-2' | '2-1' | '2-2' | '2-3' // 待审批、已审批、已拒绝
// 审批状态类型 // 审批状态类型
export type ApprovalStatus = 1 | 2 | 3 // 待审批、驳回、通过 export type ApprovalStatus = 1 | 2 | 3 // 待审批、驳回、通过

View File

@ -138,6 +138,18 @@
</div><div class="info-item"> </div><div class="info-item">
<span class="label">其他特别说明</span> <span class="label">其他特别说明</span>
<span class="value">{{ currentOrderInfo.remark}}</span> <span class="value">{{ currentOrderInfo.remark}}</span>
</div>
<div class="info-item">
<span class="label">付款方式</span>
<span class="value">{{ getPayMethod(currentOrderInfo.paymentMethod) }}</span>
</div>
<div class="info-item">
<span class="label">付款比例</span>
<span class="value">{{ currentOrderInfo.paymentRatio }}%</span>
</div>
<div class="info-item">
<span class="label">付款说明</span>
<span class="value">{{ currentOrderInfo.paymentDescription }}</span>
</div> </div>
@ -396,7 +408,20 @@
</van-tag> </van-tag>
</div> </div>
</div> </div>
<!-- 现金折扣率选择 (仅当taskName包含'商务'且为通过审批时显示) -->
<div v-if="currentOrder?.todo?.taskName?.includes('') && currentApprovalStatus !== 0"
class="discount-selection">
<div class="discount-title">现金折扣率 *</div>
<div class="discount-options">
<van-radio-group v-model="selectedDiscount" direction="horizontal">
<van-radio name="100%">100%</van-radio>
<van-radio name="98.8%">98.8%</van-radio>
<van-radio name="98.5%">98.5%</van-radio>
</van-radio-group>
</div>
</div>
<!-- 意见输入框 --> <!-- 意见输入框 -->
<div class="opinion-input"> <div class="opinion-input">
<van-field <van-field
@ -440,7 +465,7 @@ import {
getApprovalStatusColor, getApprovalStatusColor,
getFilePreviewUrl getFilePreviewUrl
} from '@/utils' } from '@/utils'
import type {OrderStatus, ApprovalStatus, AttachmentFile} from '@/types' import type {OrderStatus, ApprovalStatus, AttachmentFile, payMethod, PayMethod} from '@/types'
const route = useRoute() const route = useRoute()
const router = useRouter() const router = useRouter()
@ -453,6 +478,7 @@ const approvalOpinion = ref('')
const currentApprovalStatus = ref<ApprovalStatus>(3) const currentApprovalStatus = ref<ApprovalStatus>(3)
const submitting = ref(false) const submitting = ref(false)
const selectedTag = ref('') const selectedTag = ref('')
const selectedDiscount = ref('') //
// Tab // Tab
const activeTab = ref('order') const activeTab = ref('order')
@ -481,6 +507,16 @@ const getStatusClass = (status: OrderStatus) => {
} }
return classMap[status] || 'pending' return classMap[status] || 'pending'
} }
const getPayMethod= (method: PayMethod) => {
const methodMap = {
'1-1': '全款支付,无需预付款',
'1-2': '全款支付,需单独备货生产,预付订单总货款百分比',
'2-1': '全款支付',
'2-2': '全款支付,需单独备货生产,预付订单总货款百分比',
'2-3': '商业汇票支付,预付订单总货款百分比'
}
return methodMap[method] || ''
}
// //
const getStepIcon = (status?: ApprovalStatus) => { const getStepIcon = (status?: ApprovalStatus) => {
@ -564,6 +600,18 @@ const showApprovalDialog = (status: ApprovalStatus) => {
currentApprovalStatus.value = status currentApprovalStatus.value = status
approvalOpinion.value = '' approvalOpinion.value = ''
selectedTag.value = '' selectedTag.value = ''
//
selectedDiscount.value = ''
//
if (currentOrder.value && currentOrder.value.projectOrderInfo) {
const discountValue = getDiscountRate()
if (discountValue) {
selectedDiscount.value = discountValue.toString()
}
}
approvalDialogVisible.value = true approvalDialogVisible.value = true
} }
@ -618,20 +666,41 @@ const submitApproval = async () => {
return return
} }
//
const showCashDiscount = currentOrder.value.todo.taskName &&
currentOrder.value.todo.taskName.includes('商务')
if (showCashDiscount && currentApprovalStatus.value !== 0 && !selectedDiscount.value) {
showToast('请选择现金折扣率')
// 使
setTimeout(() => {
const discountElement = document.querySelector('.discount-selection')
if (discountElement) {
discountElement.scrollIntoView({behavior: 'smooth', block: 'center'})
}
}, 100)
return
}
submitting.value = true submitting.value = true
try { try {
const params = { const params = {
...currentOrder.value.todo, // todo ...currentOrder.value.todo, // todo
approveOpinion: opinion || undefined , // approveOpinion: opinion || undefined, //
variables:{ variables: {
approveBtn:currentApprovalStatus.value, approveBtn: currentApprovalStatus.value,
comment:opinion comment: opinion
} }
} }
//
if (showCashDiscount && currentApprovalStatus.value !== 0 && selectedDiscount.value) {
// approveBtn
params.allPriceCountValue = selectedDiscount.value
}
console.log('提交审批参数:', params) console.log('提交审批参数:', params)
await submitApprovalApi(params) await submitApprovalApi(params)
@ -664,6 +733,18 @@ onMounted(async () => {
console.log('获取订单详情结果:', result) console.log('获取订单详情结果:', result)
console.log('当前订单信息:', currentOrder.value) console.log('当前订单信息:', currentOrder.value)
console.log('当前订单基本信息:', currentOrderInfo.value) console.log('当前订单基本信息:', currentOrderInfo.value)
//
if (currentOrder.value && currentOrder.value.projectOrderInfo) {
// projectOrderInfo
//
const discountValue = currentOrder.value.projectOrderInfo.allPriceCountValue ||
currentOrder.value.projectOrderInfo.discountRate ||
currentOrder.value.projectOrderInfo.cashDiscountRate
if (discountValue) {
selectedDiscount.value = discountValue.toString()
}
}
} catch (error) { } catch (error) {
console.error('获取订单详情失败:', error) console.error('获取订单详情失败:', error)
showToast('获取订单详情失败') showToast('获取订单详情失败')
@ -1102,4 +1183,49 @@ onMounted(async () => {
color: var(--primary-color); color: var(--primary-color);
} }
} }
/* 现金折扣率样式 */
.discount-selection {
margin: 20px 0;
padding: 15px;
background-color: #fffbe6;
border-radius: 8px;
border: 1px solid #ffd700;
box-shadow: 0 2px 8px rgba(255, 215, 0, 0.2);
}
.discount-title {
font-size: 14px;
font-weight: 600;
color: #333;
margin-bottom: 12px;
display: flex;
align-items: center;
&::before {
content: '*';
color: #ff4d4f;
margin-right: 4px;
}
}
.discount-options {
:deep(.van-radio-group) {
display: flex;
justify-content: space-between;
.van-radio {
margin-right: 10px;
flex: 1;
&:last-child {
margin-right: 0;
}
.van-radio__label {
font-size: 14px;
}
}
}
}
</style> </style>