KindergartenUI/src/views/system/studentInfo/index.vue
2022-08-22 09:05:11 +08:00

1405 lines
41 KiB
Vue

<template>
<div class="app-container">
<el-form
:model="queryParams"
ref="queryForm"
size="small"
:inline="true"
v-show="showSearch"
label-width="68px"
>
<el-form-item label="学生姓名" prop="studentName">
<el-input
v-model="queryParams.studentName"
placeholder="请输入学生姓名"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="学生编号" prop="studentNumber">
<el-input
v-model="queryParams.studentNumber"
placeholder="请输入学生编号"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="民族" prop="nationDictId">
<el-select
clearable
v-model="queryParams.nationDictId"
placeholder="请选择"
style="width: 208px"
>
<el-option
v-for="item in nactionlist"
:key="item.value"
:label="item.dictLabel"
:value="item.dictCode"
>
</el-option>
</el-select>
</el-form-item>
<el-form-item label="出生日期" prop="birthDate">
<el-date-picker
clearable
v-model="queryParams.birthDate"
type="date"
value-format="yyyy-MM-dd"
placeholder="请选择出生日期"
>
</el-date-picker>
</el-form-item>
<el-form-item label="身份证号" prop="cardNumber">
<el-input
v-model="queryParams.cardNumber"
placeholder="请输入身份证号"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="曾用名" prop="onceName">
<el-input
v-model="queryParams.onceName"
placeholder="请输入曾用名"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="家庭住址" prop="homeAddress">
<el-input
v-model="queryParams.homeAddress"
placeholder="请输入家庭住址"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item>
<el-button
type="primary"
icon="el-icon-search"
size="mini"
@click="handleQuery"
>搜索</el-button
>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
>重置</el-button
>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="handleAdd"
v-hasPermi="['system:studentInfo:add']"
>新增</el-button
>
</el-col>
<el-col :span="1.5">
<el-button
type="success"
plain
icon="el-icon-edit"
size="mini"
:disabled="single"
@click="handleUpdate"
v-hasPermi="['system:studentInfo:edit']"
>修改</el-button
>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="el-icon-delete"
size="mini"
:disabled="multiple"
@click="handleDelete"
v-hasPermi="['system:studentInfo:remove']"
>删除</el-button
>
</el-col>
<!-- <el-col :span="1.5">
<el-button
type="warning"
plain
icon="el-icon-download"
size="mini"
@click="handleExport"
v-hasPermi="['system:studentInfo:export']"
>导出</el-button>
</el-col> -->
<right-toolbar
:showSearch.sync="showSearch"
@queryTable="getList"
></right-toolbar>
</el-row>
<el-table
v-loading="loading"
:data="studentInfoList"
@selection-change="handleSelectionChange"
>
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="所属班级" align="center" prop="className" />
<el-table-column label="民族" align="center" prop="nationDictId">
<template slot-scope="scope">
{{ nactiontype(scope.row.nationDictId) }}
</template>
</el-table-column>
<el-table-column label="学生姓名" align="center" prop="studentName" />
<el-table-column label="学生性别" align="center" prop="studentSex">
<template slot-scope="scope">{{
scope.row.studentSex == male ? "男" : "女"
}}</template>
</el-table-column>
<el-table-column label="学生编号" align="center" prop="studentNumber" />
<el-table-column
label="出生日期"
align="center"
prop="birthDate"
width="180"
>
<template slot-scope="scope">
<span>{{ parseTime(scope.row.birthDate, "{y}-{m}-{d}") }}</span>
</template>
</el-table-column>
<el-table-column label="身份证号" align="center" prop="cardNumber" />
<el-table-column label="曾用名" align="center" prop="onceName" />
<el-table-column label="家庭住址" align="center" prop="homeAddress" />
<el-table-column
label="操作"
align="center"
class-name="small-padding fixed-width"
width="180"
>
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-search"
@click="seepraent(scope.row)"
v-hasPermi="['system:studentInfo:edit']"
>查看</el-button
>
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
v-hasPermi="['system:studentInfo:edit']"
>修改</el-button
>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['system:studentInfo:remove']"
>删除</el-button
>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total > 0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<!-- 添加或修改学生信息对话框 -->
<el-dialog
:title="title"
:visible.sync="open"
width="500px"
append-to-body
:before-close="cancel"
>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="所属班级" prop="classId">
<el-button
type=""
@click="innerVisible = true"
style="width: 380px; text-align: left; height: 36px; color: #c0c4cc"
v-if="classinfoName == '请选择所属班级'"
>{{ classinfoName }}</el-button
>
<el-button
type=""
@click="innerVisible = true"
style="width: 380px; text-align: left; height: 36px"
v-else
>{{ classinfoName }}</el-button
>
</el-form-item>
<el-form-item label="学生家长" class="is-required">
<el-button
@click="innerVisibletrue2"
style="width: 380px; text-align: left; height: 36px; color: #c0c4cc"
v-if="parentInfoName == '请选择学生家长'"
>
{{ parentInfoName }}
</el-button>
<el-tag
v-for="tag in tags"
v-else
:key="tag.name"
closable
type=""
:disable-transitions="true"
@close="handleClose(tag)"
style="margin-right: 20px"
>
{{ tag.name }}
</el-tag>
<el-tag
v-if="parentInfoName != '请选择学生家长'"
type="primary"
plain
:disable-transitions="true"
@click="innerVisibletrue2"
style="float: right; margin-top: 4px"
>添加家长</el-tag
>
</el-form-item>
<el-form-item label="民族" prop="nationDictId">
<treeselect
:normalizer="normalizer"
:options="nactionlist"
placeholder="请选择民族"
v-model="form.nationDictId"
style="width: 380px"
/>
</el-form-item>
<el-form-item label="学生姓名" prop="studentName">
<el-input v-model="form.studentName" placeholder="请输入学生姓名" />
</el-form-item>
<el-form-item label="学生编号" prop="studentNumber">
<el-input v-model="form.studentNumber" placeholder="请输入学生编号" />
</el-form-item>
<el-form-item label="学生性别" prop="studentSex">
<el-radio-group v-model="form.studentSex">
<el-radio :label="male">男</el-radio>
<el-radio :label="female">女</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="出生日期" prop="birthDate">
<el-date-picker
clearable
v-model="form.birthDate"
type="date"
value-format="yyyy-MM-dd"
placeholder="请选择出生日期"
:picker-options="pickerOptions"
>
</el-date-picker>
</el-form-item>
<el-form-item label="身份证号" prop="cardNumber">
<el-input v-model="form.cardNumber" placeholder="请输入身份证号" />
</el-form-item>
<el-form-item label="曾用名" prop="onceName">
<el-input v-model="form.onceName" placeholder="请输入曾用名" />
</el-form-item>
<el-form-item label="家庭住址" prop="homeAddress">
<el-input v-model="form.homeAddress" placeholder="请输入家庭住址" />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm">确 定</el-button>
<el-button @click="cancel">取 消</el-button>
</div>
<!-- 学生家长 -->
<el-dialog
width="800px"
title="选择学生家长"
:visible.sync="innerVisible2"
append-to-body
:before-close="prentclickok"
>
<el-form
:model="parentInfoList2"
ref="queryForm"
size="small"
:inline="true"
v-show="showSearch"
label-width="70px"
>
<el-form-item label="家长姓名" prop="parentName">
<el-input
v-model="parentInfoList2.parentName"
placeholder="请输入家长姓名"
clearable
style="width: 160px"
@keyup.enter.native="handleQuery3"
/>
</el-form-item>
<el-form-item label="联系电话" prop="phone">
<el-input
v-model="parentInfoList2.phone"
placeholder="请输入联系电话"
clearable
style="width: 160px"
@keyup.enter.native="handleQuery3"
/>
</el-form-item>
<el-form-item>
<el-button
type="primary"
icon="el-icon-search"
size="mini"
@click="handleQuery3"
>搜索</el-button
>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
>重置</el-button
>
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="innerVisible3 = true"
style="margin-bottom: 40px"
>新增家长</el-button
>
</el-form-item>
</el-form>
<el-table ref="tags" :data="parentInfoList" align="center">
<el-table-column label="请选择" width="100" align="center">
<template slot-scope="scope">
<el-button
type="primary"
style="width: 15px; height: 15px"
circle
v-if="parent1 == scope.row.id || parent2 == scope.row.id"
@click="handleSelectionChange3(scope.row)"
></el-button>
<el-button
v-else
style="width: 15px; height: 15px"
circle
@click="handleSelectionChange2(scope.row)"
></el-button>
</template>
</el-table-column>
<el-table-column
property="parentName"
label="家长姓名"
width="220"
align="center"
>
</el-table-column>
<el-table-column
property="classType"
label="班级性别"
width="220"
align="center"
>
<template slot-scope="scope">
{{ scope.row.parentSex == "MALE" ? "男" : "女" }}
</template>
</el-table-column>
<el-table-column
property="phone"
label="联系电话"
width="220"
align="center"
>
</el-table-column>
</el-table>
<el-button
type="success"
plain
size="mini"
@click="prentclickok"
style="margin-top: 30px; margin-left: 20px"
>选择完成</el-button
>
<pagination
v-show="total3 > 0"
:total="total3"
:page.sync="parentInfoList2.pageNum"
:limit.sync="parentInfoList2.pageSize"
@pagination="getList"
/>
</el-dialog>
<!-- //班级信息表格数据 -->
<el-dialog
width="1000px"
title="选择所属班级"
:visible.sync="innerVisible"
append-to-body
:before-close="cancel3"
>
<el-form
:model="classinfoList2"
ref="queryForm"
size="small"
:inline="true"
v-show="showSearch"
label-width="90px"
>
<el-form-item label="班级名称" prop="className">
<el-input
style="width: 150px"
v-model="classinfoList2.className"
placeholder="请输入班级名称"
clearable
@keyup.enter.native="handleQuery2"
/>
</el-form-item>
<el-form-item label="班级类型" prop="classType">
<el-select
v-model="classinfoList2.classType"
placeholder="请选择"
style="width: 150px"
>
<el-option
v-for="item in options"
:key="item.value"
:label="item.label"
:value="item.classType"
>
</el-option>
</el-select>
</el-form-item>
<el-form-item label="班主任姓名" prop="classTeacher">
<el-input
v-model="classinfoList2.classTeacher"
placeholder="请输入班主任姓名"
style="width: 150px"
clearable
@keyup.enter.native="handleQuery2"
/>
</el-form-item>
<el-form-item>
<el-button
type="primary"
icon="el-icon-search"
size="mini"
@click="handleQuery2"
>搜索</el-button
>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
>重置</el-button
>
</el-form-item>
</el-form>
<el-table :data="classinfoList" align="center" style="margin-top: 10px">
<el-table-column label="请选择" width="80" align="center">
<template slot-scope="scope">
<el-button
type="primary"
v-if="classinfoId == scope.row.id"
style="width: 15px; height: 15px"
circle
@click="classinfoclick(scope.row)"
></el-button>
<el-button
v-else
style="width: 15px; height: 15px"
circle
@click="classinfoclick(scope.row)"
></el-button>
</template>
</el-table-column>
<el-table-column
property="className"
label="班级名称"
width="195"
align="center"
>
</el-table-column>
<el-table-column
property="classType"
label="班级类型"
width="195"
align="center"
>
<template slot-scope="scope">
{{ scope.row.classType == dictValue1 ? "大班" : "" }}
{{ scope.row.classType == dictValue2 ? "中班" : "" }}
{{ scope.row.classType == dictValue3 ? "小班" : "" }}
{{ scope.row.classType == dictValue4 ? "毕业" : "" }}
</template>
</el-table-column>
<el-table-column
property="classTeacher"
label="班主任姓名"
width="195"
align="center"
>
</el-table-column>
<el-table-column
property="phone"
label="联系电话"
width="300"
align="center"
>
</el-table-column>
</el-table>
<pagination
v-show="total2 > 0"
:total="total2"
:page.sync="classinfoList2.pageNum"
:limit.sync="classinfoList2.pageSize"
@pagination="getList"
/>
</el-dialog>
<!-- 修改家长信息对话框 -->
<el-dialog
title="新增家长"
:visible.sync="innerVisible3"
width="500px"
append-to-body
:before-close="cancel2"
>
<el-form
ref="form"
:model="addparentlist"
:rules="rules"
label-width="80px"
>
<el-form-item label="家长姓名" prop="parentName">
<el-input
v-model="addparentlist.parentName"
placeholder="请输入家长姓名"
/>
</el-form-item>
<el-form-item label="家长性别" prop="parentSex">
<el-radio-group v-model="addparentlist.parentSex">
<el-radio :label="male">男</el-radio>
<el-radio :label="female"></el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="联系电话" prop="phone">
<el-input
maxlength="11"
v-model="addparentlist.phone"
placeholder="请输入联系电话"
/>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="addparent">确 定</el-button>
<el-button @click="cancel2">取 消</el-button>
</div>
</el-dialog>
</el-dialog>
<!-- 查看学生父母 -->
<el-dialog
title="查看学生父母"
:visible.sync="innerVisible4"
append-to-body
style="margin-top: 5%"
width="750px"
>
<el-table
:data="parentStudentInfoList"
align="center"
style="margin-top: 10px"
>
<el-table-column
property="parentName"
label="家长姓名"
width="200"
align="center"
>
</el-table-column>
<el-table-column
property="parentSex"
label="家长性别"
width="200"
align="center"
>
<template slot-scope="scope">
{{ scope.row.parentSex == male ? "" : "" }}
</template>
</el-table-column>
<el-table-column
property="phone"
label="联系电话"
width="300"
align="center"
>
</el-table-column>
</el-table>
</el-dialog>
</div>
</template>
<script>
import {
listStudentInfo,
getStudentInfo,
delStudentInfo,
addStudentInfo,
updateStudentInfo,
addparentInfo,
} from "@/api/system/studentInfo";
import { tKindergartenInfo } from "@/api/system/kindergartenInfo";
import { listClassinfo } from "@/api/system/classinfo";
import { listParentInfo } from "@/api/system/parentInfo";
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
export default {
components: { Treeselect },
name: "StudentInfo",
data() {
// 验证手机号的规则
var checkMobile = (rule, value, cb) => {
// 验证手机号的正则表达式
const regMobile =
/^(0|86|17951)?(13[0-9]|15[012356789]|17[678]|18[0-9]|14[57])[0-9]{8}$/;
if (regMobile.test(value)) {
return cb();
}
cb(new Error("请输入合法的手机号"));
};
//验证身份证
var isCardId = (rule, value, callback) => {
if (!value) {
return new Error("请输入身份证号)");
} else {
const reg =
/^\d{6}(18|19|20)?\d{2}(0[1-9]|1[0-2])(([0-2][1-9])|10|20|30|31)\d{3}(\d|X|x)$/;
const card = reg.test(value);
if (!card) {
callback(new Error("身份证号格式有误!"));
} else {
callback();
}
}
};
return {
pickerOptions: {
disabledDate(time) {
return time.getTime() > Date.now();
},
},
//查看家长
parentStudentInfoList: [],
//民族
nationType: "nation_type",
//性别
male: "MALE",
female: "FEMALE",
// 遮罩层
loading: true,
innerVisible: false,
innerVisible2: false,
innerVisible3: false,
innerVisible4: false,
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 总条数
total: 0,
total2: 0,
total3: 0,
// 学生信息表格数据
studentInfoList: [],
//新增家长表
addparentlist: {
parentName: "",
parentSex: "",
phone: "",
},
//家长表
parentlist: [],
parent1: "",
parent2: "",
tags: [],
parentInfoList: [],
parentInfoList2: {
pageNum: 1,
pageSize: 10,
parentName: null,
parentSex: null,
phone: null,
},
parentInfoName: "请选择学生家长",
parentInfoId: "",
//民族表
nactionlist: [],
//班级表
classinfo: [],
classinfoList: [],
classinfoList2: {
pageNum: 1,
pageSize: 10,
kindergartenId: null,
className: null,
classType: null,
},
options: [
{
classType: "",
label: "大班",
},
{
classType: "",
label: "中班",
},
{
classType: "",
label: "小班",
},
{
classType: "",
label: "毕业",
},
],
dictValue1: "",
dictValue2: "",
dictValue3: "",
dictValue4: "",
ClassType: "class_type",
classinfoName: "请选择所属班级",
classinfoId: "",
// 弹出层标题
title: "",
// 是否显示弹出层
open: false,
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
classId: null,
nationDictId: null,
studentName: null,
studentSex: null,
studentNumber: null,
birthDate: null,
cardNumber: null,
onceName: null,
homeAddress: null,
},
// 表单参数
form: {},
form2: {},
// 表单校验
rules: {
phone: [
{
required: true,
validator: checkMobile,
trigger: "blur",
message: "请输入正确的手机号",
},
],
birthDate: [
{ required: true, message: "请选择日期", trigger: "change" },
],
cardNumber: [
{ required: true, message: "请输入证件号", trigger: "blur" },
{ validator: isCardId, trigger: "blur" },
],
parentIdList: [
{ required: true, message: "请选择活动区域", trigger: "change" },
],
classId: [{ required: true, message: "班级不能为空", trigger: "blur" }],
nationDictId: [
{ required: true, message: "民族不能为空", trigger: "blur" },
],
},
};
},
created() {
this.getList();
},
methods: {
cancel2() {
this.innerVisible3 = false;
this.addparentlist = {
parentName: "",
parentSex: "",
phone: "",
};
},
//查看父母
seepraent(row) {
this.reset();
const id = row.id || this.ids;
getStudentInfo(id).then((res) => {
this.parentStudentInfoList = res.data.parentStudentInfoList;
console.log(this.parentStudentInfoList);
this.innerVisible4 = true;
});
},
prentclickok() {
this.innerVisible2 = false;
this.parentInfoList2 = {
pageNum: 1,
pageSize: 10,
parentName: null,
parentSex: null,
phone: null,
};
this.handleQuery3();
},
nactiontype(e) {
var obj = {
59: "汉族",
60: "壮族",
61: "满族",
62: "回族",
63: "苗族",
64: "维吾尔族",
65: "彝族",
66: "土家族",
67: "蒙古族",
68: "藏族",
69: "布依族",
70: "侗族",
71: "瑶族",
72: "朝鲜族",
73: "白族",
74: "哈尼族",
75: "黎族",
76: "哈萨克族",
77: "傣族",
78: "畲族",
79: "傈僳族",
80: "仡佬族",
81: "拉祜族",
82: "东乡族",
83: "佤族",
84: "水族",
85: "纳西族",
86: "羌族",
87: "土族",
88: "锡伯族",
89: "仫佬族",
90: "柯尔克孜族",
91: "达斡尔族",
92: "景颇族",
93: "撒拉族",
94: "布朗族",
95: "毛南族",
96: "塔吉克族",
97: "普米族",
98: "阿昌族",
99: "怒族",
100: "鄂温克族",
101: "京族",
102: "基诺族",
103: "德昂族",
104: "乌孜别克族",
105: "俄罗斯族",
106: "裕固族",
107: "保安族",
108: "门巴族",
109: "鄂伦春族",
110: "独龙族",
111: "塔塔尔族",
112: "赫哲族",
113: "高山族",
114: "珞巴族",
};
return obj[e];
},
//新增家长
addparent() {
addparentInfo(this.addparentlist).then((res) => {
console.log(res);
this.getList();
this.innerVisible3 = false;
this.addparentlist = {
parentName: "",
parentSex: "",
phone: "",
};
});
},
//家长搜索
handleQuery3() {
listParentInfo(this.parentInfoList2).then((response) => {
this.parentInfoList = response.rows;
console.log(this.parentInfoList);
this.total3 = response.total;
});
},
//班级搜索
handleQuery2() {
listClassinfo(this.classinfoList2).then((response) => {
this.classinfoList = response.rows;
this.total2 = response.total;
// console.log(this.classinfoList);
});
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.parentInfoName = "请选择学生家长";
this.parentInfoId = "";
this.classinfoName = "请选择所属班级";
this.classinfoId = "";
this.open = true;
this.title = "添加学生信息";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const id = row.id || this.ids;
console.log(id);
this.tags = [];
this.parentlist = [];
getStudentInfo(id).then((response) => {
this.form = response.data;
this.classinfoName = this.form.className;
this.classinfoId = this.form.classId;
if (this.form.parentStudentInfoList.length == 0) {
} else if (this.form.parentStudentInfoList.length == 1) {
this.parentlist.push(this.form.parentStudentInfoList[0]);
} else if (this.form.parentStudentInfoList.length == 2) {
this.parentlist.push(this.form.parentStudentInfoList[0]);
this.parentlist.push(this.form.parentStudentInfoList[1]);
}
console.log(this.parentlist);
if (this.parentlist.length == 0) {
this.parentInfoName = "请选择学生家长";
this.parentInfoId = "";
this.parent1 = "";
this.parent2 = "";
} else if (this.parentlist.length == 1) {
this.parent1 = this.parentlist[0].id;
var obj = {
name: this.parentlist[0].parentName,
};
this.tags.push(obj);
this.tags.push();
this.parent2 = "";
} else if (this.parentlist.length == 2) {
var obj = {
name: this.parentlist[0].parentName,
};
var obj2 = {
name: this.parentlist[1].parentName,
};
this.tags.push(obj);
this.tags.push(obj2);
this.parent1 = this.parentlist[0].id;
this.parent2 = this.parentlist[1].id;
}
if (this.tags.length == 0) {
this.parentInfoName = "请选择学生家长";
this.parentInfoId = "";
} else {
this.parentInfoName = this.parent1;
}
console.log(this.tags);
console.log(this.form);
console.log(this.parent1, this.parent2);
// if (this.form.parentStudentInfoList.length == 0) {
// this.parentInfoName = "请选择学生家长";
// this.parentInfoId = "";
// this.parent1 = "";
// this.parent2 = "";
// } else if (this.form.parentStudentInfoList.length == 1) {
// this.parent1 = this.form.parentStudentInfoList[0].id;
// this.parent2 = "";
// } else {
// if (this.parent1 == "") {
// this.parent1 = this.form.parentStudentInfoList[0].id;
// } else {
// this.parent2 = this.form.parentStudentInfoList[1].id;
// }
// }
this.form2.id = this.form.id;
this.form2.classId = this.form.classId;
if (this.form.parentStudentInfoList.length == 0) {
} else if (this.form.parentStudentInfoList.length == 1) {
this.form2.parentIdList.push(this.form.parentStudentInfoList[0].id);
} else if (this.form.parentStudentInfoList.length == 2) {
this.form2.parentIdList.push(this.form.parentStudentInfoList[0].id);
this.form2.parentIdList.push(this.form.parentStudentInfoList[1].id);
}
this.form2.nationDictId = this.form.nationDictId;
this.form2.studentName = this.form.studentName;
this.form2.studentSex = this.form.studentSex;
this.form2.studentNumber = this.form.studentNumber;
this.form2.birthDate = this.form.birthDate;
this.form2.cardNumber = this.form.cardNumber;
this.form2.onceName = this.form.onceName;
this.form2.homeAddress = this.form.homeAddress;
console.log(this.form2);
// console.log(this.tags);
// console.log(this.parentlist);
// console.log(this.parent1, this.parent2);
console.log(this.form);
console.log(this.form2);
this.open = true;
this.title = "修改学生信息";
});
},
//取消家长选中
handleSelectionChange3(row) {
console.log(row);
this.parentlist = this.parentlist.filter((e) => e.id != row.id);
this.tags = this.tags.filter((e) => e.name != row.parentName);
console.log(this.tags);
if (this.form.id != null) {
this.form2.parentIdList = this.form2.parentIdList.filter(
(e) => e != row.id
);
} else {
this.form.parentIdList = this.form.parentIdList.filter(
(e) => e != row.id
);
}
console.log(this.form);
console.log(this.form2);
console.log(this.parentlist);
if (this.tags.length == 0) {
this.parentInfoName = "请选择学生家长";
this.parentInfoId = "";
} else {
this.parentInfoName = row.parentName;
}
if (this.parentlist.length == 0) {
this.parentInfoName = "请选择学生家长";
this.parentInfoId = "";
this.parent1 = "";
this.parent2 = "";
} else if (this.parentlist.length == 1) {
this.parent1 = this.parentlist[0].id;
this.parent2 = "";
} else if (this.parentlist.length == 2) {
this.parent1 = this.parentlist[0].id;
this.parent2 = this.parentlist[1].id;
}
console.log(this.parent1, this.parent2);
},
// 家长选中数据
handleSelectionChange2(val) {
// console.log(val);
this.parentlist = this.parentlist.filter((e) => e.id != val.id);
if (this.parentlist.length == 2) {
this.$message.error("最多选择两位");
} else {
this.parentlist.push(val);
}
if (this.parent1 == "") {
this.parent1 = this.parentlist[0].id;
} else {
this.parent2 = this.parentlist[1].id;
}
// this.form2.parentIdList = this.form2.parentIdList.filter(
// (e) => e != val.id
// );
if (this.form.id != null) {
if (this.form2.parentIdList.length == 2) {
this.$message.error("最多选择两位");
} else {
this.form2.parentIdList.push(val.id);
}
} else {
this.form.parentIdList.push(val.id);
}
var obj = {
name: val.parentName,
};
if (this.tags.length == 2) {
this.$message.error("最多选择两位");
} else {
this.tags.push(obj);
}
this.parentInfoId = val.id;
if (this.tags.length == 0) {
this.parentInfoName = "请选择学生家长";
this.parentInfoId = "";
} else {
this.parentInfoName = val.parentName;
}
console.log(this.form);
console.log(this.form2);
console.log(this.parentlist);
console.log(this.parent1, this.parent2);
console.log(this.tags);
},
handleSelectionChange(selection) {
// console.log(selection);
this.ids = selection.map((item) => item.id);
console.log(this.ids);
this.single = selection.length !== 1;
this.multiple = !selection.length;
},
innerVisibletrue2() {
this.innerVisible2 = true;
},
//家长表格取消选中
//移除tage
handleClose(tag) {
this.tags.splice(this.tags.indexOf(tag), 1);
console.log(tag);
// this.parentlist.splice(this.parentlist.indexOf(parentName==tag),1)
this.parentlist.map((e) => {
console.log(e);
if (e.parentName == tag.name) {
this.parentlist.splice(this.parentlist.indexOf(e), 1);
}
});
if (this.parentlist.length == 0) {
this.parentInfoName = "请选择学生家长";
this.parentInfoId = "";
this.parent1 = "";
this.parent2 = "";
} else if (this.parentlist.length == 1) {
this.parent1 = this.parentlist[0].id;
this.parent2 = "";
} else {
if (this.parent1 == "") {
this.parent1 = this.parentlist[0].id;
} else {
this.parent2 = this.parentlist[1].id;
}
}
if (this.form.id != null) {
this.form2.parentIdList = this.form2.parentIdList.filter(
(e) => e == this.parentlist.map((e) => e.id)
);
} else {
this.form.parentIdList = this.form.parentIdList.filter(
(e) => e == this.parentlist.map((e) => e.id)
);
}
console.log(this.form);
console.log(this.form2);
console.log(this.tags);
console.log(this.parentlist);
console.log(this.parent1, this.parent2);
},
classinfoclick(item) {
console.log(item);
this.classinfoName = item.className;
this.classinfoId = item.id;
this.form.classId = item.id;
this.form2.classId = item.id;
this.innerVisible = false;
console.log(this.form, this.form2);
},
normalizer(node) {
if (node.children && !node.children.length) {
delete node.children;
}
return {
id: node.dictCode,
label: node.dictLabel,
children: node.children,
};
},
// 取消按钮
cancel() {
this.open = false;
this.reset();
this.parentInfoName = "请选择学生家长";
this.parentlist = [];
this.parentInfoId = "";
this.parent1 = "";
this.parent2 = "";
this.classinfoName = "请选择所属班级";
this.classinfoId = "";
this.tags = [];
console.log(this.tags);
},
// 表单重置
reset() {
this.form2 = {
id: null,
classId: null,
parentIdList: [],
nationDictId: null,
studentName: null,
studentSex: null,
studentNumber: null,
birthDate: null,
cardNumber: null,
onceName: null,
homeAddress: null,
};
this.form = {
id: null,
classId: null,
parentIdList: [],
nationDictId: null,
studentName: null,
studentSex: null,
studentNumber: null,
birthDate: null,
cardNumber: null,
onceName: null,
homeAddress: null,
};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
cancel3() {
this.resetQuery();
this.innerVisible = false;
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
/** 查询学生信息列表 */
getList() {
this.loading = true;
listClassinfo(this.classinfoList2).then((response) => {
this.classinfoList = response.rows;
this.total2 = response.total;
// console.log(this.classinfoList);
});
tKindergartenInfo(this.nationType).then((res) => {
this.nactionlist = res.data;
console.log(this.nactionlist);
});
tKindergartenInfo(this.ClassType).then((res) => {
// console.log(res.data);
this.options[0].classType = res.data[0].dictValue;
this.options[1].classType = res.data[1].dictValue;
this.options[2].classType = res.data[2].dictValue;
this.options[3].classType = res.data[3].dictValue;
this.dictValue1 = res.data[0].dictValue;
this.dictValue2 = res.data[1].dictValue;
this.dictValue3 = res.data[2].dictValue;
this.dictValue4 = res.data[3].dictValue;
});
listParentInfo(this.parentInfoList2).then((response) => {
this.parentInfoList = response.rows;
console.log(this.parentInfoList);
this.total3 = response.total;
this.loading = false;
});
listStudentInfo(this.queryParams).then((res) => {
// res.rows.forEach((el) => {
// el.className = this.classinfoList.filter(
// (e) => e.id == el.classId
// )[0].className;
// });
this.studentInfoList = res.rows;
// console.log(this.studentInfoList);
this.total = res.total;
this.loading = false;
});
},
/** 提交按钮 */
submitForm() {
console.log(this.form);
console.log(this.form2);
this.$refs["form"].validate((valid) => {
if (valid) {
if (this.form.id != null) {
this.form2.nationDictId = this.form.nationDictId;
this.form2.studentName = this.form.studentName;
this.form2.studentSex = this.form.studentSex;
this.form2.studentNumber = this.form.studentNumber;
this.form2.birthDate = this.form.birthDate;
this.form2.cardNumber = this.form.cardNumber;
this.form2.onceName = this.form.onceName;
this.form2.homeAddress = this.form.homeAddress;
updateStudentInfo(this.form2).then((response) => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
});
} else {
addStudentInfo(this.form).then((response) => {
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
});
}
}
});
},
/** 删除按钮操作 */
handleDelete(row) {
const ids = row.id || this.ids;
this.$modal
.confirm("是否确认删除该学生信息吗?")
.then(function () {
return delStudentInfo(ids);
})
.then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
})
.catch(() => {});
},
/** 导出按钮操作 */
handleExport() {
this.download(
"system/studentInfo/export",
{
...this.queryParams,
},
`studentInfo_${new Date().getTime()}.xlsx`
);
},
},
};
</script>