492 lines
20 KiB
JavaScript
492 lines
20 KiB
JavaScript
//新加页面需要改的: 1:chak(双击跳转到详细页面) 2:selectnowday(日历点击查询) 3:selectallday(日历查询全部)
|
||
//4:drpleixingchange(查询类型下拉框选中日期类型时,释放右边时间文本框) 5:$(document).ready(如果有状态条件是需要加)
|
||
//5:pxtiaojian(返回查询条件sql语句) 6:sxym(配置完成后刷新页面)
|
||
Request = {
|
||
QueryString: function (item) {
|
||
var svalue = location.search.match(new RegExp("[\?\&]" + item + "=([^\&]*)(\&?)", "i"));
|
||
return svalue ? svalue[1] : svalue;
|
||
}
|
||
}
|
||
//传命名空间
|
||
var namespa;
|
||
function spasefuzhi(spa) {
|
||
namespa = spa;
|
||
}
|
||
//自适应屏幕
|
||
$(document).ready(function () {
|
||
var winheight = $(window).height();
|
||
var winwidth = $(window).width();
|
||
$("#t_r_content").css("width", winwidth - 20);
|
||
$("#ycsjgddiv").css("width", winwidth - 40);
|
||
$("#Gjx").css("width", winwidth - 40);
|
||
$("#t_r_content").css("height", winheight - 135);
|
||
|
||
})
|
||
//同步滚动
|
||
function listscroll() {
|
||
var b = document.getElementById("div_huizong").scrollLeft;
|
||
document.getElementById("div_title").scrollLeft = b;
|
||
document.getElementById("t_r_content").scrollLeft = b;
|
||
}
|
||
function scrolltow() {
|
||
var b = document.getElementById("t_r_content").scrollLeft;
|
||
document.getElementById("div_title").scrollLeft = b;
|
||
document.getElementById("div_huizong").scrollLeft = b;
|
||
}
|
||
window.onresize = function () {
|
||
if (window.outerHeigth == screen.heigth && window.outerWidth == screen.width) {
|
||
var winheight = $(window).height();
|
||
$("#t_r_content").css("height", winheight - 135);
|
||
} else {
|
||
var winheight = $(window).height();
|
||
$("#t_r_content").css("height", winheight - 135);
|
||
}
|
||
if ($('#Gjx').css('display') != "none") {
|
||
var winheight = $(window).height();
|
||
var gjxg = $("#Gjx").height();
|
||
$("#t_r_content").css("height", winheight - 135 - gjxg);
|
||
}
|
||
var winwidth = $(window).width();
|
||
$("#t_r_content").css("width", winwidth - 20);
|
||
$("#ycsjgddiv").css("width", winwidth - 40);
|
||
$("#Gjx").css("width", winwidth - 40);
|
||
}
|
||
//添加设定列表宽度
|
||
function setwidth() {
|
||
var winwidth = $(window).width();
|
||
|
||
$("#div_title").css("width", winwidth - 210);
|
||
$("#t_r_content").css("width", winwidth - 210);
|
||
$("#div_huizong").css("width", winwidth - 210);
|
||
|
||
}
|
||
//工具箱操作
|
||
function gjshouqi() {
|
||
$("#Gjx").slideUp("200", function () {
|
||
$("#Gjx").css("display", "none");
|
||
var winheight = $(window).height();
|
||
$("#t_r_content").css("height", winheight - 135);
|
||
});
|
||
}
|
||
function gjzkpm() {
|
||
$("#Gjx").slideDown("200", function () {
|
||
$("#Gjx").css("display", "block");
|
||
var winheight = $(window).height();
|
||
var gjxg = $("#Gjx").height();
|
||
$("#t_r_content").css("height", winheight - 135 - gjxg);
|
||
});
|
||
}
|
||
//获取最大天数
|
||
function DayNumOfMonth(Year, Month) {
|
||
var d = new Date(Year, Month, 0);
|
||
return d.getDate();
|
||
}
|
||
var dianshu;
|
||
/*点击按钮展开div,拼接添加相应功能
|
||
有下拉框的时候需要修改这里,根据不同的状态,点击显示每月中每天的数据条数
|
||
*/
|
||
function gjzk(obj) {
|
||
if (obj == dianshu) {
|
||
gjshouqi();
|
||
dianshu = "";
|
||
} else {
|
||
gjzkpm();
|
||
dianshu = obj;
|
||
}
|
||
$("#gjxnr").children().not("#div_daoru").remove();
|
||
if (obj == "rili") {
|
||
$("#div_daoru").css("display", "none");
|
||
var daylength = "";
|
||
|
||
if ($("#drp_zt").length > 0) {
|
||
daylength = namespa.nowdaycount($("#drp_zt").val()).value;
|
||
}
|
||
else {
|
||
daylength = namespa.nowdaycount().value;
|
||
}
|
||
$("#gjxnr").append(daylength);
|
||
} else if (obj == "search") {
|
||
$("#div_daoru").css("display", "none");
|
||
var pagename = $("#pagename").val();
|
||
var htmlcode = "";
|
||
if (pagename != 'cpkc') {
|
||
htmlcode = " <div class='cxwkdiv'> "
|
||
+ " <table><tr><td width='220px' >类型:  <select style='width: 140px;height: 20px' id='drop_ziduan' onchange='drpleixingchange(this)'>";
|
||
htmlcode += "</select></td><td width='220px' >内容:  <input type='text' id='txt_tiaojian' style=' height: 20px' onkeydown='EnterTextBox()'></td>"
|
||
+ "<td width='30px' ><input type='checkbox' id='cbo_isqiyong' style=' height: 20px; ' onclick='isqiyong(this)'></td> <td width='210px'>开始日期:   <input name='control_date' type='text' id='begintime' size='10' maxlength='10' onclick='new Calendar().show(this);' readonly='readonly' disabled style='background-color:#cccccc;width:120px; height: 18px; ' /> </td>"
|
||
+ "<td width='220px' >结束日期:  <input id='endtime' type='text' size='10' maxlength='10' onclick='new Calendar().show(this);' readonly='readonly' disabled style='background-color:#cccccc;width:120px; height: 18px; '/></td></tr>"
|
||
+ "<tr height='10px'><td colspan='5' ></td></tr><tr><td colspan='5'><span onclick=\"search()\"><a href='#button' class='button icon search' id='btnsearch' >搜索</a></span> <a href='#button' class='button danger icon remove' onclick=gjzk('search') >取消</a> </td></tr></table></div>";
|
||
} else {
|
||
htmlcode = " <div class='cxwkdiv'> "
|
||
+ " <table><tr><td width='220px' ></td><td width='220px' >类型:  <select style='width: 140px;height: 20px' id='drop_ziduan' onchange='drpleixingchange(this)'>";
|
||
htmlcode += "</select></td><td width='220px' >内容:  <input type='text' id='txt_tiaojian' style=' height: 20px' onkeydown='EnterTextBox()'></td>"
|
||
+ "<tr height='10px'><td colspan='5' ></td></tr><tr><td width='220px' ></td><td colspan='5'><span onclick=\"search()\"><a href='#button' class='button icon search' id='btnsearch' >搜索</a></span> <a href='#button' class='button danger icon remove' onclick=gjzk('search') >取消</a> </td></tr></table></div>";
|
||
}
|
||
$("#gjxnr").append(htmlcode);
|
||
updatedrplie();
|
||
} else if (obj == "down") {
|
||
$("#div_daoru").css("display", "block");
|
||
|
||
}
|
||
}
|
||
//搜索方法
|
||
function search() {
|
||
var tiaojian = pxtiaojian();
|
||
var fanhui = namespa.page_change(funpaixu(), tiaojian).value;
|
||
$("#tbl_list").html(fanhui);
|
||
var tj = "";
|
||
$("#span_sumitem").html(namespa.sumitem(tj).value);
|
||
$("#strwhere").val(tj);
|
||
bind();
|
||
huizong();
|
||
}
|
||
//日期查询是否启用
|
||
function isqiyong() {
|
||
if ($("#cbo_isqiyong").is(":checked")) {
|
||
$("#begintime").removeAttr("disabled");
|
||
$("#endtime").removeAttr("disabled");
|
||
$("#begintime").css("background-color", "#ffffff");
|
||
$("#endtime").css("background-color", "#ffffff");
|
||
} else {
|
||
$("#begintime").attr("disabled", "disabled");
|
||
$("#endtime").attr("disabled", "disabled");
|
||
$("#begintime").css("background-color", "#cccccc");
|
||
$("#endtime").css("background-color", "#cccccc");
|
||
}
|
||
}
|
||
|
||
|
||
|
||
//更新查询下拉框列名
|
||
function updatedrplie() {
|
||
var code = "<option value=''>全部</option>";
|
||
$("#tr_biaotou").find("td").eq(1).nextAll().each(function () {
|
||
if ($(this).attr("tag") != "riqi" && $(this).attr("tag") != "kufang") {
|
||
code += "<option value='" + $(this).attr("tag") + "'>" + $(this).text().replace('∧', '').replace('∨', '') + "</option>";
|
||
}
|
||
})
|
||
$("#drop_ziduan").html(code);
|
||
}
|
||
/*---------------------------------------------------------------------------
|
||
列名下拉框改变,本方法用做列表更改查询条件时,如果有多个日期,显示隐藏查询条件*/
|
||
function drpleixingchange(obj) {
|
||
var selectval = $(obj).find("option:checked").text();
|
||
var endname = selectval.substring(selectval.length - 2, selectval.length);
|
||
if (endname == "日期") {
|
||
enabletimesearch();
|
||
} else {
|
||
disabletimesearch();
|
||
}
|
||
|
||
}
|
||
//启用时间查询
|
||
function enabletimesearch() {
|
||
$("#txt_tiaojian").attr("disabled", "disabled");
|
||
$("#txt_tiaojian").css("background-color", "#cccccc");
|
||
$("#cbo_isqiyong").attr("checked", "true");
|
||
$("#begintime").removeAttr("disabled");
|
||
$("#endtime").removeAttr("disabled");
|
||
$("#begintime").css("background-color", "#ffffff");
|
||
$("#endtime").css("background-color", "#ffffff");
|
||
}
|
||
//禁用时间查询
|
||
function disabletimesearch() {
|
||
$("#txt_tiaojian").removeAttr("disabled");
|
||
$("#txt_tiaojian").css("background-color", "");
|
||
}
|
||
|
||
/*-----------------------------------------------------------------------------------------------------
|
||
配置完成后刷新页面,列配置后自动刷新页面防止空白页和之前配置列表出现,省略去了手动刷新*/
|
||
function sxym() {
|
||
var pgname = $("#pagename").val();
|
||
var fullurl = window.location.href;
|
||
var urlzu = fullurl.split('/');
|
||
var dizhi = urlzu[urlzu.length - 1];
|
||
location.href = "../Module_data/" + dizhi;
|
||
}
|
||
//--------------------------------------------------------------------------------------------------
|
||
$(document).ready(function () {
|
||
/*首次加载显示数据,如果有状态下拉选项的时候,根据不同的状态首次显示数据*/
|
||
var uid = $("#hiddenid").val();
|
||
var fanhuival = namespa.isquanxian(uid).value;
|
||
if (fanhuival == "") {
|
||
location.href = "../Common/nopower.htm";
|
||
return;
|
||
}
|
||
var jtindex = Request.QueryString("seljt");
|
||
$("#drp_zt").find("option").eq(jtindex).attr("selected", "selected");
|
||
var fanhui = "";
|
||
fanhui = namespa.page_change(" order by gen asc", "").value;
|
||
$("#span_sumitem").text(namespa.sumitem("").value);
|
||
|
||
if (fanhui != "") {
|
||
$("#tbl_list").html(fanhui);
|
||
huizong();
|
||
} else {
|
||
sxym();
|
||
}
|
||
})
|
||
|
||
function shujushuaxin() {
|
||
var pageitem = $("#drp_pageitem").val();
|
||
var fanhui = namespa.page_change("", "").value;
|
||
if (fanhui != null) {
|
||
$("#tbl_list").html(fanhui);
|
||
} else {
|
||
$("#tbl_list").html("<tr><td style='text-align:left'><h1>没有数据<h1/></td></tr>");
|
||
}
|
||
}
|
||
function funpaixu() {
|
||
if ($(".paixu").text() != "") {
|
||
var liename = $(".paixu").attr("tag");
|
||
if ($(".paixu").text().indexOf('∧') >= 0) {
|
||
liename += " asc";
|
||
} else if ($(".paixu").text().indexOf('∨') >= 0) {
|
||
liename += " desc";
|
||
}
|
||
return "order by " + liename;
|
||
} else {
|
||
return "order by gen asc ";
|
||
}
|
||
}
|
||
/*-----------------------------------------------------------------
|
||
页面加载和查询操作时,根据不同的条件返回不同的语句拼接
|
||
*/
|
||
var wherecode = "";
|
||
function pxtiaojian() {
|
||
wherecode = '';
|
||
//如果有下拉选项的话需要在这里加上条件;
|
||
tjpinjie("");
|
||
//每个页面中根据选择不同的日期,拼接不同日期的查询条件
|
||
if ($("#txt_tiaojian").length > 0) {
|
||
if ($("#drop_ziduan").val() == '') {
|
||
var code = "(";
|
||
var content = $("#txt_tiaojian").val();
|
||
$("#drop_ziduan").find("option:first").nextAll().each(function () {
|
||
code += $(this).val() + " like '%" + content + "%' or ";
|
||
})
|
||
code = code.substring(0, code.length - 3) + " )and ";
|
||
wherecode += code;
|
||
} else {
|
||
wherecode += $("#drop_ziduan").val() + ' like' + "'%" + $("#txt_tiaojian").val() + "%' and ";
|
||
}
|
||
if ($("#cbo_isqiyong").is(":checked")) {
|
||
var selectval = $("#drop_ziduan").find("option:checked").text();
|
||
if (selectval == '交货日期') {
|
||
wherecode += riqicode('jhrq');
|
||
} else {
|
||
wherecode += riqicode('riqi');
|
||
}
|
||
}
|
||
}
|
||
return wherecode;
|
||
}
|
||
|
||
function riqicode(riqi) {
|
||
|
||
var endtimeval = $("#endtime").val();
|
||
if (endtimeval != '') {
|
||
endtimeval = dateOperator(endtimeval, 1, "+");
|
||
}
|
||
var begintimeval = $("#begintime").val();
|
||
var timecode = "";
|
||
if (begintimeval == '' && endtimeval != '') {
|
||
timecode = " " + riqi + " <'" + endtimeval + "' and ";
|
||
} else if (begintimeval != '' && endtimeval == '') {
|
||
timecode = " " + riqi + " >='" + begintimeval + "' and ";
|
||
} else if (begintimeval == '' && endtimeval == '') {
|
||
|
||
}
|
||
else {
|
||
timecode = " " + riqi + " >='" + begintimeval + "' and " + riqi + "< '" + endtimeval + "' and ";
|
||
}
|
||
return timecode;
|
||
}
|
||
function tjpinjie(zd) {
|
||
wherecode = "";
|
||
}
|
||
|
||
|
||
//列配置
|
||
$(document).ready(function () {
|
||
var fanhuicode = namespa.paixu().value;
|
||
$("#tr_biaotou").html(fanhuicode);
|
||
var code = "";
|
||
$("#li_liepeizhi").click(function () {
|
||
$("#dialog-modal").dialog({
|
||
resizable: false,
|
||
height: 250,
|
||
width: 450,
|
||
modal: true,
|
||
buttons: {
|
||
保存: function () {
|
||
$(".tr_item").each(function () {
|
||
var shuixu = $(this).children("td:first").text();
|
||
var zwziduan = $(this).children("td:first").next("td").text();
|
||
var ywziduan = $(this).children("td:first").next("td").attr("tag");
|
||
var checkval = 0;
|
||
var ischeck = $(this).children("td:first").next("td").next("td").children().is(':checked');
|
||
if (ischeck) {
|
||
checkval = 1;
|
||
}
|
||
code += shuixu + '/' + zwziduan + '/' + ywziduan + '/' + checkval + ";"
|
||
})
|
||
code = code.substr(0, code.length - 1);
|
||
namespa.itempaixu(code);
|
||
$(this).dialog("close");
|
||
var fanhuicode = namespa.paixu().value;
|
||
$("#tr_biaotou").html(fanhuicode);
|
||
|
||
var iszx = true;
|
||
$("#tr_biaotou").children("td:first").next("td").nextAll().click(function () {
|
||
var classname = $(this).attr("class");
|
||
if (iszx) {
|
||
$(this).siblings("td:first").next("td").nextAll().each(function () {
|
||
var txtval = $(this).text().replace('∧', '').replace('∨', '')
|
||
$(this).text(txtval);
|
||
})
|
||
var txt = $(this).text().replace('∧', '').replace('∨', '');
|
||
txt = txt + '∧';
|
||
$(this).text(txt);
|
||
$(this).addClass("paixu");
|
||
$(this).siblings().removeClass("paixu");
|
||
iszx = false
|
||
|
||
} else {
|
||
$(this).siblings().siblings("td:first").nextAll().each(function () {
|
||
var txtval = $(this).text().replace('∧', '').replace('∨', '')
|
||
$(this).text(txtval);
|
||
})
|
||
var txt = $(this).text().replace('∧', '').replace('∨', '');
|
||
txt = txt + "∨";
|
||
$(this).text(txt);
|
||
$(this).addClass("paixu");
|
||
$(this).siblings().removeClass("paixu");
|
||
iszx = true;
|
||
}
|
||
var fanhui = namespa.page_change(funpaixu(), '').value;
|
||
$("#tbl_list").html(fanhui);
|
||
})
|
||
shujushuaxin();
|
||
updatedrplie();
|
||
sxym();
|
||
|
||
}
|
||
}
|
||
|
||
});
|
||
var zhi = $(".tr_titile").children().length;
|
||
var i = 1;
|
||
var htmlcode = "";
|
||
while (i < zhi - 1) {
|
||
htmlcode += "<tr class='tr_item' id='tr_" + i + "'><td style='width:30%'>" + i + "</td><td style='width:30%' tag=" + $(".tr_titile").find("td").eq(i + 1).attr("tag") + ">" + $(".tr_titile").find("td").eq(i + 1).text().replace('∧', '').replace('∨', '') + "</td><td style='width:30%'><input type='checkbox' checked /></td></tr>";
|
||
i++;
|
||
}
|
||
var displaylie = namespa.yincanglie(zhi).value;
|
||
htmlcode += displaylie;
|
||
|
||
$("#tbl_peizhi").html(htmlcode);
|
||
$(".tr_item").click(function () {
|
||
$(".tr_item").removeClass("trfocus");
|
||
$(this).addClass("trfocus");
|
||
})
|
||
})
|
||
|
||
//列排序上
|
||
$("#btn_up").click(function () {
|
||
var bianhao = $(".trfocus").find("td").eq(0).text();
|
||
if (bianhao > 1) {
|
||
var index = bianhao - 1;
|
||
var itemname = $("#tr_" + index).find("td").eq(1).text();
|
||
var tagname = $("#tr_" + index).find("td").eq(1).attr("tag");
|
||
$("#tr_" + index).find("td").eq(1).text($(".trfocus").find("td").eq(1).text());
|
||
$("#tr_" + index).find("td").eq(2).html($(".trfocus").find("td").eq(2).html());
|
||
$("#tr_" + index).find("td").eq(1).attr("tag", $(".trfocus").find("td").eq(1).attr("tag"));
|
||
$(".tr_item").removeClass("trfocus");
|
||
$("#tr_" + index).addClass("trfocus");
|
||
$("#tr_" + bianhao).find("td").eq(1).text(itemname);
|
||
$("#tr_" + bianhao).find("td").eq(1).attr("tag", tagname);
|
||
}
|
||
})
|
||
//列排序下
|
||
$("#btn_down").click(function () {
|
||
var bianhao = $(".trfocus").find("td").eq(0).text();
|
||
var zhi = $("#tbl_peizhi tbody").children().length;
|
||
if (bianhao < zhi) {
|
||
var index = parseInt(bianhao) + parseInt(1);
|
||
var itemname = $("#tr_" + index).find("td").eq(1).text();
|
||
var tagname = $("#tr_" + index).find("td").eq(1).attr("tag");
|
||
$("#tr_" + index).find("td").eq(1).text($(".trfocus").find("td").eq(1).text());
|
||
$("#tr_" + index).find("td").eq(2).html($(".trfocus").find("td").eq(2).html());
|
||
$("#tr_" + index).find("td").eq(1).attr("tag", $(".trfocus").find("td").eq(1).attr("tag"));
|
||
$(".tr_item").removeClass("trfocus");
|
||
$("#tr_" + index).addClass("trfocus");
|
||
$("#tr_" + bianhao).find("td").eq(1).text(itemname);
|
||
$("#tr_" + bianhao).find("td").eq(1).attr("tag", tagname);
|
||
}
|
||
})
|
||
var childcount = $("#tr_biaotou").children().length - 1;
|
||
var itemwidth = parseInt(childcount) * 100 + parseInt(20)
|
||
var huizong = itemwidth + 20
|
||
$("#biaotou").css("width", itemwidth);
|
||
$("#tbl_list").css("width", itemwidth);
|
||
$("#tbl_main").css("width", itemwidth);
|
||
$("#huizong").css("width", huizong);
|
||
var iszx = true;
|
||
$("#tr_biaotou").children("td:first").next("td").nextAll().click(function () {
|
||
var classname = $(this).attr("class");
|
||
if (iszx) {
|
||
$(this).siblings("td:first").next("td").nextAll().each(function () {
|
||
var txtval = $(this).text().replace('∧', '').replace('∨', '');
|
||
$(this).text(txtval);
|
||
})
|
||
var txt = $(this).text().replace('∧', '').replace('∨', '');
|
||
txt = txt + '∧';
|
||
$(this).text(txt);
|
||
$(this).addClass("paixu");
|
||
$(this).siblings().removeClass("paixu");
|
||
iszx = false
|
||
|
||
} else {
|
||
$(this).siblings("td:first").nextAll().each(function () {
|
||
var txtval = $(this).text().replace('∧', '').replace('∨', '');
|
||
$(this).text(txtval);
|
||
})
|
||
var txt = $(this).text().replace('∧', '').replace('∨', '');
|
||
txt = txt + "∨";
|
||
$(this).text(txt);
|
||
$(this).addClass("paixu");
|
||
$(this).siblings().removeClass("paixu");
|
||
iszx = true;
|
||
}
|
||
var fanhui = namespa.page_change(funpaixu(), pxtiaojian()).value;
|
||
$("#tbl_list").html(fanhui);
|
||
bind();
|
||
})
|
||
|
||
})
|
||
|
||
$(document).ready(function () {
|
||
bind();
|
||
|
||
})
|
||
function bind() {
|
||
$(".stripe tr").mouseover(function () {
|
||
//如果鼠标移到class为stripe的表格的tr上时,执行函数
|
||
$(this).addClass("over");
|
||
}).mouseout(function () {
|
||
//给这行添加class值为over,并且当鼠标一出该行时执行函数
|
||
$(this).removeClass("over");
|
||
}) //移除该行的class
|
||
}
|
||
//汇总
|
||
function huizong() {
|
||
var tj = pxtiaojian();
|
||
var hzval = $("#hiddenhuizong").val();
|
||
if ($("#hiddenhuizong").length == 1) {
|
||
var hzlie = hzval.split(',');
|
||
var code = namespa.gethuizong(tj, hzlie).value;
|
||
$(".tr_bottom").html(code);
|
||
$(".tr_bottom").find("td").eq(0).css("width", "20px")
|
||
}
|
||
} |