Commit c2b34c15 authored by 张俊's avatar 张俊

解决跳转回显等问题

parent 41c1452c
...@@ -3,13 +3,12 @@ ...@@ -3,13 +3,12 @@
<el-config-provider> <el-config-provider>
<bg-menu :path="nowParent ? nowParent[0].path : ''" @openMsg="openMsg"></bg-menu> <bg-menu :path="nowParent ? nowParent[0].path : ''" @openMsg="openMsg"></bg-menu>
<div class="container" v-if="pageShow"> <div class="container" v-if="pageShow">
<!-- <bg-nav :highlightParentRule="highlightParentRule" :title="nowParent.menuName" width="208px" :list="nowParent.children" v-show="navShow" class="con-nav" /> -->
<bg-nav <bg-nav
v-if="nowParent" v-if="nowParent"
:highlightParentRule="highlightParentRule" :highlightParentRule="highlightParentRule"
width="208px" width="208px"
:title="nowParent[0].menuName" :title="nowParent[0].menuName"
:list="nowParent[0].children" :list="dealUrl(nowParent[0].children)"
v-show="navShow" v-show="navShow"
class="con-nav" /> class="con-nav" />
<div class="bg-main view"> <div class="bg-main view">
...@@ -108,6 +107,7 @@ export default { ...@@ -108,6 +107,7 @@ export default {
return { return {
readFlag: false, readFlag: false,
menuIndex: "", menuIndex: "",
dealArr: [],
}; };
}, },
created() { created() {
...@@ -162,7 +162,17 @@ export default { ...@@ -162,7 +162,17 @@ export default {
highlightParentRule(pathArr) { highlightParentRule(pathArr) {
return pathArr.includes(this.$route.path); return pathArr.includes(this.$route.path);
}, },
ada() {}, dealUrl(arr) {
(arr || []).forEach((e) => {
if (e.path.includes("#")) {
e.path = e.path.split("#")[1];
}
if (e.children && e.children.length) {
this.dealUrl(e.children);
}
});
return arr || [];
},
}, },
}; };
</script> </script>
......
...@@ -48,10 +48,34 @@ const props = defineProps({ ...@@ -48,10 +48,34 @@ const props = defineProps({
default: 0, default: 0,
}, },
}); });
const childMenuAction = (item) => { const childMenuAction = (v) => {
// if (isDeveloping(item.path)) return; if (v.menuType !== 1 && v.children && v.children.length) {
// window.open(item.path); for (let index = 0; index < v.children.length; index++) {
const e = v.children[index];
if (e.menuType !== 2) {
pathToUrl(e);
break;
}
}
} else {
pathToUrl(v);
}
};
const pathToUrl = (item) => {
//判断是否是新窗口打开
if (item.new_window) {
window.open(item.sourcePath ? item.sourcePath : item.path, "_blank");
} else {
// 当前窗口打开
if (item.path.indexOf("#") > -1) {
// 携带#说明是其它项目,使用window.location.href
window.location.href = item.path;
} else {
// 不携带#说明是本项目,使用router.push
router.push(item.path); router.push(item.path);
}
}
}; };
</script> </script>
......
...@@ -146,7 +146,7 @@ const getUser = () => { ...@@ -146,7 +146,7 @@ const getUser = () => {
store.commit("setMenuObj", menuObj); store.commit("setMenuObj", menuObj);
// } // }
generateRoutes(); generateRoutes();
router.push("/forewarning/list"); router.push("/");
} }
}); });
}; };
......
...@@ -166,7 +166,7 @@ const getUser = () => { ...@@ -166,7 +166,7 @@ const getUser = () => {
store.commit("setMenuObj", menuObj); store.commit("setMenuObj", menuObj);
// } // }
generateRoutes(); generateRoutes();
router.push("/forewarning/list"); router.push("/");
} }
}); });
}; };
......
...@@ -100,12 +100,13 @@ Promise.all([getUser(), getMenu("1e99371c-187f-4966-94cf-32f116f42ce6")]) ...@@ -100,12 +100,13 @@ Promise.all([getUser(), getMenu("1e99371c-187f-4966-94cf-32f116f42ce6")])
// if (res[0].data.data.userType == 1) {//超管 // if (res[0].data.data.userType == 1) {//超管
store.commit("setMenu", data); store.commit("setMenu", data);
menu.menuToRouter(data); let routeData = JSON.parse(JSON.stringify(data));
store.commit("setRoute", data); menu.menuToRouter(routeData);
store.commit("setRoute", routeData);
//存储菜单对象信息 //存储菜单对象信息
let menuObj = {}; let menuObj = {};
getMenuObj(data, "", menuObj); getMenuObj(routeData, "", menuObj);
store.commit("setMenuObj", menuObj); store.commit("setMenuObj", menuObj);
// } // }
......
<template>
<div class="page_container">
<bg-breadcrumb></bg-breadcrumb>
<div class="page_content flex_cloumn">
<div class="content_top apaas_scroll">
<div class="content_main">
<systemForm
ref="systemFormRef"
:form-type="route.query.id ? true : false"
:id="route.query.id"
@action="getSystemFormData"></systemForm>
</div>
</div>
<div class="content_bottom">
<div>
<el-button @click="cancel">取消</el-button>
<el-button type="primary" @click="submit">保存</el-button>
</div>
</div>
</div>
</div>
</template>
<script setup>
import { useRoute, useRouter } from "vue-router";
import systemForm from "./system-form.vue";
import { reactive, ref, onBeforeUnmount, onMounted } from "vue";
import axios from "@/request/http.js";
import CryptoJS from "crypto-js";
import { ElMessage } from "element-plus";
import bgBreadcrumb from "@/components/bg-breadcrumb.vue";
const route = useRoute();
const router = useRouter();
const systemFormRef = ref(null);
//业务系统表单
const formData = reactive({
organization_id: "",
business_code: "",
business_name: "",
business_desc: "",
logo: "",
system_role_id: "",
system_account: "",
system_phone: "",
password: "",
confirm_password: "",
access_address: "",
develop_id: "",
state: 1,
});
//业务系统表单检验触发事件 data为null 校验失败
const getSystemFormData = (data) => {
if (data) {
Object.assign(formData, data);
} else {
}
};
//提交表单
const submit = () => {
systemFormRef.value.validateForm().then((res) => {
if (!res) return;
if (route.query.id) {
let params = {
...systemFormRef.value.systemForm,
logo:
systemFormRef.value.systemForm.logo && systemFormRef.value.systemForm.logo.length > 0
? systemFormRef.value.systemForm.logo[0].url
: "",
};
axios.put(`/v1/api/user/${route.query.id}`, params).then((res) => {
if (res.data.code == 200) {
ElMessage.success(res.data.msg);
cancel();
} else {
ElMessage.error(res.data.data);
}
});
} else {
let params = {
...systemFormRef.value.systemForm,
logo:
systemFormRef.value.systemForm.logo && systemFormRef.value.systemForm.logo.length > 0
? systemFormRef.value.systemForm.logo[0].url
: "",
password: CryptoJS.AES.encrypt(systemFormRef.value.systemForm.password, "swuE9cmCZQwrkYRV").toString(),
};
delete params.confirm_password;
axios.post(`/v1/api/user/add`, params).then((res) => {
if (res.data.code == 200) {
ElMessage.success(res.data.msg);
cancel();
} else {
ElMessage.error(res.data.data);
}
});
}
});
};
//取消
const cancel = () => {
router.push({
path: "/authority/user",
query: {
organization_id: systemFormRef.value.systemForm.organization_id,
},
});
};
const getDetail = () => {
axios.get(`/v1/api/user/${route.query.id}`).then((res) => {
if (res.data.code == 200) {
const form = res.data.data;
systemFormRef.value.setForm({
organization_id: form.organization_id,
select_role: form.system_role,
logo: form.logo ? [{ url: form.logo }] : [],
name: form.name,
system_account: form.system_account,
phone: form.phone,
state: form.state,
});
} else {
ElMessage.error(res.data.data);
}
});
};
onBeforeUnmount(() => {});
onMounted(() => {
if (route.query.id) {
getDetail();
}
});
</script>
<style scoped>
.flex_cloumn {
display: flex;
flex-direction: column;
}
.content_top {
flex: 1;
display: flex;
flex-direction: column;
overflow: auto;
}
/* .content_top::-webkit-scrollbar {
width: 5px;
height: 0px;
}
.content_top::-webkit-scrollbar-thumb {
background: #dedede;
border-radius: 10px;
height: 0px;
}
.content_top::-webkit-scrollbar-track {
background: transparent;
border-radius: 2px;
} */
.content_bottom {
height: 68px;
line-height: 68px;
text-align: right;
padding: 0 20px;
border-top: 1px solid #e6e9ef;
}
.content_process {
border-bottom: 1px solid #e6e9ef;
padding: 38px 16%;
}
.content_main {
flex: 1;
padding: 30px;
box-sizing: border-box;
}
.process_desc {
background-color: #fff;
display: inline-block;
position: absolute;
padding: 0 5px;
font-size: 18px;
color: #202531;
font-weight: bold;
}
.process_desc img {
height: 25px;
width: 25px;
vertical-align: middle;
}
.process_end {
height: 100%;
display: flex;
justify-content: center;
align-items: center;
}
.process_end div {
text-align: center;
}
.step_icon {
color: #fff;
font-weight: 600;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.icon_box {
display: inline-block;
background-color: #2b4695;
width: 48px;
height: 48px;
border-radius: 99px;
position: relative;
border: 3px solid #b0bee8;
vertical-align: middle;
}
.circle {
display: inline-block;
background-color: #a9b1c7;
width: 24px;
height: 24px;
border-radius: 99px;
position: relative;
border: 4px solid #e6e9ef;
vertical-align: middle;
}
.content_process :deep() .el-step.is-horizontal .el-step__line {
height: 4px;
}
.content_process :deep() .el-step__head.is-finish .el-step__line {
background: linear-gradient(to right, #2b4695 50%, #e6e9ef 50%);
}
.process_complete :deep() .el-step__head.is-finish .el-step__line {
background: linear-gradient(to right, #2b4695 100%, #e6e9ef 0%);
}
</style>
<template>
<el-form
:label-position="'right'"
label-width="120px"
:model="systemForm"
:rules="formRules"
ref="systemRef"
style="max-width: 66%">
<el-form-item label="所属组织" prop="organization_id">
<el-tree-select
v-model="systemForm.organization_id"
:data="orgData"
:props="treeProps"
:render-after-expand="false"
:disabled="formType"
style="width: 100%" />
</el-form-item>
<el-form-item label="姓名" prop="name">
<el-input v-model="systemForm.name" />
</el-form-item>
<el-form-item label="头像" prop="logo">
<bg-upload-image
v-model="systemForm.logo"
:showTips="true"
:limit="1"
:fileSize="500"
:fileSizeUnit="'KB'"
listType="picture-card"
:accept="['.jpg', '.jpeg', '.png']"
customTips="请选择图片上传:大小120 * 120像素支持jpg、png等格式,图片需小于500KB"></bg-upload-image>
</el-form-item>
<el-form-item label="角色" prop="select_role">
<el-select v-model="systemForm.select_role" multiple placeholder="请选择角色" style="width: 100%">
<el-option v-for="item in roleList" :key="item.role_id" :label="item.role_name" :value="item.role_id" />
</el-select>
</el-form-item>
<el-form-item label="账号" prop="system_account">
<el-input v-model="systemForm.system_account" />
</el-form-item>
<el-form-item label="手机号" prop="phone">
<el-input v-model="systemForm.phone" />
</el-form-item>
<el-form-item v-if="!formType" label="密码" prop="password">
<el-input :type="password_eye ? 'text' : 'password'" v-model="systemForm.password">
<template #suffix>
<bg-icon @click="password_eye = !password_eye" class="icon_eye" icon="#bg-ic-eye"></bg-icon>
</template>
</el-input>
</el-form-item>
<el-form-item v-if="!formType" label="确认密码" prop="confirm_password">
<el-input :type="confirm_eye ? 'text' : 'password'" v-model="systemForm.confirm_password">
<template #suffix>
<bg-icon @click="confirm_eye = !confirm_eye" class="icon_eye" icon="#bg-ic-eye"></bg-icon>
</template>
</el-input>
</el-form-item>
<el-form-item label="是否启用" prop="state">
<bg-switch :labels="['否', '是']" :values="[0, 1]" v-model="systemForm.state"></bg-switch>
</el-form-item>
</el-form>
</template>
<script setup>
import { reactive, ref, onBeforeMount, onMounted, watch } from "vue";
import axios from "@/request/http.js";
import { ElMessage } from "element-plus";
import { validatePhone } from "@/services/rules.js";
const props = defineProps({
formType: {
type: Boolean,
default: false, //false 新增 true 编辑
},
});
const systemForm = reactive({
organization_id: "",
name: "",
logo: [],
select_role: [],
system_account: "",
phone: "",
password: "",
confirm_password: "",
state: 1,
});
const password_eye = ref(false);
const confirm_eye = ref(false);
const validatePass = (rule, value, callback) => {
if (value !== systemForm.password) {
callback(new Error("密码输入不一致"));
} else {
callback();
}
};
const formRules = reactive({
organization_id: [{ required: true, message: "请选择组织", trigger: "change" }],
name: [
{ required: true, message: "请输入姓名", trigger: "blur" },
{ max: 50, message: "姓名最大长度为50个字符", trigger: "blur" },
],
select_role: [{ required: true, type: "array", message: "请选择角色", trigger: "change" }],
system_account: [
{ required: true, message: "请输入账号", trigger: "blur" },
{ min: 4, message: "帐号长度不得低于4个字符", trigger: "blur" },
{ max: 20, message: "帐号最大长度为20个字符", trigger: "blur" },
],
phone: [
{ required: true, message: "请输入账号", trigger: "blur" },
{ validator: validatePhone, trigger: "blur" },
],
password: [
{ required: true, message: "请输入密码", trigger: "blur" },
{ min: 8, message: "密码长度不得低于8位", trigger: "blur" },
],
confirm_password: [
{ required: true, message: "请确认密码", trigger: "blur" },
{ validator: validatePass, trigger: "blur" },
],
});
const systemRef = ref(null);
const roleList = ref([]);
watch(
() => systemForm.organization_id,
(val) => {
getRoleList(val);
}
);
const setForm = (data) => {
Object.assign(systemForm, data);
};
const orgData = ref([]);
const treeProps = {
label: "name",
children: "Child",
value: "organization_id",
};
const getOrgTree = () => {
axios.get(`/v1/api/org/tree`).then((res) => {
if (res.data.code == 200) {
const orgDataTemp = res.data.data || [];
orgData.value = orgDataTemp;
} else {
ElMessage.error(res.data.data);
}
});
};
const getRoleList = (oid) => {
axios.get(`/v1/api/user/select/role`, { params: { oid } }).then((res) => {
if (res.data.code == 200) {
roleList.value = res.data.data;
} else {
ElMessage.error(res.data.data);
}
});
};
const validateForm = () => {
return new Promise((resolve, reject) => {
systemRef.value.validate((res) => resolve(res));
});
};
onBeforeMount(() => {
getOrgTree();
});
onMounted(() => {});
defineExpose({ systemForm, setForm, validateForm });
</script>
...@@ -71,6 +71,11 @@ export default { ...@@ -71,6 +71,11 @@ export default {
changeOrigin: true, // true/false, Default: false - changes the origin of the host header to the target URL changeOrigin: true, // true/false, Default: false - changes the origin of the host header to the target URL
secure: false, //解决证书缺失问题 secure: false, //解决证书缺失问题
}, },
"/aiops/systemmonitor/ui/": {
target: "https://xc-cloud.dev.wodcloud.com/", // 所要代理的目标地址
changeOrigin: true, // true/false, Default: false - changes the origin of the host header to the target URL
secure: false, //解决证书缺失问题
},
}, },
}, },
build: { build: {
......
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