渠道管理增加应收关联

This commit is contained in:
wuweihua
2026-11-09 17:27:21 +08:00
parent ace1eb06c0
commit 2632e5aa78
10 changed files with 131 additions and 28 deletions
+3 -2
View File
@@ -80,10 +80,11 @@ export function comparePay(leftId, rightId) {
})
}
export function getChannelPay(channelId) {
export function getChannelPay(channelId, payType = 'AP') {
return request({
url: '/price/pay/channel/' + channelId,
method: 'get'
method: 'get',
params: { payType }
})
}
@@ -149,6 +149,14 @@
<div class="pay-tip">{{ payTip }}</div>
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="应收产品">
<el-select v-model="arOriginId" filterable clearable placeholder="选择已导入的应收产品" style="width: 280px" :disabled="viewing || !form.id" @change="onArOrigin">
<el-option v-for="item in arOptions" :key="item.productId" :label="payOptionLabel(item)" :value="item.productId" />
</el-select>
<div class="pay-tip">{{ arTip }}</div>
</el-form-item>
</el-col>
</el-row>
</el-form>
<template #footer>
@@ -175,9 +183,13 @@ const open = ref(false)
const viewing = ref(false)
const title = ref('')
const payOptions = ref([])
const arOptions = ref([])
const payOriginId = ref()
const arOriginId = ref()
const payProduct = ref(null)
const arProduct = ref(null)
const syncingPay = ref(false)
const syncingAr = ref(false)
const payTip = computed(() => {
if (viewing.value) {
if (payProduct.value?.versionNo) return `已绑定第 ${payProduct.value.versionNo} 版。`
@@ -187,6 +199,15 @@ const payTip = computed(() => {
if (payProduct.value?.versionNo) return `当前按有效期使用第 ${payProduct.value.versionNo} 版。历史订单按下单或计费时间取当时的版本。`
return '选择产品后即绑定,按应付 AP 保存。'
})
const arTip = computed(() => {
if (viewing.value) {
if (arProduct.value?.versionNo) return `已绑定第 ${arProduct.value.versionNo} 版。`
return arOriginId.value ? '已绑定应收产品。' : '未绑定应收产品。'
}
if (!form.value?.id) return '先保存渠道,再选择应收产品。渠道绑定的是产品编号,更新价格不会换编号。'
if (arProduct.value?.versionNo) return `当前按有效期使用第 ${arProduct.value.versionNo} 版。历史订单按下单或计费时间取当时的版本。`
return '选择产品后即绑定,按应收 AR 保存。'
})
const openOptions = [
{ label: '启用', value: '1' },
@@ -260,10 +281,14 @@ function emptyForm() {
function resetPay() {
syncingPay.value = true
syncingAr.value = true
payOriginId.value = undefined
arOriginId.value = undefined
payProduct.value = null
arProduct.value = null
nextTick(() => {
syncingPay.value = false
syncingAr.value = false
})
}
@@ -276,11 +301,14 @@ function loadPayOptions() {
listPayOptions('AP').then(res => {
payOptions.value = res.data || []
})
listPayOptions('AR').then(res => {
arOptions.value = res.data || []
})
}
function loadChannelPay(channelId) {
syncingPay.value = true
getChannelPay(channelId).then(res => {
getChannelPay(channelId, 'AP').then(res => {
payProduct.value = res.data || null
payOriginId.value = res.data?.originId || res.data?.productId
}).finally(() => {
@@ -290,6 +318,18 @@ function loadChannelPay(channelId) {
})
}
function loadChannelAr(channelId) {
syncingAr.value = true
getChannelPay(channelId, 'AR').then(res => {
arProduct.value = res.data || null
arOriginId.value = res.data?.originId || res.data?.productId
}).finally(() => {
nextTick(() => {
syncingAr.value = false
})
})
}
function handleAdd() {
viewing.value = false
form.value = emptyForm()
@@ -307,6 +347,7 @@ function handleUpdate(row) {
resetPay()
loadPayOptions()
loadChannelPay(row.id)
loadChannelAr(row.id)
title.value = '修改渠道'
open.value = true
nextTick(() => formRef.value && formRef.value.clearValidate())
@@ -320,6 +361,7 @@ function handleDetail(row) {
resetPay()
loadPayOptions()
loadChannelPay(row.id)
loadChannelAr(row.id)
title.value = '渠道详情'
open.value = true
nextTick(() => formRef.value && formRef.value.clearValidate())
@@ -339,6 +381,19 @@ function onPayOrigin(id) {
})
}
function onArOrigin(id) {
if (viewing.value || !form.value.id || syncingAr.value) return
if (!id) {
arProduct.value = null
bindChannelPay(form.value.id, null, 'AR')
return
}
bindChannelPay(form.value.id, id, 'AR').then(res => {
arProduct.value = res.data || null
arOriginId.value = res.data?.originId || id
})
}
function submitForm() {
if (viewing.value) return
formRef.value.validate(valid => {