//高级过滤 HTableName是这个列表的视图名
function set_QueryCondition(option, HTableName, get_FastQuery) {
var colName = "";
var contentUrl = "";
for (var i = 0; i < option.cols[0].length; i++) {
if (option.cols[0][i]["field"] != undefined && option.cols[0][i]["hide"] != true) {
colName += option.cols[0][i]["title"] + ",";
}
}
var urlStr = window.document.location.pathname;//获取文件路径
var urlLen = urlStr.split('/');
for (var i = 0; i < urlLen.length - 4; i++) {
contentUrl += "../";
}
colName = encodeURI(colName.substring(0, colName.length - 1));//对 URI 进行编码
contentUrl += '../基础资料/隐藏列设置/Gy_QueryCondition.html?HModName=' + HTableName + '&colName=' + colName;
layer.open({
type: 2
, skin: "layui-layer-rim" //加上边框
, title: "高级过滤" //标题
, closeBtn: 1 //窗体右上角关闭 的 样式
, shift: 2 //弹出动画
, area: ["50%", "80%"] //窗体大小
, maxmin: true //设置最大最小按钮是否显示
, content: [contentUrl, "yes"]
, btn: ["确定", "取消"]
, btn1: function (index, laero) {
var iframeWindow = window["layui-layer-iframe" + index];//获取弹框页面
var checkStatus = iframeWindow.layui.table.cache["mainTable"];//获取选中的数据
if (checkStatus.length == 0) {
return layer.msg("请输入过滤条件!");
}
var myIframe = window[laero.find('iframe')[0]['name']];
GetDataCols += "and (";
for (var i = 0; i < checkStatus.length; i++) {
GetDataCols += myIframe.get_FastQuery(checkStatus[i]); //get_FastQuery()为子页面的方法
if ((i + 1) < checkStatus.length) {
GetDataCols += " " + checkStatus[i]["HRelationCol"] + " ";
}
}
GetDataCols += ")";
//更新表格缓存的数据
layer.close(index);//关闭弹窗
}
, end: function () {
if (GetDataCols != "") {
get_FastQuery();
}
}
})
}
//#region 【过滤方案】
//获取当前用户的默认过滤方案
function get_DefaultModule(get_FastQuery) {
$.ajax({
url: GetWEBURL() + '/Xt_FastICScheme/Chooselist',
type: "GET",
async: false,
data: { "user": sessionStorage["Czybm"], "HModuleName": HModuleName, "HInterID": 0, "Type": "Default" },
success: function (data1) {
if (data1.count == 1) {
//当前用户设置有默认的过滤方案
var data = data1.data;
//当前选择的过滤方案
HInterID_Choose = data[0].hmainid;
//过滤方案内码
HInterID = data[0].hmainid
//过滤方案名称
HDefaultFilter = data[0].方案名称
//过滤方案的备注(方案信息描述)
var HRemark = data[0].备注
//显示出当前的默认过滤方案
document.getElementById("HFilterScheme_Now").style.display = "block";
document.getElementById('HFilterScheme_Now').innerHTML = "当前过滤方案:" + HDefaultFilter + ' ' + "(" + HRemark + ")" + '';
//把过滤条件值回写到页面上
for (let i = 0; i < data.length; i++) {
$("#" + data[i].过滤字段ID).val(data[i].过滤值);
if (data[i].过滤标签类型 == 'SELECT') {
$("#" + data[i].过滤字段ID).find("option[value='" + data[i].过滤值 + "']").attr("selected", true);
}
}
var HInitTimeCycle = $("#HInitTimeCycle").val() * 1;
//若日期间隔不为 任意间隔,则禁用开始日期与结束日期的选择
if (HInitTimeCycle != -1) {
//$('#HDate').prop('disabled', true);
//$('#HDate1').prop('disabled', true);
$("#HDate").val(Format(new Date(new Date() - 1000 * 60 * 60 * 24 * HInitTimeCycle), "yyyy-MM-dd"));
$("#HDate1").val(Format(new Date(), "yyyy-MM-dd"));
//执行查询方法
get_FastQuery();
} else {
//$('#HDate').prop('disabled', false);
//$('#HDate1').prop('disabled', false);
}
//执行查询方法
get_FastQuery()
//form.render("select");
} else {
//当前用户没有设置默认的过滤方案
//隐藏显示过滤方案的标签信息
document.getElementById("HFilterScheme_Now").style.display = "none";
//执行查询方法
//get_FastQuery()
//form.render("select");
}
}, error: function () {
layer.alert("接口请求失败!", { icon: 5 });
}
});
}
//保存方案
function set_SaveScheme(get_FastQuery) {
var index = layer.open()
//判断用户是否点击了右上角的“叉号”关闭弹窗页面
var HIsClose_Manual = false;
//获取本页所有过滤条件对象(class中包含"ForFilteringSchemes"的元素)
var Filter = document.getElementsByClassName(HClassTag);
var HFilterIdList = "";//过滤条件
var HFilterIdLists = "";//拼接多个过滤条件
var HValue = "";//过滤值
var HElement_type = "";//过滤标签类型
for (var i = 0; i < Filter.length; i++) {
HFilterIdList = Filter[i].id; //过滤条件ID
HFilterIdLists += Filter[i].id + ","; //过滤条件ID(拼接)
HValue += $("#" + HFilterIdList).val() + ","; //过滤条件中输入的值
HElement_type += document.getElementById(HFilterIdList).tagName + ",";//通过标签id获取标签类型
}
//去除末尾逗号
HFilterIdLists = HFilterIdLists.substring(0, HFilterIdLists.length - 1);
HValue = HValue.substring(0, HValue.length - 1);
HElement_type = HElement_type.substring(0, HElement_type.length - 1);
//当前页面上没有选择过滤方案,进入新增方法
if (HDefaultFilter == "") {
layer.open({
type: 2
, area: ['40%', '80%']
, title: '过滤方案'
, shift: 0//弹出动画
, content: '../../系统管理/过滤方案设置/Xt_FastICScheme.html?OperationType=1&HModuleName=' + HModuleName + '&HFilterIdLists=' + HFilterIdLists + '&HValue=' + HValue + '&HElement_type=' + HElement_type
, cancel: function () {
// 右上角关闭事件的逻辑
HIsClose_Manual = true;
}
, end: function () {
if (HIsClose_Manual != true) {
get_FastQuery();
//显示当前的过滤方案
document.getElementById("HFilterScheme_Now").style.display = "block";
document.getElementById('HFilterScheme_Now').innerHTML = "当前过滤方案:" + sessionStorage["HFilterSchemeName_" + sessionStorage["Czybm"]] + ' ' + "(" + sessionStorage["HFilterSchemeRemark_" + sessionStorage["Czybm"]] + ")" + '';
}
}
})
layer.close(index)
} else {
//当前页面已有过滤方案,用户选择 新增或者编辑
layer.confirm('当前已选择过滤方案,是否修改?请选择对应操作', {
title: "操作提示",
icon: 0,
btn: ['新增方案', '保存修改当前方案', '取消']
}, function (index, layero) {
//新增
layer.open({
type: 2
, area: ['40%', '80%']
, title: '过滤方案'
, shift: 0//弹出动画
, content: '../../系统管理/过滤方案设置/Xt_FastICScheme.html?OperationType=1&HModuleName=' + HModuleName + '&HFilterIdLists=' + HFilterIdLists + '&HValue=' + HValue + '&HElement_type=' + HElement_type
, end: function () {
get_FastQuery()
//显示当前的过滤方案
document.getElementById("HFilterScheme_Now").style.display = "block";
document.getElementById('HFilterScheme_Now').innerHTML = "当前过滤方案:" + sessionStorage["HFilterSchemeName_" + sessionStorage["Czybm"]] + ' ' + "(" + sessionStorage["HFilterSchemeRemark_" + sessionStorage["Czybm"]] + ")" + '';
}
})
layer.close(index)
}, function (index) {
//编辑
var Filter_Edit = document.getElementsByClassName(HClassTag); //获取本页所有过滤条件对象(class中包含"ForFilteringSchemes"的元素)
HFilterIdList = "";
HFilterIdLists = "";
HValue = "";
HElement_type = "";
for (var i = 0; i < Filter_Edit.length; i++) {
HFilterIdList = Filter_Edit[i].id; //过滤条件ID
HFilterIdLists += Filter_Edit[i].id + ","; //过滤条件ID(拼接)
HValue += $("#" + HFilterIdList).val() + ","; //过滤条件中输入的值
HElement_type += document.getElementById(HFilterIdList).tagName + ",";//通过标签id获取标签类型
}
//去除末尾逗号
HFilterIdLists = HFilterIdLists.substring(0, HFilterIdLists.length - 1);
HValue = HValue.substring(0, HValue.length - 1);
HElement_type = HElement_type.substring(0, HElement_type.length - 1);
var sMainSub = HInterID_Choose + ';' + HFilterIdLists + ';' + HValue + ';' + HElement_type + ';' + sessionStorage["Czybm"] + ';' + 3;
//修改
$.ajax({
type: "POST",
url: GetWEBURL() + "/Xt_FastICScheme/save", //方法所在页面和方法名
async: true,
data: { "oMain": sMainSub },
dataType: "json",
success: function (data) {
if (data.count == 1) { // 说明验证成功了,
layer.msg(data.Message, { time: 1 * 1000, icon: 1 });
}
else {
}
layer.closeAll("loading");
},
error: function (err) {
}
});
layer.close(index)
}, function (index) {
//取消
layer.alert('取消')
layer.close(index)
});
}
}
//读取方案
function set_ReadScheme(get_FastQuery) {
var HIsClose_Manual = false;
var Filter = document.getElementsByClassName(HClassTag); //获取本页所有过滤条件对象(class中包含"ForFilteringSchemes"的元素)
var HFilterIdList = "";
var HFilterIdLists = "";
var HValue = "";
var HElement_type = "";
for (var i = 0; i < Filter.length; i++) {
HFilterIdList = Filter[i].id; //过滤条件ID
HFilterIdLists += Filter[i].id + ","; //过滤条件ID(拼接)
HValue += $("#" + HFilterIdList).val() + ","; //过滤条件中输入的值
HElement_type += document.getElementById(HFilterIdList).tagName + ",";//通过标签id获取标签类型
}
//去除末尾逗号
HFilterIdLists = HFilterIdLists.substring(0, HFilterIdLists.length - 1);
HValue = HValue.substring(0, HValue.length - 1);
HElement_type = HElement_type.substring(0, HElement_type.length - 1);
layer.open({
type: 2
, area: ['80%', '80%']
, title: '过滤方案列表'
, shift: 0//弹出动画
, content: '../../系统管理/过滤方案设置/Xt_FastICSchemeList.html?HType=Select&HFilterIdLists=' + HFilterIdLists + '&HValue=' + HValue + '&HElement_type=' + HElement_type + '&HModuleName=' + HModuleName
, cancel: function () {
// 右上角关闭事件的逻辑
HIsClose_Manual = true;
}
, end: function () {
if (HIsClose_Manual != true) {
get_FastQuery()
form.render("select");
}
}
})
}
//#region 【过滤方案返回数据】
function HFilterScheme(obj) //返回过滤方案
{
var HInterID = obj[0].hmainid;
HInterID_Choose = obj[0].hmainid;
$.ajax({
url: GetWEBURL() + '/Xt_FastICScheme/Chooselist',
type: "GET",
data: { "user": sessionStorage["Czybm"], "HModuleName": HModuleName, "HInterID": HInterID, "Type": "Select" },
success: function (data1) {
if (data1.count == 1) {
var data = data1.data;
//赋值过滤方案名称
HDefaultFilter = data[0].方案名称
var HRemark = data[0].备注
//显示当前的过滤方案
document.getElementById("HFilterScheme_Now").style.display = "block";
document.getElementById('HFilterScheme_Now').innerHTML = "当前过滤方案:" + HDefaultFilter + ' ' + "(" + HRemark + ")" + '';
HInterID = data[0].hmainid
//根据选择的过滤方案回填数据到列表过滤条件
for (let i = 0; i < data.length; i++) {
$("#" + data[i].过滤字段ID).val(data[i].过滤值);
if (data[i].过滤标签类型 == 'SELECT') {
$("#" + data[i].过滤字段ID).find("option[value='" + data[i].过滤值 + "']").attr("selected", true);
}
}
} else {
layer.close(ajaxLoad);
layer.alert(data1.code + data1.Message, { icon: 5 });
}
}, error: function () {
layer.close(ajaxLoad);
layer.alert("接口请求失败!", { icon: 5 });
}
});
}
//#endregion
//#endregion