修改价格套餐样式结构
This commit is contained in:
@@ -0,0 +1,102 @@
|
||||
<template>
|
||||
<set-section-card title="基本信息" tone="blue">
|
||||
<div class="info-grid">
|
||||
<div v-for="item in items" :key="item.label" class="info-item">
|
||||
<div class="info-label">{{ item.label }}</div>
|
||||
<div class="info-value" :class="{ 'is-muted': item.muted }">
|
||||
<el-tag v-if="item.tag" :type="item.tag" size="small" effect="light">{{ item.value }}</el-tag>
|
||||
<span v-else>{{ item.value }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="note-block">
|
||||
<div class="info-label">说明</div>
|
||||
<div class="note-text">{{ set.priceSetNote || '—' }}</div>
|
||||
</div>
|
||||
</set-section-card>
|
||||
</template>
|
||||
|
||||
<script setup name="SetBasicInfoCard">
|
||||
/**
|
||||
* 套餐详情 · 基本信息卡片(纯展示)
|
||||
*/
|
||||
import SetSectionCard from './SetSectionCard.vue'
|
||||
import {
|
||||
formatDateRange,
|
||||
isDiscountType,
|
||||
setStatusLabel,
|
||||
setStatusTagType,
|
||||
setTypeLabel
|
||||
} from '../../utils/priceSet'
|
||||
|
||||
const props = defineProps({
|
||||
/** 套餐详情对象 */
|
||||
set: {
|
||||
type: Object,
|
||||
required: true
|
||||
}
|
||||
})
|
||||
|
||||
const items = computed(() => {
|
||||
const s = props.set
|
||||
const discount = isDiscountType(s.setType)
|
||||
const updater = s.updateBy ? `(${s.updateBy})` : ''
|
||||
return [
|
||||
{ label: '套餐ID', value: s.priceSetCode || '-' },
|
||||
{ label: '套餐名称', value: s.priceSetName || '-' },
|
||||
{ label: '计价类型', value: setTypeLabel(s.setType) },
|
||||
{
|
||||
label: '默认折扣',
|
||||
value: discount ? `${s.defaultDiscount}%` : '不适用(FIXED)',
|
||||
muted: !discount
|
||||
},
|
||||
{ label: '状态', value: setStatusLabel(s), tag: setStatusTagType(s) },
|
||||
{ label: '有效期', value: formatDateRange(s.effectiveDate, s.expireDate) },
|
||||
{ label: '创建人', value: s.createBy || '-' },
|
||||
{ label: '创建时间', value: s.createTime || '-' },
|
||||
{ label: '最后更新', value: (s.updateTime || '-') + ' ' + updater }
|
||||
]
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.info-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||
column-gap: 24px;
|
||||
}
|
||||
.info-item {
|
||||
padding: 10px 0;
|
||||
border-bottom: 1px dashed #ebeef5;
|
||||
}
|
||||
.info-label {
|
||||
font-size: 12px;
|
||||
color: #909399;
|
||||
line-height: 1.5;
|
||||
}
|
||||
.info-value {
|
||||
margin-top: 4px;
|
||||
font-size: 14px;
|
||||
color: #303133;
|
||||
line-height: 1.6;
|
||||
word-break: break-all;
|
||||
}
|
||||
.info-value.is-muted {
|
||||
color: #a8abb2;
|
||||
}
|
||||
.note-block {
|
||||
padding: 12px 0 2px;
|
||||
}
|
||||
.note-text {
|
||||
margin-top: 4px;
|
||||
font-size: 13px;
|
||||
color: #606266;
|
||||
line-height: 1.7;
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
@media (max-width: 992px) {
|
||||
.info-grid {
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,165 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
v-model="visible"
|
||||
:title="title"
|
||||
width="560px"
|
||||
append-to-body
|
||||
class="ps-dialog"
|
||||
>
|
||||
<el-form ref="formRef" :model="form" :rules="rules" label-width="96px">
|
||||
<el-form-item label="客户" prop="customerCode">
|
||||
<customer-select
|
||||
v-model="form.customerCode"
|
||||
value-key="customerCode"
|
||||
placeholder="请选择客户"
|
||||
@change="onCustomerSelectChange"
|
||||
/>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="客户信息">
|
||||
<div class="ps-readonly" :class="{ 'ps-readonly--empty': !form.customerCode }">
|
||||
<span class="ps-readonly__code">{{ form.customerCode || '未选择' }}</span>
|
||||
<span class="ps-readonly__name">{{ form.customerName || '选择客户后自动带出' }}</span>
|
||||
</div>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="优先级" prop="bindPriority">
|
||||
<el-input-number
|
||||
v-model="form.bindPriority"
|
||||
:min="1"
|
||||
controls-position="right"
|
||||
style="width: 100%"
|
||||
/>
|
||||
<div class="ps-hint">数字越小优先级越高,1 为最高;同一客户命中多个套餐时按此排序</div>
|
||||
</el-form-item>
|
||||
|
||||
<el-row :gutter="16">
|
||||
<el-col :span="12">
|
||||
<el-form-item label="生效日期" prop="prBegindate">
|
||||
<el-date-picker
|
||||
v-model="form.prBegindate"
|
||||
type="date"
|
||||
value-format="YYYY-MM-DD"
|
||||
placeholder="选择日期"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="失效日期" prop="prEnddate">
|
||||
<el-date-picker
|
||||
v-model="form.prEnddate"
|
||||
type="date"
|
||||
value-format="YYYY-MM-DD"
|
||||
placeholder="长期有效"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<div class="ps-hint ps-hint--block">{{ bindRangeHint }}</div>
|
||||
</el-form>
|
||||
|
||||
<template #footer>
|
||||
<el-button @click="visible = false">取 消</el-button>
|
||||
<el-button type="primary" :loading="submitting" @click="submit">确 定</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup name="SetCustomerDialog">
|
||||
/**
|
||||
* 套餐绑定客户 · 新增 / 编辑弹窗
|
||||
* 由表格组件通过 ref.open(row) 唤起,保存成功后 emit('success') 通知页面刷新。
|
||||
* 外观统一走 styles/dialog.scss 的 .ps-dialog(见该文件顶部说明)。
|
||||
*/
|
||||
import { createEmptyCustomerRow } from '../../utils/priceSet'
|
||||
import { addSetCustomer, updateSetCustomer } from '@/api/price/set'
|
||||
|
||||
const props = defineProps({
|
||||
/** 所属套餐ID */
|
||||
priceSetId: {
|
||||
type: [Number, String],
|
||||
default: undefined
|
||||
},
|
||||
/** 新行默认生效日期(套餐生效日期) */
|
||||
defaultBegindate: {
|
||||
type: String,
|
||||
default: undefined
|
||||
},
|
||||
/** 新行默认失效日期(套餐失效日期) */
|
||||
defaultEnddate: {
|
||||
type: String,
|
||||
default: undefined
|
||||
}
|
||||
})
|
||||
|
||||
const emit = defineEmits(['success'])
|
||||
|
||||
const { proxy } = getCurrentInstance()
|
||||
|
||||
const visible = ref(false)
|
||||
const title = ref('')
|
||||
const submitting = ref(false)
|
||||
const formRef = ref()
|
||||
const form = ref({})
|
||||
|
||||
const rules = {
|
||||
customerCode: [{ required: true, message: '请选择客户', trigger: 'change' }],
|
||||
prBegindate: [{ required: true, message: '生效日期不能为空', trigger: 'change' }]
|
||||
}
|
||||
|
||||
/** 有效期一句话说明,替掉原来两行零散提示 */
|
||||
const bindRangeHint = computed(() => {
|
||||
const begin = form.value.prBegindate
|
||||
const end = form.value.prEnddate
|
||||
if (!begin) return '生效日期为必填,失效日期留空表示长期有效。'
|
||||
return end
|
||||
? `该客户在 ${begin} 至 ${end} 期间的询价将命中本套餐;失效日期留空表示长期有效。`
|
||||
: `该客户自 ${begin} 起长期命中本套餐;如需限制期限,请填写失效日期。`
|
||||
})
|
||||
|
||||
/** 打开弹窗:row 为空表示新增 */
|
||||
function open(row) {
|
||||
form.value = row
|
||||
? { ...row }
|
||||
: {
|
||||
...createEmptyCustomerRow({
|
||||
effectiveDate: props.defaultBegindate,
|
||||
expireDate: props.defaultEnddate
|
||||
}),
|
||||
priceSetId: props.priceSetId
|
||||
}
|
||||
title.value = row ? '编辑客户绑定' : '添加客户'
|
||||
visible.value = true
|
||||
nextTick(() => formRef.value && formRef.value.clearValidate())
|
||||
}
|
||||
|
||||
/** 下拉选中客户后回填代码 / 名称 / ID */
|
||||
function onCustomerSelectChange(code, item) {
|
||||
form.value.customerCode = code || undefined
|
||||
form.value.customerName = item ? item.customerName : ''
|
||||
form.value.customerId = item ? item.customerId : undefined
|
||||
}
|
||||
|
||||
async function submit() {
|
||||
const valid = await formRef.value.validate().catch(() => false)
|
||||
if (!valid) return
|
||||
const payload = { ...form.value, priceSetId: props.priceSetId }
|
||||
submitting.value = true
|
||||
const req = payload.customerPricesetId ? updateSetCustomer(payload) : addSetCustomer(payload)
|
||||
req.then(() => {
|
||||
proxy.$modal.msgSuccess('保存成功')
|
||||
visible.value = false
|
||||
emit('success')
|
||||
}).finally(() => {
|
||||
submitting.value = false
|
||||
})
|
||||
}
|
||||
|
||||
defineExpose({ open })
|
||||
</script>
|
||||
|
||||
<!-- 非 scoped:弹窗被 append-to-body 传送到 body,样式需全局生效,命名空间见 styles/dialog.scss -->
|
||||
<style lang="scss" src="../../styles/dialog.scss"></style>
|
||||
@@ -0,0 +1,113 @@
|
||||
<template>
|
||||
<set-section-card
|
||||
title="绑定客户"
|
||||
tone="green"
|
||||
:count="customers.length"
|
||||
sub="一个客户只能绑定一个套餐"
|
||||
>
|
||||
<template #action>
|
||||
<el-button
|
||||
v-if="editable"
|
||||
type="primary"
|
||||
size="small"
|
||||
icon="Plus"
|
||||
@click="dialogRef.open()"
|
||||
v-hasPermi="['price:set:edit']"
|
||||
>添加客户</el-button>
|
||||
</template>
|
||||
|
||||
<el-table :data="customers" border class="customer-table" empty-text="暂未绑定客户">
|
||||
<el-table-column label="客户代码" prop="customerCode" min-width="140" show-overflow-tooltip>
|
||||
<template #default="{ row }">
|
||||
<span class="c-code">{{ row.customerCode }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="客户名称" prop="customerName" min-width="160" show-overflow-tooltip />
|
||||
<el-table-column label="优先级" width="130" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-tag v-if="row.bindPriority === 1" size="small" type="success" effect="light">最高</el-tag>
|
||||
<span v-else class="priority">{{ row.bindPriority }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="有效期" min-width="220">
|
||||
<template #default="{ row }">{{ formatDateRange(row.prBegindate, row.prEnddate) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column v-if="editable" label="操作" width="120" align="center" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<el-button link type="primary" @click="dialogRef.open(row)" v-hasPermi="['price:set:edit']">编辑</el-button>
|
||||
<el-button link type="danger" @click="remove(row)" v-hasPermi="['price:set:edit']">解绑</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<div class="table-hint">解绑后该客户可绑定其他套餐;生效中的套餐修改绑定会即时影响计费命中。</div>
|
||||
|
||||
<set-customer-dialog
|
||||
ref="dialogRef"
|
||||
:price-set-id="set.priceSetId"
|
||||
:default-begindate="set.effectiveDate"
|
||||
:default-enddate="set.expireDate"
|
||||
@success="emit('refresh')"
|
||||
/>
|
||||
</set-section-card>
|
||||
</template>
|
||||
|
||||
<script setup name="SetCustomerTable">
|
||||
/**
|
||||
* 套餐详情 · 绑定客户表格
|
||||
* 自带新增 / 编辑弹窗与解绑,数据变更后 emit('refresh') 由页面重新拉取详情。
|
||||
*/
|
||||
import SetSectionCard from './SetSectionCard.vue'
|
||||
import SetCustomerDialog from './SetCustomerDialog.vue'
|
||||
import { formatDateRange, isChildEditable } from '../../utils/priceSet'
|
||||
import { delSetCustomer } from '@/api/price/set'
|
||||
|
||||
const props = defineProps({
|
||||
/** 套餐详情对象 */
|
||||
set: {
|
||||
type: Object,
|
||||
required: true
|
||||
}
|
||||
})
|
||||
|
||||
const emit = defineEmits(['refresh'])
|
||||
|
||||
const { proxy } = getCurrentInstance()
|
||||
|
||||
const dialogRef = ref()
|
||||
|
||||
const customers = computed(() => props.set.customers || [])
|
||||
const editable = computed(() => isChildEditable(props.set.status))
|
||||
|
||||
function remove(row) {
|
||||
proxy.$modal.confirm('确认解绑该客户?').then(() => delSetCustomer(row.customerPricesetId)).then(() => {
|
||||
proxy.$modal.msgSuccess('已解绑')
|
||||
emit('refresh')
|
||||
}).catch(() => {})
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.customer-table {
|
||||
border-radius: 6px;
|
||||
}
|
||||
.customer-table :deep(th.el-table__cell) {
|
||||
background: #fafbfc;
|
||||
color: #606266;
|
||||
font-weight: 600;
|
||||
}
|
||||
.c-code {
|
||||
font-family: Consolas, Monaco, monospace;
|
||||
font-size: 12px;
|
||||
color: #606266;
|
||||
}
|
||||
.priority {
|
||||
color: #303133;
|
||||
}
|
||||
.table-hint {
|
||||
margin-top: 10px;
|
||||
font-size: 12px;
|
||||
color: #909399;
|
||||
line-height: 1.6;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,227 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
v-model="visible"
|
||||
:title="title"
|
||||
width="680px"
|
||||
append-to-body
|
||||
class="ps-dialog"
|
||||
>
|
||||
<el-form ref="formRef" :model="form" :rules="rules" label-width="96px">
|
||||
<el-form-item label="产品" prop="productCode">
|
||||
<el-select
|
||||
v-model="form.productCode"
|
||||
filterable
|
||||
clearable
|
||||
placeholder="选择产品"
|
||||
style="width: 100%"
|
||||
@change="onProductChange(form, setType)"
|
||||
>
|
||||
<el-option v-for="p in productOptions" :key="p.value" :label="p.label" :value="p.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<template v-if="isFixedType(setType)">
|
||||
<el-row :gutter="16">
|
||||
<el-col :span="12">
|
||||
<el-form-item label="国家" prop="countryCode">
|
||||
<el-select
|
||||
v-model="form._countryKey"
|
||||
filterable
|
||||
clearable
|
||||
placeholder="选择国家"
|
||||
style="width: 100%"
|
||||
:disabled="!form.productCode"
|
||||
@change="onCountryChange(form)"
|
||||
>
|
||||
<el-option v-for="c in countryOptions" :key="c.key" :label="c.label" :value="c.key" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="重量段" prop="weightLabel">
|
||||
<el-select
|
||||
v-model="form.weightLabel"
|
||||
filterable
|
||||
clearable
|
||||
placeholder="选择重量段"
|
||||
style="width: 100%"
|
||||
:disabled="!form._countryKey"
|
||||
@change="onWeightChange(form)"
|
||||
>
|
||||
<el-option v-for="w in weightOptions" :key="w.value" :label="w.label" :value="w.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<el-row :gutter="16">
|
||||
<el-col :span="12">
|
||||
<el-form-item label="运费单价" prop="fvValue">
|
||||
<div class="ps-field">
|
||||
<el-input-number
|
||||
v-model="form.fvValue"
|
||||
:min="0"
|
||||
:precision="4"
|
||||
controls-position="right"
|
||||
class="ps-field__input"
|
||||
/>
|
||||
<span class="ps-field__unit">RMB/KG</span>
|
||||
</div>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="挂号费" prop="fvRegistrationFee">
|
||||
<div class="ps-field">
|
||||
<el-input-number
|
||||
v-model="form.fvRegistrationFee"
|
||||
:min="0"
|
||||
:precision="2"
|
||||
controls-position="right"
|
||||
class="ps-field__input"
|
||||
/>
|
||||
<span class="ps-field__unit">RMB/票</span>
|
||||
</div>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<el-form-item label="取值方式" prop="roundMode">
|
||||
<el-select v-model="form.roundMode" placeholder="请选择" style="width: 100%">
|
||||
<el-option v-for="d in bms_round_mode" :key="d.value" :label="d.label" :value="d.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</template>
|
||||
|
||||
<el-row v-else :gutter="16">
|
||||
<el-col :span="12">
|
||||
<el-form-item label="产品折扣" prop="discountValue">
|
||||
<div class="ps-field">
|
||||
<el-input-number
|
||||
v-model="form.discountValue"
|
||||
:min="1"
|
||||
:max="99"
|
||||
controls-position="right"
|
||||
class="ps-field__input"
|
||||
/>
|
||||
<span class="ps-field__unit">%</span>
|
||||
</div>
|
||||
<div class="ps-hint">留空表示使用套餐默认折扣</div>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="取值方式" prop="roundMode">
|
||||
<el-select v-model="form.roundMode" placeholder="请选择" style="width: 100%">
|
||||
<el-option v-for="d in bms_round_mode" :key="d.value" :label="d.label" :value="d.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<el-form-item v-if="form.productCode" label="附加费">
|
||||
<div class="ps-subbox">
|
||||
<div class="ps-subbox__head">
|
||||
产品匹配附加费
|
||||
<span class="ps-subbox__count">{{ surcharges.length }}</span>
|
||||
</div>
|
||||
<surcharge-tags
|
||||
:popover="false"
|
||||
empty-text="该产品暂无匹配附加费"
|
||||
:list="surcharges"
|
||||
/>
|
||||
</div>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<template #footer>
|
||||
<el-button @click="visible = false">取 消</el-button>
|
||||
<el-button type="primary" :loading="submitting" @click="submit">确 定</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup name="SetDetailDialog">
|
||||
/**
|
||||
* 套餐明细 · 新增 / 编辑弹窗
|
||||
* 由表格组件通过 ref.open(row) 唤起,保存成功后 emit('success') 通知页面刷新。
|
||||
* 外观统一走 styles/dialog.scss 的 .ps-dialog(见该文件顶部说明)。
|
||||
*/
|
||||
import SurchargeTags from '../SurchargeTags.vue'
|
||||
import { useDetailCascade } from '../../composables/usePriceSetRefData'
|
||||
import { createEmptyDetailRow, isFixedType, toEditableDetailRow } from '../../utils/priceSet'
|
||||
import { addSetDetail, updateSetDetail } from '@/api/price/set'
|
||||
|
||||
const props = defineProps({
|
||||
/** 所属套餐ID */
|
||||
priceSetId: {
|
||||
type: [Number, String],
|
||||
default: undefined
|
||||
},
|
||||
/** 计价类型 FIXED / DISCOUNT */
|
||||
setType: {
|
||||
type: String,
|
||||
default: 'FIXED'
|
||||
},
|
||||
/** 页面共享的参考数据(usePriceSetRefData 返回值) */
|
||||
refData: {
|
||||
type: Object,
|
||||
required: true
|
||||
}
|
||||
})
|
||||
|
||||
const emit = defineEmits(['success'])
|
||||
|
||||
const { proxy } = getCurrentInstance()
|
||||
const { bms_round_mode } = useDict('bms_round_mode')
|
||||
|
||||
const { productOptions, surchargesOf, countryOptionsOf, weightOptionsOf } = props.refData
|
||||
const { onProductChange, onCountryChange, onWeightChange } = useDetailCascade(props.refData)
|
||||
|
||||
const visible = ref(false)
|
||||
const title = ref('')
|
||||
const submitting = ref(false)
|
||||
const formRef = ref()
|
||||
const form = ref({})
|
||||
|
||||
const rules = {
|
||||
productCode: [{ required: true, message: '请选择产品', trigger: 'change' }],
|
||||
roundMode: [{ required: true, message: '请选择取值方式', trigger: 'change' }]
|
||||
}
|
||||
|
||||
const surcharges = computed(() => surchargesOf(form.value))
|
||||
const countryOptions = computed(() => countryOptionsOf(form.value))
|
||||
const weightOptions = computed(() => weightOptionsOf(form.value))
|
||||
|
||||
/** 打开弹窗:row 为空表示新增 */
|
||||
function open(row) {
|
||||
form.value = row
|
||||
? toEditableDetailRow(row)
|
||||
: { ...createEmptyDetailRow(), priceSetId: props.priceSetId }
|
||||
title.value = row ? '编辑明细' : '添加明细'
|
||||
visible.value = true
|
||||
nextTick(() => formRef.value && formRef.value.clearValidate())
|
||||
if (!form.value.productCode) return
|
||||
props.refData.ensureSurcharges(form.value.productCode)
|
||||
if (isFixedType(props.setType)) props.refData.ensureCountries(form.value.productCode)
|
||||
}
|
||||
|
||||
async function submit() {
|
||||
const valid = await formRef.value.validate().catch(() => false)
|
||||
if (!valid) return
|
||||
const payload = { ...form.value, priceSetId: props.priceSetId }
|
||||
delete payload._countryKey
|
||||
submitting.value = true
|
||||
const req = payload.psdId ? updateSetDetail(payload) : addSetDetail(payload)
|
||||
req.then(() => {
|
||||
proxy.$modal.msgSuccess('保存成功')
|
||||
visible.value = false
|
||||
emit('success')
|
||||
}).finally(() => {
|
||||
submitting.value = false
|
||||
})
|
||||
}
|
||||
|
||||
defineExpose({ open })
|
||||
</script>
|
||||
|
||||
<!-- 非 scoped:弹窗被 append-to-body 传送到 body,样式需全局生效,命名空间见 styles/dialog.scss -->
|
||||
<style lang="scss" src="../../styles/dialog.scss"></style>
|
||||
@@ -0,0 +1,123 @@
|
||||
<template>
|
||||
<div class="set-header">
|
||||
<div class="hd-main">
|
||||
<div class="hd-line">
|
||||
<h2 class="hd-name">{{ set.priceSetName || '套餐详情' }}</h2>
|
||||
<span v-if="set.priceSetCode" class="hd-code">{{ set.priceSetCode }}</span>
|
||||
</div>
|
||||
<div class="hd-line hd-meta">
|
||||
<el-tag :type="statusTagType" size="small" effect="dark">{{ statusText }}</el-tag>
|
||||
<el-tag :type="isFixedType(set.setType) ? 'warning' : 'primary'" size="small" effect="plain">
|
||||
{{ setTypeLabel(set.setType) }}
|
||||
</el-tag>
|
||||
<span class="hd-range">
|
||||
<el-icon class="hd-icon"><Calendar /></el-icon>
|
||||
{{ dateRange }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="hd-actions">
|
||||
<el-button @click="emit('back')">返回列表</el-button>
|
||||
<template v-if="editableStatus">
|
||||
<el-button type="primary" @click="emit('edit')" v-hasPermi="['price:set:edit']">继续配置</el-button>
|
||||
<el-button type="primary" plain @click="emit('submit')" v-hasPermi="['price:set:audit']">提交审核</el-button>
|
||||
</template>
|
||||
<template v-else-if="set.status === 'A'">
|
||||
<el-button type="success" @click="emit('approve')" v-hasPermi="['price:set:audit']">审批生效</el-button>
|
||||
<el-button type="warning" plain @click="emit('reject')" v-hasPermi="['price:set:audit']">驳回</el-button>
|
||||
</template>
|
||||
<el-button
|
||||
v-else-if="set.status === 'E' && !set.expired"
|
||||
type="danger"
|
||||
plain
|
||||
@click="emit('disable')"
|
||||
v-hasPermi="['price:set:audit']"
|
||||
>停用</el-button>
|
||||
<el-button v-else-if="set.status === 'S'" type="primary" plain @click="emit('copy')" v-hasPermi="['price:set:add']">复用新建</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup name="SetDetailHeader">
|
||||
/**
|
||||
* 套餐详情 · 页头
|
||||
* 只负责展示套餐标识 / 状态与派发操作事件,接口调用与确认框由页面处理。
|
||||
*/
|
||||
import { SET_STATUS, formatDateRange, isFixedType, setStatusLabel, setStatusTagType, setTypeLabel } from '../../utils/priceSet'
|
||||
|
||||
const props = defineProps({
|
||||
/** 套餐详情对象 */
|
||||
set: {
|
||||
type: Object,
|
||||
required: true
|
||||
}
|
||||
})
|
||||
|
||||
const emit = defineEmits(['back', 'edit', 'submit', 'approve', 'reject', 'disable', 'copy'])
|
||||
|
||||
const statusText = computed(() => setStatusLabel(props.set))
|
||||
const statusTagType = computed(() => setStatusTagType(props.set))
|
||||
const dateRange = computed(() => formatDateRange(props.set.effectiveDate, props.set.expireDate))
|
||||
const editableStatus = computed(() => [SET_STATUS.DRAFT, SET_STATUS.REJECT].includes(props.set.status))
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.set-header {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
gap: 16px;
|
||||
flex-wrap: wrap;
|
||||
padding: 16px 20px;
|
||||
margin-bottom: 16px;
|
||||
background: #fff;
|
||||
border: 1px solid #ebeef5;
|
||||
border-left: 3px solid #1890ff;
|
||||
border-radius: 8px;
|
||||
}
|
||||
.hd-main {
|
||||
min-width: 0;
|
||||
}
|
||||
.hd-line {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.hd-name {
|
||||
margin: 0;
|
||||
font-size: 18px;
|
||||
font-weight: 600;
|
||||
color: #303133;
|
||||
line-height: 1.4;
|
||||
}
|
||||
.hd-code {
|
||||
font-family: Consolas, Monaco, monospace;
|
||||
font-size: 12px;
|
||||
color: #606266;
|
||||
background: #f4f4f5;
|
||||
border: 1px solid #e9e9eb;
|
||||
border-radius: 4px;
|
||||
padding: 1px 8px;
|
||||
}
|
||||
.hd-meta {
|
||||
margin-top: 10px;
|
||||
}
|
||||
.hd-range {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
font-size: 13px;
|
||||
color: #909399;
|
||||
}
|
||||
.hd-icon {
|
||||
font-size: 14px;
|
||||
}
|
||||
.hd-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,189 @@
|
||||
<template>
|
||||
<set-section-card
|
||||
title="套餐明细"
|
||||
tone="blue"
|
||||
:count="details.length"
|
||||
:sub="subTitle"
|
||||
>
|
||||
<template #action>
|
||||
<el-button
|
||||
v-if="editable"
|
||||
type="primary"
|
||||
size="small"
|
||||
icon="Plus"
|
||||
@click="dialogRef.open()"
|
||||
v-hasPermi="['price:set:edit']"
|
||||
>添加明细</el-button>
|
||||
</template>
|
||||
|
||||
<el-table :data="details" border class="detail-table" empty-text="暂无明细,点击右上角「添加明细」">
|
||||
<el-table-column label="产品" min-width="180">
|
||||
<template #default="{ row }">
|
||||
<div class="cell-product">
|
||||
<span class="p-code">{{ row.productCode }}</span>
|
||||
<span class="p-name">{{ row.productName || '' }}</span>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<template v-if="isFixedType(set.setType)">
|
||||
<el-table-column label="国家" min-width="130">
|
||||
<template #default="{ row }">{{ row.countryName || row.countryCode || '-' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="重量段" prop="weightLabel" min-width="130" />
|
||||
<el-table-column label="运费单价" min-width="130" align="right">
|
||||
<template #default="{ row }">
|
||||
<span class="hl">{{ row.fvValue }}</span>
|
||||
<span class="unit"> RMB/KG</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="挂号费" min-width="120" align="right">
|
||||
<template #default="{ row }">
|
||||
<span class="reg">{{ row.fvRegistrationFee }}</span>
|
||||
<span class="unit"> RMB/票</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</template>
|
||||
|
||||
<el-table-column v-else label="产品折扣" min-width="120" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-tag v-if="row.discountValue == null" size="small" type="info" effect="plain">默认折扣</el-tag>
|
||||
<span v-else class="pct">{{ row.discountValue }}%</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column label="附加费" min-width="220">
|
||||
<template #default="{ row }">
|
||||
<surcharge-tags :list="surchargesOf(row)" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column label="取值方式" min-width="110" align="center">
|
||||
<template #default="{ row }">{{ roundModeLabel(row.roundMode) }}</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column v-if="editable" label="操作" width="120" align="center" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<el-button link type="primary" @click="dialogRef.open(row)" v-hasPermi="['price:set:edit']">编辑</el-button>
|
||||
<el-button link type="danger" @click="remove(row)" v-hasPermi="['price:set:edit']">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<div class="table-hint">{{ hint }}</div>
|
||||
|
||||
<set-detail-dialog
|
||||
ref="dialogRef"
|
||||
:price-set-id="set.priceSetId"
|
||||
:set-type="set.setType"
|
||||
:ref-data="refData"
|
||||
@success="emit('refresh')"
|
||||
/>
|
||||
</set-section-card>
|
||||
</template>
|
||||
|
||||
<script setup name="SetDetailTable">
|
||||
/**
|
||||
* 套餐详情 · 明细表格
|
||||
* 自带新增 / 编辑弹窗与删除,数据变更后 emit('refresh') 由页面重新拉取详情。
|
||||
*/
|
||||
import SetSectionCard from './SetSectionCard.vue'
|
||||
import SetDetailDialog from './SetDetailDialog.vue'
|
||||
import SurchargeTags from '../SurchargeTags.vue'
|
||||
import { isChildEditable, isFixedType } from '../../utils/priceSet'
|
||||
import { delSetDetail } from '@/api/price/set'
|
||||
|
||||
const props = defineProps({
|
||||
/** 套餐详情对象 */
|
||||
set: {
|
||||
type: Object,
|
||||
required: true
|
||||
},
|
||||
/** 页面共享的参考数据(usePriceSetRefData 返回值) */
|
||||
refData: {
|
||||
type: Object,
|
||||
required: true
|
||||
}
|
||||
})
|
||||
|
||||
const emit = defineEmits(['refresh'])
|
||||
|
||||
const { proxy } = getCurrentInstance()
|
||||
const { bms_round_mode } = useDict('bms_round_mode')
|
||||
|
||||
const { surchargesOf } = props.refData
|
||||
|
||||
const dialogRef = ref()
|
||||
|
||||
const details = computed(() => props.set.details || [])
|
||||
const editable = computed(() => isChildEditable(props.set.status))
|
||||
|
||||
const subTitle = computed(() => isFixedType(props.set.setType)
|
||||
? '按 产品 × 国家 × 重量段 覆盖固定价'
|
||||
: '按产品限定折扣,留空走套餐默认折扣')
|
||||
|
||||
const hint = computed(() => isFixedType(props.set.setType)
|
||||
? '运费单价单位 RMB/KG,挂号费单位 RMB/票;附加费来自产品关联配置,此处只读展示。'
|
||||
: '未配置明细时全部在售产品均适用套餐默认折扣。')
|
||||
|
||||
function roundModeLabel(mode) {
|
||||
const hit = (bms_round_mode.value || []).find(d => d.value === mode)
|
||||
return hit ? hit.label : (mode || '四舍五入')
|
||||
}
|
||||
|
||||
function remove(row) {
|
||||
proxy.$modal.confirm('确认删除该明细?').then(() => delSetDetail(row.psdId)).then(() => {
|
||||
proxy.$modal.msgSuccess('已删除')
|
||||
emit('refresh')
|
||||
}).catch(() => {})
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.detail-table {
|
||||
border-radius: 6px;
|
||||
}
|
||||
.detail-table :deep(th.el-table__cell) {
|
||||
background: #fafbfc;
|
||||
color: #606266;
|
||||
font-weight: 600;
|
||||
}
|
||||
.cell-product {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
gap: 6px;
|
||||
}
|
||||
.p-code {
|
||||
font-family: Consolas, Monaco, monospace;
|
||||
font-size: 12px;
|
||||
color: #606266;
|
||||
background: #f4f4f5;
|
||||
border-radius: 3px;
|
||||
padding: 0 6px;
|
||||
}
|
||||
.p-name {
|
||||
color: #303133;
|
||||
}
|
||||
.hl {
|
||||
color: #1890ff;
|
||||
font-weight: 600;
|
||||
}
|
||||
.reg {
|
||||
color: #d48806;
|
||||
font-weight: 600;
|
||||
}
|
||||
.pct {
|
||||
color: #1890ff;
|
||||
font-weight: 600;
|
||||
}
|
||||
.unit {
|
||||
font-size: 12px;
|
||||
color: #909399;
|
||||
}
|
||||
.table-hint {
|
||||
margin-top: 10px;
|
||||
font-size: 12px;
|
||||
color: #909399;
|
||||
line-height: 1.6;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,104 @@
|
||||
<template>
|
||||
<el-card shadow="never" class="sec-card">
|
||||
<template #header>
|
||||
<div class="sec-head">
|
||||
<div class="sec-title">
|
||||
<i class="sec-bar" :class="'is-' + tone" />
|
||||
<span class="sec-text">{{ title }}</span>
|
||||
<el-tag v-if="count !== null" size="small" type="info" effect="plain" round class="sec-count">
|
||||
{{ count }}
|
||||
</el-tag>
|
||||
<span v-if="sub" class="sec-sub">{{ sub }}</span>
|
||||
</div>
|
||||
<div class="sec-extra">
|
||||
<slot name="action" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<slot />
|
||||
</el-card>
|
||||
</template>
|
||||
|
||||
<script setup name="SetSectionCard">
|
||||
/**
|
||||
* 套餐详情 · 通用分区卡片
|
||||
* 统一标题样式(色条 + 标题 + 数量徽标)与右上角操作区。
|
||||
*/
|
||||
defineProps({
|
||||
/** 分区标题 */
|
||||
title: {
|
||||
type: String,
|
||||
required: true
|
||||
},
|
||||
/** 数量徽标,传 null 不显示 */
|
||||
count: {
|
||||
type: Number,
|
||||
default: null
|
||||
},
|
||||
/** 标题右侧补充说明 */
|
||||
sub: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
/** 色条色调 */
|
||||
tone: {
|
||||
type: String,
|
||||
default: 'blue',
|
||||
validator: v => ['blue', 'green', 'orange'].includes(v)
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.sec-card {
|
||||
margin-bottom: 16px;
|
||||
border-radius: 8px;
|
||||
}
|
||||
.sec-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
}
|
||||
.sec-title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
min-width: 0;
|
||||
}
|
||||
.sec-bar {
|
||||
width: 3px;
|
||||
height: 14px;
|
||||
border-radius: 2px;
|
||||
background: #1890ff;
|
||||
flex: none;
|
||||
}
|
||||
.sec-bar.is-green {
|
||||
background: #52c41a;
|
||||
}
|
||||
.sec-bar.is-orange {
|
||||
background: #fa8c16;
|
||||
}
|
||||
.sec-text {
|
||||
font-size: 15px;
|
||||
font-weight: 600;
|
||||
color: #303133;
|
||||
}
|
||||
.sec-count {
|
||||
flex: none;
|
||||
}
|
||||
.sec-sub {
|
||||
font-size: 12px;
|
||||
font-weight: normal;
|
||||
color: #909399;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.sec-extra {
|
||||
flex: none;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user