Commit 4a01eb70 by 胡悦

优化

1 parent be35ede5
...@@ -15,6 +15,7 @@ declare global { ...@@ -15,6 +15,7 @@ declare global {
const ElPagination: typeof import('element-plus/es')['ElPagination'] const ElPagination: typeof import('element-plus/es')['ElPagination']
const ElRow: typeof import('element-plus/es')['ElRow'] const ElRow: typeof import('element-plus/es')['ElRow']
const ElSelect: typeof import('element-plus/es')['ElSelect'] const ElSelect: typeof import('element-plus/es')['ElSelect']
const ElSwitch: typeof import('element-plus/es')['ElSwitch']
const ElTable: typeof import('element-plus/es')['ElTable'] const ElTable: typeof import('element-plus/es')['ElTable']
const ElTableColumn: typeof import('element-plus/es')['ElTableColumn'] const ElTableColumn: typeof import('element-plus/es')['ElTableColumn']
} }
......
...@@ -22,6 +22,7 @@ declare module '@vue/runtime-core' { ...@@ -22,6 +22,7 @@ declare module '@vue/runtime-core' {
ElPagination: typeof import('element-plus/es')['ElPagination'] ElPagination: typeof import('element-plus/es')['ElPagination']
ElRow: typeof import('element-plus/es')['ElRow'] ElRow: typeof import('element-plus/es')['ElRow']
ElSelect: typeof import('element-plus/es')['ElSelect'] ElSelect: typeof import('element-plus/es')['ElSelect']
ElSwitch: typeof import('element-plus/es')['ElSwitch']
ElTable: typeof import('element-plus/es')['ElTable'] ElTable: typeof import('element-plus/es')['ElTable']
ElTableColumn: typeof import('element-plus/es')['ElTableColumn'] ElTableColumn: typeof import('element-plus/es')['ElTableColumn']
HelloWorld: typeof import('./src/components/HelloWorld.vue')['default'] HelloWorld: typeof import('./src/components/HelloWorld.vue')['default']
......
...@@ -78,7 +78,11 @@ import "element-plus/theme-chalk/el-message-box.css"; ...@@ -78,7 +78,11 @@ import "element-plus/theme-chalk/el-message-box.css";
import { useRouter, onBeforeRouteLeave } from "vue-router"; import { useRouter, onBeforeRouteLeave } from "vue-router";
import { conditionEdit } from "@/api/condition"; import { conditionEdit } from "@/api/condition";
import { ConditionItem } from "@/type"; import { ConditionItem } from "@/type";
interface OptionType {
label: string;
value: string;
isPro: boolean
}
export default defineComponent({ export default defineComponent({
name: "AddApi", name: "AddApi",
// props: { // props: {
...@@ -96,8 +100,9 @@ export default defineComponent({ ...@@ -96,8 +100,9 @@ export default defineComponent({
const editorName = ref(""); const editorName = ref("");
const editorIp = ref(""); const editorIp = ref("");
const editorEnv = ref(""); const editorEnv = ref("");
const options = ref<{ label: string; value: string }[]>([]); const options = ref<OptionType[]>([]);
options.value = JSON.parse(sessionStorage.getItem("envOption") || "[]"); const allOptions = JSON.parse(sessionStorage.getItem("envOption") || "[]")
// options.value = JSON.parse(sessionStorage.getItem("envOption") || "[]");
//获取路由参数(编辑的情况) //获取路由参数(编辑的情况)
let storageEditItem = let storageEditItem =
...@@ -105,6 +110,10 @@ export default defineComponent({ ...@@ -105,6 +110,10 @@ export default defineComponent({
JSON.parse(window.sessionStorage.getItem("conditionItem") || ""); JSON.parse(window.sessionStorage.getItem("conditionItem") || "");
let routerParams = storageEditItem || {}; let routerParams = storageEditItem || {};
let keysLength = Object.keys(routerParams).length; let keysLength = Object.keys(routerParams).length;
// 过滤生产环境和非生产环境
options.value = allOptions.filter((i: OptionType) => {
return routerParams.id == 1 ? i.isPro : !i.isPro
})
if (keysLength > 0) { if (keysLength > 0) {
//编辑 //编辑
editorContent.value = routerParams.content as string; editorContent.value = routerParams.content as string;
......
...@@ -19,6 +19,9 @@ ...@@ -19,6 +19,9 @@
<template #prepend>/</template> <template #prepend>/</template>
</el-input> </el-input>
</el-form-item> </el-form-item>
<el-form-item label="是否是生产环境" prop="isPro">
<el-switch v-model="ruleForm.isPro" />
</el-form-item>
<el-form-item label="备注" prop="remark"> <el-form-item label="备注" prop="remark">
<el-input v-model="ruleForm.remark" type="textarea" /> <el-input v-model="ruleForm.remark" type="textarea" />
</el-form-item> </el-form-item>
...@@ -64,6 +67,7 @@ export default defineComponent({ ...@@ -64,6 +67,7 @@ export default defineComponent({
const ruleForm = reactive({ const ruleForm = reactive({
name: "", name: "",
addr: "", addr: "",
isPro: false,
remark: "", remark: "",
}); });
...@@ -78,6 +82,7 @@ export default defineComponent({ ...@@ -78,6 +82,7 @@ export default defineComponent({
ruleForm.name = routerParams.name as string; ruleForm.name = routerParams.name as string;
ruleForm.addr = routerParams.addr as string; ruleForm.addr = routerParams.addr as string;
ruleForm.remark = routerParams.remark as string; ruleForm.remark = routerParams.remark as string;
ruleForm.isPro = routerParams.isPro as boolean;
} }
const userInfo = const userInfo =
window.sessionStorage.getItem("userInfo") && window.sessionStorage.getItem("userInfo") &&
......
...@@ -225,15 +225,16 @@ export default defineComponent({ ...@@ -225,15 +225,16 @@ export default defineComponent({
//设置test,develop环境选择 //设置test,develop环境选择
const envOption = rows const envOption = rows
.map((item: ProjectItem) => { .map((item: ProjectItem) => {
let temp = {} as { label: string; value: string }; let temp = {} as { label: string; value: string; isPro: boolean };
temp.value = item.name; temp.value = item.name;
temp.label = item.name; temp.label = item.name;
temp.isPro = item.isPro
return temp; return temp;
}) })
.filter( // .filter(
(item: { label: string; value: string }) => // (item: { label: string; value: string }) =>
item.label !== "production" // item.label !== "production"
); // );
sessionStorage.setItem("envOption", JSON.stringify(envOption)); sessionStorage.setItem("envOption", JSON.stringify(envOption));
//获取条件判断 //获取条件判断
......
...@@ -11,8 +11,8 @@ ...@@ -11,8 +11,8 @@
<div class="rt-content"> <div class="rt-content">
<h3 class="info">接口信息</h3> <h3 class="info">接口信息</h3>
<div class="option"> <div class="option">
<div class="name">method</div> <div class="name">method:get</div>
<div class="wrap"> <!-- <div class="wrap">
<el-select <el-select
v-model="method" v-model="method"
class="m-2" class="m-2"
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
:value="item.value" :value="item.value"
/> />
</el-select> </el-select>
</div> </div> -->
</div> </div>
<div class="option"> <div class="option">
<div class="name">url</div> <div class="name">url</div>
...@@ -57,7 +57,7 @@ ...@@ -57,7 +57,7 @@
<el-button <el-button
type="warning" type="warning"
v-preventReClick v-preventReClick
@click="$router.replace('/project')" @click="$router.go(-1)"
>回到首页</el-button >回到首页</el-button
> >
<!-- <el-button type="danger" @click="clearCodeFn">清空代码</el-button> --> <!-- <el-button type="danger" @click="clearCodeFn">清空代码</el-button> -->
...@@ -87,7 +87,7 @@ export default defineComponent({ ...@@ -87,7 +87,7 @@ export default defineComponent({
const editorContent = ref(""); const editorContent = ref("");
const remark = ref(""); const remark = ref("");
const url = ref(""); const url = ref("");
const method = ref(""); const method = ref("get");
const methodsOptions = [ const methodsOptions = [
{ {
value: "get", value: "get",
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!