xiangpei
2024-07-09 558fbd9d6fbb10a8cc674a10213c395ab8ee3d95
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
<template>
  <div class="app-container">
    <el-form :model="form" ref="form" label-width="100px">
      <el-form-item label="单选题" prop="radioNum" :rules="[
      { required: true, message: '单选题不能为空' },
      { type: 'number', message: '单选题必须为数字值' }
    ]">
        <el-input v-model.number="form.radioNum" autocomplete="off"></el-input>
      </el-form-item>
      <el-form-item label="多选题" prop="checkNum" :rules="[
      { required: true, message: '多选题不能为空' },
      { type: 'number', message: '多选题必须为数字值' }
    ]">
        <el-input v-model.number="form.checkNum" autocomplete="off"></el-input>
      </el-form-item>
      <el-form-item label="判断题" prop="judgingNum" :rules="[
      { required: true, message: '判断题不能为空' },
      { type: 'number', message: '判断题必须为数字值' }
    ]">
        <el-input v-model.number="form.judgingNum" autocomplete="off"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="submitForm('form')">提交</el-button>
        <el-button @click="resetForm('form')">重置</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>
 
<script>
import Pagination from '@/components/Pagination'
import examPaperApi from '@/api/examPaper'
 
export default {
  components: { Pagination },
  data() {
    return {
      form: {
        radioNum: '',
        checkNum: '',
        judgingNum: ''
      }
    }
  },
  created() {
    examPaperApi.getConfig('').then(res => {
      if (res.response) this.form = res.response;
    })
  },
  methods: {
    submitForm(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          examPaperApi.setConfig(this.form).then(res => {
            if (res.code === 1) {
              this.$message.success('操作成功')
            } else {
              this.$message.error(res.message)
            }
          })
        }
      });
    },
    resetForm(formName) {
      this.$refs[formName].resetFields();
    }
  }
}
</script>