套餐加分区功能

This commit is contained in:
wuweihua
2026-09-15 14:10:44 +08:00
parent 76208604bb
commit 7679a7d091
26 changed files with 1279 additions and 597 deletions
@@ -0,0 +1,135 @@
<template>
<el-drawer v-model="visible" size="720px" append-to-body>
<template #header>
<div class="drawer-head">
<span class="drawer-title">邮编明细</span>
<span v-if="selectedZone" class="drawer-sub">
{{ selectedZone.zoneName || selectedZone.zoneCode }}
({{ detailTotal }}条)
</span>
</div>
</template>
<div class="drawer-toolbar">
<el-input
v-model="query.postcode"
clearable
placeholder="搜索邮编"
style="width: 200px; margin-right: 8px"
@keyup.enter="loadList"
/>
<el-button type="primary" plain icon="Search" size="small" @click="loadList">搜索</el-button>
<el-button type="primary" plain icon="Plus" size="small" @click="handleAdd" v-hasPermi="['price:zone:add']">新增邮编</el-button>
</div>
<el-table v-loading="loading" :data="list" border row-key="detailId" empty-text="暂无邮编">
<el-table-column label="ID" prop="detailId" align="center" width="90" />
<el-table-column label="邮编" prop="postcode" align="center" min-width="140" />
<el-table-column label="操作" align="center" width="160">
<template #default="{ row }">
<el-button link type="primary" icon="Edit" @click="handleUpdate(row)" v-hasPermi="['price:zone:edit']">编辑</el-button>
<el-button link type="primary" icon="Delete" @click="handleDelete(row.detailId)" v-hasPermi="['price:zone:remove']">删除</el-button>
</template>
</el-table-column>
</el-table>
<div class="drawer-pager">
<el-pagination
v-model:current-page="query.pageNum"
v-model:page-size="query.pageSize"
:total="detailTotal"
:page-sizes="[20, 50, 100, 200]"
layout="total, sizes, prev, pager, next"
@size-change="loadList"
@current-change="loadList"
/>
</div>
<postcode-form-dialog ref="postcodeFormRef" @success="onChanged" />
</el-drawer>
</template>
<script setup name="PostcodeDrawer">
import { listDetail, delDetail } from '@/api/price/zone'
import PostcodeFormDialog from './PostcodeFormDialog.vue'
const { proxy } = getCurrentInstance()
const emit = defineEmits(['changed'])
const visible = ref(false)
const selectedZone = ref(null)
const list = ref([])
const loading = ref(false)
const detailTotal = ref(0)
const query = ref({ pageNum: 1, pageSize: 50, postcode: undefined })
const postcodeFormRef = ref()
function open(zone) {
selectedZone.value = zone
query.value = { pageNum: 1, pageSize: 50, postcode: undefined }
visible.value = true
loadList()
}
function loadList() {
if (!selectedZone.value?.zoneId) {
list.value = []
detailTotal.value = 0
return
}
loading.value = true
listDetail({
zoneId: selectedZone.value.zoneId,
postcode: query.value.postcode || undefined,
pageNum: query.value.pageNum,
pageSize: query.value.pageSize
}).then(res => {
list.value = res.rows || []
detailTotal.value = res.total || 0
}).catch(() => {
list.value = []
detailTotal.value = 0
}).finally(() => {
loading.value = false
})
}
function handleAdd() {
postcodeFormRef.value.open(selectedZone.value)
}
function handleUpdate(row) {
postcodeFormRef.value.open(selectedZone.value, row)
}
/** 邮编增删改后:刷新本列表,并向上通知(分区表需更新邮编数) */
function onChanged() {
loadList()
emit('changed')
}
function handleDelete(detailIds) {
proxy.$modal.confirm('是否确认删除邮编编号为"' + detailIds + '"的数据?').then(() => {
return delDetail(detailIds)
}).then(() => {
proxy.$modal.msgSuccess('删除成功')
onChanged()
}).catch(() => {})
}
defineExpose({ open })
</script>
<style scoped>
.drawer-head {
display: flex;
align-items: center;
gap: 10px;
}
.drawer-title { font-size: 16px; font-weight: 600; }
.drawer-sub { color: #909399; font-size: 13px; }
.drawer-toolbar { margin-bottom: 12px; display: flex; align-items: center; flex-wrap: wrap; gap: 4px; }
.drawer-pager { margin-top: 16px; display: flex; justify-content: flex-end; }
</style>