Files
BMS/bms-front/src/views/price/basic/product/index.vue
T
2026-09-23 17:56:45 +08:00

214 lines
7.8 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<template>
<div class="app-container">
<el-alert
type="info"
:closable="false"
show-icon
class="mb16"
title="多国家价表用「全部导入」。单国专线成本价用「按国家导入」:先选目的国家,目录里的产品都记到该国。相同产品代码+生效日期不覆盖主数据。两种导入均可在弹窗内下载对应模板。"
/>
<basic-table
ref="tableRef"
:columns="columns"
:search-columns="searchColumns"
:query="queryList"
row-key="productId"
>
<template #toolbar="{ selection }">
<el-col :span="1.5">
<el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['price:product:add']">新建产品</el-button>
</el-col>
<el-col :span="1.5">
<el-dropdown @command="handleImportCommand">
<el-button type="info" plain icon="Upload" v-hasPermi="['price:product:import']">
导入 Excel<el-icon class="el-icon--right"><arrow-down /></el-icon>
</el-button>
<template #dropdown>
<el-dropdown-menu>
<el-dropdown-item command="all">全部导入(多国家价表)</el-dropdown-item>
<el-dropdown-item command="country">按国家导入(单国专线成本价)</el-dropdown-item>
</el-dropdown-menu>
</template>
</el-dropdown>
</el-col>
</template>
<template #col-cargoAttr="{ row }">
<el-tag type="primary" size="small" effect="plain">{{ row.cargoAttr || '-' }}</el-tag>
</template>
<template #col-status="{ row }">
<dict-tag :options="bms_product_effect_status" :value="row.status" />
</template>
<template #col-action="{ row }">
<el-button link type="primary" title="产品明细" icon="View" @click="countryRef.open(row)" v-hasPermi="['price:product:query']"></el-button>
<el-button link type="primary" title="附加费" icon="Money" @click="surchargeRef.open(row)" v-hasPermi="['price:surcharge:query']"></el-button>
<el-button title="编辑" link type="primary" icon="Edit" @click="handleUpdate(row)" v-hasPermi="['price:product:edit']"></el-button>
</template>
</basic-table>
<product-form-dialog ref="formRef" @success="() => tableRef.refresh()" />
<product-country-drawer ref="countryRef" />
<product-surcharge-drawer ref="surchargeRef" @success="() => tableRef.refresh()" />
<excel-import-dialog
ref="importRef"
title="产品 Excel 导入"
action="/price/product/importData"
width="560px"
:show-update-support="false"
template-url="/templates/product/product-import-all-template.xlsx"
template-file-name="产品多国家价表导入模板"
:import-desc="allImportDesc"
@success="() => tableRef.refresh()"
/>
<excel-import-dialog
ref="countryImportRef"
title="按国家导入"
action="/price/product/importCountryData"
width="560px"
:show-update-support="false"
:extra-query="countryImportQuery"
:before-submit="validateCountryImport"
:import-desc="countryImportDesc"
template-url="/templates/product/product-import-country-template.xlsx"
template-file-name="产品按国家导入模板"
@success="() => tableRef.refresh()"
>
<template #extra>
<el-form label-width="90px">
<el-form-item label="目的国家" required>
<el-select v-model="importCountryCode" filterable clearable placeholder="请选择国家" style="width: 100%">
<el-option
v-for="item in regionOptions"
:key="item.countryCode2"
:label="regionLabel(item)"
:value="item.countryCode2"
/>
</el-select>
</el-form-item>
</el-form>
</template>
</excel-import-dialog>
</div>
</template>
<script setup name="PriceProduct">
import ExcelImportDialog from '@/components/ExcelImportDialog'
import ProductFormDialog from './components/ProductFormDialog.vue'
import ProductCountryDrawer from './components/ProductCountryDrawer.vue'
import ProductSurchargeDrawer from './components/ProductSurchargeDrawer.vue'
import { listProduct } from '@/api/price/product'
import { listRegionOptions } from '@/api/data/region'
const { proxy } = getCurrentInstance()
const { bms_product_effect_status } = useDict('bms_product_effect_status')
const tableRef = ref()
const formRef = ref()
const countryRef = ref()
const surchargeRef = ref()
const importRef = ref()
const countryImportRef = ref()
const importCountryCode = ref('')
const regionOptions = ref([])
const countryImportQuery = computed(() => ({ countryCode: importCountryCode.value }))
const allImportDesc = [
'适用多国家价表(B2C 小包价表等),按目录 sheet 匹配国家导入。',
'请在弹窗底部下载模板,按模板格式整理后上传。相同产品代码+生效日期不覆盖主数据。'
]
const countryImportDesc = [
'选择目的国家后上传专线成本价表,目录中的产品都会记到该国家。',
'邮编、赔偿标准等 sheet 不导入。相同产品代码+生效日期不覆盖主数据,重量段按生效日写入。',
'可在弹窗底部下载模板,按模板格式整理后上传。'
]
const columns = [
{ prop: 'productCode', label: '产品代码', minWidth: 110 },
{ prop: 'productName', label: '产品名称', minWidth: 140, showOverflowTooltip: true },
{ prop: 'serviceLevel', label: '时效等级', width: 90, align: 'center' },
{ prop: 'cargoAttr', label: '走货属性', minWidth: 120, slot: 'cargoAttr' },
{ prop: 'destRegion', label: '目的区域', width: 90, align: 'center' },
// { prop: 'taxMode', label: '税模式', width: 90, align: 'center', dict: 'bms_tax_mode' },
{ prop: 'effectiveDate', label: '生效日期', width: 120, align: 'center' },
{ prop: 'expireDate', label: '失效日期', width: 120, align: 'center' },
{ prop: 'countryCount', label: '国家数', width: 80, align: 'center' },
{ prop: 'surchargeCount', label: '附加费数', width: 90, align: 'center' },
{ prop: 'status', label: '状态', width: 90, align: 'center', slot: 'status' },
{ prop: 'updateNote', label: '更新内容', minWidth: 160, showOverflowTooltip: true },
{ prop: 'action', label: '操作', width: 240, fixed: 'right', slot: 'action' }
]
const searchColumns = [
{ prop: 'productCode', label: '产品代码', component: 'input', placeholder: '产品代码' },
{ prop: 'productName', label: '产品名称', component: 'input', placeholder: '产品名称' }
// {
// prop: 'taxMode',
// label: '税模式',
// component: 'select',
// dict: 'bms_tax_mode',
// placeholder: '税模式',
// clearable: true
// }
]
function queryList(params) {
return listProduct(params)
}
function isProductActive(row) {
return row && String(row.status) === '1'
}
function handleAdd() {
formRef.value.open()
}
function handleUpdate(row) {
formRef.value.open(row)
}
function handleImportCommand(command) {
if (command === 'country') {
handleCountryImport()
return
}
handleImport()
}
function handleImport() {
importRef.value.open()
}
function regionLabel(item) {
const name = item.countryNameCn || item.countryNameEn || ''
const code = item.countryCode2 || ''
return name && code ? name + ' (' + code + ')' : (name || code)
}
function loadRegionOptions() {
if (regionOptions.value.length) return
listRegionOptions().then(res => {
regionOptions.value = res.data || []
})
}
function handleCountryImport() {
importCountryCode.value = ''
loadRegionOptions()
countryImportRef.value.open()
}
function validateCountryImport() {
if (!importCountryCode.value) {
return '请先选择目的国家'
}
return ''
}
</script>
<style scoped>
.mb16 { margin-bottom: 16px; }
</style>