xiangpei
2024-06-11 241255fbe2b6db3b2ed263f1e5a9956f5f9a0ee2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
<template>
  <div class="c">
    <div class="bg">
      <div class="main">
        <div class="main-1">
          <div class="main-btn">
            <el-button
              type="primary"
              @click="openAdd"
            >安排考试
            </el-button>
          </div>
          <div>
            <el-form :inline="true" :model="searchForm" class="demo-form-inline">
              <el-form-item label="考试名称">
                <el-input v-model="searchForm.className" size="small" clearable @clear="page" placeholder="班级名称"></el-input>
              </el-form-item>
              <el-form-item label="考试班级">
                <el-select v-model="searchForm.classesId" size="small" clearable @change="page" placeholder="班级状态">
                  <el-option label="正常" value="normal"></el-option>
                  <el-option label="解散" value="dissolution"></el-option>
                </el-select>
              </el-form-item>
              <el-form-item>
                <el-button type="primary" @click="page" size="small">查询</el-button>
              </el-form-item>
            </el-form>
            <div>
              <el-table :data="tableData">
                <el-table-column
                  label="考试名称"
                  prop="examName"
                ></el-table-column>
                <el-table-column
                  label="考试试卷"
                  prop="examName"
                ></el-table-column>
                <el-table-column
                  label="参考班级"
                  prop="examClasses"
                ></el-table-column>
                <el-table-column
                  label="班级人数"
                  prop="studentNum"
                ></el-table-column>
                <el-table-column
                  label="考试地点"
                  prop="site"
                ></el-table-column>
                <el-table-column
                  label="考试科目"
                  prop="subject"
                ></el-table-column>
                <el-table-column label="状态" prop="type" :formatter="formatterType">
                </el-table-column>
                <el-table-column
                  label="考试时间"
                  prop="ctime"
                ></el-table-column>
                <el-table-column label="操作">
                  <template slot-scope="scope">
                    <el-button
                      class="deepBlue"
                      colorType="blue"
                    >修改
                    </el-button>
                  </template>
                </el-table-column>
              </el-table>
            </div>
            <div
              class="flex"
              style="justify-content:center;margin-top:20px;"
            >
              <pagination v-show="total>0" :total="total" :page.sync="searchForm.pageIndex" :limit.sync="searchForm.pageSize"
                          @pagination="page"/>
            </div>
          </div>
        </div>
      </div>
 
    </div>
 
 
    <el-dialog width="35%" :title="title" @close="closeHandler" :visible.sync="open" :destroy-on-close="true"
               :append-to-body="true" :close-on-click-modal="false">
      <el-form :model="examForm" :rules="examRules" ref="examForm">
        <el-form-item label="考试名称" :label-width="formLabelWidth" prop="examName">
          <el-input v-model="examForm.examName" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="参考班级" :label-width="formLabelWidth" prop="classesId">
          <el-input v-model="examForm.classesId" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="试卷类型" :label-width="formLabelWidth" prop="examPaperType">
          <el-input v-model="examForm.examPaperType" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="考试试卷" :label-width="formLabelWidth" prop="examPaperId">
          <el-input v-model="examForm.examPaperId" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="考试地点" :label-width="formLabelWidth" prop="examPlace">
          <el-input v-model="examForm.examPlace" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="开始时间" :label-width="formLabelWidth" prop="startTime">
          <el-input v-model="examForm.startTime" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="结束时间" :label-width="formLabelWidth" prop="endTime">
          <el-input v-model="examForm.endTime" autocomplete="off"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="closeHandler">取 消</el-button>
        <el-button type="primary" @click="addOrEditExam">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>
 
<script>
import Pagination from "@/components/Pagination"
import { getExams, addExam, editExam, deleteExamById } from "@/api/exam"
import { myClasses } from "@/api/classes"
import { myExamPaperList } from "@/api/examPaper"
export default {
  components: { Pagination },
  data() {
    return {
      formLabelWidth: "80px",
      classesList: [],
      examPaperList: [],
      examForm: {
        id: null,
        examName: "",
        examPaperId: "",
        classesId: "",
        examPaperType: "",
        examPlace: "",
        status: "",
        startTime: "",
        endTime: "",
      },
      examRules: {
        examName: [
          { required: true, message: '请输入考试名称', trigger: 'blur' }
        ],
        examPaperId: [
          { required: true, message: '请选择考试试卷', trigger: 'change' }
        ],
        classesId: [
          { required: true, message: '请选择参考班级', trigger: 'change' }
        ],
        examPaperType: [
          { required: true, message: '请选择试卷类型', trigger: 'change' }
        ],
        examPlace: [
          { required: true, message: '请输入考试地点', trigger: 'blur' }
        ],
        startTime: [
          { required: true, message: '请选择开始时间', trigger: 'change' }
        ],
        endTime: [
          { required: true, message: '请选择结束时间', trigger: 'change' }
        ],
      },
      total: 0,
      title: "安排考试",
      open: false,
      searchForm: {
        examName: "",
        subject: null,
        pageIndex: 1,
        pageSize: 10
      },
      tableData: [
      ],
    };
  },
  mounted() {
    this.page();
  },
  methods: {
    getMyExamPaperList() {
      if (! this.examForm.examPaperType) {
        return
      }
      let param = {
        "paperType": this.examForm.examPaperType
      }
      myExamPaperList(param).then(res => {
        this.examPaperList = res.data
      })
    },
    getMyClasses() {
      myClasses().then(res => {
        this.classesList = res.data.data
      })
    },
    deleteExam(id) {
      deleteExamById(id).then(res => {
        this.$message.success("删除成功")
      })
    },
    addOrEditExam() {
      this.$refs['examForm'].validate((valid) => {
        if (valid) {
          if (this.examForm.id) {
            editExam(this.examForm).then(res => {
              this.$message.success("操作成功")
            })
          } else {
            addExam(this.examForm).then(res => {
              this.$message.success("操作成功")
            })
          }
        }
      })
    },
    clearForm() {
      this.examForm = {
        id: null,
        examName: "",
        examPaperId: "",
        classesId: "",
        examPaperType: "",
        examPlace: "",
        status: "",
        startTime: "",
        endTime: "",
      }
    },
    closeHandler() {
      this.open = false
      this.clearForm()
    },
    openAdd() {
      this.title = this.examForm.id ? "修改考试" : "安排考试"
      this.open = true
    },
    formatterType(row) {
    },
    page() {
      getExams(this.searchForm).then(res => {
        this.tableData = res.data.data
      })
    },
    routerTo(url) {
      this.$router.push(url);
    },
  },
};
</script>
 
<style scoped lang="scss">
.flex {
  display: flex;
}
 
.mian-1-top {
  margin: 10px 0;
  align-items: center;
 
  & input {
    height: 30px;
    width: 200px;
    margin-right: 20px;
  }
}
 
// .c{
//     background-image:url('../../assets/img/loginBackground.jpg');
//     width:100vw;
//     height:calc(100vh - 75px);
//     background-size: cover;
// }
// .bg{
//     width:100%;
//     height:100%;
//     background: rgba(255,255,255,0.2);
//     display: flex;
//     justify-content: center;
 
// }
.main {
  &-title {
    border-left: 5px solid rgb(16, 71, 247);
    padding-left: 10px;
    margin: 50px 0;
 
    & p {
      font-weight: 700;
    }
  }
 
  &-1 {
    width: 1227px;
    height: 784px;
    background: white;
    box-shadow: 1px 1px 1px 1px rgba(0, 0, 0, 0.1);
    border-radius: 10px;
    padding: 32px 40px;
  }
 
  &-btn {
    padding-bottom: 32px;
    border-bottom: 3px solid rgb(16, 71, 247);
  }
}
 
.deepBlue {
  background: rgb(16, 71, 247);
  color: white;
  border: none;
 
  &:hover {
    background-color: rgb(45, 92, 248);
  }
}
</style>