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

添加接口信息

parent c7b848c3
...@@ -15227,6 +15227,11 @@ ...@@ -15227,6 +15227,11 @@
"resolved": "https://registry.npmjs.org/vue/-/vue-2.6.11.tgz", "resolved": "https://registry.npmjs.org/vue/-/vue-2.6.11.tgz",
"integrity": "sha512-VfPwgcGABbGAue9+sfrD4PuwFar7gPb1yl1UK1MwXoQPAw0BKSqWfoYCT/ThFrdEVWoI51dBuyCoiNU9bZDZxQ==" "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": { "vue-eslint-parser": {
"version": "2.0.3", "version": "2.0.3",
"resolved": "https://registry.npmjs.org/vue-eslint-parser/-/vue-eslint-parser-2.0.3.tgz", "resolved": "https://registry.npmjs.org/vue-eslint-parser/-/vue-eslint-parser-2.0.3.tgz",
...@@ -15258,6 +15263,11 @@ ...@@ -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": { "vue-hot-reload-api": {
"version": "2.3.4", "version": "2.3.4",
"resolved": "https://registry.npmjs.org/vue-hot-reload-api/-/vue-hot-reload-api-2.3.4.tgz", "resolved": "https://registry.npmjs.org/vue-hot-reload-api/-/vue-hot-reload-api-2.3.4.tgz",
......
...@@ -19,6 +19,8 @@ ...@@ -19,6 +19,8 @@
"element-ui": "^2.13.2", "element-ui": "^2.13.2",
"less": "^3.11.1", "less": "^3.11.1",
"vue": "^2.5.2", "vue": "^2.5.2",
"vue-bus": "^1.2.1",
"vue-events": "^3.1.0",
"vue-json-editor": "^1.4.3", "vue-json-editor": "^1.4.3",
"vue-router": "^3.0.1", "vue-router": "^3.0.1",
"vuex": "^3.6.2" "vuex": "^3.6.2"
......
// The Vue build version to load with the `import` command // The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias. // (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue' import Vue from 'vue'
import VueBus from 'vue-bus'
import App from './App' import App from './App'
import '../src/assets/css/global.css' import '../src/assets/css/global.css'
import router from './router' import router from './router'
...@@ -87,6 +88,7 @@ Vue.use(RadioGroup) ...@@ -87,6 +88,7 @@ Vue.use(RadioGroup)
Vue.use(Radio) Vue.use(Radio)
Vue.use(Row) Vue.use(Row)
Vue.use(Col) Vue.use(Col)
Vue.use(VueBus)
/* eslint-disable no-new */ /* eslint-disable no-new */
new Vue({ new Vue({
el: '#app', el: '#app',
......
import Vue from 'vue'
const bus = new Vue()
export default bus
...@@ -164,7 +164,12 @@ ...@@ -164,7 +164,12 @@
</template> </template>
<script> <script>
import { getModulList, addInterface } from '@/api/getAotoInterface' import {
getModulList,
addInterface,
editInterface
} from '@/api/getAotoInterface'
import bus from '@/utils/bus'
export default { export default {
data() { data() {
return { return {
...@@ -174,6 +179,7 @@ export default { ...@@ -174,6 +179,7 @@ export default {
}, },
activeNames: '1', activeNames: '1',
interfaceForm: { interfaceForm: {
id: '',
name: '', name: '',
moduleId: '', moduleId: '',
method: '', method: '',
...@@ -247,31 +253,23 @@ export default { ...@@ -247,31 +253,23 @@ export default {
id: 'form', id: 'form',
name: '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() { 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() this.getModelList()
}, },
methods: { methods: {
...@@ -341,17 +339,53 @@ export default { ...@@ -341,17 +339,53 @@ export default {
this.responseList.isRequired = e this.responseList.isRequired = e
} }
}, },
// 刷新列表
sendResh() {
// bus使用
this.$nextTick(function () {
// DOM 现在更新了
bus.$emit('refresh')
})
},
// 保存接口信息 // 保存接口信息
addInterfaceFrom() { addInterfaceFrom() {
this.interfaceForm.headers = JSON.stringify(this.headersList) this.interfaceForm.headers = JSON.stringify(this.headersList)
this.interfaceForm.paramTemplate = JSON.stringify(this.paramList) this.interfaceForm.paramTemplate = JSON.stringify(this.paramList)
this.interfaceForm.responseTemplate = JSON.stringify(this.responseList) this.interfaceForm.responseTemplate = JSON.stringify(this.responseList)
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) => { addInterface(this.interfaceForm).then((resp) => {
console.log('信息', this.interfaceForm)
if (resp.data.data === true) { if (resp.data.data === true) {
this.$message.success('添加成功!') this.$message.success('添加成功!')
// 返回列表页 // 返回列表页
this.$router.push('InterfaceDetail') this.$router.push('InterfaceDetail')
// 刷新列表页
this.sendResh()
this.interfaceForm.name = '' this.interfaceForm.name = ''
this.interfaceForm.moduleId = '' this.interfaceForm.moduleId = ''
this.interfaceForm.method = '' this.interfaceForm.method = ''
...@@ -366,6 +400,7 @@ export default { ...@@ -366,6 +400,7 @@ export default {
}) })
} }
} }
}
} }
</script> </script>
......
...@@ -44,6 +44,8 @@ import { ...@@ -44,6 +44,8 @@ import {
interfaceDetailList, interfaceDetailList,
delInterface delInterface
} from '@/api/getAotoInterface' } from '@/api/getAotoInterface'
// 引入组件
import bus from '@/utils/bus'
export default { export default {
data() { data() {
return { return {
...@@ -71,6 +73,9 @@ export default { ...@@ -71,6 +73,9 @@ export default {
created() { created() {
this.getProjectList() this.getProjectList()
this.getInterfaceDetailList() this.getInterfaceDetailList()
bus.$on('refresh', () => {
this.getInterfaceDetailList()
})
}, },
methods: { methods: {
// 项目列表 // 项目列表
...@@ -116,13 +121,14 @@ export default { ...@@ -116,13 +121,14 @@ export default {
}, },
// 编辑接口方法 // 编辑接口方法
editInterfaceFrom(row) { editInterfaceFrom(row) {
console.log('编辑按钮')
this.$router.push({ this.$router.push({
path: 'AddInterface', path: 'AddInterface',
name: 'AddInterface', name: 'AddInterface'
params: { })
row: row // bus使用
} this.$nextTick(function () {
// DOM 现在更新了
bus.$emit('msg', row)
}) })
}, },
// 对话框方法 // 对话框方法
......
...@@ -139,6 +139,7 @@ export default { ...@@ -139,6 +139,7 @@ export default {
this.queryModuleInfo.pageNum = newPage this.queryModuleInfo.pageNum = newPage
this.getModelList() this.getModelList()
}, },
// 添加模块按钮 // 添加模块按钮
addModelFrom() { addModelFrom() {
if (this.modelForm.id) { 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