<script setup lang="ts">
|
import { onMounted, reactive, ref } from 'vue'
|
import { useRouter } from 'vue-router'
|
import { Download, Refresh, Search } from '@element-plus/icons-vue'
|
import { ElMessage } from 'element-plus'
|
import { getServiceApplications } from '../api/admin'
|
import type { ServiceApplication } from '../types/admin'
|
import { TALENT_CARD_LEVELS } from '../utils/cardLevels'
|
import { downloadExcel } from '../utils/excel'
|
|
const loading = ref(false)
|
const router = useRouter()
|
const rows = ref<ServiceApplication[]>([])
|
|
const cardLevels = TALENT_CARD_LEVELS
|
const statusOptions = ['待处理', '已处理', '已驳回']
|
const submissionTypes = ['新增', '修改']
|
|
const filters = reactive({
|
talentKeyword: '',
|
cardLevel: '',
|
status: '',
|
submissionType: '',
|
submittedTime: [] as string[],
|
})
|
|
const pagination = reactive({
|
page: 1,
|
size: 10,
|
total: 0,
|
})
|
|
function formatDateTime(value?: string) {
|
return value ? value.replace('T', ' ') : ''
|
}
|
|
function normalizeRecord(row: ServiceApplication): ServiceApplication {
|
return { ...row, submittedAt: formatDateTime(row.submittedAt) }
|
}
|
|
async function loadData() {
|
loading.value = true
|
try {
|
const result = await getServiceApplications({
|
page: pagination.page,
|
size: pagination.size,
|
applicationType: 'FUEL_SERVICE',
|
talentKeyword: filters.talentKeyword || undefined,
|
cardLevel: filters.cardLevel || undefined,
|
status: filters.status || undefined,
|
submissionType: filters.submissionType || undefined,
|
submittedStart: filters.submittedTime?.[0],
|
submittedEnd: filters.submittedTime?.[1],
|
})
|
rows.value = result.records.map(normalizeRecord)
|
pagination.total = result.total
|
} catch {
|
rows.value = []
|
pagination.total = 0
|
} finally {
|
loading.value = false
|
}
|
}
|
|
function search() {
|
pagination.page = 1
|
loadData()
|
}
|
|
function resetFilters() {
|
filters.talentKeyword = ''
|
filters.cardLevel = ''
|
filters.status = ''
|
filters.submissionType = ''
|
filters.submittedTime = []
|
pagination.page = 1
|
search()
|
}
|
|
async function download() {
|
const result = await getServiceApplications({ page: 1, size: 1000, applicationType: 'FUEL_SERVICE', talentKeyword: filters.talentKeyword || undefined, cardLevel: filters.cardLevel || undefined, status: filters.status || undefined, submissionType: filters.submissionType || undefined, submittedStart: filters.submittedTime?.[0], submittedEnd: filters.submittedTime?.[1] })
|
exportApplications('加油服务登记', result.records.map(normalizeRecord))
|
}
|
|
function exportApplications(filename: string, data: ServiceApplication[]) {
|
downloadExcel(filename, [{ title: '申请单号', value: row => row.applicationNo }, { title: '持卡人', value: row => row.talentName }, { title: '手机号', value: row => row.talentMobile }, { title: '人才等级', value: row => row.talentLevel }, { title: '支付宝手机号', value: row => row.alipayMobile }, { title: '提交类型', value: row => row.submissionType }, { title: '提交时间', value: row => row.submittedAt }, { title: '状态', value: row => row.status }, { title: '处理人', value: row => row.handlerName }], data)
|
ElMessage.success(`已导出 ${data.length} 条登记`)
|
}
|
|
function viewDetail(row: ServiceApplication) {
|
router.push(`/fuel-services/${row.id}`)
|
}
|
|
onMounted(loadData)
|
</script>
|
|
<template>
|
<div class="page-stack prototype-page fuel-service-page">
|
<section class="panel">
|
<div class="panel-header">
|
<h3>查询表格</h3>
|
</div>
|
|
<el-form class="fuel-service-filter-form" :model="filters" label-width="72px">
|
<el-form-item label="持卡人">
|
<el-input v-model="filters.talentKeyword" placeholder="持卡人姓名、手机号、卡号" clearable />
|
</el-form-item>
|
<el-form-item label="卡片等级">
|
<el-select v-model="filters.cardLevel" placeholder="全部" clearable>
|
<el-option label="全部" value="" />
|
<el-option v-for="level in cardLevels" :key="level" :label="level" :value="level" />
|
</el-select>
|
</el-form-item>
|
<el-form-item label="提交类型">
|
<el-select v-model="filters.submissionType" placeholder="全部" clearable>
|
<el-option label="全部" value="" />
|
<el-option v-for="type in submissionTypes" :key="type" :label="type" :value="type" />
|
</el-select>
|
</el-form-item>
|
<el-form-item label="提交时间">
|
<el-date-picker
|
v-model="filters.submittedTime"
|
type="daterange"
|
start-placeholder="开始日期"
|
end-placeholder="结束日期"
|
range-separator="至"
|
value-format="YYYY-MM-DD"
|
/>
|
</el-form-item>
|
<el-form-item label="状态">
|
<el-select v-model="filters.status" placeholder="全部" clearable>
|
<el-option label="全部" value="" />
|
<el-option v-for="status in statusOptions" :key="status" :label="status" :value="status" />
|
</el-select>
|
</el-form-item>
|
<div class="fuel-service-filter-actions">
|
<el-button type="primary" :icon="Search" @click="search">查询</el-button>
|
<el-button :icon="Refresh" @click="resetFilters">重置</el-button>
|
</div>
|
</el-form>
|
|
<div class="fuel-service-table-tools">
|
<el-button v-permission="'admin.fuel-services.export'" :icon="Download" @click="download">下载</el-button>
|
</div>
|
|
<el-table
|
v-loading="loading"
|
:data="rows"
|
border
|
class="fuel-service-table"
|
empty-text="暂无加油服务数据"
|
>
|
<el-table-column prop="applicationNo" label="提交单号" min-width="96" align="center" />
|
<el-table-column prop="talentName" label="持卡人名称" min-width="112" align="center" />
|
<el-table-column prop="talentMobile" label="持卡人电话" min-width="118" align="center" />
|
<el-table-column prop="talentLevel" label="人才等级" min-width="100" align="center" />
|
<el-table-column prop="alipayMobile" label="支付宝绑定手机号" min-width="132" align="center" />
|
<el-table-column prop="submittedAt" label="提交时间" min-width="126" align="center">
|
<template #default="{ row }">{{ formatDateTime(row.submittedAt) }}</template>
|
</el-table-column>
|
<el-table-column prop="submissionType" label="提交类型" min-width="108" align="center" />
|
<el-table-column prop="status" label="状态" min-width="108" align="center" />
|
<el-table-column label="操作" width="86" fixed="right" align="center">
|
<template #default="{ row }">
|
<el-button v-if="row.applicationNo" link type="primary" @click="viewDetail(row)">查看</el-button>
|
</template>
|
</el-table-column>
|
</el-table>
|
|
<div class="pagination-row">
|
<el-pagination
|
v-model:current-page="pagination.page"
|
v-model:page-size="pagination.size"
|
background
|
layout="total, sizes, prev, pager, next"
|
:page-sizes="[10, 20, 50]"
|
:pager-count="5"
|
:total="pagination.total"
|
@change="loadData"
|
/>
|
</div>
|
</section>
|
</div>
|
</template>
|