From 9f30d8bd8f76c049edf050e57eaef84f21295d79 Mon Sep 17 00:00:00 2001
From: Administrator <admin>
Date: Fri, 30 Jul 2021 22:09:53 +0800
Subject: [PATCH] 考试管理和试卷管理合并

---
 src/views/exam/examination.vue |   20 ------
 src/views/exam/startexam.vue   |  143 ++++++++++++++++++++++++++++++++++++++---------
 2 files changed, 116 insertions(+), 47 deletions(-)

diff --git a/src/views/exam/examination.vue b/src/views/exam/examination.vue
index c06b14d..0589ab6 100644
--- a/src/views/exam/examination.vue
+++ b/src/views/exam/examination.vue
@@ -165,26 +165,6 @@
                         }]
                     },
                     {
-                        label: "试卷分数",
-                        prop: "totalScore",
-                        slot: true,
-                        // 表单新增时是否禁止
-                        addDisabled: false,
-                        // 表单新增时是否可见
-                        addDisplay: true,
-                        // 表单新增时是否为查看模式
-                        addDetail: false,
-                        // 表单编辑时是否禁止
-                        editDisabled: false,
-                        // 表单编辑时是否可见
-                        editDisplay: true,
-                        // 表单编辑时是否为查看模式
-                        editDetail: false,
-
-                        rules: [{ validator: validatePass, required: true, trigger: 'blur' }],
-                        width: 100
-                    },
-                    {
                         label: "考试时间",
                         prop: "examTime",
                         type: "daterange",
diff --git a/src/views/exam/startexam.vue b/src/views/exam/startexam.vue
index ebd62f0..3916924 100644
--- a/src/views/exam/startexam.vue
+++ b/src/views/exam/startexam.vue
@@ -6,7 +6,7 @@
  * menu-name 考试管理
  */
 <template>
-    <el-row class="morpheus-box-exam">
+    <el-row class="morpheus-box-paper">
         <el-col :span="24">
             <el-card>
 
@@ -25,7 +25,10 @@
                                @search-change="questionBankSearchChange"
                                @search-reset="questionBankSearchReset"
                                @current-change="questionBankCurrentChange"
-                               @size-change="questionBankSizeChange">
+                               @size-change="questionBankSizeChange"
+                               @row-save="questionBankRowSave"
+                               @row-update="questionBankRowUpdate"
+                               @row-del="questionBankRowDel">
 
                         <!-- 自定义按钮 -->
                         <!-- <template slot="menuLeft">
@@ -48,6 +51,14 @@
                                        @click="handleDelete">导出
                             </el-button>
                         </template> -->
+
+                        <template slot="menuLeft">
+                            <el-button type="danger"
+                                       size="small"
+                                       icon="el-icon-delete"
+                                       @click="questionBankHandleDelete">删 除
+                            </el-button>
+                        </template>
 
                         <template slot-scope="{row}"
                                   slot="examStatus">
@@ -78,6 +89,9 @@
 <script>
 import {
     getList,
+    add,
+    remove,
+    update
 } from "@/api/examapi/examination";
 
 
@@ -102,10 +116,10 @@
             form: {},
             questionBankOption: {
                 // 操作栏多余按钮去除
-                delBtn: false,
-                editBtn: false,
-                addBtn: false,
-                selection: false,
+                delBtn: true,
+                editBtn: true,
+                addBtn: true,
+                selection: true,
                 menu: true,
                 // 导出按钮
                 excelBtn: false,
@@ -124,7 +138,7 @@
                 //dialogType: 'drawer',
                 dialogClickModal: false,
                 // 操作栏宽度
-                menuWidth: 246,
+                menuWidth: 280,
 
                 labelWidth: 140,
 
@@ -153,26 +167,26 @@
                             trigger: "blur"
                         }]
                     },
-                    {
-                        label: "试卷分数",
-                        prop: "totalScore",
-                        slot: true,
-                        // 表单新增时是否禁止
-                        addDisabled: false,
-                        // 表单新增时是否可见
-                        addDisplay: true,
-                        // 表单新增时是否为查看模式
-                        addDetail: false,
-                        // 表单编辑时是否禁止
-                        editDisabled: false,
-                        // 表单编辑时是否可见
-                        editDisplay: true,
-                        // 表单编辑时是否为查看模式
-                        editDetail: false,
+                    // {
+                    //     label: "试卷分数",
+                    //     prop: "totalScore",
+                    //     slot: true,
+                    //     // 表单新增时是否禁止
+                    //     addDisabled: false,
+                    //     // 表单新增时是否可见
+                    //     addDisplay: true,
+                    //     // 表单新增时是否为查看模式
+                    //     addDetail: false,
+                    //     // 表单编辑时是否禁止
+                    //     editDisabled: false,
+                    //     // 表单编辑时是否可见
+                    //     editDisplay: true,
+                    //     // 表单编辑时是否为查看模式
+                    //     editDetail: false,
 
-                        rules: [{ validator: validatePass, required: true, trigger: 'blur' }],
-                        width: 100
-                    },
+                    //     rules: [{ validator: validatePass, required: true, trigger: 'blur' }],
+                    //     width: 100
+                    // },
                     {
                         label: "考试时间",
                         prop: "examTime",
@@ -378,7 +392,82 @@
                 path: `/startexam/${row.id}`,
                 query: row
             })
-        }
+        },
+        // 新增
+        questionBankRowSave (row, done, loading) {
+            row.startTime = row.examTime[0]
+            row.endTime = row.examTime[1]
+            row.examTime = JSON.stringify(row.examTime)
+            add(row).then(() => {
+                this.questionBankOnLoad(this.questionBankPage);
+                this.$message({
+                    type: "success",
+                    message: "操作成功!"
+                });
+                done();
+            }, error => {
+                window.console.log(error);
+                loading();
+            });
+        },
+        questionBankRowUpdate (row, index, done, loading) {
+            if (Array.isArray(row.examTime) != true) {
+                row.examTime = row.examTime.split(",")
+            }
+            row.startTime = row.examTime[0]
+            row.endTime = row.examTime[1]
+            row.examTime = JSON.stringify(row.examTime)
+            update(row).then(() => {
+                this.questionBankOnLoad(this.questionBankPage);
+                this.$message({
+                    type: "success",
+                    message: "操作成功!"
+                });
+                done();
+            }, error => {
+                window.console.log(error);
+                loading();
+            });
+        },
+        questionBankRowDel (row) {
+            this.$confirm("确定将选择数据删除?", {
+                confirmButtonText: "确定",
+                cancelButtonText: "取消",
+                type: "warning"
+            })
+                .then(() => {
+                    return remove(row.id);
+                })
+                .then(() => {
+                    this.questionBankOnLoad(this.questionBankPage);
+                    this.$message({
+                        type: "success",
+                        message: "操作成功!"
+                    });
+                });
+        },
+        questionBankHandleDelete () {
+            if (this.questionBankSelectionList.length === 0) {
+                this.$message.warning("请选择至少一条数据");
+                return;
+            }
+            this.$confirm("确定将选择数据删除?", {
+                confirmButtonText: "确定",
+                cancelButtonText: "取消",
+                type: "warning"
+            })
+                .then(() => {
+                    return remove(this.ids);
+                })
+                .then(() => {
+                    this.questionBankOnLoad(this.questionBankPage);
+                    this.$message({
+                        type: "success",
+                        message: "操作成功!"
+                    });
+                    this.$refs.questionBankCrud.toggleSelection();
+                });
+        },
     }
 }
 </script>

--
Gitblit v1.9.3