Commit 1d6056ee by luyt

feat:1.前端文档-后端api添加项目分类,列表,新增,编辑,删除

2.项目数据库project_info添加分类字段,并调整列表,新增,编辑接口,以分类来获取
3.新增项目移动功能-支持移动到类一个分类中
1 parent 5af1d2b9
...@@ -72,6 +72,6 @@ export default { ...@@ -72,6 +72,6 @@ export default {
.wrapper-content { .wrapper-content {
margin: 30px auto; margin: 30px auto;
padding: 0 10px; padding: 0 10px;
max-width: 1200px; max-width: 1300px;
} }
</style> </style>
/*
* @Author: huyue
* @Date: 2021-09-09 16:18:46
* @Last Modified by: huyue
* @Last Modified time: 2021-09-09 16:24:33
*/
import request from "@/plugins/axios";
const classify = {
getList() {
return request({
url: "/classify/getList",
method: "get",
params: {},
});
},
create(data) {
// console.log(data)
return request({
url: "/classify/create",
method: "post",
data,
});
},
update(data) {
// console.log(data)
return request({
url: "/classify/update",
method: "patch",
data,
});
},
delete(data) {
// console.log(data)
return request({
url: "/classify/delete",
method: "patch",
data,
});
},
};
export default classify;
import project from './project'; import project from "./project";
import documentation from './documentation'; import documentation from "./documentation";
import commons from './commons' import commons from "./commons";
import gitLog from './gitLog' import gitLog from "./gitLog";
import classify from "./classify";
export default { export default {
project, project,
documentation, documentation,
commons, commons,
gitLog gitLog,
} classify,
};
/* /*
* @Author: huyue * @Author: huyue
* @Date: 2021-09-06 15:27:21 * @Date: 2021-09-06 15:27:21
* @Last Modified by: huyue * @Last Modified by: huyue
* @Last Modified time: 2021-09-07 10:57:27 * @Last Modified time: 2021-09-07 10:57:27
*/ */
import request from '@/plugins/axios' import request from "@/plugins/axios";
const project = { const project = {
getList() { //按分类查找
getList(classify) {
return request({ return request({
url: '/project/getList', url: "/project/getList",
method: 'get', method: "get",
params: {} params: {
}) classify,
},
});
}, },
create(data) { create(data) {
return request({ return request({
url: '/project/create', url: "/project/create",
method: 'post', method: "post",
data data,
}) });
}, },
update(data) { update(data) {
return request({ return request({
url: '/project/update', url: "/project/update",
method: 'patch', method: "patch",
data data,
}) });
}, },
delete(data) { delete(data) {
return request({ return request({
url: '/project/delete', url: "/project/delete",
method: 'patch', method: "patch",
data data,
}) });
}, },
} };
export default project export default project;
...@@ -91,7 +91,8 @@ export default { ...@@ -91,7 +91,8 @@ export default {
if (valid) { if (valid) {
if (this.isNewAdd) { if (this.isNewAdd) {
//新增 //新增
this.api.documentation.create(this.form).then((res) => { console.log('this.form',this.form)
this.api.classify.create(this.form).then((res) => {
// console.log(res); // console.log(res);
if (res.id) { if (res.id) {
this.$message.success("添加成功"); this.$message.success("添加成功");
...@@ -103,7 +104,7 @@ export default { ...@@ -103,7 +104,7 @@ export default {
}); });
} else { } else {
//编辑 //编辑
this.api.documentation.update(this.form).then((res) => { this.api.classify.update(this.form).then((res) => {
console.log(res); console.log(res);
if (res.id) { if (res.id) {
this.$message.success("编辑成功"); this.$message.success("编辑成功");
......
<template> <template>
<div> <div>
<h2>项目分类</h2> <h2>项目分类</h2>
<a-list :grid="{ gutter: 16, column: 4 }" :data-source="docData"> <a-list :grid="{ gutter: 16, column: 4 }" :data-source="classifyData">
<a-list-item slot="renderItem" slot-scope="item"> <a-list-item slot="renderItem" slot-scope="item">
<a rel="noopener noreferrer" @click="shoClassify(item)"> <a rel="noopener noreferrer" @click="showClassify(item)">
<a-card :title="item.classify_title"> <a-card :title="item.classify_title">
<p>{{ item.classify_description }}</p> <p>{{ item.classify_description }}</p>
<!-- <p v-for="(i, idx) in item.content" :key="i">{{idx + 1}}. {{i}}</p> --> <!-- <p v-for="(i, idx) in item.content" :key="i">{{idx + 1}}. {{i}}</p> -->
...@@ -27,31 +27,43 @@ const data = [ ...@@ -27,31 +27,43 @@ const data = [
classify: "oss-web", classify: "oss-web",
classify_title: "广联赛讯Vue业务模块1", classify_title: "广联赛讯Vue业务模块1",
classify_description: "vue模板介绍与使用", classify_description: "vue模板介绍与使用",
created_at: "",
updated_at: "",
del_flag: "n",
}, },
{ {
id: "2", id: "2",
classify: "micro-service", classify: "micro-service",
classify_title: "广联赛讯Vue业务模块2", classify_title: "广联赛讯Vue业务模块2",
classify_description: "vue模板介绍与使用", classify_description: "vue模板介绍与使用",
created_at: "",
updated_at: "",
del_flag: "n",
}, },
{ {
id: "3", id: "3",
classify: "scrm", classify: "scrm",
classify_title: "广联赛讯Vue业务模块3", classify_title: "广联赛讯Vue业务模块3",
classify_description: "vue模板介绍与使用", classify_description: "vue模板介绍与使用",
created_at: "",
updated_at: "",
del_flag: "n",
}, },
{ {
id: "4", id: "4",
classify: "scrm-mobile", classify: "scrm-mobile",
classify_title: "广联赛讯Vue业务模块4", classify_title: "广联赛讯Vue业务模块4",
classify_description: "vue模板介绍与使用", classify_description: "vue模板介绍与使用",
created_at: "",
updated_at: "",
del_flag: "n",
}, },
]; ];
export default { export default {
name: "folder", name: "folder",
data() { data() {
return { return {
docData: data, classifyData: data,
}; };
}, },
mounted() { mounted() {
...@@ -59,15 +71,15 @@ export default { ...@@ -59,15 +71,15 @@ export default {
}, },
methods: { methods: {
getList() { getList() {
this.api.documentation.getList().then((res) => { this.api.classify.getList().then((res) => {
// console.log(res); // console.log(res);
this.docData = res; this.classifyData = res;
}); });
}, },
add() { add() {
this.to("FolderAdd"); this.to("FolderAdd");
}, },
shoClassify(item) { showClassify(item) {
this.$router.push({ name: "Home", query: { classify: item.classify } }); this.$router.push({ name: "Home", query: { classify: item.classify } });
// if (url) { // if (url) {
// window.open(url, "target"); // window.open(url, "target");
...@@ -92,7 +104,7 @@ export default { ...@@ -92,7 +104,7 @@ export default {
let params = { let params = {
id: item.id, id: item.id,
}; };
const res = await this.api.documentation.delete(params); const res = await this.api.classify.delete(params);
// console.log('res: ', res); // console.log('res: ', res);
if (res.id) { if (res.id) {
this.$message.success("删除成功"); this.$message.success("删除成功");
......
...@@ -103,9 +103,15 @@ export default { ...@@ -103,9 +103,15 @@ export default {
onSubmit() { onSubmit() {
this.$refs.ruleForm.validate((valid) => { this.$refs.ruleForm.validate((valid) => {
if (valid) { if (valid) {
const classify = sessionStorage.getItem("classify");
const pramas = {
...this.form,
classify,
};
if (this.isNewAdd) { if (this.isNewAdd) {
//新增 //新增
this.api.project.create(this.form).then((res) => { this.api.project.create(pramas).then((res) => {
// console.log('res: ', res); // console.log('res: ', res);
if (res.id) { if (res.id) {
this.$message.success("添加成功"); this.$message.success("添加成功");
...@@ -117,7 +123,7 @@ export default { ...@@ -117,7 +123,7 @@ export default {
}); });
} else { } else {
//编辑 //编辑
this.api.project.update(this.form).then((res) => { this.api.project.update(pramas).then((res) => {
// console.log("res: ", res); // console.log("res: ", res);
if (res.id) { if (res.id) {
this.$message.success("编辑成功"); this.$message.success("编辑成功");
......
<template> <template>
<div class="home-project"> <div class="home-project">
<h2>{{ $route.query.classify }} 分类项目</h2>
<a-list item-layout="horizontal" :data-source="projectData"> <a-list item-layout="horizontal" :data-source="projectData">
<a-list-item slot="renderItem" slot-scope="item"> <a-list-item slot="renderItem" slot-scope="item">
<a-list-item-meta> <a-list-item-meta>
...@@ -51,7 +52,6 @@ ...@@ -51,7 +52,6 @@
<a-button type="link" @click="checkGitLog(item)"> <a-button type="link" @click="checkGitLog(item)">
查看git提交信息 查看git提交信息
</a-button> </a-button>
</a-descriptions-item> </a-descriptions-item>
<a-descriptions-item label="git项目ID"> <a-descriptions-item label="git项目ID">
<a-popover title="什么是git ID"> <a-popover title="什么是git ID">
...@@ -59,7 +59,7 @@ ...@@ -59,7 +59,7 @@
<p>1.进入git仓库项目设置</p> <p>1.进入git仓库项目设置</p>
<p>2.查看 Project ID</p> <p>2.查看 Project ID</p>
</template> </template>
{{ item.git_id }} <a-icon type="question" /> {{ item.git_id }} <a-icon type="question" />
</a-popover> </a-popover>
</a-descriptions-item> </a-descriptions-item>
</a-descriptions> </a-descriptions>
...@@ -67,6 +67,22 @@ ...@@ -67,6 +67,22 @@
<a slot="actions" @click="editFn(item)">编辑</a> <a slot="actions" @click="editFn(item)">编辑</a>
<a slot="actions" @click="commentsFn(item)">评论</a> <a slot="actions" @click="commentsFn(item)">评论</a>
<a slot="actions" @click="delFn(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-item>
</a-list> </a-list>
<div class="icon-anticons" @click="add"> <div class="icon-anticons" @click="add">
...@@ -76,30 +92,32 @@ ...@@ -76,30 +92,32 @@
</template> </template>
<script> <script>
const data = [ const data = [
{ // {
id: 1, // id: 1,
project_title: "广联运营平台", // project_title: "广联运营平台",
project_description: "广联运营平台", // project_description: "广联运营平台",
developer_name: "胡悦、陈婉清", // developer_name: "胡悦、陈婉清",
config_name: "/admin_common", // config_name: "/admin_common",
test_url: "http://sso.test.glsx.com.cn/#/login", // test_url: "http://sso.test.glsx.com.cn/#/login",
product_url: "http://sso.glsx.com.cn/#/login", // product_url: "http://sso.glsx.com.cn/#/login",
technology: "vue", // technology: "vue",
git_url:'http://giturl.com/', // git_url: "http://giturl.com/",
git_id:173 // git_id: 173,
}, // classify: "other",
{ // },
id: 2, // {
project_title: "账户管理", // id: 2,
project_description: "商户、角色、员工管理", // project_title: "账户管理",
developer_name: "胡悦、陈婉清", // project_description: "商户、角色、员工管理",
config_name: "/glsx-oss-account-config", // developer_name: "胡悦、陈婉清",
test_url: "http://glsx-account-merchants.test.glsx.com.cn", // config_name: "/glsx-oss-account-config",
product_url: "http://glsx-account.glsx.com.cn", // test_url: "http://glsx-account-merchants.test.glsx.com.cn",
technology: "vue", // product_url: "http://glsx-account.glsx.com.cn",
git_url:'http://giturl.com/', // technology: "vue",
git_id:173 // git_url: "http://giturl.com/",
}, // git_id: 173,
// classify: "other",
// },
]; ];
import projectImgUrl from "@/assets/project.jpg"; import projectImgUrl from "@/assets/project.jpg";
export default { export default {
...@@ -108,23 +126,34 @@ export default { ...@@ -108,23 +126,34 @@ export default {
return { return {
projectData: data, projectData: data,
projectImgUrl, projectImgUrl,
classifyData: [],
// selectClassify: "", //选中的分类
}; };
}, },
mounted() { mounted() {
this.getList(); this.getList();
this.getClassifyList();
}, },
methods: { methods: {
getList() { getList() {
this.api.project.getList().then((res) => { const classify = this.$route.query.classify;
this.api.project.getList(classify).then((res) => {
// console.log(res); // console.log(res);
this.projectData = res; this.projectData = res;
}); });
}, },
//设置 项目分类
setClassifyFn() {
const classify = this.$route.query.classify;
sessionStorage.setItem("classify", classify);
},
add() { add() {
this.to("HomeAdd"); this.to("HomeAdd");
this.setClassifyFn();
}, },
editFn(item) { editFn(item) {
this.to("HomeAdd", item); this.to("HomeAdd", item);
this.setClassifyFn();
}, },
commentsFn(item) { commentsFn(item) {
// this.to("Record", comments); // this.to("Record", comments);
...@@ -155,13 +184,45 @@ export default { ...@@ -155,13 +184,45 @@ export default {
} }
}); });
}, },
checkGitLog(item){ checkGitLog(item) {
if(!item.git_id){ if (!item.git_id) {
return this.$message.error("请填写gitlab项目id"); return this.$message.error("请填写gitlab项目id");
} }
// console.log('item: ', item); // console.log('item: ', item);
this.$router.push({name:'GitLog',query:{projectId:item.git_id}}) 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> </script>
...@@ -171,12 +232,15 @@ export default { ...@@ -171,12 +232,15 @@ export default {
.ant-list-item { .ant-list-item {
padding: 10px; padding: 10px;
} }
.ant-select {
width: 90px !important;
}
} }
.ant-list-split .ant-list-item { .ant-list-split .ant-list-item {
transition: all 0.3s; transition: all 0.3s;
} }
.ant-list-split .ant-list-item:hover { .ant-list-split .ant-list-item:hover {
border-color: rgba(0, 0, 0, 0.09); border-color: rgba(0, 0, 0, 0.09);
box-shadow: 0 2px 8px rgba(0, 0, 0,0.09); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.09);
} }
</style> </style>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!