Skip to content

Commit fea4850

Browse files
author
redell
committed
修复canvas-nest显示bug
1 parent 07416e3 commit fea4850

File tree

6 files changed

+23
-39
lines changed

6 files changed

+23
-39
lines changed

index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
</style>
4747
<body>
4848
<div id="app"></div>
49+
<div id="CanvasNest" style="position:absolute;height:100%;width:100%;z-index:0;top:100px;left:17%;display:block;"></div>
4950
<!-- built files will be auto injected -->
5051
<div class="ajax-loading" id="ajaxLoading" style="display: none;">
5152
<div class="overlay"></div>

src/components/CanvasNest/CanvasNest.vue

Lines changed: 0 additions & 35 deletions
This file was deleted.

src/main.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ Vue.prototype.$http = axios
1111

1212
router.beforeEach((to, from, next) => {
1313
const token = sessionStorage.getItem('demo-token')
14+
const el = document.querySelector('#CanvasNest')
15+
if (to.name !== 'Index') {
16+
el.style.display = 'none'
17+
} else {
18+
el.style.display = 'block'
19+
}
1420
if (token !== 'null' && token != null) {
1521
Vue.prototype.$http.defaults.headers.common['Authorization'] = 'Bearer ' + token // 全局设定header的token验证,Bearer后面需要添加个空格
1622
}

src/pages/home/Index.vue

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,31 @@
55
<p style="font-size: 30px; color:#f3b7b7;">Author: redell</p>
66
<p style="font-size: 30px;"><a style="color:#f3b7b7;" href="https://github.com/GongJS/vue-antd-management">Github: GongJS</a></p>
77
</div>
8-
<canvas-nest></canvas-nest>
98
</div>
109
</template>
1110
<script>
12-
import CanvasNest from '@/components/CanvasNest/CanvasNest'
11+
import CanvasNest from 'canvas-nest.js'
1312
export default {
1413
name: 'Index',
1514
components: {
1615
'canvas-nest': CanvasNest
1716
},
1817
data () {
1918
return {
19+
config: {
20+
count: 99
21+
}
2022
}
23+
},
24+
mounted () {
25+
const el = document.querySelector('#CanvasNest')
26+
el.style.display = 'block'
27+
this.cn = new CanvasNest(el, this.config)
28+
},
29+
beforeDestroy () {
30+
const el = document.querySelector('#CanvasNest')
31+
el.style.display = 'none'
32+
this.cn.destroy()
2133
}
2234
}
2335
</script>

src/pages/user/User.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,10 @@ export default {
5353
if (type === 'create') {
5454
this.title = '创建员工'
5555
this.visible = true
56+
// 因为共用一个Form表单,当用户新建员工时,即使选中了table里面的某一行数据,打开的From表单应该只有默认值,所以这里要清空userInfo;通过selectItem来判断用户有没有选中table的数据
5657
this.userInfo = null
5758
} else if (type === 'edit' || type === 'detail') {
58-
if (!this.selectItem.id) {
59+
if (!this.selectIte.id) {
5960
Modal.info({
6061
title: '信息',
6162
content: '请选择一个用户'

src/pages/user/UserForm.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,6 @@ export default {
146146
if (err) {
147147
return
148148
}
149-
console.log(555, _this.userInfo.id)
150149
let params = {
151150
username: values.username,
152151
sex: values.sex,

0 commit comments

Comments
 (0)