修改导入功能
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -62,7 +62,7 @@
|
||||
<el-icon class="tip-icon"><Info-Filled /></el-icon>
|
||||
<div class="tip-text">
|
||||
仅允许上传 {{ accept }} 格式文件,文件大小不超过 {{ fileSizeMb }} MB。
|
||||
<el-link v-if="templateUrl" type="primary" underline="never" class="template-link" @click="handleDownloadTemplate">下载模板</el-link>
|
||||
<el-link v-if="hasTemplate" type="primary" underline="never" class="template-link" @click="handleDownloadTemplate">下载模板</el-link>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -97,12 +97,18 @@ const props = defineProps({
|
||||
type: String,
|
||||
required: true
|
||||
},
|
||||
// 模板下载接口地址,不传则不显示下载模板链接
|
||||
// 模板下载接口地址(后端接口,走 proxy.download),不传则不显示下载模板链接
|
||||
templateAction: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
// 模板文件名前缀
|
||||
// 静态模板文件地址(public 目录下相对路径,如 /templates/product/xxx.xlsx),
|
||||
// 与 templateAction 二选一,静态地址优先
|
||||
templateUrl: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
// 模板下载文件名(不含扩展名;静态下载时为保存文件名,接口下载时为文件名前缀)
|
||||
templateFileName: {
|
||||
type: String,
|
||||
default: 'template'
|
||||
@@ -181,7 +187,7 @@ const uploadUrl = computed(() => {
|
||||
return import.meta.env.VITE_APP_BASE_API + props.action + '?' + query.toString()
|
||||
})
|
||||
|
||||
const templateUrl = computed(() => !!props.templateAction)
|
||||
const hasTemplate = computed(() => !!(props.templateUrl || props.templateAction))
|
||||
|
||||
// 打开对话框(供父组件通过 ref 调用)
|
||||
function open() {
|
||||
@@ -205,8 +211,17 @@ function handleClose() {
|
||||
uploadRef.value?.clearFiles()
|
||||
}
|
||||
|
||||
// 下载模板
|
||||
// 下载模板:静态文件直接 <a download>,接口走 proxy.download
|
||||
function handleDownloadTemplate() {
|
||||
if (props.templateUrl) {
|
||||
const link = document.createElement('a')
|
||||
link.href = props.templateUrl
|
||||
link.download = props.templateFileName + '.xlsx'
|
||||
document.body.appendChild(link)
|
||||
link.click()
|
||||
document.body.removeChild(link)
|
||||
return
|
||||
}
|
||||
proxy.download(props.templateAction, {}, `${props.templateFileName}_${new Date().getTime()}.xlsx`)
|
||||
}
|
||||
|
||||
|
||||
@@ -37,6 +37,12 @@
|
||||
<el-descriptions-item v-if="detail.logType === 'CREDIT'" label="金额">
|
||||
{{ creditAmountLabel(detail) }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item v-if="detail.logType === 'ARREARS'" label="清除范围">
|
||||
{{ arrearsScopeLabel(detail) }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item v-if="detail.logType === 'ARREARS'" label="清除金额">
|
||||
{{ arrearsAmountLabel(detail) }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item v-if="detail.errorMessage" label="错误信息" :span="2">
|
||||
<span class="err-text">{{ detail.errorMessage }}</span>
|
||||
</el-descriptions-item>
|
||||
@@ -73,7 +79,8 @@ const drawerTitle = ref('ES日志详情')
|
||||
const typeOptions = [
|
||||
{ label: '计费', value: 'BILL' },
|
||||
{ label: '试算', value: 'QUOTE' },
|
||||
{ label: '扣减额度', value: 'CREDIT' }
|
||||
{ label: '扣减额度', value: 'CREDIT' },
|
||||
{ label: '欠费清除', value: 'ARREARS' }
|
||||
]
|
||||
|
||||
const statusOptions = [
|
||||
@@ -125,10 +132,24 @@ function creditAmountLabel(detail) {
|
||||
return String(req.amount) + (req.currency ? (' ' + req.currency) : '')
|
||||
}
|
||||
|
||||
function arrearsScopeLabel(detail) {
|
||||
const req = parseReq(detail)
|
||||
const map = { SUMMARY: '客户汇总', ORDER: '单订单' }
|
||||
return map[req.scope] || req.scope || '-'
|
||||
}
|
||||
|
||||
function arrearsAmountLabel(detail) {
|
||||
const req = parseReq(detail)
|
||||
const amount = req.scope === 'ORDER' ? req.batchAmount : req.amount
|
||||
if (amount == null || amount === '') return '-'
|
||||
return String(amount) + (req.currency ? (' ' + req.currency) : '')
|
||||
}
|
||||
|
||||
function typeTag(type) {
|
||||
if (type === 'BILL') return 'success'
|
||||
if (type === 'QUOTE') return 'warning'
|
||||
if (type === 'CREDIT') return 'danger'
|
||||
if (type === 'ARREARS') return 'primary'
|
||||
return 'info'
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
:closable="false"
|
||||
show-icon
|
||||
class="mb16"
|
||||
title="多国家价表用「导入 Excel」。单国专线成本价用「按国家导入」:先选目的国家,目录里的产品都记到该国。相同产品代码+生效日期不覆盖主数据。"
|
||||
title="多国家价表用「全部导入」。单国专线成本价用「按国家导入」:先选目的国家,目录里的产品都记到该国。相同产品代码+生效日期不覆盖主数据。两种导入均可在弹窗内下载对应模板。"
|
||||
/>
|
||||
|
||||
<basic-table
|
||||
@@ -20,10 +20,17 @@
|
||||
<el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['price:product:add']">新建产品</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="info" plain icon="Upload" @click="handleImport" v-hasPermi="['price:product:import']">导入 Excel</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="info" plain icon="Upload" @click="handleCountryImport" v-hasPermi="['price:product:import']">按国家导入</el-button>
|
||||
<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>
|
||||
|
||||
@@ -51,6 +58,9 @@
|
||||
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
|
||||
@@ -62,6 +72,8 @@
|
||||
: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>
|
||||
@@ -102,9 +114,14 @@ const countryImportRef = ref()
|
||||
const importCountryCode = ref('')
|
||||
const regionOptions = ref([])
|
||||
const countryImportQuery = computed(() => ({ countryCode: importCountryCode.value }))
|
||||
const allImportDesc = [
|
||||
'适用多国家价表(B2C 小包价表等),按目录 sheet 匹配国家导入。',
|
||||
'请在弹窗底部下载模板,按模板格式整理后上传。相同产品代码+生效日期不覆盖主数据。'
|
||||
]
|
||||
const countryImportDesc = [
|
||||
'选择目的国家后上传专线成本价表,目录中的产品都会记到该国家。',
|
||||
'邮编、赔偿标准等 sheet 不导入。相同产品代码+生效日期不覆盖主数据,重量段按生效日写入。'
|
||||
'邮编、赔偿标准等 sheet 不导入。相同产品代码+生效日期不覆盖主数据,重量段按生效日写入。',
|
||||
'可在弹窗底部下载模板,按模板格式整理后上传。'
|
||||
]
|
||||
|
||||
const columns = [
|
||||
@@ -152,6 +169,14 @@ function handleUpdate(row) {
|
||||
formRef.value.open(row)
|
||||
}
|
||||
|
||||
function handleImportCommand(command) {
|
||||
if (command === 'country') {
|
||||
handleCountryImport()
|
||||
return
|
||||
}
|
||||
handleImport()
|
||||
}
|
||||
|
||||
function handleImport() {
|
||||
importRef.value.open()
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@
|
||||
<template #col-payTotal="{ row }">
|
||||
<span class="payable">{{ formatMoney(row.payTotal) }}</span>
|
||||
</template>
|
||||
<template #toolbar="{ selection, ids }">
|
||||
<!-- <template #toolbar="{ selection, ids }">
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="warning"
|
||||
@@ -78,7 +78,7 @@
|
||||
@click="handleUpdateArrears(ids, selection)"
|
||||
>更新欠费状态</el-button>
|
||||
</el-col>
|
||||
</template>
|
||||
</template> -->
|
||||
<template #col-action="{ row }">
|
||||
<el-button link type="primary" icon="View" @click="handleView(row)">查看</el-button>
|
||||
</template>
|
||||
|
||||
Reference in New Issue
Block a user