应付模块菜单调整,新增应付费用编辑等
This commit is contained in:
@@ -50,7 +50,7 @@
|
||||
<el-table-column min-width="180">
|
||||
<template #header><span class="col-label"><i class="req-star">*</i>费用名称</span></template>
|
||||
<template #default="{ row }">
|
||||
<el-select v-model="row.feeType" filterable remote clearable reserve-keyword placeholder="输入费用名称"
|
||||
<el-select v-model="row.scId" filterable remote clearable reserve-keyword placeholder="输入费用名称"
|
||||
:remote-method="searchSurcharge" :loading="surchargeLoading" :disabled="locked(row)" style="width: 100%"
|
||||
@change="id => onFeeChange(row, id)">
|
||||
<el-option v-for="item in surchargeOptions" :key="item.scId" :label="item.scName" :value="item.scId" />
|
||||
@@ -240,12 +240,18 @@ async function loadFees(force = false) {
|
||||
searchSurcharge('')
|
||||
}
|
||||
|
||||
function pickedId(item) {
|
||||
if (item?.scId != null && item.scId !== '') return String(item.scId)
|
||||
const type = item?.feeType == null ? '' : String(item.feeType)
|
||||
return /^\d+$/.test(type) ? type : ''
|
||||
}
|
||||
|
||||
function toRow(item, saved) {
|
||||
const row = {
|
||||
rowKey: saved ? `fee-${item.id}` : `new-${++rowSeed}`,
|
||||
id: saved ? item.id : null,
|
||||
billCode: item.billCode || '',
|
||||
feeType: item.feeType == null ? '' : String(item.feeType),
|
||||
scId: pickedId(item),
|
||||
feeName: item.feeName || '',
|
||||
price: item.price === null || item.price === undefined ? null : Number(item.price),
|
||||
currency: item.currency || '',
|
||||
@@ -258,7 +264,7 @@ function toRow(item, saved) {
|
||||
|
||||
function snapshot(row) {
|
||||
return {
|
||||
feeType: row.feeType || '',
|
||||
scId: row.scId || '',
|
||||
price: row.price === null || row.price === undefined || row.price === '' ? '' : String(Number(row.price)),
|
||||
currency: row.currency || '',
|
||||
remark: (row.remark || '').trim()
|
||||
@@ -267,7 +273,7 @@ function snapshot(row) {
|
||||
|
||||
function currentOf(row) {
|
||||
return {
|
||||
feeType: row.feeType || '',
|
||||
scId: row.scId || '',
|
||||
price: row.price === null || row.price === undefined || row.price === '' ? '' : String(Number(row.price)),
|
||||
currency: row.currency || '',
|
||||
remark: (row.remark || '').trim()
|
||||
@@ -275,9 +281,9 @@ function currentOf(row) {
|
||||
}
|
||||
|
||||
function rowChanged(row) {
|
||||
if (!row.origin) return !!(row.feeType || row.price || row.currency || row.remark)
|
||||
if (!row.origin) return !!(row.scId || row.price || row.currency || row.remark)
|
||||
const now = currentOf(row)
|
||||
return now.feeType !== row.origin.feeType || now.price !== row.origin.price
|
||||
return now.scId !== row.origin.scId || now.price !== row.origin.price
|
||||
|| now.currency !== row.origin.currency || now.remark !== row.origin.remark
|
||||
}
|
||||
|
||||
@@ -302,7 +308,7 @@ function removeRow(row) {
|
||||
|
||||
function rowError(row) {
|
||||
if (!row.billCode) return '请选择提单'
|
||||
if (!row.feeType) return '请选择费用名称'
|
||||
if (!row.scId) return '请选择费用名称'
|
||||
if (row.price === null || row.price === undefined || row.price === '') return '请填写价格'
|
||||
if (Number(row.price) < 0) return '价格不能小于0'
|
||||
if (!row.currency) return '请选择币种'
|
||||
@@ -323,7 +329,7 @@ function save() {
|
||||
rows.value.forEach(row => {
|
||||
if (!rowChanged(row)) return
|
||||
const payload = {
|
||||
feeType: row.feeType || '',
|
||||
scId: row.scId || '',
|
||||
price: row.price,
|
||||
currency: row.currency || '',
|
||||
remark: (row.remark || '').trim()
|
||||
@@ -401,8 +407,8 @@ function onFeeChange(row, id) {
|
||||
function pinSelectedFees() {
|
||||
const known = new Map(surchargeOptions.value.map(item => [String(item.scId), item]))
|
||||
rows.value.forEach(row => {
|
||||
if (row.feeType && !known.has(String(row.feeType))) {
|
||||
known.set(String(row.feeType), { scId: String(row.feeType), scName: row.feeName || String(row.feeType) })
|
||||
if (row.scId && !known.has(String(row.scId))) {
|
||||
known.set(String(row.scId), { scId: String(row.scId), scName: row.feeName || String(row.scId) })
|
||||
}
|
||||
})
|
||||
surchargeOptions.value = [...known.values()]
|
||||
|
||||
Reference in New Issue
Block a user