|
|
|
@ -1,19 +1,25 @@ |
|
|
|
|
<script setup> |
|
|
|
|
import { Search, Edit, Delete } from '@element-plus/icons-vue' |
|
|
|
|
import { Search, Edit, Delete, CircleClose } from '@element-plus/icons-vue' |
|
|
|
|
import { ref, onMounted } from 'vue' |
|
|
|
|
import { |
|
|
|
|
stuListService, |
|
|
|
|
// stuListService, |
|
|
|
|
stuPageService, |
|
|
|
|
delStuListService, |
|
|
|
|
reStuPassService, |
|
|
|
|
changeStaService, |
|
|
|
|
stuNumberService, |
|
|
|
|
} from '@/api/user/stud' |
|
|
|
|
import { ElMessage, ElMessageBox } from 'element-plus' |
|
|
|
|
import useUserStore from '@/store/modules/user' |
|
|
|
|
import { tryOnMounted } from '@vueuse/core' |
|
|
|
|
const userStore = useUserStore() |
|
|
|
|
// console.log(userStore.data.id, 'icon') //用户信息 |
|
|
|
|
const formLabelWidth = '60px' |
|
|
|
|
const tableData = ref([]) |
|
|
|
|
const total = ref() |
|
|
|
|
const show = ref(false) |
|
|
|
|
const show1 = ref(false) |
|
|
|
|
|
|
|
|
|
//是否是第一次加载 |
|
|
|
|
const isFirstLoad = ref(true) |
|
|
|
|
const params = ref({ |
|
|
|
@ -29,22 +35,14 @@ const getData = async () => { |
|
|
|
|
loading.value = true |
|
|
|
|
await stuPageService(params.value).then((res) => { |
|
|
|
|
tableData.value = res.data.Records |
|
|
|
|
// console.log(tableData.value, 'params') |
|
|
|
|
total.value = res.data.totalCount |
|
|
|
|
console.log(tableData.value, 'params') |
|
|
|
|
loading.value = false |
|
|
|
|
console.log(res.data, 'res.data') |
|
|
|
|
// console.log(res.data.totalCount, 'res.data') |
|
|
|
|
isFirstLoad.value = false |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//学生 |
|
|
|
|
// const getData = async () => { |
|
|
|
|
// // id.value = userStore.data.id |
|
|
|
|
// // console.log(id.value, 'id.value') |
|
|
|
|
// stuListService(2).then((res) => { |
|
|
|
|
// tableData.value = res.data |
|
|
|
|
// console.log(res.data, 'res.data') |
|
|
|
|
// }) |
|
|
|
|
// } |
|
|
|
|
// 页面条数变化 |
|
|
|
|
const onSizeChange = (size) => { |
|
|
|
|
//页面条数变化了,原本正在访问的页面变化,重新从第一页渲染即可 |
|
|
|
@ -60,16 +58,12 @@ const onCurrentChange = (page) => { |
|
|
|
|
params.value.page = page |
|
|
|
|
getData() |
|
|
|
|
} |
|
|
|
|
//重置 |
|
|
|
|
const onReset = () => { |
|
|
|
|
params.value.page = 1 |
|
|
|
|
getData() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//搜索 |
|
|
|
|
const onSearch = () => { |
|
|
|
|
params.value.pagenum = 1 |
|
|
|
|
// getArticleService() |
|
|
|
|
} |
|
|
|
|
// const onSearch = () => { |
|
|
|
|
// params.value.pagenum = 1 |
|
|
|
|
// // getArticleService() |
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
const loading = ref(false) |
|
|
|
|
//编辑 |
|
|
|
@ -81,7 +75,7 @@ const editTable = (row) => { |
|
|
|
|
} |
|
|
|
|
//删除行 |
|
|
|
|
const delTable = async (row) => { |
|
|
|
|
console.log(row.userId, 'delrow') |
|
|
|
|
// console.log(row.userId, 'delrow') |
|
|
|
|
await ElMessageBox.confirm('您确定删除这条学生信息吗', '温馨提示', { |
|
|
|
|
confirmButtonText: '确认', |
|
|
|
|
cancelButtonText: '取消', |
|
|
|
@ -99,82 +93,150 @@ const delTable = async (row) => { |
|
|
|
|
const selectedIds = ref([]) |
|
|
|
|
function handleSelectionChange(selection) { |
|
|
|
|
selectedIds.value = selection.map((row) => row.userId) |
|
|
|
|
console.log(selectedIds.value, 'selectedIds.value') |
|
|
|
|
// console.log(selectedIds.value, 'selectedIds.value') |
|
|
|
|
} |
|
|
|
|
const onDel = async () => { |
|
|
|
|
await ElMessageBox.confirm('您确定删除这些学生信息吗', '温馨提示', { |
|
|
|
|
confirmButtonText: '确认', |
|
|
|
|
cancelButtonText: '取消', |
|
|
|
|
type: 'warning', |
|
|
|
|
}) |
|
|
|
|
await delStuListService(selectedIds.value).then(() => { |
|
|
|
|
if (selectedIds.value.length !== 0) { |
|
|
|
|
await ElMessageBox.confirm('确定删除学生信息吗', '温馨提示', { |
|
|
|
|
confirmButtonText: '确认', |
|
|
|
|
cancelButtonText: '取消', |
|
|
|
|
type: 'warning', |
|
|
|
|
}) |
|
|
|
|
await delStuListService(selectedIds.value).then(() => { |
|
|
|
|
ElMessage({ |
|
|
|
|
message: '删除成功', |
|
|
|
|
type: 'success', |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
getData() |
|
|
|
|
} else { |
|
|
|
|
ElMessage({ |
|
|
|
|
message: '删除成功', |
|
|
|
|
type: 'success', |
|
|
|
|
message: '请选择要删除的学生', |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
getData() |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
//重置学生密码 |
|
|
|
|
const onResetPass = async () => { |
|
|
|
|
await ElMessageBox.confirm('您确定重置这些学生密码吗', '温馨提示', { |
|
|
|
|
confirmButtonText: '确认', |
|
|
|
|
cancelButtonText: '取消', |
|
|
|
|
type: 'warning', |
|
|
|
|
}) |
|
|
|
|
await reStuPassService(selectedIds.value).then(() => { |
|
|
|
|
if (selectedIds.value.length !== 0) { |
|
|
|
|
await ElMessageBox.confirm('确定重置密码吗', '温馨提示', { |
|
|
|
|
confirmButtonText: '确认', |
|
|
|
|
cancelButtonText: '取消', |
|
|
|
|
type: 'warning', |
|
|
|
|
}) |
|
|
|
|
await reStuPassService(selectedIds.value).then(() => { |
|
|
|
|
ElMessage({ |
|
|
|
|
message: '重置成功', |
|
|
|
|
type: 'success', |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
getData() |
|
|
|
|
} else { |
|
|
|
|
ElMessage({ |
|
|
|
|
message: '重置成功', |
|
|
|
|
type: 'success', |
|
|
|
|
message: '请选择要重置密码的学生', |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
getData() |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
//状态 |
|
|
|
|
const status = ref() |
|
|
|
|
tableData.value.forEach((item) => { |
|
|
|
|
item.status = item.status === 1 |
|
|
|
|
}) |
|
|
|
|
async function handleStatusChange(row) { |
|
|
|
|
status.value = row.status |
|
|
|
|
// console.log(status.value, 'status') |
|
|
|
|
// console.log(`状态更改: ${row.status}`) |
|
|
|
|
// if (!isFirstLoad.value) { |
|
|
|
|
// await changeStaService(status.value, row.userId).then(() => { |
|
|
|
|
// ElMessage({ |
|
|
|
|
// message: '状态更改成功', |
|
|
|
|
// type: 'success', |
|
|
|
|
// }) |
|
|
|
|
// }) |
|
|
|
|
// } |
|
|
|
|
// getData() |
|
|
|
|
console.log(status.value, 'status') |
|
|
|
|
console.log(`状态更改: ${row.status}`) |
|
|
|
|
if (!isFirstLoad.value) { |
|
|
|
|
await changeStaService(status.value, row.userId).then(() => { |
|
|
|
|
ElMessage({ |
|
|
|
|
message: '状态更改成功', |
|
|
|
|
type: 'success', |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
getData() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//姓名查询 |
|
|
|
|
const studentName = ref() |
|
|
|
|
function onFocus1() { |
|
|
|
|
show1.value = true |
|
|
|
|
} |
|
|
|
|
// function onBlur1() { |
|
|
|
|
// show1.value = true |
|
|
|
|
// } |
|
|
|
|
const closeName = () => { |
|
|
|
|
show1.value = false |
|
|
|
|
studentName.value = '' |
|
|
|
|
} |
|
|
|
|
const searchInfo = async () => { |
|
|
|
|
params.value.name = studentName.value |
|
|
|
|
// console.log(params.value.name, 'params.value.number') |
|
|
|
|
if (studentName.value.trim() !== '') { |
|
|
|
|
// show.value = true |
|
|
|
|
// console.log(params.value.name, 'params') |
|
|
|
|
await stuPageService({ |
|
|
|
|
page: 1, |
|
|
|
|
pagesize: 3, |
|
|
|
|
id: userStore.data.id, |
|
|
|
|
name: studentName.value, |
|
|
|
|
number: '', |
|
|
|
|
}).then((res) => { |
|
|
|
|
params.value.page = 1 |
|
|
|
|
console.log(res, 'change') |
|
|
|
|
getData() |
|
|
|
|
// studentName.value = '' |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//学号查询 |
|
|
|
|
const studentId = ref() |
|
|
|
|
function onFocus() { |
|
|
|
|
show.value = true |
|
|
|
|
} |
|
|
|
|
function onblur1() { |
|
|
|
|
show.value = false |
|
|
|
|
} |
|
|
|
|
// closeName |
|
|
|
|
const clearIdinput = () => { |
|
|
|
|
show.value = false |
|
|
|
|
studentId.value = '' |
|
|
|
|
} |
|
|
|
|
const searchNumber = async () => { |
|
|
|
|
// console.log(studentId.value, 'params.value.number') |
|
|
|
|
// console.log(studentId.value > 0, 'params') |
|
|
|
|
params.value.number = studentId.value |
|
|
|
|
console.log(params.value.number, 'params.value.number') |
|
|
|
|
await stuPageService(params.value).then((res) => { |
|
|
|
|
params.value.page = 1 |
|
|
|
|
console.log(res, 'change') |
|
|
|
|
}) |
|
|
|
|
// getData() |
|
|
|
|
if (studentId.value > 0) { |
|
|
|
|
await stuPageService({ |
|
|
|
|
page: 1, |
|
|
|
|
pagesize: 3, |
|
|
|
|
id: userStore.data.id, |
|
|
|
|
name: '', |
|
|
|
|
number: studentId.value, |
|
|
|
|
}).then((res) => { |
|
|
|
|
params.value.page = 1 |
|
|
|
|
getData() |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// console.log(res, 'change') |
|
|
|
|
} |
|
|
|
|
//查询 |
|
|
|
|
const studentName = ref() |
|
|
|
|
const searchInfo = async () => { |
|
|
|
|
params.value.name = studentName.value |
|
|
|
|
console.log(params.value.name, 'params.value.number') |
|
|
|
|
await stuPageService(params.value).then((res) => { |
|
|
|
|
params.value.page = 1 |
|
|
|
|
console.log(res, 'change') |
|
|
|
|
}) |
|
|
|
|
// getData() |
|
|
|
|
//重置 |
|
|
|
|
const onReset = () => { |
|
|
|
|
params.value.page = 1 |
|
|
|
|
params.value.name = '' |
|
|
|
|
params.value.number = '' |
|
|
|
|
getData() |
|
|
|
|
} |
|
|
|
|
function clearInput() { |
|
|
|
|
studentId.value = '' |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function clearInput1() { |
|
|
|
|
studentName.value = '' |
|
|
|
|
} |
|
|
|
|
const value1 = ref(true) |
|
|
|
|
console.log(typeof value1.value, 'value2') |
|
|
|
|
const changeStatus = async (row) => {} |
|
|
|
|
onMounted(() => { |
|
|
|
|
getData() |
|
|
|
@ -187,6 +249,7 @@ onMounted(() => { |
|
|
|
|
<div class="card-header"> |
|
|
|
|
<span>学生信息</span> |
|
|
|
|
<div> |
|
|
|
|
<el-switch v-model="value1" /> |
|
|
|
|
<el-button type="primary" @click="onResetPass">重置密码</el-button> |
|
|
|
|
<el-button type="danger" @click="onDel">批量删除</el-button> |
|
|
|
|
</div> |
|
|
|
@ -195,24 +258,41 @@ onMounted(() => { |
|
|
|
|
<div class="content"> |
|
|
|
|
<el-form style="display: flex"> |
|
|
|
|
<el-form-item style="width: 250px"> |
|
|
|
|
<!-- <p>学号</p> --> |
|
|
|
|
<el-input |
|
|
|
|
class="input_search" |
|
|
|
|
v-model="studentId" |
|
|
|
|
@blur="clearInput" |
|
|
|
|
@focus="onFocus" |
|
|
|
|
placeholder="输入学号进行搜索" |
|
|
|
|
></el-input> |
|
|
|
|
<el-icon |
|
|
|
|
color="gray" |
|
|
|
|
:size="12" |
|
|
|
|
style="margin-right: 20px" |
|
|
|
|
@click="clearIdinput" |
|
|
|
|
v-if="show" |
|
|
|
|
> |
|
|
|
|
<CircleClose /> |
|
|
|
|
</el-icon> |
|
|
|
|
<el-icon><Search /></el-icon> |
|
|
|
|
</el-form-item> |
|
|
|
|
<el-button class="btn_search" @click="searchNumber">搜索</el-button> |
|
|
|
|
|
|
|
|
|
<el-button class="btn_search" @click="searchNumber"> |
|
|
|
|
学号搜索 |
|
|
|
|
</el-button> |
|
|
|
|
<el-form-item style="width: 250px; margin-left: 30px"> |
|
|
|
|
<el-input |
|
|
|
|
class="input_search" |
|
|
|
|
@blur="clearInput1" |
|
|
|
|
v-model="studentName" |
|
|
|
|
@focus="onFocus1" |
|
|
|
|
placeholder="输入姓名进行搜索" |
|
|
|
|
></el-input> |
|
|
|
|
<el-icon |
|
|
|
|
color="gray" |
|
|
|
|
:size="12" |
|
|
|
|
style="margin-right: 20px" |
|
|
|
|
v-if="show1" |
|
|
|
|
@click="closeName" |
|
|
|
|
> |
|
|
|
|
<CircleClose /> |
|
|
|
|
</el-icon> |
|
|
|
|
<el-icon><Search /></el-icon> |
|
|
|
|
</el-form-item> |
|
|
|
|
<el-button class="btn_search" @click="searchInfo">搜索</el-button> |
|
|
|
@ -265,7 +345,6 @@ onMounted(() => { |
|
|
|
|
<el-table-column prop="phone" label="手机号" width="120" /> |
|
|
|
|
<el-table-column prop="major" label="专业" /> |
|
|
|
|
<el-table-column prop="yearAge" label="年级" /> |
|
|
|
|
<!-- <el-table-column prop="className" label="班级" /> --> |
|
|
|
|
<el-table-column prop="createTime" label="创建时间" width="200" /> |
|
|
|
|
<el-table-column prop="status" label="状态"> |
|
|
|
|
<template v-slot="scope"> |
|
|
|
@ -310,7 +389,7 @@ onMounted(() => { |
|
|
|
|
:disabled="disabled" |
|
|
|
|
:background="true" |
|
|
|
|
layout="total, sizes, prev, pager, next, jumper" |
|
|
|
|
:total="10" |
|
|
|
|
:total="total" |
|
|
|
|
@size-change="onSizeChange" |
|
|
|
|
@current-change="onCurrentChange" |
|
|
|
|
/> |
|
|
|
@ -388,6 +467,8 @@ onMounted(() => { |
|
|
|
|
background: #ffffff; |
|
|
|
|
box-shadow: 0px 1px 2px 0px rgba(0, 0, 0, 0.1); |
|
|
|
|
flex: 1; |
|
|
|
|
font-family: Inter, 'Helvetica Neue', Helvetica, 'PingFang SC', |
|
|
|
|
'Hiragino Sans GB', 'Microsoft YaHei', '微软雅黑', Arial, sans-serif; |
|
|
|
|
} |
|
|
|
|
.card-header { |
|
|
|
|
display: flex; |
|
|
|
@ -395,7 +476,7 @@ onMounted(() => { |
|
|
|
|
justify-content: space-between; |
|
|
|
|
} |
|
|
|
|
.content { |
|
|
|
|
min-height: 440px; |
|
|
|
|
min-height: 660px; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
.input_search { |
|
|
|
@ -407,9 +488,13 @@ onMounted(() => { |
|
|
|
|
right: 10px; |
|
|
|
|
top: 50%; |
|
|
|
|
transform: translateY(-50%); |
|
|
|
|
.close { |
|
|
|
|
margin-right: 10px; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
.btn_search { |
|
|
|
|
margin-left: 15px; |
|
|
|
|
margin: 0px 15px; |
|
|
|
|
// margin-top: 12px; |
|
|
|
|
border-radius: 8px; |
|
|
|
|
font-size: 13px; |
|
|
|
|
background-color: #377be5; |
|
|
|
@ -446,6 +531,9 @@ onMounted(() => { |
|
|
|
|
justify-content: end; |
|
|
|
|
font-size: 12px; |
|
|
|
|
} |
|
|
|
|
h5 { |
|
|
|
|
margin-top: 22px; |
|
|
|
|
} |
|
|
|
|
.avatar-uploader { |
|
|
|
|
:deep() { |
|
|
|
|
.avatar { |
|
|
|
|