317 lines
9.1 KiB
Vue
317 lines
9.1 KiB
Vue
<template>
|
||
<el-drawer
|
||
:model-value="modelValue"
|
||
:title="title"
|
||
size="72%"
|
||
destroy-on-close
|
||
@close="close"
|
||
>
|
||
<div class="drawer-body" v-loading="loading">
|
||
<div class="toolbar">
|
||
<el-select
|
||
v-model="query.productKeyword"
|
||
filterable
|
||
clearable
|
||
:placeholder="phProduct"
|
||
:loading="optionsLoading"
|
||
style="width: 200px"
|
||
>
|
||
<el-option v-for="p in optionProducts" :key="p.code" :label="p.label" :value="p.code">
|
||
<span class="opt-name">{{ p.name }}</span>
|
||
<span class="opt-code">{{ p.code }}</span>
|
||
</el-option>
|
||
</el-select>
|
||
<el-select
|
||
v-if="isFixed"
|
||
v-model="query.countryKeyword"
|
||
filterable
|
||
clearable
|
||
:placeholder="phCountry"
|
||
:loading="optionsLoading"
|
||
style="width: 160px"
|
||
>
|
||
<el-option v-for="c in optionCountries" :key="c.key" :label="c.label" :value="c.value">
|
||
<span class="opt-name">{{ c.name }}</span>
|
||
<span class="opt-code">{{ c.code }}</span>
|
||
</el-option>
|
||
</el-select>
|
||
<el-select
|
||
v-if="isFixed"
|
||
v-model="query.zoneKeyword"
|
||
filterable
|
||
clearable
|
||
:placeholder="phZone"
|
||
:loading="optionsLoading"
|
||
style="width: 160px"
|
||
>
|
||
<el-option v-for="z in optionZones" :key="z.key" :label="z.label" :value="z.value">
|
||
<span class="opt-name">{{ z.name }}</span>
|
||
<span class="opt-code">{{ z.code }}</span>
|
||
</el-option>
|
||
</el-select>
|
||
<el-button type="primary" @click="search">查询</el-button>
|
||
<el-button @click="reset">重置</el-button>
|
||
</div>
|
||
|
||
<el-table :data="rows" border height="calc(100vh - 220px)" empty-text="暂无明细">
|
||
<el-table-column :label="colProduct" min-width="180">
|
||
<template #default="{ row }">
|
||
<div class="cell-product">
|
||
<span class="p-code">{{ row.productCode }}</span>
|
||
<span class="p-name">{{ row.productName || '' }}</span>
|
||
</div>
|
||
</template>
|
||
</el-table-column>
|
||
|
||
<template v-if="isFixed">
|
||
<el-table-column :label="colCountry" min-width="120">
|
||
<template #default="{ row }">{{ row.countryName || row.countryCode || '-' }}</template>
|
||
</el-table-column>
|
||
<el-table-column :label="colZone" min-width="110">
|
||
<template #default="{ row }">{{ row.zoneName || row.zoneCode || '-' }}</template>
|
||
</el-table-column>
|
||
<el-table-column :label="colWeight" prop="weightLabel" min-width="120" />
|
||
<el-table-column :label="colFv" min-width="130" align="right">
|
||
<template #default="{ row }">
|
||
<template v-if="row.fvValue == null">
|
||
<span class="unit">未覆盖</span>
|
||
</template>
|
||
<template v-else>
|
||
<span class="hl">{{ row.fvValue }}</span>
|
||
<span class="unit"> RMB/KG</span>
|
||
</template>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column :label="colReg" min-width="120" align="right">
|
||
<template #default="{ row }">
|
||
<span class="reg">{{ row.fvRegistrationFee }}</span>
|
||
<span class="unit"> RMB/票</span>
|
||
</template>
|
||
</el-table-column>
|
||
</template>
|
||
|
||
<el-table-column v-else :label="colDisc" min-width="120" align="center">
|
||
<template #default="{ row }">
|
||
<el-tag v-if="row.discountValue == null" size="small" type="info" effect="plain">默认折扣</el-tag>
|
||
<span v-else class="pct">{{ row.discountValue }}%</span>
|
||
</template>
|
||
</el-table-column>
|
||
|
||
<el-table-column :label="colSc" min-width="200">
|
||
<template #default="{ row }">
|
||
<surcharge-tags :list="row.surcharges || []" :empty-text="noneSc" />
|
||
</template>
|
||
</el-table-column>
|
||
|
||
<el-table-column :label="colRound" min-width="100" align="center">
|
||
<template #default="{ row }">{{ roundModeLabel(row.roundMode) }}</template>
|
||
</el-table-column>
|
||
</el-table>
|
||
|
||
<div class="pager">
|
||
<pagination
|
||
v-show="total > 0"
|
||
:total="total"
|
||
v-model:page="query.pageNum"
|
||
v-model:limit="query.pageSize"
|
||
@pagination="load"
|
||
/>
|
||
</div>
|
||
</div>
|
||
|
||
<template #footer>
|
||
<el-button @click="close">关闭</el-button>
|
||
</template>
|
||
</el-drawer>
|
||
</template>
|
||
|
||
<script setup name="SetVersionDetailDrawer">
|
||
import SurchargeTags from '../SurchargeTags.vue'
|
||
import { isFixedType } from '../../utils/priceSet'
|
||
import { listSetDetail, listSetDetailOptions } from '@/api/price/set'
|
||
|
||
const props = defineProps({
|
||
modelValue: { type: Boolean, default: false },
|
||
version: { type: Object, default: null },
|
||
setType: { type: String, default: 'FIXED' }
|
||
})
|
||
const emit = defineEmits(['update:modelValue'])
|
||
|
||
const { bms_round_mode } = useDict('bms_round_mode')
|
||
|
||
const loading = ref(false)
|
||
const rows = ref([])
|
||
const total = ref(0)
|
||
const query = reactive({
|
||
pageNum: 1,
|
||
pageSize: 20,
|
||
productKeyword: '',
|
||
countryKeyword: '',
|
||
zoneKeyword: ''
|
||
})
|
||
|
||
// 下拉选项:当前版本内去重后的 产品/国家/分区
|
||
const optionsLoading = ref(false)
|
||
const optionProducts = ref([])
|
||
const optionCountries = ref([])
|
||
const optionZones = ref([])
|
||
|
||
function loadOptions() {
|
||
const psvId = props.version && props.version.psvId
|
||
if (!psvId) {
|
||
optionProducts.value = []
|
||
optionCountries.value = []
|
||
optionZones.value = []
|
||
return
|
||
}
|
||
optionsLoading.value = true
|
||
listSetDetailOptions(psvId).then(res => {
|
||
const data = res.data || {}
|
||
optionProducts.value = (data.products || []).map(p => ({
|
||
code: p.code,
|
||
name: p.name || p.code,
|
||
label: (p.name && p.name !== p.code) ? `${p.code} ${p.name}` : p.code
|
||
}))
|
||
optionCountries.value = (data.countries || []).map(c => ({
|
||
key: c.code || c.name,
|
||
code: c.code || '-',
|
||
name: c.name || c.code,
|
||
value: c.code || c.name, // 有代码按代码搜,否则按名称搜(后端 code/name 双 LIKE)
|
||
label: (c.name && c.code) ? `${c.name} ${c.code}` : (c.name || c.code)
|
||
}))
|
||
optionZones.value = (data.zones || []).map(z => ({
|
||
key: z.code || z.name,
|
||
code: z.code || '-',
|
||
name: z.name || z.code,
|
||
value: z.code || z.name,
|
||
label: (z.name && z.code) ? `${z.name} ${z.code}` : (z.name || z.code)
|
||
}))
|
||
}).finally(() => {
|
||
optionsLoading.value = false
|
||
})
|
||
}
|
||
|
||
const phProduct = '产品'
|
||
const phCountry = '国家'
|
||
const phZone = '分区'
|
||
const colProduct = '产品'
|
||
const colCountry = '国家'
|
||
const colZone = '分区'
|
||
const colWeight = '重量段'
|
||
const colFv = '运费单价'
|
||
const colReg = '挂号费'
|
||
const colDisc = '产品折扣'
|
||
const colSc = '附加费'
|
||
const colRound = '取值方式'
|
||
const noneSc = '无'
|
||
|
||
const isFixed = computed(() => isFixedType(props.setType))
|
||
const title = computed(() => {
|
||
const v = props.version || {}
|
||
return (v.versionNo || '-') + ' · 版本明细'
|
||
})
|
||
|
||
function roundModeLabel(mode) {
|
||
const hit = (bms_round_mode.value || []).find(d => d.value === mode)
|
||
return hit ? hit.label : (mode || '四舍五入')
|
||
}
|
||
|
||
function close() {
|
||
emit('update:modelValue', false)
|
||
}
|
||
|
||
function search() {
|
||
query.pageNum = 1
|
||
load()
|
||
}
|
||
|
||
function reset() {
|
||
query.productKeyword = ''
|
||
query.countryKeyword = ''
|
||
query.zoneKeyword = ''
|
||
query.pageNum = 1
|
||
load()
|
||
}
|
||
|
||
function load() {
|
||
const psvId = props.version && props.version.psvId
|
||
if (!psvId) {
|
||
rows.value = []
|
||
total.value = 0
|
||
return
|
||
}
|
||
loading.value = true
|
||
listSetDetail({
|
||
psvId,
|
||
productKeyword: query.productKeyword || undefined,
|
||
countryKeyword: isFixed.value ? (query.countryKeyword || undefined) : undefined,
|
||
zoneKeyword: isFixed.value ? (query.zoneKeyword || undefined) : undefined,
|
||
pageNum: query.pageNum,
|
||
pageSize: query.pageSize
|
||
}).then(res => {
|
||
rows.value = res.rows || []
|
||
total.value = res.total || 0
|
||
}).finally(() => {
|
||
loading.value = false
|
||
})
|
||
}
|
||
|
||
watch(
|
||
() => [props.modelValue, props.version && props.version.psvId],
|
||
([open]) => {
|
||
if (open) {
|
||
query.pageNum = 1
|
||
query.productKeyword = ''
|
||
query.countryKeyword = ''
|
||
query.zoneKeyword = ''
|
||
loadOptions()
|
||
load()
|
||
}
|
||
}
|
||
)
|
||
</script>
|
||
|
||
<style scoped>
|
||
.drawer-body {
|
||
display: flex;
|
||
flex-direction: column;
|
||
height: 100%;
|
||
min-height: 0;
|
||
}
|
||
.toolbar {
|
||
display: flex;
|
||
gap: 8px;
|
||
margin-bottom: 12px;
|
||
flex-wrap: wrap;
|
||
align-items: center;
|
||
}
|
||
.pager {
|
||
margin-top: 12px;
|
||
}
|
||
.cell-product {
|
||
display: flex;
|
||
align-items: baseline;
|
||
gap: 6px;
|
||
}
|
||
.p-code {
|
||
font-family: Consolas, Monaco, monospace;
|
||
font-size: 12px;
|
||
color: #606266;
|
||
background: #f4f4f5;
|
||
border-radius: 3px;
|
||
padding: 0 6px;
|
||
}
|
||
.p-name { color: #303133; }
|
||
.opt-name { margin-right: 8px; }
|
||
.opt-code {
|
||
float: right;
|
||
color: var(--el-text-color-secondary);
|
||
font-size: 12px;
|
||
font-family: Consolas, Monaco, monospace;
|
||
}
|
||
.hl { color: #1890ff; font-weight: 600; }
|
||
.reg { color: #d48806; font-weight: 600; }
|
||
.pct { color: #1890ff; font-weight: 600; }
|
||
.unit { font-size: 12px; color: #909399; }
|
||
</style>
|