stu
This commit is contained in:
parent
61ea10ecf3
commit
fecbc1d096
|
@ -1,6 +1,8 @@
|
|||
import sdy from './modules/sdy'
|
||||
import ycy from './modules/ycy'
|
||||
import lcz from './modules/lcz'
|
||||
export default [
|
||||
...sdy,
|
||||
...ycy
|
||||
...ycy,
|
||||
...lcz,
|
||||
]
|
40
mock/modules/lcz.js
Normal file
40
mock/modules/lcz.js
Normal file
|
@ -0,0 +1,40 @@
|
|||
import Mock from "mockjs";
|
||||
|
||||
function randomGender() {
|
||||
return ['男', '女'][Math.floor(Math.random() * 2)];
|
||||
}
|
||||
const student = Mock.mock({
|
||||
"list|100": [
|
||||
{
|
||||
id: '@id',
|
||||
name: '@cname',
|
||||
gender: randomGender(),
|
||||
studentId: '@id',
|
||||
department: function () {
|
||||
return ['计算机科学系', '数学系', '物理系', '化学系'][this.random(0, 3)];
|
||||
},
|
||||
major: function () {
|
||||
return ['计算机科学与技术', '数学', '物理学', '化学', '生物学', '经济学'][this.random(0, 5)];
|
||||
},
|
||||
classes: function () {
|
||||
return ['一班', '二班', '三班', '四班', '五班'][this.random(0, 4)];
|
||||
},
|
||||
status: function () {
|
||||
return ['休学', '退学', '复学'][this.random(0, 2)];
|
||||
}
|
||||
}
|
||||
]
|
||||
})
|
||||
|
||||
export default [
|
||||
{
|
||||
url: '/api/student',
|
||||
method: 'post',
|
||||
response: (config) => {
|
||||
return {
|
||||
code: 200,
|
||||
data: student.list
|
||||
};
|
||||
}
|
||||
}
|
||||
];
|
|
@ -1,7 +1,5 @@
|
|||
import request from "@/utils/request";
|
||||
// 统一管理接口
|
||||
const API = {
|
||||
STUDENT_URL: "/api/student",
|
||||
};
|
||||
|
||||
export const reqStudent = () => request.post(API.STUDENT_URL);
|
||||
export function APIStudent(data) {
|
||||
return request.post('/api/student', data)
|
||||
}
|
|
@ -1,28 +1,44 @@
|
|||
<template>
|
||||
<t-space direction="vertical">
|
||||
<t-form ref="searchForm" @reset="onReset">
|
||||
<div class="back-color">
|
||||
<t-layout style="height: 90%; background-color: #f5f7fb">
|
||||
<t-header class="scarch-box">
|
||||
<t-modal
|
||||
v-model="isModalVisible"
|
||||
@confirm="onSave"
|
||||
@cancel="onModalCancel"
|
||||
title="修改学生信息"
|
||||
>
|
||||
<t-form ref="searchForm" @reset="onReset" class="scarch-from">
|
||||
<div style="margin-left: 1rem">
|
||||
<t-form-item label="姓名" name="name">
|
||||
<t-input v-model="searchCriteria.name" placeholder="请输入姓名"></t-input>
|
||||
<t-input
|
||||
v-model="searchCriteria.name"
|
||||
placeholder="请输入姓名"
|
||||
></t-input>
|
||||
</t-form-item>
|
||||
</div>
|
||||
<div style="margin-left: 1rem">
|
||||
<t-form-item label="学号" name="studentId">
|
||||
<t-input v-model="searchCriteria.studentId" placeholder="请输入学号"></t-input>
|
||||
<t-input
|
||||
v-model="searchCriteria.studentId"
|
||||
placeholder="请输入学号"
|
||||
></t-input>
|
||||
</t-form-item>
|
||||
<t-form-item>
|
||||
</div>
|
||||
<t-form-item style="margin-right: 1rem">
|
||||
<t-space size="10px">
|
||||
<t-button theme="primary" type="submit" @click="onSearch">查询</t-button>
|
||||
<t-button theme="default" variant="base" type="reset">重置</t-button>
|
||||
<t-button theme="primary" type="submit" @click="onSearch"
|
||||
>查询</t-button
|
||||
>
|
||||
<t-button theme="default" variant="base" type="reset"
|
||||
>重置</t-button
|
||||
>
|
||||
</t-space>
|
||||
</t-form-item>
|
||||
</t-form>
|
||||
|
||||
<t-space>
|
||||
<t-checkbox v-model="stripe">显示斑马纹</t-checkbox>
|
||||
<t-checkbox v-model="bordered">显示表格边框</t-checkbox>
|
||||
<t-checkbox v-model="hover">显示悬浮效果</t-checkbox>
|
||||
<t-checkbox v-model="tableLayout">宽度自适应</t-checkbox>
|
||||
<t-checkbox v-model="showHeader">显示表头</t-checkbox>
|
||||
</t-space>
|
||||
|
||||
</t-modal>
|
||||
</t-header>
|
||||
<t-content class="table-box">
|
||||
<t-table
|
||||
rowKey="studentId"
|
||||
:data="studentList"
|
||||
|
@ -36,94 +52,142 @@
|
|||
:showHeader="showHeader"
|
||||
cellEmptyContent="-"
|
||||
resizable
|
||||
></t-table>
|
||||
</t-space>
|
||||
<!-- 动态操作列 -->
|
||||
<!-- <t-table-column label="操作">
|
||||
<template #default="{ row }">
|
||||
<t-button-group>
|
||||
<t-button @click="handleLeave(row)">休学</t-button>
|
||||
<t-button @click="handleWithdraw(row)">退学</t-button>
|
||||
<t-button @click="handleReturn(row)">复学</t-button>
|
||||
</t-button-group>
|
||||
>
|
||||
<template #operation="slotProps">
|
||||
<t-button
|
||||
theme="default"
|
||||
variant="text"
|
||||
size="small"
|
||||
@click="showEditModal(slotProps)"
|
||||
>修改</t-button
|
||||
>
|
||||
</template>
|
||||
</t-table-column> -->
|
||||
</t-table>
|
||||
</t-content>
|
||||
</t-layout>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, reactive, computed } from 'vue';
|
||||
import { ref, reactive, computed } from "vue";
|
||||
import { MessagePlugin } from "tdesign-vue-next";
|
||||
import { useRouter } from "vue-router";
|
||||
import { reqStudent } from "@/api/students";
|
||||
// import { reqStudent } from "@/api/students";
|
||||
import { APIStudent } from "@/api/students";
|
||||
|
||||
const isModalVisible = ref(false);
|
||||
const editStudent = ref({});
|
||||
|
||||
// 显示编辑弹出框的方法
|
||||
const showEditModal = (student) => {
|
||||
isModalVisible.value = true;
|
||||
editStudent.value = Object.assign({}, student);
|
||||
};
|
||||
|
||||
// 确认修改的回调方法
|
||||
const onSave = () => {
|
||||
// 调用 API 更新学生状态(这里假设有个 updateStudent 方法)
|
||||
updateStudent(editStudent.value).then(() => {
|
||||
// 更新成功后关闭模态框,同时更新表格数据
|
||||
isModalVisible.value = false;
|
||||
// 重新获取或更新 studentList 数据
|
||||
});
|
||||
};
|
||||
|
||||
// 取消编辑的回调方法
|
||||
const onModalCancel = () => {
|
||||
isModalVisible.value = false;
|
||||
editStudent.value = {};
|
||||
};
|
||||
|
||||
const router = useRouter();
|
||||
const searchForm = ref(null);
|
||||
const initialStudentData = [];
|
||||
const total = 28;
|
||||
for (let i = 0; i < total; i++) {
|
||||
let statusValue = ["休学", "退学", "复学"][i % 3];
|
||||
initialStudentData.push({
|
||||
studentId: `${'S'}${i + 1}`,
|
||||
name: ['贾明', '张三', '王芳'][i % 3],
|
||||
gender: ['男', '女'][i % 2],
|
||||
departmentCode: 'D' + (i % 4 + 1),
|
||||
department: ['计算机科学系', '数学系', '物理系', '化学系'][i % 4],
|
||||
className: 'C' + (i % 5 + 1),
|
||||
majorCode: 'M' + (i % 6 + 1),
|
||||
major: ['计算机科学与技术', '数学', '物理学', '化学', '生物学', '经济学'][i % 6],
|
||||
classCode: 'C' + (i % 5 + 1),
|
||||
classes: ['一班', '二班', '三班', '四班', '五班'][i % 5],
|
||||
Id: `${i + 1}`,
|
||||
name: ["贾明", "张三", "王芳"][i % 3],
|
||||
gender: ["男", "女"][i % 2],
|
||||
studentId: i + 1000000000,
|
||||
department: ["计算机科学系", "数学系", "物理系", "化学系"][i % 4],
|
||||
major: ["计算机科学与技术", "数学", "物理学", "化学", "生物学", "经济学"][
|
||||
i % 6
|
||||
],
|
||||
classes: ["一班", "二班", "三班", "四班", "五班"][i % 5],
|
||||
status: statusValue,
|
||||
});
|
||||
}
|
||||
|
||||
// 查询条件
|
||||
const searchCriteria = reactive({ name: '', studentId: '' });
|
||||
const searchCriteria = reactive({ name: "", studentId: "" });
|
||||
|
||||
// 学生列表数据
|
||||
const studentList = computed(() => {
|
||||
return initialStudentData.filter(student =>
|
||||
return initialStudentData.filter(
|
||||
(student) =>
|
||||
(!searchCriteria.name || student.name.includes(searchCriteria.name)) &&
|
||||
(!searchCriteria.studentId || student.studentId === searchCriteria.studentId)
|
||||
(!searchCriteria.studentId ||
|
||||
student.studentId === searchCriteria.studentId)
|
||||
);
|
||||
});
|
||||
|
||||
// 表格列定义
|
||||
const studentColumns = ref([
|
||||
{
|
||||
colKey: 'studentId',
|
||||
title: '学号',
|
||||
colKey: "Id",
|
||||
title: "序号",
|
||||
},
|
||||
{
|
||||
colKey: 'name',
|
||||
title: '姓名',
|
||||
colKey: "name",
|
||||
title: "姓名",
|
||||
},
|
||||
{
|
||||
colKey: 'gender',
|
||||
title: '性别',
|
||||
colKey: "gender",
|
||||
title: "性别",
|
||||
},
|
||||
{
|
||||
colKey: 'department',
|
||||
title: '系院',
|
||||
colKey: "studentId",
|
||||
title: "学号",
|
||||
},
|
||||
{
|
||||
colKey: 'major',
|
||||
title: '专业',
|
||||
colKey: "department",
|
||||
title: "系院",
|
||||
},
|
||||
{
|
||||
colKey: 'classes',
|
||||
title: '班级',
|
||||
colKey: "major",
|
||||
title: "专业",
|
||||
},
|
||||
{
|
||||
colKey: "classes",
|
||||
title: "班级",
|
||||
},
|
||||
{
|
||||
colKey: "status",
|
||||
title: "状态",
|
||||
formatter: (value) => {
|
||||
switch (value) {
|
||||
case "休学":
|
||||
return "休学";
|
||||
case "退学":
|
||||
return "退学";
|
||||
case "复学":
|
||||
return "复学";
|
||||
default:
|
||||
return "-";
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
colKey: "operation",
|
||||
title: "操作",
|
||||
},
|
||||
]);
|
||||
|
||||
const size = ref('medium');
|
||||
const tableLayout = ref(false);
|
||||
const stripe = ref(false);
|
||||
const bordered = ref(false);
|
||||
const hover = ref(true);
|
||||
const showHeader = ref(true);
|
||||
|
||||
const pagination = reactive({
|
||||
defaultCurrent: 1,
|
||||
defaultPageSize: 5,
|
||||
defaultPageSize: 10,
|
||||
total: initialStudentData.length,
|
||||
});
|
||||
|
||||
|
@ -133,14 +197,36 @@ const onSearch = () => {
|
|||
};
|
||||
|
||||
const onReset = () => {
|
||||
searchCriteria.name = '';
|
||||
searchCriteria.studentId = '';
|
||||
searchCriteria.name = "";
|
||||
searchCriteria.studentId = "";
|
||||
pagination.defaultCurrent = 1;
|
||||
MessagePlugin.success("重置成功");
|
||||
};
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.scarch-box {
|
||||
width: 100%;
|
||||
background-color: @base-white-color;
|
||||
margin-bottom: 2rem;
|
||||
.scarch-from {
|
||||
height: 3.75rem;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
}
|
||||
|
||||
.table-box {
|
||||
height: 42rem;
|
||||
background-color: @base-white-color;
|
||||
padding: 1rem;
|
||||
padding-top: 0;
|
||||
.table-header {
|
||||
height: 3rem;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
|
Loading…
Reference in New Issue
Block a user