123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146 |
- <template>
- <div id="addChapter">
- <el-dialog
- :visible.sync="dialogVisible"
- width="700px"
- :show-close="false"
- :close-on-click-modal="false"
- >
- <div slot="title" class="hearders">
- <div class="leftTitle">添加试卷</div>
- <div class="rightBoxs">
- <img
- src="@/assets/images/Close@2x.png"
- alt=""
- @click="dialogVisible = false"
- />
- </div>
- </div>
- <div>
- <p>
- <el-button :size="size" type="primary" @click="addChapterList"
- >添加</el-button
- >
- </p>
- <el-form label-width="100px" class="elform_style">
- <div v-for="(item, index) in list" :key="index" class="dis_box">
- <div class="left_box">
- <el-form-item label="标题前缀">
- <el-input v-model="item.prefixName"></el-input>
- <p class="p_style">注:便于检索、归类,以及区分一样的标题</p>
- </el-form-item>
- <el-form-item label="试卷标题" required>
- <el-input v-model="item.examName"></el-input>
- <p class="p_style">
- 注:请尽量规范易懂,方便在题卷目录表呈现给学员
- </p>
- </el-form-item>
- <el-form-item required label="试卷类型">
- <el-select
- v-model="item.examPaperId"
- placeholder="请选择试卷类型"
- >
- <el-option
- v-for="item in paperexam"
- :key="item.paperId"
- :label="item.paperName"
- :value="item.paperId"
- >
- </el-option>
- </el-select>
- </el-form-item>
- </div>
- <div class="clear_style">
- <el-button :size="size" @click="list.splice(index, 1)"
- >删除</el-button
- >
- </div>
- </div></el-form
- >
- </div>
- <span slot="footer" class="dialog-footer">
- <el-button @click="dialogVisible = false">取 消</el-button>
- <el-button type="primary" @click="submitForm" :disabled="!list.length"
- >确 定</el-button
- >
- </span>
- </el-dialog>
- </div>
- </template>
- <script>
- import { mapGetters } from "vuex";
- export default {
- data() {
- return {
- size: "small",
- dialogVisible: false,
- list: [],
- };
- },
- computed: {
- ...mapGetters(["paperexam"]),
- },
- methods: {
- addChapterList() {
- this.list.push({});
- },
- openBoxs(arr) {
- this.businList = JSON.parse(JSON.stringify(arr));
- this.list = [{}];
- this.dialogVisible = true;
- },
- submitForm() {
- const arr = [];
- this.list.forEach((item, index) => {
- if ((!item.examName && item.examName !== 0) || !item.examPaperId) {
- arr.push(index + 1);
- }
- });
- if (arr.length) {
- this.$message.error(
- `请检查第${arr.join(",")}条数据的试卷标题或试卷类型,请完成后提交`
- );
- return;
- }
- let data = this.list.map((item) => {
- item.businessList = this.businList;
- item.status = 1;
- item.publishStatus = 1;
- return item;
- });
- this.$api.addMorebankexam(data.reverse()).then((res) => {
- this.dialogVisible = false;
- this.$emit("backData", res.data);
- });
- },
- },
- };
- </script>
- <style lang="less" scoped>
- .dis_box {
- background-color: #eee;
- padding: 10px 10px 0px;
- display: flex;
- margin-bottom: 16px;
- .left_box {
- flex: 1;
- }
- .clear_style {
- flex-shrink: 0;
- width: 80px;
- vertical-align: top;
- text-align: center;
- }
- }
- .elform_style {
- max-height: 620px;
- overflow: auto;
- }
- .p_style {
- font-size: 12px;
- color: #a4a4a4;
- margin: 0;
- }
- </style>
|