添加老师排序

This commit is contained in:
YuNan 2025-03-11 20:30:57 +08:00
parent 1416ffced7
commit 22a68dae35
3 changed files with 329 additions and 294 deletions

View File

@ -2,9 +2,9 @@ import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table'; import { FormSchema } from '/@/components/Table';
import { rules } from '/@/utils/helper/validator'; import { rules } from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils'; import { render } from '/@/utils/common/renderUtils';
import { ref, onMounted,reactive } from 'vue'; import { ref, onMounted, reactive } from 'vue';
const groupOptions=ref() const groupOptions = ref();
// 创建一个简单的事件总线 // 创建一个简单的事件总线
export const updateGroupOptions = reactive({ export const updateGroupOptions = reactive({
updateGroupOptions(newOptions: any) { updateGroupOptions(newOptions: any) {
@ -17,34 +17,39 @@ export const columns: BasicColumn[] = [
{ {
title: '姓名', title: '姓名',
align: 'center', align: 'center',
sorter: true,
dataIndex: 'userName', dataIndex: 'userName',
}, },
{ {
title: '用户ID', title: '用户ID',
align: 'center', align: 'center',
sorter: true,
dataIndex: 'userId', dataIndex: 'userId',
}, },
{ {
title: '工号', title: '工号',
align: 'center', align: 'center',
sorter: true,
dataIndex: 'teacherId', dataIndex: 'teacherId',
}, },
{ {
title: '手机号', title: '手机号',
align: 'center', align: 'center',
sorter: true,
dataIndex: 'phone', dataIndex: 'phone',
}, },
{ {
title: '学科', title: '学科',
align: 'center', align: 'center',
dataIndex: 'majorId' sorter: true,
dataIndex: 'majorId',
}, },
{ {
title: '所属分组', title: '所属分组',
align: 'center', align: 'center',
//dataIndex: 'groupId', //dataIndex: 'groupId',
customRender: ({ text }) => { customRender: ({ text }) => {
const group = groupOptions.value.find(item => item.value === text.groupId); const group = groupOptions.value.find((item) => item.value === text.groupId);
if (group) { if (group) {
return group.label; return group.label;
} }
@ -54,6 +59,7 @@ export const columns: BasicColumn[] = [
{ {
title: '是否第一次阅卷', title: '是否第一次阅卷',
align: 'center', align: 'center',
sorter: true,
dataIndex: 'status', dataIndex: 'status',
}, },
//{ //{
@ -62,13 +68,11 @@ export const columns: BasicColumn[] = [
// dataIndex: 'userMajorId', // dataIndex: 'userMajorId',
//}, //},
//{ //{
// title: '使用次数', // title: '使用次数',
// align: 'center', // align: 'center',
// dataIndex: 'numberuse', // dataIndex: 'numberuse',
//}, //},
]; ];
//查询数据 //查询数据
export const searchFormSchema: FormSchema[] = [ export const searchFormSchema: FormSchema[] = [
@ -90,7 +94,7 @@ export const searchFormSchema: FormSchema[] = [
{ label: '政治', value: 8 }, { label: '政治', value: 8 },
], ],
}, },
} },
]; ];
//表单数据 //表单数据
export const formSchema: FormSchema[] = [ export const formSchema: FormSchema[] = [

View File

@ -18,41 +18,49 @@ export const columns: BasicColumn[] = [
{ {
title: '姓名', title: '姓名',
align: 'center', align: 'center',
sorter: true,
dataIndex: 'userName', dataIndex: 'userName',
}, },
{ {
title: '用户ID', title: '用户ID',
align: 'center', align: 'center',
sorter: true,
dataIndex: 'userId', dataIndex: 'userId',
}, },
{ {
title: '年龄', title: '年龄',
align: 'center', align: 'center',
sorter: true,
dataIndex: 'age', dataIndex: 'age',
}, },
{ {
title: '性别', title: '性别',
align: 'center', align: 'center',
sorter: true,
dataIndex: 'sex', dataIndex: 'sex',
}, },
{ {
title: '学科', title: '学科',
align: 'center', align: 'center',
dataIndex: 'majorId' sorter: true,
dataIndex: 'majorId',
}, },
{ {
title: '手机号', title: '手机号',
align: 'center', align: 'center',
sorter: true,
dataIndex: 'phone', dataIndex: 'phone',
}, },
{ {
title: '职称', title: '职称',
align: 'center', align: 'center',
sorter: true,
dataIndex: 'jobTitle', dataIndex: 'jobTitle',
}, },
{ {
title: '职务', title: '职务',
align: 'center', align: 'center',
sorter: true,
dataIndex: 'office', dataIndex: 'office',
}, },
{ {

View File

@ -1,8 +1,15 @@
<template> <template>
<div> <div>
<!--引用表格--> <!--引用表格-->
<BasicTable @register="registerTable" :rowSelection="rowSelection" ref="tableRef" :expandedRowKeys="expandedKeys" <BasicTable
rowKey="id" :expandedRowRender="renderExpandedRow" @expand="handleExpand"> @register="registerTable"
:rowSelection="rowSelection"
ref="tableRef"
:expandedRowKeys="expandedKeys"
rowKey="id"
:expandedRowRender="renderExpandedRow"
@expand="handleExpand"
>
<!--插槽:table标题--> <!--插槽:table标题-->
<template #tableTitle> <template #tableTitle>
<a-button type="primary" @click="handleAdd" preIcon="ant-design:plus-outlined"> 新增</a-button> <a-button type="primary" @click="handleAdd" preIcon="ant-design:plus-outlined"> 新增</a-button>
@ -17,7 +24,8 @@
</a-menu-item> </a-menu-item>
</a-menu> </a-menu>
</template> </template>
<a-button>批量操作 <a-button
>批量操作
<Icon icon="mdi:chevron-down" /> <Icon icon="mdi:chevron-down" />
</a-button> </a-button>
</a-dropdown> </a-dropdown>
@ -52,16 +60,21 @@
</span> </span>
<span v-if="column.dataIndex === 'dormitoryName'"> <span v-if="column.dataIndex === 'dormitoryName'">
<!-- 选择逻辑存在问题使placeholder没办法显示 --> <!-- 选择逻辑存在问题使placeholder没办法显示 -->
<a-select placeholder="请选择" size="small" style="width: 120px" v-model:value="record.dormitoryName" <a-select
:disabled="record.dormitoryId != null" @focus="handleFocus(record.sex, record)" placeholder="请选择"
@change="handleChange(record.userId, record.dormitoryName, record)" filterables> size="small"
style="width: 120px"
v-model:value="record.dormitoryName"
:disabled="record.dormitoryName != null"
@focus="handleFocus(record.sex, record)"
@change="handleChange(record.userId, record.dormitoryName, record)"
filterables
>
<template v-if="dormOptions.length === 0"> <template v-if="dormOptions.length === 0">
<a-option value="" label="加载中..." disabled /> <a-option value="" label="加载中..." disabled />
</template> </template>
<a-select-option v-for="item in dormOptions" :key="item.value" :label="item.label" :value="item.value">{{ <a-select-option v-for="item in dormOptions" :key="item.value" :label="item.label" :value="item.value">{{ item.label }}</a-select-option>
item.label
}}</a-select-option>
<template v-if="dormOptions.length === 0"> <template v-if="dormOptions.length === 0">
<a-option value="" label="暂无数据" disabled /> <a-option value="" label="暂无数据" disabled />
@ -76,30 +89,40 @@
</template> </template>
<script lang="tsx" name="cees-ceesWaiTeacher" setup> <script lang="tsx" name="cees-ceesWaiTeacher" setup>
import { ref, reactive, computed, unref, onMounted } from 'vue'; import { ref, reactive, computed, unref, onMounted } from 'vue';
import { BasicTable, useTable, TableAction } from '/@/components/Table'; import { BasicTable, useTable, TableAction } from '/@/components/Table';
import { useModal } from '/@/components/Modal'; import { useModal } from '/@/components/Modal';
import { useListPage } from '/@/hooks/system/useListPage'; import { useListPage } from '/@/hooks/system/useListPage';
import CeesWaiTeacherModal from './components/CeesWaiTeacherModal.vue'; import CeesWaiTeacherModal from './components/CeesWaiTeacherModal.vue';
import { columns, searchFormSchema, superQuerySchema, updateGroupOptions } from './CeesWaiTeacher.data'; import { columns, searchFormSchema, superQuerySchema, updateGroupOptions } from './CeesWaiTeacher.data';
import { list, deleteOne, batchDelete, getImportUrl, getExportUrl, getGroup, updateDormitory, cancelCheckIn, confirmCheckIn } from './CeesWaiTeacher.api'; import {
import { selectBySex } from '/@/views/cees/dormitory/CeesDormitoryInfo.api'; list,
import { downloadFile } from '/@/utils/common/renderUtils'; deleteOne,
import { useUserStore } from '/@/store/modules/user'; batchDelete,
const queryParam = reactive<any>({}); getImportUrl,
const checkedKeys = ref<Array<string | number>>([]); getExportUrl,
const userStore = useUserStore(); getGroup,
import { configStyleImportPlugin } from 'build/vite/plugin/styleImport'; updateDormitory,
import { message } from 'ant-design-vue'; cancelCheckIn,
import { registerCoordinateSystem } from 'echarts'; confirmCheckIn,
} from './CeesWaiTeacher.api';
import { selectBySex } from '/@/views/cees/dormitory/CeesDormitoryInfo.api';
import { downloadFile } from '/@/utils/common/renderUtils';
import { useUserStore } from '/@/store/modules/user';
const queryParam = reactive<any>({});
const checkedKeys = ref<Array<string | number>>([]);
const userStore = useUserStore();
import { configStyleImportPlugin } from 'build/vite/plugin/styleImport';
import { message } from 'ant-design-vue';
import { registerCoordinateSystem } from 'echarts';
// //
const dormOptions = ref([]); const dormOptions = ref([]);
//model //model
const [registerModal, { openModal }] = useModal(); const [registerModal, { openModal }] = useModal();
//table //table
const { prefixCls, tableContext, onExportXls, onImportXls } = useListPage({ const { prefixCls, tableContext, onExportXls, onImportXls } = useListPage({
tableProps: { tableProps: {
title: '外校老师管理', title: '外校老师管理',
api: list, api: list,
@ -129,11 +152,11 @@ const { prefixCls, tableContext, onExportXls, onImportXls } = useListPage({
url: getImportUrl, url: getImportUrl,
success: handleSuccess, success: handleSuccess,
}, },
}); });
// rowKey key // rowKey key
const expandedKeys = ref<string[]>(['1']); // const expandedKeys = ref<string[]>(['1']); //
// //
const renderExpandedRow = (record: Record<string, any>) => { const renderExpandedRow = (record: Record<string, any>) => {
return ( return (
<a-descriptions column={2}> <a-descriptions column={2}>
<a-descriptions-item label="身份证号"> {record.record.identityId} </a-descriptions-item> <a-descriptions-item label="身份证号"> {record.record.identityId} </a-descriptions-item>
@ -146,9 +169,9 @@ const renderExpandedRow = (record: Record<string, any>) => {
<a-descriptions-item label="饭卡号"> {record.record.mealCard} </a-descriptions-item> <a-descriptions-item label="饭卡号"> {record.record.mealCard} </a-descriptions-item>
</a-descriptions> </a-descriptions>
); );
}; };
// / expandedKeys // / expandedKeys
const handleExpand = (expanded: boolean, record: Record<string, any>) => { const handleExpand = (expanded: boolean, record: Record<string, any>) => {
console.log('展开/收起', expanded, record); console.log('展开/收起', expanded, record);
if (expanded) { if (expanded) {
if (!expandedKeys.value.includes(record.id)) { if (!expandedKeys.value.includes(record.id)) {
@ -157,13 +180,13 @@ const handleExpand = (expanded: boolean, record: Record<string, any>) => {
} else { } else {
expandedKeys.value = expandedKeys.value.filter((key) => key !== record.id); expandedKeys.value = expandedKeys.value.filter((key) => key !== record.id);
} }
}; };
const [registerTable, { reload }, { rowSelection, selectedRowKeys }] = tableContext; const [registerTable, { reload }, { rowSelection, selectedRowKeys }] = tableContext;
// //
const groupOptions = ref<{ label: string; value: number }[]>([]); const groupOptions = ref<{ label: string; value: number }[]>([]);
onMounted(async () => { onMounted(async () => {
console.log('组件已加载'); console.log('组件已加载');
try { try {
const res = await getGroup(); const res = await getGroup();
@ -177,71 +200,71 @@ onMounted(async () => {
} catch (error) { } catch (error) {
console.error('获取分组数据失败:', error); console.error('获取分组数据失败:', error);
} }
}); });
// //
const superQueryConfig = reactive(superQuerySchema); const superQueryConfig = reactive(superQuerySchema);
/** /**
* 高级查询事件 * 高级查询事件
*/ */
function handleSuperQuery(params) { function handleSuperQuery(params) {
Object.keys(params).map((k) => { Object.keys(params).map((k) => {
queryParam[k] = params[k]; queryParam[k] = params[k];
}); });
reload(); reload();
} }
/** /**
* 新增事件 * 新增事件
*/ */
function handleAdd() { function handleAdd() {
openModal(true, { openModal(true, {
isUpdate: false, isUpdate: false,
showFooter: true, showFooter: true,
}); });
} }
/** /**
* 编辑事件 * 编辑事件
*/ */
function handleEdit(record: Recordable) { function handleEdit(record: Recordable) {
openModal(true, { openModal(true, {
record, record,
isUpdate: true, isUpdate: true,
showFooter: true, showFooter: true,
}); });
} }
/** /**
* 详情 * 详情
*/ */
function handleDetail(record: Recordable) { function handleDetail(record: Recordable) {
openModal(true, { openModal(true, {
record, record,
isUpdate: true, isUpdate: true,
showFooter: false, showFooter: false,
}); });
} }
/** /**
* 删除事件 * 删除事件
*/ */
async function handleDelete(record) { async function handleDelete(record) {
await deleteOne({ id: record.id }, handleSuccess); await deleteOne({ id: record.id }, handleSuccess);
} }
/** /**
* 批量删除事件 * 批量删除事件
*/ */
async function batchHandleDelete() { async function batchHandleDelete() {
await batchDelete({ ids: selectedRowKeys.value }, handleSuccess); await batchDelete({ ids: selectedRowKeys.value }, handleSuccess);
} }
/** /**
* 成功回调 * 成功回调
*/ */
function handleSuccess() { function handleSuccess() {
(selectedRowKeys.value = []) && reload(); (selectedRowKeys.value = []) && reload();
} }
/** /**
* 操作栏 * 操作栏
*/ */
function getTableAction(record) { function getTableAction(record) {
const actions = [ const actions = [
{ {
label: '编辑', label: '编辑',
@ -250,8 +273,8 @@ function getTableAction(record) {
]; ];
return actions; return actions;
} }
function ConfirmRegistration(record) { function ConfirmRegistration(record) {
const actions = [{}]; const actions = [{}];
// //
if (record.status === 0) { if (record.status === 0) {
@ -268,9 +291,9 @@ function ConfirmRegistration(record) {
}); });
} }
return actions; return actions;
} }
async function updateStatus(id, action = '') { async function updateStatus(id, action = '') {
try { try {
let params = { id }; let params = { id };
if (action === 'un') { if (action === 'un') {
@ -289,11 +312,11 @@ async function updateStatus(id, action = '') {
} catch (error) { } catch (error) {
console.error('操作失败:', error); console.error('操作失败:', error);
} }
} }
/** /**
* 下拉操作栏 * 下拉操作栏
*/ */
function getDropDownAction(record) { function getDropDownAction(record) {
return [ return [
{ {
label: '详情', label: '详情',
@ -308,10 +331,10 @@ function getDropDownAction(record) {
}, },
}, },
]; ];
} }
// handleFocus // handleFocus
async function handleFocus(sex, record) { async function handleFocus(sex, record) {
console.log('dormitory11:', record.dormitoryId); console.log('dormitory11:', record.dormitoryId);
console.log('性别:', sex); console.log('性别:', sex);
try { try {
@ -337,12 +360,12 @@ async function handleFocus(sex, record) {
} catch (error) { } catch (error) {
console.error('在 handleFocus 中发生错误:', error); console.error('在 handleFocus 中发生错误:', error);
} }
} }
// handleFocus // handleFocus
async function handleChange(userId, dormitory, record) { async function handleChange(userId, dormitory, record) {
console.log("userId", userId) console.log('userId', userId);
console.log("dormitory", dormitory) console.log('dormitory', dormitory);
console.log("record", record) console.log('record', record);
let params = { let params = {
id: userId, id: userId,
dormitory: dormitory, dormitory: dormitory,
@ -354,11 +377,11 @@ async function handleChange(userId, dormitory, record) {
} catch (error) { } catch (error) {
console.error('在 handleFocus 中发生错误:', error); console.error('在 handleFocus 中发生错误:', error);
} }
} }
</script> </script>
<style scoped> <style scoped>
.ant-select .ant-input__inner::placeholder { .ant-select .ant-input__inner::placeholder {
color: #999 !important; color: #999 !important;
} }
</style> </style>