648 lines
25 KiB
Vue
648 lines
25 KiB
Vue
<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"
|
||
scrollbar-always-on
|
||
>
|
||
<template #toolbar="{ selection, ids }">
|
||
<el-col :span="1.5">
|
||
<el-button type="primary" plain icon="Link" :disabled="selection.length !== 1" @click="openBind(selection)" v-hasPermi="['price:pay:bind']">绑定渠道</el-button>
|
||
</el-col>
|
||
<el-col :span="1.5">
|
||
<el-button type="primary" plain icon="Plus" @click="createRef.open()" v-hasPermi="['price:pay:add']">新增价卡</el-button>
|
||
</el-col>
|
||
<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-chargeType="{ row }">
|
||
<span>{{ chargeTypeText(row.chargeType) }}</span>
|
||
</template>
|
||
|
||
<template #col-sourceFile="{ row }">
|
||
<el-button v-if="row.filePath" link type="primary" @click="downloadSource(row)">{{ row.sourceFile }}</el-button>
|
||
<span v-else>{{ row.sourceFile || '-' }}</span>
|
||
</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' : '2'"
|
||
active-value="1"
|
||
inactive-value="2"
|
||
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" @click="surchargeRef.open(row)" v-hasPermi="['price:pay:surcharge']">附加费</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()" />
|
||
<pay-create-dialog ref="createRef" @saved="tableRef.refresh()" />
|
||
<pay-card-surcharge-dialog ref="surchargeRef" @saved="tableRef.refresh()" />
|
||
<el-dialog v-model="bindVisible" title="绑定渠道" width="640px" append-to-body @closed="resetBind">
|
||
<el-form label-width="70px">
|
||
<el-form-item label="产品">
|
||
<el-select v-model="bindForm.productId" disabled style="width: 100%">
|
||
<el-option :label="bindForm.productName" :value="bindForm.productId" />
|
||
</el-select>
|
||
</el-form-item>
|
||
<el-form-item label="渠道">
|
||
<el-select
|
||
v-model="bindForm.channelIds"
|
||
class="bind-channel-select"
|
||
multiple
|
||
filterable
|
||
clearable
|
||
placeholder="输入渠道编码或名称搜索,勾选后显示在框内"
|
||
style="width: 100%"
|
||
>
|
||
<el-option v-for="item in channelOptions" :key="item.id" :label="channelLabel(item)" :value="item.id" />
|
||
</el-select>
|
||
</el-form-item>
|
||
</el-form>
|
||
<template #footer>
|
||
<el-button @click="bindVisible = false">取消</el-button>
|
||
<el-button type="primary" :loading="bindSaving" @click="submitBind">确认</el-button>
|
||
</template>
|
||
</el-dialog>
|
||
<el-drawer v-model="historyVisible" :title="historyTitle" size="980px" append-to-body 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" row-key="termId" 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 label="来源文件" min-width="160" show-overflow-tooltip>
|
||
<template #default="{ row }">
|
||
<el-button v-if="row.filePath" link type="primary" @click="downloadSource(row)">{{ row.sourceFile || '下载源文件' }}</el-button>
|
||
<span v-else>{{ row.sourceFile || '-' }}</span>
|
||
</template>
|
||
</el-table-column>
|
||
<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="220" align="center">
|
||
<template #default="{ row }">
|
||
<el-button link type="primary" @click="downloadSource(row)" v-hasPermi="['price:pay:query']">下载</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 :z-index="4000" destroy-on-close>
|
||
<div class="compare-panel">
|
||
<div v-if="compareReady && !compareLoading" class="history-bar">
|
||
<el-tag type="primary" effect="plain">变更 {{ compareStat.changed }}</el-tag>
|
||
<el-tag type="success" effect="plain">新增 {{ compareStat.added }}</el-tag>
|
||
<el-tag type="danger" effect="plain">删除 {{ compareStat.removed }}</el-tag>
|
||
<el-tag type="info" effect="plain">相同 {{ compareStat.same }}</el-tag>
|
||
</div>
|
||
<el-alert
|
||
v-if="compareReady && !compareLoading && !compareRows.length"
|
||
title="这两版的有效期、重量段和附加费一致"
|
||
type="success"
|
||
:closable="false"
|
||
show-icon
|
||
/>
|
||
<el-table v-show="compareLoading || compareRows.length" v-loading="compareLoading" :data="compareRows" :row-class-name="compareRowClass" border size="small" max-height="640" empty-text="没有差异">
|
||
<el-table-column prop="kind" label="类型" width="100" align="center" />
|
||
<el-table-column label="变化" width="90" align="center">
|
||
<template #default="{ row }">
|
||
<el-tag :type="changeTagType(row.change)" effect="light">{{ row.change }}</el-tag>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column prop="name" label="项目" min-width="180" show-overflow-tooltip />
|
||
<el-table-column prop="zoneName" label="地区" min-width="140" show-overflow-tooltip />
|
||
<el-table-column label="旧版" min-width="200" show-overflow-tooltip>
|
||
<template #default="{ row }">
|
||
<span :class="changeTextClass(row.change, 'old')">{{ row.oldValue || '-' }}</span>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column label="新版" min-width="200" show-overflow-tooltip>
|
||
<template #default="{ row }">
|
||
<span :class="changeTextClass(row.change, 'new')">{{ row.newValue || '-' }}</span>
|
||
</template>
|
||
</el-table-column>
|
||
</el-table>
|
||
</div>
|
||
</el-drawer>
|
||
|
||
<el-drawer
|
||
v-model="detailVisible"
|
||
:title="detailTitle"
|
||
size="78%"
|
||
append-to-body
|
||
:close-on-click-modal="false"
|
||
>
|
||
<pay-config-detail
|
||
v-loading="detailLoading"
|
||
:product="detail"
|
||
:editable="true"
|
||
:saving-row-key="savingRowKey"
|
||
@save-row="saveProductRow"
|
||
/>
|
||
<template #footer>
|
||
<el-button @click="detailVisible = false">关闭</el-button>
|
||
<el-button v-if="detail" @click="downloadSource(detail)" v-hasPermi="['price:pay:query']">下载源文件</el-button>
|
||
</template>
|
||
</el-drawer>
|
||
</div>
|
||
</template>
|
||
|
||
<script setup name="PricePay">
|
||
import { listPay, getPay, delPay, updatePay, listPayTerm, updatePayTerm, changePayTermStatus, comparePay, batchBindChannelPay } from '@/api/price/pay'
|
||
import { listChannelOptions } from '@/api/masterdata/serviceChannel'
|
||
import { useDict } from '@/utils/dict'
|
||
import PayImportDialog from './components/PayImportDialog.vue'
|
||
import PayCreateDialog from './components/PayCreateDialog.vue'
|
||
import PayCardSurchargeDialog from './components/PayCardSurchargeDialog.vue'
|
||
import PayConfigDetail from './components/PayConfigDetail.vue'
|
||
|
||
const { proxy } = getCurrentInstance()
|
||
const { order_charge_type } = useDict('order_charge_type')
|
||
const tableRef = ref()
|
||
const importRef = ref()
|
||
const createRef = ref()
|
||
const surchargeRef = ref()
|
||
const detailVisible = ref(false)
|
||
const detailLoading = ref(false)
|
||
const savingRowKey = ref('')
|
||
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 compareAll = ref([])
|
||
const compareReady = ref(false)
|
||
const compareStat = computed(() => {
|
||
const count = (name) => compareAll.value.filter(row => row.change === name).length
|
||
return { changed: count('变更'), added: count('新增'), removed: count('删除'), same: count('相同') }
|
||
})
|
||
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 bindVisible = ref(false)
|
||
const bindSaving = ref(false)
|
||
const channelOptions = ref([])
|
||
const bindForm = reactive({ productId: null, productName: '', channelIds: [] })
|
||
|
||
const statusOptions = [
|
||
{ label: '已识别', value: 'OK' },
|
||
{ label: '未识别到配置', value: 'EMPTY' },
|
||
{ label: '缺少工作表', value: 'MISSING' }
|
||
]
|
||
|
||
const columns = [
|
||
{ label: '应付价卡名称', prop: 'productName', align: 'center', minWidth: 180, showOverflowTooltip: true, fixed: 'left' },
|
||
{ 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: 340, 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 downloadSource(row) {
|
||
const id = row.versionProductId || row.productId
|
||
if (!id || !row.filePath) {
|
||
proxy.$modal.msgWarning('这一版导入时没有保存源文件,请重新导入后再下载')
|
||
return
|
||
}
|
||
proxy.download('/price/pay/' + id + '/source', {}, row.sourceFile || '价卡.xlsx', {
|
||
timeout: 120000,
|
||
headers: { repeatSubmit: false }
|
||
})
|
||
}
|
||
|
||
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 chargeTypeText(value) {
|
||
const hit = (order_charge_type.value || []).find(item => item.value === value)
|
||
if (hit) return hit.label
|
||
if (value === 'PER_KG') return '常规计费'
|
||
if (value === 'FLAT') return '一口价'
|
||
if (value === 'EXTRA') return '续重价'
|
||
return value || '-'
|
||
}
|
||
|
||
function channelLabel(item) {
|
||
const code = item?.channelCode || ''
|
||
const name = item?.channelName || ''
|
||
return [code, name].filter(Boolean).join(' ')
|
||
}
|
||
|
||
function openBind(selection) {
|
||
if (!selection || selection.length !== 1) return
|
||
const row = selection[0]
|
||
if (!row?.productId) {
|
||
proxy.$modal.msgWarning('这个产品没有编号,不能绑定渠道')
|
||
return
|
||
}
|
||
bindForm.productId = row.productId
|
||
bindForm.productName = row.productName || ''
|
||
bindForm.channelIds = []
|
||
bindVisible.value = true
|
||
if (!channelOptions.value.length) {
|
||
listChannelOptions().then(res => {
|
||
channelOptions.value = res.data || []
|
||
})
|
||
}
|
||
}
|
||
|
||
function resetBind() {
|
||
bindForm.productId = null
|
||
bindForm.productName = ''
|
||
bindForm.channelIds = []
|
||
}
|
||
|
||
function submitBind() {
|
||
if (!bindForm.productId) {
|
||
proxy.$modal.msgWarning('请选择一个应付价卡')
|
||
return
|
||
}
|
||
if (!bindForm.channelIds.length) {
|
||
proxy.$modal.msgWarning('请选择渠道')
|
||
return
|
||
}
|
||
bindSaving.value = true
|
||
batchBindChannelPay({
|
||
channelIds: bindForm.channelIds,
|
||
apProductId: bindForm.productId
|
||
}).then(res => {
|
||
proxy.$modal.msgSuccess(typeof res.data === 'string' ? res.data : (res.msg || '绑定成功'))
|
||
bindVisible.value = false
|
||
}).finally(() => {
|
||
bindSaving.value = false
|
||
})
|
||
}
|
||
|
||
function openDetail(row) {
|
||
detailVisible.value = true
|
||
savingRowKey.value = ''
|
||
detailLoading.value = true
|
||
detail.value = null
|
||
getPay(row.versionProductId || row.productId).then(res => {
|
||
detail.value = res.data
|
||
}).finally(() => {
|
||
detailLoading.value = false
|
||
})
|
||
}
|
||
|
||
async function saveProductRow(payload) {
|
||
if (!detail.value || savingRowKey.value) {
|
||
payload?.done?.(false)
|
||
return
|
||
}
|
||
cleanMoney(detail.value)
|
||
;(detail.value.surcharges || []).forEach(row => {
|
||
if (row.amount === '') row.amount = null
|
||
})
|
||
const productId = detail.value.productId
|
||
savingRowKey.value = payload?.rowKey || 'row'
|
||
let ok = false
|
||
try {
|
||
await updatePay(detail.value)
|
||
ok = true
|
||
proxy.$modal.msgSuccess('该行已保存')
|
||
} catch (e) {
|
||
ok = false
|
||
} finally {
|
||
savingRowKey.value = ''
|
||
payload?.done?.(ok)
|
||
}
|
||
if (!ok || !productId) return
|
||
try {
|
||
const res = await getPay(productId)
|
||
if (res.data) detail.value = res.data
|
||
tableRef.value?.refresh()
|
||
} catch (e) {}
|
||
}
|
||
|
||
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 || '产品'}的价格版本`
|
||
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].sort((a, b) => (Number(a.versionNo) || 0) - (Number(b.versionNo) || 0))
|
||
if (!first.productId || !second.productId) {
|
||
proxy.$modal.msgError('选中的版本没有价格数据')
|
||
return
|
||
}
|
||
compareTitle.value = `第 ${first.versionNo || '-'} 版 对比 第 ${second.versionNo || '-'} 版`
|
||
compareVisible.value = true
|
||
compareLoading.value = true
|
||
compareRows.value = []
|
||
compareAll.value = []
|
||
compareReady.value = false
|
||
comparePay(first.productId, second.productId).then(res => {
|
||
const data = res.data || {}
|
||
const older = data.older?.versionNo
|
||
const newer = data.newer?.versionNo
|
||
if (older && newer) compareTitle.value = `第 ${older} 版 对比 第 ${newer} 版`
|
||
const rows = []
|
||
.concat(markKind(data.versionDiffs, '版本'))
|
||
.concat(markKind(data.weightDiffs, '重量段'))
|
||
.concat(markKind(data.surchargeDiffs, '附加费'))
|
||
.concat(markKind(data.extraDiffs, '其他配置'))
|
||
compareAll.value = rows
|
||
compareRows.value = rows.filter(row => row.change !== '相同')
|
||
compareReady.value = true
|
||
}).finally(() => {
|
||
compareLoading.value = false
|
||
})
|
||
}
|
||
|
||
function markKind(rows, kind) {
|
||
return (rows || []).map(row => ({ ...row, kind: row.kind || kind }))
|
||
}
|
||
|
||
function changeTagType(change) {
|
||
if (change === '变更') return 'primary'
|
||
if (change === '新增') return 'success'
|
||
if (change === '删除') return 'danger'
|
||
return 'info'
|
||
}
|
||
|
||
function compareRowClass({ row }) {
|
||
if (row.change === '变更') return 'compare-changed'
|
||
if (row.change === '新增') return 'compare-added'
|
||
if (row.change === '删除') return 'compare-removed'
|
||
return ''
|
||
}
|
||
|
||
function changeTextClass(change, side) {
|
||
if (change === '变更') return 'compare-text-changed'
|
||
if (change === '删除' && side === 'old') return 'compare-text-removed'
|
||
if (change === '新增' && side === 'new') return 'compare-text-added'
|
||
return ''
|
||
}
|
||
|
||
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) {
|
||
// pay_product_term.status:0待生效 1生效 2已失效;开关只在 生效/已失效 间切换
|
||
if (!row?.termId || (status !== '1' && status !== '2') || row[field] === status) return
|
||
const previous = row[field]
|
||
row[field] = status
|
||
changePayTermStatus({ termId: row.termId, productId: row.productId, status }).then(() => {
|
||
proxy.$modal.msgSuccess(status === '1' ? '已设为生效' : '已设为失效')
|
||
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);
|
||
}
|
||
.compare-text-changed {
|
||
color: var(--el-color-primary);
|
||
font-weight: 600;
|
||
}
|
||
.compare-text-added {
|
||
color: var(--el-color-success);
|
||
font-weight: 600;
|
||
}
|
||
.compare-text-removed {
|
||
color: var(--el-color-danger);
|
||
font-weight: 600;
|
||
}
|
||
.compare-panel :deep(tr.compare-changed > td.el-table__cell) {
|
||
background: var(--el-color-primary-light-9);
|
||
}
|
||
.compare-panel :deep(tr.compare-added > td.el-table__cell) {
|
||
background: var(--el-color-success-light-9);
|
||
}
|
||
.compare-panel :deep(tr.compare-removed > td.el-table__cell) {
|
||
background: var(--el-color-danger-light-9);
|
||
}
|
||
.compare-panel :deep(tr.compare-changed:hover > td.el-table__cell) {
|
||
background: var(--el-color-primary-light-8);
|
||
}
|
||
.compare-panel :deep(tr.compare-added:hover > td.el-table__cell) {
|
||
background: var(--el-color-success-light-8);
|
||
}
|
||
.compare-panel :deep(tr.compare-removed:hover > td.el-table__cell) {
|
||
background: var(--el-color-danger-light-8);
|
||
}
|
||
.bind-channel-select :deep(.el-select__wrapper),
|
||
.bind-channel-select :deep(.el-input__wrapper) {
|
||
min-height: 168px;
|
||
align-items: flex-start;
|
||
padding-top: 8px;
|
||
}
|
||
</style>
|