From 23729a4c0bae01d950d466f7cefd5fb32d5faa64 Mon Sep 17 00:00:00 2001
From: wangjiahao <1522128093@qq.com>
Date: Tue, 20 Apr 2021 11:46:24 +0800
Subject: [PATCH] =?UTF-8?q?feat:=E4=BB=AA=E8=A1=A8=E7=9B=98=E6=A8=A1?=
=?UTF-8?q?=E6=9D=BF=E5=AF=BC=E5=85=A5=E5=AF=BC=E5=87=BA?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../template/component/SystemTemplateList.vue | 99 -----------
.../panel/template/component/TemplateItem.vue | 5 +
.../panel/template/component/TemplateList.vue | 158 ++++++++++++++++++
frontend/src/views/panel/template/index.vue | 63 +++----
4 files changed, 198 insertions(+), 127 deletions(-)
delete mode 100644 frontend/src/views/panel/template/component/SystemTemplateList.vue
create mode 100644 frontend/src/views/panel/template/component/TemplateList.vue
diff --git a/frontend/src/views/panel/template/component/SystemTemplateList.vue b/frontend/src/views/panel/template/component/SystemTemplateList.vue
deleted file mode 100644
index 188ca726ce..0000000000
--- a/frontend/src/views/panel/template/component/SystemTemplateList.vue
+++ /dev/null
@@ -1,99 +0,0 @@
-
-
-
-
- 添加分类
-
-
-
-
-
-
-
-
-
-
-
-
-
- {{ data.name }}
-
-
-
-
-
-
-
-
-
-
-
diff --git a/frontend/src/views/panel/template/component/TemplateItem.vue b/frontend/src/views/panel/template/component/TemplateItem.vue
index aac807f64f..504d0f6e0f 100644
--- a/frontend/src/views/panel/template/component/TemplateItem.vue
+++ b/frontend/src/views/panel/template/component/TemplateItem.vue
@@ -2,6 +2,7 @@
@@ -98,4 +99,8 @@ export default {
display: inline;
}
+ .template-img:hover > .el-icon-edit {
+ display: inline;
+ }
+
diff --git a/frontend/src/views/panel/template/component/TemplateList.vue b/frontend/src/views/panel/template/component/TemplateList.vue
new file mode 100644
index 0000000000..aac3281641
--- /dev/null
+++ b/frontend/src/views/panel/template/component/TemplateList.vue
@@ -0,0 +1,158 @@
+
+
+
+
+ 添加分类
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{ data.name }}
+
+
+
+
+
+
+
+
+
+ 编辑
+
+
+ 删除
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/frontend/src/views/panel/template/index.vue b/frontend/src/views/panel/template/index.vue
index e9e4ca293b..da1eec0223 100644
--- a/frontend/src/views/panel/template/index.vue
+++ b/frontend/src/views/panel/template/index.vue
@@ -4,11 +4,12 @@
系统模板
-
+
用户模板
- 开发中...
+
+
@@ -40,14 +41,13 @@
import DeMainContainer from '@/components/dataease/DeMainContainer'
import DeContainer from '@/components/dataease/DeContainer'
import DeAsideContainer from '@/components/dataease/DeAsideContainer'
-import SystemTemplateList from './component/SystemTemplateList'
+import TemplateList from './component/TemplateList'
import TemplateItem from './component/TemplateItem'
import { get, post } from '@/api/panel/panel'
-import { deepCopy } from '../../../components/canvas/utils/utils'
export default {
name: 'PanelMain',
- components: { DeMainContainer, DeContainer, DeAsideContainer, SystemTemplateList, TemplateItem },
+ components: { DeMainContainer, DeContainer, DeAsideContainer, TemplateList, TemplateItem },
data() {
return {
showShare: false,
@@ -62,7 +62,7 @@ export default {
templateEditForm: {},
editTemplate: false,
dialogTitle: '',
- systemTemplateList: []
+ templateList: []
}
},
mounted() {
@@ -70,12 +70,12 @@ export default {
},
methods: {
handleClick(tab, event) {
-
+ this.getTree()
},
showCurrentTemplate(pid) {
- this.currentPid = pid
- if (this.currentPid) {
- post('/template/templateList', { pid: this.currentPid }).then(response => {
+ this.currentTemplateId = pid
+ if (this.currentTemplateId) {
+ post('/template/templateList', { pid: this.currentTemplateId }).then(response => {
this.currentTemplateShowList = response.data
})
}
@@ -88,26 +88,14 @@ export default {
type: 'success',
showClose: true
})
- this.showCurrentTemplate(this.currentPid)
- })
- }
- },
- saveTemplate(templateEditForm) {
- if (templateEditForm) {
- post('/template/save', templateEditForm).then(response => {
- this.$message({
- message: '删除成功',
- type: 'success',
- showClose: true
- })
- this.showCurrentTemplate(this.currentPid)
+ this.getTree()
})
}
},
showTemplateEditDialog(type, templateInfo) {
if (type === 'edit') {
this.dialogTitle = '编辑'
- this.templateEditForm = deepCopy(templateInfo)
+ this.templateEditForm = JSON.parse(JSON.stringify(templateInfo))
} else {
this.dialogTitle = '新建'
this.templateEditForm = { name: '', templateType: this.currentTemplateType, level: 0 }
@@ -138,11 +126,30 @@ export default {
level: '0'
}
post('/template/templateList', request).then(res => {
- this.systemTemplateList = res.data
- if (this.systemTemplateList && this.systemTemplateList.length > 0) {
- this.showCurrentTemplate(this.systemTemplateList[0].id)
- }
+ this.templateList = res.data
+ this.showFirst()
})
+ },
+ showFirst() {
+ // 判断是否默认点击第一条
+ if (this.templateList && this.templateList.length > 0) {
+ let showFirst = true
+ this.templateList.forEach(template => {
+ if (template.id === this.currentTemplateId) {
+ showFirst = false
+ }
+ })
+ if (showFirst) {
+ this.$nextTick().then(() => {
+ const firstNode = document.querySelector('.el-tree-node')
+ firstNode.click()
+ })
+ } else {
+ this.showCurrentTemplate(this.currentTemplateId)
+ }
+ } else {
+ this.currentTemplateShowList = []
+ }
}
}
}