addChapterjs.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. <template>
  2. <div id="addChapter">
  3. <el-dialog
  4. :visible.sync="dialogVisible"
  5. width="700px"
  6. :show-close="false"
  7. :close-on-click-modal="false"
  8. >
  9. <div slot="title" class="hearders">
  10. <div class="leftTitle">添加试卷</div>
  11. <div class="rightBoxs">
  12. <img
  13. src="@/assets/images/Close@2x.png"
  14. alt=""
  15. @click="dialogVisible = false"
  16. />
  17. </div>
  18. </div>
  19. <div>
  20. <p>
  21. <el-button :size="size" type="primary" @click="addChapterList"
  22. >添加</el-button
  23. >
  24. </p>
  25. <el-form label-width="100px" class="elform_style">
  26. <div v-for="(item, index) in list" :key="index" class="dis_box">
  27. <div class="left_box">
  28. <el-form-item label="标题前缀">
  29. <el-input v-model="item.prefixName"></el-input>
  30. <p class="p_style">注:便于检索、归类,以及区分一样的标题</p>
  31. </el-form-item>
  32. <el-form-item label="试卷标题" required>
  33. <el-input v-model="item.examName"></el-input>
  34. <p class="p_style">
  35. 注:请尽量规范易懂,方便在题卷目录表呈现给学员
  36. </p>
  37. </el-form-item>
  38. <el-form-item required label="试卷类型">
  39. <el-select
  40. v-model="item.examPaperId"
  41. placeholder="请选择试卷类型"
  42. >
  43. <el-option
  44. v-for="item in paperexam"
  45. :key="item.paperId"
  46. :label="item.paperName"
  47. :value="item.paperId"
  48. >
  49. </el-option>
  50. </el-select>
  51. </el-form-item>
  52. </div>
  53. <div class="clear_style">
  54. <el-button :size="size" @click="list.splice(index, 1)"
  55. >删除</el-button
  56. >
  57. </div>
  58. </div></el-form
  59. >
  60. </div>
  61. <span slot="footer" class="dialog-footer">
  62. <el-button @click="dialogVisible = false">取 消</el-button>
  63. <el-button type="primary" @click="submitForm" :disabled="!list.length"
  64. >确 定</el-button
  65. >
  66. </span>
  67. </el-dialog>
  68. </div>
  69. </template>
  70. <script>
  71. import { mapGetters } from "vuex";
  72. export default {
  73. data() {
  74. return {
  75. size: "small",
  76. dialogVisible: false,
  77. list: [],
  78. };
  79. },
  80. computed: {
  81. ...mapGetters(["paperexam"]),
  82. },
  83. methods: {
  84. addChapterList() {
  85. this.list.push({});
  86. },
  87. openBoxs(arr) {
  88. this.businList = JSON.parse(JSON.stringify(arr));
  89. this.list = [{}];
  90. this.dialogVisible = true;
  91. },
  92. submitForm() {
  93. const arr = [];
  94. this.list.forEach((item, index) => {
  95. if ((!item.examName && item.examName !== 0) || !item.examPaperId) {
  96. arr.push(index + 1);
  97. }
  98. });
  99. if (arr.length) {
  100. this.$message.error(
  101. `请检查第${arr.join(",")}条数据的试卷标题或试卷类型,请完成后提交`
  102. );
  103. return;
  104. }
  105. let data = this.list.map((item) => {
  106. item.businessList = this.businList;
  107. item.status = 1;
  108. item.publishStatus = 1;
  109. return item;
  110. });
  111. this.$api.addMorebankexam(data.reverse()).then((res) => {
  112. this.dialogVisible = false;
  113. this.$emit("backData", res.data);
  114. });
  115. },
  116. },
  117. };
  118. </script>
  119. <style lang="less" scoped>
  120. .dis_box {
  121. background-color: #eee;
  122. padding: 10px 10px 0px;
  123. display: flex;
  124. margin-bottom: 16px;
  125. .left_box {
  126. flex: 1;
  127. }
  128. .clear_style {
  129. flex-shrink: 0;
  130. width: 80px;
  131. vertical-align: top;
  132. text-align: center;
  133. }
  134. }
  135. .elform_style {
  136. max-height: 620px;
  137. overflow: auto;
  138. }
  139. .p_style {
  140. font-size: 12px;
  141. color: #a4a4a4;
  142. margin: 0;
  143. }
  144. </style>