index.vue
3.73 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
<template>
<div>
<h2>{{ listItem.title }}</h2>
<a-list :grid="{ gutter: 16, column: 2 }" :data-source="docData">
<a-list-item slot="renderItem" slot-scope="item">
<a rel="noopener noreferrer" @click="showDocument(item.doc_url)">
<a-card :title="item.doc_title">
<p class="white_space" :title="item.doc_description">{{ item.doc_description }}</p>
<!-- <p v-for="(i, idx) in item.content" :key="i">{{idx + 1}}. {{i}}</p> -->
<template slot="actions">
<a-icon key="edit" type="edit" @click.stop="editFn(item)" />
<a-icon key="delete" type="delete" @click.stop="deleteFn(item)" />
<span @click.stop>
<a-select size="small" v-model="item.classifyId" @select="(e) => {handleSelect(e, item)}">
<!-- @change="handleChange(item)" -->
<a-select-option v-for="classitem in classifyData" :key="classitem.id" :value="classitem.id">
{{ classitem.title }}
</a-select-option>
</a-select>
</span>
</template>
</a-card>
</a>
</a-list-item>
</a-list>
<div class="icon-anticons" @click="add">
<a-icon type="plus-circle" theme="filled" />
</div>
</div>
</template>
<script>
const data = []
export default {
name: 'Developers',
data() {
return {
docData: data,
classifyData: [],
listItem: this.$route.query
}
},
mounted() {
this.getList()
this.getClassifyList()
},
methods: {
//获取全部的分类
getClassifyList() {
this.api.documentClassify.getList().then(res => {
this.classifyData = res
})
},
//移动文档,选中某个分类
handleSelect(e, item) {
let classifyTitle = this.classifyData.filter(val => val.id == e)[0].title
const that = this
this.$confirm({
title: '您确定要移动项目文档?',
content: `您确定要移动项目文档到 ${classifyTitle} 分类?`,
onOk() {
//编辑
item.classify_id = undefined
that.api.documentation.update(item).then(res => {
// console.log("res: ", res);
if (res.id) {
that.$message.success('移动成功')
//重新获取列表
that.getList()
} else {
that.$message.error('移动失败')
}
})
},
onCancel() {
item.classifyId = item.classify_id
},
okText: '确认',
cancelText: '取消'
})
},
getList() {
this.api.documentation.getList(this.listItem.id).then(res => {
// console.log(res);
res.forEach(val => {
val.classifyId = val.classify_id
})
this.docData = res
})
},
add() {
this.to('DocAdd', { classify_id: this.listItem.id })
},
showDocument(url) {
if (url) {
window.open(url)
}
},
editFn(item) {
this.to('DocAdd', 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.documentation.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>