a
This commit is contained in:
161
src/views/professional/common/professional-back-resaon.vue
Normal file
161
src/views/professional/common/professional-back-resaon.vue
Normal file
@@ -0,0 +1,161 @@
|
||||
<template>
|
||||
<el-dialog v-model="visible" title="驳回" width="600px" :close-on-click-modal="false" destroy-on-close>
|
||||
<el-form label-width="150px">
|
||||
<el-form-item label="姓名:">
|
||||
<el-tag>{{ dataForm.name }}</el-tag>
|
||||
</el-form-item>
|
||||
<el-form-item label="工号:">
|
||||
<el-tag>{{ dataForm.teacherNo }}</el-tag>
|
||||
</el-form-item>
|
||||
<el-form-item label="类型:">
|
||||
<el-tag>{{ typeName }}</el-tag>
|
||||
</el-form-item>
|
||||
<el-form-item label="驳回理由">
|
||||
<el-input
|
||||
type="textarea"
|
||||
v-model="dataForm.backReason"
|
||||
:rows="4"
|
||||
placeholder="请输入驳回理由"
|
||||
maxlength="500"
|
||||
show-word-limit
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button @click="visible = false">关 闭</el-button>
|
||||
<el-button @click="saveData" :loading="loading" type="primary">保 存</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive } from 'vue'
|
||||
import { useMessage, useMessageBox } from '/@/hooks/message'
|
||||
import { putObj as editTitle } from '/@/api/professional/professionaluser/professionaltitlerelation'
|
||||
import { putObj as editQua } from '/@/api/professional/professionaluser/professionalqualificationrelation'
|
||||
import { putObj as editCer } from '/@/api/professional/professionaluser/professionalteachercertificaterelation'
|
||||
import { putObj as editEducation } from '/@/api/professional/professionaluser/professionalteacheracademicrelation'
|
||||
import { putObj as editHonor } from '/@/api/professional/professionaluser/professionalteacherhonor'
|
||||
import { putObj as editPaper } from '/@/api/professional/professionalteacherpaper'
|
||||
import { putObj as editMaterial } from '/@/api/professional/professionalteachingmaterial'
|
||||
import { putObj as editTopic } from '/@/api/professional/professionaltopiclist'
|
||||
|
||||
// Emits
|
||||
const emit = defineEmits<{
|
||||
(e: 'refreshData'): void
|
||||
}>()
|
||||
|
||||
// 消息提示
|
||||
const message = useMessage()
|
||||
const messageBox = useMessageBox()
|
||||
|
||||
// 对话框显示状态
|
||||
const visible = ref(false)
|
||||
|
||||
// 加载状态
|
||||
const loading = ref(false)
|
||||
|
||||
// 表单数据
|
||||
const dataForm = reactive({
|
||||
name: '',
|
||||
id: null as string | number | null,
|
||||
backReason: '',
|
||||
teacherNo: ''
|
||||
})
|
||||
|
||||
// 类型名称
|
||||
const typeName = ref('')
|
||||
|
||||
// 类型
|
||||
const type = ref('')
|
||||
|
||||
// 类型映射
|
||||
const typeMap: Record<string, string> = {
|
||||
title: '职称',
|
||||
qua: '职业资格',
|
||||
cer: '教师资格证',
|
||||
education: '学历学位',
|
||||
honor: '综合表彰',
|
||||
paper: '教师论文',
|
||||
material: '教材',
|
||||
topic: '课题'
|
||||
}
|
||||
|
||||
// API 方法映射
|
||||
const apiMethodMap: Record<string, any> = {
|
||||
title: editTitle,
|
||||
qua: editQua,
|
||||
cer: editCer,
|
||||
education: editEducation,
|
||||
honor: editHonor,
|
||||
paper: editPaper,
|
||||
material: editMaterial,
|
||||
topic: editTopic
|
||||
}
|
||||
|
||||
// 初始化
|
||||
const init = (row: any, typeValue: string) => {
|
||||
type.value = typeValue
|
||||
typeName.value = typeMap[typeValue] || ''
|
||||
dataForm.name = row.realName || ''
|
||||
dataForm.teacherNo = row.teacherNo || ''
|
||||
dataForm.id = row.id || null
|
||||
dataForm.backReason = ''
|
||||
visible.value = true
|
||||
}
|
||||
|
||||
// 保存数据
|
||||
const saveData = async () => {
|
||||
if (!dataForm.backReason.trim()) {
|
||||
message.warning('请填写驳回理由')
|
||||
return
|
||||
}
|
||||
|
||||
const apiMethod = apiMethodMap[type.value]
|
||||
if (!apiMethod) {
|
||||
message.error('未知的类型')
|
||||
return
|
||||
}
|
||||
|
||||
await saveDataMethod(apiMethod)
|
||||
}
|
||||
|
||||
// 保存数据方法
|
||||
const saveDataMethod = async (method: any) => {
|
||||
const data = {
|
||||
id: dataForm.id,
|
||||
state: '-2',
|
||||
backReason: dataForm.backReason
|
||||
}
|
||||
|
||||
try {
|
||||
await messageBox.confirm(`确认驳回, ${dataForm.name}的${typeName.value}申请?`)
|
||||
loading.value = true
|
||||
await method(data)
|
||||
message.success('操作成功')
|
||||
visible.value = false
|
||||
emit('refreshData')
|
||||
} catch (error: any) {
|
||||
// 用户取消或请求失败
|
||||
if (error !== 'cancel') {
|
||||
message.error(error?.msg || '操作失败')
|
||||
}
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 暴露方法
|
||||
defineExpose({
|
||||
init
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.dialog-footer {
|
||||
text-align: right;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user