123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410 |
- <template>
- <el-dialog
- class="select-question-dialog"
- :visible.sync="modalIsShow"
- :close-on-click-modal="false"
- :close-on-press-escape="false"
- :show-close="false"
- append-to-body
- fullscreen
- @open="visibleChange"
- >
- <div slot="title" class="box-justify">
- <h3>选择试题</h3>
- <div>
- <el-button size="mini" type="primary" @click="confirm">确定</el-button>
- <el-button size="mini" type="danger" plain @click="cancel"
- >取消</el-button
- >
- </div>
- </div>
- <el-tabs
- v-model="tabType"
- class="part-box"
- type="card"
- @tab-click="tabChange"
- >
- <el-tab-pane name="1">
- <span slot="label">试题筛选</span>
- <div class="part-filter">
- <div class="part-filter-form">
- <el-form class="part-filter-form" :inline="true" :model="filter">
- <el-form-item label="题型">
- <source-detail-select
- v-model="filter"
- :course-id="filter.courseId"
- :disabled="disabledSourceDetail"
- >
- </source-detail-select>
- </el-form-item>
- <el-form-item label="题目内容">
- <el-input
- v-model="filter.questionBody"
- placeholder="题目内容"
- ></el-input>
- </el-form-item>
- <el-form-item label="属性">
- <property-tree-select
- v-model="filter.questionProperty"
- :course-id="filter.courseId"
- ></property-tree-select>
- </el-form-item>
- <el-form-item>
- <el-button type="danger" @click="toPage(1)">查询</el-button>
- </el-form-item>
- </el-form>
- </div>
- </div>
- <el-table :data="questions">
- <el-table-column
- width="60"
- type="index"
- :index="indexMethod"
- label="编号"
- >
- </el-table-column>
- <el-table-column label="题干" min-width="200">
- <div slot-scope="scope" @click="toViewQuestion(scope.row)">
- <rich-text
- class="row-question-body"
- title="点击查看试题"
- :text-json="scope.row.quesBody"
- ></rich-text>
- </div>
- </el-table-column>
- <el-table-column label="课程" width="120">
- <template slot-scope="scope">
- <span>{{ scope.row.course.name }}</span>
- </template>
- </el-table-column>
- <el-table-column label="题型" prop="sourceDetailName" width="100">
- </el-table-column>
- <el-table-column label="难度" prop="difficulty" width="80">
- </el-table-column>
- <el-table-column label="使用量" prop="usageAmount" width="80">
- </el-table-column>
- <el-table-column label="创建人" prop="creator" width="120">
- </el-table-column>
- <el-table-column label="属性" min-width="150">
- <div
- v-if="scope.row.quesProperties"
- slot-scope="scope"
- class="edit-cont-props"
- >
- <p
- v-for="(content, propIndex) in scope.row.quesProperties"
- :key="propIndex"
- >
- {{ content.courseProperty && content.courseProperty.name }}
- <span style="margin: 0 3px">/</span>
- {{ content.firstProperty && content.firstProperty.name }}
- <span v-if="content.secondProperty" style="margin: 0 3px"
- >/</span
- >
- {{ content.secondProperty && content.secondProperty.name }}
- </p>
- </div>
- </el-table-column>
- <el-table-column label="操作" width="90" fixed="right">
- <div v-if="!scope.row.disabled" slot-scope="scope">
- <el-button
- v-if="scope.row.selected"
- size="mini"
- type="danger"
- @click="toDelete(scope.row)"
- >
- 删除
- </el-button>
- <el-button
- v-else
- size="mini"
- type="primary"
- plain
- @click="toSelect(scope.row)"
- >
- 添加
- </el-button>
- </div>
- </el-table-column>
- </el-table>
- <div class="part-page">
- <el-pagination
- background
- :current-page="currentPage"
- :page-size="pageSize"
- :page-sizes="[10, 20, 50, 100, 200, 300]"
- layout="total, sizes, prev, pager, next, jumper"
- :total="total"
- @current-change="toPage"
- @size-change="handleSizeChange"
- />
- </div>
- </el-tab-pane>
- <el-tab-pane name="2">
- <span slot="label">
- <span>已选试题</span>
- <span class="color-primary">({{ curSelectedQuestions.length }})</span>
- </span>
- <el-table :data="curSelectedQuestions">
- <el-table-column width="60" type="index" label="编号">
- </el-table-column>
- <el-table-column label="题干" min-width="200">
- <div slot-scope="scope" @click="toViewQuestion(scope.row)">
- <rich-text
- class="row-question-body"
- title="点击查看试题"
- :text-json="scope.row.quesBody"
- ></rich-text>
- </div>
- </el-table-column>
- <el-table-column label="课程" width="200">
- <template slot-scope="scope">
- <span>{{ scope.row.course.name }}</span>
- </template>
- </el-table-column>
- <el-table-column label="题型" prop="sourceDetailName" width="100">
- </el-table-column>
- <el-table-column label="难度" prop="difficulty" width="80">
- </el-table-column>
- <el-table-column label="使用量" prop="usageAmount" width="80">
- </el-table-column>
- <el-table-column label="创建人" prop="creator" width="120">
- </el-table-column>
- <el-table-column label="属性" min-width="150">
- <div
- v-if="scope.row.quesProperties"
- slot-scope="scope"
- class="edit-cont-props"
- >
- <p
- v-for="(content, propIndex) in scope.row.quesProperties"
- :key="propIndex"
- >
- {{ content.courseProperty && content.courseProperty.name }}
- <span style="margin: 0 3px">/</span>
- {{ content.firstProperty && content.firstProperty.name }}
- <span v-if="content.secondProperty" style="margin: 0 3px"
- >/</span
- >
- {{ content.secondProperty && content.secondProperty.name }}
- </p>
- </div>
- </el-table-column>
- <!-- <el-table-column
- v-if="IS_PAPER_MODE"
- label="分值"
- width="120"
- prop="score"
- >
- <template slot-scope="scope">
- <el-input-number
- v-model="scope.row.score"
- placeholder="分值"
- :precision="1"
- :min="0"
- :max="999"
- :step="0.1"
- step-strictly
- :controls="false"
- style="width: 90px"
- ></el-input-number>
- </template>
- </el-table-column> -->
- <el-table-column label="操作" width="90" fixed="right">
- <div slot-scope="scope">
- <el-button
- size="mini"
- type="danger"
- @click="toDeleteSelected(scope.row)"
- >
- 删除
- </el-button>
- </div>
- </el-table-column>
- </el-table>
- </el-tab-pane>
- </el-tabs>
- <div slot="footer"></div>
- <question-preview-dialog
- ref="QuestionPreviewDialog"
- :question="curQuestion"
- ></question-preview-dialog>
- </el-dialog>
- </template>
- <script>
- import QuestionPreviewDialog from "../../question/components/QuestionPreviewDialog";
- import PropertyTreeSelect from "../../question/components/PropertyTreeSelect.vue";
- import { questionPageListApi } from "../../question/api";
- import { deepCopy } from "@/plugins/utils";
- export default {
- name: "SelectQuestionDialog",
- components: { QuestionPreviewDialog, PropertyTreeSelect },
- props: {
- courseId: {
- type: [String, Number],
- default: "",
- },
- sourceDetail: {
- type: Object,
- default() {
- return {
- questionType: "",
- sourceDetailId: "",
- };
- },
- },
- disabledSourceDetail: {
- type: Boolean,
- default: false,
- },
- selectedQuestionIds: {
- type: Array,
- default() {
- return [];
- },
- },
- disabledQuestionIds: {
- type: Array,
- default() {
- return [];
- },
- },
- selectMode: {
- type: String,
- default: "question",
- },
- },
- data() {
- return {
- modalIsShow: false,
- filter: {
- courseId: "",
- questionType: "",
- sourceDetailId: "",
- questionBody: "",
- questionProperty: [],
- },
- tabType: "1",
- tableData: [],
- currentPage: 1,
- pageSize: 10,
- total: 10,
- questions: [],
- curSelectedQuestions: [],
- curSelectedQuestionIds: [],
- curQuestion: {},
- };
- },
- computed: {
- IS_PAPER_MODE() {
- return this.selectMode === "paper";
- },
- },
- methods: {
- initData() {
- this.filter = Object.assign({}, this.filter, {
- courseId: this.courseId,
- questionType: this.sourceDetail.questionType,
- sourceDetailId: this.sourceDetail.sourceDetailId,
- });
- this.curSelectedQuestions = [];
- this.curSelectedQuestionIds = [];
- this.toPage(this.currentPage);
- },
- visibleChange() {
- this.initData();
- },
- cancel() {
- this.modalIsShow = false;
- },
- open() {
- this.modalIsShow = true;
- },
- async getList() {
- let data = {
- ...this.filter,
- pageNumber: this.currentPage,
- pageSize: this.pageSize,
- };
- data.questionProperty = data.questionProperty.join();
- const res = await questionPageListApi(data).catch(() => {});
- this.questions = res.data.content.map((item) => {
- return {
- ...item,
- selected: this.curSelectedQuestionIds.includes(item.id),
- disabled: this.disabledQuestionIds.includes(item.id),
- };
- });
- this.total = res.data.total;
- },
- indexMethod(index) {
- return index + (this.currentPage - 1) * this.pageSize + 1;
- },
- toPage(val) {
- this.currentPage = val;
- this.getList();
- },
- handleSizeChange(val) {
- this.pageSize = val;
- this.currentPage = 1;
- this.getList();
- },
- tabChange(val) {
- if (val.name === "1") {
- this.questions.forEach((item) => {
- item.selected = this.curSelectedQuestionIds.includes(item.id);
- });
- }
- },
- toViewQuestion(row) {
- this.curQuestion = row;
- this.$refs.QuestionPreviewDialog.open();
- },
- toSelect(row) {
- row.selected = true;
- this.curSelectedQuestions.push({ ...row });
- this.updateSelectedQuestionIds();
- },
- toDelete(row) {
- row.selected = false;
- this.toDeleteSelected(row);
- },
- toDeleteSelected(row) {
- const pos = this.curSelectedQuestions.findIndex(
- (item) => item.id === row.id
- );
- this.curSelectedQuestions.splice(pos, 1);
- this.updateSelectedQuestionIds();
- },
- updateSelectedQuestionIds() {
- this.curSelectedQuestionIds = this.curSelectedQuestions.map(
- (item) => item.id
- );
- },
- confirm() {
- // if (this.IS_PAPER_MODE) {
- // const unvalid = this.curSelectedQuestions.some((item) => !item.score);
- // if (unvalid) {
- // this.$message.error("请完成已选试题分值设置");
- // this.tabType = "2";
- // return;
- // }
- // }
- this.$emit("confirm", deepCopy(this.curSelectedQuestions));
- this.cancel();
- },
- },
- };
- </script>
|