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