<template>
|
<div class="app-container">
|
<el-aside class="sidebar-box" style="padding: 0;">
|
<div class="sidebar">
|
<el-card class="box-card" shadow="never">
|
<div slot="header" class="clearfix">
|
<span>
|
<svg-icon icon-class="nested" style="margin-top: -2px;" />题库分类
|
</span>
|
<el-button style="float: right; padding: 3px 0" type="text" @click="expandedAll">收起</el-button>
|
</div>
|
<el-input v-model="filterText" clearable placeholder="关键字过滤" />
|
<el-tree ref="treeRef" :data="treeData" :default-expanded-keys="defaultExpandedKeys" :filter-node-method="filterNode" :props="defaultProps" highlight-current node-key="id" @node-click="handleNodeClick" />
|
</el-card>
|
</div>
|
</el-aside>
|
|
<div class="flex-1">
|
<el-card shadow="never" class="box-card filter-card">
|
<!--搜索条件-->
|
<div class="filter-container">
|
<el-form :inline="true" :model="filterForm" size="small">
|
<el-form-item label="顶级单位">
|
<el-select v-model="filterForm.orgId" placeholder="选择顶级单位" @change="search(1)">
|
<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="试题类型">
|
<el-select v-model="filterForm.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="试题题目">
|
<el-input v-model="filterForm.content" placeholder="试题内容" clearable/>
|
</el-form-item>
|
<el-form-item>
|
<my-button-v2 site="filter" name="搜索" @click="search(1)" />
|
<my-button-v2 site="filter" name="重置" @click="reset()" />
|
</el-form-item>
|
</el-form>
|
</div>
|
</el-card>
|
|
<!--列表-->
|
<my-table-v3 ref="myTable" :filter="filterForm" :table="table" />
|
</div>
|
<!--添加/编辑弹窗-->
|
<add v-if="editSetting.show" :setting="editSetting" @search="search()" @close="editSetting.show=false"/>
|
<!-- 导入窗口-->
|
<my-import :import-setting="importSetting" :dialog-show="importSetting.dialogShow" :dialog-title="importSetting.dialogTitle"/>
|
</div>
|
</template>
|
|
<script>
|
import { getToken } from '@/utils/auth'
|
import {listOrgRoot} from '@/api/system/dept'
|
import {clear, listCatalogTreeList, listQuestionType} from '@/api/etaa/question_bank'
|
import myTableV3 from '@/views/components/myTableV3';
|
import myButtonV2 from '@/views/components/myButtonV2'
|
import myImport from '@/views/components/myImport'
|
import {isEmptyValue} from "@/utils/StringUtils";
|
import add from './add'
|
|
export default {
|
components: {myTableV3, myButtonV2, add, myImport},
|
name: "questionBank",
|
data() {
|
return {
|
/** 树配置*/
|
defaultExpandedKeys: [1], // 默认展开的key
|
filterText: '',
|
treeData: [],
|
/** 分类树数据结构 */
|
defaultProps: {
|
children: "children",
|
label: "label"
|
},
|
|
/** 搜索条件*/
|
filterForm: {
|
orgId: null,
|
questionType: null,
|
content: null
|
},
|
|
table: {
|
// size: "small",
|
autoLoad: false,
|
showIndex: false, // 是否显示序号
|
expand: false, // 是否显示详情数据
|
checkBox: false, // 是否显示复选框
|
url: globalConf.baseUrl + '/etaa/question_bank/list', // 请求地址
|
// 工具条
|
tools: {
|
columnsCtrl: {// 列控制按钮
|
show: true
|
},
|
generalExport: {// 通用导出按钮
|
show: false
|
},
|
custom: [ // 自定义工具条按钮
|
{
|
name: '添加试题',
|
// checkPermission: 'system:config:remove',
|
myType: 'danger',
|
mySize: 'mini',
|
click: ()=> {
|
this.handleAdd();
|
}
|
},
|
{
|
name: '导入',
|
click: ()=> {
|
this.handleImport();
|
}
|
},
|
{
|
name: '清空题库',
|
checkPermission: 'etaa:question_bank:clear',
|
myType: 'info',
|
mySize: 'mini',
|
click: ()=> {
|
this.handleClear();
|
}
|
}
|
]
|
},
|
columns: [
|
{ title: 'ID', field: 'id', align: 'left', width: 80 },
|
{ title: '归属', field: 'parameter.orgName', align: 'left', width: 130 },
|
{ title: '大类', field: 'parameter.rootCatalogName', align: 'left', width: 150 },
|
{ title: '子分类', field: 'parameter.majorCatalogName', align: 'left', width: 160},
|
{ title: '题目', field: 'content', align: 'left', width: 230 },
|
{ title: '题型', field: 'parameter.questionTypeName', align: 'left', width: 80 },
|
{ title: '创建人', field: 'createUserId', align: 'left', width: 80 },
|
{ title: '创建时间', field: 'parameter.createTimeName', align: 'left', width: 160 }
|
],
|
// 操作信息
|
operation: {
|
show: true, // 显示操作列
|
width: '100', // 列宽
|
attr: [
|
{
|
title: '编辑',
|
checkPermission: 'system:config:edit',
|
events: row => {
|
this.handleUpdate(row)
|
}
|
}
|
]
|
},
|
paging: {
|
show: true, // 显示分页
|
// 分页信息
|
page: {
|
small: false,
|
pageNum: 1,
|
pageSize: platformPageSize,
|
total: 0
|
}
|
}
|
},
|
|
// 2022-12-30 根机构列表,个人只能列出自己所在根机构
|
rootOrgList:[],
|
// 2022-12-30 超级管理员选择的顶级机构ID
|
selectedRootOrgId: undefined,
|
// 试题类别列表,2023-03-11
|
questionTypeList: [],
|
|
// 添加&编辑窗口
|
editSetting: {
|
id: null,
|
title: '',
|
show: false
|
},
|
|
// 导入
|
importSetting: {
|
dialogTitle: '导入',
|
dialogShow: false,
|
fileSettings: {
|
uploadUrl: globalConf.baseUrl + "/etaa/question_bank/select/import?Authorization=" + getToken(), // 上传地址
|
accept: '.xlsx,.csv', // 格式
|
type: 'text', // 回显形式
|
loading: false // 导入效果
|
},
|
/* 模板下载 */
|
templateSettings: {
|
templateName: '题库导入模板.xlsx', // 名称
|
templateUrl: globalConf.baseUrl + '/etaa/question_bank/select/downloadTemplate?Authorization=' + getToken() // 下载地址
|
},
|
onSuccess: null
|
},
|
};
|
},
|
|
created() {
|
this.getRootOrgList();
|
this.getQuestionTypeList();
|
},
|
methods: {
|
// 树节点过滤
|
filterNode(value, data) {
|
if (!value) return true;
|
console.log("value = " + value + ", data = " + data);
|
return data.label.indexOf(value) !== -1;
|
},
|
// 树节点收起
|
expandedAll() {
|
const nodes = this.$refs.treeRef.store._getAllNodes()
|
for (let i = 0; i < nodes.length; i++) {
|
nodes[i].expanded = false
|
}
|
// 编辑页面
|
// this.editSetting.orgId = null
|
// this.editSetting.orgName = '无'
|
this.reset()
|
},
|
|
// 重置
|
reset() {
|
this.filterForm = {
|
orgId: this.selectedRootOrgId,
|
questionType: null,
|
content: null
|
}
|
this.search(1)
|
},
|
|
// 查询table列表
|
search(pageNum) {
|
if(isEmptyValue(this.filterForm.orgId)){
|
return;
|
} else {
|
// console.log("-----------" + this.filterForm.orgId);
|
if (pageNum != undefined) {
|
this.$refs.myTable.search({ pageNum: pageNum })
|
} else {
|
this.$refs.myTable.search()
|
}
|
}
|
},
|
|
/** 获取试题类别集合 2023-03-11 */
|
getQuestionTypeList(){
|
listQuestionType().then(response => {
|
// console.log(response.data);
|
this.questionTypeList = response.data;
|
});
|
},
|
/** 获取顶级机构列表选择框 2022-12-30 */
|
getRootOrgList(){
|
listOrgRoot().then(response => {
|
this.rootOrgList = response.data;
|
this.selectedRootOrgId = this.rootOrgList[0].id;
|
this.filterForm.orgId = this.selectedRootOrgId;
|
}).then(() => {
|
this.listCatalogTree();
|
this.search(1);
|
}).catch(function() {
|
});
|
},
|
|
// 试题类别树
|
listCatalogTree(){
|
listCatalogTreeList("question_root_catalog").then(response => {
|
// console.log(response.data);
|
this.treeData = response.data;
|
});
|
},
|
|
// 节点单击事件
|
handleNodeClick(data) {
|
// 保持已展开的菜单刷新后依旧展开
|
this.defaultExpandedKeys = [data.id];
|
this.filterForm.catalogId = data.id;
|
this.search(1);
|
},
|
|
/** 任务详细信息 */
|
handleView(row) {
|
// getJob(row.id).then(response => {
|
// this.form = response.data;
|
// this.openView = true;
|
// });
|
},
|
/** 新增按钮操作 */
|
handleAdd() {
|
if(isEmptyValue(this.selectedRootOrgId)){
|
this.$message.warning("请先选择一个顶级机构");
|
return;
|
}
|
if(isEmptyValue(this.filterForm.catalogId)){
|
this.$message.warning("请先选择题库分类");
|
return;
|
}
|
this.editSetting.id = null;
|
this.editSetting.title = "添加试题";
|
this.editSetting.catalogId = this.filterForm.catalogId;
|
this.editSetting.orgId = this.selectedRootOrgId;
|
this.editSetting.show = true;
|
},
|
|
/** 修改按钮操作 */
|
handleUpdate(row) {
|
this.reset();
|
const id = row.id || this.ids;
|
getJob(id).then(response => {
|
this.form = response.data;
|
this.open = true;
|
this.title = "修改试题库";
|
});
|
},
|
|
handleClear(){
|
this.$modal.confirm('要清空题库吗?通常只有测试阶段需要使用!').then(function() {
|
return clear();
|
}).then(() => {
|
this.search(1);
|
this.$modal.msgSuccess("操作成功");
|
}).catch(() => {});
|
},
|
|
handleImport(){
|
this.importSetting.dialogShow = true
|
this.importSetting.onSuccess = (response, callBack) => {
|
console.log(response);
|
if(response.code != 1){
|
this.$message.error('导入失败' || response.msg);
|
callBack();
|
return;
|
}
|
|
if(isEmptyValue(response.data)){
|
// 没有返回错误记录文件
|
this.$message.success("导入成功");
|
this.search();
|
callBack();
|
return;
|
}
|
|
this.$confirm("请查看导入错误,文件:" + response.data, '导入完成', {
|
confirmButtonText: '确定',
|
type: 'warning'
|
}).then(() => {
|
this.search()
|
});
|
// user.importUser(response.data[0]).then(response => {
|
// if (response.code === 10000) {
|
// this.importSetting.dialogShow = false
|
// if (response.data.errorInfo.length === 0) {
|
// this.$message.success(response.data.info)
|
// this.search()
|
// } else {
|
// const errorInfoList = response.data.errorInfo
|
// var errorInfo = errorInfoList.join('')
|
// this.$confirm(errorInfo, '提示', {
|
// confirmButtonText: '确定',
|
// type: 'warning'
|
// }).then(() => {
|
// this.search()
|
// })
|
// }
|
// } else {
|
// this.$message.error('导入失败' || response.description)
|
// this.search()
|
// }
|
// callBack()
|
// })
|
}
|
},
|
|
/** 提交按钮 */
|
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>
|
<style scope lang="scss">
|
.info-main{
|
min-height: calc( 100vh - 50px);
|
}
|
.flex-1{
|
flex:1;
|
}
|
</style>
|