修改产品套餐

This commit is contained in:
wuweihua
2026-09-29 23:07:38 +08:00
parent 38f371742a
commit 52d0a13d83
25 changed files with 1229 additions and 351 deletions
+62 -10
View File
@@ -6,22 +6,24 @@
<template #header><span>试算参数</span></template>
<el-form ref="formRef" :model="form" :rules="rules" label-width="120px">
<el-form-item label="客户" prop="customerCode">
<customer-select v-model="form.customerCode" value-key="customerCode" placeholder="请选择客户" />
<div class="form-hint">与套餐绑定客户一致;未绑定套餐时报错</div>
<customer-select v-model="form.customerCode" value-key="customerCode" placeholder="请选择客户" @change="handleCustomerChange" />
<div class="form-hint">产品列表来自该客户绑定套餐;未绑定或套餐无产品时为空</div>
</el-form-item>
<el-form-item label="产品" prop="productCode">
<el-select
v-model="form.productCode"
filterable
clearable
placeholder="请选择产品"
:placeholder="productPlaceholder"
style="width: 100%"
:disabled="!form.customerCode"
:loading="productLoading"
@change="handleProductChange"
>
<el-option
v-for="item in productOptions"
:key="item.productCode"
:label="item.productName + ' (' + item.productCode + ')'"
:label="(item.productName || item.productCode) + ' (' + item.productCode + ')'"
:value="item.productCode"
/>
</el-select>
@@ -262,8 +264,8 @@
</template>
<script setup name="BillingQuote">
import { quoteBilling, listQuote, getQuote } from '@/api/price/billing'
import { listProduct, listProductCountries } from '@/api/price/product'
import { quoteBilling, listQuoteBoundProducts, listQuote, getQuote } from '@/api/price/billing'
import { listProductCountries } from '@/api/price/product'
const { proxy } = getCurrentInstance()
const { bms_fee_type, bms_currency } = useDict('bms_fee_type', 'bms_currency')
@@ -346,12 +348,62 @@ const rules = {
weight: [{ required: true, message: '请输入计费重量', trigger: 'blur' }]
}
function loadProducts() {
listProduct({ pageNum: 1, pageSize: 500, status: '1' }).then(res => {
productOptions.value = res.rows || []
const productLoading = ref(false)
const productPlaceholder = computed(() => {
if (!form.customerCode) return '请先选择客户'
if (productLoading.value) return '加载中…'
if (!(productOptions.value || []).length) return '该客户绑定套餐暂无产品'
return '请选择产品'
})
function clearProductCascade() {
form.productCode = undefined
form.countryCode = undefined
form.destPostcode = undefined
countryOptions.value = []
countryRows.value = []
productOptions.value = []
}
function handleCustomerChange(code) {
clearProductCascade()
result.value = null
errorMsg.value = ''
if (!code) return
loadProductsByCustomer(code)
}
function loadProductsByCustomer(customerCode) {
if (!customerCode) {
productOptions.value = []
return Promise.resolve([])
}
productLoading.value = true
return listQuoteBoundProducts(customerCode, form.bizDate || undefined).then(res => {
productOptions.value = res.data || []
return productOptions.value
}).catch(() => {
productOptions.value = []
return []
}).finally(() => {
productLoading.value = false
})
}
watch(() => form.bizDate, () => {
if (!form.customerCode) return
const keep = form.productCode
loadProductsByCustomer(form.customerCode).then(list => {
if (keep && !(list || []).some(p => p.productCode === keep)) {
form.productCode = undefined
form.countryCode = undefined
form.destPostcode = undefined
countryOptions.value = []
countryRows.value = []
}
})
})
function uniqueCountries(list) {
const map = new Map()
;(list || []).forEach(item => {
@@ -430,6 +482,7 @@ function resetForm() {
form.destPostcode = undefined
form.weight = undefined
form.bizDate = undefined
productOptions.value = []
countryOptions.value = []
countryRows.value = []
result.value = null
@@ -539,7 +592,6 @@ function sourceTagType(source) {
return ''
}
loadProducts()
</script>
<style scoped>