Commit 6457b753 by luyt

feat:1.调整环境逻辑判断的内容格式,调整逻辑判断

2.新增项目环境判断名称编辑功能
3.添加手动插入ip地址,选择环境功能
4.建立环境判断中的,以模块名建立对应的映射关系,读取相应的模块的相应环境配置
1 parent c2dfb6e4
import request from "@/api/request";
import qs from "qs";
const serverUrl = {
config: "/glsxAdmin/config",
};
export const getConfig = () => {
return request.get(serverUrl.config);
export const getConfig = (params: { moduleUrl: string }) => {
return request.get(serverUrl.config + "?" + qs.stringify(params));
};
......@@ -7,7 +7,7 @@
</template>
<script lang="ts">
import { defineComponent, onMounted, PropType, ref } from "vue";
import { defineComponent, nextTick, onMounted, PropType, ref } from "vue";
export default defineComponent({
name: "AceEditor",
props: {
......@@ -49,10 +49,18 @@ export default defineComponent({
);
};
winHeight.value = getViewPortHeight();
// 设置web编辑器内容
const setEditorContent = () => {
// console.log(editorRef.value);
nextTick(() => {
editorRef.value.setValue(props.content);
});
};
expose({
codeFormat,
getCode,
setValue,
setEditorContent,
});
onMounted(() => {
......@@ -92,10 +100,9 @@ export default defineComponent({
// console.log(delta);
getCode();
});
//设置web编辑器内容
setEditorContent();
}
//设置web编辑器内容
// console.log(editorRef.value);
editorRef.value.setValue(props.content);
});
return {
......
......@@ -6,13 +6,49 @@
<div class="rt-content">
<h3 class="info">项目环境判断条件</h3>
<div class="option">
<div class="name">要插入的ip</div>
<div class="wrap">
<el-input v-model="editorIp" placeholder="请输入ip"> </el-input>
</div>
</div>
<div class="option">
<div class="name">要添加的环境</div>
<div class="wrap">
<el-select v-model="editorEnv" class="m-2" placeholder="请选择名称">
<el-option
v-for="item in options"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</div>
</div>
<div class="option">
<div class="name">操作</div>
<div class="wrap">
<el-button type="primary" @click="addToEditor"
>添加到编辑器</el-button
>
</div>
</div>
<div class="option">
<div class="name">名称</div>
<div class="wrap">
<el-input v-model="editorName" placeholder="请输入名称"> </el-input>
</div>
</div>
<div class="option">
<div class="name">操作</div>
<div class="wrap">
<el-button type="primary" @click="beautifulCodeFn"
>美化代码</el-button
>
<el-button type="info" @click="saveCodeFn">保存代码</el-button>
<el-button type="danger" @click="clearCodeFn">清空代码</el-button>
<!-- <el-button type="danger" @click="clearCodeFn">清空代码</el-button> -->
<el-button type="warning" @click="$router.push('/')"
>回到首页</el-button
>
</div>
</div>
</div>
......@@ -32,12 +68,23 @@ import { ConditionItem } from "@/type";
export default defineComponent({
name: "AddApi",
// props: {
// options: {
// type: Array as PropType<{ label: string; value: string }[]>,
// default: () => [],
// },
// },
setup() {
//获取路由对象
// const route = useRoute();
const editorDom = ref();
const editorContent = ref("123");
const editorContent = ref("");
const editorName = ref("");
const editorIp = ref("");
const editorEnv = ref("");
const options = ref<{ label: string; value: string }[]>([]);
options.value = JSON.parse(sessionStorage.getItem("envOption") || "[]");
//获取路由参数(编辑的情况)
let storageEditItem =
......@@ -48,6 +95,7 @@ export default defineComponent({
if (keysLength > 0) {
//编辑
editorContent.value = routerParams.content as string;
editorName.value = routerParams.name as string;
}
// 格式化代码
......@@ -73,8 +121,9 @@ export default defineComponent({
...routerParams,
id: parseInt(routerParams.id as string),
content: editorContent.value,
name: editorName.value,
} as ConditionItem;
console.log("params: ", params);
// console.log("params: ", params);
let { code } = await conditionEdit(params);
if (code === 200) {
requestAnimationFrame(() => {
......@@ -117,16 +166,31 @@ export default defineComponent({
});
});
};
//添加到编辑器内容区
const addToEditor = () => {
const contentObj = eval("(" + editorContent.value + ")");
editorContent.value = JSON.stringify({
...contentObj,
[editorIp.value]: editorEnv.value,
});
editorDom.value.setEditorContent();
};
// watch(editorContent, (newVal, prevCount) => {
// console.log("newVal: ", newVal);
// // console.log("prevCount: ", prevCount);
// });
return {
editorContent,
editorName,
editorDom,
editorIp,
beautifulCodeFn,
saveCodeFn,
clearCodeFn,
addToEditor,
editorEnv,
options,
};
},
components: {
......
......@@ -14,8 +14,10 @@
<el-form-item label="名称" prop="name">
<el-input v-model="ruleForm.name" />
</el-form-item>
<el-form-item label="addr" prop="addr">
<el-input v-model="ruleForm.addr" />
<el-form-item label="moduleUrl(url)" prop="addr">
<el-input v-model="ruleForm.addr">
<template #prepend>/</template>
</el-input>
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input v-model="ruleForm.remark" type="textarea" />
......
......@@ -60,7 +60,8 @@
<div style="padding: 14px">
<span>项目环境:{{ item.name }}</span>
<div class="bottom">
<el-button
<el-button type="text" class="button">查看</el-button>
<!-- <el-button
type="text"
class="button"
@click.stop="editConditionFn(item)"
......@@ -71,7 +72,7 @@
class="button"
@click.stop="deleteConditionFn(item)"
>删除</el-button
>
> -->
</div>
</div>
</el-card>
......@@ -90,7 +91,7 @@ import "element-plus/theme-chalk/el-message.css";
import "element-plus/theme-chalk/el-message-box.css";
import { getProjectList, projectDel } from "@/api/project";
import { getConfig } from "@/api/config";
import { getConditionList } from "@/api/condition";
import { getConditionList, conditionEdit } from "@/api/condition";
import { ProjectItem, ConditionItem } from "@/type/index";
interface DataType {
......@@ -179,14 +180,16 @@ export default defineComponent({
};
//项目环境判断
const editConditionFn = (item: ConditionItem) => {
const editConditionFn = async (item: ConditionItem) => {
console.log("item: ", item);
const res = await conditionEdit(item);
console.log("res: ", res);
};
const deleteConditionFn = (item: ConditionItem) => {
console.log("item: ", item);
};
const goToEdit = (item: ConditionItem) => {
console.log("item: ", item);
// console.log("item: ", item);
router.push({
name: "conditioneditor",
});
......@@ -201,6 +204,14 @@ export default defineComponent({
if (code === 200) {
state.projectList = rows;
}
//设置test,develop环境选择
const envOption = rows.map((item: ProjectItem) => {
let temp = {} as { label: string; value: string };
temp.value = item.name;
temp.label = item.name;
return temp;
});
sessionStorage.setItem("envOption", JSON.stringify(envOption));
//获取条件判断
let res = await getConditionList();
if (res.code === 200) {
......@@ -208,7 +219,8 @@ export default defineComponent({
}
//获取config
let result = await getConfig();
let params = { moduleUrl: "base" };
let result = await getConfig(params);
console.log("result: ", result);
};
getData();
......
......@@ -43,7 +43,10 @@
>美化代码</el-button
>
<el-button type="info" @click="saveCodeFn">保存代码</el-button>
<el-button type="danger" @click="clearCodeFn">清空代码</el-button>
<el-button type="warning" @click="$router.push('/')"
>回到首页</el-button
>
<!-- <el-button type="danger" @click="clearCodeFn">清空代码</el-button> -->
</div>
</div>
</div>
......@@ -127,6 +130,7 @@ export default defineComponent({
try {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const contentObj = eval("(" + editorContent.value + ")");
console.log("contentObj: ", contentObj);
//发起请求
if (queryKeysLength > 0) {
//新增
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!