This commit is contained in:
zhoutianchi
2026-02-06 16:14:20 +08:00
parent 020468c6f1
commit 4403299835
2 changed files with 319 additions and 242 deletions

View File

@@ -0,0 +1,101 @@
<template>
<el-dialog v-model="visible" :title="title" width="600" append-to-body>
<div style="text-align: center; margin-bottom: 20px">
<el-button type="success" :icon="Download" @click="handleDownloadTemplate">下载模板</el-button>
</div>
<el-upload
class="upload-demo"
:action="uploadUrl"
:headers="headers"
:accept="'.xls,.xlsx'"
:on-success="handleUploadSuccess"
:on-error="handleAvatarError"
:limit="1"
drag
>
<el-icon class="el-icon--upload"><upload-filled /></el-icon>
<div class="el-upload__text">将文件拖到此处<em>点击上传</em></div>
<template #tip>
<div class="el-upload__tip">只能上传 .xls .xlsx 格式的 Excel 文件</div>
</template>
</el-upload>
</el-dialog>
</template>
<script setup lang="ts">
import { ref, computed } from 'vue';
import { ElNotification } from 'element-plus';
import { Download, UploadFilled } from '@element-plus/icons-vue';
import { Session } from '/@/utils/storage';
import { downBlobFile } from '/@/utils/other';
const title = ref('');
// 响应式数据
const visible = ref(false);
// 计算属性
const headers = computed(() => {
return {
Authorization: 'Bearer ' + Session.getToken(),
TENANT_ID: Session.getTenant()
};
});
const uploadUrl = ref('')
const currentType = ref('')
const titleMap: Record<string, string> = {
planMajor: '计划专业导入'
}
// 方法
const init = (type: any) => {
currentType.value = type
uploadUrl.value = '/professional/file/importTeacherOtherInfo?type=' + type
title.value = titleMap[type] || '信息导入'
visible.value = true
}
// Emits
const emit = defineEmits<{
(e: 'refreshData'): void
}>()
const handleUploadSuccess = () => {
visible.value = false;
ElNotification({
title: '成功',
message: '导入成功',
type: 'success',
});
emit('refreshData')
};
const handleAvatarError = (err: any) => {
const result = JSON.parse(err.message);
if (result.code == '1') {
ElNotification.error({
title: '错误',
message: result.msg,
duration: 30000,
});
}
};
const handleDownloadTemplate = () => {
downBlobFile('/recruit/file/exportRecruitTemplate', { type: currentType.value || 'planMajor' }, title.value+'模板.xlsx')
}
// 暴露方法给父组件
defineExpose({
init
});
</script>
<style scoped lang="scss">
.upload-demo {
:deep(.el-upload-dragger) {
width: 100%;
}
}
</style>

View File

@@ -22,22 +22,12 @@
<el-form :model="queryForm" inline ref="searchFormRef">
<el-form-item label="招生计划" prop="groupId">
<el-select v-model="queryForm.groupId" filterable clearable placeholder="请选择招生计划">
<el-option
v-for="item in planList"
:key="item.id"
:label="item.groupName"
:value="item.id"
/>
<el-option v-for="item in planList" :key="item.id" :label="item.groupName" :value="item.id" />
</el-select>
</el-form-item>
<el-form-item label="学院" prop="deptCode">
<el-select v-model="queryForm.deptCode" filterable clearable placeholder="请选择">
<el-option
v-for="item in deptList"
:key="item.deptCode"
:label="item.deptName"
:value="item.deptCode"
/>
<el-option v-for="item in deptList" :key="item.deptCode" :label="item.deptName" :value="item.deptCode" />
</el-select>
</el-form-item>
<el-form-item label="专业序号" prop="majorCode">
@@ -57,13 +47,16 @@
<!-- 操作按钮 -->
<div class="mb15">
<el-button v-if="hasAuth('recruit_recruitplanmajor_add')" type="primary" icon="FolderAdd" @click="addOrUpdateHandle"> </el-button>
<el-button
v-if="hasAuth('recruit_recruitplanmajor_add')"
v-auth="'professional_teacherinfo_import'"
type="primary"
icon="FolderAdd"
@click="addOrUpdateHandle"
>
plain
icon="UploadFilled"
:loading="exportLoading"
@click="handleImportDialog"
>导入信息
</el-button>
</div>
@@ -101,14 +94,7 @@
<el-table-column prop="sm" label="色盲不可录" align="center" width="120">
<template #default="scope">
<el-switch
v-model="scope.row.sm"
active-text=""
inactive-text=""
active-value="1"
inactive-value="0"
@change="changeSm(scope.row)"
/>
<el-switch v-model="scope.row.sm" active-text="是" inactive-text="否" active-value="1" inactive-value="0" @change="changeSm(scope.row)" />
</template>
</el-table-column>
<el-table-column prop="stuworkMajorCode" label="正式专业代码" align="center" show-overflow-tooltip>
@@ -124,21 +110,8 @@
<!-- <el-table-column prop="sort" label="排序" align="center" show-overflow-tooltip /> -->
<el-table-column label="操作" width="150" align="center" fixed="right">
<template #default="scope">
<el-button
type="primary"
link
icon="EditPen"
@click="addOrUpdateHandle(scope.row)"
>
修改
</el-button>
<el-button
v-if="hasAuth('recruit_recruitplanmajor_del')"
type="danger"
link
icon="Delete"
@click="deleteHandle(scope.row.id)"
>
<el-button type="primary" link icon="EditPen" @click="addOrUpdateHandle(scope.row)"> 修改 </el-button>
<el-button v-if="hasAuth('recruit_recruitplanmajor_del')" type="danger" link icon="Delete" @click="deleteHandle(scope.row.id)">
删除
</el-button>
</template>
@@ -146,47 +119,47 @@
</el-table>
<!-- 分页 -->
<pagination
v-bind="state.pagination"
@current-change="currentChangeHandle"
@size-change="sizeChangeHandle"
/>
<pagination v-bind="state.pagination" @current-change="currentChangeHandle" @size-change="sizeChangeHandle" />
<!-- 弹窗, 新增 / 修改 -->
<table-form ref="addOrUpdateRef" @refreshDataList="getDataList" />
<import-recruit-info ref="ImportRecruitInfoRef"></import-recruit-info>
</div>
</div>
</template>
<script setup lang="ts" name="recruitplanmajor">
import { ref, reactive, onMounted, nextTick, defineAsyncComponent } from 'vue'
import { useAuth } from '/@/hooks/auth'
import { BasicTableProps, useTable } from '/@/hooks/table'
import { useMessage, useMessageBox } from '/@/hooks/message'
import { useDict } from '/@/hooks/dict'
import { getList } from '/@/api/recruit/recruitstudentplangroup'
import { fetchList, delObj, editQuickField } from '/@/api/recruit/recruitstudentplan'
import { getDeptList } from '/@/api/basic/basicclass'
import { getMajorNameList } from '/@/api/basic/major'
import { ref, reactive, onMounted, nextTick, defineAsyncComponent } from 'vue';
import { useAuth } from '/@/hooks/auth';
import { BasicTableProps, useTable } from '/@/hooks/table';
import { useMessage, useMessageBox } from '/@/hooks/message';
import { useDict } from '/@/hooks/dict';
import { getList } from '/@/api/recruit/recruitstudentplangroup';
import { fetchList, delObj, editQuickField } from '/@/api/recruit/recruitstudentplan';
import { getDeptList } from '/@/api/basic/basicclass';
import { getMajorNameList } from '/@/api/basic/major';
const TableForm = defineAsyncComponent(() => import('./detaiform.vue'))
const { hasAuth } = useAuth()
const TableForm = defineAsyncComponent(() => import('./detaiform.vue'));
const ImportRecruitInfo = defineAsyncComponent(() => import('/@/views/recruit/common/import-recruit-info.vue'));
const ImportRecruitInfoRef=ref<any>();
const { hasAuth } = useAuth();
// 消息提示 hooks
const message = useMessage()
const messageBox = useMessageBox()
const message = useMessage();
const messageBox = useMessageBox();
// 表格引用
const tableRef = ref()
const searchFormRef = ref()
const addOrUpdateRef = ref()
const tableRef = ref();
const searchFormRef = ref();
const addOrUpdateRef = ref();
// 字典数据
const { yes_no_type } = useDict('yes_no_type')
const { yes_no_type } = useDict('yes_no_type');
// 数据
const planList = ref<any[]>([])
const deptList = ref<any[]>([])
const offcialZydmList = ref<any[]>([])
const planList = ref<any[]>([]);
const deptList = ref<any[]>([]);
const offcialZydmList = ref<any[]>([]);
// 查询表单
const queryForm = reactive({
@@ -194,125 +167,128 @@ const queryForm = reactive({
deptCode: '',
majorCode: '',
majorName: '',
learnYear: ''
})
learnYear: '',
});
// 获取计划名称
const getPlanName = (groupId: string) => {
const item = planList.value.find(item => item.id === groupId)
return item ? item.groupName : ''
}
const item = planList.value.find((item) => item.id === groupId);
return item ? item.groupName : '';
};
// 获取学院名称
const getDeptName = (deptCode: string) => {
const item = deptList.value.find(item => item.deptCode === deptCode)
return item ? item.deptName : ''
}
const item = deptList.value.find((item) => item.deptCode === deptCode);
return item ? item.deptName : '';
};
// 获取是/否标签
const getYesNoLabel = (value: string) => {
const item = yes_no_type.value.find((item: any) => item.value === value)
return item ? item.label : ''
}
const item = yes_no_type.value.find((item: any) => item.value === value);
return item ? item.label : '';
};
// 获取专业代码名称
const getMajorCodeName = (majorCode: string) => {
const item = offcialZydmList.value.find(item => item.majorCode === majorCode)
return item ? item.majorCodeAndName : ''
}
const item = offcialZydmList.value.find((item) => item.majorCode === majorCode);
return item ? item.majorCodeAndName : '';
};
// 表格状态
const state: BasicTableProps = reactive<BasicTableProps>({
queryForm: queryForm,
pageList: async (params: any) => {
const response = await fetchList(params)
const response = await fetchList(params);
return {
data: {
records: response.data.records,
total: response.data.total
}
}
total: response.data.total,
},
createdIsNeed: false
})
};
},
createdIsNeed: false,
});
// 使用 table hook
const { getDataList, currentChangeHandle, sizeChangeHandle, tableStyle } = useTable(state)
const { getDataList, currentChangeHandle, sizeChangeHandle, tableStyle } = useTable(state);
// 初始化
const init = async () => {
try {
// 查询二级学院信息
const deptData = await getDeptList()
deptList.value = deptData.data || []
const deptData = await getDeptList();
deptList.value = deptData.data || [];
// 获取招生计划列表
const planData = await getList()
planList.value = planData.data || []
const planData = await getList();
planList.value = planData.data || [];
if (planList.value.length > 0) {
queryForm.groupId = planList.value[0].id
queryForm.groupId = planList.value[0].id;
}
// 获取专业名称列表
const majorData = await getMajorNameList()
offcialZydmList.value = majorData.data || []
const majorData = await getMajorNameList();
offcialZydmList.value = majorData.data || [];
getDataList()
getDataList();
} catch (error) {
console.log(error)
console.log(error);
}
}
};
// 修改开关
const changeSm = async (row: any) => {
try {
let parmas={id:row.id,sm:row.sm}
await editQuickField(parmas)
message.success('修改成功')
let parmas = { id: row.id, sm: row.sm };
await editQuickField(parmas);
message.success('修改成功');
} catch (error: any) {
console.log(error)
console.log(error);
}
}
};
// 新增 / 修改
const addOrUpdateHandle = (row?: any) => {
nextTick(() => {
addOrUpdateRef.value?.init(row.id || null)
})
}
addOrUpdateRef.value?.init(row.id || null);
});
};
// 删除
const deleteHandle = async (id: string) => {
try {
await messageBox.confirm('是否确认删除本条数据?请谨慎操作')
await delObj(id)
message.success('删除成功')
getDataList()
await messageBox.confirm('是否确认删除本条数据?请谨慎操作');
await delObj(id);
message.success('删除成功');
getDataList();
} catch {
// 用户取消
}
}
};
// 重置查询
const resetQuery = () => {
searchFormRef.value?.resetFields()
queryForm.groupId = ''
queryForm.deptCode = ''
queryForm.majorCode = ''
queryForm.majorName = ''
queryForm.learnYear = ''
searchFormRef.value?.resetFields();
queryForm.groupId = '';
queryForm.deptCode = '';
queryForm.majorCode = '';
queryForm.majorName = '';
queryForm.learnYear = '';
if (planList.value.length > 0) {
queryForm.groupId = planList.value[0].id
queryForm.groupId = planList.value[0].id;
}
getDataList()
}
getDataList();
};
const exportLoading = ref(false);
const handleImportDialog = () => {
ImportRecruitInfoRef.value?.init("planMajor");
};
onMounted(() => {
init()
})
init();
});
</script>
<style lang="scss" scoped>
</style>
<style lang="scss" scoped></style>