Commit f684eba7 by zhangxw

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

1 parent b0e485a3
This diff could not be displayed because it is too large.
......@@ -3,15 +3,18 @@
<div class="wrapper-header">
<img class="logo" src="./assets/logo.png" alt="" />
<a-menu v-model="current" mode="horizontal">
<a-menu-item key="folder" @click="handleTab('Folder')"
><a-icon type="home" />项目主页</a-menu-item
>
<a-menu-item key="documentation" @click="handleTab('Documentation')"
><a-icon type="file-text" />项目文档描述</a-menu-item
>
<a-menu-item key="record" @click="handleTab('Record')"
><a-icon type="message" />问题记录</a-menu-item
>
<a-menu-item key="folder" @click="handleTab('Folder')">
<a-icon type="home" />
项目主页
</a-menu-item>
<a-menu-item key="DocumentClassify" @click="handleTab('DocumentClassify')">
<a-icon type="file-text" />
项目文档描述
</a-menu-item>
<a-menu-item key="record" @click="handleTab('Record')">
<a-icon type="message" />
问题记录
</a-menu-item>
</a-menu>
</div>
<div class="wrapper-content">
......@@ -21,32 +24,39 @@
</template>
<script>
let currentName = "";
let currentName = ''
export default {
name: "App",
name: 'App',
data() {
return {
current: ["folder"],
};
current: ['folder']
}
},
mounted() {
currentName = window.location.pathname.substr(1);
console.log(currentName);
if (!currentName) this.current = ["folder"];
else this.current = [currentName];
currentName = window.location.pathname.substr(1)
console.log(currentName)
if (!currentName) this.current = ['folder']
else this.current = [currentName]
},
methods: {
handleTab(name) {
this.to(name);
},
},
};
this.to(name)
}
}
}
</script>
<style>
<style lang="scss">
#app {
display: flex;
flex-flow: column;
height: 100vh;
overflow: hidden;
}
.wrapper-header {
display: flex;
background-color: #2b303b;
height: 50px;
}
.wrapper-header .logo {
display: inline-flex;
......@@ -70,8 +80,13 @@ export default {
color: #fff;
}
.wrapper-content {
overflow-y: auto;
margin: 30px auto;
padding: 0 10px;
max-width: 1300px;
width: 100%;
& > div {
max-width: 1300px;
margin: 0 auto;
}
}
</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
......@@ -6,11 +6,11 @@
*/
import request from '@/plugins/axios'
const documentation = {
getList() {
getList(id) {
return request({
url: '/documentation/getList',
url: `/documentation/getList?classifyId=${id}`,
method: 'get',
params: {}
})
......
import project from "./project";
import documentation from "./documentation";
import documentClassify from "./documentClassify";
import commons from "./commons";
import gitLog from "./gitLog";
import classify from "./classify";
......@@ -7,6 +8,7 @@ import classify from "./classify";
export default {
project,
documentation,
documentClassify,
commons,
gitLog,
classify,
......
......@@ -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,Modal } from "ant-design-vue";
import { message, Modal } from "ant-design-vue";
import api from './api'
import PubSub from 'pubsub-js'
......@@ -13,12 +13,12 @@ Vue.config.productionTip = false;
components.forEach(component => Vue.use(component))
Vue.prototype.api = api
Vue.prototype.to = function (name, params) {
Vue.prototype.to = function (name, query) {
if (name === -1) {
router.go(-1)
return
}
router.push({ name, params})
router.push({ name, query })
}
Vue.prototype.$message = message
Vue.prototype.$confirm = Modal.confirm
......
......@@ -30,6 +30,18 @@ const routes = Object.freeze([
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",
path: "/documentation",
component: (resolve) =>
......
<template>
<div>
<a-form-model
ref="ruleForm"
:model="form"
:rules="rules"
:label-col="labelCol"
:wrapper-col="wrapperCol"
>
<a-form-model ref="ruleForm" :model="form" :rules="rules" :label-col="labelCol" :wrapper-col="wrapperCol">
<a-form-model-item label="文档标题" prop="docTitle">
<a-input v-model="form.docTitle" />
</a-form-model-item>
......@@ -17,11 +11,9 @@
<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"
>{{ 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 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>
......@@ -29,94 +21,91 @@
<script type="text/ecmascript-6">
export default {
name: "",
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() {
this.editeItemFn();
this.editeItemFn()
},
methods: {
onSubmit() {
this.$refs.ruleForm.validate((valid) => {
this.$refs.ruleForm.validate(valid => {
if (valid) {
if (this.isNewAdd) {
//新增
this.api.documentation.create(this.form).then((res) => {
this.api.documentation.create(this.form).then(res => {
// console.log(res);
if (res.id) {
this.$message.success("添加成功");
this.closeForm();
this.resetForm();
this.$message.success('添加成功')
this.closeForm()
this.resetForm()
} else {
this.$message.error("添加失败");
this.$message.error('添加失败')
}
});
})
} else {
//编辑
this.api.documentation.update(this.form).then((res) => {
console.log(res);
this.api.documentation.update(this.form).then(res => {
console.log(res)
if (res.id) {
this.$message.success("编辑成功");
this.closeForm();
this.resetForm();
this.$message.success('编辑成功')
this.closeForm()
this.resetForm()
} else {
this.$message.error("编辑失败");
this.$message.error('编辑失败')
}
});
})
}
} else {
return false;
return false
}
});
})
},
resetForm() {
this.isNewAdd = true;
this.$refs.ruleForm.resetFields();
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;
const editeItem = this.$route.query
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,
};
},
classify_id: editeItem.classify_id
}
}
},
// 重置
beforeDestroy() {
this.resetForm();
},
};
this.resetForm()
}
}
</script>
<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>
<div>
<h2>前端开发文档</h2>
<h2>{{ listItem.title }}</h2>
<a-list :grid="{ gutter: 16, column: 4 }" :data-source="docData">
<a-list-item slot="renderItem" slot-scope="item">
<a rel="noopener noreferrer" @click="showDocument(item.doc_url)">
<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> -->
<template slot="actions" class="ant-card-actions">
<template slot="actions">
<a-icon key="edit" type="edit" @click.stop="editFn(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>
</a-card>
</a>
......@@ -21,88 +29,102 @@
</div>
</template>
<script>
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",
},
];
const data = []
export default {
name: "Developers",
name: 'Developers',
data() {
return {
docData: data,
};
classifyData: [],
listItem: this.$route.query
}
},
mounted() {
this.getList();
this.getList()
this.getClassifyList()
},
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() {
this.api.documentation.getList().then((res) => {
this.api.documentation.getList(this.listItem.id).then(res => {
// console.log(res);
this.docData = res;
});
this.docData = res
})
},
add() {
this.to("DocAdd");
this.to('DocAdd')
},
showDocument(url) {
if (url) {
window.open(url, "target");
window.open(url)
}
},
editFn(item) {
this.to("DocAdd", item);
this.to('DocAdd', item)
},
deleteFn(item) {
let that = this;
let that = this
this.$confirm({
title: "您确认删除吗?",
title: '您确认删除吗?',
onOk() {
that.deleteApiFn(item);
that.deleteApiFn(item)
},
onCancel() {},
okText: "确认",
cancelText: "取消",
});
okText: '确认',
cancelText: '取消'
})
},
async deleteApiFn(item) {
let params = {
id: item.id,
};
const res = await this.api.documentation.delete(params);
id: item.id
}
const res = await this.api.documentation.delete(params)
// console.log('res: ', res);
if (res.id) {
this.$message.success("删除成功");
this.getList();
this.$message.success('删除成功')
this.getList()
} else {
this.$message.error("删除失败");
this.$message.error('删除失败')
}
},
},
};
}
}
}
</script>
<style>
.white_space {
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
</style>
<template>
<div>
<a-form-model
ref="ruleForm"
:model="form"
:rules="rules"
:label-col="labelCol"
:wrapper-col="wrapperCol"
>
<a-form-model ref="ruleForm" :model="form" :rules="rules" :label-col="labelCol" :wrapper-col="wrapperCol">
<a-form-model-item label="分类标题" prop="classify_title">
<a-input v-model="form.classify_title" />
</a-form-model-item>
......@@ -27,11 +21,9 @@
<a-input v-model="form.classify_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-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>
......@@ -39,7 +31,7 @@
<script type="text/ecmascript-6">
export default {
name: "",
name: '',
data() {
return {
isNewAdd: true,
......@@ -47,105 +39,101 @@ export default {
wrapperCol: { span: 14 },
classifyList: [
{
name: "oss-web",
value: "oss-web",
name: 'oss-web',
value: 'oss-web'
},
{
name: "micro-service",
value: "micro-service",
name: 'micro-service',
value: 'micro-service'
},
{
name: "scrm",
value: "scrm",
name: 'scrm',
value: 'scrm'
},
{
name: "scrm-mobile",
value: "scrm-mobile",
},
name: 'scrm-mobile',
value: 'scrm-mobile'
}
],
form: {
classify_title: "",
classify: "",
classify_description: "",
classify_title: '',
classify: '',
classify_description: ''
},
rules: {
classify_title: [
{ required: true, message: "请输入分类名称", trigger: "blur" },
{ min: 1, max: 30, message: "请输入字符1~50之间", trigger: "blur" },
],
classify: [
{ required: true, message: "请输入分类字段", trigger: "blur" },
],
classify_description: [
{ required: true, message: "请输入分类描述", trigger: "blur" },
{ required: true, message: '请输入分类名称', trigger: 'blur' },
{ min: 1, max: 30, message: '请输入字符1~50之间', trigger: 'blur' }
],
},
};
classify: [{ required: true, message: '请输入分类字段', trigger: 'blur' }],
classify_description: [{ required: true, message: '请输入分类描述', trigger: 'blur' }]
}
}
},
mounted() {
this.editeItemFn();
this.editeItemFn()
},
methods: {
onSubmit() {
this.$refs.ruleForm.validate((valid) => {
this.$refs.ruleForm.validate(valid => {
if (valid) {
if (this.isNewAdd) {
//新增
console.log('this.form',this.form)
this.api.classify.create(this.form).then((res) => {
console.log('this.form', this.form)
this.api.classify.create(this.form).then(res => {
// console.log(res);
if (res.id) {
this.$message.success("添加成功");
this.closeForm();
this.resetForm();
this.$message.success('添加成功')
this.closeForm()
this.resetForm()
} else {
this.$message.error("添加失败");
this.$message.error('添加失败')
}
});
})
} else {
//编辑
this.api.classify.update(this.form).then((res) => {
console.log(res);
this.api.classify.update(this.form).then(res => {
console.log(res)
if (res.id) {
this.$message.success("编辑成功");
this.closeForm();
this.resetForm();
this.$message.success('编辑成功')
this.closeForm()
this.resetForm()
} else {
this.$message.error("编辑失败");
this.$message.error('编辑失败')
}
});
})
}
} else {
return false;
return false
}
});
})
},
resetForm() {
this.isNewAdd = true;
this.$refs.ruleForm.resetFields();
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;
const editeItem = this.$route.query
console.log('editeItem: ', editeItem)
if (Object.keys(editeItem).length === 0) return
this.isNewAdd = false
this.form = {
classify_title: editeItem.classify_title,
classify: editeItem.classify,
classify_description: editeItem.classify_description,
id: editeItem.id,
};
},
id: editeItem.id
}
}
},
// 重置
beforeDestroy() {
this.resetForm();
},
};
this.resetForm()
}
}
</script>
<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 ref="ruleForm" :model="form" :rules="rules" :label-col="labelCol" :wrapper-col="wrapperCol">
<a-form-model-item label="项目名称" prop="project_title">
<a-input v-model="form.project_title" />
</a-form-model-item>
......@@ -35,11 +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">{{
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 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>
......@@ -47,135 +39,119 @@
<script>
export default {
name: "",
name: '',
data() {
return {
isNewAdd: true,
labelCol: { span: 4 },
wrapperCol: { span: 14 },
form: {
project_title: "",
project_description: "",
developer_name: "",
config_name: "",
test_url: "",
product_url: "",
technology: "",
git_url: "",
git_id: "",
project_title: '',
project_description: '',
developer_name: '',
config_name: '',
test_url: '',
product_url: '',
technology: '',
git_url: '',
git_id: ''
},
rules: {
project_title: [
{ 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' }
],
project_description: [
{ required: true, message: "请输入项目描述", trigger: "blur" },
],
developer_name: [
{ required: true, message: "请输入开发者名称", trigger: "blur" },
],
config_name: [
{ required: true, message: "请输入配置名称", 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" },
],
},
};
project_description: [{ required: true, message: '请输入项目描述', trigger: 'blur' }],
developer_name: [{ required: true, message: '请输入开发者名称', trigger: 'blur' }],
config_name: [{ required: true, message: '请输入配置名称', 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() {
this.editeItemFn();
this.editeItemFn()
},
methods: {
onSubmit() {
this.$refs.ruleForm.validate((valid) => {
this.$refs.ruleForm.validate(valid => {
if (valid) {
// const classify = sessionStorage.getItem("classify");
const pramas = {
...this.form,
...this.form
// classify,
};
}
// console.log("pramas: " + JSON.stringify(pramas));
if (this.isNewAdd) {
//新增
this.api.project.create(pramas).then((res) => {
this.api.project.create(pramas).then(res => {
// console.log('res: ', res);
if (res.id) {
this.$message.success("添加成功");
this.closeForm();
this.resetData();
this.$message.success('添加成功')
this.closeForm()
this.resetData()
} else {
this.$message.error("添加失败");
this.$message.error('添加失败')
}
});
})
} else {
//编辑
this.api.project.update(pramas).then((res) => {
this.api.project.update(pramas).then(res => {
// console.log("res: ", res);
if (res.id) {
this.$message.success("编辑成功");
this.closeForm();
this.resetData();
this.$message.success('编辑成功')
this.closeForm()
this.resetData()
} else {
this.$message.error("编辑失败");
this.$message.error('编辑失败')
}
});
})
}
} else {
return false;
return false
}
});
})
},
resetForm() {
this.isNewAdd = true;
this.$refs.ruleForm.resetFields();
this.isNewAdd = true
this.$refs.ruleForm.resetFields()
// this.resetData();
},
resetData() {
this.form = {
project_title: "",
project_description: "",
developer_name: "",
config_name: "",
test_url: "",
product_url: "",
technology: "",
};
project_title: '',
project_description: '',
developer_name: '',
config_name: '',
test_url: '',
product_url: '',
technology: ''
}
},
closeForm() {
this.to(-1);
this.to(-1)
},
//编辑项目
editeItemFn() {
const editeItem = this.$route.params;
if (Object.keys(editeItem).length === 0) return;
this.isNewAdd = false;
const editeItem = this.$route.query
if (Object.keys(editeItem).length === 0) return
this.isNewAdd = false
this.form = {
...editeItem,
};
},
...editeItem
}
}
},
// 重置
beforeDestroy() {
this.resetForm();
},
};
this.resetForm()
}
}
</script>
<style scoped lang="scss"></style>
......@@ -4,17 +4,17 @@ module.exports = {
proxy: {
//配置跨域
"/api3": {
target: "http://192.168.2.24:7001",
ws:true,
target: "http://192.168.1.113:7001",
ws: true,
changOrigin: true,
pathRewrite: {
"^/api3": "/"
}
},
},
"/api2": {
// target: "http://192.168.3.233:8090/api/v4/projects",
target: "http://192.168.1.16:8090/api/v4/projects",
ws:true,
ws: true,
changOrigin: true,
pathRewrite: {
"^/api2": "/"
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!