Commit f684eba7 by zhangxw

文档添加分类,跳转参数params 改成query 防止刷新丢失

1 parent b0e485a3
This diff could not be displayed because it is too large.
...@@ -3,15 +3,18 @@ ...@@ -3,15 +3,18 @@
<div class="wrapper-header"> <div class="wrapper-header">
<img class="logo" src="./assets/logo.png" alt="" /> <img class="logo" src="./assets/logo.png" alt="" />
<a-menu v-model="current" mode="horizontal"> <a-menu v-model="current" mode="horizontal">
<a-menu-item key="folder" @click="handleTab('Folder')" <a-menu-item key="folder" @click="handleTab('Folder')">
><a-icon type="home" />项目主页</a-menu-item <a-icon type="home" />
> 项目主页
<a-menu-item key="documentation" @click="handleTab('Documentation')" </a-menu-item>
><a-icon type="file-text" />项目文档描述</a-menu-item <a-menu-item key="DocumentClassify" @click="handleTab('DocumentClassify')">
> <a-icon type="file-text" />
<a-menu-item key="record" @click="handleTab('Record')" 项目文档描述
><a-icon type="message" />问题记录</a-menu-item </a-menu-item>
> <a-menu-item key="record" @click="handleTab('Record')">
<a-icon type="message" />
问题记录
</a-menu-item>
</a-menu> </a-menu>
</div> </div>
<div class="wrapper-content"> <div class="wrapper-content">
...@@ -21,32 +24,39 @@ ...@@ -21,32 +24,39 @@
</template> </template>
<script> <script>
let currentName = ""; let currentName = ''
export default { export default {
name: "App", name: 'App',
data() { data() {
return { return {
current: ["folder"], current: ['folder']
}; }
}, },
mounted() { mounted() {
currentName = window.location.pathname.substr(1); currentName = window.location.pathname.substr(1)
console.log(currentName); console.log(currentName)
if (!currentName) this.current = ["folder"]; if (!currentName) this.current = ['folder']
else this.current = [currentName]; else this.current = [currentName]
}, },
methods: { methods: {
handleTab(name) { handleTab(name) {
this.to(name); this.to(name)
}, }
}, }
}; }
</script> </script>
<style> <style lang="scss">
#app {
display: flex;
flex-flow: column;
height: 100vh;
overflow: hidden;
}
.wrapper-header { .wrapper-header {
display: flex; display: flex;
background-color: #2b303b; background-color: #2b303b;
height: 50px;
} }
.wrapper-header .logo { .wrapper-header .logo {
display: inline-flex; display: inline-flex;
...@@ -70,8 +80,13 @@ export default { ...@@ -70,8 +80,13 @@ export default {
color: #fff; color: #fff;
} }
.wrapper-content { .wrapper-content {
overflow-y: auto;
margin: 30px auto; margin: 30px auto;
padding: 0 10px; padding: 0 10px;
width: 100%;
& > div {
max-width: 1300px; max-width: 1300px;
margin: 0 auto;
}
} }
</style> </style>
import request from '@/plugins/axios'
const documentClassify = {
getList() {
return request({
url: '/docClassify/getList',
method: 'get',
params: {}
})
},
create(data) {
// console.log(data)
return request({
url: '/docClassify/create',
method: 'post',
data
})
},
update(data) {
// console.log(data)
return request({
url: '/docClassify/update',
method: 'patch',
data
})
},
delete(data) {
// console.log(data)
return request({
url: '/docClassify/delete',
method: 'patch',
data
})
},
}
export default documentClassify
...@@ -8,9 +8,9 @@ ...@@ -8,9 +8,9 @@
import request from '@/plugins/axios' import request from '@/plugins/axios'
const documentation = { const documentation = {
getList() { getList(id) {
return request({ return request({
url: '/documentation/getList', url: `/documentation/getList?classifyId=${id}`,
method: 'get', method: 'get',
params: {} params: {}
}) })
......
import project from "./project"; import project from "./project";
import documentation from "./documentation"; import documentation from "./documentation";
import documentClassify from "./documentClassify";
import commons from "./commons"; import commons from "./commons";
import gitLog from "./gitLog"; import gitLog from "./gitLog";
import classify from "./classify"; import classify from "./classify";
...@@ -7,6 +8,7 @@ import classify from "./classify"; ...@@ -7,6 +8,7 @@ import classify from "./classify";
export default { export default {
project, project,
documentation, documentation,
documentClassify,
commons, commons,
gitLog, gitLog,
classify, classify,
......
...@@ -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,Modal } 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'
...@@ -13,12 +13,12 @@ Vue.config.productionTip = false; ...@@ -13,12 +13,12 @@ Vue.config.productionTip = false;
components.forEach(component => Vue.use(component)) components.forEach(component => Vue.use(component))
Vue.prototype.api = api Vue.prototype.api = api
Vue.prototype.to = function (name, params) { Vue.prototype.to = function (name, query) {
if (name === -1) { if (name === -1) {
router.go(-1) router.go(-1)
return return
} }
router.push({ name, params}) router.push({ name, query })
} }
Vue.prototype.$message = message Vue.prototype.$message = message
Vue.prototype.$confirm = Modal.confirm Vue.prototype.$confirm = Modal.confirm
......
...@@ -30,6 +30,18 @@ const routes = Object.freeze([ ...@@ -30,6 +30,18 @@ const routes = Object.freeze([
component: (resolve) => require(["../views/home/add/index.vue"], resolve), component: (resolve) => require(["../views/home/add/index.vue"], resolve),
}, },
{ {
name: "DocumentClassify",
path: "/documentClassify",
component: (resolve) =>
require(["../views/documentation/documentClassify.vue"], resolve),
},
{
name: "DocClassifyAdd",
path: "/documentClassify/add",
component: (resolve) =>
require(["../views/documentation/addClassify/index.vue"], resolve),
},
{
name: "Documentation", name: "Documentation",
path: "/documentation", path: "/documentation",
component: (resolve) => component: (resolve) =>
......
<template> <template>
<div> <div>
<a-form-model <a-form-model ref="ruleForm" :model="form" :rules="rules" :label-col="labelCol" :wrapper-col="wrapperCol">
ref="ruleForm"
:model="form"
:rules="rules"
:label-col="labelCol"
:wrapper-col="wrapperCol"
>
<a-form-model-item label="文档标题" prop="docTitle"> <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>
...@@ -17,11 +11,9 @@ ...@@ -17,11 +11,9 @@
<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>
>{{ isNewAdd ? "创建" : "提交" }} <a-button style="margin-left: 10px" @click="resetForm">重置</a-button>
</a-button> <a-button style="margin-left: 10px" @click="closeForm">关闭</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>
...@@ -29,94 +21,91 @@ ...@@ -29,94 +21,91 @@
<script type="text/ecmascript-6"> <script type="text/ecmascript-6">
export default { export default {
name: "", name: '',
data() { data() {
return { return {
isNewAdd: true, 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: [ docUrl: [{ required: true, message: '请输入文档地址', trigger: 'blur' }],
{ required: true, message: "请输入文档地址", trigger: "blur" }, docDescription: [{ required: true, message: '请输入文档描述', trigger: 'blur' }]
], }
docDescription: [ }
{ required: true, message: "请输入文档描述", trigger: "blur" },
],
},
};
}, },
mounted() { mounted() {
this.editeItemFn(); this.editeItemFn()
}, },
methods: { methods: {
onSubmit() { onSubmit() {
this.$refs.ruleForm.validate((valid) => { this.$refs.ruleForm.validate(valid => {
if (valid) { if (valid) {
if (this.isNewAdd) { if (this.isNewAdd) {
//新增 //新增
this.api.documentation.create(this.form).then((res) => { this.api.documentation.create(this.form).then(res => {
// console.log(res); // console.log(res);
if (res.id) { if (res.id) {
this.$message.success("添加成功"); this.$message.success('添加成功')
this.closeForm(); this.closeForm()
this.resetForm(); this.resetForm()
} else { } else {
this.$message.error("添加失败"); this.$message.error('添加失败')
} }
}); })
} else { } else {
//编辑 //编辑
this.api.documentation.update(this.form).then((res) => { this.api.documentation.update(this.form).then(res => {
console.log(res); console.log(res)
if (res.id) { if (res.id) {
this.$message.success("编辑成功"); this.$message.success('编辑成功')
this.closeForm(); this.closeForm()
this.resetForm(); this.resetForm()
} else { } else {
this.$message.error("编辑失败"); this.$message.error('编辑失败')
} }
}); })
} }
} else { } else {
return false; return false
} }
}); })
}, },
resetForm() { resetForm() {
this.isNewAdd = true; this.isNewAdd = true
this.$refs.ruleForm.resetFields(); this.$refs.ruleForm.resetFields()
}, },
closeForm() { closeForm() {
this.to(-1); this.to(-1)
}, },
//编辑项目 //编辑项目
editeItemFn() { editeItemFn() {
const editeItem = this.$route.params; const editeItem = this.$route.query
console.log('editeItem: ', editeItem); console.log('editeItem: ', editeItem)
if (Object.keys(editeItem).length === 0) return; if (Object.keys(editeItem).length === 0) return
this.isNewAdd = false; this.isNewAdd = false
this.form = { this.form = {
docTitle: editeItem.doc_title, docTitle: editeItem.doc_title,
docUrl: editeItem.doc_url, docUrl: editeItem.doc_url,
docDescription: editeItem.doc_description, docDescription: editeItem.doc_description,
id: editeItem.id, id: editeItem.id,
}; classify_id: editeItem.classify_id
}, }
}
}, },
// 重置 // 重置
beforeDestroy() { beforeDestroy() {
this.resetForm(); this.resetForm()
}, }
}; }
</script> </script>
<style scoped lang="scss"></style> <style scoped lang="scss"></style>
<template>
<div>
<a-form-model ref="ruleForm" :model="form" :rules="rules" :label-col="labelCol" :wrapper-col="wrapperCol">
<a-form-model-item label="文档分类标题" prop="title">
<a-input v-model="form.title" />
</a-form-model-item>
<a-form-model-item label="文档分类描述" prop="description">
<a-input v-model="form.description" type="textarea" />
</a-form-model-item>
<a-form-model-item :wrapper-col="{ span: 14, offset: 4 }">
<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>
</template>
<script type="text/ecmascript-6">
export default {
name: '',
data() {
return {
isNewAdd: true,
labelCol: { span: 4 },
wrapperCol: { span: 14 },
form: {
docTitle: '',
docUrl: '',
docDescription: ''
},
rules: {
title: [
{ required: true, message: '请输入文档分类名称', trigger: 'blur' },
{ min: 1, max: 30, message: '请输入字符1~50之间', trigger: 'blur' }
],
description: [{ required: true, message: '请输入文档分类描述', trigger: 'blur' }]
}
}
},
mounted() {
this.editeItemFn()
},
methods: {
onSubmit() {
this.$refs.ruleForm.validate(valid => {
if (valid) {
if (this.isNewAdd) {
//新增
this.api.documentClassify.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.documentClassify.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)
},
//编辑项目
editeItemFn() {
const editeItem = this.$route.query
console.log('editeItem: ', editeItem)
if (Object.keys(editeItem).length === 0) return
this.isNewAdd = false
this.form = {
title: editeItem.title,
description: editeItem.description,
id: editeItem.id
}
}
},
// 重置
beforeDestroy() {
this.resetForm()
}
}
</script>
<style scoped lang="scss"></style>
<template>
<div>
<h2>前端开发文档分类</h2>
<a-list :grid="{ gutter: 16, column: 4 }" :data-source="docData">
<a-list-item slot="renderItem" slot-scope="item">
<a rel="noopener noreferrer" @click="showDocumentList(item)">
<a-card :title="item.title">
<p class="white_space" :title="item.description">{{ item.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>
</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
}
},
mounted() {
this.getList()
},
methods: {
getList() {
this.api.documentClassify.getList().then(res => {
// console.log(res);
this.docData = res
})
},
// 添加项目文档分类
add() {
this.to('DocClassifyAdd')
},
showDocumentList(item) {
if (item) {
this.$router.push({ name: 'Documentation', query: { id: item.id, title: item.title } })
}
},
editFn(item) {
this.to('DocClassifyAdd', 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.documentClassify.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>
<template> <template>
<div> <div>
<h2>前端开发文档</h2> <h2>{{ listItem.title }}</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 rel="noopener noreferrer" @click="showDocument(item.doc_url)"> <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 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> --> <!-- <p v-for="(i, idx) in item.content" :key="i">{{idx + 1}}. {{i}}</p> -->
<template slot="actions" class="ant-card-actions"> <template slot="actions">
<a-icon key="edit" type="edit" @click.stop="editFn(item)" /> <a-icon key="edit" type="edit" @click.stop="editFn(item)" />
<a-icon key="delete" type="delete" @click.stop="deleteFn(item)" /> <a-icon key="delete" type="delete" @click.stop="deleteFn(item)" />
<span @click.stop>
<a-select size="small" v-model="item.classify_id" @select="handleSelect(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> </template>
</a-card> </a-card>
</a> </a>
...@@ -21,88 +29,102 @@ ...@@ -21,88 +29,102 @@
</div> </div>
</template> </template>
<script> <script>
const data = [ const data = []
{
doc_title: "广联赛讯Vue模板及组件",
doc_description: "vue模板介绍与使用",
doc_url: "http://192.168.3.171:8080/#/installNode",
},
{
doc_title: "glsx-vue-common使用文档",
doc_description: "介绍使用方法;内置方法介绍",
doc_url: "http://192.168.3.171:8089/",
},
{
doc_title: "easy mock 地址",
doc_description: "通用配置",
doc_url: "https://oss-config.test.glsx.com.cn",
},
{
doc_title: "公司git仓库",
doc_description: "公司git仓库地址(使用svn账号)",
doc_url: "http://192.168.3.233:8090",
},
{
doc_title: "上线发版OPS",
doc_description: "公司上线发版地址",
doc_url: "http://192.168.3.233:8888/login",
},
];
export default { export default {
name: "Developers", name: 'Developers',
data() { data() {
return { return {
docData: data, docData: data,
}; classifyData: [],
listItem: this.$route.query
}
}, },
mounted() { mounted() {
this.getList(); this.getList()
this.getClassifyList()
}, },
methods: { methods: {
//获取全部的分类
getClassifyList() {
this.api.documentClassify.getList().then(res => {
this.classifyData = res
})
},
//移动文档,选中某个分类
handleSelect(item) {
console.log('item: ', item)
let classifyTitle = this.classifyData.filter(val => val.id == item.classify_id)[0].title
const that = this
this.$confirm({
title: '您确定要移动项目文档?',
content: `您确定要移动项目文档到 ${classifyTitle} 分类?`,
onOk() {
//编辑
that.api.documentation.update(item).then(res => {
// console.log("res: ", res);
if (res.id) {
that.$message.success('移动成功')
//重新获取列表
that.getList()
} else {
that.$message.error('移动失败')
}
})
},
onCancel() {},
okText: '确认',
cancelText: '取消'
})
},
getList() { getList() {
this.api.documentation.getList().then((res) => { this.api.documentation.getList(this.listItem.id).then(res => {
// console.log(res); // console.log(res);
this.docData = res; this.docData = res
}); })
}, },
add() { add() {
this.to("DocAdd"); this.to('DocAdd')
}, },
showDocument(url) { showDocument(url) {
if (url) { if (url) {
window.open(url, "target"); window.open(url)
} }
}, },
editFn(item) { editFn(item) {
this.to("DocAdd", item); this.to('DocAdd', item)
}, },
deleteFn(item) { deleteFn(item) {
let that = this; let that = this
this.$confirm({ this.$confirm({
title: "您确认删除吗?", title: '您确认删除吗?',
onOk() { onOk() {
that.deleteApiFn(item); that.deleteApiFn(item)
}, },
onCancel() {}, onCancel() {},
okText: "确认", okText: '确认',
cancelText: "取消", cancelText: '取消'
}); })
}, },
async deleteApiFn(item) { async deleteApiFn(item) {
let params = { let params = {
id: item.id, id: item.id
}; }
const res = await this.api.documentation.delete(params); const res = await this.api.documentation.delete(params)
// console.log('res: ', res); // console.log('res: ', res);
if (res.id) { if (res.id) {
this.$message.success("删除成功"); this.$message.success('删除成功')
this.getList(); this.getList()
} else { } else {
this.$message.error("删除失败"); this.$message.error('删除失败')
} }
}, }
}, }
}; }
</script> </script>
<style> <style>
.white_space {
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
</style> </style>
<template> <template>
<div> <div>
<a-form-model <a-form-model ref="ruleForm" :model="form" :rules="rules" :label-col="labelCol" :wrapper-col="wrapperCol">
ref="ruleForm"
:model="form"
:rules="rules"
:label-col="labelCol"
:wrapper-col="wrapperCol"
>
<a-form-model-item label="分类标题" prop="classify_title"> <a-form-model-item label="分类标题" prop="classify_title">
<a-input v-model="form.classify_title" /> <a-input v-model="form.classify_title" />
</a-form-model-item> </a-form-model-item>
...@@ -27,11 +21,9 @@ ...@@ -27,11 +21,9 @@
<a-input v-model="form.classify_description" type="textarea" /> <a-input v-model="form.classify_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 type="primary" @click="onSubmit">{{ isNewAdd ? '创建' : '提交' }}</a-button>
>{{ isNewAdd ? "创建" : "提交" }} <a-button style="margin-left: 10px" @click="resetForm">重置</a-button>
</a-button> <a-button style="margin-left: 10px" @click="closeForm">关闭</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>
...@@ -39,7 +31,7 @@ ...@@ -39,7 +31,7 @@
<script type="text/ecmascript-6"> <script type="text/ecmascript-6">
export default { export default {
name: "", name: '',
data() { data() {
return { return {
isNewAdd: true, isNewAdd: true,
...@@ -47,105 +39,101 @@ export default { ...@@ -47,105 +39,101 @@ export default {
wrapperCol: { span: 14 }, wrapperCol: { span: 14 },
classifyList: [ classifyList: [
{ {
name: "oss-web", name: 'oss-web',
value: "oss-web", value: 'oss-web'
}, },
{ {
name: "micro-service", name: 'micro-service',
value: "micro-service", value: 'micro-service'
}, },
{ {
name: "scrm", name: 'scrm',
value: "scrm", value: 'scrm'
}, },
{ {
name: "scrm-mobile", name: 'scrm-mobile',
value: "scrm-mobile", value: 'scrm-mobile'
}, }
], ],
form: { form: {
classify_title: "", classify_title: '',
classify: "", classify: '',
classify_description: "", classify_description: ''
}, },
rules: { rules: {
classify_title: [ classify_title: [
{ 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' }
],
classify: [
{ required: true, message: "请输入分类字段", trigger: "blur" },
], ],
classify_description: [ classify: [{ required: true, message: '请输入分类字段', trigger: 'blur' }],
{ required: true, message: "请输入分类描述", trigger: "blur" }, classify_description: [{ required: true, message: '请输入分类描述', trigger: 'blur' }]
], }
}, }
};
}, },
mounted() { mounted() {
this.editeItemFn(); this.editeItemFn()
}, },
methods: { methods: {
onSubmit() { onSubmit() {
this.$refs.ruleForm.validate((valid) => { this.$refs.ruleForm.validate(valid => {
if (valid) { if (valid) {
if (this.isNewAdd) { if (this.isNewAdd) {
//新增 //新增
console.log('this.form',this.form) console.log('this.form', this.form)
this.api.classify.create(this.form).then((res) => { 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('添加成功')
this.closeForm(); this.closeForm()
this.resetForm(); this.resetForm()
} else { } else {
this.$message.error("添加失败"); this.$message.error('添加失败')
} }
}); })
} else { } else {
//编辑 //编辑
this.api.classify.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('编辑成功')
this.closeForm(); this.closeForm()
this.resetForm(); this.resetForm()
} else { } else {
this.$message.error("编辑失败"); this.$message.error('编辑失败')
} }
}); })
} }
} else { } else {
return false; return false
} }
}); })
}, },
resetForm() { resetForm() {
this.isNewAdd = true; this.isNewAdd = true
this.$refs.ruleForm.resetFields(); this.$refs.ruleForm.resetFields()
}, },
closeForm() { closeForm() {
this.to(-1); this.to(-1)
}, },
//编辑项目 //编辑项目
editeItemFn() { editeItemFn() {
const editeItem = this.$route.params; const editeItem = this.$route.query
console.log("editeItem: ", editeItem); console.log('editeItem: ', editeItem)
if (Object.keys(editeItem).length === 0) return; if (Object.keys(editeItem).length === 0) return
this.isNewAdd = false; this.isNewAdd = false
this.form = { this.form = {
classify_title: editeItem.classify_title, classify_title: editeItem.classify_title,
classify: editeItem.classify, classify: editeItem.classify,
classify_description: editeItem.classify_description, classify_description: editeItem.classify_description,
id: editeItem.id, id: editeItem.id
}; }
}, }
}, },
// 重置 // 重置
beforeDestroy() { beforeDestroy() {
this.resetForm(); this.resetForm()
}, }
}; }
</script> </script>
<style scoped lang="scss"></style> <style scoped lang="scss"></style>
<template> <template>
<div> <div>
<a-form-model <a-form-model ref="ruleForm" :model="form" :rules="rules" :label-col="labelCol" :wrapper-col="wrapperCol">
ref="ruleForm"
:model="form"
:rules="rules"
:label-col="labelCol"
:wrapper-col="wrapperCol"
>
<a-form-model-item label="项目名称" prop="project_title"> <a-form-model-item label="项目名称" prop="project_title">
<a-input v-model="form.project_title" /> <a-input v-model="form.project_title" />
</a-form-model-item> </a-form-model-item>
...@@ -35,11 +29,9 @@ ...@@ -35,11 +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 type="primary" @click="onSubmit">{{ isNewAdd ? '创建' : '提交' }}</a-button>
isNewAdd ? "创建" : "提交" <a-button style="margin-left: 10px" @click="resetForm">重置</a-button>
}}</a-button> <a-button style="margin-left: 10px" @click="closeForm">关闭</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>
...@@ -47,135 +39,119 @@ ...@@ -47,135 +39,119 @@
<script> <script>
export default { export default {
name: "", name: '',
data() { data() {
return { return {
isNewAdd: true, isNewAdd: true,
labelCol: { span: 4 }, labelCol: { span: 4 },
wrapperCol: { span: 14 }, wrapperCol: { span: 14 },
form: { form: {
project_title: "", project_title: '',
project_description: "", project_description: '',
developer_name: "", developer_name: '',
config_name: "", config_name: '',
test_url: "", test_url: '',
product_url: "", product_url: '',
technology: "", technology: '',
git_url: "", git_url: '',
git_id: "", git_id: ''
}, },
rules: { rules: {
project_title: [ project_title: [
{ 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' }
], ],
project_description: [ project_description: [{ required: true, message: '请输入项目描述', trigger: 'blur' }],
{ required: true, message: "请输入项目描述", trigger: "blur" }, developer_name: [{ required: true, message: '请输入开发者名称', trigger: 'blur' }],
], config_name: [{ required: true, message: '请输入配置名称', trigger: 'blur' }],
developer_name: [ test_url: [{ required: true, message: '请输入测试环境地址', trigger: 'blur' }],
{ required: true, message: "请输入开发者名称", trigger: "blur" }, product_url: [{ required: true, message: '请输入生产环境地址', trigger: 'blur' }],
], technology: [{ required: true, message: '请输入相关技术栈', trigger: 'blur' }],
config_name: [ git_url: [{ required: true, message: '请输入gitlab地址', trigger: 'blur' }],
{ required: true, message: "请输入配置名称", trigger: "blur" }, git_id: [{ required: true, message: '请输入项目gitlab id', trigger: 'blur' }]
], }
test_url: [ }
{ required: true, message: "请输入测试环境地址", trigger: "blur" },
],
product_url: [
{ required: true, message: "请输入生产环境地址", trigger: "blur" },
],
technology: [
{ required: true, message: "请输入相关技术栈", trigger: "blur" },
],
git_url: [
{ required: true, message: "请输入gitlab地址", trigger: "blur" },
],
git_id: [
{ required: true, message: "请输入项目gitlab id", trigger: "blur" },
],
},
};
}, },
mounted() { mounted() {
this.editeItemFn(); this.editeItemFn()
}, },
methods: { methods: {
onSubmit() { onSubmit() {
this.$refs.ruleForm.validate((valid) => { this.$refs.ruleForm.validate(valid => {
if (valid) { if (valid) {
// const classify = sessionStorage.getItem("classify"); // const classify = sessionStorage.getItem("classify");
const pramas = { const pramas = {
...this.form, ...this.form
// classify, // classify,
}; }
// console.log("pramas: " + JSON.stringify(pramas)); // console.log("pramas: " + JSON.stringify(pramas));
if (this.isNewAdd) { if (this.isNewAdd) {
//新增 //新增
this.api.project.create(pramas).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('添加成功')
this.closeForm(); this.closeForm()
this.resetData(); this.resetData()
} else { } else {
this.$message.error("添加失败"); this.$message.error('添加失败')
} }
}); })
} else { } else {
//编辑 //编辑
this.api.project.update(pramas).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('编辑成功')
this.closeForm(); this.closeForm()
this.resetData(); this.resetData()
} else { } else {
this.$message.error("编辑失败"); this.$message.error('编辑失败')
} }
}); })
} }
} else { } else {
return false; return false
} }
}); })
}, },
resetForm() { resetForm() {
this.isNewAdd = true; this.isNewAdd = true
this.$refs.ruleForm.resetFields(); this.$refs.ruleForm.resetFields()
// this.resetData(); // this.resetData();
}, },
resetData() { resetData() {
this.form = { this.form = {
project_title: "", project_title: '',
project_description: "", project_description: '',
developer_name: "", developer_name: '',
config_name: "", config_name: '',
test_url: "", test_url: '',
product_url: "", product_url: '',
technology: "", technology: ''
}; }
}, },
closeForm() { closeForm() {
this.to(-1); this.to(-1)
}, },
//编辑项目 //编辑项目
editeItemFn() { editeItemFn() {
const editeItem = this.$route.params; const editeItem = this.$route.query
if (Object.keys(editeItem).length === 0) return; if (Object.keys(editeItem).length === 0) return
this.isNewAdd = false; this.isNewAdd = false
this.form = { this.form = {
...editeItem, ...editeItem
}; }
}, }
}, },
// 重置 // 重置
beforeDestroy() { beforeDestroy() {
this.resetForm(); this.resetForm()
}, }
}; }
</script> </script>
<style scoped lang="scss"></style> <style scoped lang="scss"></style>
...@@ -4,8 +4,8 @@ module.exports = { ...@@ -4,8 +4,8 @@ module.exports = {
proxy: { proxy: {
//配置跨域 //配置跨域
"/api3": { "/api3": {
target: "http://192.168.2.24:7001", target: "http://192.168.1.113:7001",
ws:true, ws: true,
changOrigin: true, changOrigin: true,
pathRewrite: { pathRewrite: {
"^/api3": "/" "^/api3": "/"
...@@ -14,7 +14,7 @@ module.exports = { ...@@ -14,7 +14,7 @@ module.exports = {
"/api2": { "/api2": {
// target: "http://192.168.3.233:8090/api/v4/projects", // target: "http://192.168.3.233:8090/api/v4/projects",
target: "http://192.168.1.16:8090/api/v4/projects", target: "http://192.168.1.16:8090/api/v4/projects",
ws:true, ws: true,
changOrigin: true, changOrigin: true,
pathRewrite: { pathRewrite: {
"^/api2": "/" "^/api2": "/"
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!