HnRealNameBmwWeb/js/work/basic/integratedQuery/ProQuery/ProQueryList.js

205 lines
7.8 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

var example = null;
var pers = null;
layui.use(['layer', 'form'], function () {
var layer = layui.layer;
var form = layui.form;
form.render();
form.verify();
getOrg(form);
var orgId = $("#orgId").val();
getPro(form, orgId);
form.on('select(orgId)', function (data) {
getPro(form, data.value);
});
pers = checkPermission();
init();
$("#searchBt").click(function () {
example.ajax.reload();
});
});
function init() {
example =
$('#dt-table').DataTable({
"sort": false,
"searching": false,
"processing": true, //加载数据时显示进度状态
"serverSide": true,
"pagingType": "full_numbers", //首页|尾页
"language": {
"url": ctxPath + "/js/plugin/datatables/Chinese.lang"
},
"ajax": {
"url": ctxPath + "/integratedQuery/getProQueryList",
"type": "post",
"data": function (d) {
d.companyId = $("#orgId").val();
d.proId = $("#proId").val();
},
"error": function (xhr, textStatus, errorThrown) {
var msg = xhr.responseText;
console.log(msg);
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 () {
// alert( '表格重绘了' );
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": "5%",
data: function (row, type, set, meta) {
var c = meta.settings._iDisplayStart + meta.row + 1;
return c;
}
},
{"data": "proName", "defaultContent": "", "width": "15%"},
{"data": "proType", "defaultContent": "", "width": "8%"},
{"data": "voltageLevel", "defaultContent": "", "width": "10%"},
{
"data": "",
"defaultContent": "",
"orderable": false,
"render": function (data, type, row) {
var proId = row['id'];
var html = '';
var subCount = row['subCount'];
html += "<a style = 'color:#09A8F1;cursor: pointer' onclick = 'subCountView(\"" + proId + "\")'>" + subCount + "</a>";
return html;
}, width: "20%"
},
{
"data": "",
"defaultContent": "",
"orderable": false,
"render": function (data, type, row) {
var proId = row['id'];
var html = '';
var teamCount = row['teamCount'];
var outstandingTeamCount = row['outstandingTeamCount'];
let num = teamCount + "/" + outstandingTeamCount;
html += "<a style = 'color:#09A8F1;cursor: pointer' onclick = 'teamCountViewByPro(\"" + proId + "\",\"" + "" + "\")'>" + num + "</a>";
return html;
}, width: "20%"
},
{
"data": "",
"defaultContent": "",
"orderable": false,
"render": function (data, type, row) {
var proId = row['id'];
var html = '';
var inPlaceCount = row['inPlaceCount'];
var redCount = row['redCount'];
let num = inPlaceCount + "/" + redCount;
html += "<a style = 'color:#09A8F1;cursor: pointer' onclick = 'personCountViewByPro(\"" + proId + "\",\"" + "" + "\",\"" + "" + "\")'>" + num + "</a>";
return html;
}, width: "10%"
},
{"data": "status", "defaultContent": "", "width": "8%"},
],
"order": [[0, "desc"], [1, "asc"]] //在栏目列上显示排序功能
});
}
/**
* 获取分公司
* */
function getCompanys(form) {
$("#orgId").empty();
$.ajax({
type: 'POST',
url: ctxPath + '/users/getOrgInfo',
data: {},
dataType: 'json',
success: function (data) {
var str = '<option value="">请选择分公司</option>';
for (var i = 0; i < data.length; i++) {
str += '<option value=\'' + data[i].id + '\'>' + data[i].companyName + '</option>';
}
$("#orgId").html(str);
form.render();
}
})
}
/**
* 获取工程
* */
function getProject(orgId) {
$("#proId").empty();
$.ajax({
type: 'POST',
url: ctxPath + '/users/getProInfo',
data: {
"orgId": orgId
},
dataType: 'json',
success: function (data) {
var str = '';
str = '<option value="">请选择工程</option>';
for (var i = 0; i < data.length; i++) {
str += '<option value=\'' + data[i].id + '\'>' + data[i].proName + '</option>';
}
$("#proId").html(str);
}
})
}
//查看附件详情
function subCountView(proId) {
localStorage.setItem("proId", proId);
layer.open({
title: ['分包商', 'color:#3B70A1;background-color:#E8ECEB;font-size:20px'],
type: 2,
content: 'SubByProList.html',
area: ['95%', '95%'],
maxmin: false
});
}