feat(pl): 购买证运输证改为客户品类额度并支持齐备完善。
按客户与证用品类自动选证,未配置生效时间拦住安排;齐备仅放行安排,归档前须完善挂证,并补充迁移与测试造数脚本。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
aad74505c0
commit
cd94ebc56d
31 files changed
+2835
-39
No files matched your search
@@ -0,0 +1,190 @@
|
||||
<!-- 证用品类 — P01 标准列表;与 CRM 分类独立 -->
|
||||
<template>
|
||||
<div class="page-container">
|
||||
<section class="panel">
|
||||
<div class="panel-top">
|
||||
<h2 class="title-bar-heading">证用品类</h2>
|
||||
</div>
|
||||
<div class="list-toolbar">
|
||||
<div class="list-toolbar-row">
|
||||
<ListQuickSearchInput
|
||||
v-model="keyword"
|
||||
placeholder="品类名称"
|
||||
@search="search"
|
||||
@clear="search"
|
||||
/>
|
||||
<el-button type="primary" @click="openEdit()">
|
||||
<el-icon><Plus /></el-icon>新增品类
|
||||
</el-button>
|
||||
<el-button :loading="loading" @click="load">
|
||||
<el-icon><Refresh /></el-icon>刷新
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="list-body list-wrap">
|
||||
<ListTable
|
||||
v-loading="loading"
|
||||
table-key="pl-cert-category"
|
||||
class="list-table"
|
||||
:data="rows"
|
||||
stripe
|
||||
row-key="id"
|
||||
>
|
||||
<el-table-column prop="categoryName" label="品类名称" min-width="160" />
|
||||
<el-table-column prop="categoryCode" label="编码" min-width="120">
|
||||
<template #default="{ row }">{{ row.categoryCode || '—' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="status" label="状态" min-width="100">
|
||||
<template #default="{ row }">
|
||||
<el-tag size="small" :type="row.status === '1' ? 'success' : 'info'">
|
||||
{{ row.status === '1' ? '启用' : '停用' }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" min-width="200" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<el-button link type="primary" @click="openEdit(row)">编辑</el-button>
|
||||
<el-button link type="danger" @click="remove(row)">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</ListTable>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<el-dialog
|
||||
v-model="visible"
|
||||
class="dialog-form-layout"
|
||||
:title="editingId ? '编辑证用品类' : '新增证用品类'"
|
||||
width="640px"
|
||||
align-center
|
||||
destroy-on-close
|
||||
>
|
||||
<el-form label-position="top">
|
||||
<div class="form-grid-2">
|
||||
<el-form-item label="品类名称" required>
|
||||
<el-input v-model="form.categoryName" maxlength="128" />
|
||||
</el-form-item>
|
||||
<el-form-item label="编码">
|
||||
<el-input v-model="form.categoryCode" maxlength="64" />
|
||||
</el-form-item>
|
||||
<el-form-item label="状态">
|
||||
<el-select v-model="form.status" class="w-full">
|
||||
<el-option label="启用" value="1" />
|
||||
<el-option label="停用" value="0" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</div>
|
||||
<el-form-item label="关联系统产品(产品 ID,逗号分隔,保存后按差量写入)">
|
||||
<el-input
|
||||
v-model="productIdsText"
|
||||
type="textarea"
|
||||
:rows="3"
|
||||
placeholder="例如:uuid1,uuid2(上线后可改产品选择器)"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="visible = false">
|
||||
<el-icon><Close /></el-icon>取消
|
||||
</el-button>
|
||||
<el-button type="primary" :loading="saving" @click="save">
|
||||
<el-icon><Check /></el-icon>确定
|
||||
</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { certCategoryApi, type CertCategory } from '@/api/pl/quota-cert'
|
||||
import ListQuickSearchInput from '@/components/business/list-quick-search-input/index.vue'
|
||||
import { Check, Close, Plus, Refresh } from '@element-plus/icons-vue'
|
||||
|
||||
const keyword = ref('')
|
||||
const loading = ref(false)
|
||||
const saving = ref(false)
|
||||
const rows = ref<CertCategory[]>([])
|
||||
const visible = ref(false)
|
||||
const editingId = ref('')
|
||||
const form = reactive({ categoryName: '', categoryCode: '', status: '1' })
|
||||
const productIdsText = ref('')
|
||||
|
||||
async function load() {
|
||||
loading.value = true
|
||||
try {
|
||||
rows.value = (await certCategoryApi.list({ keyword: keyword.value || undefined })) || []
|
||||
} catch (error: any) {
|
||||
ElMessage.error(error?.message || '加载失败')
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function search() {
|
||||
void load()
|
||||
}
|
||||
|
||||
async function openEdit(row?: CertCategory) {
|
||||
editingId.value = row?.id || ''
|
||||
form.categoryName = row?.categoryName || ''
|
||||
form.categoryCode = row?.categoryCode || ''
|
||||
form.status = row?.status || '1'
|
||||
productIdsText.value = ''
|
||||
if (row?.id) {
|
||||
const detail = await certCategoryApi.get(row.id)
|
||||
productIdsText.value = (detail.products || [])
|
||||
.filter((p) => p.scopeStatus !== 'inactive')
|
||||
.map((p) => p.productId)
|
||||
.join(',')
|
||||
}
|
||||
visible.value = true
|
||||
}
|
||||
|
||||
async function save() {
|
||||
if (!form.categoryName.trim()) {
|
||||
ElMessage.warning('请填写品类名称')
|
||||
return
|
||||
}
|
||||
const productIds = productIdsText.value
|
||||
.split(/[,,\s]+/)
|
||||
.map((s) => s.trim())
|
||||
.filter(Boolean)
|
||||
const body = {
|
||||
categoryName: form.categoryName.trim(),
|
||||
categoryCode: form.categoryCode || null,
|
||||
status: form.status,
|
||||
products: productIds.map((productId) => ({ productId, scopeStatus: 'active' }))
|
||||
}
|
||||
saving.value = true
|
||||
try {
|
||||
if (editingId.value) await certCategoryApi.update(editingId.value, body)
|
||||
else await certCategoryApi.create(body)
|
||||
ElMessage.success('已保存')
|
||||
visible.value = false
|
||||
await load()
|
||||
} catch (error: any) {
|
||||
ElMessage.error(error?.message || '保存失败')
|
||||
} finally {
|
||||
saving.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function remove(row: CertCategory) {
|
||||
try {
|
||||
await ElMessageBox.confirm(`确认删除品类「${row.categoryName}」?`, '删除', { type: 'warning' })
|
||||
} catch {
|
||||
return
|
||||
}
|
||||
try {
|
||||
await certCategoryApi.remove(row.id)
|
||||
ElMessage.success('已删除')
|
||||
await load()
|
||||
} catch (error: any) {
|
||||
ElMessage.error(error?.message || '删除失败')
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
void load()
|
||||
})
|
||||
</script>
|
||||
@@ -4,12 +4,25 @@
|
||||
<div class="panel-top"><h2 class="title-bar-heading">证书齐备</h2></div>
|
||||
<div class="list-toolbar">
|
||||
<div class="list-toolbar-row">
|
||||
<el-radio-group v-model="listMode" class="mr-3" @change="onModeChange">
|
||||
<el-radio-button value="mark">标记齐备</el-radio-button>
|
||||
<el-radio-button value="fulfill">待完善并关闭</el-radio-button>
|
||||
</el-radio-group>
|
||||
<ListQuickSearchInput
|
||||
v-model="keyword"
|
||||
placeholder="计划编号"
|
||||
@search="search"
|
||||
@clear="search"
|
||||
/>
|
||||
<el-button
|
||||
v-if="listMode === 'fulfill'"
|
||||
type="primary"
|
||||
:disabled="!selectedIds.length"
|
||||
:loading="batching"
|
||||
@click="fulfillBatch"
|
||||
>
|
||||
<el-icon><CircleCheck /></el-icon>批量完善并关闭
|
||||
</el-button>
|
||||
<el-button v-if="keyword || hasActiveFilters" @click="reset">
|
||||
<el-icon><RefreshLeft /></el-icon>清除筛选
|
||||
</el-button>
|
||||
@@ -29,6 +42,7 @@
|
||||
row-key="id"
|
||||
stripe
|
||||
class="list-table"
|
||||
@selection-change="onSelectionChange"
|
||||
>
|
||||
<el-table-column
|
||||
v-for="column in columns"
|
||||
@@ -73,17 +87,34 @@
|
||||
<span v-else>{{ row[column.prop] || '—' }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
v-if="listMode === 'fulfill'"
|
||||
type="selection"
|
||||
width="48"
|
||||
:reserve-selection="false"
|
||||
/>
|
||||
<el-table-column label="操作" min-width="260" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<el-button
|
||||
v-if="!row.quotaCertWaived"
|
||||
type="primary"
|
||||
:loading="markingId === row.id"
|
||||
@click="mark(row)"
|
||||
>
|
||||
<el-icon><CircleCheck /></el-icon>证书齐备
|
||||
</el-button>
|
||||
<span v-else>已确认</span>
|
||||
<template v-if="listMode === 'fulfill'">
|
||||
<el-button
|
||||
type="primary"
|
||||
:loading="markingId === row.id"
|
||||
@click="fulfillOne(row)"
|
||||
>
|
||||
<el-icon><CircleCheck /></el-icon>完善并关闭
|
||||
</el-button>
|
||||
</template>
|
||||
<template v-else>
|
||||
<el-button
|
||||
v-if="!row.quotaCertWaived"
|
||||
type="primary"
|
||||
:loading="markingId === row.id"
|
||||
@click="mark(row)"
|
||||
>
|
||||
<el-icon><CircleCheck /></el-icon>证书齐备
|
||||
</el-button>
|
||||
<span v-else>已确认</span>
|
||||
</template>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</ListTable>
|
||||
@@ -124,6 +155,9 @@
|
||||
const total = ref(0)
|
||||
const loading = ref(false)
|
||||
const markingId = ref('')
|
||||
const batching = ref(false)
|
||||
const listMode = ref<'mark' | 'fulfill'>('mark')
|
||||
const selectedIds = ref<string[]>([])
|
||||
const rows = ref<CertReadyPlan[]>([])
|
||||
let epoch = 0
|
||||
const defaultPlanDates = certReadyDefaultPlanDates()
|
||||
@@ -203,13 +237,21 @@
|
||||
async function load() {
|
||||
const current = ++epoch
|
||||
loading.value = true
|
||||
selectedIds.value = []
|
||||
try {
|
||||
const value = await certReadyApi.list({
|
||||
keyword: keyword.value || undefined,
|
||||
page: page.value,
|
||||
pageSize: 20,
|
||||
...toQueryParams()
|
||||
})
|
||||
const value =
|
||||
listMode.value === 'fulfill'
|
||||
? await certReadyApi.listPendingFulfill({
|
||||
keyword: keyword.value || undefined,
|
||||
page: page.value,
|
||||
pageSize: 20
|
||||
})
|
||||
: await certReadyApi.list({
|
||||
keyword: keyword.value || undefined,
|
||||
page: page.value,
|
||||
pageSize: 20,
|
||||
...toQueryParams()
|
||||
})
|
||||
if (current !== epoch) return
|
||||
rows.value = value?.list || []
|
||||
total.value = value?.total || 0
|
||||
@@ -225,6 +267,11 @@
|
||||
void load()
|
||||
}
|
||||
|
||||
function onModeChange() {
|
||||
page.value = 1
|
||||
void load()
|
||||
}
|
||||
|
||||
function reset() {
|
||||
keyword.value = ''
|
||||
if (hasActiveFilters.value) clearAllFilters()
|
||||
@@ -234,7 +281,7 @@
|
||||
async function mark(row: CertReadyPlan) {
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
'确认后,这条运输计划在安排和归档时都不再校验购买证、运输证,也不扣减额度。确认人和时间会记在本行。',
|
||||
'确认后可先安排运输;新规则下归档前仍须在「待完善并关闭」中挂上购买证/运输证。确认人和时间会记在本行。',
|
||||
'证书齐备',
|
||||
{ type: 'warning', confirmButtonText: '确认齐备', cancelButtonText: '取消' }
|
||||
)
|
||||
@@ -253,6 +300,42 @@
|
||||
}
|
||||
}
|
||||
|
||||
async function fulfillOne(row: CertReadyPlan) {
|
||||
markingId.value = row.id
|
||||
try {
|
||||
await certReadyApi.fulfill(row.id)
|
||||
ElMessage.success('已完善并关闭')
|
||||
await load()
|
||||
} catch (error) {
|
||||
ElMessage.error(certReadyErrorText(error, '完善并关闭失败'))
|
||||
} finally {
|
||||
markingId.value = ''
|
||||
}
|
||||
}
|
||||
|
||||
function onSelectionChange(selection: CertReadyPlan[]) {
|
||||
selectedIds.value = selection.map((row) => row.id)
|
||||
}
|
||||
|
||||
async function fulfillBatch() {
|
||||
if (!selectedIds.value.length) return
|
||||
batching.value = true
|
||||
try {
|
||||
const res = await certReadyApi.fulfillBatch(selectedIds.value)
|
||||
const failed = (res?.results || []).filter((r) => !r.ok)
|
||||
if (failed.length) {
|
||||
ElMessage.warning(`部分失败:${failed.map((f) => f.message || f.planId).join(';')}`)
|
||||
} else {
|
||||
ElMessage.success('批量完善完成')
|
||||
}
|
||||
await load()
|
||||
} catch (error) {
|
||||
ElMessage.error(certReadyErrorText(error, '批量完善失败'))
|
||||
} finally {
|
||||
batching.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const tableWrapRef = ref<HTMLElement | null>(null)
|
||||
const pagerRef = ref<HTMLElement | null>(null)
|
||||
const tableRef = ref()
|
||||
|
||||
Reference in new issue
Block a user