应付配置的附加费调整
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<el-dialog :title="title" v-model="visible" width="720px" append-to-body>
|
||||
<basic-form ref="formRef" v-model="form" :schemas="schemas" label-width="100px" />
|
||||
<el-dialog :title="title" v-model="visible" width="760px" append-to-body>
|
||||
<basic-form ref="formRef" v-model="form" class="surcharge-form" :schemas="schemas" label-width="118px" />
|
||||
<template #footer>
|
||||
<el-button type="primary" @click="submitForm">确 定</el-button>
|
||||
<el-button @click="visible = false">取 消</el-button>
|
||||
@@ -15,7 +15,6 @@ import { listRegionOptions } from '@/api/data/region'
|
||||
|
||||
const emit = defineEmits(['success'])
|
||||
const { proxy } = getCurrentInstance()
|
||||
const { payment_product_type } = useDict('payment_product_type')
|
||||
|
||||
const formRef = ref()
|
||||
const visible = ref(false)
|
||||
@@ -45,17 +44,12 @@ const countrySelectOptions = computed(() => {
|
||||
})))
|
||||
})
|
||||
|
||||
const channelProductOptions = computed(() =>
|
||||
(payment_product_type.value || []).map(item => ({
|
||||
label: item.label,
|
||||
value: item.value
|
||||
}))
|
||||
)
|
||||
|
||||
const blockSelectOptions = computed(() =>
|
||||
(blockOptions.value || []).map(title => ({ label: title, value: title }))
|
||||
)
|
||||
|
||||
const chargeType = computed(() => String(form.value.chargeType || '').toUpperCase())
|
||||
|
||||
const schemas = computed(() => [
|
||||
{
|
||||
label: '附加费名称',
|
||||
@@ -89,14 +83,67 @@ const schemas = computed(() => [
|
||||
rules: [{ required: true, message: '请选择计费方式', trigger: 'change' }]
|
||||
},
|
||||
{
|
||||
label: '渠道产品',
|
||||
prop: 'dictValue',
|
||||
component: 'select',
|
||||
placeholder: '请选择渠道产品',
|
||||
options: channelProductOptions.value,
|
||||
label: '长(cm)',
|
||||
prop: 'lengthCm',
|
||||
component: 'inputNumber',
|
||||
span: 12,
|
||||
width: '100%',
|
||||
props: { filterable: true, clearable: true }
|
||||
show: chargeType.value === 'SIZE',
|
||||
props: { min: 0, precision: 2, controls: false, align: 'left' },
|
||||
rules: chargeType.value === 'SIZE' ? [{ required: true, message: '请填写长', trigger: 'blur' }] : undefined
|
||||
},
|
||||
{
|
||||
label: '宽(cm)',
|
||||
prop: 'widthCm',
|
||||
component: 'inputNumber',
|
||||
span: 12,
|
||||
width: '100%',
|
||||
show: chargeType.value === 'SIZE',
|
||||
props: { min: 0, precision: 2, controls: false, align: 'left' },
|
||||
rules: chargeType.value === 'SIZE' ? [{ required: true, message: '请填写宽', trigger: 'blur' }] : undefined
|
||||
},
|
||||
{
|
||||
label: '高(cm)',
|
||||
prop: 'heightCm',
|
||||
component: 'inputNumber',
|
||||
span: 12,
|
||||
width: '100%',
|
||||
show: chargeType.value === 'SIZE',
|
||||
props: { min: 0, precision: 2, controls: false, align: 'left' },
|
||||
rules: chargeType.value === 'SIZE' ? [{ required: true, message: '请填写高', trigger: 'blur' }] : undefined
|
||||
},
|
||||
{
|
||||
label: '超过重量(kg)',
|
||||
prop: 'overWeightKg',
|
||||
component: 'inputNumber',
|
||||
placeholder: '超过这个重量才收取',
|
||||
span: 12,
|
||||
width: '100%',
|
||||
show: chargeType.value === 'WEIGHT',
|
||||
props: { min: 0, precision: 3, controls: false, align: 'left' },
|
||||
rules: chargeType.value === 'WEIGHT' ? [{ required: true, message: '请填写超过重量', trigger: 'blur' }] : undefined
|
||||
},
|
||||
{
|
||||
label: '续重起始(kg)',
|
||||
prop: 'extraWeightKg',
|
||||
component: 'inputNumber',
|
||||
placeholder: '超过这个重量后按超出公斤计',
|
||||
span: 12,
|
||||
width: '100%',
|
||||
show: chargeType.value === 'EXTRA_KG',
|
||||
props: { min: 0, precision: 3, controls: false, align: 'left' },
|
||||
rules: chargeType.value === 'EXTRA_KG' ? [{ required: true, message: '请填写续重起始重量', trigger: 'blur' }] : undefined
|
||||
},
|
||||
{
|
||||
label: '邮编',
|
||||
prop: 'postcodeText',
|
||||
component: 'textarea',
|
||||
placeholder: '多个可用逗号分隔',
|
||||
span: 24,
|
||||
width: '100%',
|
||||
show: chargeType.value === 'POSTCODE',
|
||||
props: { rows: 2, maxlength: 1000 },
|
||||
rules: chargeType.value === 'POSTCODE' ? [{ required: true, message: '请填写邮编', trigger: 'blur' }] : undefined
|
||||
},
|
||||
{
|
||||
label: '计费数值',
|
||||
@@ -104,7 +151,7 @@ const schemas = computed(() => [
|
||||
component: 'inputNumber',
|
||||
span: 12,
|
||||
width: '100%',
|
||||
props: { min: 0, precision: 6, step: 1, controlsPosition: 'right' },
|
||||
props: { min: 0, precision: 6, controls: false, align: 'left' },
|
||||
rules: [{ required: true, message: '计费数值不能为空', trigger: 'blur' }]
|
||||
},
|
||||
{
|
||||
@@ -144,6 +191,7 @@ const schemas = computed(() => [
|
||||
options: blockSelectOptions.value,
|
||||
span: 12,
|
||||
width: '100%',
|
||||
show: chargeType.value === 'ZONE',
|
||||
disabled: !form.value.countryCode || loadingBlocks.value,
|
||||
props: { filterable: true, clearable: true }
|
||||
},
|
||||
@@ -163,14 +211,19 @@ function emptyForm() {
|
||||
scId: undefined,
|
||||
scName: undefined,
|
||||
feeType: 'SURCHARGE',
|
||||
dictValue: undefined,
|
||||
chargeType: 'MANUAL',
|
||||
chargeValue: 0,
|
||||
currency: 'CNY',
|
||||
roundMode: 'HALF_UP',
|
||||
countryCode: undefined,
|
||||
blockTitle: undefined,
|
||||
scNote: undefined
|
||||
scNote: undefined,
|
||||
lengthCm: undefined,
|
||||
widthCm: undefined,
|
||||
heightCm: undefined,
|
||||
overWeightKg: undefined,
|
||||
extraWeightKg: undefined,
|
||||
postcodeText: undefined
|
||||
}
|
||||
}
|
||||
|
||||
@@ -252,7 +305,7 @@ function submitForm() {
|
||||
if (!valid) return
|
||||
const payload = { ...form.value }
|
||||
if (!payload.countryCode) payload.countryCode = undefined
|
||||
if (!payload.dictValue) payload.dictValue = undefined
|
||||
delete payload.dictValue
|
||||
if (!payload.blockTitle) payload.blockTitle = undefined
|
||||
if (!payload.chargeType) payload.chargeType = 'MANUAL'
|
||||
if (payload.chargeValue != null) payload.chargeValue = Number(payload.chargeValue)
|
||||
@@ -273,5 +326,33 @@ watch(() => form.value.countryCode, (code, prev) => {
|
||||
loadBlockOptions(code, false)
|
||||
})
|
||||
|
||||
watch(() => form.value.chargeType, (type, prev) => {
|
||||
if (suppressCountryWatch.value || !prev || type === prev) return
|
||||
form.value.lengthCm = undefined
|
||||
form.value.widthCm = undefined
|
||||
form.value.heightCm = undefined
|
||||
form.value.overWeightKg = undefined
|
||||
form.value.extraWeightKg = undefined
|
||||
form.value.postcodeText = undefined
|
||||
if (String(type || '').toUpperCase() !== 'ZONE') form.value.blockTitle = undefined
|
||||
nextTick(() => formRef.value?.clearValidate())
|
||||
})
|
||||
|
||||
defineExpose({ open })
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.surcharge-form :deep(.el-form-item__content) {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
.surcharge-form :deep(.el-input),
|
||||
.surcharge-form :deep(.el-select),
|
||||
.surcharge-form :deep(.el-input-number),
|
||||
.surcharge-form :deep(.el-textarea) {
|
||||
width: 100%;
|
||||
}
|
||||
.surcharge-form :deep(.el-input-number .el-input__inner) {
|
||||
text-align: left;
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user