diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..3876009d --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.idea/ +django_simpleui.egg-info +dist \ No newline at end of file diff --git a/simpleui/__init__.py b/simpleui/__init__.py index e930b24c..a710cf21 100644 --- a/simpleui/__init__.py +++ b/simpleui/__init__.py @@ -1,2 +1,2 @@ def get_version(): - return '2.5' + return '2.6' diff --git a/simpleui/static/admin/simpleui-x/js/index.js b/simpleui/static/admin/simpleui-x/js/index.js index 80b0fac3..aeeedece 100644 --- a/simpleui/static/admin/simpleui-x/js/index.js +++ b/simpleui/static/admin/simpleui-x/js/index.js @@ -184,6 +184,12 @@ } }); } + /*, + tabs: function (newValue, oldValue) { + + //改变tab时把状态储存到sessionStorage + console.log(newValue) + }*/ }, created: function () { @@ -245,12 +251,27 @@ fontEvents.push(handler); } } + var temp_tabs = sessionStorage['tabs']; - if(location.hash!=''){ + if (temp_tabs && temp_tabs != '') { + this.tabs = JSON.parse(temp_tabs); + console.log(this.tabs) + } + if (location.hash != '') { openByHash(); } + + //elementui布局问题,导致页面不能正常撑开,调用resize使其重新计算 + if(window.onresize){ + window.onresize(); + } }, methods: { + syncTabs: function () { + if (window.sessionStorage) { + sessionStorage['tabs'] = JSON.stringify(this.tabs); + } + }, reset: function () { this.fontSlider = 14; fontConfig.fontSize = 0; @@ -350,6 +371,7 @@ if (targetName != 0) { this.tabs = this.tabs.filter(tab => tab.id !== targetName); } + this.syncTabs(); } } , @@ -380,7 +402,7 @@ this.tabModel = data.id; } changeUrl(data) - + this.syncTabs(); } , foldClick: function () { diff --git a/simpleui/templates/admin/index.html b/simpleui/templates/admin/index.html index 0e813f74..d620d1f6 100755 --- a/simpleui/templates/admin/index.html +++ b/simpleui/templates/admin/index.html @@ -168,7 +168,7 @@ @tab-click="tabClick"> + :key="item.id" lazy="true"> {% home_page %} @@ -310,7 +310,7 @@ - + {% load_analysis %} {% block script %} diff --git a/simpleui/templatetags/simpletags.py b/simpleui/templatetags/simpletags.py index 4922694d..2282d565 100644 --- a/simpleui/templatetags/simpletags.py +++ b/simpleui/templatetags/simpletags.py @@ -357,7 +357,7 @@ def custom_button(context): values = {} fun = actions.get(name)[0] for key, v in fun.__dict__.items(): - if key != '__len__': + if key != '__len__' and key != '__wrapped__': values[key] = v data[name] = values return json.dumps(data, cls=LazyEncoder) @@ -381,8 +381,6 @@ def get_model_fields(model, base=None): list.append(('{}__{}'.format(base, f.name), label)) else: list.append((f.name, label)) - if isinstance(f, ForeignKey): - list.extend(get_model_fields(f.related_model, f.name)) return list @@ -391,8 +389,13 @@ def get_model_fields(model, base=None): def search_placeholder(context): cl = context.get('cl') + # 取消递归,只获取2级 fields = get_model_fields(cl.model) + for f in cl.model._meta.fields: + if isinstance(f, ForeignKey): + fields.extend(get_model_fields(f.related_model, f.name)) + verboses = [] for s in cl.search_fields: