lcw
This commit is contained in:
@ -620,7 +620,7 @@ export const idCardNoLogin = (data) => {
|
||||
method: "POST",
|
||||
data
|
||||
});
|
||||
}
|
||||
};
|
||||
// 通过身份证号获取会话信息
|
||||
export const getSessionForSfzh = (params) => {
|
||||
return request({
|
||||
@ -636,7 +636,7 @@ export const idCardNoLoginPcs = (data) => {
|
||||
method: "POST",
|
||||
data
|
||||
});
|
||||
}
|
||||
};
|
||||
// 通过身份证号获取会话信息
|
||||
export const getSessionForSfzhPcs = (params) => {
|
||||
return request({
|
||||
|
||||
@ -1,8 +1,19 @@
|
||||
<template>
|
||||
<el-menu class="el-menu-vertical-demo" :collapse="!$store.getters.sidebarOpened" :default-active="activeMenu"
|
||||
:unique-opened="true" background-color="rgba(0, 0, 0, 0)" :text-color="$store.getters.cssVar.menuText"
|
||||
:active-text-color="$store.getters.cssVar.menuActiveText" router>
|
||||
<SideBarItem v-for="item in routes" :key="item.path" :route="item"></SideBarItem>
|
||||
<el-menu
|
||||
class="el-menu-vertical-demo"
|
||||
:collapse="!$store.getters.sidebarOpened"
|
||||
:default-active="activeMenu"
|
||||
:unique-opened="true"
|
||||
background-color="rgba(0, 0, 0, 0)"
|
||||
:text-color="$store.getters.cssVar.menuText"
|
||||
:active-text-color="$store.getters.cssVar.menuActiveText"
|
||||
router
|
||||
>
|
||||
<SideBarItem
|
||||
v-for="item in routes"
|
||||
:key="item.path"
|
||||
:route="item"
|
||||
></SideBarItem>
|
||||
</el-menu>
|
||||
</template>
|
||||
|
||||
@ -11,27 +22,62 @@ import { computed } from "vue";
|
||||
import { useRouter, useRoute } from "vue-router";
|
||||
import { useStore } from "vuex";
|
||||
import { filterRoutes, generateMenus } from "@/utils/route";
|
||||
import { getItem } from "@/utils/storage";
|
||||
import SideBarItem from "./SideBarItem.vue";
|
||||
const store = useStore();
|
||||
const router = useRouter();
|
||||
const EXCLUDE_NAMES = [
|
||||
"warningLists",
|
||||
"behaviorWarnings",
|
||||
"identityWarnings",
|
||||
"combinedWarnings",
|
||||
"DeploymentAreas",
|
||||
"mpvPeos",
|
||||
"myControls"
|
||||
];
|
||||
const filterRoutesByMenusPermission = (routes, menusSet) => {
|
||||
return routes.reduce((result, route) => {
|
||||
const children = Array.isArray(route.children)
|
||||
? filterRoutesByMenusPermission(route.children, menusSet)
|
||||
: [];
|
||||
const routeName = route.name ? `${route.name}` : "";
|
||||
const selfMatched = routeName && menusSet.has(routeName);
|
||||
if (selfMatched || children.length > 0) {
|
||||
result.push({ ...route, children });
|
||||
}
|
||||
return result;
|
||||
}, []);
|
||||
};
|
||||
const routes = computed(() => {
|
||||
const fRoutes = filterRoutes(router.getRoutes());
|
||||
const data = fRoutes.filter((item) => !EXCLUDE_NAMES.includes(item.name));
|
||||
const menusPermission = getItem("menusPermission");
|
||||
console.log(JSON.parse(localStorage.getItem("menusPermission")));
|
||||
console.log(
|
||||
router.getRoutes().map((r) => ({ name: r.name, path: r.path })),
|
||||
"xxx"
|
||||
);
|
||||
// menusPermission 里存的 name
|
||||
router
|
||||
.getRoutes()
|
||||
.filter((r) => r.path === "/")
|
||||
.map((r) => ({
|
||||
name: r.name,
|
||||
path: r.path,
|
||||
children: r.children?.map((c) => ({ name: c.name, path: c.path }))
|
||||
}));
|
||||
console.log(JSON.parse(localStorage.getItem("menusPermission")));
|
||||
const menusSet = new Set(
|
||||
Array.isArray(menusPermission)
|
||||
? menusPermission.map((item) => `${item}`)
|
||||
: []
|
||||
);
|
||||
console.log(menusSet);
|
||||
|
||||
const data = fRoutes.filter(item => {
|
||||
if (item.name != "warningLists"
|
||||
&& item.name != "behaviorWarnings"
|
||||
&& item.name != "identityWarnings"
|
||||
&& item.name != "combinedWarnings"
|
||||
&& item.name != "DeploymentAreas"
|
||||
&& item.name != "mpvPeos"
|
||||
&& item.name != "myControls") {
|
||||
return item;
|
||||
}
|
||||
}
|
||||
)
|
||||
console.log(data);
|
||||
|
||||
return generateMenus(data);
|
||||
const permissionFiltered = menusSet.size
|
||||
? filterRoutesByMenusPermission(data, menusSet)
|
||||
: data;
|
||||
return generateMenus(permissionFiltered);
|
||||
});
|
||||
if (!store.getters.token) {
|
||||
router.push("/login");
|
||||
|
||||
@ -15,10 +15,9 @@
|
||||
node-key="id"
|
||||
show-checkbox
|
||||
default-expand-all
|
||||
:check-strictly="true"
|
||||
@check="checkeTree"
|
||||
:check-strictly="false"
|
||||
@check="handleCheck"
|
||||
/>
|
||||
|
||||
</div>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
@ -32,7 +31,7 @@
|
||||
|
||||
<script setup>
|
||||
import { ElMessage } from "element-plus";
|
||||
import { defineProps, watch, ref, onMounted, nextTick } from "vue";
|
||||
import { defineProps, watch, ref } from "vue";
|
||||
import {
|
||||
saveRoleMenuInfo,
|
||||
getRoleMenuIds,
|
||||
@ -48,17 +47,31 @@ const props = defineProps({
|
||||
required: true
|
||||
}
|
||||
});
|
||||
const form = ref({});
|
||||
|
||||
const emits = defineEmits(["update:modelValue", "updateRole"]);
|
||||
const closed = () => {
|
||||
emits("update:modelValue", false);
|
||||
};
|
||||
|
||||
// 实时记录选中状态
|
||||
const currentCheckedKeys = ref([]);
|
||||
const currentHalfCheckedKeys = ref([]);
|
||||
|
||||
// 勾选事件,实时记录完全选中 + 半选父节点
|
||||
const handleCheck = (data, checkInfo) => {
|
||||
currentCheckedKeys.value = checkInfo.checkedKeys;
|
||||
currentHalfCheckedKeys.value = checkInfo.halfCheckedKeys;
|
||||
};
|
||||
|
||||
// 提交时合并完全选中 + 半选父节点
|
||||
const onComfirm = () => {
|
||||
const checkedKeys = treeRef.value.getCheckedKeys();
|
||||
const halfCheckedKeys = treeRef.value.getHalfCheckedKeys();
|
||||
const submitKeys = [...checkedKeys, ...halfCheckedKeys];
|
||||
|
||||
let params = {
|
||||
roleId: Number(props.roleId),
|
||||
menuIds: treeRef.value.getCheckedKeys().map((item) => Number(item))
|
||||
menuIds: submitKeys.map((item) => Number(item))
|
||||
};
|
||||
saveRoleMenuInfo(params).then((res) => {
|
||||
ElMessage.success("操作成功");
|
||||
@ -69,41 +82,23 @@ const onComfirm = () => {
|
||||
//所有权限
|
||||
const allPermission = ref([]);
|
||||
const getPermissionList = async () => {
|
||||
const res = await getMenuTree({ssxt:'sgxt'});
|
||||
const res = await getMenuTree({ ssxt: "sgxt" });
|
||||
allPermission.value = res;
|
||||
};
|
||||
getPermissionList();
|
||||
|
||||
const treeRef = ref(null);
|
||||
//属性结构配置
|
||||
const defaultProps = {
|
||||
children: "sysMenuList",
|
||||
label: "menuName"
|
||||
};
|
||||
//当前角色权限
|
||||
|
||||
//当前角色权限回显
|
||||
const getRolePermission = async () => {
|
||||
const checkedKeys = await getRoleMenuIds(props.roleId);
|
||||
treeRef.value.setCheckedKeys(checkedKeys);
|
||||
};
|
||||
|
||||
// 选中子节点,默认选中父节点
|
||||
const checkeTree = (data) => {
|
||||
let thisNode = treeRef.value.getNode(data.id); // 获取当前节点
|
||||
const keys = treeRef.value.getCheckedKeys(); // 获取已勾选节点的key值
|
||||
if (thisNode.checked) {
|
||||
// 当前节点若被选中
|
||||
for (let i = thisNode.level; i > 1; i--) {
|
||||
// 判断是否有父级节点
|
||||
if (!thisNode.parent.checked) {
|
||||
// 父级节点未被选中,则将父节点替换成当前节点,往上继续查询,并将此节点key存入keys数组
|
||||
thisNode = thisNode.parent;
|
||||
// keys.push(thisNode.data.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
treeRef.value.setCheckedKeys(keys); // 将所有keys数组的节点全选中
|
||||
};
|
||||
|
||||
watch(
|
||||
() => props.roleId,
|
||||
(val) => {
|
||||
|
||||
@ -294,7 +294,7 @@ const dialogFormVisible = ref(false);
|
||||
const formLabelWidth = "140px";
|
||||
// 获取数据的方法
|
||||
const getListData = async () => {
|
||||
const params = listQuery.value;
|
||||
const params = { ...listQuery.value, ssxt: "sgxt" };
|
||||
params.current = params.page;
|
||||
const res = await getRoleList(params);
|
||||
tableData.value = res?.records;
|
||||
@ -360,7 +360,8 @@ const onSave = () => {
|
||||
}
|
||||
buttonLoading.value = true;
|
||||
updateSysRole({
|
||||
...dialogForm.value
|
||||
...dialogForm.value,
|
||||
ssxt: "sgxt"
|
||||
})
|
||||
.then((res) => {
|
||||
dialogFormVisible.value = false;
|
||||
@ -382,7 +383,8 @@ const onAdd = () => {
|
||||
}
|
||||
buttonLoading.value = true;
|
||||
addSysRole({
|
||||
...dialogForm.value
|
||||
...dialogForm.value,
|
||||
ssxt: "sgxt"
|
||||
})
|
||||
.then((res) => {
|
||||
dialogFormVisible.value = false;
|
||||
|
||||
@ -3,19 +3,28 @@
|
||||
<!-- <el-checkbox-group v-model="userRoleTitleList">
|
||||
<el-checkbox v-for="item in allRoleList" :key="item.id" :label="item.roleName" />
|
||||
</el-checkbox-group>-->
|
||||
<el-table max-height="380px" ref="multipleTableRef" :data="allRoleList" style="width: 100%"
|
||||
@selection-change="handleSelectionChange">
|
||||
<el-table
|
||||
max-height="380px"
|
||||
ref="multipleTableRef"
|
||||
:data="allRoleList"
|
||||
style="width: 100%"
|
||||
@selection-change="handleSelectionChange"
|
||||
>
|
||||
<el-table-column type="selection" width="55" />
|
||||
<el-table-column property="orderNo" label="角色编号" />
|
||||
<el-table-column property="roleName" label="角色名称" />
|
||||
<el-table-column prop="xtZhxgsj" label="更新时间">
|
||||
<template #default="{ row }">{{ $filters.dateFilter(row.xtZhxgsj) }}</template>
|
||||
<template #default="{ row }">{{
|
||||
$filters.dateFilter(row.xtZhxgsj)
|
||||
}}</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button @click="closed">取消</el-button>
|
||||
<el-button type="primary" :loading="buttonLoading" @click="onComfirm">保存</el-button>
|
||||
<el-button type="primary" :loading="buttonLoading" @click="onComfirm"
|
||||
>保存</el-button
|
||||
>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
@ -39,13 +48,13 @@ const props = defineProps({
|
||||
required: true
|
||||
}
|
||||
});
|
||||
const buttonLoading = ref(false)
|
||||
const buttonLoading = ref(false);
|
||||
const emits = defineEmits(["update:modelValue", "updateRole"]);
|
||||
const closed = () => {
|
||||
emits("update:modelValue", false);
|
||||
};
|
||||
|
||||
const multipleTableRef = ref(null)
|
||||
const multipleTableRef = ref(null);
|
||||
|
||||
const multipleSelection = ref([]);
|
||||
const handleSelectionChange = (val) => {
|
||||
@ -83,30 +92,31 @@ const getUserRoles = async () => {
|
||||
const res = await getUserRoleList(Number(props.userId));
|
||||
userRoleTitleList.value = res.map((item) => item.id);
|
||||
const hx = [];
|
||||
allRoleList.value.forEach(item => {
|
||||
allRoleList.value.forEach((item) => {
|
||||
if (userRoleTitleList.value.includes(item.id)) {
|
||||
hx.push(item)
|
||||
hx.push(item);
|
||||
}
|
||||
})
|
||||
toggleSelection(hx)
|
||||
});
|
||||
toggleSelection(hx);
|
||||
};
|
||||
|
||||
const toggleSelection = (rows) => {
|
||||
if (rows) {
|
||||
rows.forEach((row) => {
|
||||
multipleTableRef.value.toggleRowSelection(row, true)
|
||||
})
|
||||
multipleTableRef.value.toggleRowSelection(row, true);
|
||||
});
|
||||
} else {
|
||||
multipleTableRef.value.clearSelection()
|
||||
}
|
||||
multipleTableRef.value.clearSelection();
|
||||
}
|
||||
};
|
||||
|
||||
//所有角色
|
||||
const allRoleList = ref([]);
|
||||
const getAllRoleList = async () => {
|
||||
const params = {
|
||||
page: 1,
|
||||
size: 999
|
||||
size: 999,
|
||||
ssxt: "sgxt"
|
||||
};
|
||||
const res = await getRoleList(params);
|
||||
allRoleList.value = res?.records;
|
||||
@ -123,5 +133,4 @@ watch(
|
||||
);
|
||||
</script>
|
||||
|
||||
<style>
|
||||
</style>
|
||||
<style></style>
|
||||
|
||||
@ -8,9 +8,9 @@ function resolve(dir) {
|
||||
// const serverHost = "http://192.168.2.206:8006"//线上
|
||||
// const serverHost = "http://192.168.191.75:8006"//周
|
||||
// const serverHost = "http://192.168.212.75:8016"//周
|
||||
// const serverHost = "http://192.168.1.98:8006"//毛毛
|
||||
const serverHost = "http://192.168.1.162:8006"; //毛毛
|
||||
// const serverHost = "http:// 192.168.1.45:8006"; //线上
|
||||
const serverHost = "http://47.108.232.77:9537"; //线上
|
||||
// const serverHost = "http://47.108.232.77:9537"; //线上
|
||||
module.exports = {
|
||||
// configureWebpack: {
|
||||
// resolve: {
|
||||
|
||||
Reference in New Issue
Block a user