Commit 75ee64d9 authored by 王晓铜's avatar 王晓铜

添加接口信息

parent c7b848c3
......@@ -15227,6 +15227,11 @@
"resolved": "https://registry.npmjs.org/vue/-/vue-2.6.11.tgz",
"integrity": "sha512-VfPwgcGABbGAue9+sfrD4PuwFar7gPb1yl1UK1MwXoQPAw0BKSqWfoYCT/ThFrdEVWoI51dBuyCoiNU9bZDZxQ=="
},
"vue-bus": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/vue-bus/-/vue-bus-1.2.1.tgz",
"integrity": "sha512-uCSJEWFWoDZz+GV/Pj/wXAC7WVBLD18V62l+2ezd4UCsZWZB27Hz3K0M9WUcbNum/yKBoN+OkOCIrU6A9xqWhw=="
},
"vue-eslint-parser": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/vue-eslint-parser/-/vue-eslint-parser-2.0.3.tgz",
......@@ -15258,6 +15263,11 @@
}
}
},
"vue-events": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/vue-events/-/vue-events-3.1.0.tgz",
"integrity": "sha512-JoE6ZlIEFdpj/vE7oW6T1T3Vz2h0Zxc4XEyz92L2tiRVc1TZ0u/nY1s6ZrnpHKoVxeEU0ouAp/FMxTKI3JBpvA=="
},
"vue-hot-reload-api": {
"version": "2.3.4",
"resolved": "https://registry.npmjs.org/vue-hot-reload-api/-/vue-hot-reload-api-2.3.4.tgz",
......
// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import VueBus from 'vue-bus'
import App from './App'
import '../src/assets/css/global.css'
import router from './router'
......@@ -87,6 +88,7 @@ Vue.use(RadioGroup)
Vue.use(Radio)
Vue.use(Row)
Vue.use(Col)
Vue.use(VueBus)
/* eslint-disable no-new */
new Vue({
el: '#app',
......
import Vue from 'vue'
const bus = new Vue()
export default bus
......@@ -164,7 +164,12 @@
</template>
<script>
import { getModulList, addInterface } from '@/api/getAotoInterface'
import {
getModulList,
addInterface,
editInterface
} from '@/api/getAotoInterface'
import bus from '@/utils/bus'
export default {
data() {
return {
......@@ -174,6 +179,7 @@ export default {
},
activeNames: '1',
interfaceForm: {
id: '',
name: '',
moduleId: '',
method: '',
......@@ -247,31 +253,23 @@ export default {
id: 'form',
name: 'form'
}
],
new_header: ''
}
},
watch: {
$route(to, from) {
console.log('参数信息', to)
if (to.params !== '{}') {
this.interfaceForm.name = to.params.row.name
this.interfaceForm.moduleId = to.params.row.moduleName
this.interfaceForm.method = to.params.row.method
this.interfaceForm.url = to.params.row.url
this.interfaceForm.paramType = to.params.row.paramType
this.headersList = JSON.parse(to.params.row.headers)
this.paramList = JSON.parse(to.params.row.paramTemplate)
this.responseList = JSON.parse(to.params.row.responseTemplate)
console.log('111', JSON.parse(to.params.row.headers))
// for (var i in this.headersList) {
// console.log('555', i)
// console.log('666', this.headersList[i])
// }
}
]
}
},
created() {
console.log('2222')
bus.$on('msg', (row) => {
console.log('传递的参数信息', row)
this.interfaceForm.id = row.id
this.interfaceForm.name = row.name
this.interfaceForm.moduleId = row.moduleId
this.interfaceForm.method = row.method
this.interfaceForm.url = row.url
this.interfaceForm.paramType = row.paramType
this.headersList = JSON.parse(row.headers)
this.paramList = JSON.parse(row.paramTemplate)
this.responseList = JSON.parse(row.responseTemplate)
})
this.getModelList()
},
methods: {
......@@ -341,29 +339,66 @@ export default {
this.responseList.isRequired = e
}
},
// 刷新列表
sendResh() {
// bus使用
this.$nextTick(function () {
// DOM 现在更新了
bus.$emit('refresh')
})
},
// 保存接口信息
addInterfaceFrom() {
this.interfaceForm.headers = JSON.stringify(this.headersList)
this.interfaceForm.paramTemplate = JSON.stringify(this.paramList)
this.interfaceForm.responseTemplate = JSON.stringify(this.responseList)
addInterface(this.interfaceForm).then((resp) => {
console.log('信息', this.interfaceForm)
if (resp.data.data === true) {
this.$message.success('添加成功!')
// 返回列表页
this.$router.push('InterfaceDetail')
this.interfaceForm.name = ''
this.interfaceForm.moduleId = ''
this.interfaceForm.method = ''
this.interfaceForm.url = ''
this.interfaceForm.paramType = ''
this.interfaceForm.headers = ''
this.interfaceForm.paramTemplate = ''
this.interfaceForm.responseTemplate = ''
} else {
this.$message.error(resp.data.msg)
}
})
if (this.interfaceForm.id) {
// 编辑接口
editInterface(this.interfaceForm).then((resp) => {
console.log('编辑信息', this.interfaceForm)
if (resp.data.data === true) {
this.$message.success('修改成功!')
this.$router.push('InterfaceDetail')
// 刷新列表页
this.sendResh()
this.interfaceForm.id = ''
this.interfaceForm.name = ''
this.interfaceForm.moduleId = ''
this.interfaceForm.method = ''
this.interfaceForm.url = ''
this.interfaceForm.paramType = ''
this.interfaceForm.headers = ''
this.interfaceForm.paramTemplate = ''
this.interfaceForm.responseTemplate = ''
} else {
this.$message.error(resp.data.msg)
}
})
} else {
// this.interfaceForm.headers = JSON.stringify(this.headersList)
// this.interfaceForm.paramTemplate = JSON.stringify(this.paramList)
// this.interfaceForm.responseTemplate = JSON.stringify(this.responseList)
addInterface(this.interfaceForm).then((resp) => {
if (resp.data.data === true) {
this.$message.success('添加成功!')
// 返回列表页
this.$router.push('InterfaceDetail')
// 刷新列表页
this.sendResh()
this.interfaceForm.name = ''
this.interfaceForm.moduleId = ''
this.interfaceForm.method = ''
this.interfaceForm.url = ''
this.interfaceForm.paramType = ''
this.interfaceForm.headers = ''
this.interfaceForm.paramTemplate = ''
this.interfaceForm.responseTemplate = ''
} else {
this.$message.error(resp.data.msg)
}
})
}
}
}
}
......
......@@ -44,6 +44,8 @@ import {
interfaceDetailList,
delInterface
} from '@/api/getAotoInterface'
// 引入组件
import bus from '@/utils/bus'
export default {
data() {
return {
......@@ -71,6 +73,9 @@ export default {
created() {
this.getProjectList()
this.getInterfaceDetailList()
bus.$on('refresh', () => {
this.getInterfaceDetailList()
})
},
methods: {
// 项目列表
......@@ -116,13 +121,14 @@ export default {
},
// 编辑接口方法
editInterfaceFrom(row) {
console.log('编辑按钮')
this.$router.push({
path: 'AddInterface',
name: 'AddInterface',
params: {
row: row
}
name: 'AddInterface'
})
// bus使用
this.$nextTick(function () {
// DOM 现在更新了
bus.$emit('msg', row)
})
},
// 对话框方法
......
......@@ -139,6 +139,7 @@ export default {
this.queryModuleInfo.pageNum = newPage
this.getModelList()
},
// 添加模块按钮
addModelFrom() {
if (this.modelForm.id) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment