ChangeQuestion.vue 6.56 KB
Newer Older
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 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241
<!--
 * @Author: 纪泽龙 jizelong@qq.com
 * @Date: 2022-12-27 09:30:19
 * @LastEditors: 纪泽龙 jizelong@qq.com
 * @LastEditTime: 2023-01-29 14:52:33
 * @FilePath: /danger-manage-web/src/views/educationPlanExam/textPaper/components/ChangeQuestion.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
  <div class="table-wrapper">
    <el-form :model="queryParams" ref="queryForm" :inline="true">
      <el-form-item label="所属单位" prop="deptId" ref="treeItem">
        <Treeselect
          class="tree"
          v-model="queryParams.deptId"
          :options="deptOptions"
          :show-count="true"
          placeholder="请选择归属部门"
          style="width: 200px"
        />
      </el-form-item>
      <el-form-item label="题库名称" prop="bankName">
        <el-input
          v-model="queryParams.bankName"
          placeholder="考试时间"
          clearable
          size="small"
        />
      </el-form-item>

      <el-form-item>
        <el-button
          type="primary"
          icon="el-icon-search"
          size="mini"
          @click="search"
          >搜索</el-button
        >
        <el-button icon="el-icon-refresh" size="mini" @click="resetClick"
          >重置</el-button
        >
      </el-form-item>
    </el-form>

    <el-table v-loading="loading" :data="list" height="435" ref="multipleTable">
      <!-- <el-table-column type="selection"></el-table-column> -->
      <el-table-column label="" align="center" prop="profession">
        <template v-slot="{ row }">
          <!-- <div> -->
          <el-checkbox
            :disabled="row.numberQuestions == 0"
            v-model="row.checked"
          ></el-checkbox>
          <!-- </div> -->
        </template>
      </el-table-column>
      <el-table-column label="题库名称" align="center" prop="bankName">
      </el-table-column>
      <el-table-column label="所属单位" align="center" prop="courseType">
        <template v-slot="scope">
          <div>
            {{ selectList(deptOptions, scope.row.deptId) || "-" }}
          </div>
        </template>
      </el-table-column>
      <el-table-column
        label="包含题目数量"
        align="center"
        prop="numberQuestions"
        :formatter="formatter"
      >
      </el-table-column>
      <el-table-column label="选取题目数量" align="center" prop="profession">
        <template v-slot="{ row }">
          <div>
            <!-- <el-input
              :disabled="!row.checked|| row.numberQuestions==0 "
              v-model="row.changeNum"
              size="mini"
              style="width: 100px"
            ></el-input> -->
            <el-input-number
              v-model="row.changeNum"
              :disabled="!row.checked || row.numberQuestions == 0"
              size="mini"
              :min="1"
              :max="+row.numberQuestions ? +row.numberQuestions : 1000000"
              label="描述文字"
            ></el-input-number>
          </div>
        </template>
      </el-table-column>
    </el-table>
    <!-- <div> -->
    <el-pagination
      :layout="'prev, pager, next'"
      v-show="total > 0"
      :total="total"
      :current-page="queryParams.pageNum"
      :page-sizes="[queryParams.pageSize]"
      @current-change="currentChangeClick"
    />
  </div>
</template>

<script>
import { listBank, delBank } from "@/api/educationPlanExam/questionBank";
import { bachAddTopicGuest } from "@/api/educationPlanExam/lessonsProgram.js";

// 部门列表

import { treeselect } from "@/api/system/dept";
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
export default {
  name: "",
  components: {
    Treeselect,
  },
  props: {
    courseId: {
      type: Number,
    },
  },
  data() {
    return {
      queryParams: {
        deptId: null,
        courseName: "",
        pageNum: 1,
        pageSize: 10,
      },
      list: [
        {
          checked: false,
        },
      ],
      total: 20,
      loading: false,
      // 题库id
      deptId: null,
      // 归属部门列表
      deptOptions: [],
    };
  },
  created() {
    this.getList();
    this.getTreeselect();
  },
  methods: {
    getTreeselect() {
      treeselect().then((response) => {
        this.deptOptions = response.data;
        // console.log("123", this.deptOptions);
        // console.log(this.selectList(this.deptOptions, 175));
      });
    },
    // 递归查值的方法
    selectList(list, id) {
      for (let i = 0; i < list.length; i++) {
        let item = list[i];
        if (item.id == id) {
          return item.label;
        } else {
          if (Array.isArray(item.children)) {
            let a = this.selectList(item.children, id);
            if (a) {
              return a;
            }
          }
        }
      }
    },
    getList() {
      this.loading = true;
      listBank(this.queryParams)
        .then((res) => {
          console.log(res);
          this.list = res.rows.map((item, index) => {
            return {
              bankNum:
                index +
                1 +
                (this.queryParams.pageNum - 1) * this.queryParams.pageSize,
              checked: false,
              changeNum: 0,
              ...item,
            };
          });
          this.total = res.total;
        })
        .finally(() => {
          this.loading = false;
        });
    },
    saveAndNext() {
      const topicInfos = this.list
        .filter((item) => item.checked)
        .map((item) => {
          return {
            bankId: item.bankId,
            quan: item.changeNum,
          };
        });

      console.log(this.courseId, topicInfos);
      const data = { courseId: this.courseId, topicInfos };
      console.log(data);

      bachAddTopicGuest(data).then((res) => {
        console.log(res);
        if (res.code == 200) {
          // this.$parent.$parent.componentsNumChange(2);
          this.$parent.$parent.getContractTopicList(this.courseId);
          this.$parent.$parent.dialogVisible2=false;
        }
      });
    },
    resetClick() {},
    search() {
      this.getList();
    },
    currentChangeClick() {},
    formatter(row, column, cellValue, index) {
      // console.log(row, column, cellValue, index);
      if (!cellValue) return "-";
      else return cellValue;
    },
  },
};
</script>
<style lang="scss" scoped>
.table-wrapper {
  padding-top: 22px;
  width: 100%;
  height: 550px;
  overflow: hidden;
  // padding-bottom: 10px;
  margin-bottom: 20px;
}
</style>