153 lines
6.1 KiB
JavaScript
153 lines
6.1 KiB
JavaScript
var example = null;
|
||
var pers = null;
|
||
$(function () {
|
||
layui.use(['layer', 'laydate', 'form'], function () {
|
||
var layer = layui.layer;
|
||
var laydate = layui.laydate;
|
||
var form = layui.form;
|
||
pers = checkPermission();
|
||
$("#checkall").change(function () {
|
||
if ($(this).is(':checked')) {
|
||
$('input[name="checked"]').each(function () {
|
||
$(this).prop("checked", true);
|
||
});
|
||
} else {
|
||
$('input[name="checked"]').each(function () {
|
||
$(this).prop("checked", false);
|
||
});
|
||
}
|
||
});
|
||
init();
|
||
$("#searchBt").click(function () {
|
||
example.ajax.reload();
|
||
});
|
||
});
|
||
|
||
})
|
||
|
||
function init() {
|
||
example =
|
||
$('#dt-table').DataTable({
|
||
"sort": false,
|
||
"searching": false,
|
||
"processing": true, //加载数据时显示进度状态
|
||
"serverSide": true,
|
||
"language": {
|
||
"url": contentPath + "/js/plugin/datatables/Chinese.lang"
|
||
},
|
||
"ajax": {
|
||
"url": ctxPath + "/proBidRelation/selectProjectList",
|
||
"type": "post",
|
||
"data": function (d) {
|
||
d.proName = $("#proName").val();
|
||
},
|
||
"error": function (xhr, textStatus, errorThrown) {
|
||
var msg = xhr.responseText;
|
||
var response = JSON.parse(msg);
|
||
var code = response.code;
|
||
var message = response.message;
|
||
if (code == 400) {
|
||
layer.msg(message);
|
||
} else if (code == 401) {
|
||
localStorage.removeItem("token");
|
||
layer.msg("token过期,请先登录", {shift: -1, time: 1000}, function () {
|
||
location.href = ctxPath + '/login.html';
|
||
});
|
||
} else if (code == 403) {
|
||
console.log("未授权:" + message);
|
||
layer.msg('未授权');
|
||
} else if (code == 500) {
|
||
console.log('系统错误:' + message);
|
||
}
|
||
}
|
||
},
|
||
"drawCallback": function() {
|
||
var thisDataTable = $('#dt-table').DataTable();
|
||
$(".pagination").append("<li>" +
|
||
"<a class='paginate_button' style='padding:4px;' href='#' tabindex='0'>到 <input style='margin:0px;width:40px;' id='changePage'> 页</a>" +
|
||
"<a class='paginate_button' style='margin-bottom:1px' href='#' tabindex='0' id='dataTable-btn'>确认</a></li>");
|
||
//点击按钮跳转指定页数
|
||
$('#dataTable-btn').click(function (e) {
|
||
if ($("#changePage").val() && $("#changePage").val() > 0) {
|
||
var redirectpage = $("#changePage").val() - 1;
|
||
} else {
|
||
var redirectpage = 0;
|
||
}
|
||
thisDataTable.page(redirectpage).draw( 'page' );
|
||
});
|
||
//敲击回车键跳转指定页数
|
||
$("#changePage").keypress(function (e) {
|
||
if(event.keyCode==13){
|
||
if ($("#changePage").val() && $("#changePage").val() > 0) {
|
||
var redirectpage = $("#changePage").val() - 1;
|
||
} else {
|
||
var redirectpage = 0;
|
||
}
|
||
thisDataTable.page(redirectpage).draw( 'page' );
|
||
}
|
||
});
|
||
},
|
||
"dom": "<'dt-toolbar'r>t<'dt-toolbar-footer'<'col-sm-4 col-xs-4 hidden-xs'i><'col-xs-8 col-sm-8' p v>>",
|
||
"columns": [
|
||
{
|
||
"width":"3%",
|
||
"data": null,
|
||
"bSortable": false,
|
||
render: function (data, type, full, meta) {
|
||
var node = '';
|
||
var checkedStatus = data['checkedStatus'];
|
||
node = '<input class="checkall" name="checked" value=\"' + full.id + ',' + full.proName + ',' + full.abbreviation + '\" type="checkbox"/>';
|
||
if (checkedStatus == 1) {
|
||
node = '<input class="checkall" name="checked" checked="checked" value=\"' + full.id + ',' + full.proName + ',' + full.abbreviation + '\" type="checkbox"/>';
|
||
}
|
||
return node;
|
||
}
|
||
},
|
||
{
|
||
width: '3%',
|
||
data: function (row, type, set, meta) {
|
||
var c = meta.settings._iDisplayStart + meta.row + 1;
|
||
return c;
|
||
}
|
||
},
|
||
{"data": "proName",width: '10%'},
|
||
{"data": "abbreviation",width: '10%'}
|
||
|
||
],
|
||
"order": [[0, "desc"], [1, "asc"]] //在栏目列上显示排序功能
|
||
});
|
||
}
|
||
|
||
function upload() {
|
||
var id = null;
|
||
var selected = []; // 选中删除的数据
|
||
var oTable = $('#dt-table').dataTable();
|
||
var rowcollection = oTable.$(".checkall:checked", {"page": "all"});
|
||
rowcollection.each(function (index, elem) {
|
||
var checkbox_value = $(elem).val();
|
||
selected.push(checkbox_value);
|
||
});
|
||
if (selected.length == 0) {
|
||
return layer.msg("请勾选标段", {icon: 2, time: 2000});
|
||
}
|
||
layer.confirm("您确定选择这" + selected.length + "个标段吗?", function () {
|
||
parent.layer.closeAll();
|
||
parent.showBidData(selected);
|
||
})
|
||
}
|
||
|
||
/**
|
||
* 获取当日时间
|
||
*/
|
||
function getNowTime() {
|
||
var nowDate = new Date();
|
||
var year = nowDate.getFullYear();
|
||
var month = nowDate.getMonth() + 1 < 10 ? "0" + (nowDate.getMonth() + 1) :
|
||
nowDate.getMonth() + 1;
|
||
var day = nowDate.getDate() < 10 ? "0" + nowDate.getDate() : nowDate.getDate();
|
||
var h =nowDate.getHours();
|
||
var m=nowDate.getMinutes();
|
||
var s=nowDate.getSeconds();
|
||
var dateStr = year + "-" + month + "-" + day;
|
||
return dateStr;
|
||
} |