123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359 |
- <template>
- <div class="m-container">
- <h2>
- <div class="squrt"></div>学员列表
- </h2>
- <div class="m-core">
- <div class="newBand"
- v-permission="'studentManage/register'"
- @click="addStudent">新增学员</div>
- <!-- 搜索标题 -->
- <el-form :inline="true"
- class="searchForm"
- v-model="searchForm">
- <el-form-item>
- <el-input placeholder="家长联系电话"
- @keyup.enter.native='onSearch'
- v-model="searchForm.search"></el-input>
- </el-form-item>
- <el-form-item prop='organId'>
- <el-select class='multiple'
- v-model="searchForm.organId"
- clearable
- placeholder="请选择分部">
- <el-option v-for="(item,index) in organList"
- :key="index"
- :label="item.name"
- :value="item.id"></el-option>
- </el-select>
- </el-form-item>
- <el-form-item>
- <el-input placeholder="学生姓名"
- @keyup.enter.native='onSearch'
- v-model="searchForm.studentName"></el-input>
- </el-form-item>
- <el-form-item>
- <el-button @click="onSearch"
- type="danger">搜索</el-button>
- <el-button @click="onReSet"
- type="primary">重置</el-button>
- </el-form-item>
- </el-form>
- <!-- 列表 -->
- <div class="tableWrap">
- <el-table :data='tableList'
- :header-cell-style="{background:'#EDEEF0',color:'#444'}">
- <el-table-column align='center'
- prop="userId"
- label="学员编号">
- </el-table-column>
- <el-table-column align='center'
- prop="username"
- label="学员姓名">
- </el-table-column>
- <el-table-column align='center'
- label="性别">
- <template slot-scope="scope">
- {{ scope.row.gender ? '男': '女' }}
- </template>
- </el-table-column>
- <el-table-column align='center'
- prop="realName"
- label="家长姓名">
- </el-table-column>
- <el-table-column align='center'
- prop="parentsPhone"
- label="家长联系电话">
- </el-table-column>
- <el-table-column align='center'
- prop="courseBalance"
- label="课程余额(元)">
- </el-table-column>
- <el-table-column align='center'
- label="操作">
- <template slot-scope="scope">
- <router-link style="color:#409EFF"
- v-permission="'/studentDetail'"
- :to="{path:`/business/studentDetail?userId=${scope.row.userId}`,query:{search:JSON.stringify(searchForm),rules:JSON.stringify(pageInfo)}}">查看</router-link>
- <el-button type="text"
- v-permission="'studentManage/studentUpdate'"
- @click="resetStudent(scope.row)">修改</el-button>
- </template>
- </el-table-column>
- </el-table>
- <pagination :total="pageInfo.total"
- :page.sync="pageInfo.page"
- :limit.sync="pageInfo.limit"
- :page-sizes="pageInfo.page_size"
- @pagination="getList" />
- </div>
- </div>
- <el-dialog :title="maskName"
- width="700px"
- label-width='100px'
- label-position="right"
- :visible.sync="studentVisible">
- <el-divider>基本信息</el-divider>
- <el-form :model="studentForm"
- :inline='true'
- label-width="80px"
- label-position="right"
- ref='studentForm'
- :rules="studentRules">
- <el-form-item label="联系电话"
- :rules="[{ required: true, message: '请输入手机号' }, { pattern: /^1[3456789]\d{9}$/, message: '请输入正确的手机号', trigger: 'blur' }]">
- <!-- @blur="checkPhone(studentForm.phone)" -->
- <el-input v-model="studentForm.phone"></el-input>
- </el-form-item>
- <el-form-item label="所属分部"
- v-if="isNew"
- prop="organId">
- <el-select class='multiple'
- v-model="studentForm.organId"
- clearable
- placeholder="请选择分部">
- <el-option v-for="(item,index) in organList"
- :key="index"
- :label="item.name"
- :value="item.id"></el-option>
- </el-select>
- </el-form-item>
- <el-form-item label="学生姓名"
- prop="name">
- <el-input v-model="studentForm.name"></el-input>
- </el-form-item>
- <el-form-item label="学生性别"
- prop="sex">
- <el-select class='multiple'
- v-model="studentForm.sex"
- clearable
- placeholder="请选择分部">
- <el-option :value="0"
- label="女"></el-option>
- <el-option :value="1"
- label="男"></el-option>
- </el-select>
- </el-form-item>
- <!-- <el-form-item label="名族"
- prop="nation">
- <el-input v-model="studentForm.nation"></el-input>
- </el-form-item> -->
- <el-form-item label="家长姓名">
- <el-input v-model="studentForm.parseName"></el-input>
- </el-form-item>
- <el-form-item label="出生日期">
- <el-date-picker v-model="studentForm.date"
- value-format="yyyy-MM-dd"
- type="date"
- placeholder="选择日期">
- </el-date-picker>
- </el-form-item>
- </el-form>
- <div slot="footer"
- class="dialog-footer">
- <el-button @click="studentVisible = false">取 消</el-button>
- <el-button type="primary"
- v-if="isNew"
- @click="submitAddStudent">确 定</el-button>
- <el-button type="primary"
- v-if="!isNew"
- @click="resetStudentSubmie">确 定</el-button>
- </div>
- </el-dialog>
- </div>
- </template>
- <script>
- import pagination from '@/components/Pagination/index'
- import { queryStudentList, getStudentInfoByPhone, registerStudent, updateStudent } from '@/api/studentManager'
- import { getEmployeeOrgan } from '@/api/buildTeam'
- import store from '@/store'
- export default {
- name: 'studentList',
- components: { pagination },
- data () {
- return {
- studentVisible: false,
- searchForm: {
- organId: null,
- search: null,
- studentName: null
- },
- searchList: [],
- tableList: [],
- organList: [],
- pageInfo: {
- // 分页规则
- limit: 10, // 限制显示条数
- page: 1, // 当前页
- total: 0, // 总条数
- page_size: [10, 20, 40, 50] // 选择限制显示条数
- },
- studentForm: {
- phone: '',
- organId: '',
- name: '',
- sex: '',
- parseName: '',
- date: '',
- nation: ''
- },
- studentRules: {
- name: [{ required: true, message: '请输入学生姓名' },],
- sex: [{ required: true, message: '请选择学生姓名' },],
- date: [{ required: true, message: '请选择出生日期' },],
- organId: [{ required: true, message: '请选择分部' }],
- nation: [{ required: true, message: '请输入名族' }]
- },
- isNew: false,
- active: null,
- maskName: '新增学员'
- }
- },
- mounted () {
- if (this.$route.query.search) {
- this.$route.query.search instanceof Object ? this.searchForm = this.$route.query.search : this.searchForm = JSON.parse(this.$route.query.search);
- }
- if (this.$route.query.rules) {
- this.$route.query.rules instanceof Object ? this.pageInfo = this.$route.query.rules : this.pageInfo = JSON.parse(this.$route.query.rules);
- }
- getEmployeeOrgan().then(res => {
- if (res.code == 200) {
- this.organList = res.data;
- }
- })
- this.getList();
- },
- methods: {
- onSearch () {
- this.pageInfo.page = 1;
- this.getList()
- },
- getList () {
- let params = this.searchForm
- params.rows = this.pageInfo.limit
- params.page = this.pageInfo.page
- params.organId ? params.organId : params.organId = null;
- queryStudentList(params).then(res => {
- if (res.code == 200) {
- this.tableList = res.data.rows
- this.pageInfo.total = res.data.total
- }
- })
- },
- onReSet () {
- this.searchForm = {
- organId: null,
- search: null,
- studentName: null
- }
- },
- checkPhone (val) {
- var regu = /^1[3456789]\d{9}$/;
- var re = new RegExp(regu);
- if (re.test(val)) {
- getStudentInfoByPhone({ mobile: this.studentForm.phone }).then(res => {
- if (res.code == 200) {
- if (res.data) {
- this.studentForm = {
- name: res.data.name,
- sex: res.data.gender,
- parseName: res.data.parentsName,
- // sound: parseInt(res.data.subjectId),
- phone: val,
- date: res.data.birthdate
- }
- }
- }
- })
- }
- },
- submitAddStudent () {
- // 效验 然后组数据提交
- this.$refs['studentForm'].validate(item => {
- if (item) {
- let obj = {
- phone: this.studentForm.phone,
- username: this.studentForm.name,
- gender: this.studentForm.sex,
- realName: this.studentForm.parseName,
- birthdate: this.studentForm.date,
- organId: this.studentForm.organId,
- nation: this.studentForm.nation
- }
- registerStudent(obj).then(res => {
- if (res.code == 200) {
- this.$message.success('添加成功');
- this.studentVisible = false;
- this.getList()
- }
- })
- }
- })
- },
- // 修改学生信息
- resetStudentSubmie () {
- this.$refs['studentForm'].validate(item => {
- if (item) {
- let obj = {
- phone: this.studentForm.phone,
- username: this.studentForm.name,
- gender: this.studentForm.sex,
- realName: this.studentForm.parseName,
- birthdate: this.studentForm.date,
- organId: this.studentForm.organId,
- id: this.active.userId,
- nation: this.studentForm.nation
- }
- updateStudent(obj).then(res => {
- if (res.code == 200) {
- this.$message.success('修改成功');
- this.studentVisible = false;
- this.getList()
- }
- })
- }
- })
- },
- addStudent () {
- this.isNew = true;
- this.studentVisible = true;
- this.maskName = '新增学员'
- },
- resetStudent (row) {
- this.isNew = false;
- this.active = row;
- this.studentVisible = true;
- this.maskName = '修改学员'
- this.studentForm = {
- phone: row.parentsPhone,
- name: row.username,
- sex: row.gender,
- parseName: row.realName,
- date: row.birthdate,
- nation: row.nation
- }
- }
- },
- watch: {
- studentVisible (val) {
- if (!val) {
- this.studentForm = {
- phone: '',
- organId: '',
- name: '',
- sex: '',
- parseName: '',
- date: '',
- nation: ''
- }
- // this.studentForm.
- }
- }
- }
- }
- </script>
- <style lang="scss">
- </style>
|