Merge branch 'dev' of https://gitea.dykj.co/sundongyu/dykj-college-back-office-management-system into dev
This commit is contained in:
commit
4c9667e84b
70
mock/modules/lcz.js
Normal file
70
mock/modules/lcz.js
Normal file
|
@ -0,0 +1,70 @@
|
||||||
|
import Mock from "mockjs"
|
||||||
|
|
||||||
|
const student = Mock.mock({
|
||||||
|
"list|100": [
|
||||||
|
{
|
||||||
|
"Id|+1": 1,
|
||||||
|
"name": "@cname",
|
||||||
|
"gender":`@pick(['男', '女'])`,
|
||||||
|
"studentId": "@integer(1000000000,9999999999)",
|
||||||
|
"department":`@pick(['机电工程系', '护理分院','建筑系','材料科学与工程系','环境科学与工程系'])`,
|
||||||
|
"major":`@pick(['机械制造与自动化', '材料科学与工程', '环境科学与工程', '建筑工程', '护理学'])`,
|
||||||
|
"classes":`@pick(['机制1班', '材料1班', '环境1班', '建筑1班','护理1班'])`,
|
||||||
|
"status":`@pick(['休学', '退学', '复学'])`,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
export default [
|
||||||
|
{
|
||||||
|
url:'/api-list',
|
||||||
|
method:'get',
|
||||||
|
response: () => {
|
||||||
|
return {
|
||||||
|
code: 200,
|
||||||
|
data: student
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
url: '/api-student',
|
||||||
|
method: 'post',
|
||||||
|
response: (req) => {
|
||||||
|
if (req.body.name !== '') {
|
||||||
|
return student.list.filter(item => item.name.includes(req.body.name))
|
||||||
|
}
|
||||||
|
else if (req.body.studentId !== '') {
|
||||||
|
const studentId = Number(req.body.studentId)
|
||||||
|
if (!isNaN(studentId)) {
|
||||||
|
return student.list.filter(item => item.studentId === studentId)
|
||||||
|
} else {
|
||||||
|
return {
|
||||||
|
code: 400,
|
||||||
|
message: 'Invalid student number format'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (req.body.name !== '') {
|
||||||
|
return student.list.filter(item => item.name.includes(req.body.name))
|
||||||
|
}
|
||||||
|
else if (req.body.gender !== '') {
|
||||||
|
return student.list.filter(item => item.gender.includes(req.body.gender))
|
||||||
|
}
|
||||||
|
else if (req.body.department !== '') {
|
||||||
|
return student.list.filter(item => item.grade.includes(req.body.department))
|
||||||
|
}
|
||||||
|
else if (req.body.major !== '') {
|
||||||
|
return student.list.filter(item => item.major.includes(req.body.major))
|
||||||
|
}
|
||||||
|
else if (req.body.classes !== '') {
|
||||||
|
return student.list.filter(item => item.classes.includes(req.body.classes))
|
||||||
|
}
|
||||||
|
else if (req.body.status !== '') {
|
||||||
|
return student.list.filter(item => item.major.includes(req.body.status))
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
code: 200,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
|
@ -12,6 +12,8 @@
|
||||||
"axios": "^1.6.8",
|
"axios": "^1.6.8",
|
||||||
"dayjs": "^1.11.10",
|
"dayjs": "^1.11.10",
|
||||||
"echarts": "^5.5.0",
|
"echarts": "^5.5.0",
|
||||||
|
"exceljs": "^4.4.0",
|
||||||
|
"file-saver": "^2.0.5",
|
||||||
"less": "^4.2.0",
|
"less": "^4.2.0",
|
||||||
"mockjs": "^1.1.0",
|
"mockjs": "^1.1.0",
|
||||||
"pinia": "^2.1.7",
|
"pinia": "^2.1.7",
|
||||||
|
|
|
@ -5,4 +5,4 @@ const API = {
|
||||||
};
|
};
|
||||||
|
|
||||||
export const reqUser = () => request.post(API.LOGIN_URL);
|
export const reqUser = () => request.post(API.LOGIN_URL);
|
||||||
export const reqUserone = (data) => request.post(API.LOGIN_URL, data);
|
// export const reqUserone = (data) => request.post(API.LOGIN_URL, data);
|
|
@ -1,7 +1,8 @@
|
||||||
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 getList() {
|
||||||
|
return request.get('/api-list')
|
||||||
|
}
|
||||||
|
export function getStudents(studentData) {
|
||||||
|
return request.post('/api-student', studentData)
|
||||||
|
}
|
|
@ -29,6 +29,9 @@
|
||||||
<h4 style="font-size: 110%">报表明细</h4>
|
<h4 style="font-size: 110%">报表明细</h4>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
|
<t-button theme="primary" size="small" @click="exportExcel">
|
||||||
|
导出报表明细
|
||||||
|
</t-button>
|
||||||
<t-button
|
<t-button
|
||||||
shape="circle"
|
shape="circle"
|
||||||
theme="primary"
|
theme="primary"
|
||||||
|
@ -63,6 +66,7 @@ import { ref, onMounted } from "vue";
|
||||||
import { MessagePlugin } from "tdesign-vue-next";
|
import { MessagePlugin } from "tdesign-vue-next";
|
||||||
import { LoadIcon } from "tdesign-icons-vue-next";
|
import { LoadIcon } from "tdesign-icons-vue-next";
|
||||||
import { reqDetailReportList } from "@/api/finance-bill-manage/detailReportList";
|
import { reqDetailReportList } from "@/api/finance-bill-manage/detailReportList";
|
||||||
|
import { ExcelUtils } from "@/utils/excel";
|
||||||
|
|
||||||
const tableData = ref([]);
|
const tableData = ref([]);
|
||||||
const dataList = ref([]);
|
const dataList = ref([]);
|
||||||
|
@ -171,6 +175,34 @@ const resetting = () => {
|
||||||
const refresh = () => {
|
const refresh = () => {
|
||||||
tableList();
|
tableList();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 导出excel
|
||||||
|
const exportExcel = () => {
|
||||||
|
const title = "报表明细excel";
|
||||||
|
const titleFile = "报表明细";
|
||||||
|
const columns = [
|
||||||
|
{ header: "部门", key: "1", width: 20 },
|
||||||
|
{ header: "入库量", key: "2", width: 20 },
|
||||||
|
{ header: "退库量", key: "3", width: 20 },
|
||||||
|
{ header: "领用量", key: "4", width: 20 },
|
||||||
|
{ header: "报损量", key: "5", width: 20 },
|
||||||
|
{ header: "核销量", key: "6", width: 20 },
|
||||||
|
{ header: "总票据比例", key: "7", width: 20 },
|
||||||
|
];
|
||||||
|
const addRow = [];
|
||||||
|
tableData.value.forEach((item) => {
|
||||||
|
addRow.push({
|
||||||
|
1: item.branch,
|
||||||
|
2: item.stockNum,
|
||||||
|
3: item.cancelNum,
|
||||||
|
4: item.receiveNum,
|
||||||
|
5: item.breakNum,
|
||||||
|
6: item.destoryNum,
|
||||||
|
7: item.grossBillRatio,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
ExcelUtils(title, titleFile, columns, addRow);
|
||||||
|
};
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
tableList();
|
tableList();
|
||||||
});
|
});
|
||||||
|
|
|
@ -55,7 +55,7 @@ import { MessagePlugin } from "tdesign-vue-next";
|
||||||
import { reactive, ref, onMounted } from "vue";
|
import { reactive, ref, onMounted } from "vue";
|
||||||
import { reqUser } from "@/api/login";
|
import { reqUser } from "@/api/login";
|
||||||
import { useRouter } from "vue-router";
|
import { useRouter } from "vue-router";
|
||||||
import axios from 'axios';
|
// import axios from 'axios';
|
||||||
// import { TForm, TFormItem, TInput, TButton } from "tdesign-vue-next";
|
// import { TForm, TFormItem, TInput, TButton } from "tdesign-vue-next";
|
||||||
// import { DesktopIcon, LockOnIcon } from "tdesign-icons-vue";
|
// import { DesktopIcon, LockOnIcon } from "tdesign-icons-vue";
|
||||||
|
|
||||||
|
@ -103,7 +103,11 @@ onMounted(() => {
|
||||||
|
|
||||||
const onSubmit = async () => {
|
const onSubmit = async () => {
|
||||||
try {
|
try {
|
||||||
const validateResult = await from.value?.validate();
|
if (!form || !form.value) {
|
||||||
|
console.warn("form 或 form.value 不存在,无法进行表单验证");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const validateResult = await form.value?.validate();
|
||||||
if (validateResult?.result) {
|
if (validateResult?.result) {
|
||||||
await reqUser(formData.account, formData.password);
|
await reqUser(formData.account, formData.password);
|
||||||
MessagePlugin.success("提交成功");
|
MessagePlugin.success("提交成功");
|
||||||
|
|
|
@ -1,146 +1,295 @@
|
||||||
<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-form-item label="姓名" name="name">
|
<t-header class="scarch-box">
|
||||||
<t-input v-model="searchCriteria.name" placeholder="请输入姓名"></t-input>
|
<t-form
|
||||||
</t-form-item>
|
ref="form"
|
||||||
<t-form-item label="学号" name="studentId">
|
:data="studentData"
|
||||||
<t-input v-model="searchCriteria.studentId" placeholder="请输入学号"></t-input>
|
reset-type="initial"
|
||||||
</t-form-item>
|
colon
|
||||||
<t-form-item>
|
@reset="onReset"
|
||||||
<t-space size="10px">
|
@submit="onSubmit"
|
||||||
<t-button theme="primary" type="submit" @click="onSearch">查询</t-button>
|
>
|
||||||
<t-button theme="default" variant="base" type="reset">重置</t-button>
|
<t-row class="scarch-from">
|
||||||
</t-space>
|
<t-col :span="3">
|
||||||
</t-form-item>
|
<t-form-item label="姓名" name="name">
|
||||||
</t-form>
|
<t-input v-model="studentData.name"></t-input>
|
||||||
|
</t-form-item>
|
||||||
|
</t-col>
|
||||||
|
<t-col :span="3">
|
||||||
|
<t-form-item label="学号" name="studentId">
|
||||||
|
<t-input v-model="studentData.studentId"></t-input>
|
||||||
|
</t-form-item>
|
||||||
|
</t-col>
|
||||||
|
<t-col :push="2" :span="4">
|
||||||
|
<t-button theme="primary" type="submit"
|
||||||
|
>查询</t-button
|
||||||
|
>
|
||||||
|
<t-button theme="default" variant="base" type="reset"
|
||||||
|
style="margin-left: 1rem;">重置</t-button
|
||||||
|
>
|
||||||
|
</t-col>
|
||||||
|
</t-row>
|
||||||
|
</t-form>
|
||||||
|
</t-header>
|
||||||
|
<t-content class="table-box">
|
||||||
|
<t-table
|
||||||
|
rowKey="Id"
|
||||||
|
:data="studentList"
|
||||||
|
:columns="studentColumns"
|
||||||
|
:stripe="stripe"
|
||||||
|
:bordered="bordered"
|
||||||
|
:hover="true"
|
||||||
|
:size="size"
|
||||||
|
:table-layout="tableLayout ? 'auto' : 'fixed'"
|
||||||
|
:pagination="pagination"
|
||||||
|
:showHeader="true"
|
||||||
|
cellEmptyContent="-"
|
||||||
|
resizable
|
||||||
|
lazy-load
|
||||||
|
@row-click="handleRowClick"
|
||||||
|
@page-change="onPageChange"
|
||||||
|
:loading="loading"
|
||||||
|
>
|
||||||
|
<template #operation="{ row }">
|
||||||
|
<t-button
|
||||||
|
theme="default"
|
||||||
|
variant="text"
|
||||||
|
size="small"
|
||||||
|
@click="Modify(row)"
|
||||||
|
>修改</t-button
|
||||||
|
>
|
||||||
|
<t-popconfirm
|
||||||
|
content="确认删除吗"
|
||||||
|
@confirm="Delete(row)"
|
||||||
|
>
|
||||||
|
<t-button theme="default" variant="text" size="small"
|
||||||
|
>删除</t-button
|
||||||
|
>
|
||||||
|
</t-popconfirm>
|
||||||
|
</template>
|
||||||
|
</t-table>
|
||||||
|
</t-content>
|
||||||
|
</t-layout>
|
||||||
<t-space>
|
<t-space>
|
||||||
<t-checkbox v-model="stripe">显示斑马纹</t-checkbox>
|
<t-dialog
|
||||||
<t-checkbox v-model="bordered">显示表格边框</t-checkbox>
|
ref="postForm"
|
||||||
<t-checkbox v-model="hover">显示悬浮效果</t-checkbox>
|
v-model="visible"
|
||||||
<t-checkbox v-model="tableLayout">宽度自适应</t-checkbox>
|
header="学生变动处理"
|
||||||
<t-checkbox v-model="showHeader">显示表头</t-checkbox>
|
width="40%"
|
||||||
|
:on-cancel="onCancel"
|
||||||
|
:on-close-btn-click="onCloseBtnClick"
|
||||||
|
:on-confirm="onConfirmAnother"
|
||||||
|
:close-on-overlay-click="false"
|
||||||
|
>
|
||||||
|
<t-space direction="vertical" style="width: 100%">
|
||||||
|
<div>
|
||||||
|
<t-form
|
||||||
|
ref="form"
|
||||||
|
:data="formData"
|
||||||
|
reset-type="initial"
|
||||||
|
colon
|
||||||
|
@reset="onReset"
|
||||||
|
>
|
||||||
|
<t-form-item label="姓名" name="name">
|
||||||
|
<t-input v-model="formData.name"></t-input>
|
||||||
|
</t-form-item>
|
||||||
|
<t-form-item label="性别" name="gender">
|
||||||
|
<t-input v-model="formData.gender"></t-input>
|
||||||
|
</t-form-item>
|
||||||
|
<t-form-item label="学号" name="studentId">
|
||||||
|
<t-input v-model="formData.studentId"></t-input>
|
||||||
|
</t-form-item>
|
||||||
|
<t-form-item label="系院" name="department">
|
||||||
|
<t-input v-model="formData.department"></t-input>
|
||||||
|
</t-form-item>
|
||||||
|
<t-form-item label="专业" name="major">
|
||||||
|
<t-input v-model="formData.major"></t-input>
|
||||||
|
</t-form-item>
|
||||||
|
<t-form-item label="班级" name="classes">
|
||||||
|
<t-input v-model="formData.classes"></t-input>
|
||||||
|
</t-form-item>
|
||||||
|
<t-form-item label="状态" name="status">
|
||||||
|
<t-input v-model="formData.status"></t-input>
|
||||||
|
</t-form-item>
|
||||||
|
</t-form>
|
||||||
|
</div>
|
||||||
|
</t-space>
|
||||||
|
</t-dialog>
|
||||||
</t-space>
|
</t-space>
|
||||||
|
|
||||||
<t-table
|
</div>
|
||||||
rowKey="studentId"
|
|
||||||
:data="studentList"
|
|
||||||
:columns="studentColumns"
|
|
||||||
:stripe="stripe"
|
|
||||||
:bordered="bordered"
|
|
||||||
:hover="hover"
|
|
||||||
:size="size"
|
|
||||||
:table-layout="tableLayout ? 'auto' : 'fixed'"
|
|
||||||
:pagination="pagination"
|
|
||||||
: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>
|
|
||||||
</t-table-column> -->
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, reactive, computed } from 'vue';
|
import { ref, reactive, computed, onMounted } from "vue";
|
||||||
|
import {getList, getStudents } from "@/api/students";
|
||||||
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";
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const searchForm = ref(null);
|
|
||||||
const initialStudentData = [];
|
|
||||||
const total = 28;
|
|
||||||
for (let i = 0; i < total; i++) {
|
|
||||||
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],
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// 查询条件
|
const studentData = reactive({
|
||||||
const searchCriteria = reactive({ name: '', studentId: '' });
|
Id:"",
|
||||||
|
name: "",
|
||||||
// 学生列表数据
|
gender: "",
|
||||||
const studentList = computed(() => {
|
studentId: "",
|
||||||
return initialStudentData.filter(student =>
|
department: "",
|
||||||
(!searchCriteria.name || student.name.includes(searchCriteria.name)) &&
|
major: "",
|
||||||
(!searchCriteria.studentId || student.studentId === searchCriteria.studentId)
|
classes: "",
|
||||||
);
|
status: "",
|
||||||
});
|
});
|
||||||
|
|
||||||
// 表格列定义
|
// 弹出框表单
|
||||||
|
const formData = ref({
|
||||||
|
name: "",
|
||||||
|
gender: "",
|
||||||
|
studentId: "",
|
||||||
|
department: "",
|
||||||
|
major: "",
|
||||||
|
classes: "",
|
||||||
|
status: "",
|
||||||
|
})
|
||||||
|
const visible = ref(true)
|
||||||
|
const studentList = ref([]);
|
||||||
|
|
||||||
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: "状态",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
colKey: "operation",
|
||||||
|
title: "操作",
|
||||||
|
align: "center"
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
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: 0,
|
||||||
});
|
});
|
||||||
|
|
||||||
// 查询功能
|
//表单提交
|
||||||
const onSearch = () => {
|
const onSubmit = async () => {
|
||||||
pagination.defaultCurrent = 1;
|
if (
|
||||||
|
studentData.Id ||
|
||||||
|
studentData.name ||
|
||||||
|
studentData.gender ||
|
||||||
|
studentData.studentId ||
|
||||||
|
studentData.department ||
|
||||||
|
studentData.major ||
|
||||||
|
studentData.classes ||
|
||||||
|
studentData.status
|
||||||
|
) {
|
||||||
|
const res = await getStudents(studentData);
|
||||||
|
// console.log(res);
|
||||||
|
studentList.value = Array.from(res);
|
||||||
|
pagination.total = res.length;
|
||||||
|
} else {
|
||||||
|
alert("请填写完整信息");
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//表单重置
|
||||||
const onReset = () => {
|
const onReset = () => {
|
||||||
searchCriteria.name = '';
|
TableData()
|
||||||
searchCriteria.studentId = '';
|
}
|
||||||
pagination.defaultCurrent = 1;
|
|
||||||
MessagePlugin.success("重置成功");
|
//获取表格数据
|
||||||
|
const TableData = async () => {
|
||||||
|
const res = await getList()
|
||||||
|
// console.log(res);
|
||||||
|
studentList.value = res.data.list
|
||||||
|
pagination.total = res.data.list.length
|
||||||
|
}
|
||||||
|
console.log(TableData.name);
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
TableData()
|
||||||
|
})
|
||||||
|
|
||||||
|
// 修改学生状态
|
||||||
|
const Modify = row => {
|
||||||
|
conlose.log(1)
|
||||||
|
visible.value = true;
|
||||||
|
formData.value = {
|
||||||
|
name: row.name,
|
||||||
|
gender: row.gender,
|
||||||
|
studentId: row.studentId,
|
||||||
|
department: row.department,
|
||||||
|
major: row.major,
|
||||||
|
classes: row.classes,
|
||||||
|
status: row.status,
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const onConfirmAnother = async () => {
|
||||||
|
try {
|
||||||
|
// 这里假设存在一个更新学生信息的API方法,例如updateStudent
|
||||||
|
await updateStudent(formData.value);
|
||||||
|
// 更新成功后,关闭弹窗并重新加载表格数据
|
||||||
|
visible.value = false;
|
||||||
|
TableData();
|
||||||
|
} catch (error) {
|
||||||
|
console.error('更新学生信息失败:', error);
|
||||||
|
}
|
||||||
|
};
|
||||||
</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>
|
||||||
|
|
24
src/utils/excel.js
Normal file
24
src/utils/excel.js
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
import ExcelJS from "exceljs";
|
||||||
|
import saveAs from "file-saver"; // 引入FileSaver.js以使用saveAs函数
|
||||||
|
|
||||||
|
const ExcelUtils = (title, titleFile, columns, addRow) => {
|
||||||
|
// 创建一个新的工作簿
|
||||||
|
const workbook = new ExcelJS.Workbook();
|
||||||
|
// 添加一个新的工作表
|
||||||
|
const worksheet = workbook.addWorksheet(title);
|
||||||
|
// 添加表头
|
||||||
|
worksheet.columns = columns;
|
||||||
|
// 添加数据行
|
||||||
|
for (const row of addRow) {
|
||||||
|
worksheet.addRow(row);
|
||||||
|
}
|
||||||
|
// 写入文件并下载
|
||||||
|
workbook.xlsx.writeBuffer().then((buffer) => {
|
||||||
|
const blob = new Blob([buffer], {
|
||||||
|
type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
||||||
|
});
|
||||||
|
saveAs(blob, `${titleFile}.xlsx`);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
export { ExcelUtils };
|
Loading…
Reference in New Issue
Block a user