This commit is contained in:
吕才卓 2024-04-08 18:13:54 +08:00
parent 61ea10ecf3
commit fecbc1d096
4 changed files with 220 additions and 94 deletions

View File

@ -1,6 +1,8 @@
import sdy from './modules/sdy' import sdy from './modules/sdy'
import ycy from './modules/ycy' import ycy from './modules/ycy'
import lcz from './modules/lcz'
export default [ export default [
...sdy, ...sdy,
...ycy ...ycy,
...lcz,
] ]

40
mock/modules/lcz.js Normal file
View 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
};
}
}
];

View File

@ -1,7 +1,5 @@
import request from "@/utils/request"; 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)
}

View File

@ -1,28 +1,44 @@
<template> <template>
<t-space direction="vertical"> <div class="back-color">
<t-form ref="searchForm" @reset="onReset"> <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-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> </t-form-item>
</div>
<div style="margin-left: 1rem">
<t-form-item label="学号" name="studentId"> <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>
<t-form-item> </div>
<t-form-item style="margin-right: 1rem">
<t-space size="10px"> <t-space size="10px">
<t-button theme="primary" type="submit" @click="onSearch">查询</t-button> <t-button theme="primary" type="submit" @click="onSearch"
<t-button theme="default" variant="base" type="reset">重置</t-button> >查询</t-button
>
<t-button theme="default" variant="base" type="reset"
>重置</t-button
>
</t-space> </t-space>
</t-form-item> </t-form-item>
</t-form> </t-form>
</t-modal>
<t-space> </t-header>
<t-checkbox v-model="stripe">显示斑马纹</t-checkbox> <t-content class="table-box">
<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-table <t-table
rowKey="studentId" rowKey="studentId"
:data="studentList" :data="studentList"
@ -36,94 +52,142 @@
:showHeader="showHeader" :showHeader="showHeader"
cellEmptyContent="-" cellEmptyContent="-"
resizable resizable
></t-table> >
</t-space> <template #operation="slotProps">
<!-- 动态操作列 --> <t-button
<!-- <t-table-column label="操作"> theme="default"
<template #default="{ row }"> variant="text"
<t-button-group> size="small"
<t-button @click="handleLeave(row)">休学</t-button> @click="showEditModal(slotProps)"
<t-button @click="handleWithdraw(row)">退学</t-button> >修改</t-button
<t-button @click="handleReturn(row)">复学</t-button> >
</t-button-group>
</template> </template>
</t-table-column> --> </t-table>
</t-content>
</t-layout>
</div>
</template> </template>
<script setup> <script setup>
import { ref, reactive, computed } from 'vue'; import { ref, reactive, computed } from "vue";
import { MessagePlugin } from "tdesign-vue-next"; import { MessagePlugin } from "tdesign-vue-next";
import { useRouter } from "vue-router"; 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 router = useRouter();
const searchForm = ref(null); const searchForm = ref(null);
const initialStudentData = []; const initialStudentData = [];
const total = 28; const total = 28;
for (let i = 0; i < total; i++) { for (let i = 0; i < total; i++) {
let statusValue = ["休学", "退学", "复学"][i % 3];
initialStudentData.push({ initialStudentData.push({
studentId: `${'S'}${i + 1}`, Id: `${i + 1}`,
name: ['贾明', '张三', '王芳'][i % 3], name: ["贾明", "张三", "王芳"][i % 3],
gender: ['男', '女'][i % 2], gender: ["男", "女"][i % 2],
departmentCode: 'D' + (i % 4 + 1), studentId: i + 1000000000,
department: ['计算机科学系', '数学系', '物理系', '化学系'][i % 4], department: ["计算机科学系", "数学系", "物理系", "化学系"][i % 4],
className: 'C' + (i % 5 + 1), major: ["计算机科学与技术", "数学", "物理学", "化学", "生物学", "经济学"][
majorCode: 'M' + (i % 6 + 1), i % 6
major: ['计算机科学与技术', '数学', '物理学', '化学', '生物学', '经济学'][i % 6], ],
classCode: 'C' + (i % 5 + 1), classes: ["一班", "二班", "三班", "四班", "五班"][i % 5],
classes: ['一班', '二班', '三班', '四班', '五班'][i % 5], status: statusValue,
}); });
} }
// //
const searchCriteria = reactive({ name: '', studentId: '' }); const searchCriteria = reactive({ name: "", studentId: "" });
// //
const studentList = computed(() => { const studentList = computed(() => {
return initialStudentData.filter(student => return initialStudentData.filter(
(student) =>
(!searchCriteria.name || student.name.includes(searchCriteria.name)) && (!searchCriteria.name || student.name.includes(searchCriteria.name)) &&
(!searchCriteria.studentId || student.studentId === searchCriteria.studentId) (!searchCriteria.studentId ||
student.studentId === searchCriteria.studentId)
); );
}); });
// //
const studentColumns = ref([ const studentColumns = ref([
{ {
colKey: 'studentId', colKey: "Id",
title: '学号', title: "序号",
}, },
{ {
colKey: 'name', colKey: "name",
title: '姓名', title: "姓名",
}, },
{ {
colKey: 'gender', colKey: "gender",
title: '性别', title: "性别",
}, },
{ {
colKey: 'department', colKey: "studentId",
title: '系院', title: "学号",
}, },
{ {
colKey: 'major', colKey: "department",
title: '专业', title: "系院",
}, },
{ {
colKey: 'classes', colKey: "major",
title: '班级', 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({ const pagination = reactive({
defaultCurrent: 1, defaultCurrent: 1,
defaultPageSize: 5, defaultPageSize: 10,
total: initialStudentData.length, total: initialStudentData.length,
}); });
@ -133,14 +197,36 @@ const onSearch = () => {
}; };
const onReset = () => { const onReset = () => {
searchCriteria.name = ''; searchCriteria.name = "";
searchCriteria.studentId = ''; searchCriteria.studentId = "";
pagination.defaultCurrent = 1; pagination.defaultCurrent = 1;
MessagePlugin.success("重置成功"); MessagePlugin.success("重置成功");
}; };
</script> </script>
<style lang="less" scoped> <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> </style>