修改测试
This commit is contained in:
@@ -63,99 +63,24 @@
|
||||
</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>
|
||||
<surcharge-form-dialog ref="formDialogRef" @success="() => tableRef.refresh()" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup name="PriceSurcharge">
|
||||
import { listSurcharge, getSurcharge, addSurcharge, updateSurcharge, delSurcharge } from '@/api/price/surcharge'
|
||||
import { listSurcharge, delSurcharge } from '@/api/price/surcharge'
|
||||
import SurchargeFormDialog from './components/SurchargeFormDialog.vue'
|
||||
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 { bms_charge_type } = useDict('bms_charge_type')
|
||||
|
||||
const tableRef = ref()
|
||||
const open = ref(false)
|
||||
const title = ref('')
|
||||
const formDialogRef = 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 },
|
||||
@@ -192,18 +117,6 @@ const searchColumns = [
|
||||
}
|
||||
]
|
||||
|
||||
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)
|
||||
}
|
||||
@@ -213,11 +126,6 @@ function chargeTypeLabel(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)
|
||||
@@ -243,52 +151,12 @@ function formatChargeValue(row) {
|
||||
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 = '新建附加费'
|
||||
formDialogRef.value.open()
|
||||
}
|
||||
|
||||
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()
|
||||
})
|
||||
})
|
||||
formDialogRef.value.open(row)
|
||||
}
|
||||
|
||||
function handleDelete(ids) {
|
||||
|
||||
Reference in New Issue
Block a user