应付账单初始化
This commit is contained in:
@@ -0,0 +1,396 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<basic-table
|
||||
ref="tableRef"
|
||||
:columns="columns"
|
||||
:search-columns="searchColumns"
|
||||
:query="queryList"
|
||||
:search-per-row="4"
|
||||
search-action-align="right"
|
||||
row-key="productId"
|
||||
>
|
||||
<template #toolbar="{ selection, ids }">
|
||||
<el-col :span="1.5">
|
||||
<el-button type="primary" plain icon="Upload" @click="importRef.open()" v-hasPermi="['price:pay:import']">导入价卡</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="danger" plain icon="Delete" :disabled="!selection.length" @click="handleDelete(ids)" v-hasPermi="['price:pay:remove']">删除</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="warning" plain icon="Download" @click="handleExport" v-hasPermi="['price:pay:export']">导出列表</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="warning" plain icon="Download" @click="handleExportDetail" v-hasPermi="['price:pay:export']">导出明细</el-button>
|
||||
</el-col>
|
||||
</template>
|
||||
|
||||
<template #col-parseStatus="{ row }">
|
||||
<el-tag :type="statusType(row.parseStatus)" size="small">{{ statusText(row.parseStatus) }}</el-tag>
|
||||
</template>
|
||||
|
||||
<template #col-termRange="{ row }">
|
||||
<span>{{ termText(row) }}</span>
|
||||
</template>
|
||||
|
||||
<template #col-termStatus="{ row }">
|
||||
<el-switch
|
||||
v-if="row.termId"
|
||||
:model-value="row.termStatus === '1' ? '1' : '0'"
|
||||
active-value="0"
|
||||
inactive-value="1"
|
||||
inline-prompt
|
||||
active-text="生效"
|
||||
inactive-text="失效"
|
||||
@change="(val) => changeStatus(row, 'termStatus', val)"
|
||||
v-hasPermi="['price:pay:edit']"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<template #col-action="{ row }">
|
||||
<el-button link type="primary" icon="View" @click="openDetail(row)" v-hasPermi="['price:pay:query']">查看</el-button>
|
||||
<el-button link type="primary" icon="Calendar" @click="openTermDialog(row)" v-hasPermi="['price:pay:edit']">有效期</el-button>
|
||||
<el-button link type="primary" icon="Clock" @click="openHistory(row)" v-hasPermi="['price:pay:query']">历史</el-button>
|
||||
<el-button link type="primary" icon="Delete" @click="handleDelete(row.productId)" v-hasPermi="['price:pay:remove']">删除</el-button>
|
||||
</template>
|
||||
</basic-table>
|
||||
|
||||
<pay-import-dialog ref="importRef" @saved="tableRef.refresh()" />
|
||||
|
||||
<el-drawer v-model="historyVisible" :title="historyTitle" size="860px" destroy-on-close>
|
||||
<div class="history-bar">
|
||||
<el-button type="primary" plain :disabled="historyPicked.length !== 2" @click="openCompare">比对所选版本</el-button>
|
||||
<span>勾选两个版本后比对。历史订单按生效时间取价,不看当前开关。</span>
|
||||
</div>
|
||||
<el-table v-loading="historyLoading" :data="historyRows" border size="small" empty-text="还没有价格版本" @selection-change="onHistoryPick">
|
||||
<el-table-column type="selection" width="42" align="center" />
|
||||
<el-table-column prop="versionNo" label="版本" width="70" align="center" />
|
||||
<el-table-column prop="sourceFile" label="来源文件" min-width="160" show-overflow-tooltip />
|
||||
<el-table-column prop="weightCount" label="重量段" width="80" align="center" />
|
||||
<el-table-column prop="surchargeCount" label="附加费" width="80" align="center" />
|
||||
<el-table-column label="生效开始" width="110" align="center">
|
||||
<template #default="{ row }">{{ dayText(row.effectiveStart) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="生效结束" width="110" align="center">
|
||||
<template #default="{ row }">{{ dayText(row.effectiveEnd) || '不限' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="状态" width="100" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-switch
|
||||
v-if="row.termId"
|
||||
:model-value="row.status === '1' ? '1' : '0'"
|
||||
active-value="0"
|
||||
inactive-value="1"
|
||||
inline-prompt
|
||||
active-text="生效"
|
||||
inactive-text="失效"
|
||||
@change="(val) => changeStatus(row, 'status', val)"
|
||||
v-hasPermi="['price:pay:edit']"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="150" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-button link type="primary" @click="openTermDialog(row)" v-hasPermi="['price:pay:edit']">修改有效期</el-button>
|
||||
<el-button link type="primary" @click="openDetail(row)" v-hasPermi="['price:pay:query']">查看</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-drawer>
|
||||
|
||||
<el-dialog v-model="termVisible" title="修改有效期" width="460px" append-to-body>
|
||||
<el-form label-width="90px">
|
||||
<el-form-item label="生效开始" required>
|
||||
<el-date-picker v-model="termForm.effectiveStart" type="date" value-format="YYYY-MM-DD" placeholder="生效开始" style="width: 100%" />
|
||||
</el-form-item>
|
||||
<el-form-item label="生效结束">
|
||||
<el-date-picker v-model="termForm.effectiveEnd" type="date" value-format="YYYY-MM-DD" placeholder="不填表示不限" style="width: 100%" clearable />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="termVisible = false">取消</el-button>
|
||||
<el-button type="primary" :loading="termSaving" @click="saveTerm">保存</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<el-drawer v-model="compareVisible" :title="compareTitle" size="88%" append-to-body destroy-on-close>
|
||||
<el-table v-loading="compareLoading" :data="compareRows" border size="small" max-height="640" empty-text="没有差异">
|
||||
<el-table-column prop="kind" label="类型" width="90" align="center" />
|
||||
<el-table-column prop="change" label="变化" width="80" align="center" />
|
||||
<el-table-column prop="name" label="项目" min-width="160" show-overflow-tooltip />
|
||||
<el-table-column prop="zoneName" label="地区" min-width="140" show-overflow-tooltip />
|
||||
<el-table-column prop="oldValue" label="旧版" min-width="160" show-overflow-tooltip />
|
||||
<el-table-column prop="newValue" label="新版" min-width="160" show-overflow-tooltip />
|
||||
</el-table>
|
||||
</el-drawer>
|
||||
|
||||
<el-drawer v-model="detailVisible" :title="detailTitle" size="78%" destroy-on-close>
|
||||
<pay-config-detail v-loading="detailLoading" :product="detail" :editable="editing" />
|
||||
<template #footer>
|
||||
<el-button v-if="!editing" type="primary" @click="editing = true" v-hasPermi="['price:pay:import']">编辑</el-button>
|
||||
<el-button v-else type="primary" :loading="saving" @click="saveDetail">保存</el-button>
|
||||
<el-button @click="detailVisible = false">关闭</el-button>
|
||||
</template>
|
||||
</el-drawer>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup name="PricePay">
|
||||
import { listPay, getPay, delPay, updatePay, listPayTerm, updatePayTerm, changePayTermStatus, comparePay } from '@/api/price/pay'
|
||||
import PayImportDialog from './components/PayImportDialog.vue'
|
||||
import PayConfigDetail from './components/PayConfigDetail.vue'
|
||||
|
||||
const { proxy } = getCurrentInstance()
|
||||
const tableRef = ref()
|
||||
const importRef = ref()
|
||||
const detailVisible = ref(false)
|
||||
const detailLoading = ref(false)
|
||||
const editing = ref(false)
|
||||
const saving = ref(false)
|
||||
const detail = ref(null)
|
||||
const historyVisible = ref(false)
|
||||
const historyLoading = ref(false)
|
||||
const historyRows = ref([])
|
||||
const historyTitle = ref('价格版本')
|
||||
const historyProductId = ref(null)
|
||||
const historyPicked = ref([])
|
||||
const compareVisible = ref(false)
|
||||
const compareLoading = ref(false)
|
||||
const compareTitle = ref('版本比对')
|
||||
const compareRows = ref([])
|
||||
const detailTitle = computed(() => {
|
||||
if (!detail.value) return '应付配置'
|
||||
const no = detail.value.versionNo ? `第 ${detail.value.versionNo} 版` : ''
|
||||
return `${detail.value.productName || '应付配置'} ${no}`.trim()
|
||||
})
|
||||
const termVisible = ref(false)
|
||||
const termSaving = ref(false)
|
||||
const termForm = reactive({ termId: null, productId: null, effectiveStart: '', effectiveEnd: '' })
|
||||
|
||||
const statusOptions = [
|
||||
{ label: '已识别', value: 'OK' },
|
||||
{ label: '未识别到配置', value: 'EMPTY' },
|
||||
{ label: '缺少工作表', value: 'MISSING' }
|
||||
]
|
||||
|
||||
const columns = [
|
||||
{ label: '产品编号', prop: 'productId', align: 'center', width: 90 },
|
||||
{ label: '产品名称', prop: 'productName', align: 'center', minWidth: 150, showOverflowTooltip: true },
|
||||
{ label: '价卡归属', prop: 'supplierName', align: 'center', width: 100 },
|
||||
{ label: '国家/口岸', prop: 'countryScope', align: 'center', minWidth: 120, showOverflowTooltip: true },
|
||||
{ label: '费用类型', prop: 'chargeType', align: 'center', width: 110 },
|
||||
{ label: '每公斤加价', prop: 'extraPerKg', align: 'center', width: 120 },
|
||||
{ label: '报价工作表', prop: 'sheetName', align: 'center', minWidth: 140, showOverflowTooltip: true },
|
||||
{ label: '关联分区表', prop: 'relatedSheet', align: 'center', minWidth: 140, showOverflowTooltip: true },
|
||||
{ label: '版本', prop: 'versionNo', align: 'center', width: 70 },
|
||||
{ label: '有效期', prop: 'termRange', align: 'center', minWidth: 180, showOverflowTooltip: true },
|
||||
{ label: '状态', prop: 'termStatus', align: 'center', width: 100 },
|
||||
{ label: '币种', prop: 'currency', align: 'center', width: 80 },
|
||||
{ label: '重量段', prop: 'weightCount', align: 'center', width: 80 },
|
||||
{ label: '附加费', prop: 'surchargeCount', align: 'center', width: 80 },
|
||||
{ label: '识别结果', prop: 'parseStatus', align: 'center', width: 120 },
|
||||
{ label: '来源文件', prop: 'sourceFile', align: 'center', minWidth: 180, showOverflowTooltip: true },
|
||||
{ label: '创建时间', prop: 'createTime', align: 'center', width: 160, parseTime: true },
|
||||
{ label: '操作', prop: 'action', align: 'center', width: 280, fixed: 'right', showInToolbar: false }
|
||||
]
|
||||
|
||||
const searchColumns = [
|
||||
{ label: '产品名称', prop: 'productName', component: 'input', placeholder: '产品名称', width: '180px' },
|
||||
{ label: '价卡归属', prop: 'supplierName', component: 'input', placeholder: '威狮、易德、GWE', width: '160px' },
|
||||
{ label: '来源文件', prop: 'sourceFile', component: 'input', placeholder: '文件名', width: '180px' },
|
||||
{ label: '报价工作表', prop: 'sheetName', component: 'input', placeholder: '工作表', width: '160px' },
|
||||
{ label: '国家/口岸', prop: 'countryScope', component: 'input', placeholder: '国家或口岸', width: '160px' },
|
||||
{ label: '服务类型', prop: 'serviceType', component: 'input', placeholder: '服务类型', width: '150px' },
|
||||
{ label: '重量段', prop: 'weightKeyword', component: 'input', placeholder: '重量段、分区或费用项', width: '180px' },
|
||||
{ label: '附加费', prop: 'surchargeName', component: 'input', placeholder: '名称、说明或时效', width: '180px' },
|
||||
{ label: '生效日期', prop: 'effectiveRange', component: 'daterange', width: '280px' },
|
||||
{ label: '识别结果', prop: 'parseStatus', component: 'select', options: statusOptions, placeholder: '全部', width: '150px' }
|
||||
]
|
||||
|
||||
function queryList(params) {
|
||||
return listPay({ ...toQuery(params), templateOnly: true, currentOnly: true })
|
||||
}
|
||||
|
||||
function toQuery(params) {
|
||||
const query = { ...params }
|
||||
if (query.effectiveRange?.length === 2) {
|
||||
query.effectiveBegin = query.effectiveRange[0]
|
||||
query.effectiveEnd = query.effectiveRange[1]
|
||||
}
|
||||
delete query.effectiveRange
|
||||
return query
|
||||
}
|
||||
|
||||
function currentQuery() {
|
||||
const query = toQuery(tableRef.value?.getQueryParams() || {})
|
||||
delete query.pageNum
|
||||
delete query.pageSize
|
||||
query.templateOnly = true
|
||||
query.currentOnly = true
|
||||
return query
|
||||
}
|
||||
|
||||
function handleExport() {
|
||||
proxy.download('/price/pay/export', currentQuery(), `应付配置_${Date.now()}.xlsx`)
|
||||
}
|
||||
|
||||
function handleExportDetail() {
|
||||
proxy.download('/price/pay/exportDetail', currentQuery(), `应付配置明细_${Date.now()}.xlsx`)
|
||||
}
|
||||
|
||||
function handleDelete(ids) {
|
||||
const idText = Array.isArray(ids) ? ids.join(',') : ids
|
||||
if (!idText) return
|
||||
proxy.$modal.confirm('确认删除所选应付产品?重量段和附加费会一起删除。').then(() => {
|
||||
return delPay(idText)
|
||||
}).then(() => {
|
||||
proxy.$modal.msgSuccess('删除成功')
|
||||
tableRef.value.refresh()
|
||||
}).catch(() => {})
|
||||
}
|
||||
|
||||
function openDetail(row) {
|
||||
detailVisible.value = true
|
||||
editing.value = false
|
||||
detailLoading.value = true
|
||||
detail.value = null
|
||||
getPay(row.versionProductId || row.productId).then(res => {
|
||||
detail.value = res.data
|
||||
}).finally(() => {
|
||||
detailLoading.value = false
|
||||
})
|
||||
}
|
||||
|
||||
function saveDetail() {
|
||||
cleanMoney(detail.value)
|
||||
saving.value = true
|
||||
updatePay(detail.value).then(() => {
|
||||
proxy.$modal.msgSuccess('已保存这一版。产品编号不变,绑定该产品的渠道按有效期取价')
|
||||
editing.value = false
|
||||
tableRef.value.refresh()
|
||||
}).finally(() => {
|
||||
saving.value = false
|
||||
})
|
||||
}
|
||||
|
||||
function cleanMoney(product) {
|
||||
;(product?.weightBands || []).forEach(row => {
|
||||
if (row.price === '') row.price = null
|
||||
})
|
||||
}
|
||||
|
||||
function dayText(value) {
|
||||
if (!value) return ''
|
||||
return typeof value === 'string' ? value.slice(0, 10) : proxy.parseTime(value, '{y}-{m}-{d}')
|
||||
}
|
||||
|
||||
function termText(row) {
|
||||
const start = dayText(row.termStart || row.effectiveDate)
|
||||
const end = dayText(row.termEnd)
|
||||
if (!start && !end) return '-'
|
||||
return `${start || '不限'} 至 ${end || '不限'}`
|
||||
}
|
||||
|
||||
function openHistory(row) {
|
||||
historyProductId.value = row.productId
|
||||
historyTitle.value = `${row.productName || '产品'}(编号 ${row.productId})的价格版本`
|
||||
historyPicked.value = []
|
||||
historyVisible.value = true
|
||||
loadHistory()
|
||||
}
|
||||
|
||||
function onHistoryPick(rows) {
|
||||
historyPicked.value = rows || []
|
||||
}
|
||||
|
||||
function openCompare() {
|
||||
if (historyPicked.value.length !== 2) return
|
||||
const [first, second] = historyPicked.value
|
||||
compareVisible.value = true
|
||||
compareLoading.value = true
|
||||
compareRows.value = []
|
||||
comparePay(first.productId, second.productId).then(res => {
|
||||
const data = res.data || {}
|
||||
const older = data.older?.versionNo || '-'
|
||||
const newer = data.newer?.versionNo || '-'
|
||||
compareTitle.value = `第 ${older} 版 对比 第 ${newer} 版`
|
||||
const weights = (data.weightDiffs || []).map(row => ({ ...row, kind: '重量段' }))
|
||||
const fees = (data.surchargeDiffs || []).map(row => ({ ...row, kind: '附加费' }))
|
||||
compareRows.value = weights.concat(fees).filter(row => row.change !== '相同')
|
||||
}).finally(() => {
|
||||
compareLoading.value = false
|
||||
})
|
||||
}
|
||||
|
||||
function loadHistory() {
|
||||
if (!historyProductId.value) return
|
||||
historyLoading.value = true
|
||||
listPayTerm(historyProductId.value).then(res => {
|
||||
historyRows.value = res.data || []
|
||||
}).finally(() => {
|
||||
historyLoading.value = false
|
||||
})
|
||||
}
|
||||
|
||||
function openTermDialog(row) {
|
||||
termForm.termId = row.termId
|
||||
termForm.productId = row.productId
|
||||
termForm.effectiveStart = dayText(row.termStart || row.effectiveStart || row.effectiveDate)
|
||||
termForm.effectiveEnd = dayText(row.termEnd || row.effectiveEnd)
|
||||
termVisible.value = true
|
||||
}
|
||||
|
||||
function saveTerm() {
|
||||
if (!termForm.effectiveStart) {
|
||||
proxy.$modal.msgError('请填写生效开始')
|
||||
return
|
||||
}
|
||||
termSaving.value = true
|
||||
updatePayTerm({
|
||||
termId: termForm.termId,
|
||||
productId: termForm.productId,
|
||||
effectiveStart: termForm.effectiveStart,
|
||||
effectiveEnd: termForm.effectiveEnd || null
|
||||
}).then(() => {
|
||||
proxy.$modal.msgSuccess('有效期已保存')
|
||||
termVisible.value = false
|
||||
tableRef.value.refresh()
|
||||
if (historyVisible.value) loadHistory()
|
||||
}).finally(() => {
|
||||
termSaving.value = false
|
||||
})
|
||||
}
|
||||
|
||||
function changeStatus(row, field, status) {
|
||||
if (!row?.termId || (status !== '0' && status !== '1') || row[field] === status) return
|
||||
const previous = row[field]
|
||||
row[field] = status
|
||||
changePayTermStatus({ termId: row.termId, productId: row.productId, status }).then(() => {
|
||||
proxy.$modal.msgSuccess(status === '0' ? '已设为生效' : '已设为失效')
|
||||
tableRef.value.refresh()
|
||||
if (historyVisible.value) loadHistory()
|
||||
}).catch(() => {
|
||||
row[field] = previous
|
||||
})
|
||||
}
|
||||
|
||||
function statusText(status) {
|
||||
return statusOptions.find(item => item.value === status)?.label || status || '-'
|
||||
}
|
||||
|
||||
function statusType(status) {
|
||||
if (status === 'OK') return 'success'
|
||||
if (status === 'EMPTY') return 'warning'
|
||||
if (status === 'MISSING') return 'danger'
|
||||
return 'info'
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.history-bar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
margin-bottom: 12px;
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user