人员资质修改正常接收数据
This commit is contained in:
parent
b028f2a7bd
commit
cf780323e0
|
@ -1,5 +1,5 @@
|
|||
import http from '@/utils/http'
|
||||
import type { CertificationInfo, CertificationListParams, CertificationListResponse, SimpleUserInfo } from './type'
|
||||
import type { CertificationInfo, CertificationListParams, CertificationListResponse, SimpleUserInfo,CertificationPageResponse, CertificationReq } from './type'
|
||||
|
||||
const { request } = http
|
||||
|
||||
|
@ -7,7 +7,7 @@ const { request } = http
|
|||
export type { CertificationInfo, CertificationListParams, CertificationListResponse, SimpleUserInfo }
|
||||
|
||||
// 新增人员资质
|
||||
export function createCertification(data: CertificationInfo) {
|
||||
export function createCertification(data: CertificationReq) {
|
||||
return request({
|
||||
url: '/certification',
|
||||
method: 'post',
|
||||
|
@ -74,4 +74,12 @@ export function getUserList() {
|
|||
url: '/user/list',
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
}
|
||||
// 查询人员资质信息分页列表(新接口)
|
||||
export function getCertificationPage(params: CertificationListParams) {
|
||||
return request<CertificationPageResponse>({
|
||||
url: '/certification/page',
|
||||
method: 'get',
|
||||
params
|
||||
})
|
||||
}
|
|
@ -11,19 +11,25 @@ export interface CertificationInfo {
|
|||
createTime?: string
|
||||
updateTime?: string
|
||||
}
|
||||
|
||||
export interface CertificationReq {
|
||||
certificationCode: string
|
||||
certificationImage: string
|
||||
certificationName: string
|
||||
certificationType: string
|
||||
userId: string
|
||||
validityDateBegin: string
|
||||
validityDateEnd: string
|
||||
}
|
||||
/** 人员资质列表查询参数 */
|
||||
export interface CertificationListParams {
|
||||
certificationName?: string
|
||||
certificationType?: string
|
||||
userName?: string
|
||||
current?: number
|
||||
size?: number
|
||||
}
|
||||
|
||||
/** 人员资质列表响应 */
|
||||
export interface CertificationListResponse {
|
||||
records: CertificationInfo[]
|
||||
data: CertificationInfo[]
|
||||
total: number
|
||||
current: number
|
||||
size: number
|
||||
|
@ -32,7 +38,22 @@ export interface CertificationListResponse {
|
|||
/** 用户信息简化版 */
|
||||
export interface SimpleUserInfo {
|
||||
userId: string
|
||||
userName: string
|
||||
account: string
|
||||
name: string
|
||||
}
|
||||
account: string
|
||||
}
|
||||
export interface CertificationInfo {
|
||||
certificationId?: string
|
||||
certificationCode: string
|
||||
certificationName: string
|
||||
userId: string
|
||||
userName?: string // 新增,后端会返回
|
||||
}
|
||||
|
||||
// 分页响应
|
||||
export interface CertificationPageResponse {
|
||||
rows: CertificationInfo[]
|
||||
total: number
|
||||
code?: number
|
||||
msg?: string
|
||||
[key: string]: any
|
||||
}
|
|
@ -15,30 +15,15 @@
|
|||
<a-card class="search-card" :bordered="false">
|
||||
<a-form :model="searchForm" layout="inline">
|
||||
<a-form-item label="证书名称" field="certificationName">
|
||||
<a-input
|
||||
v-model="searchForm.certificationName"
|
||||
placeholder="请输入证书名称"
|
||||
allow-clear
|
||||
style="width: 200px"
|
||||
/>
|
||||
<a-input v-model="searchForm.certificationName" placeholder="请输入证书名称" allow-clear style="width: 200px" />
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item label="证书类型" field="certificationType">
|
||||
<a-input
|
||||
v-model="searchForm.certificationType"
|
||||
placeholder="请输入证书类型"
|
||||
allow-clear
|
||||
style="width: 200px"
|
||||
/>
|
||||
<a-input v-model="searchForm.certificationType" placeholder="请输入证书类型" allow-clear style="width: 200px" />
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item label="用户姓名" field="userName">
|
||||
<a-input
|
||||
v-model="searchForm.userName"
|
||||
placeholder="请输入用户姓名"
|
||||
allow-clear
|
||||
style="width: 200px"
|
||||
/>
|
||||
<a-input v-model="searchForm.userName" placeholder="请输入用户姓名" allow-clear style="width: 200px" />
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item>
|
||||
|
@ -62,28 +47,15 @@
|
|||
|
||||
<!-- 人员资质表格 -->
|
||||
<a-card class="table-card" :bordered="false">
|
||||
<a-table
|
||||
:columns="columns"
|
||||
:data="certificationList"
|
||||
:pagination="paginationConfig"
|
||||
:loading="loading"
|
||||
row-key="certificationId"
|
||||
@page-change="handlePageChange"
|
||||
>
|
||||
<a-table :columns="columns" :data="certificationList" :pagination="paginationConfig" :loading="loading"
|
||||
row-key="certificationId" @page-change="handlePageChange">
|
||||
<template #userName="{ record }">
|
||||
<span>{{ getUserName(record.userId) }}</span>
|
||||
</template>
|
||||
|
||||
<template #certificationImage="{ record }">
|
||||
<a-image
|
||||
v-if="record.certificationImage"
|
||||
:src="record.certificationImage"
|
||||
width="60"
|
||||
height="40"
|
||||
fit="cover"
|
||||
show-loader
|
||||
preview
|
||||
/>
|
||||
<a-image v-if="record.certificationImage" :src="record.certificationImage" width="60" height="40"
|
||||
fit="cover" show-loader preview />
|
||||
<span v-else>-</span>
|
||||
</template>
|
||||
|
||||
|
@ -105,19 +77,9 @@
|
|||
</a-card>
|
||||
|
||||
<!-- 新增/编辑资质信息模态框 -->
|
||||
<a-modal
|
||||
v-model:visible="modalVisible"
|
||||
:title="isEdit ? '编辑资质信息' : '新增资质信息'"
|
||||
width="700px"
|
||||
@ok="handleSubmit"
|
||||
@cancel="handleCancel"
|
||||
>
|
||||
<a-form
|
||||
ref="formRef"
|
||||
:model="formData"
|
||||
:rules="formRules"
|
||||
layout="vertical"
|
||||
>
|
||||
<a-modal v-model:visible="modalVisible" :title="isEdit ? '编辑资质信息' : '新增资质信息'" width="700px" @ok="handleSubmit"
|
||||
@cancel="handleCancel">
|
||||
<a-form ref="formRef" :model="formData" :rules="formRules" layout="vertical">
|
||||
<a-row :gutter="16">
|
||||
<a-col :span="12">
|
||||
<a-form-item label="证书编号" field="certificationCode">
|
||||
|
@ -141,19 +103,9 @@
|
|||
|
||||
<a-col :span="12">
|
||||
<a-form-item label="持证人" field="userId">
|
||||
<a-select
|
||||
v-model="formData.userId"
|
||||
placeholder="请选择持证人"
|
||||
:loading="loadingUsers"
|
||||
allow-search
|
||||
:filter-option="filterUserOption"
|
||||
>
|
||||
<a-option
|
||||
v-for="user in userList"
|
||||
:key="user.userId"
|
||||
:value="user.userId"
|
||||
:label="user.name"
|
||||
>
|
||||
<a-select v-model="formData.userId" placeholder="请选择持证人" :loading="loadingUsers" allow-search
|
||||
:filter-option="filterUserOption" @="console.log('d', formData)">
|
||||
<a-option v-for="user in userList" :key="user.userId" :value="user.userId" :label="user.name">
|
||||
{{ user.name }}({{ user.account }})
|
||||
</a-option>
|
||||
</a-select>
|
||||
|
@ -164,43 +116,24 @@
|
|||
<a-row :gutter="16">
|
||||
<a-col :span="12">
|
||||
<a-form-item label="有效期开始" field="validityDateBegin">
|
||||
<a-date-picker
|
||||
v-model="formData.validityDateBegin"
|
||||
placeholder="请选择有效期开始日期"
|
||||
style="width: 100%"
|
||||
/>
|
||||
<a-date-picker v-model="formData.validityDateBegin" placeholder="请选择有效期开始日期" style="width: 100%" />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
|
||||
<a-col :span="12">
|
||||
<a-form-item label="有效期结束" field="validityDateEnd">
|
||||
<a-date-picker
|
||||
v-model="formData.validityDateEnd"
|
||||
placeholder="请选择有效期结束日期"
|
||||
style="width: 100%"
|
||||
/>
|
||||
<a-date-picker v-model="formData.validityDateEnd" placeholder="请选择有效期结束日期" style="width: 100%" />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
|
||||
<a-form-item label="证书图片" field="certificationImage">
|
||||
<a-upload
|
||||
:custom-request="handleUpload"
|
||||
:show-file-list="false"
|
||||
accept="image/*"
|
||||
:before-upload="beforeUpload"
|
||||
>
|
||||
<a-upload :custom-request="handleUpload" :show-file-list="false" accept="image/*"
|
||||
:before-upload="beforeUpload">
|
||||
<template #upload-button>
|
||||
<div class="upload-wrapper">
|
||||
<a-image
|
||||
v-if="formData.certificationImage"
|
||||
:src="formData.certificationImage"
|
||||
width="200"
|
||||
height="120"
|
||||
fit="cover"
|
||||
show-loader
|
||||
preview
|
||||
/>
|
||||
<a-image v-if="formData.certificationImage" :src="formData.certificationImage" width="200"
|
||||
height="120" fit="cover" show-loader preview />
|
||||
<div v-else class="upload-placeholder">
|
||||
<icon-plus />
|
||||
<div>点击上传证书图片</div>
|
||||
|
@ -233,7 +166,7 @@ const isEdit = ref(false)
|
|||
const formRef = ref()
|
||||
|
||||
// 列表数据
|
||||
const certificationList = ref<CertificationInfo[]>([])
|
||||
const certificationList = ref<CertificationAPI.CertificationListResponse>()
|
||||
const userList = ref<SimpleUserInfo[]>([])
|
||||
|
||||
// 搜索表单
|
||||
|
@ -254,14 +187,14 @@ const paginationConfig = reactive({
|
|||
|
||||
// 表单数据
|
||||
const formData = reactive<CertificationInfo>({
|
||||
certificationId: '',
|
||||
certificationCode: '',
|
||||
certificationImage: '',
|
||||
certificationImage: 'n',
|
||||
certificationName: '',
|
||||
certificationType: '',
|
||||
userId: '',
|
||||
validityDateBegin: '',
|
||||
validityDateEnd: ''
|
||||
validityDateEnd: '',
|
||||
// certificationTypeLabel: ''
|
||||
})
|
||||
|
||||
// 表单验证规则
|
||||
|
@ -305,7 +238,7 @@ const columns = [
|
|||
},
|
||||
{
|
||||
title: '持证人',
|
||||
dataIndex: 'userId',
|
||||
dataIndex: 'userName',
|
||||
slotName: 'userName',
|
||||
width: 120
|
||||
},
|
||||
|
@ -339,10 +272,10 @@ const getUserName = (userId: string) => {
|
|||
const filterUserOption = (inputValue: string, option: any) => {
|
||||
const user = userList.value.find(u => u.userId === option.value)
|
||||
if (!user) return false
|
||||
|
||||
|
||||
const searchText = inputValue.toLowerCase()
|
||||
return user.name.toLowerCase().includes(searchText) ||
|
||||
user.account.toLowerCase().includes(searchText)
|
||||
return user.name.toLowerCase().includes(searchText) ||
|
||||
user.account.toLowerCase().includes(searchText)
|
||||
}
|
||||
|
||||
// 获取用户列表
|
||||
|
@ -350,11 +283,16 @@ const getUserList = async () => {
|
|||
try {
|
||||
loadingUsers.value = true
|
||||
const response = await CertificationAPI.getUserList()
|
||||
|
||||
|
||||
console.log('用户列表响应:', response)
|
||||
|
||||
|
||||
if (response.data) {
|
||||
userList.value = response.data || []
|
||||
userList.value = response.data.map(item => ({
|
||||
userId: item.userId,
|
||||
name: item.name,
|
||||
account: item.account,
|
||||
})) || []
|
||||
console.log('用户列表响应2:', userList.value)
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取用户列表失败:', error)
|
||||
|
@ -370,20 +308,15 @@ const getCertificationList = async () => {
|
|||
loading.value = true
|
||||
const params: CertificationListParams = {
|
||||
...searchForm,
|
||||
current: paginationConfig.current,
|
||||
size: paginationConfig.pageSize
|
||||
}
|
||||
|
||||
const response = await CertificationAPI.getCertificationList(params)
|
||||
|
||||
console.log('资质信息列表响应:', response)
|
||||
|
||||
if (response.data) {
|
||||
certificationList.value = response.data.records || []
|
||||
certificationList.value = response.data || []
|
||||
paginationConfig.total = response.data.total || 0
|
||||
console.log('cc', certificationList.value)
|
||||
console.log('cd', response.data[0])
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取资质信息列表失败:', error)
|
||||
Message.error('获取资质信息列表失败')
|
||||
} finally {
|
||||
loading.value = false
|
||||
|
@ -397,13 +330,13 @@ const beforeUpload = (file: File) => {
|
|||
Message.error('只能上传图片文件')
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
const isLt2M = file.size / 1024 / 1024 < 2
|
||||
if (!isLt2M) {
|
||||
Message.error('图片大小不能超过 2MB')
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
|
@ -412,9 +345,9 @@ const handleUpload = async (option: any) => {
|
|||
try {
|
||||
const uploadFormData = new FormData()
|
||||
uploadFormData.append('file', option.fileItem.file)
|
||||
|
||||
|
||||
const response = await uploadFile(uploadFormData)
|
||||
|
||||
|
||||
if (response.data && response.data.url) {
|
||||
formData.certificationImage = response.data.url
|
||||
Message.success('图片上传成功')
|
||||
|
@ -491,7 +424,7 @@ const deleteRecord = (record: CertificationInfo) => {
|
|||
const handleSubmit = async () => {
|
||||
try {
|
||||
await formRef.value?.validate()
|
||||
|
||||
|
||||
if (isEdit.value) {
|
||||
await CertificationAPI.updateCertification(formData.certificationId!, formData)
|
||||
Message.success('更新成功')
|
||||
|
@ -499,7 +432,7 @@ const handleSubmit = async () => {
|
|||
await CertificationAPI.createCertification(formData)
|
||||
Message.success('创建成功')
|
||||
}
|
||||
|
||||
|
||||
modalVisible.value = false
|
||||
resetForm()
|
||||
await getCertificationList()
|
||||
|
@ -598,4 +531,4 @@ onMounted(() => {
|
|||
font-size: 24px;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
</style>
|
||||
</style>
|
Loading…
Reference in New Issue