提交附加费配置功能
This commit is contained in:
@@ -0,0 +1,310 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<basic-table
|
||||
ref="tableRef"
|
||||
:columns="columns"
|
||||
:search-columns="searchColumns"
|
||||
:query="queryList"
|
||||
row-key="scId"
|
||||
>
|
||||
<template #toolbar="{ selection, ids }">
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="primary"
|
||||
plain
|
||||
icon="Plus"
|
||||
@click="handleAdd"
|
||||
v-hasPermi="['price:surcharge:add']"
|
||||
>新建附加费</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="success"
|
||||
plain
|
||||
icon="Edit"
|
||||
:disabled="selection.length !== 1"
|
||||
@click="handleUpdate(selection[0])"
|
||||
v-hasPermi="['price:surcharge:edit']"
|
||||
>修改</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="danger"
|
||||
plain
|
||||
icon="Delete"
|
||||
:disabled="!selection.length"
|
||||
@click="handleDelete(ids)"
|
||||
v-hasPermi="['price:surcharge:remove']"
|
||||
>删除</el-button>
|
||||
</el-col>
|
||||
</template>
|
||||
|
||||
<template #col-ssCode="{ row }">
|
||||
<el-tag :type="(row.ssCode || '').toLowerCase() === 'on' ? 'success' : 'warning'" size="small">
|
||||
{{ (row.ssCode || '').toLowerCase() === 'on' ? '有效' : '停用' }}
|
||||
</el-tag>
|
||||
</template>
|
||||
|
||||
<template #col-chargeType="{ row }">
|
||||
<el-tag type="primary" size="small" effect="plain">{{ chargeTypeLabel(row.chargeType) }}</el-tag>
|
||||
</template>
|
||||
|
||||
<template #col-chargeValue="{ row }">
|
||||
<span class="charge-value">{{ formatChargeValue(row) }}</span>
|
||||
</template>
|
||||
|
||||
<template #col-countryCode="{ row }">
|
||||
<span>{{ countryLabel(row.countryCode) }}</span>
|
||||
</template>
|
||||
|
||||
<template #col-action="{ row }">
|
||||
<el-button link type="primary" icon="Edit" @click="handleUpdate(row)" v-hasPermi="['price:surcharge:edit']">编辑</el-button>
|
||||
<el-button link type="primary" icon="Delete" @click="handleDelete(row.scId)" v-hasPermi="['price:surcharge:remove']">删除</el-button>
|
||||
</template>
|
||||
</basic-table>
|
||||
|
||||
<el-dialog :title="title" v-model="open" width="640px" append-to-body>
|
||||
<el-form ref="formRef" :model="form" :rules="rules" label-width="100px">
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="附加费名称" prop="scName">
|
||||
<el-input v-model="form.scName" placeholder="如 燃油附加费" maxlength="100" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="费用类型" prop="feeType">
|
||||
<el-select v-model="form.feeType" placeholder="请选择" style="width: 100%" disabled>
|
||||
<el-option v-for="d in bms_fee_type" :key="d.value" :label="d.label" :value="d.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="计费方式" prop="chargeType">
|
||||
<el-select v-model="form.chargeType" placeholder="请选择" style="width: 100%">
|
||||
<el-option v-for="c in bms_charge_type" :key="c.value" :label="c.label" :value="c.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="计费数值" prop="chargeValue">
|
||||
<el-input-number v-model="form.chargeValue" :min="0" :precision="6" :step="1" controls-position="right" style="width: 100%" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="币种" prop="currency">
|
||||
<el-select v-model="form.currency" placeholder="请选择" style="width: 100%">
|
||||
<el-option v-for="c in bms_currency" :key="c.value" :label="c.label" :value="c.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="取值方式" prop="roundMode">
|
||||
<el-select v-model="form.roundMode" placeholder="请选择" style="width: 100%">
|
||||
<el-option v-for="d in bms_round_mode" :key="d.value" :label="d.label" :value="d.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="适用国家" prop="countryCode">
|
||||
<el-select v-model="form.countryCode" placeholder="全部国家" clearable filterable style="width: 100%">
|
||||
<el-option label="全部国家" value="" />
|
||||
<el-option v-for="r in regionOptions" :key="r.countryCode2" :label="regionLabel(r)" :value="r.countryCode2" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="状态" prop="ssCode">
|
||||
<el-radio-group v-model="form.ssCode">
|
||||
<el-radio value="on">有效</el-radio>
|
||||
<el-radio value="of">停用</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-form-item label="备注" prop="scNote">
|
||||
<el-input v-model="form.scNote" type="textarea" :rows="2" placeholder="请输入备注" maxlength="500" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button type="primary" @click="submitForm">确 定</el-button>
|
||||
<el-button @click="open = false">取 消</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup name="PriceSurcharge">
|
||||
import { listSurcharge, getSurcharge, addSurcharge, updateSurcharge, delSurcharge } from '@/api/price/surcharge'
|
||||
import { listRegionOptions } from '@/api/data/region'
|
||||
import { onMounted } from 'vue'
|
||||
|
||||
const { proxy } = getCurrentInstance()
|
||||
const { bms_fee_type, bms_round_mode, bms_charge_type, bms_currency } = useDict('bms_fee_type', 'bms_round_mode', 'bms_charge_type', 'bms_currency')
|
||||
|
||||
const tableRef = ref()
|
||||
const open = ref(false)
|
||||
const title = ref('')
|
||||
const regionOptions = ref([])
|
||||
|
||||
const columns = [
|
||||
{ label: 'scId', prop: 'scId', align: 'center', width: 80 },
|
||||
{ label: '附加费名称', prop: 'scName', align: 'center', minWidth: 140, showOverflowTooltip: true },
|
||||
{ label: '费用类型', prop: 'feeType', align: 'center', width: 110, dict: 'bms_fee_type' },
|
||||
{ label: '计费方式', prop: 'chargeType', align: 'center', width: 130 },
|
||||
{ label: '计费数值', prop: 'chargeValue', align: 'center', width: 140 },
|
||||
{ label: '取值方式', prop: 'roundMode', align: 'center', width: 110, dict: 'bms_round_mode' },
|
||||
{ label: '适用国家', prop: 'countryCode', align: 'center', minWidth: 120, showOverflowTooltip: true },
|
||||
{ label: '状态', prop: 'ssCode', align: 'center', width: 80 },
|
||||
{ label: '备注', prop: 'scNote', align: 'center', minWidth: 140, showOverflowTooltip: true },
|
||||
{ label: '创建时间', prop: 'createTime', align: 'center', width: 160, parseTime: true },
|
||||
{ label: '操作', prop: 'action', align: 'center', width: 150, fixed: 'right', showInToolbar: false }
|
||||
]
|
||||
|
||||
const searchColumns = [
|
||||
{ label: '附加费名称', prop: 'scName', component: 'input', placeholder: '请输入名称', width: '200px' },
|
||||
{
|
||||
label: '计费方式',
|
||||
prop: 'chargeType',
|
||||
component: 'select',
|
||||
dict: 'bms_charge_type',
|
||||
placeholder: '计费方式',
|
||||
width: '150px'
|
||||
},
|
||||
{ label: '取值方式', prop: 'roundMode', component: 'select', dict: 'bms_round_mode', placeholder: '取值方式', width: '150px' },
|
||||
{
|
||||
label: '状态',
|
||||
prop: 'ssCode',
|
||||
component: 'select',
|
||||
options: [
|
||||
{ label: '有效', value: 'on' },
|
||||
{ label: '停用', value: 'of' }
|
||||
],
|
||||
placeholder: '状态',
|
||||
width: '120px'
|
||||
}
|
||||
]
|
||||
|
||||
const data = reactive({
|
||||
form: {},
|
||||
rules: {
|
||||
scName: [{ required: true, message: '附加费名称不能为空', trigger: 'blur' }],
|
||||
feeType: [{ required: true, message: '请选择费用类型', trigger: 'change' }],
|
||||
chargeType: [{ required: true, message: '请选择计费方式', trigger: 'change' }],
|
||||
chargeValue: [{ required: true, message: '计费数值不能为空', trigger: 'blur' }],
|
||||
roundMode: [{ required: true, message: '请选择取值方式', trigger: 'change' }]
|
||||
}
|
||||
})
|
||||
const { form, rules } = toRefs(data)
|
||||
|
||||
function queryList(params) {
|
||||
return listSurcharge(params)
|
||||
}
|
||||
|
||||
function chargeTypeLabel(val) {
|
||||
const found = bms_charge_type.value.find(c => c.value === val)
|
||||
return found ? found.label : (val || '-')
|
||||
}
|
||||
|
||||
function regionLabel(r) {
|
||||
const cn = r.countryNameCn || r.countryNameEn || ''
|
||||
return cn ? `${r.flagEmoji || ''} ${cn} (${r.countryCode2})`.trim() : r.countryCode2
|
||||
}
|
||||
|
||||
function countryLabel(code) {
|
||||
if (!code) return '全部'
|
||||
const found = regionOptions.value.find(r => r.countryCode2 === code)
|
||||
return found ? (found.countryNameCn || found.countryNameEn || code) : code
|
||||
}
|
||||
|
||||
function loadRegionOptions() {
|
||||
listRegionOptions().then(res => {
|
||||
regionOptions.value = res.data || []
|
||||
})
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
loadRegionOptions()
|
||||
})
|
||||
|
||||
function formatChargeValue(row) {
|
||||
if (row.chargeValue == null) return '-'
|
||||
const v = Number(row.chargeValue)
|
||||
if (row.chargeType === 'RATE') {
|
||||
return (v * 100).toFixed(2) + '%'
|
||||
}
|
||||
return v + ' ' + (row.currency || 'CNY')
|
||||
}
|
||||
|
||||
function reset() {
|
||||
form.value = {
|
||||
scId: undefined,
|
||||
scName: undefined,
|
||||
feeType: 'SURCHARGE',
|
||||
chargeType: 'FIXED',
|
||||
chargeValue: undefined,
|
||||
currency: 'CNY',
|
||||
roundMode: 'HALF_UP',
|
||||
ssCode: 'on',
|
||||
countryCode: undefined,
|
||||
scNote: undefined
|
||||
}
|
||||
proxy.resetForm('formRef')
|
||||
}
|
||||
|
||||
function handleAdd() {
|
||||
reset()
|
||||
open.value = true
|
||||
title.value = '新建附加费'
|
||||
}
|
||||
|
||||
function handleUpdate(row) {
|
||||
reset()
|
||||
getSurcharge(row.scId).then(res => {
|
||||
const data = res.data || {}
|
||||
if (data.ssCode) data.ssCode = String(data.ssCode).toLowerCase()
|
||||
form.value = data
|
||||
open.value = true
|
||||
title.value = '修改附加费'
|
||||
})
|
||||
}
|
||||
|
||||
function submitForm() {
|
||||
proxy.$refs['formRef'].validate(valid => {
|
||||
if (!valid) return
|
||||
const payload = { ...form.value }
|
||||
if (!payload.countryCode) payload.countryCode = undefined
|
||||
if (payload.chargeValue != null) payload.chargeValue = Number(payload.chargeValue)
|
||||
const req = payload.scId != null ? updateSurcharge(payload) : addSurcharge(payload)
|
||||
req.then(() => {
|
||||
proxy.$modal.msgSuccess(payload.scId != null ? '修改成功' : '新增成功')
|
||||
open.value = false
|
||||
tableRef.value.refresh()
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function handleDelete(ids) {
|
||||
const idText = Array.isArray(ids) ? ids.join(',') : ids
|
||||
proxy.$modal.confirm('是否确认删除所选附加费配置?').then(() => {
|
||||
return delSurcharge(idText)
|
||||
}).then(() => {
|
||||
proxy.$modal.msgSuccess('删除成功')
|
||||
tableRef.value.refresh()
|
||||
}).catch(() => {})
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.charge-value {
|
||||
font-weight: 600;
|
||||
color: #d63031;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user