Commit 55045274 by luyt

add;项目文档描述api 编辑删除新增

     问题记录新增查询 联调
     项目主页新增编辑评论删除 联调
1 parent a6f9c092
import request from '@/plugins/axios'
const commons = {
getList(id) {
return request({
url: '/commons/getList',
method: 'get',
params: {
project_id:id
}
})
},
create(data) {
return request({
url: '/commons/create',
method: 'post',
data
})
},
}
export default commons
\ No newline at end of file \ No newline at end of file
...@@ -16,13 +16,29 @@ const documentation = { ...@@ -16,13 +16,29 @@ const documentation = {
}) })
}, },
create(data) { create(data) {
console.log(data) // console.log(data)
return request({ return request({
url: '/documentation/create', url: '/documentation/create',
method: 'post', method: 'post',
data data
}) })
} },
update(data) {
// console.log(data)
return request({
url: '/documentation/update',
method: 'patch',
data
})
},
delete(data) {
// console.log(data)
return request({
url: '/documentation/delete',
method: 'patch',
data
})
},
} }
export default documentation export default documentation
import project from './project'; import project from './project';
import documentation from './documentation'; import documentation from './documentation';
import commons from './commons'
export default { export default {
project, project,
documentation documentation,
commons
} }
...@@ -14,7 +14,28 @@ const project = { ...@@ -14,7 +14,28 @@ const project = {
method: 'get', method: 'get',
params: {} params: {}
}) })
} },
create(data) {
return request({
url: '/project/create',
method: 'post',
data
})
},
update(data) {
return request({
url: '/project/update',
method: 'patch',
data
})
},
delete(data) {
return request({
url: '/project/delete',
method: 'patch',
data
})
},
} }
export default project export default project
...@@ -5,7 +5,7 @@ import 'ant-design-vue/dist/antd.css'; ...@@ -5,7 +5,7 @@ import 'ant-design-vue/dist/antd.css';
import '@/assets/css/common.css' import '@/assets/css/common.css'
// 全局引入按需引入UI库 vant // 全局引入按需引入UI库 vant
import { components } from '@/plugins/ant' import { components } from '@/plugins/ant'
import { message } from "ant-design-vue"; import { message,Modal } from "ant-design-vue";
import api from './api' import api from './api'
import PubSub from 'pubsub-js' import PubSub from 'pubsub-js'
...@@ -21,6 +21,7 @@ Vue.prototype.to = function (name, params) { ...@@ -21,6 +21,7 @@ Vue.prototype.to = function (name, params) {
router.push({ name, params}) router.push({ name, params})
} }
Vue.prototype.$message = message Vue.prototype.$message = message
Vue.prototype.$confirm = Modal.confirm
Vue.prototype.$PubSub = PubSub Vue.prototype.$PubSub = PubSub
new Vue({ new Vue({
render: h => h(App), render: h => h(App),
......
...@@ -7,9 +7,10 @@ ...@@ -7,9 +7,10 @@
import axios from 'axios' import axios from 'axios'
import { message } from "ant-design-vue"; import { message } from "ant-design-vue";
let url = process.env.NODE_ENV == "development" ? "/api" : "http://192.168.2.9:7001" // let url = process.env.NODE_ENV == "development" ? "/api" : "http://glsk-front-node.test.glsx.com.cn"
let url = process.env.NODE_ENV == "development" ? "http://192.168.2.24:7001" : "http://192.168.3.182:7001"
const service = axios.create({ const service = axios.create({
withCredentials: true, withCredentials: false,
baseURL: url baseURL: url
}) })
// 添加请求拦截器 // 添加请求拦截器
......
...@@ -8,28 +8,20 @@ ...@@ -8,28 +8,20 @@
:wrapper-col="wrapperCol" :wrapper-col="wrapperCol"
> >
<a-form-model-item label="文档标题" prop="docTitle"> <a-form-model-item label="文档标题" prop="docTitle">
<a-input <a-input v-model="form.docTitle" />
v-model="form.docTitle"
/>
</a-form-model-item> </a-form-model-item>
<a-form-model-item label="文档地址" prop="docUrl"> <a-form-model-item label="文档地址" prop="docUrl">
<a-input <a-input v-model="form.docUrl" />
v-model="form.docUrl"
/>
</a-form-model-item> </a-form-model-item>
<a-form-model-item label="文档描述" prop="docDescription"> <a-form-model-item label="文档描述" prop="docDescription">
<a-input v-model="form.docDescription" type="textarea" /> <a-input v-model="form.docDescription" type="textarea" />
</a-form-model-item> </a-form-model-item>
<a-form-model-item :wrapper-col="{ span: 14, offset: 4 }"> <a-form-model-item :wrapper-col="{ span: 14, offset: 4 }">
<a-button type="primary" @click="onSubmit"> <a-button type="primary" @click="onSubmit"
创建 >{{ isNewAdd ? "创建" : "提交" }}
</a-button>
<a-button style="margin-left: 10px;" @click="resetForm">
重置
</a-button>
<a-button style="margin-left: 10px;" @click="closeForm">
关闭
</a-button> </a-button>
<a-button style="margin-left: 10px" @click="resetForm"> 重置 </a-button>
<a-button style="margin-left: 10px" @click="closeForm"> 关闭 </a-button>
</a-form-model-item> </a-form-model-item>
</a-form-model> </a-form-model>
</div> </div>
...@@ -37,51 +29,94 @@ ...@@ -37,51 +29,94 @@
<script type="text/ecmascript-6"> <script type="text/ecmascript-6">
export default { export default {
name: '', name: "",
data () { data() {
return { return {
isNewAdd: true,
labelCol: { span: 4 }, labelCol: { span: 4 },
wrapperCol: { span: 14 }, wrapperCol: { span: 14 },
form: { form: {
docTitle: '', docTitle: "",
docUrl: '', docUrl: "",
docDescription: '', docDescription: "",
}, },
rules: { rules: {
docTitle: [ docTitle: [
{ required: true, message: '请输入文档名称', trigger: 'blur' }, { required: true, message: "请输入文档名称", trigger: "blur" },
{ min: 1, max: 30, message: '请输入字符1~50之间', trigger: 'blur' }, { min: 1, max: 30, message: "请输入字符1~50之间", trigger: "blur" },
],
docUrl: [
{ required: true, message: "请输入文档地址", trigger: "blur" },
],
docDescription: [
{ required: true, message: "请输入文档描述", trigger: "blur" },
], ],
docUrl: [{ required: true, message: '请输入文档地址', trigger: 'blur' }],
docDescription: [{ required: true, message: '请输入文档描述', trigger: 'blur' }],
}, },
} };
}, },
mounted () { mounted() {
this.editeItemFn();
}, },
methods: { methods: {
onSubmit() { onSubmit() {
this.$refs.ruleForm.validate(valid => { this.$refs.ruleForm.validate((valid) => {
if (valid) { if (valid) {
console.log(this.form) if (this.isNewAdd) {
this.api.documentation.create(this.form).then(res => { //新增
console.log(res) this.api.documentation.create(this.form).then((res) => {
this.$message.success('添加成功') // console.log(res);
this.closeForm() if (res.id) {
}) this.$message.success("添加成功");
this.closeForm();
this.resetForm();
} else {
this.$message.error("添加失败");
}
});
} else {
//编辑
this.api.documentation.update(this.form).then((res) => {
console.log(res);
if (res.id) {
this.$message.success("编辑成功");
this.closeForm();
this.resetForm();
} else {
this.$message.error("编辑失败");
}
});
}
} else { } else {
return false; return false;
} }
}); });
}, },
resetForm() { resetForm() {
this.isNewAdd = true;
this.$refs.ruleForm.resetFields(); this.$refs.ruleForm.resetFields();
}, },
closeForm() { closeForm() {
this.to(-1) this.to(-1);
} },
} //编辑项目
} editeItemFn() {
const editeItem = this.$route.params;
console.log('editeItem: ', editeItem);
if (Object.keys(editeItem).length === 0) return;
this.isNewAdd = false;
this.form = {
docTitle: editeItem.doc_title,
docUrl: editeItem.doc_url,
docDescription: editeItem.doc_description,
id: editeItem.id,
};
},
},
// 重置
beforeDestroy() {
this.resetForm();
},
};
</script> </script>
<style scoped lang="scss"></style> <style scoped lang="scss"></style>
...@@ -3,10 +3,14 @@ ...@@ -3,10 +3,14 @@
<h2>前端开发文档</h2> <h2>前端开发文档</h2>
<a-list :grid="{ gutter: 16, column: 4 }" :data-source="docData"> <a-list :grid="{ gutter: 16, column: 4 }" :data-source="docData">
<a-list-item slot="renderItem" slot-scope="item"> <a-list-item slot="renderItem" slot-scope="item">
<a :href="item.doc_url" target="_blank" rel="noopener noreferrer"> <a rel="noopener noreferrer" @click="showDocument(item.doc_url)">
<a-card :title="item.doc_title"> <a-card :title="item.doc_title">
<p>{{ item.doc_description }}</p> <p>{{ item.doc_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> -->
<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-card>
</a> </a>
</a-list-item> </a-list-item>
...@@ -57,13 +61,46 @@ export default { ...@@ -57,13 +61,46 @@ export default {
methods: { methods: {
getList() { getList() {
this.api.documentation.getList().then((res) => { this.api.documentation.getList().then((res) => {
console.log(res); // console.log(res);
this.docData = res; this.docData = res;
}); });
}, },
add() { add() {
this.to("DocAdd"); this.to("DocAdd");
}, },
showDocument(url) {
if (url) {
window.open(url, "target");
}
},
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> </script>
......
...@@ -29,7 +29,9 @@ ...@@ -29,7 +29,9 @@
<a-input v-model="form.project_description" type="textarea" /> <a-input v-model="form.project_description" type="textarea" />
</a-form-model-item> </a-form-model-item>
<a-form-model-item :wrapper-col="{ span: 14, offset: 4 }"> <a-form-model-item :wrapper-col="{ span: 14, offset: 4 }">
<a-button type="primary" @click="onSubmit"> 创建 </a-button> <a-button type="primary" @click="onSubmit">{{
isNewAdd ? "创建" : "提交"
}}</a-button>
<a-button style="margin-left: 10px" @click="resetForm"> 重置 </a-button> <a-button style="margin-left: 10px" @click="resetForm"> 重置 </a-button>
<a-button style="margin-left: 10px" @click="closeForm"> 关闭 </a-button> <a-button style="margin-left: 10px" @click="closeForm"> 关闭 </a-button>
</a-form-model-item> </a-form-model-item>
...@@ -37,11 +39,12 @@ ...@@ -37,11 +39,12 @@
</div> </div>
</template> </template>
<script type="text/ecmascript-6"> <script>
export default { export default {
name: "", name: "",
data() { data() {
return { return {
isNewAdd: true,
labelCol: { span: 4 }, labelCol: { span: 4 },
wrapperCol: { span: 14 }, wrapperCol: { span: 14 },
form: { form: {
...@@ -86,22 +89,42 @@ export default { ...@@ -86,22 +89,42 @@ export default {
onSubmit() { onSubmit() {
this.$refs.ruleForm.validate((valid) => { this.$refs.ruleForm.validate((valid) => {
if (valid) { if (valid) {
console.log(this.form); if (this.isNewAdd) {
// this.api.documentation.create(this.form).then((res) => { //新增
// console.log(res); this.api.project.create(this.form).then((res) => {
// this.$message.success("添加成功"); // console.log('res: ', res);
// this.closeForm(); if (res.id) {
// }); this.$message.success("添加成功");
this.closeForm();
this.resetData();
} else {
this.$message.error("添加失败");
}
});
} else {
//编辑
this.api.project.update(this.form).then((res) => {
// console.log("res: ", res);
if (res.id) {
this.$message.success("编辑成功");
this.closeForm();
this.resetData();
} else {
this.$message.error("编辑失败");
}
});
}
} else { } else {
return false; return false;
} }
}); });
}, },
resetForm() { resetForm() {
this.isNewAdd = true;
this.$refs.ruleForm.resetFields(); this.$refs.ruleForm.resetFields();
this.resetDate(); // this.resetData();
}, },
resetDate() { resetData() {
this.form = { this.form = {
project_title: "", project_title: "",
project_description: "", project_description: "",
...@@ -118,12 +141,17 @@ export default { ...@@ -118,12 +141,17 @@ export default {
//编辑项目 //编辑项目
editeItemFn() { editeItemFn() {
const editeItem = this.$route.params; const editeItem = this.$route.params;
if (!editeItem) return; if ( Object.keys(editeItem).length === 0) return;
this.isNewAdd = false;
this.form = { this.form = {
...editeItem, ...editeItem,
}; };
}, },
}, },
// 重置
beforeDestroy() {
this.resetForm();
},
}; };
</script> </script>
......
...@@ -2,41 +2,42 @@ ...@@ -2,41 +2,42 @@
<div> <div>
<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>
<!-- <a slot="title" href="https://www.antdv.com/">{{ item.title }}</a> --> <!-- <a slot="title" href="https://www.antdv.com/">{{ item.title }}</a> -->
<a-avatar slot="avatar" :src="projectImgUrl" /> <a-avatar slot="avatar" :src="projectImgUrl" />
</a-list-item-meta> </a-list-item-meta>
<div> <div>
<a-descriptions :title="item.project_title" :bordered="false"> <a-descriptions :title="item.project_title" :bordered="false">
<a-descriptions-item label="开发人员"> <a-descriptions-item label="开发人员">
{{ item.developer_name }} {{ item.developer_name }}
</a-descriptions-item> </a-descriptions-item>
<a-descriptions-item label="测试项目地址"> <a-descriptions-item label="测试项目地址">
<a <a
:href="item.test_url" :href="item.test_url"
target="_blank" target="_blank"
rel="noopener noreferrer" rel="noopener noreferrer"
>{{ item.test_url }}</a >{{ item.test_url }}</a
> >
</a-descriptions-item> </a-descriptions-item>
<a-descriptions-item label="上产项目地址"> <a-descriptions-item label="上产项目地址">
<a <a
:href="item.test_url" :href="item.test_url"
target="_blank" target="_blank"
rel="noopener noreferrer" rel="noopener noreferrer"
>{{ item.product_url }}</a >{{ item.product_url }}</a
> >
</a-descriptions-item> </a-descriptions-item>
<a-descriptions-item label="使用技术"> <a-descriptions-item label="使用技术">
{{ item.technology }} {{ item.technology }}
</a-descriptions-item> </a-descriptions-item>
<a-descriptions-item label="配置名称"> <a-descriptions-item label="配置名称">
{{ item.config_name }} {{ item.config_name }}
</a-descriptions-item> </a-descriptions-item>
</a-descriptions> </a-descriptions>
</div> </div>
<a slot="actions" @click="editFn(item)">edit</a> <a slot="actions" @click="editFn(item)">编辑</a>
<a slot="actions" @click="commentsFn(item.comments)">comments</a> <a slot="actions" @click="commentsFn(item)">评论</a>
<a slot="actions" @click="delFn(item)">删除</a>
</a-list-item> </a-list-item>
</a-list> </a-list>
<div class="icon-anticons" @click="add"> <div class="icon-anticons" @click="add">
...@@ -90,21 +91,46 @@ export default { ...@@ -90,21 +91,46 @@ export default {
this.to("HomeAdd"); this.to("HomeAdd");
}, },
editFn(item) { editFn(item) {
console.log("item: ", item);
this.to("HomeAdd", item); this.to("HomeAdd", item);
}, },
commentsFn(comments) { commentsFn(item) {
this.to("Record", comments); // 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("删除失败");
}
});
}, },
}, },
}; };
</script> </script>
<style> <style>
.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 rgb(0 0 0 / 9%); box-shadow: 0 2px 8px rgb(0 0 0 / 9%);
} }
.ant-list-item {
padding: 10px;
}
</style> </style>
<template> <template>
<div> <div>
<div class="ant-result-title">项目名称</div> <div class="ant-result-title">项目名称:{{title}}</div>
<a-list <a-list
v-if="comments.length" v-if="comments.length"
:data-source="comments" :data-source="comments"
...@@ -11,10 +11,14 @@ ...@@ -11,10 +11,14 @@
> >
<a-list-item slot="renderItem" slot-scope="item"> <a-list-item slot="renderItem" slot-scope="item">
<a-comment <a-comment
:author="item.author" :author="item.author ? item.author : 'Some One'"
:avatar="item.avatar" :avatar="
item.avatar
? item.avatar
: 'https://zos.alipayobjects.com/rmsportal/ODTLcjxAfvqbxHnVXCYX.png'
"
:content="item.content" :content="item.content"
:datetime="item.datetime" :datetime="moment(item.create_at).fromNow()"
/> />
</a-list-item> </a-list-item>
</a-list> </a-list>
...@@ -52,35 +56,59 @@ export default { ...@@ -52,35 +56,59 @@ export default {
submitting: false, submitting: false,
value: "", value: "",
moment, moment,
projectId: "",
title: "",
}; };
}, },
components: { [FormItem.name]: FormItem }, components: { [FormItem.name]: FormItem },
mounted() {
this.getProjectId();
},
methods: { methods: {
handleSubmit() { handleSubmit() {
if (!this.value) { if (!this.value) {
return; return;
} }
this.submitting = true; this.submitting = true;
setTimeout(() => { //创建评论
this.submitting = false; let params = {
this.comments = [ // user_id:'',
{ // create_at:''
author: "Han Solo", project_id: this.$route.query.id,
avatar: content: this.value,
"https://zos.alipayobjects.com/rmsportal/ODTLcjxAfvqbxHnVXCYX.png", };
content: this.value, this.api.commons
datetime: moment().fromNow(), .create(params)
}, .then((res) => {
...this.comments, // console.log("res: ", res);
]; if (res.id) {
this.value = ""; this.$message.success("评论成功");
}, 1000); this.value = "";
this.submitting = false;
this.getProjectId();
} else {
this.$message.error("评论失败");
}
})
.catch(() => {
this.$message.error("评论失败");
});
}, },
handleChange(e) { handleChange(e) {
this.value = e.target.value; this.value = e.target.value;
}, },
getProjectId() {
const projectId = this.$route.query.id;
this.title = this.$route.query.title;
if (!projectId) return;
this.getComments(projectId);
},
async getComments(id) {
const res = await this.api.commons.getList(id);
if (res.length === 0) return;
this.comments = res;
},
}, },
}; };
</script> </script>
......
module.exports = { module.exports = {
devServer: { // devServer: {
port: 8080, // 端口 // port: 8080, // 端口
proxy: { // proxy: {
//配置跨域 // //配置跨域
"/api": { // "/api": {
target: "http://192.168.2.24:7001", // target: "http://192.168.2.24:7001",
// ws:true, // // ws:true,
changOrigin: true, // changOrigin: true,
pathRewrite: { // pathRewrite: {
"^/api": "/" // "^/api": "/"
} // }
} // }
} // }
} // }
}; };
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!