HZH-PC\HZH vor 2 Jahren
Ursprung
Commit
60c87f8889
2 geänderte Dateien mit 88 neuen und 22 gelöschten Zeilen
  1. 29 0
      src/api/ctrlPaper.js
  2. 59 22
      src/components/controlMainPage/IssuePaperList.vue

+ 29 - 0
src/api/ctrlPaper.js

@@ -26,4 +26,33 @@ export function getIssuePaperList(param) {
         params: param
     })
     .then(res => res.data);
+}
+
+//新增组合试卷
+export function addIssuePaper(addPaperSet) {
+    return axios({
+        method: 'post',
+        url: '/issuePaper/add',
+        data: addPaperSet
+    }).then(res => res.data)
+}
+
+//修改组合试卷
+export function updateIssuePaper(addPaperSet) {
+    return axios({
+        method: 'post',
+        url: '/issuePaper/update',
+        data: addPaperSet
+    }).then(res => res.data)
+}
+
+//删除组合试卷
+export function deleteIssuePaper(id) {
+    return axios({
+        method: 'post',
+        url: '/issuePaper/delete',
+        params: {
+            id
+        }
+    }).then(res => res.data)
 }

+ 59 - 22
src/components/controlMainPage/IssuePaperList.vue

@@ -82,16 +82,14 @@ table{
       </el-option>
     </el-select>
     <el-button icon="el-icon-search" circle @click="searchList"></el-button>
-    <el-button type="primary" class="add-user" @click="visibleAdd = true">新增</el-button>
+    <el-button type="primary" class="add-user" @click="visibleAdd = true;addPaperSet = JSON.parse(JSON.stringify(initPaperSet))">新增</el-button>
   </div>
   <table>
     <thead>
             <tr>
                 <th>序号</th>
-                <th>姓名</th>
-                <th>手机</th>
-                <!-- <th>email</th> -->
-                <th>学校</th>
+                <th>名称</th>
+                <th>学科</th>
                 <th>年级</th>
                 <th>操作</th>
             </tr>
@@ -100,11 +98,13 @@ table{
             <tr v-for="(item,index) in paperList" :key="index">
               <td>{{index + 1}}</td>
               <td>{{item.name}}</td>
-              <td>{{item.username}}</td>
-              <!-- <td>{{item.email}}</td> -->
-              <td>{{item.region}}</td>
+              <td>{{subjectOptions.filter(subject => subject.id == item.subjectId)[0].name }}</td>
               <td>{{gradeMap[item.grade]}}</td>
               <td>
+                <a @click="changeSet(item)">修改参数</a>
+                &nbsp;&nbsp;
+                <a @click="checkPaper(item.id)">查看</a>
+                &nbsp;&nbsp;
                 <a @click="visibleDelete = true;deleteId = item.id">删除</a>
               </td>
             </tr>
@@ -113,7 +113,7 @@ table{
 
   <el-dialog
         class="dialog-style"
-        title="编辑"
+        :title="addPaperSet.id?'编辑':'添加'"
         :visible.sync="visibleAdd"
         width="800px">
         <div>
@@ -171,9 +171,9 @@ table{
 </template>
 
 <script>
-import { getIssuePaperList } from '@/api/ctrlPaper';
+import { getIssuePaperList,addIssuePaper,updateIssuePaper, deleteIssuePaper } from '@/api/ctrlPaper';
 import { subjectList, issueChapterList} from '@/api/common';
-import { GRADE_OPTION } from '@/services/constant';
+import { GRADE_OPTION, GRADE_MAP } from '@/services/constant';
 
 export default {
   name: 'IssueList',
@@ -190,6 +190,7 @@ export default {
         paperList: [],
         
         gradeOptions: GRADE_OPTION,
+        gradeMap: GRADE_MAP,
 
         chapterData:{},
 
@@ -199,6 +200,13 @@ export default {
           subjectId:2,
         },
 
+        initPaperSet: {
+          "name": "",
+          "subjectId": 2,
+          "publisher": "人教版",
+          "chapterIds": "",
+          "grade": "",
+        },
         addPaperSet:{
           "name": "",
           "subjectId": 2,
@@ -215,6 +223,7 @@ export default {
   created() {
     this.searchSubject();
     this.issueChapterList();
+    this.searchList();
   },
   methods: {
     searchSubject(){
@@ -248,19 +257,47 @@ export default {
         })
       })
       this.addPaperSet.chapterIds = tempList.join(',');
-      console.log(this.addPaperSet);
-      // addUser(this.user).then((result) => {
-      //   alert(result.message);
-      //   this.visibleAdd = false
-      //   this.searchUser();
-      // })
+      if(this.addPaperSet.id){
+        updateIssuePaper(this.addPaperSet).then((result) => {
+          if(result.result){
+            this.$message('修改成功');
+            this.visibleAdd = false;
+            this.searchList();
+          }
+        })
+      }
+      else{
+        addIssuePaper(this.addPaperSet).then((result) => {
+          if(result.result){
+            this.$message('添加成功');
+            this.visibleAdd = false;
+            this.searchList();
+          }
+        })
+      }
     },
     deletePaper(){
-    //   deleteUser(this.deleteId).then((result) => {
-    //     alert(result?'删除成功':'删除失败');
-    //     this.visibleDelete = false
-    //     this.searchUser();
-    //   })
+      deleteIssuePaper(this.deleteId).then((result) => {
+        this.$message(result.result?'删除成功':'删除失败');
+        this.visibleDelete = false
+        this.searchList();
+      })
+    },
+    changeSet(item){
+      this.visibleAdd = true;
+      this.addPaperSet = item;
+      this.addPaperSet.publisher = '人教版';
+
+      let tempList = this.addPaperSet.chapterIds.split(',');
+      Object.keys(this.chapterData).forEach(key => {
+        this.chapterData[key].forEach(item => {
+            item.choose = tempList.includes(item.id.toString());
+          }
+        )
+      })
+    },
+    checkPaper(id){
+
     }
   }
 }