|
@@ -62,14 +62,20 @@
|
|
|
/>
|
|
|
|
|
|
<div class="treeWrap">
|
|
|
- <el-button type="primary" @click="addCate">添加分类</el-button>
|
|
|
+ <el-button type="primary" @click="addCate" class="addCateBtn"
|
|
|
+ >添加分类</el-button
|
|
|
+ >
|
|
|
<el-tree
|
|
|
:data="form.data"
|
|
|
- show-checkbox
|
|
|
node-key="index"
|
|
|
default-expand-all
|
|
|
:expand-on-click-node="false"
|
|
|
+ draggable
|
|
|
+ accordion
|
|
|
+ :allow-drop="allowDrop"
|
|
|
+ :allow-drag="allowDrag"
|
|
|
>
|
|
|
+ >
|
|
|
<span class="custom-tree-node" slot-scope="{ node, data }">
|
|
|
<span>{{ node.label }}</span>
|
|
|
<span>
|
|
@@ -78,7 +84,7 @@
|
|
|
size="mini"
|
|
|
@click="() => appendItem(data)"
|
|
|
>
|
|
|
- 添加
|
|
|
+ 添加
|
|
|
</el-button>
|
|
|
<el-button
|
|
|
type="text"
|
|
@@ -133,25 +139,43 @@ export default {
|
|
|
return newArr;
|
|
|
}
|
|
|
},
|
|
|
- appendItem(data) {},
|
|
|
+ appendItem(data) {
|
|
|
+ this.$prompt("请输入教材名称", "提示", {
|
|
|
+ confirmButtonText: "确定",
|
|
|
+ cancelButtonText: "取消",
|
|
|
+ closeOnClickModal: false,
|
|
|
+ inputPattern: /^.{1,30}$/,
|
|
|
+ inputErrorMessage: "请输入1到15个汉字或字符",
|
|
|
+ })
|
|
|
+ .then(({ value }) => {
|
|
|
+ this.index += 1;
|
|
|
+ this.form.data.push({ index: `xxx${this.index}`, label: value });
|
|
|
+ const newChild = {
|
|
|
+ index: `xxx${this.index}`,
|
|
|
+ label: value,
|
|
|
+ children: [],
|
|
|
+ };
|
|
|
+ if (!data.children) {
|
|
|
+ this.$set(data, "children", []);
|
|
|
+ }
|
|
|
+ data.children.push(newChild);
|
|
|
+ })
|
|
|
+ .catch(() => {});
|
|
|
+ },
|
|
|
removeItem(node, data) {},
|
|
|
addCate() {
|
|
|
-
|
|
|
this.$prompt("请输入分类名称", "提示", {
|
|
|
confirmButtonText: "确定",
|
|
|
cancelButtonText: "取消",
|
|
|
- closeOnClickModal:false,
|
|
|
- inputPattern:
|
|
|
- /^.{1,30}$/,
|
|
|
+ closeOnClickModal: false,
|
|
|
+ inputPattern: /^.{1,30}$/,
|
|
|
inputErrorMessage: "请输入1到15个汉字或字符",
|
|
|
})
|
|
|
.then(({ value }) => {
|
|
|
- this.index += 1;
|
|
|
- this.form.data.push({index:`xxx${this.index}`,label:value})
|
|
|
+ this.index += 1;
|
|
|
+ this.form.data.push({ index: `xxx${this.index}`, label: value });
|
|
|
})
|
|
|
- .catch(() => {
|
|
|
-
|
|
|
- });
|
|
|
+ .catch(() => {});
|
|
|
// this.form.data.push({})
|
|
|
},
|
|
|
},
|
|
@@ -166,4 +190,7 @@ export default {
|
|
|
margin-right: 0 !important;
|
|
|
}
|
|
|
}
|
|
|
+.addCateBtn {
|
|
|
+ margin-bottom: 20px;
|
|
|
+}
|
|
|
</style>
|