From 0af507deb2a8b08a606b795d73c660d02ecb7f49 Mon Sep 17 00:00:00 2001
From: fuliqi <fuliqi@qq.com>
Date: 星期四, 06 六月 2024 17:11:23 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 src/views/Manage/ClassManagement/ClassStaff.vue |  297 +++++++++++++++++++++++++++++++++++++++-------------------
 1 files changed, 198 insertions(+), 99 deletions(-)

diff --git a/src/views/Manage/ClassManagement/ClassStaff.vue b/src/views/Manage/ClassManagement/ClassStaff.vue
index b6849c8..468e550 100644
--- a/src/views/Manage/ClassManagement/ClassStaff.vue
+++ b/src/views/Manage/ClassManagement/ClassStaff.vue
@@ -3,11 +3,12 @@
   <div class="c">
     <div class="bg">
       <div class="main">
-        <TitleIndex title="鐝骇浜哄憳绠$悊" />
         <div class="content">
           <!-- 鐝骇鍚嶇О -->
           <div style="padding-bottom:20px; border-bottom: 3px solid #409EFF;margin-bottom: 20px;">
             <span>{{title}}</span>
+            <el-button @click="handlerAddStudent" type="primary" size="small">鏂板瀛﹀憳</el-button>
+            <el-button @click="open = true" type="primary" size="small">瀛﹀憳璋冩暣</el-button>
           </div>
           <!-- 琛ㄦ牸 -->
           <el-table
@@ -26,13 +27,14 @@
             </el-table-column>
             <el-table-column
               align="center"
-              prop="name"
+              prop="realName"
               label="濮撳悕"
             >
             </el-table-column>
             <el-table-column
               align="center"
               prop="sex"
+              :formatter="sexFormatter"
               label="鎬у埆"
             >
             </el-table-column>
@@ -43,33 +45,23 @@
             >
             </el-table-column>
             <el-table-column
-              align="center"
-              prop="condition"
-              label="涓婄嚎鎯呭喌"
-            >
-            </el-table-column>
-            <el-table-column
               label="鎿嶄綔"
               align="center"
               width="300px"
             >
-              <el-button type="warning">缂栬緫</el-button>
-              <el-button type="danger">鍒犻櫎</el-button>
-              <el-button type="primary">鍒嗛厤瑙掕壊</el-button>
+              <template slot-scope="scope">
+                <el-button @click="handlerEditStudent(scope.row)" type="warning">缂栬緫</el-button>
+                <el-button @click="remove(scope.row.id)" type="danger">鍒犻櫎</el-button>
+                <el-button type="primary">鍒嗛厤瑙掕壊</el-button>
+              </template>
             </el-table-column>
           </el-table>
           <div
             class="block"
             style="display: flex; margin-top: 40px;"
           >
-            <el-pagination
-              style="margin:auto"
-              background
-              :page-size="10"
-              layout="prev, pager, next, jumper"
-              :total="100"
-            >
-            </el-pagination>
+            <pagination v-show="total>0" :total="total" :page.sync="searchForm.pageNum" :limit.sync="searchForm.pageSize"
+                        @pagination="page"/>
           </div>
         </div>
       </div>
@@ -79,11 +71,69 @@
       ref="popUp"
       @children="parentGoods"
     />
+
+    <el-dialog
+      :title="studentTitle"
+      :visible.sync="addOpen"
+      width="700px"
+      :before-close="handleAddClose">
+      <el-form :model="studentForm" :rules="studentRules" ref="studentForm" label-width="100px" class="demo-ruleForm">
+        <el-form-item label="濮撳悕" prop="realName">
+          <el-input v-model="studentForm.realName"></el-input>
+        </el-form-item>
+        <el-form-item label="鎬у埆" prop="sex">
+          <el-select v-model="studentForm.sex">
+            <el-option label="鐢�" value="N"></el-option>
+            <el-option label="濂�" value="V"></el-option>
+          </el-select>
+        </el-form-item>
+        <el-form-item label="鐢佃瘽" prop="phone">
+          <el-input v-model="studentForm.phone"></el-input>
+        </el-form-item>
+        <el-form-item label="鐧诲綍璐﹀彿" prop="account">
+          <el-input v-model="studentForm.account"></el-input>
+        </el-form-item>
+        <el-form-item label="鐧诲綍瀵嗙爜" prop="password">
+          <el-input v-model="studentForm.password" show-password placeholder="涓嶅~鍐欎細浣跨敤榛樿202406"></el-input>
+        </el-form-item>
+      </el-form>
+      <span slot="footer" class="dialog-footer">
+        <el-button @click="handleAddClose">鍙� 娑�</el-button>
+        <el-button type="primary" @click="submitStudentForm">娣� 鍔�</el-button>
+      </span>
+    </el-dialog>
+
+    <el-dialog
+      title="瀛﹀憳璋冩暣"
+      :visible.sync="open"
+      width="900px"
+      :before-close="handleClose">
+      <el-transfer
+        filterable
+        :filter-method="filterMethod"
+        filter-placeholder="瀛﹀憳濮撳悕"
+        :titles="['瀛︾敓鍒楄〃', '褰撳墠瀛︾敓']"
+        :button-texts="['閫�鍑虹彮绾�', '鍔犲叆鐝骇']"
+        :props="{
+          key: 'id',
+          label: 'realName'
+        }"
+        v-model="classes.studentList"
+        :data="studentList">
+      </el-transfer>
+      <span slot="footer" class="dialog-footer">
+        <el-button @click="handleClose">鍙� 娑�</el-button>
+        <el-button type="primary" @click="submitForm">淇� 瀛�</el-button>
+      </span>
+    </el-dialog>
+
   </div>
 </template>
 <script>
 // 寮曞叆褰堝嚭绐楀彛绲勪欢
 import PopUp from "../../../components/PopUp/Question.vue";
+import UserApi from "@/api/user";
+import { updateClassesUser, getClassesUsers, deleteClassesUserById, addClassesUser, edit } from "@/api/classesUser";
 export default {
   // 娉ㄥ唽
   components: {
@@ -91,6 +141,43 @@
   },
   data() {
     return {
+      studentForm: {
+        realName: "",
+        sex: "",
+        phone: "",
+        age: null,
+        account: "",
+        password: ""
+      },
+      studentRules: {
+        realName: [
+          { required: true, message: '璇峰~鍐欏鍛樺鍚�', trigger: 'blur' },
+        ],
+        sex: [
+          { required: true, message: '璇烽�夋嫨瀛﹀憳鎬у埆', trigger: 'change' },
+        ],
+        phone: [
+          { required: true, message: '璇峰~鍐欏鍛樼數璇�', trigger: 'blur' },
+        ],
+        account: [
+          { required: true, message: '璇峰~鍐欏鍛樼櫥褰曡处鍙�', trigger: 'blur' },
+        ]
+      },
+      studentTitle: "鏂板瀛﹀憳",
+      addOpen: false,
+      total: 0,
+      studentList: [],
+      searchForm: {
+        realName: "",
+        pageSize: 10,
+        pageNum: 1,
+        classesId: null
+      },
+      classes: {
+        id: null,
+        studentList: []
+      },
+      open: false,
       // 鐝骇鍚嶇О
       title: "19绾ц蒋浠跺洓鐝�",
       formLabelAlign: {
@@ -99,90 +186,102 @@
         region: "",
       },
       tableData: [
-        {
-          id: 1,
-          name: "寮犱笁",
-          sex: "鐢�",
-          phone: "12345678977",
-          // 鏄惁涓婄嚎
-          condition: "宸蹭笂绾�",
-        },
-        {
-          id: 1,
-          name: "鏉庡洓",
-          sex: "濂�",
-          phone: "12345678977",
-          // 鏄惁涓婄嚎
-          condition: "宸蹭笂绾�",
-        },
-        {
-          id: 1,
-          name: "鐜嬩簲",
-          sex: "鐢�",
-          phone: "12345678977",
-          // 鏄惁涓婄嚎
-          condition: "鏈笂绾�",
-        },
-        {
-          id: 1,
-          name: "寮犱笁",
-          sex: "鐢�",
-          phone: "12345678977",
-          // 鏄惁涓婄嚎
-          condition: "宸蹭笂绾�",
-        },
-        {
-          id: 1,
-          name: "鏉庡洓",
-          sex: "濂�",
-          phone: "12345678977",
-          // 鏄惁涓婄嚎
-          condition: "宸蹭笂绾�",
-        },
-        {
-          id: 1,
-          name: "鐜嬩簲",
-          sex: "鐢�",
-          phone: "12345678977",
-          // 鏄惁涓婄嚎
-          condition: "鏈笂绾�",
-        },
-        {
-          id: 1,
-          name: "寮犱笁",
-          sex: "鐢�",
-          phone: "12345678977",
-          // 鏄惁涓婄嚎
-          condition: "宸蹭笂绾�",
-        },
-        {
-          id: 1,
-          name: "鏉庡洓",
-          sex: "濂�",
-          phone: "12345678977",
-          // 鏄惁涓婄嚎
-          condition: "宸蹭笂绾�",
-        },
-        {
-          id: 1,
-          name: "鐜嬩簲",
-          sex: "鐢�",
-          phone: "12345678977",
-          // 鏄惁涓婄嚎
-          condition: "鏈笂绾�",
-        },
-        {
-          id: 1,
-          name: "鐜嬩簲",
-          sex: "鐢�",
-          phone: "12345678977",
-          // 鏄惁涓婄嚎
-          condition: "鏈笂绾�",
-        },
       ],
     };
   },
+  mounted() {
+    this.classes.id = this.$route.query.classesId;
+    this.page()
+    this.getClassesCurrentUserList(this.classes.id)
+    this.getStudentList()
+  },
   methods: {
+    handlerEditStudent(row) {
+      this.studentForm = row
+      this.studentTitle = "缂栬緫瀛﹀憳"
+      this.addOpen = true
+    },
+    handlerAddStudent() {
+      this.studentTitle = "娣诲姞瀛﹀憳"
+      this.addOpen = true
+    },
+    submitStudentForm() {
+      this.$refs['studentForm'].validate((valid) => {
+        if (valid) {
+          this.studentForm.classes = this.classes.id
+          if (this.studentForm.id) {
+            edit(this.studentForm).then(res => {
+              this.addOpen = false
+              this.$message.success(res.data.message)
+              this.page()
+            })
+          }
+          addClassesUser(this.studentForm).then(res => {
+            this.addOpen = false
+            this.$message.success(res.data.message)
+            this.page()
+          })
+        }
+      })
+    },
+    resetStudentForm() {
+      this.studentForm = {
+        realName: "",
+        sex: "",
+        phone: "",
+        age: null
+      }
+    },
+    handleAddClose() {
+      this.addOpen = false
+      this.resetStudentForm()
+    },
+    remove(id) {
+      deleteClassesUserById(id).then(res => {
+        this.$message.success(res.data.message)
+        this.page()
+      })
+    },
+    sexFormatter(row) {
+      if (row.sex === 1) {
+        return "鐢�"
+      }
+      if (row.sex === 2) {
+        return "濂�"
+      }
+    },
+    getClassesCurrentUserList(classesId) {
+      let param = {
+        classesId: classesId
+      }
+      UserApi.getClassesCurrentUserList(param).then(res => {
+        this.classes.studentList = res.data
+      })
+    },
+    getStudentList() {
+      UserApi.studentList().then(res => {
+        this.studentList = res.data;
+      })
+    },
+    // 鑾峰彇褰撳墠鐝骇瀛﹀憳鍒嗛〉
+    page() {
+      this.searchForm.classesId = this.classes.id
+      getClassesUsers(this.searchForm).then(res => {
+        this.tableData = res.data.data
+      })
+    },
+    submitForm() {
+      updateClassesUser(this.classes).then(res => {
+        this.$message.success(res.data.message)
+        this.page();
+      })
+    },
+    handleClose() {
+      this.open = false
+    },
+    filterMethod(query, item) {
+      return item.realName.indexOf(query) > -1;
+    },
     // 杩斿洖涓婁竴涓〉闈�
     goBack() {
       this.$router.back();

--
Gitblit v1.8.0