国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

學(xué)生管理系統(tǒng)-03項目案例(3)

這篇具有很好參考價值的文章主要介紹了學(xué)生管理系統(tǒng)-03項目案例(3)。希望對大家有所幫助。如果存在錯誤或未考慮完全的地方,請大家不吝賜教,您也可以點擊"舉報違法"按鈕提交疑問。

一、用戶列表

1、編寫api接口
//導(dǎo)入封裝后的axios
import {instance} from '@/util/request'
export default{
 ? getUsers:params=>instance.get('/users/getUsers',{params})
}
2、表格渲染
<template>
 ?<el-card>
 ? ?<!-- 
 ? ? ? ? ? ?當el-table元素中注入data對象數(shù)組后,
 ? ? ? ? ? ?在el-table-column中用prop屬性來對應(yīng)對象中的鍵名即可填入數(shù)據(jù),
 ? ? ? ? ? ?用label屬性來定義表格的列名。可以使用width屬性來定義列寬。
 ? ? ? ? -->
 ? ?<el-table :data="list" stripe border height="600">
 ? ? ?<el-table-column prop="username" label="用戶名" align="center" />
 ? ? ?<el-table-column prop="phone" label="電話" align="center"/>
 ? ? ?<el-table-column prop="email" label="郵箱" align="center"/>
 ? ? ?<el-table-column prop="auth" label="角色" align="center">
 ? ? ? ? ?<template slot-scope="scope">
 ? ? ? ? ? ?<el-tag :type="scope.row.auth==1?'primary':'success'">
 ? ? ? ? ? ? ? ? {{scope.row.auth==1?"超級管理員":scope.row.auth==2?"普通管理員":""}}
 ? ? ? ? ? ?</el-tag>
 ? ? ? ? ?</template>
 ? ? ?</el-table-column>
 ? ? ?<el-table-column prop="image" label="頭像" align="center">
 ? ? ? ? ? ?<template slot-scope="scope">
 ? ? ? ? ? ? ? ?<el-avatar :size="50" :src="scope.row.image"></el-avatar>
 ? ? ? ? ? ?</template>
 ? ? ?</el-table-column>
 ? ? ?<el-table-column label="操作" align="center">
 ? ? ? ? ? <template slot-scope="scope">
 ? ? ? ? ? ? ? ?<el-button type="primary" size="mini" icon="el-icon-edit">編輯</el-button>
 ? ? ? ? ? ? ? ?<el-button type="danger" size="mini" icon="el-icon-delete">刪除</el-button>
 ? ? ? ? ? </template>
 ? ? ?</el-table-column>
 ? ?</el-table>
 ?</el-card>
</template>
?
<script>
export default {
 ?data() {
 ? ?return {
 ? ? ?list: [],
 ? ? ?total: 0,
 ?  };
  },
 ?methods: {
 ? ?async getUsers() {
 ? ? ?const result = await this.$api.users.getUsers();
 ? ? ?console.log("result", result.data);
 ? ? ?this.list = result.data.result;
 ? ? ?this.total = result.data.total;
 ?  },
  },
 ?created() {
 ? ?this.getUsers();
  },
};
</script>
?
<style>
</style>
3、分頁
 <!-- 分頁區(qū)域 -->
 ? ? <el-pagination
 ? ? ? background
 ? ? ? layout="sizes, prev, pager, next, jumper, ->, total, slot"
 ? ?  :total="total"
 ? ?  :page-size="query.pageSize"
 ? ?  :current-page="query.currentPage"
 ? ?  :page-sizes="[5,10,15,20]"
 ? ? ?@size-change="changePageSize"
 ? ? ?@current-change="changeCurrentPage">
 ? ? </el-pagination>
export default {
 ?data() {
 ? ?return {
 ? ? ?list: [],
 ? ? ?total: 0,
 ? ? ?query:{
 ? ? ? ?pageSize:5,
 ? ? ? ?currentPage:1
 ? ?  }
 ?  };
  },
 ?methods: {
 ? ?async getUsers() {
 ? ? ?const result = await this.$api.users.getUsers(this.query);
 ? ? ?console.log("result", result.data);
 ? ? ?this.list = result.data.result;
 ? ? ?this.total = result.data.total;
 ?  },
 ? ?changePageSize(args){
 ? ? ?this.query.pageSize=args
 ? ? ?this.getUsers()
 ?  },
 ? ?changeCurrentPage(args){
 ? ? ? this.query.currentPage=args
 ? ? ? this.getUsers()
 ?  }
  },
 ?created() {
 ? ?this.getUsers();
  },
};
4、搜索功能
  • 首先在data中的query對象中添加type和value屬性

export default {
 ?data() {
 ? ?return {
 ? ? ?query:{
 ? ? ? ?type:'',
 ? ? ? ?value:'',
 ? ? ? ?pageSize:5,
 ? ? ? ?currentPage:1
 ? ?  }
 ?  };
  },
};
  • 頁面中進行布局

<el-form :inline="true">
 ? ? ? ?<el-form-item>
 ? ? ? ? ? ?<el-select placeholder="請選擇類型" v-model="query.type">
 ? ? ? ? ? ? ? ?<el-option label="用戶名" value="username"></el-option>
 ? ? ? ? ? ? ? ?<el-option label="手機號" value="phone"></el-option>
 ? ? ? ? ? ? ? ?<el-option label="郵箱" value="email"></el-option>
 ? ? ? ? ? ?</el-select>
 ? ? ? ?</el-form-item>
 ? ? ? ?<el-form-item>
 ? ? ? ? ? ?<el-input placeholder="請輸入值" v-model="query.value"></el-input>
 ? ? ? ?</el-form-item>
 ? ? ? ?<el-form-item>
 ? ? ? ? ? ? <el-button icon="el-icon-search" type="primary" @click="getUsers">搜索</el-button>
 ? ? ? ?</el-form-item>
 ? ?</el-form>
5、注冊

6、修改用戶
  • 在api接口中編寫修改方法

import {instance} from '@/util/request'
export default{
 ? updateUsers:data=>instance.put('/users/updateUsers',data)
}
  • 為編輯按鈕綁定事件

<template slot-scope="scope">
 ? ? ? <el-button type="primary" size="mini" icon="el-icon-edit" @click="updateUser(scope)">編輯</el-button> ? ? 
</template>
  • 在data中定義

data(){
    return{
      updateDialogVisible:false,
      updateUserItem:{
        username:'',
        auth:1
      }
    }
}
  • 在methods中定義一個修改方法

methods:{
    async updateUserApi(){
      console.log('修改后的數(shù)據(jù)',this.updateUserItem);
      const result=await this.$api.users.updateUsers(this.updateUserItem)
      console.log('resultss',result);
      if(result.code){
        this.$message.success(result.message)
        //模態(tài)框關(guān)閉
        this.updateDialogVisible=false
      }
    }
}
  • 使用深淺拷貝解決修改中的一個問題

如上程序有一個問題,就是當修改的時候,在未點擊確認按鈕之前,當文本框中的內(nèi)容變化,table表格中對應(yīng)的行也在變化,頁面刷新后數(shù)據(jù)又還原了,實際上這樣是有問題的,解決方案就是對數(shù)據(jù)進行深拷貝

methods:{
    updateUser(args){
      //對數(shù)據(jù)進行深拷貝
      this.updateUserItem={...args.row}
      this.updateDialogVisible=true
    },
    async updateUserApi(){
      const result=await this.$api.users.updateUsers(this.updateUserItem)
      if(result.code){
        this.$message.success(result.message)
        //重新渲染列表頁面
        this.getUsers()
        //模態(tài)框關(guān)閉
        this.updateDialogVisible=false
      }
    }
}

二、學(xué)員管理

1、增加學(xué)員
1.1、編寫api接口
  • 首先在api/modules文件夾下創(chuàng)建students.js文件,在該文件中編寫增加的方法

import {instance} from '@/util/request'
export default{
    addStudents:data=>instance.post('/students/addStudents',data)
}
  • 在api文件下的index.js中對studnets模塊進行匯總

import users from "./modules/users";
import students from "./modules/students";
export default{
    users,students
}
1.2、獲取專業(yè)信息
  • 首先在api/modules文件夾下新建subjects.js文件,在該文件下定義查詢專業(yè)的方法

import {instance} from '@/util/request'
export default{
    getSubjects:params=>instance.get("/subjects/getSubjects",{params})
}
  • 然后在api/index.js中進行匯總

import users from "./modules/users";
import students from "./modules/students";
import subjects from "./modules/subjects";
export default{
    users,students,subjects
}
  • 在studentList.vue組件中獲取所有的專業(yè)并綁定到下拉列表中

export default {
    data(){
        return{
            addStudentDialogVisible:false,
            subjectsAllList:[]
        }
    },
    methods:{
        openAddDialog(){
            this.addStudentDialogVisible=true
        },
        handleCloseAddStudentDialog(){
            this.addStudentDialogVisible=false
        },
        //獲取所有的專業(yè)
        async getAllSubjects(){
            const result=await this.$api.subjects.getSubjects()
            console.log('所有專業(yè)',result.data.result);
            this.subjectsAllList=result.data.result
        }
    },
    created(){
        this.getAllSubjects()
    }
}
<el-form-item label="專業(yè)">
   <el-select>
     <el-option v-for="item in subjectsAllList" :key="item._id" :label="item.name" :value="item._id"></el-option>
   </el-select>
</el-form-item>
1.3、通過專業(yè)獲取班級信息

這里通過watch監(jiān)聽器來完成文章來源地址http://www.zghlxwxcb.cn/news/detail-606466.html

watch:{
        'addStudentItem.subjectsId':{
            handler:async function(newVal){
                let result=await this.$api.classes.getClassesBySubjectsId(newVal)
          
                this.classesBySubjectList=result.data.result
                this.addStudentItem.classesId=""
            }
        }
    }
1.4、上傳圖片
<el-upload
        class="avatar-uploader"
        action="http://www.zhaijizhe.cn:3005/images/uploadImages"
        :show-file-list="false"
        :on-success="handleAvatarSuccess"
        :before-upload="beforeAvatarUpload">
        <img v-if="addStudentItem.image" :src="addStudentItem.image" class="avatar">
         <i v-else class="el-icon-plus avatar-uploader-icon"></i>
 </el-upload>
 methods:{
        handleAvatarSuccess(args){
            console.log('args',args);
           this.addStudentItem.image=`http://www.zhaijizhe.cn:3005${args.data[0]}`
           
        },
        beforeAvatarUpload(file){
            const isJPG = file.type === 'image/jpeg';
            const isLt2M = file.size / 1024 / 1024 < 2;

            if (!isJPG) {
            this.$message.error('上傳頭像圖片只能是 JPG 格式!');
            }
            if (!isLt2M) {
            this.$message.error('上傳頭像圖片大小不能超過 2MB!');
            }
            return isJPG && isLt2M;
        }
    },
1.5、增加學(xué)生
 methods:{
        async addStudentApi(){
            // console.log('學(xué)生對象',this.addStudentItem);
            const result=await this.$api.students.addStudents(this.addStudentItem)
            if(result.code){
                this.$message.success(result.message)
                //將表單中的數(shù)據(jù)清空
                this.addStudentItem.name=""
                this.addStudentItem.age=""
                this.addStudentItem.gender=""
                this.addStudentItem.subjectsId=""
                this.addStudentItem.classesId=""
                this.addStudentItem.image=""
                this.addStudentDialogVisible=false
            }
        }
   }

到了這里,關(guān)于學(xué)生管理系統(tǒng)-03項目案例(3)的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實不符,請點擊違法舉報進行投訴反饋,一經(jīng)查實,立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費用

相關(guān)文章

  • 【項目案例】前后端分離項目 【W(wǎng)eb圖書管理系統(tǒng) 】SpringBoot + Vue + Element UI + Mysql

    【項目案例】前后端分離項目 【W(wǎng)eb圖書管理系統(tǒng) 】SpringBoot + Vue + Element UI + Mysql

    ?? 博主介紹 : 博主從事應(yīng)用安全和大數(shù)據(jù)領(lǐng)域,有8年研發(fā)經(jīng)驗,5年面試官經(jīng)驗,Java技術(shù)專家,WEB架構(gòu)師,阿里云專家博主,華為云云享專家,51CTO 專家博主 Java知識圖譜點擊鏈接: 體系化學(xué)習(xí)Java(Java面試專題) ???? 感興趣的同學(xué)可以收藏關(guān)注下 , 不然下次找不到喲

    2024年02月07日
    瀏覽(40)
  • 【項目案例】前后端分離項目 【中小企業(yè)辦公自動化管理系統(tǒng) 】SpringBoot + Vue + Element UI + Mysql

    【項目案例】前后端分離項目 【中小企業(yè)辦公自動化管理系統(tǒng) 】SpringBoot + Vue + Element UI + Mysql

    ?? 博主介紹 : 博主從事應(yīng)用安全和大數(shù)據(jù)領(lǐng)域,有8年研發(fā)經(jīng)驗,5年面試官經(jīng)驗,Java技術(shù)專家,WEB架構(gòu)師,阿里云專家博主,華為云云享專家,51CTO 專家博主 Java知識圖譜點擊鏈接: 體系化學(xué)習(xí)Java(Java面試專題) ???? 感興趣的同學(xué)可以收藏關(guān)注下 , 不然下次找不到喲

    2024年02月14日
    瀏覽(32)
  • Python學(xué)生通訊錄管理系統(tǒng)案例(文件版)

    Python學(xué)生通訊錄管理系統(tǒng)案例(文件版)

    目錄 1.打印輸出學(xué)生通訊錄管理系統(tǒng)的菜單 2.接收用戶從鍵盤輸入的選擇序號 3.根據(jù)輸入的選擇序號,判斷并執(zhí)行不同的功能 注意:本例中,要想保存所以學(xué)生的通訊信息,需要用到字典。 1.打印輸出學(xué)生通訊錄管理系統(tǒng)的菜單 首先我們先定義一個showMenu()函數(shù),實現(xiàn)打印輸

    2024年02月08日
    瀏覽(93)
  • html+css+js 學(xué)生信息管理系統(tǒng)

    html+css+js 學(xué)生信息管理系統(tǒng)

    需求:Web前端開發(fā)技術(shù)完成管理系統(tǒng)后臺管理功能,主要包括用戶登錄、系統(tǒng)主界面(要求直接跳轉(zhuǎn)到用戶管理界面,可選做一個系統(tǒng)后臺管理主界面,用戶管理作為主界面下的某個子功能,)并實現(xiàn)一個具體功能增、刪、改的界面設(shè)計。 1. 用戶登錄 輸入賬號、密碼。如果賬號

    2023年04月11日
    瀏覽(20)
  • Java連接數(shù)據(jù)庫(學(xué)生管理系統(tǒng)案例,可以實現(xiàn)增刪改查)

    Java連接數(shù)據(jù)庫(學(xué)生管理系統(tǒng)案例,可以實現(xiàn)增刪改查)

    首先,需要做一個準備工作 ——下載jar包,這個包是用來支持數(shù)據(jù)庫的連接的 官網(wǎng)的下載鏈接:MySQL :: Download Connector/J 點擊鏈接進入頁面: 選擇畫紅框的下載按鈕。 與此同時,打開IDEA開發(fā)工具,在當前項目目錄下新建一個lib目錄文件夾用來存放第三方j(luò)ar包,這樣做方便管

    2024年02月07日
    瀏覽(27)
  • QT項目-學(xué)生管理系統(tǒng)

    QT項目-學(xué)生管理系統(tǒng)

    ? 本文章主要講解本人在QT學(xué)習(xí)期間所開發(fā)的項目-學(xué)生管理系統(tǒng),代碼主要參考于網(wǎng)上查找。 ?功能主要包括,學(xué)生信息的插入刪除,以及修改。 再加上按照id,或者成績的升降序排序 1.pro 2.widget.h 3. main.cpp 4.widget.cpp 5.widget.ui 總結(jié) 項目處于學(xué)習(xí)階段所做,參考了一些網(wǎng)絡(luò)上

    2024年02月12日
    瀏覽(18)
  • 學(xué)生管理系統(tǒng)-01項目簡介

    一、項目簡介 項目名稱:學(xué)生管理系統(tǒng) 項目功能 用戶管理 用戶登錄 用戶的注冊 用戶增加 用戶刪除 用戶的修改 學(xué)生管理 用戶的列表渲染 用戶的分頁操作 用戶的搜索 用戶的增加 用戶刪除 用戶編輯 excel報表的導(dǎo)出 班級管理 專業(yè)管理 班主任管理 教師管理 課程管理 可視化

    2024年02月15日
    瀏覽(17)
  • 案例:創(chuàng)建一個學(xué)生管理系統(tǒng)(PXSCJ1)的數(shù)據(jù)庫(SQL)

    案例:創(chuàng)建一個學(xué)生管理系統(tǒng)(PXSCJ1)的數(shù)據(jù)庫(SQL)

    1、新建數(shù)據(jù)庫:PXSCJ1 2、創(chuàng)建并確認屬性:XSB、KCB、CJB 代碼見上! 3、設(shè)計每個表的實體完整性:鍵、索引 代碼見上! ? ?4、設(shè)計每個表的域完整性:CHECK語句 代碼見上! ? ? ?5、建立表與表之間的參照完整性:XSB與CJB,KCB與CJB 代碼見上! 6、輸入表數(shù)據(jù):增加、刪除、修改

    2024年02月10日
    瀏覽(24)
  • 【Java】學(xué)生管理系統(tǒng)項目演示

    目錄 學(xué)生管理系統(tǒng) 學(xué)生管理系統(tǒng)代碼思路分析 nextLine()?和 nextInt() 區(qū)別 需求:實現(xiàn)對學(xué)生的增刪改查功能,學(xué)生(學(xué)號,姓名,年齡,地址)字段 定義學(xué)生 Student 實體類 成員屬性 (學(xué)號,姓名,年齡,地址); 定義容器(ArrayList) 集合存入對象; 定義StudentManage 對 Stu

    2024年02月07日
    瀏覽(17)
  • JavaWeb小項目——【源碼】使用Vue+axios+Servlet+Lombok+JDBC+MySQL技術(shù)棧實現(xiàn)云筆記管理系統(tǒng)案例的開發(fā)

    JavaWeb小項目——【源碼】使用Vue+axios+Servlet+Lombok+JDBC+MySQL技術(shù)棧實現(xiàn)云筆記管理系統(tǒng)案例的開發(fā)

    使用Vue+axios+Servlet+Lombok+JDBC+MySQL技術(shù)棧實現(xiàn)云筆記管理系統(tǒng)案例的開發(fā) (一)題目要求 使用Vue+axios+Servlet+Lombok+JDBC+MySQL技術(shù)棧實現(xiàn)云筆記管理系統(tǒng)案例的開發(fā) (二)數(shù)據(jù)庫設(shè)計(10分) 創(chuàng)建數(shù)據(jù)庫woniu_note (1)用戶表:t_user,必要字段包含:用戶名(username)、密碼(passwd)

    2024年02月09日
    瀏覽(22)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包