|
@@ -0,0 +1,161 @@
|
|
|
+<template>
|
|
|
+ <div id="service-publish-detail" class="detail-default">
|
|
|
+ <div class="detail-header">
|
|
|
+ <div class="d-title">
|
|
|
+ <span>服务信息</span>
|
|
|
+ <span v-if="route.params.type==='add'">新增</span>
|
|
|
+ <span v-else-if="route.params.type==='detail'">详情</span>
|
|
|
+ <span v-else-if="route.params.type==='edit'">编辑</span>
|
|
|
+ </div>
|
|
|
+ <div class="d-btns">
|
|
|
+ <el-button class="btn-default primary" type="primary" v-if="route.params.type==='add'" @click="handleSave()">发布</el-button>
|
|
|
+ <el-button class="btn-default primary" type="primary" v-if="route.params.type==='edit'" @click="handleSave()">保存</el-button>
|
|
|
+ <el-button class="btn-default" @click="handleClose">关闭</el-button>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="detail-main-wrapper">
|
|
|
+ <div class="detail-main">
|
|
|
+ <span class="detail-part-title">基本信息</span>
|
|
|
+ <el-form :model="form.basicInfo" :rules="formRules.basicInfo" label-position="top" ref="basicInfo" class="form-detail">
|
|
|
+ <el-form-item label="接口名称" prop="apiName">
|
|
|
+ <el-input v-model="form.basicInfo.apiName" placeholder="请输入内容" clearable></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="类别" prop="apiClass">
|
|
|
+ <el-select v-model="form.basicInfo.apiClass" placeholder="请选择" clearable :options="select_class">
|
|
|
+ <el-option v-for="item in select_class" :key="item.value" :label="item.label" :value="item.value"></el-option>
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="接口简介" prop="apiDes" class="item-row">
|
|
|
+ <el-input type="textarea" :rows="4" v-model="form.basicInfo.apiDes" placeholder="请输入接口简介信息"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <span class="detail-part-title">接口信息</span>
|
|
|
+ <el-form-item label="接口地址" prop="apiUrl">
|
|
|
+ <el-input v-model="form.basicInfo.apiUrl" placeholder="请输入内容" clearable></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="请求方式" prop="apiRequest">
|
|
|
+ <el-select v-model="form.basicInfo.apiRequest" placeholder="请选择" clearable :options="select_request">
|
|
|
+ <el-option v-for="item in select_request" :key="item.value" :label="item.label" :value="item.value"></el-option>
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="接口说明" prop="apiExplain" class="item-row">
|
|
|
+ <el-input type="textarea" :rows="4" v-model="form.basicInfo.apiExplain" placeholder="请输入接口说明信息"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script setup>
|
|
|
+
|
|
|
+ import {useRoute, useRouter} from "vue-router";
|
|
|
+ import {reactive, ref} from "vue";
|
|
|
+ import {ServicePublishAdd, ServicePublishEdit, ServicePublishDetail} from "../../service/servicePublishApi";
|
|
|
+ import {ElMessage} from "element-plus";
|
|
|
+ import {onBeforeMount} from "@vue/runtime-core";
|
|
|
+ import createEnum from "../../utils/data/create-enum";
|
|
|
+
|
|
|
+
|
|
|
+ const route = useRoute()
|
|
|
+ const router = useRouter()
|
|
|
+
|
|
|
+ const form = reactive({
|
|
|
+ basicInfo: {
|
|
|
+ apiName: '',
|
|
|
+ apiClass: '',
|
|
|
+ apiDes: '',
|
|
|
+ },
|
|
|
+ apiInfo: {
|
|
|
+ apiUrl: '',
|
|
|
+ apiRequest:'',
|
|
|
+ apiExplain:''
|
|
|
+ }
|
|
|
+ })
|
|
|
+ const select_request = createEnum([
|
|
|
+ {value: 'post', label: 'POST'},
|
|
|
+ {value: 'get', label: 'GET'}
|
|
|
+ ])
|
|
|
+ const select_class = createEnum([
|
|
|
+ {value: 1, label: '基础底图'},
|
|
|
+ {value: 2, label: '空间查询'},
|
|
|
+ {value: 3, label: '三维分析'},
|
|
|
+ {value: 4, label: '空间可视化'},
|
|
|
+ {value: 5, label: '空间编辑'},
|
|
|
+ {value: 6, label: '其它功能'}
|
|
|
+ ])
|
|
|
+ const formRules = reactive({
|
|
|
+ basicInfo: {
|
|
|
+ apiName: { required: true, message: '请输入接口名称', trigger: 'blur' },
|
|
|
+ apiClass: { required: true, message: '请输入接口类型', trigger: 'blur' },
|
|
|
+ apiDes: { required: true, message: '请输入接口简介信息', trigger: 'change' },
|
|
|
+ apiUrl: { required: true, message: '请输入接口地址', trigger: 'change' },
|
|
|
+ apiRequest: { required: true, message: '请选择接入方式', trigger: 'change' },
|
|
|
+ apiExplain: { required: true, message: '请选择接口说明信息', trigger: 'change' },
|
|
|
+ },
|
|
|
+ })
|
|
|
+ function handleClose() {
|
|
|
+ router.push({
|
|
|
+ name: route.name.slice(0,-6)
|
|
|
+ })
|
|
|
+ }
|
|
|
+ const basicInfo = ref(null)
|
|
|
+ // 整个提交表单
|
|
|
+ function handleSave() {
|
|
|
+ Promise.all([basicInfo.value.validate()]).then(valid => {
|
|
|
+ if(valid.findIndex(val => val===false)===-1) {
|
|
|
+ // 校验通过
|
|
|
+ let pForm={}
|
|
|
+ for (const k in form.basicInfo) {
|
|
|
+ pForm[k] = form.basicInfo[k]
|
|
|
+ }
|
|
|
+ if(route.params.type==='edit') {
|
|
|
+ // 编辑
|
|
|
+ pForm['id'] = route.params.id
|
|
|
+ ServicePublishEdit(pForm).then(res => {
|
|
|
+ if(res.code=='200'&&res.data==='保存成功') {
|
|
|
+ ElMessage({type:'success', message: '修改成功'})
|
|
|
+ handleClose()
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ // 新增
|
|
|
+ pForm['id'] = null
|
|
|
+ pForm['state'] = 1
|
|
|
+ ServicePublishAdd(pForm).then(res => {
|
|
|
+ if(res.code=='200'&&res.data==='保存成功') {
|
|
|
+ ElMessage({type:'success', message: '新增成功'})
|
|
|
+ handleClose()
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ const currentPage = ref(1)
|
|
|
+ const pageSize = ref(10)
|
|
|
+ const select_resource = ref([])
|
|
|
+ onBeforeMount(()=> {
|
|
|
+ if(route.params.type!=='add') {
|
|
|
+ ServicePublishDetail(route.params.id).then(res => {
|
|
|
+ if(res.code===200) {
|
|
|
+ const data = res.data
|
|
|
+ form.basicInfo.apiName = data.apiName
|
|
|
+ form.basicInfo.apiClass = data.apiClass
|
|
|
+ form.basicInfo.apiDes = data.apiDes
|
|
|
+ form.basicInfo.apiUrl = data.apiUrl
|
|
|
+ form.basicInfo.apiRequest = data.apiRequest
|
|
|
+ form.basicInfo.apiExplain = data.apiExplain
|
|
|
+ } else {
|
|
|
+ ElMessage({type:'error', message: '查询失败'})
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+</script>
|
|
|
+
|
|
|
+<style scoped lang="scss">
|
|
|
+ #service-publish-detail {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+</style>
|