Files
shanxia2.0/web-admin/src/views/pl/cert-ready/index.vue
T
wuzilongandCursor e8cda33a3c fix(pl): 修复客户品类证件额度选证与回显问题。
优先消耗有到期日的证件,补齐品类产品选择与运输证适用品类回显,避免新规则安排与建档展示失败。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-15 07:13:42 +08:00

384 lines
12 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<template>
<div class="page-container">
<section class="panel">
<div class="panel-top"><h2 class="title-bar-heading">证书齐备</h2></div>
<el-tabs v-model="listMode" class="cert-ready-tabs" @tab-change="onModeChange">
<el-tab-pane label="待标记齐备" name="mark" />
<el-tab-pane label="已标记待完善证书" name="fulfill" />
</el-tabs>
<div class="list-toolbar">
<div class="list-toolbar-row">
<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="listMode === 'fulfill'" @click="goUploadCert('purchase')">
<el-icon><Upload /></el-icon>上传购买证
</el-button>
<el-button v-if="listMode === 'fulfill'" @click="goUploadCert('transport')">
<el-icon><Upload /></el-icon>上传运输证
</el-button>
<el-button v-if="keyword || hasActiveFilters" @click="reset">
<el-icon><RefreshLeft /></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">
<div ref="tableWrapRef" class="table-scroll">
<ListTable
ref="tableRef"
v-loading="loading"
:height="tableHeight"
table-key="pl-cert-ready"
:data="rows"
row-key="id"
stripe
class="list-table"
@selection-change="onSelectionChange"
>
<el-table-column
v-for="column in columns"
:key="column.prop"
:prop="column.prop"
:label="column.label"
:min-width="column.minWidth"
>
<template #header>
<div class="col-header-with-filter">
<span class="col-header-with-filter__label">{{ column.label }}</span>
<ColumnHeaderFilter
:prop="column.prop"
:label="column.label"
:type="column.type"
:enable-sort="false"
:options="column.enumOptions || []"
:model-value="filters[column.prop] || null"
:is-active="isFilterActive(column.prop)"
@update:model-value="(value) => setFilterState(column.prop, value)"
/>
</div>
</template>
<template #default="{ row }">
<el-tag
v-if="column.prop === 'followStatus'"
size="small"
:type="getPlPlanFollowStatusTagType(row.followStatus)"
>
{{ getPlPlanFollowStatusLabel(row.followStatus) }}
</el-tag>
<el-tag
v-else-if="column.prop === 'quotaCertWaived'"
size="small"
:type="row.quotaCertWaived ? 'success' : 'warning'"
>
{{ row.quotaCertWaived ? '已齐备' : '未齐备' }}
</el-tag>
<span v-else-if="column.prop === 'quotaCertWaivedTime'">{{
formatCertReadyTime(row.quotaCertWaivedTime)
}}</span>
<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 }">
<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>
</div>
<div ref="pagerRef" class="pagination list-pager-bar">
<el-pagination
v-model:current-page="page"
:page-size="20"
:total="total"
layout="total, prev, pager, next"
@current-change="load"
/>
</div>
</div>
</section>
</div>
</template>
<script setup lang="ts">
import { certReadyApi, type CertReadyPlan } from '@/api/pl/quota-cert'
import ColumnHeaderFilter from '@/components/business/column-header-filter/index.vue'
import ListQuickSearchInput from '@/components/business/list-quick-search-input/index.vue'
import { useListTableViewportHeight } from '@/composables/useListTableViewportHeight'
import { useServerColumnFilters } from '@/composables/useServerColumnFilters'
import type { ColumnFilterDef } from '@/composables/useClientColumnFilters'
import { certReadyDefaultPlanDates } from '@/utils/cert-ready-plan-date'
import { certReadyErrorText, formatCertReadyTime } from '@/utils/pl-quota-cert-waiver'
import {
PL_PLAN_CERT_READY_DEFAULT_FOLLOW_STATUSES,
PL_PLAN_FOLLOW_STATUS_OPTIONS,
getPlPlanFollowStatusLabel,
getPlPlanFollowStatusTagType
} from '@/utils/pl-display'
import { CircleCheck, Refresh, RefreshLeft, Upload } from '@element-plus/icons-vue'
const router = useRouter()
function goUploadCert(kind: 'purchase' | 'transport') {
void router.push({
path: '/pl/cert-upload/quota-cert',
query: { kind, create: '1' }
})
}
const keyword = ref('')
const page = ref(1)
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()
const columns: (ColumnFilterDef & { minWidth: number })[] = [
{ prop: 'planNo', label: '计划编号', type: 'text', queryKey: 'planNo', minWidth: 160 },
{
prop: 'planDate',
label: '计划日期',
type: 'datetime',
queryKeyFrom: 'planDateFrom',
queryKeyTo: 'planDateTo',
minWidth: 140
},
{ prop: 'licensePlate', label: '车号', type: 'text', queryKey: 'licensePlate', minWidth: 120 },
{
prop: 'productNames',
label: '易制毒产品',
type: 'text',
queryKey: 'productNames',
minWidth: 180
},
{ prop: 'supplierName', label: '供方', type: 'text', queryKey: 'supplierName', minWidth: 160 },
{ prop: 'customerName', label: '需方', type: 'text', queryKey: 'customerName', minWidth: 160 },
{
prop: 'followStatus',
label: '跟进状态',
type: 'enum',
queryKey: 'followStatus',
enumOptions: PL_PLAN_FOLLOW_STATUS_OPTIONS.filter((item) => item.value !== 'cancelled').map(
(item) => ({ value: item.value, label: item.label })
),
minWidth: 120
},
{
prop: 'quotaCertWaived',
label: '证书齐备',
type: 'enum',
queryKey: 'quotaCertWaived',
enumOptions: [
{ value: '0', label: '未齐备' },
{ value: '1', label: '已齐备' }
],
minWidth: 120
},
{
prop: 'quotaCertWaivedByName',
label: '确认人',
type: 'text',
queryKey: 'quotaCertWaivedByName',
minWidth: 120
},
{
prop: 'quotaCertWaivedTime',
label: '确认时间',
type: 'datetime',
queryKeyFrom: 'quotaCertWaivedTimeFrom',
queryKeyTo: 'quotaCertWaivedTimeTo',
minWidth: 170
}
]
const {
filters,
hasActiveFilters,
setFilterState,
clearAllFilters,
isFilterActive,
toQueryParams
} = useServerColumnFilters(columns, {
initialFilters: {
quotaCertWaived: { text: '', selected: ['0'] },
followStatus: { text: '', selected: [...PL_PLAN_CERT_READY_DEFAULT_FOLLOW_STATUSES] },
planDate: { from: defaultPlanDates.from, to: defaultPlanDates.to }
},
onChange: search
})
async function load() {
const current = ++epoch
loading.value = true
selectedIds.value = []
try {
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
} catch (error) {
if (current === epoch) ElMessage.error(certReadyErrorText(error, '证书齐备列表加载失败'))
} finally {
if (current === epoch) loading.value = false
}
}
function search() {
page.value = 1
void load()
}
function onModeChange() {
page.value = 1
selectedIds.value = []
void load()
}
function reset() {
keyword.value = ''
if (hasActiveFilters.value) clearAllFilters()
else search()
}
async function mark(row: CertReadyPlan) {
try {
await ElMessageBox.confirm(
'确认后可先安排运输;新规则下归档前仍须到「已标记待完善证书」页上传证件并执行完善并关闭。确认人和时间会记在本行。',
'标记齐备',
{ type: 'warning', confirmButtonText: '确认标记', cancelButtonText: '取消' }
)
} catch {
return
}
markingId.value = row.id
try {
await certReadyApi.mark(row.id)
ElMessage.success('已标记证书齐备')
await load()
} catch (error) {
ElMessage.error(certReadyErrorText(error, '标记证书齐备失败'))
} finally {
markingId.value = ''
}
}
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()
const { tableHeight } = useListTableViewportHeight({
tableEl: tableWrapRef,
pagerEl: pagerRef,
tableRef,
enabled: computed(() => true)
})
onMounted(() => {
void load()
})
</script>
<style scoped lang="scss">
.cert-ready-tabs {
margin: 0 0 4px;
padding: 0 24px;
:deep(> .el-tabs__header) {
margin-bottom: 0;
}
:deep(> .el-tabs__content) {
display: none;
}
}
</style>