This commit is contained in:
吴红兵
2026-03-07 12:35:45 +08:00
parent 271710e870
commit b997b3ba48
423 changed files with 79612 additions and 91574 deletions

View File

@@ -1,292 +1,273 @@
<template>
<el-dialog v-model="dialogVisible" :title="title" width="600px" append-to-body :close-on-click-modal="false" destroy-on-close>
<el-form
ref="formRef"
:model="dataForm"
:rules="dataRules"
label-width="120px"
>
<el-form-item label="荣誉" prop="honor">
<el-input v-model="dataForm.honor" placeholder="请输入荣誉" clearable />
</el-form-item>
<el-form-item label="表彰单位" prop="honorCompany">
<el-input v-model="dataForm.honorCompany" placeholder="请输入表彰单位" clearable />
</el-form-item>
<el-form-item label="年份" prop="year">
<el-date-picker
v-model="dataForm.year"
type="year"
placeholder="请选择年份"
format="YYYY"
value-format="YYYY"
/>
</el-form-item>
<el-form-item label="证明材料" prop="attachment" required>
<el-upload
ref="uploadRef"
:headers="headers"
:limit="1"
:action="url"
:before-upload="beforeUpload"
:on-success="materiaUploadSuccess"
:on-remove="handleRemove"
:on-exceed="handleExceed"
:file-list="fileList"
:accept="'.jpg,.jpeg,.png,.pdf'"
>
<el-button size="small" type="primary">点击上传</el-button>
<template #tip>
<div style="margin-top: 8px;">
<el-tag>仅支持jpg,jpeg,png,pdf后缀的文件上传</el-tag>
</div>
</template>
</el-upload>
</el-form-item>
</el-form>
<el-dialog v-model="dialogVisible" :title="title" width="600px" append-to-body :close-on-click-modal="false" destroy-on-close>
<el-form ref="formRef" :model="dataForm" :rules="dataRules" label-width="120px">
<el-form-item label="荣誉" prop="honor">
<el-input v-model="dataForm.honor" placeholder="请输入荣誉" clearable />
</el-form-item>
<template #footer>
<div class="dialog-footer">
<el-button @click="dialogVisible = false">取消</el-button>
<el-button @click="dialogSubmit" type="primary" :loading="submitLoading">保存</el-button>
</div>
</template>
</el-dialog>
<el-form-item label="表彰单位" prop="honorCompany">
<el-input v-model="dataForm.honorCompany" placeholder="请输入表彰单位" clearable />
</el-form-item>
<el-form-item label="年份" prop="year">
<el-date-picker v-model="dataForm.year" type="year" placeholder="请选择年份" format="YYYY" value-format="YYYY" />
</el-form-item>
<el-form-item label="证明材料" prop="attachment" required>
<el-upload
ref="uploadRef"
:headers="headers"
:limit="1"
:action="url"
:before-upload="beforeUpload"
:on-success="materiaUploadSuccess"
:on-remove="handleRemove"
:on-exceed="handleExceed"
:file-list="fileList"
:accept="'.jpg,.jpeg,.png,.pdf'"
>
<el-button size="small" type="primary">点击上传</el-button>
<template #tip>
<div style="margin-top: 8px">
<el-tag>仅支持jpg,jpeg,png,pdf后缀的文件上传</el-tag>
</div>
</template>
</el-upload>
</el-form-item>
</el-form>
<template #footer>
<div class="dialog-footer">
<el-button @click="dialogVisible = false">取消</el-button>
<el-button @click="dialogSubmit" type="primary" :loading="submitLoading">保存</el-button>
</div>
</template>
</el-dialog>
</template>
<script setup lang="ts">
import { ref, reactive, computed, nextTick } from 'vue'
import { Session } from '/@/utils/storage'
import { useMessage } from '/@/hooks/message'
import { addObj } from '/@/api/professional/professionaluser/professionalteacherhonor'
import { checkLocked } from '/@/api/professional/professionalstatuslock'
import { ref, reactive, computed, nextTick } from 'vue';
import { Session } from '/@/utils/storage';
import { useMessage } from '/@/hooks/message';
import { addObj } from '/@/api/professional/professionaluser/professionalteacherhonor';
import { checkLocked } from '/@/api/professional/professionalstatuslock';
// Emits
const emit = defineEmits<{
(e: 'refreshData'): void
}>()
(e: 'refreshData'): void;
}>();
// 消息提示
const message = useMessage()
const message = useMessage();
// 表单引用
const formRef = ref()
const uploadRef = ref()
const submitLoading = ref(false)
const formRef = ref();
const uploadRef = ref();
const submitLoading = ref(false);
// 对话框显示状态(内部管理)
const dialogVisible = ref(false)
const dialogVisible = ref(false);
// 表单数据
const dataForm = reactive({
honor: '',
honorCompany: '',
year: '',
materialA: '',
attachment: '',
state: '',
teacherName: '',
id: ''
})
honor: '',
honorCompany: '',
year: '',
materialA: '',
attachment: '',
state: '',
teacherName: '',
id: '',
});
// 表单验证规则
const dataRules = {
honor: [
{ required: true, message: '请填写荣誉', trigger: 'blur' }
],
honorCompany: [
{ required: true, message: '请填写表彰单位', trigger: 'blur' }
],
year: [
{ required: true, message: '请选择年份', trigger: 'change' }
],
attachment: [
{ required: true, message: '请上传证明材料', trigger: 'change' }
]
}
honor: [{ required: true, message: '请填写荣誉', trigger: 'blur' }],
honorCompany: [{ required: true, message: '请填写表彰单位', trigger: 'blur' }],
year: [{ required: true, message: '请选择年份', trigger: 'change' }],
attachment: [{ required: true, message: '请上传证明材料', trigger: 'change' }],
};
// 基础信息(简化,只保留需要的)
// 上传相关
const url = ref('')
const fileList = ref<any[]>([])
const url = ref('');
const fileList = ref<any[]>([]);
// 请求头
const headers = computed(() => {
return {
"Authorization": 'Bearer ' + Session.getToken()
}
})
return {
Authorization: 'Bearer ' + Session.getToken(),
};
});
// 显示表单标志
const showForm = ref(false)
const showForm = ref(false);
// 标题
const title = ref('')
const title = ref('');
// 初始化字典数据(简化,不需要加载字典数据)
const initDicData = async () => {
// 综合表彰不需要额外的字典数据
}
// 综合表彰不需要额外的字典数据
};
// 上传前的处理
const beforeUpload = () => {
return true
}
return true;
};
// 文件超出限制时的处理(当 limit=1 且已有文件时,用户上传新文件会触发此事件)
// 根据 Element Plus 官方文档,在 on-exceed 中清空文件列表并添加新文件
const handleExceed = (files: File[]) => {
// 清空当前文件列表
uploadRef.value?.clearFiles()
fileList.value = []
dataForm.attachment = ''
// 等待 DOM 更新后,手动触发新文件的上传
nextTick(() => {
const newFile = files[0]
if (newFile && uploadRef.value) {
// 通过 input 元素手动触发文件上传
const input = uploadRef.value.$el?.querySelector('input[type="file"]')
if (input) {
// 创建新的 DataTransfer 对象并添加新文件
const dataTransfer = new DataTransfer()
dataTransfer.items.add(newFile)
input.files = dataTransfer.files
// 触发 change 事件,让 Element Plus 自动处理上传
const changeEvent = new Event('change', { bubbles: true })
input.dispatchEvent(changeEvent)
}
}
})
}
// 清空当前文件列表
uploadRef.value?.clearFiles();
fileList.value = [];
dataForm.attachment = '';
// 等待 DOM 更新后,手动触发新文件的上传
nextTick(() => {
const newFile = files[0];
if (newFile && uploadRef.value) {
// 通过 input 元素手动触发文件上传
const input = uploadRef.value.$el?.querySelector('input[type="file"]');
if (input) {
// 创建新的 DataTransfer 对象并添加新文件
const dataTransfer = new DataTransfer();
dataTransfer.items.add(newFile);
input.files = dataTransfer.files;
// 触发 change 事件,让 Element Plus 自动处理上传
const changeEvent = new Event('change', { bubbles: true });
input.dispatchEvent(changeEvent);
}
}
});
};
// 文件上传成功
const materiaUploadSuccess = (response: any, file: any) => {
if (response.data && response.data.code === "-1") {
message.error("当前不允许上传文件")
// 上传失败,移除文件
fileList.value = []
uploadRef.value?.clearFiles()
return
}
if (response.data && response.data.url) {
dataForm.attachment = response.data.url
// 更新文件列表,确保显示新上传的文件(替换旧文件)
fileList.value = [{
name: file.name || '证明材料',
url: response.data.url,
uid: file.uid || Date.now(),
status: 'success'
}]
formRef.value?.clearValidate('attachment')
}
}
if (response.data && response.data.code === '-1') {
message.error('当前不允许上传文件');
// 上传失败,移除文件
fileList.value = [];
uploadRef.value?.clearFiles();
return;
}
if (response.data && response.data.url) {
dataForm.attachment = response.data.url;
// 更新文件列表,确保显示新上传的文件(替换旧文件)
fileList.value = [
{
name: file.name || '证明材料',
url: response.data.url,
uid: file.uid || Date.now(),
status: 'success',
},
];
formRef.value?.clearValidate('attachment');
}
};
// 文件删除处理
const handleRemove = () => {
dataForm.attachment = ''
fileList.value = []
formRef.value?.clearValidate('attachment')
}
dataForm.attachment = '';
fileList.value = [];
formRef.value?.clearValidate('attachment');
};
// 打开对话框
const openDialog = async (row?: any) => {
// 新增模式:先检查是否锁定
if (!row || !row.id) {
try {
const lockResponse = await checkLocked('remix')
if (lockResponse.data) {
message.warning("新增功能已锁定,暂不允许操作")
return
}
} catch (error) {
// 错误处理已在数据请求层统一处理,此处不需要提示
return
}
}
// 根据是否有 row 设置不同的表单数据
if (row && row.id) {
// 编辑模式:使用传入的数据
title.value = row.teacherName || ''
Object.assign(dataForm, {
honor: row.honor || '',
honorCompany: row.honorCompany || '',
year: row.year ? String(row.year) : '',
materialA: row.materialA || '',
attachment: row.attachment || '',
state: row.state || '',
teacherName: row.teacherName || '',
id: row.id || ''
})
// 回显已上传的证明材料
fileList.value = dataForm.attachment
? [{ name: '证明材料', url: dataForm.attachment }]
: []
} else {
// 新增模式:重置为空
title.value = '新增综合表彰'
Object.assign(dataForm, {
honor: '',
honorCompany: '',
year: '',
attachment: '',
state: '',
teacherName: '',
id: ''
})
fileList.value = []
}
// 公共设置:每次打开都重置上传地址
url.value = `/professional/file/teacherAboutInfoUpload?type=4`
// 公共操作:加载字典数据并显示对话框
await initDicData()
showForm.value = true
dialogVisible.value = true
}
// 新增模式:先检查是否锁定
if (!row || !row.id) {
try {
const lockResponse = await checkLocked('remix');
if (lockResponse.data) {
message.warning('新增功能已锁定,暂不允许操作');
return;
}
} catch (error) {
// 错误处理已在数据请求层统一处理,此处不需要提示
return;
}
}
// 根据是否有 row 设置不同的表单数据
if (row && row.id) {
// 编辑模式:使用传入的数据
title.value = row.teacherName || '';
Object.assign(dataForm, {
honor: row.honor || '',
honorCompany: row.honorCompany || '',
year: row.year ? String(row.year) : '',
materialA: row.materialA || '',
attachment: row.attachment || '',
state: row.state || '',
teacherName: row.teacherName || '',
id: row.id || '',
});
// 回显已上传的证明材料
fileList.value = dataForm.attachment ? [{ name: '证明材料', url: dataForm.attachment }] : [];
} else {
// 新增模式:重置为空
title.value = '新增综合表彰';
Object.assign(dataForm, {
honor: '',
honorCompany: '',
year: '',
attachment: '',
state: '',
teacherName: '',
id: '',
});
fileList.value = [];
}
// 公共设置:每次打开都重置上传地址
url.value = `/professional/file/teacherAboutInfoUpload?type=4`;
// 公共操作:加载字典数据并显示对话框
await initDicData();
showForm.value = true;
dialogVisible.value = true;
};
// 提交表单
const dialogSubmit = async () => {
if (!formRef.value) return
await formRef.value.validate(async (valid: boolean) => {
if (valid) {
submitLoading.value = true
try {
// 统一使用 addObj 接口(新增和编辑都使用同一个接口)
await addObj(dataForm)
message.success(dataForm.id ? "修改成功" : "提交成功")
dialogVisible.value = false
emit('refreshData')
} catch (error: any) {
// 错误处理已在数据请求层统一处理,此处不需要提示
} finally {
submitLoading.value = false
}
}
})
}
if (!formRef.value) return;
await formRef.value.validate(async (valid: boolean) => {
if (valid) {
submitLoading.value = true;
try {
// 统一使用 addObj 接口(新增和编辑都使用同一个接口)
await addObj(dataForm);
message.success(dataForm.id ? '修改成功' : '提交成功');
dialogVisible.value = false;
emit('refreshData');
} catch (error: any) {
// 错误处理已在数据请求层统一处理,此处不需要提示
} finally {
submitLoading.value = false;
}
}
});
};
// 初始化方法(保持兼容性)
const init = () => {
// 新版本不再需要初始化配置
}
// 新版本不再需要初始化配置
};
// 暴露方法
defineExpose({
openDialog,
init
})
openDialog,
init,
});
</script>
<style scoped lang="scss">
.dialog-footer {
text-align: right;
text-align: right;
}
</style>

View File

@@ -1,413 +1,371 @@
<template>
<div class="layout-padding">
<div class="layout-padding-auto layout-padding-view">
<!-- 搜索表单 -->
<search-form
v-show="showSearch"
:model="search"
ref="searchFormRef"
@keyup-enter="handleFilter"
>
<template #default="{ visible }">
<template v-if="visible">
<el-form-item label="审核状态" prop="state">
<el-select
v-model="search.state"
clearable
placeholder="请选择审核状态"
>
<el-option
v-for="item in professionalState"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-form-item>
<div class="layout-padding">
<div class="layout-padding-auto layout-padding-view">
<!-- 搜索表单 -->
<search-form v-show="showSearch" :model="search" ref="searchFormRef" @keyup-enter="handleFilter">
<template #default="{ visible }">
<template v-if="visible">
<el-form-item label="审核状态" prop="state">
<el-select v-model="search.state" clearable placeholder="请选择审核状态">
<el-option v-for="item in professionalState" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
</el-form-item>
<el-form-item label="工号" prop="teacherNo">
<el-input
v-model="search.teacherNo"
clearable
placeholder="请输入工号"
/>
</el-form-item>
<el-form-item label="工号" prop="teacherNo">
<el-input v-model="search.teacherNo" clearable placeholder="请输入工号" />
</el-form-item>
<el-form-item label="姓名" prop="teacherName">
<el-input
v-model="search.teacherName"
clearable
placeholder="请输入姓名"
/>
</el-form-item>
</template>
</template>
<el-form-item label="姓名" prop="teacherName">
<el-input v-model="search.teacherName" clearable placeholder="请输入姓名" />
</el-form-item>
</template>
</template>
<!-- 操作按钮 -->
<template #actions>
<el-form-item>
<el-button type="primary" @click="handleFilter" icon="Search">查询</el-button>
<el-button @click="resetQuery" icon="Refresh">重置</el-button>
</el-form-item>
</template>
</search-form>
<!-- 操作按钮 -->
<template #actions>
<el-form-item>
<el-button type="primary" @click="handleFilter" icon="Search">查询</el-button>
<el-button @click="resetQuery" icon="Refresh">重置</el-button>
</el-form-item>
</template>
</search-form>
<!-- 操作按钮 -->
<el-row>
<div class="mb15" style="width: 100%;">
<el-button
v-if="hasAuth('professional_professionalteacherhonor_add')"
type="primary"
icon="FolderAdd"
@click="handleAdd">
</el-button>
<el-button
type="warning"
plain
icon="Download"
@click="handleDownLoadWord"
:loading="exportLoading">导出信息
</el-button>
<el-button
v-auth="'professional_teacherinfo_import'"
type="primary"
plain
icon="UploadFilled"
:loading="exportLoading"
@click="handleImportDialog">导入信息
</el-button>
</div>
</el-row>
<!-- 操作按钮 -->
<el-row>
<div class="mb15" style="width: 100%">
<el-button v-if="hasAuth('professional_professionalteacherhonor_add')" type="primary" icon="FolderAdd" @click="handleAdd"> </el-button>
<el-button type="warning" plain icon="Download" @click="handleDownLoadWord" :loading="exportLoading">导出信息 </el-button>
<el-button
v-auth="'professional_teacherinfo_import'"
type="primary"
plain
icon="UploadFilled"
:loading="exportLoading"
@click="handleImportDialog"
>导入信息
</el-button>
</div>
</el-row>
<!-- 表格 -->
<el-table
ref="tableRef"
:data="state.dataList"
row-key="id"
v-loading="state.loading"
border
:cell-style="tableStyle.cellStyle"
:header-cell-style="tableStyle.headerCellStyle"
>
<el-table-column type="index" label="序号" width="60" align="center" />
<el-table-column prop="state" label="审核状态" width="130" align="center">
<template #default="scope">
<DetailPopover
v-if="scope.row.state === '-2' && scope.row.backReason"
title="审核详情"
placement="top"
:width="300"
:items="[
{ label: '审核状态', layout: 'horizontal', content: getAuditStateTagConfig(scope.row.state)?.label },
{ label: '驳回理由', content: scope.row.backReason, contentClass: 'reason-content' }
]"
>
<template #reference>
<ClickableTag
:type="getAuditStateTagConfig(scope.row.state)?.type || 'danger'"
:left-icon="getAuditStateTagConfig(scope.row.state)?.leftIcon"
:effect="getAuditStateTagConfig(scope.row.state)?.effect || 'dark'"
>
{{ getAuditStateTagConfig(scope.row.state)?.label || '已驳回' }}
</ClickableTag>
</template>
<template #content-0>
<ClickableTag
:type="getAuditStateTagConfig(scope.row.state)?.type || 'danger'"
:left-icon="getAuditStateTagConfig(scope.row.state)?.leftIcon"
:effect="getAuditStateTagConfig(scope.row.state)?.effect || 'dark'"
:right-icon="null"
>
{{ getAuditStateTagConfig(scope.row.state)?.label || '已驳回' }}
</ClickableTag>
</template>
<template #content-1>
<div class="reason-content">
<el-icon class="reason-icon"><Warning /></el-icon>
<span>{{ scope.row.backReason }}</span>
</div>
</template>
</DetailPopover>
<AuditState v-else :state="scope.row.state" :options="auditStateOptions" />
</template>
</el-table-column>
<el-table-column label="姓名/工号" min-width="150" align="center">
<template #default="scope">
<TeacherNameNo :name="scope.row.realName" :no="scope.row.teacherNo" />
</template>
</el-table-column>
<el-table-column prop="honor" label="荣誉" min-width="150" align="center" show-overflow-tooltip />
<el-table-column prop="honorCompany" label="表彰单位" min-width="150" align="center" show-overflow-tooltip />
<el-table-column prop="year" label="年份" width="100" align="center" />
<el-table-column label="证明材料" width="120" align="center">
<template #default="scope">
<el-button
v-if="scope.row.attachment && scope.row.attachment !== ''"
type="primary"
link
icon="Document"
@click="showEdvince(scope.row)">查看
</el-button>
<span v-else>-</span>
</template>
</el-table-column>
<el-table-column label="操作" width="280" align="center" fixed="right">
<template #default="scope">
<el-button
v-if="hasAuth('professional_professionalteacherhonor_edit') && (scope.row.state === '0' || scope.row.state === '-2')"
type="primary"
link
icon="edit-pen"
@click="handleEdit(scope.row)">修改
</el-button>
<el-button
v-if="hasAuth('professional_professionalteacherhonor_exam') && scope.row.canExam"
type="success"
link
icon="CircleCheck"
@click="changeState(scope.row, 1)">通过
</el-button>
<el-button
v-if="hasAuth('professional_professionalteacherhonor_exam') && scope.row.canDeptExam"
type="success"
link
icon="CircleCheck"
@click="changeState(scope.row, 1)">部门通过
</el-button>
<el-button
v-if="hasAuth('professional_professionalteacherhonor_exam') && scope.row.canBack"
type="danger"
link
icon="CircleClose"
@click="changeState(scope.row, -2)">驳回
</el-button>
<el-button
v-if="hasAuth('professional_professionalteacherhonor_exam') && scope.row.canDeptBack"
type="danger"
link
icon="CircleClose"
@click="changeState(scope.row, -2)">部门驳回
</el-button>
<el-button
v-if="hasAuth('professional_professionalteacherhonor_del')"
type="danger"
link
icon="delete"
@click="handleDel(scope.row)">删除
</el-button>
</template>
</el-table-column>
</el-table>
<!-- 表格 -->
<el-table
ref="tableRef"
:data="state.dataList"
row-key="id"
v-loading="state.loading"
border
:cell-style="tableStyle.cellStyle"
:header-cell-style="tableStyle.headerCellStyle"
>
<el-table-column type="index" label="序号" width="60" align="center" />
<!-- 分页 -->
<pagination
v-bind="state.pagination"
@current-change="currentChangeHandle"
@size-change="sizeChangeHandle"
/>
<el-table-column prop="state" label="审核状态" width="130" align="center">
<template #default="scope">
<DetailPopover
v-if="scope.row.state === '-2' && scope.row.backReason"
title="审核详情"
placement="top"
:width="300"
:items="[
{ label: '审核状态', layout: 'horizontal', content: getAuditStateTagConfig(scope.row.state)?.label },
{ label: '驳回理由', content: scope.row.backReason, contentClass: 'reason-content' },
]"
>
<template #reference>
<ClickableTag
:type="getAuditStateTagConfig(scope.row.state)?.type || 'danger'"
:left-icon="getAuditStateTagConfig(scope.row.state)?.leftIcon"
:effect="getAuditStateTagConfig(scope.row.state)?.effect || 'dark'"
>
{{ getAuditStateTagConfig(scope.row.state)?.label || '已驳回' }}
</ClickableTag>
</template>
<template #content-0>
<ClickableTag
:type="getAuditStateTagConfig(scope.row.state)?.type || 'danger'"
:left-icon="getAuditStateTagConfig(scope.row.state)?.leftIcon"
:effect="getAuditStateTagConfig(scope.row.state)?.effect || 'dark'"
:right-icon="null"
>
{{ getAuditStateTagConfig(scope.row.state)?.label || '已驳回' }}
</ClickableTag>
</template>
<template #content-1>
<div class="reason-content">
<el-icon class="reason-icon"><Warning /></el-icon>
<span>{{ scope.row.backReason }}</span>
</div>
</template>
</DetailPopover>
<AuditState v-else :state="scope.row.state" :options="auditStateOptions" />
</template>
</el-table-column>
<!-- 材料预览图片直接显示PDF 在组件内部 dialog 中显示 -->
<preview-file
v-for="src in imgUrl"
:key="src.title"
:authSrc="src.url"
dialog-title="综合表彰材料"
/>
<el-table-column label="姓名/工号" min-width="150" align="center">
<template #default="scope">
<TeacherNameNo :name="scope.row.realName" :no="scope.row.teacherNo" />
</template>
</el-table-column>
<!-- 子组件 -->
<ProfessionalBackResaon ref="backReasonRef" @refreshData="handleFilter" />
<DataForm ref="dataFormRef" @refreshData="handleFilter" />
<import-teacher-other-info ref="importTeacherOtherInfoRef" @refreshData="handleFilter" />
</div>
</div>
<el-table-column prop="honor" label="荣誉" min-width="150" align="center" show-overflow-tooltip />
<el-table-column prop="honorCompany" label="表彰单位" min-width="150" align="center" show-overflow-tooltip />
<el-table-column prop="year" label="年份" width="100" align="center" />
<el-table-column label="证明材料" width="120" align="center">
<template #default="scope">
<el-button v-if="scope.row.attachment && scope.row.attachment !== ''" type="primary" link icon="Document" @click="showEdvince(scope.row)"
>查看
</el-button>
<span v-else>-</span>
</template>
</el-table-column>
<el-table-column label="操作" width="280" align="center" fixed="right">
<template #default="scope">
<el-button
v-if="hasAuth('professional_professionalteacherhonor_edit') && (scope.row.state === '0' || scope.row.state === '-2')"
type="primary"
link
icon="edit-pen"
@click="handleEdit(scope.row)"
>修改
</el-button>
<el-button
v-if="hasAuth('professional_professionalteacherhonor_exam') && scope.row.canExam"
type="success"
link
icon="CircleCheck"
@click="changeState(scope.row, 1)"
>通过
</el-button>
<el-button
v-if="hasAuth('professional_professionalteacherhonor_exam') && scope.row.canDeptExam"
type="success"
link
icon="CircleCheck"
@click="changeState(scope.row, 1)"
>部门通过
</el-button>
<el-button
v-if="hasAuth('professional_professionalteacherhonor_exam') && scope.row.canBack"
type="danger"
link
icon="CircleClose"
@click="changeState(scope.row, -2)"
>驳回
</el-button>
<el-button
v-if="hasAuth('professional_professionalteacherhonor_exam') && scope.row.canDeptBack"
type="danger"
link
icon="CircleClose"
@click="changeState(scope.row, -2)"
>部门驳回
</el-button>
<el-button v-if="hasAuth('professional_professionalteacherhonor_del')" type="danger" link icon="delete" @click="handleDel(scope.row)"
>删除
</el-button>
</template>
</el-table-column>
</el-table>
<!-- 分页 -->
<pagination v-bind="state.pagination" @current-change="currentChangeHandle" @size-change="sizeChangeHandle" />
<!-- 材料预览图片直接显示PDF 在组件内部 dialog 中显示 -->
<preview-file v-for="src in imgUrl" :key="src.title" :authSrc="src.url" dialog-title="综合表彰材料" />
<!-- 子组件 -->
<ProfessionalBackResaon ref="backReasonRef" @refreshData="handleFilter" />
<DataForm ref="dataFormRef" @refreshData="handleFilter" />
<import-teacher-other-info ref="importTeacherOtherInfoRef" @refreshData="handleFilter" />
</div>
</div>
</template>
<script setup lang="ts">
import { ref, reactive, nextTick } from 'vue'
import { BasicTableProps, useTable } from '/@/hooks/table'
import { useAuth } from '/@/hooks/auth'
import { useMessage } from '/@/hooks/message'
import { useMessageBox } from '/@/hooks/message'
import { useDict } from '/@/hooks/dict'
import {
fetchList,
examObj,
delObj
} from '/@/api/professional/professionaluser/professionalteacherhonor'
import { PROFESSIONAL_AUDIT_STATE_OPTIONS, getStatusConfig } from '/@/config/global'
import { defineAsyncComponent } from 'vue'
import {makeExportTeacherInfoByTypeTask} from "/@/api/professional/professionalfile";
const TeacherNameNo = defineAsyncComponent(() => import('/@/components/TeacherNameNo/index.vue'))
const AuditState = defineAsyncComponent(() => import('/@/components/AuditState/index.vue'))
const ClickableTag = defineAsyncComponent(() => import('/@/components/ClickableTag/index.vue'))
const DetailPopover = defineAsyncComponent(() => import('/@/components/DetailPopover/index.vue'))
const ProfessionalBackResaon = defineAsyncComponent(() => import('/@/views/professional/common/professional-back-resaon.vue'))
const DataForm = defineAsyncComponent(() => import('./form.vue'))
const previewFile = defineAsyncComponent(() => import('/@/components/tools/preview-file.vue'))
const ImportTeacherOtherInfo = defineAsyncComponent(() => import('/@/views/professional/common/import-teacher-other-info.vue'))
import { ref, reactive, nextTick } from 'vue';
import { BasicTableProps, useTable } from '/@/hooks/table';
import { useAuth } from '/@/hooks/auth';
import { useMessage } from '/@/hooks/message';
import { useMessageBox } from '/@/hooks/message';
import { useDict } from '/@/hooks/dict';
import { fetchList, examObj, delObj } from '/@/api/professional/professionaluser/professionalteacherhonor';
import { PROFESSIONAL_AUDIT_STATE_OPTIONS, getStatusConfig } from '/@/config/global';
import { defineAsyncComponent } from 'vue';
import { makeExportTeacherInfoByTypeTask } from '/@/api/professional/professionalfile';
const TeacherNameNo = defineAsyncComponent(() => import('/@/components/TeacherNameNo/index.vue'));
const AuditState = defineAsyncComponent(() => import('/@/components/AuditState/index.vue'));
const ClickableTag = defineAsyncComponent(() => import('/@/components/ClickableTag/index.vue'));
const DetailPopover = defineAsyncComponent(() => import('/@/components/DetailPopover/index.vue'));
const ProfessionalBackResaon = defineAsyncComponent(() => import('/@/views/professional/common/professional-back-resaon.vue'));
const DataForm = defineAsyncComponent(() => import('./form.vue'));
const previewFile = defineAsyncComponent(() => import('/@/components/tools/preview-file.vue'));
const ImportTeacherOtherInfo = defineAsyncComponent(() => import('/@/views/professional/common/import-teacher-other-info.vue'));
// 消息提示 hooks
const message = useMessage()
const messageBox = useMessageBox()
const message = useMessage();
const messageBox = useMessageBox();
// 字典数据
const { professional_state: professionalState } = useDict('professional_state')
const { professional_state: professionalState } = useDict('professional_state');
// 审核状态选项
const auditStateOptions = PROFESSIONAL_AUDIT_STATE_OPTIONS
const auditStateOptions = PROFESSIONAL_AUDIT_STATE_OPTIONS;
// 审核状态转 ClickableTag 配置(用 options 的 icon 字符串,与 AuditState 一致为实心)
const getAuditStateTagConfig = (state: string | number) => {
const opt = getStatusConfig(auditStateOptions, state)
if (!opt) return null
return { type: opt.type, label: opt.label, leftIcon: opt.icon, effect: opt.effect || 'dark' }
}
const opt = getStatusConfig(auditStateOptions, state);
if (!opt) return null;
return { type: opt.type, label: opt.label, leftIcon: opt.icon, effect: opt.effect || 'dark' };
};
// 无权限即无节点
const { hasAuth } = useAuth()
const { hasAuth } = useAuth();
// 表格引用
const tableRef = ref()
const searchFormRef = ref()
const backReasonRef = ref()
const dataFormRef = ref()
const showSearch = ref(true)
const tableRef = ref();
const searchFormRef = ref();
const backReasonRef = ref();
const dataFormRef = ref();
const showSearch = ref(true);
// 搜索表单数据
const search = reactive({
state: '',
teacherNo: '',
teacherName: ''
})
state: '',
teacherNo: '',
teacherName: '',
});
// 材料预览
const imgUrl = ref<Array<{ title: string; url: string }>>([])
const imgUrl = ref<Array<{ title: string; url: string }>>([]);
// 导出加载状态
const exportLoading = ref(false)
const importTeacherOtherInfoRef = ref()
const exportLoading = ref(false);
const importTeacherOtherInfoRef = ref();
// 配置 useTable
const state: BasicTableProps = reactive<BasicTableProps>({
pageList: async (params: any) => {
const response = await fetchList(params)
return {
data: {
records: response.data.records || [],
total: response.data.total || 0
}
}
},
queryForm: search
})
pageList: async (params: any) => {
const response = await fetchList(params);
return {
data: {
records: response.data.records || [],
total: response.data.total || 0,
},
};
},
queryForm: search,
});
const { getDataList, currentChangeHandle, sizeChangeHandle, tableStyle } = useTable(state)
const { getDataList, currentChangeHandle, sizeChangeHandle, tableStyle } = useTable(state);
// 查看证明材料:构造预览列表,交给 auth-img 处理
const showEdvince = (row: any) => {
imgUrl.value = []
nextTick(() => {
const list = row.attachment ? [row.attachment] : []
list.forEach(v => {
imgUrl.value.push({
title: '',
url: v
})
})
})
}
imgUrl.value = [];
nextTick(() => {
const list = row.attachment ? [row.attachment] : [];
list.forEach((v) => {
imgUrl.value.push({
title: '',
url: v,
});
});
});
};
// 审核状态变更
const changeState = (row: any, val: number) => {
if (val === 1) {
// 通过
const str = '通过'
messageBox.confirm(`是否确认${str}${row.teacherName || row.realName}的申请`).then(async () => {
try {
await examObj({
id: row.id,
state: val
})
message.success('操作成功')
getDataList()
} catch (error: any) {
// 处理业务错误
message.error(error.msg)
}
}).catch(() => {})
} else if (val === -2) {
// 驳回
const newRow = JSON.parse(JSON.stringify(row))
backReasonRef.value?.init(newRow, 'honor')
}
}
if (val === 1) {
// 通过
const str = '通过';
messageBox
.confirm(`是否确认${str}${row.teacherName || row.realName}的申请`)
.then(async () => {
try {
await examObj({
id: row.id,
state: val,
});
message.success('操作成功');
getDataList();
} catch (error: any) {
// 处理业务错误
message.error(error.msg);
}
})
.catch(() => {});
} else if (val === -2) {
// 驳回
const newRow = JSON.parse(JSON.stringify(row));
backReasonRef.value?.init(newRow, 'honor');
}
};
// 查询
const handleFilter = () => {
getDataList()
}
getDataList();
};
// 重置查询
const resetQuery = () => {
Object.assign(search, {
state: '',
teacherNo: '',
teacherName: ''
})
getDataList()
}
Object.assign(search, {
state: '',
teacherNo: '',
teacherName: '',
});
getDataList();
};
// 打开新增窗口
const handleAdd = () => {
dataFormRef.value?.openDialog()
}
dataFormRef.value?.openDialog();
};
// 打开编辑窗口
const handleEdit = (row: any) => {
dataFormRef.value?.openDialog(row)
}
dataFormRef.value?.openDialog(row);
};
// 删除
const handleDel = (row: any) => {
messageBox.confirm('是否确认删除该条记录').then(async () => {
try {
await delObj(row.id)
message.success('删除成功')
// 如果当前页只剩一条数据,且不是第一页,则跳转到上一页
if (state.pagination && state.dataList && state.dataList.length === 1 && state.pagination.current && state.pagination.current > 1) {
state.pagination.current = state.pagination.current - 1
}
getDataList()
} catch (error: any) {
// 处理业务错误
message.error(error.msg)
}
}).catch(() => {})
}
messageBox
.confirm('是否确认删除该条记录')
.then(async () => {
try {
await delObj(row.id);
message.success('删除成功');
// 如果当前页只剩一条数据,且不是第一页,则跳转到上一页
if (state.pagination && state.dataList && state.dataList.length === 1 && state.pagination.current && state.pagination.current > 1) {
state.pagination.current = state.pagination.current - 1;
}
getDataList();
} catch (error: any) {
// 处理业务错误
message.error(error.msg);
}
})
.catch(() => {});
};
// 导出
const handleDownLoadWord = async () => {
exportLoading.value = true;
let params = Object.assign(search, { type: 'P20006' });
makeExportTeacherInfoByTypeTask(params).then((res: any) => {
message.success('后台下载进行中,请稍后查看任务列表');
});
setTimeout(() => {
exportLoading.value = false;
}, 3000); // 5分钟后自动关闭
}
exportLoading.value = true;
let params = Object.assign(search, { type: 'P20006' });
makeExportTeacherInfoByTypeTask(params).then((res: any) => {
message.success('后台下载进行中,请稍后查看任务列表');
});
setTimeout(() => {
exportLoading.value = false;
}, 3000); // 5分钟后自动关闭
};
// 打开导入弹窗
const handleImportDialog = () => {
importTeacherOtherInfoRef.value?.init('honor')
}
importTeacherOtherInfoRef.value?.init('honor');
};
// 表格数据由 useTablecreatedIsNeed 默认 true在挂载时自动请求
</script>
@@ -415,27 +373,27 @@ const handleImportDialog = () => {
<style lang="scss" scoped>
/* 驳回理由展示(与 backSchoolCheckin 一致) */
.reason-content {
display: flex;
align-items: flex-start;
gap: 8px;
padding: 8px 12px;
background-color: #fef0f0;
border-radius: 4px;
border-left: 3px solid #f56c6c;
display: flex;
align-items: flex-start;
gap: 8px;
padding: 8px 12px;
background-color: #fef0f0;
border-radius: 4px;
border-left: 3px solid #f56c6c;
.reason-icon {
color: #f56c6c;
font-size: 16px;
flex-shrink: 0;
margin-top: 2px;
}
.reason-icon {
color: #f56c6c;
font-size: 16px;
flex-shrink: 0;
margin-top: 2px;
}
span {
color: #f56c6c;
font-size: 13px;
line-height: 1.6;
word-break: break-all;
flex: 1;
}
span {
color: #f56c6c;
font-size: 13px;
line-height: 1.6;
word-break: break-all;
flex: 1;
}
}
</style>