documentClassify.vue
2.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<template>
<div>
<h2>文档分类</h2>
<a-list :grid="{ gutter: 16, column: 4 }" :data-source="docData">
<a-list-item slot="renderItem" slot-scope="item">
<a rel="noopener noreferrer" @click="showDocumentList(item)">
<a-card :title="item.title">
<p class="white_space" :title="item.description">{{ item.description }}</p>
<!-- <p v-for="(i, idx) in item.content" :key="i">{{idx + 1}}. {{i}}</p> -->
<template slot="actions" class="ant-card-actions">
<a-icon key="edit" type="edit" @click.stop="editFn(item)" />
<a-icon key="delete" type="delete" @click.stop="deleteFn(item)" />
</template>
</a-card>
</a>
</a-list-item>
</a-list>
<div class="icon-anticons" @click="addDocument">
<a-icon type="plus-circle" theme="filled" />
<span>添加文档</span>
</div>
<div class="icon-anticons icon-addDoc" @click="addClassify">
<a-icon type="plus-circle" theme="filled" />
<span>添加分类</span>
</div>
</div>
</template>
<script>
const data = []
export default {
name: 'Developers',
data() {
return {
docData: data
}
},
mounted() {
this.getList()
},
methods: {
getList() {
this.api.documentClassify.getList().then(res => {
// console.log(res);
this.docData = res
})
},
// 添加项目文档分类
addClassify() {
this.to('DocClassifyAdd')
},
// 添加文档
addDocument() {
this.to('DocAdd')
},
showDocumentList(item) {
if (item) {
this.$router.push({ name: 'Documentation', query: { id: item.id, title: item.title } })
}
},
editFn(item) {
this.to('DocClassifyAdd', item)
},
deleteFn(item) {
let that = this
this.$confirm({
title: '您确认删除吗?',
onOk() {
that.deleteApiFn(item)
},
onCancel() {},
okText: '确认',
cancelText: '取消'
})
},
async deleteApiFn(item) {
let params = {
id: item.id
}
const res = await this.api.documentClassify.delete(params)
// console.log('res: ', res);
if (res.id) {
this.$message.success('删除成功')
this.getList()
} else {
this.$message.error('删除失败')
}
}
}
}
</script>
<style>
.white_space {
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
</style>