Răsfoiți Sursa

模版使用

zhangjie 2 ani în urmă
părinte
comite
6fe710d23a

+ 12 - 1
src/modules/paper/components/AutoBuildPaperStructManage.vue

@@ -69,9 +69,16 @@
           </el-table-column>
           <el-table-column label="创建时间" width="170" prop="creationTime">
           </el-table-column>
-          <el-table-column label="操作" width="180" fixed="right">
+          <el-table-column label="操作" width="220" fixed="right">
             <template slot-scope="scope">
               <div class="operate_left">
+                <el-button
+                  size="mini"
+                  type="primary"
+                  plain
+                  @click="toUse(scope.row)"
+                  >使用</el-button
+                >
                 <el-button
                   size="mini"
                   type="primary"
@@ -181,6 +188,10 @@ export default {
     tableSelectChange(selections) {
       this.selectedQuestionIds = selections.map((item) => item.id);
     },
+    toUse(row) {
+      this.$emit("selected", row);
+      this.cancel();
+    },
     toEdit(row) {
       this.curRow = row;
       this.$refs.ModifyAutoBuildPaperStruct.open();

+ 13 - 1
src/modules/paper/components/BuildPaperAuto.vue

@@ -119,12 +119,24 @@ export default {
   },
   methods: {
     isAnEmptyRichText,
+    setDetails(details) {
+      this.details = [];
+      this.activeNames = [];
+      this.curDetail = {};
+      this.$nextTick(() => {
+        this.details = deepCopy(details);
+      });
+    },
     addDetail() {
       this.curDetail = { courseId: this.courseId };
       this.$refs.ModifyDetailStruct.open();
     },
     editDetail(curDetail) {
-      this.curDetail = curDetail;
+      this.curDetail = {
+        ...curDetail,
+        scorePerQuestion: curDetail.score,
+        courseId: this.courseId,
+      };
       this.$refs.ModifyDetailStruct.open();
     },
     async removeDetail(index) {

+ 0 - 206
src/modules/paper/components/BuildPaperAutoStruct.vue

@@ -1,206 +0,0 @@
-<template>
-  <div class="build-paper-auto">
-    <div class="build-step-title">
-      <h3><span>试卷结构设置</span></h3>
-      <div>
-        <el-button
-          type="primary"
-          size="small"
-          icon="el-icon-circle-plus-outline"
-          @click="addDetail"
-          >新增大题</el-button
-        >
-      </div>
-    </div>
-
-    <el-collapse v-model="activeNames" accordion>
-      <el-collapse-item
-        v-for="(detail, index) in details"
-        :key="detail.id"
-        :name="detail.id"
-      >
-        <div slot="title" class="detail-header">
-          <h3>{{ index + 1 }}、{{ detail.detailName }}</h3>
-          <div>
-            <el-button
-              size="mini"
-              type="text"
-              icon="el-icon-edit"
-              title="编辑"
-              @click.stop="editDetail(detail)"
-            ></el-button>
-            <el-button
-              class="btn-danger"
-              size="mini"
-              type="text"
-              icon="el-icon-delete"
-              title="删除"
-              @click.stop="removeDetail(index)"
-            ></el-button>
-          </div>
-        </div>
-        <div v-if="!isAnEmptyRichText(detail.description)" class="detail-desc">
-          <rich-text :text-json="detail.description"></rich-text>
-        </div>
-        <div class="detail-info">
-          <div>
-            <p>
-              <span>题型:</span>
-              <span>{{ detail.sourceDetailName }}</span>
-            </p>
-          </div>
-          <div>
-            <p>
-              <span>小题数:</span>
-              <span>{{ detail.questionCount }}</span>
-            </p>
-            <p>
-              <span>总分:</span>
-              <span>{{ detail.questionCount * detail.score }}</span>
-            </p>
-          </div>
-        </div>
-        <question-group-struct
-          :ref="`QuestionStruct${detail.id}`"
-          :filter-data="{
-            courseId,
-            sourceDetailId: detail.sourceDetailId,
-          }"
-          :data-source="detail"
-          @count-change="(val) => structCountChange(val, detail)"
-        ></question-group-struct>
-      </el-collapse-item>
-    </el-collapse>
-
-    <!-- ModifyDetailStruct -->
-    <modify-detail-struct
-      ref="ModifyDetailStruct"
-      :detail="curDetail"
-      @modified="detailModified"
-    ></modify-detail-struct>
-  </div>
-</template>
-
-<script>
-import ModifyDetailStruct from "./ModifyDetailStruct.vue";
-import QuestionGroupStruct from "./QuestionGroupStruct.vue";
-import { isAnEmptyRichText } from "@/utils/utils";
-import { deepCopy } from "@/plugins/utils";
-
-export default {
-  name: "BuildPaperAutoStruct",
-  components: {
-    ModifyDetailStruct,
-    QuestionGroupStruct,
-  },
-  props: {
-    courseId: {
-      type: [String, Number],
-      default: "",
-    },
-    detailSource: {
-      type: Array,
-      default() {
-        return [];
-      },
-    },
-  },
-  data() {
-    return {
-      details: [],
-      curDetail: {},
-      activeNames: [],
-    };
-  },
-  computed: {
-    isEdit() {
-      return !!(this.detailSource && this.detailSource.length);
-    },
-  },
-  mounted() {
-    if (this.detailSource) {
-      this.details = deepCopy(this.detailSource);
-    }
-  },
-  methods: {
-    isAnEmptyRichText,
-    toSelectStruct() {
-      this.$refs.AutoBuildPaperStructManage.open();
-    },
-    addDetail() {
-      this.curDetail = { courseId: this.courseId };
-      this.$refs.ModifyDetailStruct.open();
-    },
-    editDetail(curDetail) {
-      this.curDetail = curDetail;
-      this.$refs.ModifyDetailStruct.open();
-    },
-    async removeDetail(index) {
-      const confirm = await this.$confirm(`确定要删除当前大题吗?`, "提示", {
-        type: "warning",
-      }).catch(() => {});
-      if (confirm !== "confirm") return;
-
-      this.details.splice(index, 1);
-    },
-    detailModified(data) {
-      const index = this.details.findIndex((item) => item.id === data.id);
-      if (index === -1) {
-        this.details.push({
-          ...data,
-          questionCount: 0,
-          score: data.scorePerQuestion,
-        });
-        if (!this.activeNames.includes(data.id)) this.activeNames.push(data.id);
-      } else {
-        this.$set(
-          this.details,
-          index,
-          Object.assign({}, this.details[index], {
-            ...data,
-            score: data.scorePerQuestion,
-          })
-        );
-      }
-    },
-    structCountChange(val, detail) {
-      const index = this.details.findIndex((item) => item.id === detail.id);
-      if (index === -1) return;
-      this.details[index].questionCount = val;
-    },
-    getData() {
-      let detailInfo = this.details.map((item) => {
-        const structData =
-          this.$refs[`QuestionStruct${item.id}`][0].getDataList();
-        return {
-          questionType: item.questionType,
-          description: item.description,
-          detailName: item.detailName,
-          sourceDetailId: item.sourceDetailId,
-          courseId: item.courseId,
-          score: item.score,
-          ...structData,
-        };
-      });
-
-      return { detailInfo };
-    },
-    validate() {
-      if (!this.details.length) {
-        this.$message.error("请设置大题!");
-        return Promise.reject();
-      }
-
-      let hasNoQuestionDetail = this.details.some(
-        (detail) => !detail.questionCount
-      );
-      if (hasNoQuestionDetail) {
-        this.$message.error("有大题未设置小题!");
-        return Promise.reject();
-      }
-
-      return Promise.resolve(true);
-    },
-  },
-};
-</script>

+ 5 - 0
src/modules/paper/views/BuildPaper.vue

@@ -138,6 +138,7 @@
       v-if="IS_AUTO_MODE"
       ref="AutoBuildPaperStructManage"
       :course-id="modalForm.courseId"
+      @selected="structSelected"
     ></auto-build-paper-struct-manage>
   </div>
 </template>
@@ -238,6 +239,10 @@ export default {
     toSelectStruct() {
       this.$refs.AutoBuildPaperStructManage.open();
     },
+    structSelected(row) {
+      console.log(row);
+      this.$refs.BuildPaperDetail.setDetails(row.structInfo);
+    },
     async confirm() {
       let valid = await this.$refs.modalFormComp.validate().catch(() => {});
       if (!valid) return;