Datatable get请求传参应用
以关注页面为例:
html:
<div class="row"> <div class="col-md-12 col-sm-12 col-xs-12">
<div class="x_panel" style="margin-top: 0px; padding-top: 0px;">
<div class="x_title">
<!--本页图标-->
<div class="btn-group">
<a href="/task_mgm/taskinfo_finished" style="font-size: 28px; padding-bottom: 5px"><i
class="fa fa-home" style="padding-top: 4px"></i> </a>
</div>
<!--与我相关-->
<div class="btn-group" style="margin-left: 4px">
<button type="button" class="btn btn-danger dropdown-toggle" data-toggle="dropdown"
style="background-color: #fff; color: #73879C; border-color: #73879C; margin-top: 5px">与我相关
</button>
</button>
<ul class="dropdown-menu" id="select_task1" role="menu">
<li id="create_mine"><a href="#">我创建的任务</a>
</li>
<li id="res_mine"><a href="#">我负责的任务</a>
</li>
<li id="exe_mine"><a href="#">我参与的任务</a>
</li>
<li class="divider"></li>
</ul>
</div>
<!--到期时间-->
<div class="btn-group">
<button type="button" class="btn btn-danger dropdown-toggle" data-toggle="dropdown" style="background-color: #fff; color: #73879C; border-color: #73879C; margin-top: 5px">到期时间</button></button>
<ul class="dropdown-menu" id="select_task2" role="menu">
<li style="">
<lable style="margin-left: 10px">从:</lable>
<input type="text" id="rz1" class="calendar-control select_input4" style="width: 140px; margin-left: 8px;" autocomplete="off"></li>
</li>
<li style="">
<lable style="margin-left: 10px">到:</lable>
<input type="text" id="rz2" class="calendar-control select_input5" style="width: 140px; margin-left: 8px;" autocomplete="off"></li>
</li>
<input id="sub_date" type="button" style="float: right; margin: 2px 8px 5px" value=" 确 定 ">
</ul>
</div>
<!--任务进度-->
<div class="btn-group">
<button type="button" class="btn btn-danger dropdown-toggle" data-toggle="dropdown"
style="background-color: #fff; color: #73879C; border-color: #73879C; margin-top: 5px">任务进度
</button>
</button>
<ul class="dropdown-menu" id="task_advance" role="menu">
<li id="advance_0"><a href="#"> 0%</a>
</li>
<li id="advance_2"><a href="#"> 20%</a>
</li>
<li id="advance_4"><a href="#"> 40%</a>
</li>
<li id="advance_6"><a href="#"> 60%</a>
</li>
<li id="advance_8"><a href="#"> 80%</a>
</li>
<li id="advance_10"><a href="#"> 100%</a>
</li>
<li class="divider"></li>
</ul>
</div>
<!--更多-->
<div class="btn-group">
<button type="button" class="btn btn-danger dropdown-toggle" data-toggle="dropdown" style="background-color: #fff; color: #73879C; border-color: #73879C; margin-top: 5px">筛 选</button> <ul class="dropdown-menu" id="select_task3" role="menu">
<li style="text-align: center"><input type="text" class="select_input1" placeholder="按创建人筛选" style="border: #FFFFFF; margin-top: 6px">
</li>
<li style="text-align: center"><input type="text" class="select_input2" placeholder="按负责人筛选" style="border: #FFFFFF; margin-top: 3px">
</li>
<li style="text-align: center"><input type="text" class="select_input3" placeholder="按参与人筛选" style="border: #FFFFFF; margin-top: 3px">
</li>
<li class="divider"></li>
</ul>
</div>
<div class="clearfix"></div>
</div>
<div class="x_content">
<table id="datatable-buttonss" class="table table-hover bulk_action" style="width:100%">
<thead>
<tr>
<th>id</th>
<th></th>
<th>任务名称</th>
<th>紧急程度</th>
<th> 进度</th>
<th>创建人</th>
<th>责任人</th>
<th>参与人</th>
<th style="text-align: center">状态</th>
<th>更新时间</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
</div> </div>
js:
<script>
(function ($) {
$.extend({
urlGet: function () {
var aQuery = window.location.href.split("?"); //取得Get所有参数
var aGET = new Array();
if (aQuery.length > 1) {
var aBuf = aQuery[1].split("&");
for (var i = 0, iLoop = aBuf.length; i < iLoop; i++) {
var aTmp = aBuf[i].split("="); //分离key与Value
aGET[aTmp[0]] = aTmp[1];
}
} else {
flagForShow = true;
}
return aGET;
}
})
})(jQuery);
var GetIt = $.urlGet(); // 可根据key值获取get请求参数值
function goSearch() {
var stime = $("#rz1").val();
var etime = $("#rz2").val();
var myparas = "?stime="+stime+"&etime="+etime;
window.location.href="/task_mgm/taskinfo_focus"+myparas;
}
$(function () {
//我创建任务
$("#create_mine").click(function () {
var myparas = "?which=create_mine";
window.location.href="/task_mgm/taskinfo_focus"+myparas;
});
//我负责任务
$("#res_mine").click(function () {
var myparas = "?which=res_mine";
window.location.href="/task_mgm/taskinfo_focus"+myparas;
});
//我参与任务
$("#exe_mine").click(function () {
var myparas = "?which=exe_mine";
window.location.href="/task_mgm/taskinfo_focus"+myparas;
});
//到期日功能
$("#sub_date").click(function () {
$("#select_task2").hide();
goSearch();
});
//任务进度0%
$("#advance_0").click(function () {
var myparas = "?advance=advance_0";
window.location.href="/task_mgm/taskinfo_focus"+myparas;
});
//任务进度20%
$("#advance_2").click(function () {
var myparas = "?advance=advance_2";
window.location.href="/task_mgm/taskinfo_focus"+myparas;
});
//任务进度40%
$("#advance_4").click(function () {
var myparas = "?advance=advance_4";
window.location.href="/task_mgm/taskinfo_focus"+myparas;
});
//任务进度60%
$("#advance_6").click(function () {
var myparas = "?advance=advance_6";
window.location.href="/task_mgm/taskinfo_focus"+myparas;
});
//任务进度80%
$("#advance_8").click(function () {
var myparas = "?advance=advance_8";
window.location.href="/task_mgm/taskinfo_focus"+myparas;
});
//任务进度100%
$("#advance_10").click(function () {
var myparas = "?advance=advance_10";
window.location.href="/task_mgm/taskinfo_focus"+myparas;
});
var myparas = "?stime="+GetIt["stime"]+"&etime="+GetIt["etime"]+"&which="+GetIt["which"]+"&advance="+GetIt["advance"];
// 表数据定义
var table = $("#datatable-buttonss").DataTable({
"aaSorting": [[9, "desc"]],
// "sDom": '<"x_content"B><"top"lf>rt<"bottom"ip><"clear">',
// buttons: [ ], 两者共用才能出效果 单用报错
"sPaginationType": "full",
"bPaginate": true, //翻页功能
"bInfo": true,//页脚信息
"bAutoWidth": true,//自动宽度
responsive: true,
// "bRetrieve": true,
// "bProcessing": true, //DataTables载入数据时,是否显示‘进度’提示
ajax: "/task_mgm/taskDataFocus"+myparas,
"columnDefs": [
{
"targets": [0],
"visible": false,
},
{
"targets": [1],
"sorting": false,
"width": "3%", },
{
"sorting": false,
"targets": [2],
"render": function (data, type, row, meta) {
var pageType = '?pageType=focusPage';
if (row[3] == 0) {
var rr = '<a style="color: forestgreen"> 0%</a>';
if (type === 'display' && data.length > 20) {
return '<a id="rrrrr" href="/task_mgm/taskinfo_editID=' + row[0] + pageType + '">' + data.substr(0, 16) + '...' + rr + '</a>'
}
else {
return '<a id="taskFocus" href="/task_mgm/taskinfo_editID=' + row[0] + pageType + '">' + data + rr + '</a>'
}
}
else if (row[3] == 1) {
var rr = '<a style="color: forestgreen"> 20%</a>';
if (type === 'display' && data.length > 20) {
return '<a id="rrrrr" href="/task_mgm/taskinfo_editID=' + row[0] + pageType + '">' + data.substr(0, 16) + '...' + rr + '</a>'
}
else {
return '<a id="taskFocus" href="/task_mgm/taskinfo_editID=' + row[0] + pageType + '">' + data + rr + '</a>'
}
}
else if (row[3] == 2) {
var rr = '<a style="color: forestgreen"> 40%</a>';
if (type === 'display' && data.length > 20) {
return '<a id="rrrrr" href="/task_mgm/taskinfo_editID=' + row[0] + pageType + '">' + data.substr(0, 16) + '...' + rr + '</a>'
}
else {
return '<a id="taskFocus" href="/task_mgm/taskinfo_editID=' + row[0] + pageType + '">' + data + rr + '</a>'
}
}
else if (row[3] == 3) {
var rr = '<a style="color: forestgreen"> 60%</a>';
if (type === 'display' && data.length > 20) {
return '<a id="rrrrr" href="/task_mgm/taskinfo_editID=' + row[0] + pageType + '">' + data.substr(0, 16) + '...' + rr + '</a>'
}
else {
return '<a id="taskFocus" href="/task_mgm/taskinfo_editID=' + row[0] + pageType + '">' + data + rr + '</a>'
}
}
else if (row[3] == 4) {
var rr = '<a style="color: forestgreen"> 80%</a>';
if (type === 'display' && data.length > 20) {
return '<a id="rrrrr" href="/task_mgm/taskinfo_editID=' + row[0] + pageType + '">' + data.substr(0, 16) + '...' + rr + '</a>'
}
else {
return '<a id="taskFocus" href="/task_mgm/taskinfo_editID=' + row[0] + pageType + '">' + data + rr + '</a>'
}
}
else if (row[3] == 5) {
var rr = '<a style="color: forestgreen"> 100%</a>';
if (type === 'display' && data.length > 20) {
return '<a id="rrrrr" href="/task_mgm/taskinfo_editID=' + row[0] + pageType + '">' + data.substr(0, 16) + '...' + rr + '</a>'
}
else {
return '<a id="taskFocus" href="/task_mgm/taskinfo_editID=' + row[0] + pageType + '">' + data + rr + '</a>'
}
}
}
},
{
"sorting": true,
"targets": [3],
"visible": false
},
{
"sortable": true,
"targets": [4],
"width": "10%",
"render": function (data, type, row, meta) {
if (data == '非常紧急') {
return '<a class="sorting_1" style="background-color: #D94600;">' + data + '</a>'
}
else if (data == '紧急任务') {
return '<a class="sorting_1" style="background-color: #F9F900">' + data + '</a>'
}
else {
return '<a class="sorting_1" style="background-color: #4DFFFF">' + data + '</a>'
}
}
},
{
"sorting": true,
"width": "8%",
"targets": [5],
},
{
"targets": [6],
"visible": false
},
{
"targets": [7],
"visible": false
},
{
"sorting": false,
"targets": [8],
"width": "10%",
"text-align": "right",
"data": null,
"render": function (data, type, row, meta) {
if (row[8] == 1) {
return "<i class=\"fa fa-star\" id=\"focus\">已关注</i>";
}
else {
return ""
}
},
},
{
"targets": [9],
"visible": false
},
],
});
// 行号设置
table.on('order.dt search.dt', function () {
table.column(1, {search: 'applied', order: 'applied'}).nodes().each(function (cell, i) {
cell.innerHTML = i + 1;
});
}).draw();
// 筛选
$('#select_task3 .select_input1').on( 'keyup change', function () {
table
.columns( 5 )
.search( this.value )
.draw(false);
});
$('#select_task3 .select_input2').on( 'keyup change', function () {
table
.columns( 6 )
.search( this.value )
.draw(false);
});
$('#select_task3 .select_input3').on( 'keyup change', function () {
table
.columns( 7 )
.search( this.value )
.draw(false);
});
$(".calendar-control").datetimepicker({
language: 'zh-CN',
// format: 'yyyy-mm-dd hh:ii',//显示格式
format: 'yyyy-mm-dd 00:00',//显示格式
todayHighlight: 1,//今天高亮
minView: "month",//设置只显示到月份
// minView: 0,//设置显示到分钟
startView: 2,
weekStart: 1,
forceParse: 0,
showMeridian: 1,
autoclose: 1,
});
// 取消关注
$('#datatable-buttonss tbody').on('click', '#focus', function () {
if (confirm('确定取消?')) {
var data = table.row($(this).parents('tr')).data();
$.get('/task_mgm/taskinfo_focusID=' + data[0], function (res) {
if (res.errno == "OK") {
return console.log('取消关注成功')
}
else {
return console.log("取消关注失败")
}
});
window.location.reload()
}
});
});
</script>
后台falsk:
# 关注任务数据
@task_mgm.route('/taskDataFocus')
@sso_wrapper
def taskinfo_dataFocus_fun():
try:
which = request.values.get('which')
advance = request.values.get('advance')
startTime = request.values.get('stime') # 起时
endTime = request.values.get('etime')
time_str = setTime()
if startTime is None or startTime is '' or startTime == 'undefined':
startTime = time_str.split("|")[0]
if endTime is None or endTime is '' or endTime == 'undefined':
endTime = time_str.split("|")[1] # 应该根据用户名或ID 的到自己的任务 现在先暂时应任务ID
if which == "undefined" and advance == "undefined":
tasks = Task.query.filter(
and_(Task.isDelete != 1, Task.ifFocus == 1, Task.endTime >= startTime, Task.endTime <= endTime,
)).order_by(Task.updateTime.desc()).all()
elif which == "create_mine":
tasks = Task.query.filter(
and_(Task.isDelete != 1, Task.ifFocus == 1, Task.createPeople == g.name
)).order_by(Task.updateTime.desc()).all()
elif which == "res_mine":
tasks = Task.query.filter(
and_(Task.isDelete != 1, Task.ifFocus == 1, Task.resPeople == g.name
)).order_by(Task.updateTime.desc()).all()
elif which == "exe_mine":
tasks = Task.query.filter(
and_(Task.isDelete != 1, Task.ifFocus == 1, Task.exePeople == g.name
)).order_by(Task.updateTime.desc()).all()
elif advance == "advance_0":
tasks = Task.query.filter(
and_(Task.isDelete != 1, Task.ifFocus == 1, Task.advanceId == 0
)).order_by(Task.updateTime.desc()).all()
elif advance == "advance_2":
tasks = Task.query.filter(
and_(Task.isDelete != 1, Task.ifFocus == 1, Task.advanceId == 1
)).order_by(Task.updateTime.desc()).all()
elif advance == "advance_4":
tasks = Task.query.filter(
and_(Task.isDelete != 1, Task.ifFocus == 1, Task.advanceId == 2
)).order_by(Task.updateTime.desc()).all()
elif advance == "advance_6":
tasks = Task.query.filter(
and_(Task.isDelete != 1, Task.ifFocus == 1, Task.advanceId == 3
)).order_by(Task.updateTime.desc()).all()
elif advance == "advance_8":
tasks = Task.query.filter(
and_(Task.isDelete != 1, Task.ifFocus == 1, Task.advanceId == 4
)).order_by(Task.updateTime.desc()).all()
elif advance == "advance_10":
tasks = Task.query.filter(
and_(Task.isDelete != 1, Task.ifFocus == 1, Task.advanceId == 5
)).order_by(Task.updateTime.desc()).all() data = sql3json(tasks, ["id", "endState", "taskName", "advanceId", "urgentId", "createPeople", "resPeople", "exePeople", "ifFocus", "updateTime"])
return data
except Exception as e:
logging.error(e)
Datatable get请求传参应用的更多相关文章
- 13.scrapy框架的日志等级和请求传参
今日概要 日志等级 请求传参 如何提高scrapy的爬取效率 今日详情 一.Scrapy的日志等级 - 在使用scrapy crawl spiderFileName运行程序时,在终端里打印输出的就是s ...
- scrapy框架的日志等级和请求传参
日志等级 请求传参 如何提高scrapy的爬取效率 一.Scrapy的日志等级 - 在使用scrapy crawl spiderFileName运行程序时,在终端里打印输出的就是scrapy的日志信息 ...
- [转]ASP.NET MVC学习系列(二)-WebAPI请求 传参
[转]ASP.NET MVC学习系列(二)-WebAPI请求 传参 本文转自:http://www.cnblogs.com/babycool/p/3922738.html ASP.NET MVC学习系 ...
- scrapy框架之日志等级和请求传参-cookie-代理
一.Scrapy的日志等级 - 在使用scrapy crawl spiderFileName运行程序时,在终端里打印输出的就是scrapy的日志信息. - 日志信息的种类: ERROR : 一般错误 ...
- 爬虫--Scrapy-参数等级和请求传参
日志等级 日志等级(种类): ERROR:错误 WARNING:警告 INFO:一般信息 DEBUG:调试信息(默认) 指定输入某一中日志信息: settings:LOG_LEVEL = ‘ERROR ...
- Scrapy的日志等级和请求传参
日志等级 日志信息: 使用命令:scrapy crawl 爬虫文件 运行程序时,在终端输出的就是日志信息: 日志信息的种类: ERROR:一般错误: WARNING:警告: INFO:一般的信息: ...
- 爬虫开发10.scrapy框架之日志等级和请求传参
今日概要 日志等级 请求传参 今日详情 一.Scrapy的日志等级 - 在使用scrapy crawl spiderFileName运行程序时,在终端里打印输出的就是scrapy的日志信息. - 日志 ...
- scrapy框架post请求发送,五大核心组件,日志等级,请求传参
一.post请求发送 - 问题:爬虫文件的代码中,我们从来没有手动的对start_urls列表中存储的起始url进行过请求的发送,但是起始url的确是进行了请求的发送,那这是如何实现的呢? - 解答: ...
- scrapy模块之分页处理,post请求,cookies处理,请求传参
一.scrapy分页处理 1.分页处理 如上篇博客,初步使用了scrapy框架了,但是只能爬取一页,或者手动的把要爬取的网址手动添加到start_url中,太麻烦接下来介绍该如何去处理分页,手动发起分 ...
随机推荐
- vue2.x 在引用插件的时候,npm run dev跑正常 ,npm run build 报错vue-cli Unexpected token: punc (() [
这是因为,引用的插件在node_modules里,并不在vue-cli的es6编译范围内,所以语法报错,修改方法:
- arcgis api 3.x for js 入门开发系列七图层控制(附源码下载)
前言 关于本篇功能实现用到的 api 涉及类看不懂的,请参照 esri 官网的 arcgis api 3.x for js:esri 官网 api,里面详细的介绍 arcgis api 3.x 各个类 ...
- How to Apply Patches to a WLS 8.1 Environment
APPLIES TO: Oracle Weblogic Server - Version 8.1 to 8.1Information in this document applies to any p ...
- iOS-----------计算两个时间的时间差
UIButton * nameButton = [UIButton buttonWithType:UIButtonTypeCustom]; nameButton.frame = CGRectMake( ...
- AndroidStudio开发Java工程(解决java控制台中文打印乱码+导入jar包运行工程)
这篇分享一点个人AS开发java工程经验,虽然有时候还是得打开eclipse来运行java项目,但能用AS的时候还是尽量用AS,毕竟一个字,爽~ 废话不多说,进入正题. 一.开发Java工程 你有两种 ...
- 智能POS(轻餐、正餐同理)桌台页面已结金额,只做参考,不做对账使用
智能POS桌台已结金额只用来做参考使用,不做对账保障: 已结金额只有桌台一次结账金额,若存在反结账或退款的情况则不会减去相应的已结金额: 点餐无桌台的订单,金额不做统计: 口碑订单.扫码点餐,金额不做 ...
- python正则表达式模块re
正则表达式的特殊元素 匹配符号 描述 '.'(点dot) 在默认模式下,它匹配除换行符之外的任何字符.如果指定了DOTALL标志,则匹配包括换行符在内的任何字符 '^'(Caret) 匹配以字符串开头 ...
- ReSharper导致Visual Studio缓慢?
问题排查 我们会竭尽所能的ReSharper的性能方面,但是也有一些已知和未知的情况下,ReSharper的可以减缓的Visual Studio. 这里有一些关键点进行故障排除和修复ReSharper ...
- Python爬虫之Requests库的基本使用
import requests response = requests.get('http://www.baidu.com/') print(type(response)) print(respons ...
- 记录日常Linux常用软件
yum -y install gcc gcc-c++ autoconf pcre pcre-devel make automake yum -y install wget httpd-tools vi ...