<template>
|
<div class="app-container">
|
|
<el-row :gutter="10" class="mb8">
|
<el-col :span="6" :xs="24">
|
<div class="head-container">
|
<el-tree
|
:data="catalogListOptions"
|
:props="defaultProps"
|
:expand-on-click-node="false"
|
:filter-node-method="filterNode"
|
ref="tree"
|
default-expand-all
|
highlight-current
|
@node-click="handleNodeClick"
|
/>
|
</div>
|
</el-col>
|
<el-col :span="18" :xs="24">
|
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
|
<el-form-item label="顶级单位" prop="orgId">
|
<el-select v-model="queryParams.orgId" placeholder="选择顶级单位" @change="getList()">
|
<el-option
|
v-for="org in this.rootOrgList"
|
:key="org.id"
|
:label="org.dept_name"
|
:value="org.id"
|
/>
|
</el-select>
|
</el-form-item>
|
|
<el-form-item label="试题类型" prop="questionType">
|
<el-select v-model="queryParams.questionType" placeholder="试题类型">
|
<el-option
|
v-for="d in this.questionTypeList"
|
:key="d.key"
|
:label="d.value"
|
:value="d.key"
|
/>
|
</el-select>
|
</el-form-item>
|
<el-form-item label="试题题目" prop="content">
|
<el-input
|
v-model="queryParams.content"
|
placeholder="试题内容"
|
clearable
|
@keyup.enter.native="handleQuery"
|
/>
|
</el-form-item>
|
<!-- <el-form-item label="专业分类" prop="majorCode">-->
|
<!-- <el-select v-model="queryParams.majorCode" placeholder="请选择专业分类" clearable>-->
|
<!-- <el-option-->
|
<!-- v-for="dict in dict.type.sys_job_status"-->
|
<!-- :key="dict.value"-->
|
<!-- :label="dict.label"-->
|
<!-- :value="dict.value"-->
|
<!-- />-->
|
<!-- </el-select>-->
|
<!-- </el-form-item>-->
|
|
<el-form-item>
|
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
</el-form-item>
|
</el-form>
|
|
<el-row :gutter="10" class="mb8">
|
<el-col :span="1.5">
|
<el-button
|
type="primary"
|
plain
|
icon="el-icon-plus"
|
size="mini"
|
@click="handleAdd"
|
v-hasPermi="['exam:online:add']"
|
>添加</el-button>
|
</el-col>
|
<el-col :span="1.5">
|
<el-button
|
type="danger"
|
plain
|
icon="el-icon-delete"
|
size="mini"
|
:disabled="multiple"
|
@click="handleDelete"
|
v-hasPermi="['exam:online:delBatch']"
|
>删除</el-button>
|
</el-col>
|
<el-col :span="1.5">
|
<el-button
|
type="warning"
|
plain
|
icon="el-icon-search"
|
size="mini"
|
@click="handleExport"
|
v-hasPermi="['exam:online:exist']"
|
>查重</el-button>
|
</el-col>
|
<el-col :span="1.5">
|
<el-button
|
type="warning"
|
plain
|
icon="el-icon-upload2"
|
size="mini"
|
@click="handleExport"
|
v-hasPermi="['exam:online:upload']"
|
>导入</el-button>
|
</el-col>
|
<el-col :span="1.5">
|
<el-button
|
type="info"
|
plain
|
icon="el-icon-download"
|
size="mini"
|
@click=""
|
v-hasPermi="['exam:online:download']"
|
>模板下载</el-button>
|
</el-col>
|
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
</el-row>
|
|
<el-table v-loading="loading" :data="examList" @selection-change="handleSelectionChange">
|
<el-table-column type="selection" width="55" align="left" />
|
<el-table-column label="ID" align="left" prop="id" :show-overflow-tooltip="true" />
|
<el-table-column label="归属" align="left" prop="parameter.orgName"/>
|
<el-table-column label="大类" align="left" prop="parameter.rootCatalogName"/>
|
<el-table-column label="子分类" align="left" prop="parameter.majorCatalogName"/>
|
<el-table-column label="题目" align="left" prop="content" :show-overflow-tooltip="true" />
|
<el-table-column label="试题类型" align="left" prop="parameter.questionTypeName"/>
|
<el-table-column label="创建人" align="left" prop="createUserId" :show-overflow-tooltip="true" />
|
<el-table-column label="创建时间" align="left" prop="parameter.createTimeName" />
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
<template slot-scope="scope">
|
<el-button
|
size="mini"
|
type="text"
|
icon="el-icon-edit"
|
@click="handleUpdate(scope.row)"
|
v-hasPermi="['exam:online:edit']"
|
>修改</el-button>
|
<el-button
|
size="mini"
|
type="text"
|
icon="el-icon-delete"
|
@click="handleDelete(scope.row)"
|
v-hasPermi="['exam:online:del']"
|
>删除</el-button>
|
</template>
|
</el-table-column>
|
</el-table>
|
|
<pagination
|
v-show="total>0"
|
:total="total"
|
:page.sync="queryParams.pageNum"
|
:limit.sync="queryParams.pageSize"
|
@pagination="getList"
|
/>
|
</el-col>
|
</el-row>
|
|
<!-- 添加或修改定时任务对话框 -->
|
<el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
|
<el-form ref="form" :model="form" :rules="rules" label-width="120px">
|
<el-row>
|
<el-col :span="24">
|
<el-form-item label="所属分类" prop="majorId">
|
<el-select v-model="form.majorId" placeholder="请选择所属分类">
|
<el-option
|
v-for="dict in dict.type.sys_job_group"
|
:key="dict.value"
|
:label="dict.label"
|
:value="dict.value"
|
></el-option>
|
</el-select>
|
</el-form-item>
|
</el-col>
|
<el-col :span="24">
|
<el-form-item label="题目类型" prop="type">
|
<el-select v-model="form.type" placeholder="请选择题目类型">
|
<el-option
|
v-for="dict in dict.type.sys_job_group"
|
:key="dict.value"
|
:label="dict.label"
|
:value="dict.value"
|
></el-option>
|
</el-select>
|
</el-form-item>
|
</el-col>
|
<el-col :span="24">
|
<el-form-item label="题目" prop="content">
|
<el-input v-model="form.content" placeholder="请输入题目"/>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
</el-form>
|
<div slot="footer" class="dialog-footer">
|
<el-button type="primary" @click="submitForm">确 定</el-button>
|
<el-button @click="cancel">取 消</el-button>
|
</div>
|
</el-dialog>
|
|
<!-- 试题库详细 -->
|
<el-dialog title="试题库详细" :visible.sync="openView" width="700px" append-to-body>
|
<el-form ref="form" :model="form" label-width="120px" size="mini">
|
<el-row>
|
<el-col :span="12">
|
<el-form-item label="所属分类:">{{ form.id }}</el-form-item>
|
<el-form-item label="题目类型:">{{ form.jobName }}</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item label="题目:">{{ "" }}</el-form-item>
|
<el-form-item label="答案:">{{ form.createTime }}</el-form-item>
|
</el-col>
|
</el-row>
|
</el-form>
|
<div slot="footer" class="dialog-footer">
|
<el-button @click="openView = false">关 闭</el-button>
|
</div>
|
</el-dialog>
|
</div>
|
</template>
|
|
<script>
|
// import { listJob, getJob, delJob, addJob, updateJob, runJob, changeJobStatus } from "@/api/monitor/job";
|
import { listOrgRoot, listOrgRootTree } from '@/api/system/dept'
|
import { listCatalogTreeList, listQuestion, listQuestionType } from '@/api/etaa/question_bank'
|
|
export default {
|
// components: { Crontab },
|
name: "questionBank",
|
dicts: ['sys_job_status'],
|
data() {
|
return {
|
// 日期范围
|
dateRange: [],
|
// 遮罩层
|
loading: true,
|
// 选中数组
|
ids: [],
|
// 非单个禁用
|
single: true,
|
// 非多个禁用
|
multiple: true,
|
// 显示搜索条件
|
showSearch: true,
|
// 总条数
|
total: 0,
|
// 表格数据
|
examList: [],
|
|
// 2022-12-30 根机构列表,个人只能列出自己所在根机构
|
rootOrgList:[],
|
// 2022-12-30 超级管理员选择的顶级机构ID
|
selectedRootOrgId: undefined,
|
// 试题类别列表,2023-03-11
|
questionTypeList: [],
|
// 2023-03-13 试题类别树数据选项
|
catalogListOptions: undefined,
|
/** 分类树数据结构 */
|
defaultProps: {
|
children: "children",
|
label: "label"
|
},
|
|
// 弹出层标题
|
title: "",
|
// 是否显示弹出层
|
open: false,
|
// 是否显示详细弹出层
|
openView: false,
|
// 是否显示Cron表达式弹出层
|
openCron: false,
|
// 传入的表达式
|
expression: "",
|
// 查询参数
|
queryParams: {
|
pageNum: 1,
|
pageSize: 10,
|
content: undefined,
|
catalogId: undefined,
|
orgId: undefined,
|
questionType: undefined
|
},
|
// 表单参数
|
form: {},
|
// 表单校验
|
rules: {
|
content: [
|
{ required: true, message: "题目不能为空", trigger: "blur" }
|
]
|
}
|
};
|
},
|
created() {
|
this.getRootOrgList();
|
this.getQuestionTypeList();
|
},
|
methods: {
|
/** 获取试题类别集合 2023-03-11 */
|
getQuestionTypeList(){
|
listQuestionType().then(response => {
|
// console.log(response.data);
|
this.questionTypeList = response.data;
|
});
|
},
|
/** 获取顶级机构列表选择框 2022-12-30 */
|
getRootOrgList(){
|
this.loading = true;
|
listOrgRoot().then(response => {
|
this.rootOrgList = response.data;
|
this.selectedRootOrgId = this.rootOrgList[0].id;
|
this.queryParams.orgId = this.selectedRootOrgId;
|
this.loading = false;
|
}).then(() => {
|
this.listCatalogTree();
|
this.getList();
|
}).catch(function() {
|
this.loading = false;
|
});
|
},
|
|
// 试题类别树
|
listCatalogTree(){
|
listCatalogTreeList("question_root_catalog").then(response => {
|
console.log(response.data);
|
this.catalogListOptions = response.data;
|
});
|
},
|
|
/** 查询列表 */
|
getList() {
|
this.loading = true;
|
listQuestion(this.queryParams).then(response => {
|
this.examList = response.data;
|
this.total = response.total;
|
this.loading = false;
|
});
|
},
|
|
// 筛选节点
|
filterNode(value, data) {
|
if (!value) return true;
|
console.log("value = " + value + ", data = " + data);
|
return data.label.indexOf(value) !== -1;
|
},
|
// 节点单击事件
|
handleNodeClick(data) {
|
this.queryParams.catalogId = data.id;
|
this.handleQuery();
|
},
|
|
// 取消按钮
|
cancel() {
|
this.open = false;
|
this.reset();
|
},
|
// 表单重置
|
reset() {
|
this.form = {
|
id: undefined,
|
content: undefined,
|
concurrent: 1,
|
status: "0"
|
};
|
this.dateRange = [];// 时间范围
|
this.resetForm("form");
|
},
|
/** 搜索按钮操作 */
|
handleQuery() {
|
this.queryParams.pageNum = 1;
|
this.getList();
|
},
|
/** 重置按钮操作 */
|
resetQuery() {
|
this.resetForm("queryForm");
|
this.queryParams.orgId = this.selectedRootOrgId;
|
this.queryParams.questionType = undefined;
|
this.handleQuery();
|
},
|
// 多选框选中数据
|
handleSelectionChange(selection) {
|
this.ids = selection.map(item => item.id);
|
this.single = selection.length != 1;
|
this.multiple = !selection.length;
|
},
|
// 状态修改
|
handleStatusChange(row) {
|
let text = row.status === "0" ? "启用" : "停用";
|
this.$modal.confirm('确认要"' + text + '""' + row.name + '"任务吗?').then(function() {
|
return changeJobStatus(row.id, row.status);
|
}).then(() => {
|
this.$modal.msgSuccess(text + "成功");
|
}).catch(function() {
|
row.status = row.status === "0" ? "1" : "0";
|
});
|
},
|
/** 任务详细信息 */
|
handleView(row) {
|
// getJob(row.id).then(response => {
|
// this.form = response.data;
|
// this.openView = true;
|
// });
|
},
|
/** 新增按钮操作 */
|
handleAdd() {
|
this.reset();
|
this.open = true;
|
this.title = "添加试题库";
|
},
|
/** 修改按钮操作 */
|
handleUpdate(row) {
|
this.reset();
|
const id = row.id || this.ids;
|
getJob(id).then(response => {
|
this.form = response.data;
|
this.open = true;
|
this.title = "修改试题库";
|
});
|
},
|
/** 提交按钮 */
|
submitForm: function() {
|
this.$refs["form"].validate(valid => {
|
if (valid) {
|
if (this.form.id != undefined) {
|
updateJob(this.form).then(response => {
|
this.$modal.msgSuccess("修改成功");
|
this.open = false;
|
this.getList();
|
});
|
} else {
|
addJob(this.form).then(response => {
|
this.$modal.msgSuccess("新增成功");
|
this.open = false;
|
this.getList();
|
});
|
}
|
}
|
});
|
},
|
/** 删除按钮操作 */
|
handleDelete(row) {
|
const jobIds = row.id || this.ids;
|
this.$modal.confirm('是否确认删除编号为"' + jobIds + '"的数据项?').then(function() {
|
return delJob(jobIds);
|
}).then(() => {
|
this.getList();
|
this.$modal.msgSuccess("删除成功");
|
}).catch(() => {});
|
},
|
/** 导出按钮操作 */
|
handleExport() {
|
this.download('monitor/job/export', {
|
...this.queryParams
|
}, `job_${new Date().getTime()}.xlsx`)
|
}
|
}
|
};
|
</script>
|