zhou zhou
2026-04-01 a49845f424ae5b1e43e391837a55c43ce07ea62d
rsf-design/src/views/system/role/modules/role-permission-dialog.vue
@@ -96,21 +96,7 @@
    label: 'label',
    children: 'children'
  }
  const scopeState = reactive(
    Object.fromEntries(
      scopeConfigs.map((config) => [
        config.scopeType,
        {
          loading: false,
          loaded: false,
          treeData: [],
          checkedKeys: [],
          halfCheckedKeys: [],
          condition: ''
        }
      ])
    )
  )
  const scopeState = reactive(Object.fromEntries(scopeConfigs.map((config) => [config.scopeType, createScopeTabState()])))
  const visible = computed({
    get: () => props.visible,
@@ -119,18 +105,37 @@
  const roleLabel = computed(() => props.roleData?.name || props.roleData?.code || '未选择角色')
  function createScopeTabState() {
    return {
      loading: false,
      loaded: false,
      treeData: [],
      checkedKeys: [],
      halfCheckedKeys: [],
      condition: ''
    }
  }
  function resetScopeTabState(state) {
    Object.assign(state, createScopeTabState())
  }
  function hasNodeKey(value) {
    return value !== void 0 && value !== null && value !== ''
  }
  const loadScopeData = async (scopeType, { reloadSelection = true } = {}) => {
    const config = getRoleScopeConfig(scopeType)
    const state = scopeState[scopeType]
    state.loading = true
    try {
      const requests = [fetchGetRoleScopeTree(config.scopeType, { condition: state.condition || '' })]
      if (reloadSelection) {
        requests.unshift(fetchGetRoleScopeList(config.scopeType, props.roleData.id))
      }
      const selectionRequest = reloadSelection
        ? fetchGetRoleScopeList(config.scopeType, props.roleData.id)
        : Promise.resolve(state.checkedKeys)
      const treeRequest = fetchGetRoleScopeTree(config.scopeType, { condition: state.condition || '' })
      const guardedResult = await guardRequestWithMessage(
        reloadSelection ? Promise.all(requests) : Promise.resolve([state.checkedKeys, await requests[0]]),
        Promise.all([selectionRequest, treeRequest]),
        null,
        {
          timeoutMessage: `${config.title}加载超时,已停止等待`
@@ -237,12 +242,7 @@
  const handleClosed = () => {
    activeScopeType.value = props.scopeType || 'menu'
    Object.keys(scopeState).forEach((key) => {
      scopeState[key].loading = false
      scopeState[key].loaded = false
      scopeState[key].treeData = []
      scopeState[key].checkedKeys = []
      scopeState[key].halfCheckedKeys = []
      scopeState[key].condition = ''
      resetScopeTabState(scopeState[key])
    })
  }
@@ -250,7 +250,7 @@
    const keys = []
    const traverse = (nodeList) => {
      nodeList.forEach((node) => {
        if (node.id !== void 0 && node.id !== null && node.id !== '') {
        if (hasNodeKey(node.id)) {
          keys.push(String(node.id))
        }
        if (node.children?.length) {