Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -3,6 +3,20 @@ import api from 'src/services/api'
|
||||
|
||||
let lastRequestId = 0
|
||||
|
||||
const ACTION_CANONICAL = {
|
||||
view: 'read',
|
||||
insert: 'write'
|
||||
}
|
||||
|
||||
function normalizeToken(v) {
|
||||
return String(v || '').toLowerCase().trim()
|
||||
}
|
||||
|
||||
function canonicalAction(v) {
|
||||
const key = normalizeToken(v)
|
||||
return ACTION_CANONICAL[key] || key
|
||||
}
|
||||
|
||||
export const useRoleDeptPermissionListStore = defineStore('roleDeptPermissionList', {
|
||||
state: () => ({
|
||||
modules: [],
|
||||
@@ -47,10 +61,15 @@ export const useRoleDeptPermissionListStore = defineStore('roleDeptPermissionLis
|
||||
: []
|
||||
|
||||
this.moduleActions = Array.isArray(payload?.module_actions)
|
||||
? payload.module_actions.map((a) => ({
|
||||
module_code: String(a.module_code || '').toLowerCase().trim(),
|
||||
action: String(a.action || '').toLowerCase().trim()
|
||||
})).filter((a) => a.module_code && a.action)
|
||||
? payload.module_actions
|
||||
.map((a) => ({
|
||||
module_code: normalizeToken(a.module_code),
|
||||
action: canonicalAction(a.action)
|
||||
}))
|
||||
.filter((a) => a.module_code && a.action)
|
||||
.filter((a, idx, arr) =>
|
||||
arr.findIndex((x) => x.module_code === a.module_code && x.action === a.action) === idx
|
||||
)
|
||||
: []
|
||||
|
||||
const rawRows = Array.isArray(payload?.rows)
|
||||
@@ -63,7 +82,11 @@ export const useRoleDeptPermissionListStore = defineStore('roleDeptPermissionLis
|
||||
: {}
|
||||
const flags = {}
|
||||
Object.keys(rawFlags).forEach((k) => {
|
||||
flags[String(k).toLowerCase().trim()] = Boolean(rawFlags[k])
|
||||
const [moduleRaw, actionRaw] = normalizeToken(k).split('|')
|
||||
if (!moduleRaw || !actionRaw) return
|
||||
const action = canonicalAction(actionRaw)
|
||||
const key = `${moduleRaw}|${action}`
|
||||
flags[key] = Boolean(flags[key]) || Boolean(rawFlags[k])
|
||||
})
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user