修改套餐规则
This commit is contained in:
@@ -5,112 +5,38 @@
|
||||
:closable="false"
|
||||
show-icon
|
||||
class="mb16"
|
||||
title="已生效展示当前生效版本产品。待生效、已失效按版本展示;待生效可启动或删除整版。建价请点「新建产品价格」。"
|
||||
:title="alertTitle"
|
||||
/>
|
||||
|
||||
<el-tabs v-model="statusTab" class="catalog-tabs" @tab-change="onTabChange">
|
||||
<el-tab-pane label="已生效" name="effect" />
|
||||
<el-tab-pane label="待生效" name="pending" />
|
||||
<el-tab-pane label="已失效" name="expired" />
|
||||
</el-tabs>
|
||||
|
||||
<div v-show="statusTab === 'effect'">
|
||||
<basic-table
|
||||
ref="tableRef"
|
||||
:extra-params="extraParams"
|
||||
:columns="columns"
|
||||
:search-columns="searchColumns"
|
||||
:query="queryList"
|
||||
row-key="productId"
|
||||
:selection="false"
|
||||
>
|
||||
<template #toolbar>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['price:product:add']">新建产品价格</el-button>
|
||||
</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>
|
||||
</template>
|
||||
</basic-table>
|
||||
</div>
|
||||
|
||||
<div v-show="statusTab === 'pending'">
|
||||
<el-row class="mb12">
|
||||
<el-col :span="1.5">
|
||||
<el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['price:product:add']">新建产品价格</el-button>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-table v-loading="versionLoading" :data="versionRows" border empty-text="暂无待生效版本" @row-click="openVersionProducts">
|
||||
<el-table-column label="版本号" prop="versionNo" width="120" />
|
||||
<el-table-column label="生效时间" prop="effectiveTime" min-width="170" />
|
||||
<el-table-column label="失效时间" prop="expireTime" min-width="170" />
|
||||
<el-table-column label="状态" width="100" align="center">
|
||||
<template #default="{ row }">{{ versionStatusText(row.status) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="产品数" prop="productCount" width="90" align="center" />
|
||||
<el-table-column label="明细行数" prop="detailCount" width="100" align="center" />
|
||||
<el-table-column label="操作" width="360" align="center" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<el-button link type="primary" @click.stop="onEditVersion(row)" v-hasPermi="['price:product:edit']">编辑</el-button>
|
||||
<el-button link type="primary" @click.stop="openVersionProducts(row)">查看产品</el-button>
|
||||
<el-button link type="primary" @click.stop="openExcel(row)" v-hasPermi="['price:product:query']">查看附件</el-button>
|
||||
<el-button link type="success" @click.stop="onStartVersion(row)" v-hasPermi="['price:product:edit']">启动</el-button>
|
||||
<el-button link type="danger" @click.stop="onDeleteVersion(row)" v-hasPermi="['price:product:remove']">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<pagination
|
||||
v-show="versionTotal > 0"
|
||||
:total="versionTotal"
|
||||
v-model:page="versionQuery.pageNum"
|
||||
v-model:limit="versionQuery.pageSize"
|
||||
@pagination="loadVersions"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div v-show="statusTab === 'expired'">
|
||||
<el-table v-loading="versionLoading" :data="versionRows" border empty-text="暂无失效版本" @row-click="openVersionProducts">
|
||||
<el-table-column label="版本号" prop="versionNo" width="120" />
|
||||
<el-table-column label="生效时间" prop="effectiveTime" min-width="170" />
|
||||
<el-table-column label="失效时间" prop="expireTime" min-width="170" />
|
||||
<el-table-column label="状态" width="100" align="center">
|
||||
<template #default="{ row }">{{ versionStatusText(row.status) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="产品数" prop="productCount" width="90" align="center" />
|
||||
<el-table-column label="明细行数" prop="detailCount" width="100" align="center" />
|
||||
<el-table-column label="操作" width="220" align="center" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<el-button link type="primary" @click.stop="openVersionProducts(row)">查看产品</el-button>
|
||||
<el-button link type="primary" @click.stop="openExcel(row)" v-hasPermi="['price:product:query']">查看附件</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<pagination
|
||||
v-show="versionTotal > 0"
|
||||
:total="versionTotal"
|
||||
v-model:page="versionQuery.pageNum"
|
||||
v-model:limit="versionQuery.pageSize"
|
||||
@pagination="loadVersions"
|
||||
/>
|
||||
</div>
|
||||
<catalog-version-table
|
||||
:versions="versionRows"
|
||||
:loading="versionLoading"
|
||||
:removing-psv-id="removingPsvId"
|
||||
:title="verTitle"
|
||||
:create-label="createLabel"
|
||||
create-perm="price:product:add"
|
||||
edit-perm="price:product:edit"
|
||||
remove-perm="price:product:remove"
|
||||
query-perm="price:product:query"
|
||||
@create="handleAdd"
|
||||
@edit="onEditVersion"
|
||||
@view-products="openVersionProducts"
|
||||
@view-attach="openExcel"
|
||||
@activate="onStartVersion"
|
||||
@remove="onDeleteVersion"
|
||||
/>
|
||||
|
||||
<catalog-version-excel-drawer ref="excelRef" :list-fn="listProductVersionExcelFiles" />
|
||||
<product-country-drawer ref="countryRef" />
|
||||
<product-surcharge-drawer ref="surchargeRef" @success="() => tableRef.refresh()" />
|
||||
<catalog-version-products-drawer ref="versionProductsRef" :list-fn="listProduct" @view="(row) => countryRef.open(row)" />
|
||||
<product-surcharge-drawer ref="surchargeRef" />
|
||||
<catalog-version-products-drawer
|
||||
ref="versionProductsRef"
|
||||
:list-fn="listProduct"
|
||||
show-surcharge
|
||||
@view="(row) => countryRef.open(row)"
|
||||
@surcharge="(row) => surchargeRef.open(row)"
|
||||
/>
|
||||
<catalog-activate-dialog ref="activateRef" :load-versions="loadAllVersions" :activate-fn="activateProductVersion" @success="onActivated" />
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -120,53 +46,24 @@ import ProductSurchargeDrawer from './components/ProductSurchargeDrawer.vue'
|
||||
import CatalogVersionProductsDrawer from '../components/CatalogVersionProductsDrawer.vue'
|
||||
import CatalogVersionExcelDrawer from '../components/CatalogVersionExcelDrawer.vue'
|
||||
import CatalogActivateDialog from '../components/CatalogActivateDialog.vue'
|
||||
import CatalogVersionTable from '../components/CatalogVersionTable.vue'
|
||||
import { listProduct, listProductVersions, activateProductVersion, deleteProductVersion, listProductVersionExcelFiles } from '@/api/price/product'
|
||||
|
||||
const { proxy } = getCurrentInstance()
|
||||
const { bms_product_effect_status } = useDict('bms_product_effect_status')
|
||||
|
||||
const statusTab = ref('effect')
|
||||
const extraParams = reactive({ statusGroup: 'effect' })
|
||||
const alertTitle = "按版本管理产品价(与套餐版本一致)。点击版本可查看产品与明细;待生效(含草稿)可编辑、启动或硬删;已生效可软删(上一版自动恢复生效并清空失效时间)。建价请点「新建产品价格」。"
|
||||
const verTitle = '产品价版本'
|
||||
const createLabel = '新建产品价格'
|
||||
|
||||
const versionProductsRef = ref()
|
||||
const activateRef = ref()
|
||||
const versionLoading = ref(false)
|
||||
const removingPsvId = ref(null)
|
||||
const versionRows = ref([])
|
||||
const versionTotal = ref(0)
|
||||
const versionQuery = reactive({ pageNum: 1, pageSize: 10 })
|
||||
const tableRef = ref()
|
||||
const countryRef = ref()
|
||||
const surchargeRef = ref()
|
||||
const excelRef = ref()
|
||||
|
||||
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: 'effectiveDate', label: '生效时间', width: 160, align: 'center' },
|
||||
{ prop: 'expireDate', label: '失效时间', width: 160, 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: 120, fixed: 'right', slot: 'action' }
|
||||
]
|
||||
|
||||
const searchColumns = [
|
||||
{ prop: 'productCode', label: '产品代码', component: 'input', placeholder: '产品代码' },
|
||||
{ prop: 'productName', label: '产品名称', component: 'input', placeholder: '产品名称' }
|
||||
]
|
||||
|
||||
function queryList(params) {
|
||||
const p = { ...(params || {}) }
|
||||
// Exact status search must not be limited by default statusGroup=active.
|
||||
if (p.status != null && p.status !== '') {
|
||||
delete p.statusGroup
|
||||
}
|
||||
return listProduct(p)
|
||||
}
|
||||
|
||||
function handleAdd() {
|
||||
proxy.$router.push({ path: '/price/product-create/index' })
|
||||
}
|
||||
@@ -179,32 +76,10 @@ function openExcel(row) {
|
||||
excelRef.value && excelRef.value.open(row)
|
||||
}
|
||||
|
||||
function onTabChange(name) {
|
||||
if (name === 'pending' || name === 'expired') {
|
||||
versionQuery.pageNum = 1
|
||||
loadVersions()
|
||||
return
|
||||
}
|
||||
extraParams.statusGroup = 'effect'
|
||||
nextTick(() => tableRef.value && tableRef.value.refresh())
|
||||
}
|
||||
|
||||
function versionStatusText(status) {
|
||||
const map = { '0': '草稿', '1': '已生效', '2': '已失效', '3': '待生效' }
|
||||
return map[String(status)] || status || '-'
|
||||
}
|
||||
|
||||
function loadVersions() {
|
||||
versionLoading.value = true
|
||||
const params = {
|
||||
pageNum: versionQuery.pageNum,
|
||||
pageSize: versionQuery.pageSize
|
||||
}
|
||||
if (statusTab.value === 'pending') params.statusGroup = 'pending'
|
||||
else params.status = '2'
|
||||
listProductVersions(params).then(res => {
|
||||
listProductVersions({ pageNum: 1, pageSize: 500 }).then(res => {
|
||||
versionRows.value = res.rows || []
|
||||
versionTotal.value = res.total || 0
|
||||
}).finally(() => { versionLoading.value = false })
|
||||
}
|
||||
|
||||
@@ -230,48 +105,33 @@ function onEditVersion(row) {
|
||||
function onStartVersion(row) {
|
||||
if (row && row.psvId != null) {
|
||||
activateRef.value && activateRef.value.open(row)
|
||||
return
|
||||
}
|
||||
loadAllVersions().then(list => {
|
||||
const pending = (list || []).filter(v => v && (String(v.status) === '0' || String(v.status) === '3'))
|
||||
if (!pending.length) {
|
||||
proxy.$modal.msgWarning('当前没有可启动的待生效版本')
|
||||
return
|
||||
}
|
||||
pending.sort((a, b) => (Number(b.versionSeq) || 0) - (Number(a.versionSeq) || 0))
|
||||
const draft = pending.find(v => String(v.status) === '0')
|
||||
activateRef.value && activateRef.value.open(draft || pending[0])
|
||||
})
|
||||
}
|
||||
|
||||
function onDeleteVersion(row) {
|
||||
if (!row || row.psvId == null) return
|
||||
proxy.$modal.confirm('确认硬删除该待生效版本?版本、产品、明细将从数据库真删除,且不可恢复。').then(() => deleteProductVersion(row.psvId)).then(() => {
|
||||
loadVersions()
|
||||
proxy.$modal.msgSuccess('删除成功')
|
||||
const effect = String(row.status) === '1'
|
||||
const msg = effect ? "确认软删除该已生效版本?版本及产品、明细将标记为已删除(列表不再展示)。" : "确认硬删除该版本?版本、产品、明细将从数据库真删除,且不可恢复。"
|
||||
proxy.$modal.confirm(msg).then(() => {
|
||||
removingPsvId.value = row.psvId
|
||||
proxy.$modal.loading("正在删除,请稍候...")
|
||||
return deleteProductVersion(row.psvId).then(() => {
|
||||
loadVersions()
|
||||
proxy.$modal.msgSuccess("删除成功")
|
||||
}).finally(() => {
|
||||
removingPsvId.value = null
|
||||
proxy.$modal.closeLoading()
|
||||
})
|
||||
}).catch(() => {})
|
||||
}
|
||||
|
||||
function onActivated() {
|
||||
if (statusTab.value === 'pending' || statusTab.value === 'expired') loadVersions()
|
||||
else if (tableRef.value) tableRef.value.refresh()
|
||||
loadVersions()
|
||||
}
|
||||
|
||||
|
||||
onMounted(() => loadVersions())
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.mb16 { margin-bottom: 16px; }
|
||||
.mb12 { margin-bottom: 12px; }
|
||||
.catalog-tabs { margin-bottom: 8px; }
|
||||
.import-progress { padding: 8px 4px 4px; }
|
||||
.import-progress-msg {
|
||||
margin-top: 12px;
|
||||
color: var(--el-text-color-secondary);
|
||||
font-size: 13px;
|
||||
line-height: 1.5;
|
||||
word-break: break-word;
|
||||
max-height: 160px;
|
||||
overflow: auto;
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user