导入新产品,20.套餐编辑的时候,不能低于基准价,低于就提示不能保存
This commit is contained in:
@@ -99,6 +99,8 @@ const props = defineProps({
|
||||
})
|
||||
const emit = defineEmits(['update:modelValue', 'pick-surcharge', 'row-change'])
|
||||
|
||||
const { proxy } = getCurrentInstance()
|
||||
|
||||
const keyword = ref('')
|
||||
const editingKey = ref('')
|
||||
const committing = ref(false)
|
||||
@@ -109,7 +111,7 @@ const title = computed(() => {
|
||||
const name = props.productName || ''
|
||||
return code + ' · ' + name + ' · 国家服务价格'
|
||||
})
|
||||
const hint = '黄色行=已改价;点编辑图标后修改,失焦即刻写入数据库。单位:运费 RMB/KG,挂号费 RMB/票。'
|
||||
const hint = '黄色行=已改价;点编辑图标后修改,失焦即刻写入数据库。单位:运费 RMB/KG,挂号费 RMB/票。不能低于导入基准价。'
|
||||
const phSearch = '搜索国家/分区'
|
||||
const colCountry = '国家'
|
||||
const colZone = '分区'
|
||||
@@ -136,6 +138,8 @@ function setEditRef(el, row, field) {
|
||||
|
||||
function startEdit(row, field) {
|
||||
if (!row) return
|
||||
row._editPrevFv = row.fvValue
|
||||
row._editPrevReg = row.fvRegistrationFee
|
||||
editingKey.value = cellKey(row, field)
|
||||
nextTick(() => {
|
||||
const el = editInputRefs[editingKey.value]
|
||||
@@ -143,13 +147,36 @@ function startEdit(row, field) {
|
||||
})
|
||||
}
|
||||
|
||||
function isBelowFloor(value, floor) {
|
||||
if (value == null || value === '' || floor == null || floor === '') return false
|
||||
const n = Number(value)
|
||||
const f = Number(floor)
|
||||
if (Number.isNaN(n) || Number.isNaN(f)) return false
|
||||
return n + 1e-8 < f
|
||||
}
|
||||
|
||||
function belowFloorMessage(field, floor) {
|
||||
const name = field === 'fv' ? '\u5957\u9910\u8fd0\u8d39' : '\u5957\u9910\u6302\u53f7\u8d39'
|
||||
const prec = field === 'fv' ? 4 : 2
|
||||
return name + '\u4e0d\u80fd\u4f4e\u4e8e\u5bfc\u5165\u57fa\u51c6\u4ef7 ' + formatNum(floor, prec)
|
||||
}
|
||||
|
||||
async function commitEdit(row, field) {
|
||||
if (committing.value) return
|
||||
if (editingKey.value !== cellKey(row, field)) return
|
||||
editingKey.value = ''
|
||||
if (!row || !row.psdId) return
|
||||
committing.value = true
|
||||
editingKey.value = ''
|
||||
try {
|
||||
if (!row) return
|
||||
const floor = field === 'fv' ? row._floorFreight : row._floorReg
|
||||
const value = field === 'fv' ? row.fvValue : row.fvRegistrationFee
|
||||
if (isBelowFloor(value, floor)) {
|
||||
if (field === 'fv') row.fvValue = row._editPrevFv
|
||||
else row.fvRegistrationFee = row._editPrevReg
|
||||
proxy.$modal.msgError(belowFloorMessage(field, floor))
|
||||
return
|
||||
}
|
||||
if (!row.psdId) return
|
||||
emit('row-change', row)
|
||||
} finally {
|
||||
committing.value = false
|
||||
|
||||
Reference in New Issue
Block a user