From 1315f5489cab1264c70040b2fd222310c59f9d04 Mon Sep 17 00:00:00 2001
From: Jo <479214531@qq.com>
Date: Sun, 21 Nov 2021 23:28:19 +0800
Subject: [PATCH 1/6] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=88=86=E7=B1=BB?=
=?UTF-8?q?=E6=94=B9=E6=88=90=E6=87=92=E5=8A=A0=E8=BD=BD=EF=BC=88=E6=9C=AA?=
=?UTF-8?q?=E5=AE=8C=E6=88=90=EF=BC=89?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/utils/api.js | 1 +
src/views/data/Framework.vue | 68 +++++++++---------
src/views/data/Introduce.vue | 56 +++++----------
src/views/data/Product.vue | 131 ++++++++++++++---------------------
4 files changed, 103 insertions(+), 153 deletions(-)
diff --git a/src/utils/api.js b/src/utils/api.js
index e322202..ffc1e86 100644
--- a/src/utils/api.js
+++ b/src/utils/api.js
@@ -163,6 +163,7 @@ export default {
staticPreview: `${host}/data/data/staticPreview`,
editTableName: `${host}/data/data/table/editTableName`,
updateTableCommit: `${host}/data/data/updateTableCommit`,
+ getLevel: `${host}/data/category/getLevel`,
// 产品管理
deleteProduct: `${host}/data/data/product/delete`,
diff --git a/src/views/data/Framework.vue b/src/views/data/Framework.vue
index 6ae93cb..9dff693 100644
--- a/src/views/data/Framework.vue
+++ b/src/views/data/Framework.vue
@@ -5,7 +5,7 @@
-
+
{{ node.label }}
@@ -70,7 +70,8 @@
{
- // 递归赋值,同时添加层级标识
- function handleId(data,level = 0){
- data.map(n => {
- n.id = String(n.id)
- n.label = n.categoryName
- n.level = level + 1
- if(n.children.length){
- handleId(n.children,n.level)
- }
- })
- }
- handleId(res)
-
- this.typeList = res
- if (!this.added) {
- if(res[0].children.length){
- this.categoryId = res[0].children[0].id
- this.defaultActive = [res[0].children[0].id]
- }else{
- this.categoryId = res[0].id
- this.defaultActive = [res[0].id]
- }
- // 取第一个分类的id
+ getType(node, resolve){
+ this.$post(`${this.api.getLevel}?parentId=${node.level ? node.data.id : 0}`).then(res => {
+ const list = res.list
+ this.node = node
+ this.resolve = resolve
+ resolve(list)
+ // 取第一个分类的id
+ if (!this.added && list.length) {
+ this.categoryId = list[0].id
+ this.defaultActive = [list[0].id]
this.$nextTick(() => {
- this.$refs.type.setCurrentKey(res[0].children[0].id)
+ this.$refs.type.setCurrentKey(list[0].id)
})
}
this.added = false
@@ -274,6 +260,7 @@ export default {
this.getData()
},
addType(row){
+ this.categoryId = row.data.id
if (row) this.defaultActive = [row.data.id]
this.typeVisible = true
this.levelId = row ? row.data.id : 0
@@ -282,6 +269,8 @@ export default {
this.typeVisible = true
this.id = row.data.id
this.categoryName = row.data.categoryName
+ this.curNode = row
+ this.categoryId = row.data.id
},
delType(row){
// 该分类下的数据表已存在于产品管理中,是否确认删除?
@@ -291,7 +280,7 @@ export default {
this.added = true
this.$post(`${this.api.deleteCategory}?categoryId=${row.data.id}`).then(res => {
this.$message.success('删除成功')
- this.getType()
+ this.$refs.type.remove(row)
}).catch(res => {})
}).catch(() => {})
},
@@ -305,7 +294,9 @@ export default {
categoryName: this.categoryName
}).then(res => {
this.$message.success('编辑成功')
- this.getType()
+ this.curNode.data.categoryName = this.categoryName
+ this.$refs.type.updateKeyChildren(this.id, this.curNode)
+ this.getType(this.node, this.resolve)
this.typeVisible = false
setTimeout(() => {
this.submited = false
@@ -319,7 +310,10 @@ export default {
categoryName: this.categoryName
}).then(res => {
this.$message.success('添加成功')
- this.getType()
+ this.getType(this.node, this.resolve)
+ let node = this.$refs.type.getNode(this.categoryId)
+ node.loaded = false
+ node.expand()
this.typeVisible = false
setTimeout(() => {
this.submited = false
diff --git a/src/views/data/Introduce.vue b/src/views/data/Introduce.vue
index 66e5f3d..45e9c05 100644
--- a/src/views/data/Introduce.vue
+++ b/src/views/data/Introduce.vue
@@ -2,7 +2,7 @@
-
+
@@ -56,10 +56,9 @@
export default {
data() {
return {
- typeList: [],
defaultProps: {
children: 'children',
- label: 'label'
+ label: 'categoryName'
},
defaultActive: [],
editing: false,
@@ -69,7 +68,10 @@ export default {
introduceText: '',
categoryId: '',
keywordList: [],
- newKeyword: ''
+ newKeyword: '',
+ node: [],
+ resolve: null,
+ curNode: {}
};
},
watch: {
@@ -80,42 +82,22 @@ export default {
},500)
}
},
- mounted(){
- this.getData()
- },
+ mounted(){},
methods: {
- getData(){
+ getData(node, resolve){
// 获取分类
- this.$post(this.api.getTableByClassification).then(res => {
- // 递归处理id和label
- function handleId(data){
- data.map(n => {
- n.id = String(n.id)
- n.label = n.categoryName
- if(n.children.length){
- handleId(n.children)
- }
- })
- }
- handleId(res)
-
- this.typeList = res
+ this.$post(`${this.api.getLevel}?parentId=${node.level ? node.data.id : 0}`).then(res => {
+ const list = res.list
+ this.node = node
+ this.resolve = resolve
+ resolve(list)
// 取首个的id和简介
- if (!this.edited) {
- if(res[0].children.length){
- let item = res[0].children[0]
- this.categoryId = item.id
- this.dataSource = res[0].children[0].dataSource
- this.defaultActive = [item.id]
- this.introduceText = item.introduce
- this.introduce = item.introduce
- }else{
- this.categoryId = res[0].id
- this.dataSource = res[0].dataSource
- this.defaultActive = [res[0].id]
- this.introduceText = res[0].introduce
- this.introduce = res[0].introduce
- }
+ if (!this.edited && list.length) {
+ this.categoryId = list[0].id
+ this.dataSource = list[0].dataSource
+ this.defaultActive = [list[0].id]
+ this.introduceText = list[0].introduce
+ this.introduce = list[0].introduce
}
this.getKeyword()
}).catch(res => {})
diff --git a/src/views/data/Product.vue b/src/views/data/Product.vue
index 0838271..01b1523 100644
--- a/src/views/data/Product.vue
+++ b/src/views/data/Product.vue
@@ -81,14 +81,10 @@
- 配置数据权限
-
-
-
- {{ node.label }}
-
-
-
+ 配置数据权限
+
+
+