|
|
@@ -2,32 +2,77 @@
|
|
|
<el-space :fill="true" direction="vertical" class="knowledge-wrapper">
|
|
|
<h1>知识树</h1>
|
|
|
<div class="tree_body">
|
|
|
+ <!-- 搜索框 -->
|
|
|
<el-input class="tree_input" placeholder="输入关键字进行过滤" v-model="filterText">
|
|
|
</el-input>
|
|
|
+
|
|
|
+ <!-- 知识树 -->
|
|
|
<el-tree node-key="id" :data="knowledgeData" :props="defaultProps" :filter-node-method="filterNode"
|
|
|
- :default-expanded-keys="expandId" ref="tree" :defalt-expand-all>
|
|
|
+ :default-expanded-keys="expandId" ref="tree">
|
|
|
<template #default="{ node, data }">
|
|
|
<span class="custom-tree-node">
|
|
|
<!-- 知识名 -->
|
|
|
- <span style="width:160px; text-align: left;">{{ node.label }}</span>
|
|
|
- <!-- 掌握程度(百分比)-->
|
|
|
- <span style=" display: flex; justify-content: flex-end; align-items: center;">
|
|
|
- <el-progress :percentage="data.grasp"
|
|
|
- :status="data.grasp >= 80 ? 'success' : data.grasp >= 60 ? 'warning' : 'danger'" style="width: 100px;">
|
|
|
- </el-progress>
|
|
|
- <span>{{ data.grasp }}%</span>
|
|
|
- </span>
|
|
|
- <!-- 编辑按钮 -->
|
|
|
+ <span style="text-align: left;">{{ node.label }}</span>
|
|
|
+ <!-- 按钮区 -->
|
|
|
<span>
|
|
|
- <i class=" el-icon-plus" @click="append(data)"></i>
|
|
|
+ <i class="el-icon-info" @click="() => { curData = data; detailVisible = true }"></i>
|
|
|
+ <el-divider direction="vertical"></el-divider>
|
|
|
+ <i class=" el-icon-plus" @click="() => { curData = data; addVisible = true }"></i>
|
|
|
<el-divider direction="vertical"></el-divider>
|
|
|
- <i class="el-icon-edit" @click="edit(data)"></i>
|
|
|
+ <i class="el-icon-edit" @click="() => { curData = data; editVisible = true }"></i>
|
|
|
<el-divider direction="vertical"></el-divider>
|
|
|
<i class="el-icon-delete" @click="remove(node, data)"></i>
|
|
|
</span>
|
|
|
</span>
|
|
|
</template>
|
|
|
</el-tree>
|
|
|
+
|
|
|
+ <!-- 新建提示框 -->
|
|
|
+ <el-dialog title="新建知识点" v-model="addVisible">
|
|
|
+ <el-form>
|
|
|
+ <el-form-item label="知识点名">
|
|
|
+ <el-input v-model="newData.label" placeholder="请输入知识名"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="掌握要求">
|
|
|
+ <el-input v-model="newData.grasp" placeholder="请输入掌握要求"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="知识描述">
|
|
|
+ <el-input v-model="newData.description" placeholder="请输入知识描述"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ <template #footer>
|
|
|
+ <el-button @click="addVisible = false">取 消</el-button>
|
|
|
+ <el-button type="primary" @click="append">确 定</el-button>
|
|
|
+ </template>
|
|
|
+ </el-dialog>
|
|
|
+
|
|
|
+ <!-- 修改提示框 -->
|
|
|
+ <el-dialog title="修改知识点" v-model="editVisible">
|
|
|
+ <el-form>
|
|
|
+ <el-form-item label="知识点名">
|
|
|
+ <el-input v-model="curData.label" placeholder="请输入知识名"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="掌握要求">
|
|
|
+ <el-input v-model="curData.grasp" placeholder="请输入掌握要求"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="知识描述">
|
|
|
+ <el-input v-model="curData.description" placeholder="请输入知识描述"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ <template #footer>
|
|
|
+ <el-button @click="editVisible = false">取 消</el-button>
|
|
|
+ <el-button type="primary" @click="edit">确 定</el-button>
|
|
|
+ </template>
|
|
|
+ </el-dialog>
|
|
|
+
|
|
|
+ <!-- 详情提示框 -->
|
|
|
+ <el-dialog title="知识点详情" v-model="detailVisible">
|
|
|
+ <el-descriptions size="large" border :column="2">
|
|
|
+ <el-descriptions-item label="知识点名">{{ curData.label }}</el-descriptions-item>
|
|
|
+ <el-descriptions-item label="掌握要求">{{ curData.grasp }}</el-descriptions-item>
|
|
|
+ <el-descriptions-item label="知识描述">{{ curData.description }}</el-descriptions-item>
|
|
|
+ </el-descriptions>
|
|
|
+ </el-dialog>
|
|
|
</div>
|
|
|
|
|
|
</el-space>
|
|
|
@@ -35,7 +80,7 @@
|
|
|
|
|
|
<script>
|
|
|
// import axios from 'axios'
|
|
|
-import { knowledgeData } from "../../../utils/knowledgeData";
|
|
|
+import { knowledgeData } from "@/utils/knowledgeData";
|
|
|
|
|
|
export default {
|
|
|
name: "Knowledge",
|
|
|
@@ -51,28 +96,19 @@ export default {
|
|
|
if (!value) return true;
|
|
|
return data.label.includes(value);
|
|
|
},
|
|
|
- append(data) {
|
|
|
+ append() {
|
|
|
+ let data = this.curData;
|
|
|
if (!data.children) {
|
|
|
data.children = [];
|
|
|
}
|
|
|
- this.$prompt('请输入知识点名称', '添加知识点', {
|
|
|
- confirmButtonText: '确定',
|
|
|
- cancelButtonText: '取消',
|
|
|
- inputPattern: /\S/,
|
|
|
- inputErrorMessage: '知识点名称不能为空'
|
|
|
- }).then(({ value }) => {
|
|
|
- data.children.push({
|
|
|
- id: data.id * 10 + data.children.length,
|
|
|
- label: value,
|
|
|
- grasp: "0"
|
|
|
- });
|
|
|
- }).catch((err) => {
|
|
|
- console.log(err);
|
|
|
- this.$message({
|
|
|
- type: 'info',
|
|
|
- message: '取消输入'
|
|
|
- });
|
|
|
+ // 知识点名、知识点缩写、知识点描述
|
|
|
+ data.children.push({
|
|
|
+ id: data.id * 10 + data.children.length,
|
|
|
+ label: this.newData.label,
|
|
|
+ grasp: this.newData.grasp,
|
|
|
+ description: this.newData.description,
|
|
|
});
|
|
|
+ this.addVisible = false;
|
|
|
},
|
|
|
remove(node, data) {
|
|
|
this.$confirm('确认删除该知识点吗?', '删除知识点', {
|
|
|
@@ -91,21 +127,8 @@ export default {
|
|
|
});
|
|
|
});
|
|
|
},
|
|
|
- edit(data) {
|
|
|
- this.$prompt('请输入新知识点名称', '修改知识点', {
|
|
|
- confirmButtonText: '确定',
|
|
|
- cancelButtonText: '取消',
|
|
|
- inputPattern: /\S/,
|
|
|
- inputErrorMessage: '知识点名称不能为空',
|
|
|
- inputValue: data.label
|
|
|
- }).then(({ value }) => {
|
|
|
- data.label = value;
|
|
|
- }).catch(() => {
|
|
|
- this.$message({
|
|
|
- type: 'info',
|
|
|
- message: '取消输入'
|
|
|
- });
|
|
|
- });
|
|
|
+ edit() {
|
|
|
+ this.editVisible = false;
|
|
|
},
|
|
|
},
|
|
|
data() {
|
|
|
@@ -117,6 +140,18 @@ export default {
|
|
|
children: 'children',
|
|
|
label: 'label',
|
|
|
},
|
|
|
+ // 编辑相关
|
|
|
+ newData: {
|
|
|
+ id: '',
|
|
|
+ label: '',
|
|
|
+ grasp: '',
|
|
|
+ description: '',
|
|
|
+ },
|
|
|
+ curData: {},
|
|
|
+ curNode: {},
|
|
|
+ addVisible: false,
|
|
|
+ editVisible: false,
|
|
|
+ detailVisible: false,
|
|
|
}
|
|
|
},
|
|
|
mounted() {
|
|
|
@@ -136,7 +171,7 @@ export default {
|
|
|
}
|
|
|
</script>
|
|
|
|
|
|
-<style>
|
|
|
+<style scoped>
|
|
|
.custom-tree-node {
|
|
|
flex: 1;
|
|
|
display: flex;
|