From 90537943d6fef3e52bb11beeb7e502373a277901 Mon Sep 17 00:00:00 2001 From: vapao Date: Wed, 7 Apr 2021 20:21:27 +0800 Subject: [PATCH] fix issues --- spug_api/apps/host/group.py | 4 ++-- spug_web/src/index.js | 3 ++- spug_web/src/libs/functools.js | 1 - spug_web/src/pages/host/Detail.js | 7 ++++--- spug_web/src/pages/host/store.js | 2 +- 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/spug_api/apps/host/group.py b/spug_api/apps/host/group.py index a5fee4c..5523640 100644 --- a/spug_api/apps/host/group.py +++ b/spug_api/apps/host/group.py @@ -25,12 +25,12 @@ def merge_children(data, prefix, childes): if item['children']: merge_children(data, name, item['children']) else: - data.append({'id': item['key'], 'name': name}) + data[item['key']] = name class GroupView(View): def get(self, request): - data, data2 = dict(), [] + data, data2 = dict(), dict() for item in Group.objects.filter(parent_id=0): data[item.id] = item.to_view() fetch_children(data) diff --git a/spug_web/src/index.js b/spug_web/src/index.js index 08cfe70..bad5d3a 100644 --- a/spug_web/src/index.js +++ b/spug_web/src/index.js @@ -13,9 +13,10 @@ import App from './App'; import moment from 'moment'; import 'moment/locale/zh-cn'; import * as serviceWorker from './serviceWorker'; -import { history } from 'libs'; +import { history, updatePermissions } from 'libs'; moment.locale('zh-cn'); +updatePermissions(); ReactDOM.render( diff --git a/spug_web/src/libs/functools.js b/spug_web/src/libs/functools.js index dab88c7..67bbbab 100644 --- a/spug_web/src/libs/functools.js +++ b/spug_web/src/libs/functools.js @@ -22,7 +22,6 @@ export function updatePermissions() { // 前端页面的权限判断(仅作为前端功能展示的控制,具体权限控制应在后端实现) export function hasPermission(strCode) { - if (!Permission.isReady) updatePermissions(); const {isSuper, permissions} = Permission; if (!strCode || isSuper) return true; for (let or_item of strCode.split('|')) { diff --git a/spug_web/src/pages/host/Detail.js b/spug_web/src/pages/host/Detail.js index 5b8fc61..3540bea 100644 --- a/spug_web/src/pages/host/Detail.js +++ b/spug_web/src/pages/host/Detail.js @@ -5,6 +5,7 @@ import store from './store'; export default observer(function () { const host = store.record; + const group_ids = host.group_ids || []; return ( {host.desc} - 腾讯云/华北区 - 腾讯云/测试环境/电商商城系统 - 腾讯云/测试环境/订单后台系统 + {group_ids.map(g_id => ( + {store.groups[g_id]} + ))} diff --git a/spug_web/src/pages/host/store.js b/spug_web/src/pages/host/store.js index e26784f..7608480 100644 --- a/spug_web/src/pages/host/store.js +++ b/spug_web/src/pages/host/store.js @@ -11,7 +11,7 @@ class Store { counter = {}; @observable records = []; @observable treeData = []; - @observable groups = []; + @observable groups = {}; @observable group = {}; @observable record = {}; @observable idMap = {};