Skip to content

Commit

Permalink
## version 1.4.7
Browse files Browse the repository at this point in the history
- [x] 标题页点击刷新菜单无效
- [x] 列表页的过滤条件下拉框,如果类型为普通字段,内容不能被正确显示
- [x] 所有的搜索,在第一页显示正常,但是在第二页的时候就丢失了搜索关键字,也就是说这个第二页就是当前页面所有数据分页之后的第二页
- [X] 在list_filter中,不能按时间过滤(增加了时间区域选择,由于django的限制,暂时不能很好的发挥作用)
  • Loading branch information
newpanjing committed Mar 1, 2019
1 parent c19095d commit 8b9e533
Show file tree
Hide file tree
Showing 6 changed files with 93 additions and 13 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,13 @@ SIMPLEUI_HOME_ICON = 'layui-icon-rate'
## version 1.4.6
+ 加入 `# -*- coding: utf-8 -*-` 以支持python2

## version 1.4.7
- [x] 标题页点击刷新菜单无效
- [x] 列表页的过滤条件下拉框,如果类型为普通字段,内容不能被正确显示
- [x] 所有的搜索,在第一页显示正常,但是在第二页的时候就丢失了搜索关键字,也就是说这个第二页就是当前页面所有数据分页之后的第二页
- [X] 在list_filter中,不能按时间过滤(增加了时间区域选择,由于django的限制,暂时不能很好的发挥作用)



## v1.4版预览图

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

setup(
name='django-simpleui',
version='1.4.6',
version='1.4.7',
packages=['simpleui'],
zip_safe=False,
include_package_data=True,
Expand Down
12 changes: 11 additions & 1 deletion simpleui/static/admin/simpleui/static/js/vip_comm.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ layui.use(['layer', 'element', 'util'], function () {
// 右键提示框菜单操作-刷新页面
$(document).on('click', '.card-refresh', function () {
// 窗体对象
var ifr = $(document).find('.my-body .layui-tab-content .layui-tab-item iframe').eq(cardIdx);
var ifr = $(document).find('.my-body .layui-tab-content .layui-tab-item iframe').eq(cardIdx-1);
// 刷新当前页
ifr.attr('src', ifr.attr('src'));
// 切换到当前选项卡
Expand Down Expand Up @@ -312,4 +312,14 @@ layui.use(['layer', 'element', 'util'], function () {

// 初始化
init();

window.processForm=function (obj) {
$(obj).find("*[name]").each(function () {
var val = $(this).val();
if(val==""){
$(this).removeAttr('name');
}
});
return false;
}
});
24 changes: 18 additions & 6 deletions simpleui/templates/admin/pagination.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,18 @@
<a href="javascript:;" data-page="{{ i }}">{{ i }}</a>
{% endif %}
{% endfor %}
<a href="javascript:;" class="layui-laypage-next">下一页</a>
<a href="javascript:;" class="layui-laypage-next">下一页{{ request.GET.p }}</a>
{% endif %}
</div>
</div>
<script type="text/javascript">
$(function () {

function page_go(p) {
$("#changelist-search input[name='p']").val(p);
$("#changelist-search").submit();
}

var _cl ={{ cl.page_num }};
$("#pagination *[data-page!='']").each(function () {
var page = $(this).attr("data-page")
Expand All @@ -34,23 +40,29 @@
'<em>' + (page + 1) + '</em>');
} else {
$(this).text(page + 1);
$(this).attr("href", "?p=" + page);
$(this).data('page', page);
$(this).click(function () {
page_go($(this).data().page);
});
}
});
//处理上一页和下一页
if (_cl == 0) {
$(".layui-laypage-prev").addClass("layui-disabled");
} else {
$(".layui-laypage-prev").attr("href", "?p=" + (_cl - 1));
$(".layui-laypage-prev").click(function () {
page_go(_cl - 1)
});
}
{#var total = $(".layui-laypage-next").prev().text();#}
{#total = parseInt(total);#}

var total ={{cl.paginator.count}};

if (_cl == (total - 1)) {
$(".layui-laypage-next").addClass("layui-disabled");
} else {
$(".layui-laypage-next").attr("href", "?p=" + (_cl + 1));
$(".layui-laypage-next").click(function () {
page_go(_cl+1)
});
}
});
</script>
55 changes: 50 additions & 5 deletions simpleui/templates/admin/search_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
{% load simpletags %}
{% if cl.search_fields or cl.has_filters %}
<div id="toolbar">
<form id="changelist-search" method="get">
<form id="changelist-search" method="get" onsubmit="processForm(this)">
<input type="hidden" name="p" value=""/>
<div class="layui-form"><!-- DIV needed for valid HTML -->
<label for="searchbar"><img src="{% static "admin/img/search.svg" %}" alt="Search"/></label>
{% if cl.search_fields %}
Expand All @@ -14,13 +15,24 @@
{% for spec in cl.filter_specs %}

<div class="layui-inline">

{% if spec.links %}
<input type="input" class="date_field" data-name="{{spec.field_path}}" data-json="{{spec|date_to_json}}" placeholder="{{spec.title}}"/>
<input type="hidden" name="{{spec.field_generic}}gte"/>
<input type="hidden" name="{{spec.field_generic}}lt"/>
{% else %}
<select data-name="{{ spec.lookup_kwarg }}" lay-search>
<option value="">全部{{ spec.title }}</option>

{% if spec.lookup_choices %}
{% for option in spec.lookup_choices %}
<option value="{{ option.0 }}">{{ option.1 }}</option>
{% endfor %}
{% if spec.lookup_choices.query %}
{% for option in spec.lookup_choices %}
<option value="{{ option }}">{{ option }}</option>
{% endfor %}
{% else %}
{% for option in spec.lookup_choices %}
<option value="{{ option.0 }}">{{ option.1 }}</option>
{% endfor %}
{% endif %}
{% elif spec.field.choices %}
{% for option in spec.field.choices %}
<option value="{{ option.0 }}">{{ option.1 }}</option>
Expand All @@ -30,6 +42,7 @@
<option value="False">False</option>
{% endif %}
</select>
{% endif %}
</div>
{% endfor %}
{% endif %}
Expand Down Expand Up @@ -77,6 +90,38 @@
}
})
});

function format_datetime(d) {
for(i in d){
if (d[i] < 10) {
d[i] = '0' + d[i];
}
}
//2019-03-01 00:00:00+08:00
return d.year + '-' + d.month + '-' + d.date + ' ' + d.hours + ":" + d.minutes + ':' + d.seconds+'+08:00';
}

layui.use('laydate', function () {
var date = new Date();
var laydate = layui.laydate;
laydate.render({
elem: '.date_field'
// , type: 'datetime'
, type: 'date'
, range: true
// max:date.getFullYear()+"-"+date.getMonth()+"-"+date.getDate()
,done:function (value,begin,end) {

var obj = $(this.elem);
var name = obj.attr('data-name');
//2019-03-01 00:00:00+08:00
var d = begin;
obj.parent().find('input[name="' + name + '__gte"]').val(format_datetime(begin));
obj.parent().find('input[name="' + name + '__lt"]').val(format_datetime(end));

}
});
});
}
</script>
{% endif %}
6 changes: 6 additions & 0 deletions simpleui/templatetags/simpletags.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from django.utils.html import format_html
from django.conf import settings
import os
import json

register = template.Library()

Expand Down Expand Up @@ -466,7 +467,12 @@ def get_icon(name):
@register.filter
def test(obj):
print(obj)
# pass
return ''

@register.filter
def date_to_json(obj):
return json.dumps(obj.date_params)

@register.simple_tag(takes_context=True)
def home_page(context):
Expand Down

0 comments on commit 8b9e533

Please sign in to comment.