知识点、题库分类

dev_review
yujialong 4 months ago
parent 2669f15962
commit b831b14302
  1. 8
      src/router/index.js
  2. 488
      src/views/theoryExam/knowledge.vue
  3. 194
      src/views/theoryExam/quesBankType.vue

@ -245,6 +245,14 @@ let router = new Router({
path: '/theoryExam/quesBank',
component: () => import('../views/theoryExam/quesBank'),
},
{
path: '/theoryExam/knowledge',
component: () => import('../views/theoryExam/knowledge'),
},
{
path: '/theoryExam/quesBankType',
component: () => import('../views/theoryExam/quesBankType'),
},
{
path: '/404',
component: () => import('../views/404.vue'),

@ -0,0 +1,488 @@
<template>
<div class="page">
<div class="side">
<div class="m-b-20">
<h6 class="p-title">知识点</h6>
<el-radio-group v-model="studentType" @change="changeType">
<div class="m-b-20">
<el-radio :label="1">所有知识点</el-radio>
</div>
<div>
<el-radio :label="2">未加入分类的知识点</el-radio>
</div>
</el-radio-group>
</div>
<el-divider></el-divider>
<div>
<div class="flex-between">
<h6 class="p-title" style="margin-bottom: 0">知识点分类</h6>
<el-button type="text" @click="addOrg">添加</el-button>
</div>
<div style="overflow: auto">
<el-tree :data="orgList" default-expand-all ref="orgTree" node-key="id" highlight-current
:expand-on-click-node="false" @node-click="handleNodeClick"
:props="{ children: 'children', label: 'organizationName', isLeaf: 'leaf' }">
<span class="custom-tree-node" slot-scope="{ node, data }">
<span class="org-name">{{ node.label }}</span>
<span>
<el-button type="text" icon="el-icon-circle-plus-outline" @click="() => addOrg(node, data)">
</el-button>
<el-button type="text" icon="el-icon-edit-outline" @click="() => editOrg(node, data)">
</el-button>
<el-button type="text" icon="el-icon-delete" @click="() => delOrg(node, data)">
</el-button>
</span>
</span>
</el-tree>
</div>
</div>
<el-dialog :title="orgForm.id ? '编辑' : '新增' + '知识点分类'" :visible.sync="orgVisible" :close-on-click-modal="false"
width="50%">
<el-form v-if="orgVisible" ref="orgForm" :model="orgForm" :rules="orgRules" label-width="100px">
<el-form-item label="知识点分类名称" prop="organizationName">
<el-input v-model.trim="orgForm.organizationName" placeholder="请输入"></el-input>
</el-form-item>
<el-form-item label="设置上一级">
<span v-if="orgForm.parentName">{{ orgForm.parentName }}</span>
<el-cascader v-else :options="orgListDia" v-model="cascaderValue" :props="cascaderProps" clearable
style="width: 100%">
</el-cascader>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button @click="closeOrg"> </el-button>
<el-button type="primary" @click="orgSubmit"> </el-button>
</span>
</el-dialog>
</div>
<div class="right">
<h6 class="p-title">筛选</h6>
<div class="tool">
<ul class="filter">
<li>
<el-input style="width: 250px;" placeholder="请输入知识点名称" prefix-icon="el-icon-search" v-model="keyWord"
clearable></el-input>
</li>
</ul>
<div>
<el-button type="primary" @click="add">新增知识点</el-button>
<el-button type="primary" @click="delAllSelection">批量删除</el-button>
</div>
</div>
<el-table :data="list" class="table" ref="table" stripe header-align="center"
@selection-change="handleSelectionChange" row-key="accountId">
<el-table-column type="selection" width="55" align="center" :reserve-selection="true"></el-table-column>
<el-table-column type="index" width="60" label="序号" align="center"></el-table-column>
<el-table-column prop="userName" label="知识点名称" align="center" min-width="100"></el-table-column>
<el-table-column prop="account" label="知识点分类" align="center" min-width="100"></el-table-column>
<el-table-column prop="phone" label="已关联试题" align="center" width="120"></el-table-column>
<el-table-column prop="phone" label="创建时间" align="center" width="120"></el-table-column>
<el-table-column prop="phone" label="创建人" align="center" width="120"></el-table-column>
<el-table-column label="操作" align="center" width="300">
<template slot-scope="scope">
<el-button type="text" v-auth="'/system:后台账号:编辑'" @click="queryStaff(scope.row, false)">编辑</el-button>
<el-button type="text" v-auth="'/system:后台账号:重置密码'" @click="resetPassword(scope.row)">转移</el-button>
<el-button type="text" v-auth="'/system:后台账号:删除'" @click="delStaff(scope.row)">删除</el-button>
</template>
</el-table-column>
</el-table>
<div class="pagination">
<el-pagination background @current-change="currentChange" :current-page="page" layout="total, prev, pager, next"
:total="total"></el-pagination>
</div>
<el-dialog :title="!form.id ? '添加知识点' : '编辑知识点'" :visible.sync="knowledgeVisible" width="400px"
:close-on-click-modal="false">
<el-form label-width="100px">
<el-form-item prop="userName" label="知识点分类">
<el-select style="width: 100%" v-model="form.provinceId" placeholder="请选择知识点分类">
<el-option v-for="(item, i) in types" :key="i" :label="item.provinceName"
:value="item.provinceId"></el-option>
</el-select>
</el-form-item>
<el-form-item prop="userName" label="知识点名称">
<el-input placeholder="请输入知识点名称" v-model="form.name" maxlength="20"></el-input>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button @click="knowledgeVisible = false"> </el-button>
<el-button type="primary" @click="knowledgeSubmit"> </el-button>
</span>
</el-dialog>
</div>
</div>
</template>
<script>
import util from "@/libs/util";
import Setting from "@/setting";
import OrgTree from "@/components/org-tree/src/tree";
export default {
components: { OrgTree },
data () {
return {
orgList: [],
orgListDia: [],
studentType: 1, //:(1. 2.)
orgVisible: false, //
orgForm: {
id: '',
organizationName: ''
},
cascaderValue: [], //
cascaderProps: {
checkStrictly: true,
label: "organizationName",
value: "id"
},
treeVisible: true,
treeNode: {},
treeResolve: [],
isDetail: false,
keyWord: '',
types: [],
form: {
accountId: '',
userName: '',
phone: '',
roleList: [],
uniqueIdentification: '',
workNumber: '',
email: '',
account: '',
staffArchitectureId: []
},
orgRules: {
organizationName: [
{ required: true, message: "请输入部门名称", trigger: "blur" }
]
},
rules: {
account: [
{ required: true, message: "请输入部门名称", trigger: "blur" }
],
},
list: [],
page: 1,
pageSize: 10,
total: 0,
multipleSelection: [],
knowledgeVisible: false,
submiting: false //
};
},
watch: {
keyWord: function (val) {
clearTimeout(this.searchTimer);
this.searchTimer = setTimeout(this.getList, 500);
}
},
mounted () {
this.getOrg()
},
methods: {
//
async getOrg () {
const res = await this.$post(this.api.treeListArch)
const list = res.treeList
this.orgList = list
this.getList()
},
//
changeType () {
this.$refs.orgTree.setCurrentKey(null)
this.initData()
},
//
addOrg (node, data) {
const list = JSON.parse(JSON.stringify(this.orgList))
this.handleOrg(list)
this.orgListDia = list
this.orgForm = {
id: '',
parentId: data ? data.id : 1,
level: data ? data.level + 1 : 1,
parentName: data ? data.organizationName : '',
organizationName: ''
}
this.orgVisible = true
},
//
editOrg (node, data) {
const list = JSON.parse(JSON.stringify(this.orgList))
this.handleOrg(list, data.id, 0)
this.orgListDia = list
this.orgForm = {
id: data.id,
organizationName: data.organizationName
}
this.orgVisible = true
const ids = data.ids
ids.splice(ids.length - 1, 1)
this.cascaderValue = ids
},
//
handleOrg (list, id, disabled) {
list.forEach(e => {
// disabled
if (disabled) {
e.disabled = true
e.children && this.handleOrg(e.children, id, 1)
} else {
if (e.id === id) {
e.disabled = true
e.children && this.handleOrg(e.children, id, 1)
} else {
e.children && this.handleOrg(e.children, id, 0)
}
}
})
},
//
delOrg (node, data) {
this.$confirm("确定要删除吗?", "提示", {
type: "warning"
}).then(() => {
this.$post(`${this.api.deleteArch}?id=${data.id}`).then(res => {
util.successMsg("删除成功")
this.getOrg()
}).catch(res => { })
}).catch(() => { })
},
// /
orgSubmit () {
this.$refs.orgForm.validate((valid) => {
if (valid) {
const form = this.orgForm
const cas = this.cascaderValue
const len = cas.length
if (cas && len) {
this.orgForm.parentId = cas[len - 1]
this.orgForm.level = len + 1
}
if (!form.id) {
//
this.$post(this.api.saveArch, form).then(res => {
util.successMsg("新增成功!")
this.closeOrg()
}).catch(err => { })
} else {
//
this.$post(this.api.updateArch, form).then(res => {
util.successMsg("编辑成功!")
this.closeOrg()
}).catch(err => { })
}
}
});
},
//
handleNodeClick (data) {
this.$refs.table.clearSelection()
this.studentType = null
this.getList()
},
//
closeOrg () {
this.orgVisible = false
this.cascaderValue = []
this.getOrg()
},
//
getList () {
this.$post(this.api.staffList, {
type: this.studentType || 1,
staffArchitectureId: this.$refs.orgTree.getCurrentKey() || '',
keyWord: this.keyWord,
pageNum: this.page,
pageSize: this.pageSize
}).then(res => {
this.list = res.page.records
this.total = res.page.total
}).catch(err => { })
},
//
currentChange (val) {
this.page = val
this.getList()
},
handleSelectionChange (val) { //
this.multipleSelection = val
},
initData () {
this.$refs.table.clearSelection()
this.page = 1
this.getList()
},
//
delStaff (row) {
this.$confirm("确定要删除吗?", "提示", {
type: "warning"
}).then(() => {
this.$post(`${this.api.delStaff}?accountIds=${row.accountId}`).then(res => {
util.successMsg("删除成功")
this.getList()
}).catch(res => { })
}).catch(() => { })
},
//
resetPassword (row) {
const newPwd = Setting.initialPassword
this.$confirm(`重置后的密码为:${newPwd},确定重置?`, "提示", { type: "warning" }).then(() => {
this.$get(`${this.api.resetPwd}?userId=${row.userId}&newPwd=${newPwd}`).then(res => {
util.successMsg("重置成功")
}).catch(res => { })
}).catch(() => { })
},
//
add () {
this.knowledgeVisible = true
this.$nextTick(() => {
this.$refs.form.clearValidate()
})
},
// /
queryStaff (row, isDetail) {
const archId = []
// id
const handleArchId = (list, ids, parentId = []) => {
list.map(e => {
// id[[1, 2], [3, 4]]idid
if (ids.includes(e.id)) {
archId.push([...parentId, e.id])
} else {
e.children && handleArchId(e.children, ids, [...parentId, e.id])
}
})
}
this.isDetail = isDetail
this.staffVisible = true
this.$get(`${this.api.staffDetail}?accountId=${row.accountId}`).then(res => {
const { data } = res
const { staffArchitectureId, roleId } = data
if (roleId) {
const roleList = roleId.split(',').map(e => Number(e))
const list = this.roleList
if (roleList.length) {
let has = false //
for (const i in roleList) {
if (list.find(n => n.id === roleList[i])) {
has = true
break
}
}
if (!has) {
util.warningMsg('角色被删请重新选择')
data.roleList = []
} else {
data.roleList = roleList
}
}
}
if (staffArchitectureId) {
handleArchId(this.orgList, staffArchitectureId.split(',').map(e => Number(e)))
data.staffArchitectureId = archId
}
this.form = data
this.originAccount = data.account
this.originWorkNumber = data.workNumber
}).catch(res => { })
},
//
knowledgeSubmit () {
this.$refs.form.validate((valid) => {
if (valid) {
if (this.submiting) return false
this.submiting = true
const form = JSON.parse(JSON.stringify(this.form))
const ids = form.staffArchitectureId
if (ids) form.staffArchitectureId = ids.map(e => e[e.length - 1])
if (form.accountId) {
this.$post(this.api.modifyStaff, form).then(res => {
util.successMsg("编辑成功!")
this.staffVisible = false
setTimeout(() => {
this.submiting = false
}, 2000)
}).catch(res => {
setTimeout(() => {
this.submiting = false
}, 2000)
})
} else {
form.uniqueIdentification = new Date().getTime()
this.$post(this.api.saveStaff, form).then(res => {
util.successMsg("新增成功!")
this.staffVisible = false
setTimeout(() => {
this.submiting = false
}, 2000)
}).catch(res => {
setTimeout(() => {
this.submiting = false
}, 2000)
})
}
}
})
},
delAllSelection () {
const list = this.multipleSelection
if (list.length) {
//
this.$confirm("确定要删除吗?", "提示", {
type: "warning"
}).then(() => {
this.$post(this.api.orderDelete, { ids: list }).then(res => {
const { orderData } = this
this.$message.success("删除成功");
this.$refs.table.clearSelection()
this.getData();
}).catch(err => {
});
}).catch(err => {
});
} else {
this.$message.error("请先选择数据 !");
}
},
}
};
</script>
<style lang="scss" scoped>
.m-b-20 {
margin-bottom: 20px;
}
.org-name {
margin-right: 20px;
}
.w-100 {
width: 100%;
}
.page {
display: flex;
min-height: 100%;
padding: 0 24px;
.side {
width: 300px;
padding: 24px 10px 24px 0;
margin-right: 24px;
border-right: 1px solid rgba(0, 0, 0, 0.06);
}
.right {
width: calc(100% - 374px);
padding: 24px 0;
}
}
</style>

@ -0,0 +1,194 @@
<template>
<div class="page">
<div class="tool">
<ul class="filter">
<li>
<label>状态</label>
<el-select v-model="filter.status" clearable placeholder="请选择状态" @change="getData">
<el-option v-for="(item, i) in status" :key="i" :label="item.name" :value="item.id"></el-option>
</el-select>
</li>
<li>
<label>搜索</label>
<el-input style="width: 250px;" placeholder="请输入题库分类名称" prefix-icon="el-icon-search" v-model="filter.keyWord"
clearable></el-input>
</li>
</ul>
<div>
<el-button type="primary" @click="add">新增</el-button>
<el-button type="primary" @click="delAllSelection">批量删除</el-button>
</div>
</div>
<el-table v-loading="loading" :data="list" class="table" ref="table" stripe header-align="center" row-key="id"
default-expand-all :tree-props="{ children: 'children', hasChildren: 'hasChildren' }">
<el-table-column type="index" width="100" label="序号" align="center"></el-table-column>
<el-table-column prop="curriculumName" label="题库分类名称" align="center"></el-table-column>
<el-table-column prop="curriculumType" label="已关联题库" align="center"></el-table-column>
<el-table-column prop="userName" label="创建时间" align="center"></el-table-column>
<el-table-column prop="orderVolume" label="创建人" align="center"></el-table-column>
<el-table-column label="操作" align="center" width="300">
<template slot-scope="scope">
<el-button type="text" @click="edit(scope.row)">新增下级</el-button>
<el-button type="text" @click="edit(scope.row)">编辑</el-button>
<el-button type="text" @click="del(scope.row)">删除</el-button>
<el-switch v-model="scope.row.ztOpen" :active-value="0" :inactive-value="1" style="margin: 0 10px 0 5px"
:active-text="scope.row.ztOpen ? '关' : '开'"
@change="switchOff($event, scope.row, scope.$index)"></el-switch>
</template>
</el-table-column>
</el-table>
<div class="pagination">
<el-pagination background @current-change="handleCurrentChange" :current-page="page"
layout="total, prev, pager, next" :total="total"></el-pagination>
</div>
<el-dialog :title="(!form.id ? '新增' : '编辑') + '题库分类'" :visible.sync="typeVisible" width="400px"
:close-on-click-modal="false">
<el-form label-width="100px">
<el-form-item prop="userName" label="题库分类名称">
<el-input placeholder="请输入分类名称" v-model="form.name" maxlength="20"></el-input>
</el-form-item>
<el-form-item prop="userName" label="设置上一级">
<el-select style="width: 100%" v-model="form.provinceId" placeholder="请选择">
<el-option v-for="(item, i) in types" :key="i" :label="item.provinceName"
:value="item.provinceId"></el-option>
</el-select>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button @click="knowledgeVisible = false"> </el-button>
<el-button type="primary" @click="knowledgeSubmit"> </el-button>
</span>
</el-dialog>
</div>
</template>
<script>
import qs from 'qs'
export default {
data () {
return {
status: [
{
id: 1,
name: '启用'
},
{
id: 2,
name: '禁用'
},
],
filter: {
status: '',
keyWord: '',
},
list: [],
types: [],
form: {
curriculumName: ''
},
typeVisible: false,
page: +this.$route.query.page || 1,
pageSize: 10,
total: 0,
loading: false,
searchTimer: null
};
},
watch: {
"form.curriculumName": function (val) {
clearTimeout(this.searchTimer);
this.searchTimer = setTimeout(() => {
this.initData();
}, 500);
}
},
mounted () {
this.getData()
},
methods: {
//
getData () {
const sid = this.$store.state.dataPer.find(e => e.permissionName === '课程管理')
let data = {
...this.form,
pageNum: this.page,
pageSize: this.pageSize,
supplierId: sid ? sid.supplierId : ''
};
this.$post(this.api.curriculumList, data).then(res => {
this.list = res.page.records
this.total = res.page.total
this.loading = false
}).catch(err => { })
},
initData () {
this.page = 1
this.getData()
},
//
add () {
this.typeVisible = true
},
//
edit (row) {
this.$router.push(`/addcurriculum?cid=${row.cid}`);
},
//
del (row) {
this.$post(`${this.api.deleteCoursePrompt}?cids=${row.cid}`).then(({ status }) => {
if (status === 200) {
this.$confirm("确定要删除吗?", "提示", {
type: "warning"
}).then(() => {
this.$post(`${this.api.delCourse}?cids=${row.cid}`).then(res => {
this.getData();
this.$message.success("删除成功");
}).catch(err => { })
}).catch(() => {
});
}
}).catch(err => { })
},
//
delAllSelection () {
if (this.multipleSelection.length) {
let cids = []
this.multipleSelection.forEach(i => {
cids.push('cids=' + i.cid)
});
this.$post(`${this.api.deleteCoursePrompt}?${cids.join('&')}`).then(({ status }) => {
if (status === 200) {
this.$confirm("确定要删除吗?", "提示", {
type: "warning"
}).then(() => {
let ids = this.multipleSelection.map(i => i.cid);
this.$post(`${this.api.delCourse}?cids=${ids.toString()}`).then(res => {
if (ids.length == this.list.length) {
if (this.page > 1) {
this.page = this.page - 1
}
}
this.getData();
this.$message.success("删除成功");
this.$refs.table.clearSelection()
}).catch(err => { })
}).catch(() => { })
}
}).catch(err => { })
} else {
this.$message.warning("请先选择课程 !");
}
},
//
handleCurrentChange (val) {
this.page = val;
this.$router.push(`/curriculum?page=${val}`)
this.getData();
},
}
};
</script>
<style scoped></style>
Loading…
Cancel
Save