补齐证书齐备、证件折算、移动用证和合同绑定,并带上报销批量发放、付款备注以及个人开发流程升级,便于继续讨论已安排计划的调整规则。 Co-authored-by: Cursor <cursoragent@cursor.com>
162 lines
6.1 KiB
Vue
162 lines
6.1 KiB
Vue
<template>
|
|
<main class="mp-h5-list-content mp-plan-cert-list">
|
|
<p v-if="error" class="mp-wv-empty" role="alert">
|
|
{{ error }}
|
|
<button class="mp-wv-btn" type="button" @click="reload">重试</button>
|
|
</p>
|
|
<div v-else-if="authReady && !allowed" class="mp-wv-empty">
|
|
<div class="mp-wv-empty__title">无证件查看权限</div>
|
|
</div>
|
|
<van-list v-else v-model:loading="loading" :finished="finished" finished-text="" @load="load">
|
|
<article
|
|
v-for="row in rows"
|
|
:key="row.certType + row.certId"
|
|
class="mp-wv-card mp-wv-flat-card"
|
|
@click="open(row)"
|
|
>
|
|
<div class="mp-wv-card__head">
|
|
<div>
|
|
<div class="mp-wv-card__no">{{ row.certNo }}</div>
|
|
<div class="mp-wv-card__sub">{{ row.certType === 'transport' ? '运输证' : '购买证' }}</div>
|
|
</div>
|
|
<span class="status-tag" :class="`status-tag--${row.status === 'active' ? 'success' : 'info'}`">
|
|
{{ certListStatus(row.status) }}
|
|
</span>
|
|
</div>
|
|
<div class="mp-wv-card__kv">
|
|
<div class="mp-wv-card__kv-row"><span>销售单位</span><span>{{ row.salePartyName || '—' }}</span></div>
|
|
<div class="mp-wv-card__kv-row"><span>购买单位</span><span>{{ row.buyPartyName || '—' }}</span></div>
|
|
<div class="mp-wv-card__kv-row"><span>有效次数</span><span>{{ row.validUseText || '—' }}</span></div>
|
|
<div class="mp-wv-card__kv-row">
|
|
<span>是否预警</span>
|
|
<span v-if="warningText(row)" class="status-tag status-tag--danger">{{ warningText(row) }}</span>
|
|
<span v-else>—</span>
|
|
</div>
|
|
<div class="mp-wv-card__kv-row">
|
|
<span>证载品名</span><span>{{ row.productNameOnCert || '—' }}</span>
|
|
</div>
|
|
<div class="mp-wv-card__kv-row"><span>单位</span><span>{{ unit(row.quantityUnit) || '—' }}</span></div>
|
|
<div class="mp-wv-card__kv-row"><span>全证核定</span><span>{{ qty(row.totalQty) }}</span></div>
|
|
<div class="mp-wv-card__kv-row"><span>全证预占</span><span>{{ qty(row.reservedQty) }}</span></div>
|
|
<div class="mp-wv-card__kv-row"><span>全证已用</span><span>{{ qty(row.usedQty) }}</span></div>
|
|
<div class="mp-wv-card__kv-row"><span>全证共享余额</span><span>{{ qty(row.availableQty) }}</span></div>
|
|
<div class="mp-wv-card__kv-row"><span>有效期起</span><span>{{ row.validFrom || '—' }}</span></div>
|
|
<div class="mp-wv-card__kv-row"><span>有效期止</span><span>{{ row.validTo || '—' }}</span></div>
|
|
</div>
|
|
<div class="mp-wv-card-actions mp-wv-card-actions--single" @click.stop>
|
|
<button class="mp-wv-btn mp-wv-btn--primary" type="button" @click="open(row)">查看</button>
|
|
</div>
|
|
</article>
|
|
</van-list>
|
|
<van-empty
|
|
v-if="authReady && allowed && !loading && finished && !error && !rows.length"
|
|
description="暂无证件用量"
|
|
/>
|
|
</main>
|
|
</template>
|
|
<script setup lang="ts">
|
|
import { fetchGetMenuCodes } from '@/api/auth'
|
|
import { quotaStatisticsApi, type CertificateStatisticsSummary } from '@/api/pl/quota-cert'
|
|
import { formatCertQty } from '@/views/pl/quota-cert/model'
|
|
import { useDictStore } from '@/store/modules/dict'
|
|
import { getProductUnitLabel } from '@/utils/crm-product-display'
|
|
import { certListStatus } from './usage-model'
|
|
import { expiryWarning } from '@/views/pl/quota-cert/cert-list-face'
|
|
|
|
const props = defineProps<{ keyword: string; kind: string }>()
|
|
const router = useRouter()
|
|
const rows = ref<CertificateStatisticsSummary[]>([])
|
|
const loading = ref(true)
|
|
const finished = ref(false)
|
|
const error = ref('')
|
|
const allowed = ref(false)
|
|
const authReady = ref(false)
|
|
const page = ref(1)
|
|
let epoch = 0
|
|
let checking = true
|
|
|
|
function warningText(row: CertificateStatisticsSummary) {
|
|
return expiryWarning(row.validTo)?.label || ''
|
|
}
|
|
function qty(value: unknown) {
|
|
return formatCertQty(value)
|
|
}
|
|
function unit(value?: string | null) {
|
|
const label = getProductUnitLabel(useDictStore().getLabel, value)
|
|
return !label || label === '—' ? '' : label
|
|
}
|
|
function open(row: CertificateStatisticsSummary) {
|
|
void router.push(`/m/pl/plan-cert/usage/${row.certType}/${row.certId}`)
|
|
}
|
|
async function init() {
|
|
const current = epoch
|
|
try {
|
|
const permissions = await fetchGetMenuCodes()
|
|
if (current !== epoch) return
|
|
const codes = permissions?.menuCodes || []
|
|
allowed.value =
|
|
!!permissions?.all || !!permissions?.isSuperAdmin || codes.includes('pl:quota-cert:list')
|
|
authReady.value = true
|
|
checking = false
|
|
if (!allowed.value) {
|
|
finished.value = true
|
|
loading.value = false
|
|
return
|
|
}
|
|
await load()
|
|
} catch {
|
|
if (current !== epoch) return
|
|
checking = false
|
|
authReady.value = true
|
|
finished.value = true
|
|
loading.value = false
|
|
error.value = '权限加载失败,请重新打开页面'
|
|
}
|
|
}
|
|
function reload() {
|
|
if (!allowed.value) {
|
|
void init()
|
|
return
|
|
}
|
|
epoch++
|
|
page.value = 1
|
|
rows.value = []
|
|
loading.value = true
|
|
finished.value = false
|
|
error.value = ''
|
|
void load()
|
|
}
|
|
async function load() {
|
|
if (checking || !allowed.value) return
|
|
const current = epoch
|
|
loading.value = true
|
|
try {
|
|
const data = await quotaStatisticsApi.certificates({
|
|
page: page.value,
|
|
pageSize: 20,
|
|
keyword: props.keyword || undefined,
|
|
certTypeIn: props.kind ? props.kind : undefined
|
|
})
|
|
if (current !== epoch) return
|
|
const list = data?.list || []
|
|
rows.value = page.value === 1 ? list : rows.value.concat(list)
|
|
finished.value = rows.value.length >= (data?.total || 0) || list.length < 20
|
|
page.value += 1
|
|
} catch {
|
|
if (current === epoch) {
|
|
error.value = '证件用量加载失败,请重试'
|
|
finished.value = true
|
|
}
|
|
} finally {
|
|
if (current === epoch) loading.value = false
|
|
}
|
|
}
|
|
watch(
|
|
() => props.kind,
|
|
() => {
|
|
if (!checking && allowed.value) reload()
|
|
}
|
|
)
|
|
void init()
|
|
</script>
|