|
|
|
@ -9,6 +9,7 @@ import { storeToRefs } from "pinia" |
|
|
|
const adminStore = useAdminStore(); |
|
|
|
const { adminData, menuTree } = storeToRefs(adminStore); |
|
|
|
import { permissionMapping, findMenuById } from "@/utils/menuTreePermission.js" |
|
|
|
import { tr } from 'element-plus/es/locales.mjs' |
|
|
|
|
|
|
|
// 表单验证ref |
|
|
|
const Ref = ref(null) |
|
|
|
@ -35,7 +36,7 @@ const addRole = ref({ |
|
|
|
market: '' |
|
|
|
}) |
|
|
|
const addRoleMarket = ref([]) |
|
|
|
|
|
|
|
const channelList = ref(['美股', '港股', 'hc第一频道']) |
|
|
|
const getRoleList = async function (val) { |
|
|
|
if (!findMenuById(menuTree.value, permissionMapping.view_role_information)) { |
|
|
|
ElMessage.error('无此权限') |
|
|
|
@ -196,7 +197,8 @@ const handleAddRole = async function () { |
|
|
|
"roleName": addRole.value.roleName, |
|
|
|
"menuIds": finalCheckedKeys, |
|
|
|
"fatherId": addRole.value.parentId, |
|
|
|
"market": addRole.value.market |
|
|
|
"market": addRole.value.market, |
|
|
|
channel: addRole.value.channel |
|
|
|
} |
|
|
|
}) |
|
|
|
if (res.code === 200) { |
|
|
|
@ -317,6 +319,7 @@ const handleEditRolePermissionCheck = (checkedNodes, checkedInfo) => { |
|
|
|
// 判断是否有选中的节点 |
|
|
|
if (allCheckedNodes.length === 0) { |
|
|
|
permissionEditRoleObj.value.checkedKeys = [] |
|
|
|
ifHasChannel.value = false |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
@ -326,13 +329,22 @@ const handleEditRolePermissionCheck = (checkedNodes, checkedInfo) => { |
|
|
|
|
|
|
|
console.log('编辑角色选中的权限ID:', checkedKeys) |
|
|
|
console.log('选中的节点数量:', allCheckedNodes.length) |
|
|
|
if (checkedKeys.includes(124) || checkedKeys.includes(125) || checkedKeys.includes(126) || checkedKeys.includes(127)) { |
|
|
|
ifHasChannel.value = true |
|
|
|
} else { |
|
|
|
ifHasChannel.value = false |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
//用于标记是否勾选频道管理 |
|
|
|
const ifHasChannel = ref(false) |
|
|
|
const handleCheckChange = async (checkedNodes, checkedInfo) => { |
|
|
|
const { checkedKeys, checkedNodes: allCheckedNodes } = checkedInfo |
|
|
|
|
|
|
|
// 判断是否有选中的节点 |
|
|
|
if (allCheckedNodes.length === 0) { |
|
|
|
addRole.value.checkedKeys = [] |
|
|
|
ifHasChannel.value = false |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
@ -348,6 +360,12 @@ const handleCheckChange = async (checkedNodes, checkedInfo) => { |
|
|
|
// 将Set转换为数组并更新 |
|
|
|
addRole.value.checkedKeys = Array.from(allKeys) |
|
|
|
console.log('新增角色包含所有父级的选中项:', addRole.value.checkedKeys) |
|
|
|
if (addRole.value.checkedKeys.includes(124)) { |
|
|
|
ifHasChannel.value = true |
|
|
|
console.log('勾选了频道'); |
|
|
|
} else { |
|
|
|
ifHasChannel.value = false |
|
|
|
} |
|
|
|
} |
|
|
|
const selectParentNodes = (treeData, nodeId, checkedKeys) => { |
|
|
|
if (!Array.isArray(treeData)) return false |
|
|
|
@ -413,18 +431,38 @@ const collectIds2 = (tree) => { |
|
|
|
return ids |
|
|
|
} |
|
|
|
|
|
|
|
const collectIdsAll = (tree) => { |
|
|
|
let ids = [] |
|
|
|
tree.forEach((node) => { |
|
|
|
ids.push(node.id) |
|
|
|
// 如果当前节点没有 children 或 children 为空,说明是叶子节点 |
|
|
|
if (node.children || node.children.length === 0) { |
|
|
|
ids = ids.concat(collectIdsAll(node.children)) |
|
|
|
} |
|
|
|
}) |
|
|
|
return ids |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 编辑角色初始化 |
|
|
|
const permissionEditRoleInit = async function (row) { |
|
|
|
console.log('row', row) |
|
|
|
console.log('row.tree', row.tree) |
|
|
|
let EditIds = collectIdsAll(row.tree) |
|
|
|
console.log(EditIds); |
|
|
|
|
|
|
|
permissionEditRoleObj.value = {} |
|
|
|
permissionEditRoleObj.value.id = row.id |
|
|
|
permissionEditRoleObj.value.roleName = row.roleName |
|
|
|
permissionEditRoleObj.value.market = row.market |
|
|
|
permissionEditRoleObj.value.parentId = row.fatherId |
|
|
|
permissionEditRoleObj.value.parentName = row.fatherName |
|
|
|
|
|
|
|
permissionEditRoleObj.value.channel = row.channel |
|
|
|
if (EditIds.includes(124)) { |
|
|
|
ifHasChannel.value = true |
|
|
|
} else { |
|
|
|
ifHasChannel.value = false |
|
|
|
} |
|
|
|
try { |
|
|
|
let roleId = permissionEditRoleObj.value.parentId; |
|
|
|
// 如果没有上级角色,设置为管理员的id |
|
|
|
@ -636,9 +674,9 @@ onMounted(async function () { |
|
|
|
</div> |
|
|
|
|
|
|
|
<div style="margin-top: 20px;display: flex;"> |
|
|
|
<el-pagination background :current-page="getRoleObj.pageNum" :page-size="getRoleObj.pageSize" :page-sizes="[5, 10, 20, 50, 100]" |
|
|
|
layout="total, sizes, prev, pager, next, jumper" :total="roleTotal" @size-change="handleRolePageSizeChange" |
|
|
|
@current-change="handleRoleCurrentChange"></el-pagination> |
|
|
|
<el-pagination background :current-page="getRoleObj.pageNum" :page-size="getRoleObj.pageSize" |
|
|
|
:page-sizes="[5, 10, 20, 50, 100]" layout="total, sizes, prev, pager, next, jumper" :total="roleTotal" |
|
|
|
@size-change="handleRolePageSizeChange" @current-change="handleRoleCurrentChange"></el-pagination> |
|
|
|
</div> |
|
|
|
</el-card> |
|
|
|
</div> |
|
|
|
@ -686,6 +724,11 @@ onMounted(async function () { |
|
|
|
<span style="color: #999;">暂无数据</span> |
|
|
|
</div> |
|
|
|
</el-form-item> |
|
|
|
<el-form-item v-show="ifHasChannel" prop="channel" label="频道名称:" required> |
|
|
|
<el-select v-model="addRole.channel" placeholder="请选择频道" style="width: 220px" clearable> |
|
|
|
<el-option v-for="item in channelList" :key="item" :label="item" :value="item" /> |
|
|
|
</el-select> |
|
|
|
</el-form-item> |
|
|
|
</el-form> |
|
|
|
|
|
|
|
<div> |
|
|
|
@ -729,6 +772,12 @@ onMounted(async function () { |
|
|
|
<span style="color: #999;">暂无数据</span> |
|
|
|
</div> |
|
|
|
</el-form-item> |
|
|
|
|
|
|
|
<el-form-item v-show="ifHasChannel" prop="channel" label="频道名称:" required> |
|
|
|
<el-select v-model="permissionEditRoleObj.channel" placeholder="请选择频道" style="width: 220px" clearable> |
|
|
|
<el-option v-for="item in channelList" :key="item" :label="item" :value="item" /> |
|
|
|
</el-select> |
|
|
|
</el-form-item> |
|
|
|
</el-form> |
|
|
|
|
|
|
|
<div> |
|
|
|
|