|
@@ -5,15 +5,29 @@ export default {
|
|
|
};
|
|
|
</script>
|
|
|
<script setup lang="ts">
|
|
|
-import { inject, onMounted, reactive, ref, Uploadfile, UploadImg, Editor, useRenderIcon, ElMessage, ElMessageBox, Upload, Close, http, getGroupUrl, RegularVerification, verification } from "@/utils/importUsed"
|
|
|
-// 接口列表实例
|
|
|
-let UrlList = reactive(null)
|
|
|
+import { requestEdit, requestSearch } from "@/utils/handlePort";
|
|
|
+import {
|
|
|
+ inject,
|
|
|
+ onMounted,
|
|
|
+ reactive,
|
|
|
+ ref,
|
|
|
+ Uploadfile,
|
|
|
+ UploadImg,
|
|
|
+ Editor,
|
|
|
+ useRenderIcon,
|
|
|
+ ElMessage,
|
|
|
+ ElMessageBox,
|
|
|
+ Upload,
|
|
|
+ Close,
|
|
|
+ http,
|
|
|
+ getGroupUrl,
|
|
|
+ RegularVerification,
|
|
|
+ verification
|
|
|
+} from "@/utils/importUsed";
|
|
|
// 获取当前板块接口列表
|
|
|
onMounted(async () => {
|
|
|
- UrlList = await getGroupUrl(["kxsConfigServer"]);
|
|
|
groupIdQuery();
|
|
|
-
|
|
|
-})
|
|
|
+});
|
|
|
const props = defineProps<{
|
|
|
editVisible: {
|
|
|
type: Boolean;
|
|
@@ -28,175 +42,103 @@ const props = defineProps<{
|
|
|
type: any;
|
|
|
default: {};
|
|
|
};
|
|
|
+ closeFn: any;
|
|
|
}>();
|
|
|
-// 表单数据
|
|
|
-const UpdateForm: any = ref({
|
|
|
- groupId: "", //分组
|
|
|
- apiName: "", //接口名称
|
|
|
- apiKey: "", //接口关键字
|
|
|
- apiHost: "", //接口主机头
|
|
|
- apiPort: "", //接口端口号
|
|
|
- apiRouter: "", //接口路由
|
|
|
- apiMethod: "", //接口请求方式
|
|
|
-
|
|
|
-});
|
|
|
-// 分组选项数据
|
|
|
-const groupIdOptionList = ref([]);
|
|
|
-
|
|
|
-// 表单实例
|
|
|
-const ruleFormRef = ref()
|
|
|
|
|
|
-// 选项卡参数(默认值为列表某项的id)
|
|
|
-const activeId = ref('1')
|
|
|
// 提交函数
|
|
|
-const submit = async (formEl) => {
|
|
|
- // 表单校验拦截
|
|
|
- if (!formEl) return
|
|
|
- await formEl.validate(async (valid, fields) => {
|
|
|
- if (valid) {
|
|
|
- //表单校验成功回调
|
|
|
- console.log('submit!')
|
|
|
-
|
|
|
- // 需动态生成接口
|
|
|
- const { status, msg }: any = await http.Request({
|
|
|
- method: UrlList.kxsConfigServer.apiInfoupdate.method,
|
|
|
- url: UrlList.kxsConfigServer.apiInfoupdate.url,
|
|
|
- params: UpdateForm.value
|
|
|
- });
|
|
|
- if (status === 1) {
|
|
|
- //业务成功回调
|
|
|
- ElMessage({
|
|
|
- message: "修改成功",
|
|
|
- type: "success"
|
|
|
- });
|
|
|
- UpdateForm.value = {
|
|
|
- groupId: "", //分组
|
|
|
- apiName: "", //接口名称
|
|
|
- apiKey: "", //接口关键字
|
|
|
- apiHost: "", //接口主机头
|
|
|
- apiPort: "", //接口端口号
|
|
|
- apiRouter: "", //接口路由
|
|
|
- apiMethod: "", //接口请求方式
|
|
|
-
|
|
|
- };
|
|
|
- // 关闭修改弹窗;
|
|
|
- closeUpdateVisible();
|
|
|
- } else {
|
|
|
- //业务失败回调
|
|
|
- ElMessageBox.alert(msg, "提示", {
|
|
|
- confirmButtonText: "关闭",
|
|
|
- type: "warning"
|
|
|
- });
|
|
|
- }
|
|
|
- } else {
|
|
|
- //表单校验失败回调
|
|
|
- ElMessage({
|
|
|
- message: "请输入完整信息",
|
|
|
- type: "error"
|
|
|
- });
|
|
|
- }
|
|
|
- })
|
|
|
+const submit = async data => {
|
|
|
+ requestEdit(
|
|
|
+ {
|
|
|
+ module: "kxsConfigServer",
|
|
|
+ method: "apiInfoupdate",
|
|
|
+ params: data
|
|
|
+ },
|
|
|
+ props.closeFn
|
|
|
+ );
|
|
|
};
|
|
|
|
|
|
//获取分组数据
|
|
|
const groupIdQuery = async () => {
|
|
|
- const { status, data }: any = await http.Request({ method: UrlList.kxsConfigServer.apiGroupselectList.method, url: UrlList.kxsConfigServer.apiGroupselectList.url, params: { } });
|
|
|
+ const { status, data }: any = await requestSearch({
|
|
|
+ module: "kxsConfigServer",
|
|
|
+ method: "apiGroupselectList",
|
|
|
+ params: {}
|
|
|
+ });
|
|
|
if (status === 1) {
|
|
|
- groupIdOptionList.value = data.records;
|
|
|
+ formData.value.groupId.options = data.records.map(item => {
|
|
|
+ return { value: item.id, label: item.groupName };
|
|
|
+ });
|
|
|
}
|
|
|
};
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-// 表单校验规则
|
|
|
-const rules = reactive({
|
|
|
- apiName: [
|
|
|
- { required: true, message: '请输入接口名称', trigger: 'blur' },
|
|
|
- ],
|
|
|
- apiKey: [
|
|
|
- { required: true, message: '请输入接口关键字', trigger: 'blur' },
|
|
|
- ],
|
|
|
- apiHost: [
|
|
|
- { required: true, message: '请输入接口主机头', trigger: 'blur' },
|
|
|
- ],
|
|
|
- apiPort: [
|
|
|
- { required: true, message: '请输入接口端口号', trigger: 'blur' },
|
|
|
- ],
|
|
|
- apiRouter: [
|
|
|
- { required: true, message: '请输入接口路由', trigger: 'blur' },
|
|
|
- ],
|
|
|
-
|
|
|
-})
|
|
|
-// 关闭弹窗回调函数
|
|
|
-const closeFn: any = inject('closeEditUpdateVisible');
|
|
|
const openVisible = async () => {
|
|
|
- //通过ID获取表格数据
|
|
|
- const { status, data }: any = await http.Request({ method: UrlList.kxsConfigServer.apiInfoquery.method, url: UrlList.kxsConfigServer.apiInfoquery.url, params: { id: props.formData.id }});
|
|
|
+ const { status, data }: any = await requestSearch({
|
|
|
+ module: "kxsConfigServer",
|
|
|
+ method: "apiInfoquery",
|
|
|
+ params: { id: props.formData.id }
|
|
|
+ });
|
|
|
if (status === 1) {
|
|
|
- UpdateForm.value = data;
|
|
|
-
|
|
|
+ for (const key in formData.value) {
|
|
|
+ if (Object.prototype.hasOwnProperty.call(formData.value, key)) {
|
|
|
+ formData.value[key].value = data[key];
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
};
|
|
|
-// 关闭弹窗回调函数
|
|
|
-const closeUpdateVisible = () => {
|
|
|
- UpdateForm.value = {
|
|
|
- groupId: "", //分组
|
|
|
- apiName: "", //接口名称
|
|
|
- apiKey: "", //接口关键字
|
|
|
- apiHost: "", //接口主机头
|
|
|
- apiPort: "", //接口端口号
|
|
|
- apiRouter: "", //接口路由
|
|
|
- apiMethod: "", //接口请求方式
|
|
|
|
|
|
- };
|
|
|
- closeFn();
|
|
|
-};
|
|
|
+// 表单数据
|
|
|
+const formData = ref({
|
|
|
+ groupId: {
|
|
|
+ label: "分组",
|
|
|
+ type: "select",
|
|
|
+ disposition: {},
|
|
|
+ options: [],
|
|
|
+ rules: []
|
|
|
+ },
|
|
|
+ apiName: {
|
|
|
+ label: "接口名称",
|
|
|
+ rules: [{ required: true, message: "请输入接口名称", trigger: "blur" }],
|
|
|
+ type: "input",
|
|
|
+ disposition: {}
|
|
|
+ },
|
|
|
+ apiKey: {
|
|
|
+ label: "接口关键字",
|
|
|
+ rules: [{ required: true, message: "请输入接口关键字", trigger: "blur" }],
|
|
|
+ type: "input",
|
|
|
+ disposition: {}
|
|
|
+ },
|
|
|
+ apiHost: {
|
|
|
+ label: "接口主机头",
|
|
|
+ rules: [{ required: true, message: "请输入接口主机头", trigger: "blur" }],
|
|
|
+ type: "input",
|
|
|
+ disposition: {}
|
|
|
+ },
|
|
|
+ apiPort: {
|
|
|
+ label: "接口主机头",
|
|
|
+ rules: [{ required: true, message: "请输入接口主机头", trigger: "blur" }],
|
|
|
+ type: "input",
|
|
|
+ disposition: {}
|
|
|
+ },
|
|
|
+ apiRouter: {
|
|
|
+ label: "接口路由",
|
|
|
+ rules: [{ required: true, message: "请输入接口路由", trigger: "blur" }],
|
|
|
+ type: "input",
|
|
|
+ disposition: {}
|
|
|
+ }
|
|
|
+});
|
|
|
|
|
|
// 弹窗是否全屏
|
|
|
-const isFullscreen = ref(false)
|
|
|
+const isFullscreen = ref(false);
|
|
|
</script>
|
|
|
|
|
|
<template lang="pug">
|
|
|
.main
|
|
|
el-dialog(v-model='props.editVisible' draggable width="50%" :fullscreen="isFullscreen" title="修改" @close="closeUpdateVisible" @open="openVisible")
|
|
|
- el-form(:model='UpdateForm' label-position="right" ref="ruleFormRef" :rules="rules" label-width="100px")
|
|
|
- el-form-item(label="分组", prop="groupId")
|
|
|
- el-select(
|
|
|
- v-model="UpdateForm.groupId",
|
|
|
- placeholder="请选择分组",
|
|
|
- clearable,
|
|
|
- )
|
|
|
- el-option(:label="item.groupName", :value="item.id" v-for="(item,index) in groupIdOptionList")
|
|
|
- el-form-item(label='接口名称' prop="apiName")
|
|
|
- el-input(v-model='UpdateForm.apiName' autocomplete='off'
|
|
|
- placeholder="请输入接口名称")
|
|
|
- el-form-item(label='接口关键字' prop="apiKey")
|
|
|
- el-input(v-model='UpdateForm.apiKey' autocomplete='off'
|
|
|
- placeholder="请输入接口关键字")
|
|
|
- el-form-item(label='接口主机头' prop="apiHost")
|
|
|
- el-input(v-model='UpdateForm.apiHost' autocomplete='off'
|
|
|
- placeholder="请输入接口主机头")
|
|
|
- el-form-item(label='接口端口号' prop="apiPort")
|
|
|
- el-input-number(v-model='UpdateForm.apiPort' :min="1" :max="1000"
|
|
|
- placeholder="请输入接口端口号")
|
|
|
- el-form-item(label='接口路由' prop="apiRouter")
|
|
|
- el-input(v-model='UpdateForm.apiRouter' autocomplete='off'
|
|
|
- placeholder="请输入接口路由")
|
|
|
- el-form-item(label='接口请求方式' prop="apiMethod")
|
|
|
- el-input(v-model='UpdateForm.apiMethod' autocomplete='off'
|
|
|
- placeholder="请输入接口请求方式")
|
|
|
-
|
|
|
+ omega-form(ref="formRef" :formData="formData" labelPosition="left" labelWidth="100px" size="default" @search="formsubmit" formWidth="!w-[230px]" :searchAll="false" searchText="确认提交")
|
|
|
.flex.justify-end
|
|
|
el-button(
|
|
|
:icon="useRenderIcon(Close)",
|
|
|
- :loading="loading",
|
|
|
- @click="closeUpdateVisible()"
|
|
|
+ @click="closeFn"
|
|
|
) 关闭
|
|
|
- el-button(
|
|
|
- type="primary",
|
|
|
- :icon="useRenderIcon(Upload)",
|
|
|
- @click="submit(ruleFormRef)"
|
|
|
- ) 确认提交
|
|
|
</template>
|
|
|
|
|
|
<style scoped lang="scss">
|