From 3c976c69d872cf552d93826e2a4770b4db512f8f Mon Sep 17 00:00:00 2001
From: xieshen <1397910458@qq.com>
Date: Tue, 13 Oct 2020 18:13:08 +0800
Subject: [PATCH] =?UTF-8?q?#=E7=94=A8=E6=88=B7=E6=B3=A8=E5=86=8C=E4=BF=AE?=
=?UTF-8?q?=E6=94=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
dashboard/templates/dashboard/register.html | 42 ++-----------------
.../dashboard/results_by_keywords.html | 7 +++-
dashboard/views.py | 37 ++++++++--------
3 files changed, 27 insertions(+), 59 deletions(-)
diff --git a/dashboard/templates/dashboard/register.html b/dashboard/templates/dashboard/register.html
index 1704a74..d5cd314 100644
--- a/dashboard/templates/dashboard/register.html
+++ b/dashboard/templates/dashboard/register.html
@@ -71,21 +71,21 @@
-
+
{#
#}
{#
#}
{#
loading...
#}
{#
#}
- {#
{{ points.point_lat }}
#}
- {#
{{ points.point_lon }}
#}
+ {#
{{ points.point_lat }}
#}
+ {#
{{ points.point_lon }}
#}
{#
#}
{#
#}
{#
#}
@@ -225,45 +225,11 @@
}).show();
}).blur(function (e) {
e.preventDefault();
- resetAutoCompletePanel();
}).on('input', function (e) {
var val = $(this).val();
var params = {keyword: val}
$('.autocomplete-panel').load('/get/organization/' + '?' + $.param(params))
});
-
- function search(value) {
- console.log('search');
- $('.main-search input').val(value);
- {#resetAutoCompletePanel();#}
- {#showFilterPanel();#}
- {#resetResultPanel();#}
- {#showResultPanel(value);#}
-
- }
-
- function showFilterPanel() {
- $('.filter-panel').show();
- }
-
- function resetFilterCompletePanel() {
- $('.filter-panel').hide();
- }
-
- function resetAutoCompletePanel() {
- $('.autocomplete-panel').html("
loading...
").hide();
- }
-
- function showResultPanel(name) {
- $('.result-panel').show();
- $('.result-panel').load('{% url "get-organization" %}' + '?keyword=' + encodeURIComponent(name));
- }
-
- function resetResultPanel() {
- $('.result-panel').html("
\n" +
- "
loading...
\n" +
- "
")
- }
})
diff --git a/dashboard/templates/dashboard/results_by_keywords.html b/dashboard/templates/dashboard/results_by_keywords.html
index a71486f..3c6659b 100644
--- a/dashboard/templates/dashboard/results_by_keywords.html
+++ b/dashboard/templates/dashboard/results_by_keywords.html
@@ -2,7 +2,7 @@
{% for topten in topten_list %}
-
-
+
{{ topten.name }}- ({{ topten.province }},{{ topten.cities }},{{ topten.district }})
@@ -17,7 +17,10 @@
e.preventDefault();
var name = $(this).data('name');
console.log(name+"11111111111111111111111111111111")
- $('.main-search input').val(value)
+ $('.main-search input').val(name)
+ $('.filter-panel').hide();
+ $('.list-group').hide();
+
})
})
diff --git a/dashboard/views.py b/dashboard/views.py
index b991a35..5d33548 100644
--- a/dashboard/views.py
+++ b/dashboard/views.py
@@ -219,26 +219,25 @@ def get_village(request):
def get_organization(request):
- # q = request.GET.get('q')
- # organization = Organization.objects.filter(name__contains=q)[:20]
- # res = []
- # for o in organization:
- # d = dict()
- # d['name'] = o.name
- # d['province'] = Area_code_2020.objects.get(code=o.province).name
- # if o.cities:
- # d['cities'] = Area_code_2020.objects.get(code=o.cities).name
- # else:
- # d['cities'] = ''
- # if o.district:
- # d['district'] = Area_code_2020.objects.get(code=o.district).name
- # else:
- # d['district'] = ''
- # res.append(d)
- # print(res)
- # return HttpResponse(json.dumps(res))
keywords = request.GET.get('keyword')
if len(keywords) != 0:
- topten_list = Organization.objects.filter(Q(name__contains=keywords))
+ o = Organization.objects.filter(Q(name__contains=keywords))[:10]
+ topten_list = []
+ for i in o:
+ d = dict()
+ d['name'] = i.name
+ if i.province:
+ d['province'] = Area_code_2020.objects.get(code=i.province).name
+ else:
+ d['province'] = ''
+ if i.cities:
+ d['cities'] = Area_code_2020.objects.get(code=i.cities).name
+ else:
+ d['cities'] = ''
+ if i.district:
+ d['district'] = Area_code_2020.objects.get(code=i.district).name
+ else:
+ d['district'] = ''
+ topten_list.append(d)
print(str(topten_list))
return render(request, 'dashboard/results_by_keywords.html', {'topten_list': topten_list})