index.vue
7.28 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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
<template>
<div class="home-project">
<h2>{{ $route.query.classify }} 分类项目</h2>
<a-list item-layout="horizontal" :data-source="projectData">
<a-list-item slot="renderItem" slot-scope="item">
<a-list-item-meta>
<!-- <a slot="title" href="https://www.antdv.com/">{{ item.title }}</a> -->
<a-avatar slot="avatar" :src="projectImgUrl" />
</a-list-item-meta>
<div>
<a-descriptions :title="item.project_title" :bordered="false">
<a-descriptions-item label="开发人员">
{{ item.developer_name }}
</a-descriptions-item>
<a-descriptions-item label="测试项目地址">
<a
:href="item.test_url"
target="_blank"
rel="noopener noreferrer"
>{{ item.test_url }}</a
>
</a-descriptions-item>
<a-descriptions-item label="生产项目地址">
<a
:href="item.test_url"
target="_blank"
rel="noopener noreferrer"
>{{ item.product_url }}</a
>
</a-descriptions-item>
<a-descriptions-item label="使用技术">
{{ item.technology }}
</a-descriptions-item>
<a-descriptions-item label="配置名称">
{{ item.config_name }}
</a-descriptions-item>
<a-descriptions-item label="git地址">
<a
:href="item.git_url"
target="_blank"
rel="noopener noreferrer"
>{{ item.git_url }}</a
>
</a-descriptions-item>
<a-descriptions-item label="git提交信息">
<!-- <a
:href="item.git_commit"
target="_blank"
rel="noopener noreferrer"
>{{ item.git_commit }}</a
> -->
<a-button type="link" @click="checkGitLog(item)">
查看git提交信息
</a-button>
</a-descriptions-item>
<a-descriptions-item label="git项目ID">
<a-popover title="什么是git ID">
<template slot="content">
<p>1.进入git仓库项目设置</p>
<p>2.查看 Project ID</p>
</template>
{{ item.git_id }} <a-icon type="question" />
</a-popover>
</a-descriptions-item>
</a-descriptions>
</div>
<a slot="actions" @click="editFn(item)">编辑</a>
<a slot="actions" @click="commentsFn(item)">评论</a>
<a slot="actions" @click="delFn(item)">删除</a>
<template slot="actions">
<a-select
size="small"
v-model="item.classify"
@select="handleSelect(item)"
>
<!-- @change="handleChange(item)" -->
<a-select-option
v-for="classitem in classifyData"
:key="classitem.id"
:value="classitem.classify"
>
{{ classitem.classify }}
</a-select-option>
</a-select>
</template>
</a-list-item>
</a-list>
<div class="icon-anticons" @click="add">
<a-icon type="plus-circle" theme="filled" />
</div>
</div>
</template>
<script>
const data = [
// {
// id: 1,
// project_title: "广联运营平台",
// project_description: "广联运营平台",
// developer_name: "胡悦、陈婉清",
// config_name: "/admin_common",
// test_url: "http://sso.test.glsx.com.cn/#/login",
// product_url: "http://sso.glsx.com.cn/#/login",
// technology: "vue",
// git_url: "http://giturl.com/",
// git_id: 173,
// classify: "other",
// },
// {
// id: 2,
// project_title: "账户管理",
// project_description: "商户、角色、员工管理",
// developer_name: "胡悦、陈婉清",
// config_name: "/glsx-oss-account-config",
// test_url: "http://glsx-account-merchants.test.glsx.com.cn",
// product_url: "http://glsx-account.glsx.com.cn",
// technology: "vue",
// git_url: "http://giturl.com/",
// git_id: 173,
// classify: "other",
// },
];
import projectImgUrl from "@/assets/project.jpg";
// import { getQueryVariable } from "@/utils/index";
export default {
name: "Home",
data() {
return {
projectData: data,
projectImgUrl,
classifyData: [],
// selectClassify: "", //选中的分类
};
},
mounted() {
this.getList();
this.getClassifyList();
},
methods: {
getList() {
const classify = this.$route.query.classify;
this.api.project.getList(classify).then((res) => {
// console.log(res);
this.projectData = res;
});
},
//设置 项目分类
setClassifyFn() {
const classify = this.$route.query.classify;
sessionStorage.setItem("classify", classify);
},
add() {
this.to("HomeAdd");
this.setClassifyFn();
},
editFn(item) {
this.to("HomeAdd", item);
this.setClassifyFn();
},
commentsFn(item) {
// this.to("Record", comments);
this.$router.push({
name: "Record",
query: { id: item.id, title: item.project_title },
});
},
delFn(item) {
let that = this;
this.$confirm({
title: "您确认删除吗?",
onOk() {
that.delApiFn(item);
},
onCancel() {},
okText: "确认",
cancelText: "取消",
});
},
delApiFn(item) {
this.api.project.delete({ id: item.id }).then((res) => {
if (res.id) {
this.$message.success("删除成功");
this.getList();
} else {
this.$message.error("删除失败");
}
});
},
checkGitLog(item) {
if (!item.git_id) {
return this.$message.error("请填写gitlab项目id");
}
// console.log('item: ', item);
this.$router.push({ name: "GitLog", query: { projectId: item.git_id } });
},
//h获取全部的分类
getClassifyList() {
this.api.classify.getList().then((res) => {
console.log(res);
this.classifyData = res;
});
},
//移动项目,选中某个分类
handleSelect(item) {
console.log("item: ", item);
const that = this;
this.$confirm({
title: "您确定要移动项目?",
content: `您确定要移动项目到 ${item.classify} 分类?`,
onOk() {
//编辑
that.api.project.update(item).then((res) => {
// console.log("res: ", res);
if (res.id) {
that.$message.success("移动成功");
//重新获取列表
that.getList();
} else {
that.$message.error("移动失败");
}
});
},
onCancel() {},
okText: "确认",
cancelText: "取消",
});
},
},
};
</script>
<style lang="scss">
.home-project {
padding: 20px;
.ant-list-item {
padding: 10px;
}
.ant-select {
width: 90px !important;
}
}
.ant-list-split .ant-list-item {
transition: all 0.3s;
}
.ant-list-split .ant-list-item:hover {
border-color: rgba(0, 0, 0, 0.09);
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.09);
}
</style>