123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810 |
- <template>
- <section class="content">
- <!-- 正文信息 -->
- <div class="box-body">
- <el-form
- :inline="true"
- :model="formSearch"
- label-position="right"
- label-width="70px"
- >
- <el-row>
- <el-col :span="6">
- <el-form-item label="考试类型">
- <el-select
- v-model="formSearch.examType"
- class="search_width"
- filterable
- clearable
- placeholder="请选择"
- size="small"
- @change="searchExams"
- >
- <el-option
- v-for="item in EXAM_TYPES"
- :key="item.value"
- :label="item.label"
- :value="item.value"
- >
- </el-option>
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label="考试名称">
- <el-select
- v-model="formSearch.examId"
- class="search_width"
- filterable
- :remote-method="getExams"
- remote
- clearable
- placeholder="请选择"
- size="small"
- >
- <el-option
- v-for="item in examList"
- :key="item.id"
- :label="item.name"
- :value="item.id"
- >
- </el-option>
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label="导出类型">
- <el-select
- v-model="formSearch.exportType"
- class="search_width"
- filterable
- clearable
- placeholder="请选择"
- size="small"
- >
- <el-option
- v-for="item in EXPORT_TYPES"
- :key="item.value"
- :label="item.label"
- :value="item.value"
- >
- </el-option>
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <div class="search_down">
- <el-button size="small" type="primary" @click="searchFrom"
- ><i class="el-icon-search"></i> 查询</el-button
- >
- <el-button size="small" @click="resetForm"
- ><i class="el-icon-refresh"></i> 重 置</el-button
- >
- <el-button size="small" type="primary" @click="add"
- ><i class="el-icon-plus"></i> 新增</el-button
- >
- </div>
- </el-col>
- </el-row>
- </el-form>
- <div
- style="width: 100%; border-bottom: 1px solid #ddd; margin: 10px 0"
- ></div>
- <!-- 页面列表 -->
- <el-table border :data="tableData">
- <el-table-column label="考试类型">
- <template slot-scope="scope">
- <span>{{ scope.row.examType | examTypesFilter }}</span>
- </template>
- </el-table-column>
- <el-table-column label="考试名称">
- <template slot-scope="scope">
- <span>{{ scope.row.examName }}</span>
- </template>
- </el-table-column>
- <el-table-column label="导出类型">
- <template slot-scope="scope">
- <span>{{ scope.row.exportType | exportTypesFilter }}</span>
- </template>
- </el-table-column>
- <el-table-column label="题数">
- <template slot-scope="scope">
- <div
- v-for="(item, index) in scope.row.questionTypeNums"
- v-show="scope.row.exportType == 'NORMAL'"
- :key="index"
- >
- <span>{{ item.questionType | questionType }}</span>
- <span>{{ item.quantity }}</span>
- </div>
- </template>
- </el-table-column>
- <el-table-column label="操作" width="175">
- <template slot-scope="scope">
- <div class="operate_left">
- <el-button
- size="mini"
- type="primary"
- plain
- @click="copy(scope.row)"
- ><i class="el-icon-edit"></i>复用</el-button
- >
- <el-button size="mini" type="danger" @click="del(scope.row)"
- ><i class="el-icon-delete"></i> 删除</el-button
- >
- </div>
- </template>
- </el-table-column>
- </el-table>
- <div class="page pull-right">
- <el-pagination
- :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="handleCurrentChange"
- @size-change="handleSizeChange"
- >
- </el-pagination>
- </div>
- </div>
- <!-- 复用窗口 -->
- <el-dialog
- title="试卷结构复用"
- :visible.sync="dialogCopyModel"
- width="500px"
- >
- <el-form
- :model="exportStructureCopy"
- label-position="right"
- label-width="120px"
- >
- <el-tabs> <el-tab-pane label="原结构信息"></el-tab-pane> </el-tabs>
- <el-form-item label="考试类型">
- <el-select
- v-model="exportStructureCopy.examTypeOld"
- placeholder="请选择"
- disabled
- >
- <el-option
- v-for="item in EXAM_TYPES"
- :key="item.value"
- :label="item.label"
- :value="item.value"
- ></el-option>
- </el-select>
- </el-form-item>
- <el-form-item label="考试名称">
- <el-select
- v-model="exportStructureCopy.examIdOld"
- placeholder="请选择"
- disabled
- >
- <el-option
- v-for="item in examList"
- :key="item.id"
- :label="item.name"
- :value="item.id"
- ></el-option>
- </el-select>
- </el-form-item>
- <el-form-item label="导出类型">
- <el-select
- v-model="exportStructureCopy.exportTypeOld"
- placeholder="请选择"
- disabled
- >
- <el-option
- v-for="item in EXPORT_TYPES"
- :key="item.value"
- :label="item.label"
- :value="item.value"
- ></el-option>
- </el-select>
- </el-form-item>
- <el-tabs> <el-tab-pane label="新结构信息"></el-tab-pane> </el-tabs>
- <el-form-item label="考试类型">
- <el-select
- v-model="exportStructureCopy.examType"
- placeholder="请选择"
- @change="searchExamId"
- >
- <el-option
- v-for="item in EXAM_TYPES"
- :key="item.value"
- :label="item.label"
- :value="item.value"
- ></el-option>
- </el-select>
- <span
- v-if="check_value(exportStructureCopy.examType)"
- class="error_message error_other"
- >请选择考试类型</span
- >
- </el-form-item>
- <el-form-item label="考试名称">
- <el-select v-model="exportStructureCopy.examId" placeholder="请选择">
- <el-option
- v-for="item in examListNew"
- :key="item.id"
- :label="item.name"
- :value="item.id"
- ></el-option>
- </el-select>
- <span
- v-if="check_value(exportStructureCopy.examId)"
- class="error_message error_other"
- >请选择考试名称</span
- >
- </el-form-item>
- <el-row class="margin_top_10 margin_left_120">
- <el-button type="primary" @click="saveCopy">保 存</el-button>
- <!-- <el-button @click="resetForm3"
- ><i class="el-icon-refresh"></i> 重 置</el-button
- > -->
- <el-button type="primary" @click="cancleCopy"
- ><i class="el-icon-arrow-left"></i> 返 回</el-button
- >
- </el-row>
- </el-form>
- </el-dialog>
- <!-- 新增窗口 -->
- <el-dialog title="新增导出结构" :visible.sync="dialogModel" width="500px">
- <el-form
- :model="exportStructure"
- label-position="right"
- label-width="78px"
- :inline="true"
- >
- <el-row>
- <div style="color: #f56c6c; margin-bottom: -30px">*</div>
- <el-form-item label="考试类型">
- <el-select
- v-model="exportStructure.examType"
- placeholder="请选择"
- @change="searchExportStructure('examType')"
- >
- <el-option
- v-for="item in EXAM_TYPES"
- :key="item.value"
- :label="item.label"
- :value="item.value"
- ></el-option>
- </el-select>
- <span
- v-if="check_value(exportStructure.examType)"
- class="error_message error_other"
- >请选择考试类型</span
- >
- </el-form-item>
- </el-row>
- <el-row>
- <div style="color: #f56c6c; margin-bottom: -30px; margin-top: 8px">
- *
- </div>
- <el-form-item label="考试名称">
- <el-select
- v-model="exportStructure.examId"
- filterable
- placeholder="请选择"
- @change="searchExportStructure('examId')"
- >
- <el-option
- v-for="item in examListByExamType"
- :key="item.id"
- :label="item.name"
- :value="item.id"
- ></el-option>
- </el-select>
- <span
- v-if="check_value(exportStructure.examId)"
- class="error_message error_other"
- >请选择考试名称</span
- >
- </el-form-item>
- </el-row>
- <el-row>
- <div style="color: #f56c6c; margin-bottom: -30px; margin-top: 8px">
- *
- </div>
- <el-form-item label="导出类型">
- <el-select
- v-model="exportStructure.exportType"
- placeholder="请选择"
- :disabled="button"
- >
- <el-option
- v-for="item in EXPORT_TYPES"
- :key="item.value"
- :label="item.label"
- :value="item.value"
- ></el-option>
- </el-select>
- <span
- v-if="check_value(exportStructure.exportType)"
- class="error_message error_other"
- >请选择导出类型</span
- >
- </el-form-item>
- </el-row>
- <!-- 判断机考还是传统 -->
- <div v-if="exportStructure.exportType == 'NORMAL'">
- <div
- v-for="(item, index) in exportStructure.questionTypeNums"
- :key="index"
- >
- <el-row>
- <div
- style="
- color: #f56c6c;
- margin-bottom: -30px;
- margin-left: 26px;
- margin-top: 8px;
- "
- >
- *
- </div>
- <el-form-item
- :label="item.questionType | questionType"
- label-width="78px"
- >
- <el-input
- v-model="item.quantity"
- style="width: 220px"
- :disabled="button"
- ></el-input>
- <span
- v-if="check(item.quantity)"
- class="error_message error_other"
- >
- 请输入正整数或0
- </span>
- </el-form-item>
- </el-row>
- </div>
- </div>
- <el-row class="margin_top_10 margin_left_120">
- <el-button type="primary" :disabled="button" @click="save"
- >保 存</el-button
- >
- <!-- <el-button @click="resetForm2"
- ><i class="el-icon-refresh"></i> 重 置</el-button
- > -->
- <el-button type="primary" @click="cancel"
- ><i class="el-icon-arrow-left"></i> 返 回</el-button
- >
- </el-row>
- </el-form>
- </el-dialog>
- </section>
- </template>
- <script>
- import { QUESTION_API, EXAM_WORK_API } from "@/constants/constants";
- import { EXAM_TYPES, EXPORT_TYPES } from "../constants/constants";
- import { mapState } from "vuex";
- import _ from "lodash";
- export default {
- data() {
- return {
- isShow: false,
- loading: false,
- dialogModel: false,
- dialogCopyModel: false,
- formSearch: {
- examType: null,
- examId: null,
- exportType: null,
- },
- exportStructure: {
- examType: "",
- examId: "",
- examName: "",
- exportType: "",
- useable: "1", //默认启用
- questionTypeNums: [
- {
- questionType: "SINGLE_ANSWER_QUESTION",
- quantity: "",
- },
- {
- questionType: "MULTIPLE_ANSWER_QUESTION",
- quantity: "",
- },
- {
- questionType: "BOOL_ANSWER_QUESTION",
- quantity: "",
- },
- ],
- },
- exportStructureCopy: {
- examTypeOld: "",
- examIdOld: "",
- exportTypeOld: "",
- examType: "",
- examId: "",
- useable: "1",
- questionTypeNums: [
- {
- questionType: "SINGLE_ANSWER_QUESTION",
- quantity: "",
- },
- {
- questionType: "MULTIPLE_ANSWER_QUESTION",
- quantity: "",
- },
- {
- questionType: "BOOL_ANSWER_QUESTION",
- quantity: "",
- },
- ],
- },
- EXAM_TYPES: EXAM_TYPES,
- EXPORT_TYPES: EXPORT_TYPES,
- examList: [],
- examListByExamType: [],
- tableData: [],
- pageSize: 10,
- currentPage: 1,
- total: 10,
- button: false,
- examListNew: [],
- disMessage: false,
- reShow: false,
- };
- },
- computed: {
- ...mapState({ user: (state) => state.user }),
- },
- created() {
- this.getExams("");
- this.search();
- },
- methods: {
- resetForm() {
- this.formSearch = {
- examType: null,
- examId: null,
- exportType: null,
- };
- },
- searchFrom() {
- this.currentPage = 1;
- this.search();
- },
- search() {
- if (this.formSearch.examType === "") {
- this.formSearch.examType = null;
- }
- this.tableData = [];
- this.loading = true;
- var url =
- QUESTION_API +
- "/findPageByExportStructure/" +
- this.currentPage +
- "/" +
- this.pageSize;
- this.$http.post(url, this.formSearch).then((response) => {
- this.tableData = response.data.content;
- this.total = response.data.totalElements;
- this.loading = false;
- });
- },
- //新增考试结构
- add() {
- this.dialogModel = true;
- this.button = false;
- this.isShow = false;
- this.exportStructure = {
- examType: "",
- examId: "",
- examName: "",
- exportType: "",
- useable: "1", //默认启用
- questionTypeNums: [
- {
- questionType: "SINGLE_ANSWER_QUESTION",
- quantity: "",
- },
- {
- questionType: "MULTIPLE_ANSWER_QUESTION",
- quantity: "",
- },
- {
- questionType: "BOOL_ANSWER_QUESTION",
- quantity: "",
- },
- ],
- };
- },
- handleCurrentChange(val) {
- this.currentPage = val;
- this.search();
- },
- handleSizeChange(val) {
- this.pageSize = val;
- this.currentPage = 1;
- this.search();
- },
- closeQuesDialog() {
- this.dialogModel = false;
- },
- //表单验证
- check(value) {
- if (this.disMessage) {
- return false;
- }
- if (this.reShow) {
- return false;
- }
- var r = /^\+?[1-9][0-9]*$/;
- if ((r.test(value) || value === "0") && this.isShow) {
- return false;
- }
- return true;
- },
- check_value(value) {
- if (!value && this.isShow) {
- return true;
- }
- return false;
- },
- save() {
- this.reShow = false;
- this.isShow = true;
- if (this.check_value(this.exportStructure.examType)) {
- return false;
- }
- if (this.check_value(this.exportStructure.examId)) {
- return false;
- }
- if (this.check_value(this.exportStructure.exportType)) {
- return false;
- }
- if (this.exportStructure.exportType == "NORMAL") {
- for (var i = 0; i < this.exportStructure.questionTypeNums.length; i++) {
- if (this.check(this.exportStructure.questionTypeNums[i].quantity)) {
- return false;
- }
- }
- }
- let examId = this.exportStructure.examId;
- this.exportStructure.examName = _.filter(this.examList, function (item) {
- return item.id == examId;
- })[0].name;
- this.$http
- .post(QUESTION_API + "/saveExportStructure", this.exportStructure)
- .then(() => {
- this.$notify({
- title: "提示",
- message: "保存成功",
- type: "success",
- });
- this.closeQuesDialog();
- this.search();
- });
- },
- //重置2
- resetForm2() {
- this.exportStructure = {
- examType: "",
- examId: "",
- examName: "",
- exportType: "",
- useable: "1", //默认启用
- questionTypeNums: [
- {
- questionType: "SINGLE_ANSWER_QUESTION",
- quantity: "",
- },
- {
- questionType: "MULTIPLE_ANSWER_QUESTION",
- quantity: "",
- },
- {
- questionType: "BOOL_ANSWER_QUESTION",
- quantity: "",
- },
- ],
- };
- this.isShow = false;
- this.button = false;
- },
- //取消
- cancel() {
- this.isShow = false;
- this.button = false;
- this.dialogModel = false;
- },
- //取消复用
- cancleCopy() {
- this.isShow = false;
- this.dialogCopyModel = false;
- },
- //重置3
- resetForm3() {
- this.exportStructureCopy.examType = "";
- this.exportStructureCopy.examId = "";
- this.isShow = false;
- },
- //复用
- copy(row) {
- this.dialogCopyModel = true;
- this.exportStructureCopy.examTypeOld = row.examType;
- this.exportStructureCopy.examIdOld = parseInt(row.examId);
- this.exportStructureCopy.exportTypeOld = row.exportType;
- this.exportStructureCopy.questionTypeNums = row.questionTypeNums;
- this.exportStructureCopy.examType = "";
- this.exportStructureCopy.examId = "";
- },
- //新增的时候,先查询
- searchExportStructure(type) {
- this.disMessage = false;
- if (type == "examType") {
- this.$http
- .get(
- EXAM_WORK_API +
- "/exam/queryByNameLike?enable=true&name=&examTypes=" +
- this.exportStructure.examType
- )
- .then((response) => {
- this.examListByExamType = response.data;
- this.exportStructure.examId = "";
- this.resetExportStructure();
- });
- }
- if (this.exportStructure.examType && this.exportStructure.examId) {
- var url =
- QUESTION_API + "/findExportStructure/" + this.exportStructure.examId;
- this.$http
- .get(url)
- .then((response) => {
- console.log(response);
- if (!response.data.id) {
- //如果没有数据
- this.resetExportStructure();
- } else {
- this.button = true;
- this.exportStructure.exportType = response.data.exportType;
- this.exportStructure.useable = response.data.useable
- ? response.data.useable.toString()
- : "1";
- for (
- var i = 0;
- i < this.exportStructure.questionTypeNums.length;
- i++
- ) {
- this.exportStructure.questionTypeNums[i].quantity =
- response.data.questionTypeNums[i].quantity;
- }
- this.disMessage = true;
- console.log("非空对象");
- }
- })
- .catch(() => {});
- }
- },
- resetExportStructure() {
- this.button = false;
- this.reShow = true;
- this.exportStructure.exportType = "";
- this.exportStructure.useable = "1";
- for (var i = 0; i < this.exportStructure.questionTypeNums.length; i++) {
- this.exportStructure.questionTypeNums[i].quantity = "";
- }
- },
- //点击复用,选择
- searchExamId() {
- if (this.exportStructureCopy.examType) {
- this.$http
- .get(
- EXAM_WORK_API +
- "/exam/queryByNameLike?enable=true&name=&examTypes=" +
- this.exportStructureCopy.examType
- )
- .then((response) => {
- let examListFilter = response.data;
- var url =
- QUESTION_API +
- "/findExportStructureByExamType/" +
- this.exportStructureCopy.examType;
- this.$http.get(url).then((response) => {
- let examListOld = response.data;
- //两个数组相减
- this.examListNew = _.filter(examListFilter, function (exam) {
- return examListOld.indexOf(exam.id.toString()) == -1;
- });
- });
- });
- }
- },
- //保存复用
- saveCopy() {
- this.isShow = true;
- if (this.check_value(this.exportStructureCopy.examType) === true) {
- return false;
- }
- if (this.check_value(this.exportStructureCopy.examId) === true) {
- return false;
- }
- this.exportStructure.examType = this.exportStructureCopy.examType;
- this.exportStructure.examId = this.exportStructureCopy.examId;
- this.exportStructure.exportType = this.exportStructureCopy.exportTypeOld;
- this.exportStructure.useable = this.exportStructureCopy.useable;
- this.exportStructure.questionTypeNums =
- this.exportStructureCopy.questionTypeNums;
- let examId = this.exportStructure.examId;
- this.exportStructure.examName = _.filter(
- this.examListNew,
- function (item) {
- return item.id == examId;
- }
- )[0].name;
- this.$http
- .post(QUESTION_API + "/saveExportStructure", this.exportStructure)
- .then(() => {
- this.$notify({
- title: "提示",
- message: "保存成功",
- type: "success",
- });
- this.dialogCopyModel = false;
- this.search();
- });
- },
- //删除
- del(row) {
- this.$confirm("是否删除该条导出结构", "提示", {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "warning",
- }).then(() => {
- this.loading = true;
- var url = QUESTION_API + "/deleteExportStructure/" + row.id;
- this.$http.delete(url).then(
- () => {
- this.$notify({
- type: "success",
- message: "删除成功!",
- });
- this.loading = false;
- this.search();
- },
- () => {
- this.$notify({
- type: "error",
- message: "删除失败!",
- });
- this.loading = false;
- }
- );
- });
- this.loading = false;
- },
- //查询考试
- getExams(query) {
- query = query.trim();
- var examType = this.formSearch.examType;
- if (this.formSearch.examType == null) {
- examType = "";
- }
- this.$http
- .get(
- EXAM_WORK_API +
- "/exam/queryByNameLike?enable=true&name=" +
- query +
- "&examTypes=" +
- examType
- )
- .then((response) => {
- this.examList = response.data;
- });
- },
- searchExams() {
- this.formSearch.examId = null;
- this.getExams("");
- },
- },
- };
- </script>
- <style scoped src="../styles/Common.css"></style>
|