| | |
| | | for (var i = 1; i < option.cols[0].length; i++) { |
| | | colName += option.cols[0][i]["field"] + ","; |
| | | } |
| | | |
| | | colName = encodeURI(colName.substring(0, colName.length - 1));//对 URI 进行编码 |
| | | |
| | | var contentUrl = ""; |
| | | var urlStr = window.document.location.pathname;//获取文件路径 |
| | | var urlLen = urlStr.split('/'); |
| | | for (var i = 0; i < urlLen.length - 4; i++) { |
| | | contentUrl += "../"; |
| | | } |
| | | contentUrl += '基础资料/隐藏列设置/Gy_GridView_Hide_New.html?HModName=' + HModName + '&colName=' + colName; |
| | | layer.open({ |
| | | type: 2 |
| | | , skin: "layui-layer-rim" //加上边框 |
| | |
| | | , shift: 2 //弹出动画 |
| | | , area: ["50%", "90%"] //窗体大小 |
| | | , maxmin: true //设置最大最小按钮是否显示 |
| | | , content: ['../../基础资料/隐藏列设置/Gy_GridView_Hide_New.html?HModName=' + HModName + '&colName=' + colName, "yes"] |
| | | , content: [contentUrl, "yes"] |
| | | , btn: ["确定", "取消"] |
| | | , btn1: function (index, laero) { |
| | | //刷新表格数据 |
| | |
| | | } |
| | | //#endregion |
| | | |
| | | //#region 隐藏列设置 没分页插件 |
| | | function get_HideColumnNoPage(HModName, user, option, get_FastQuery) { |
| | | var colName = ""; |
| | | for (var i = 1; i < option.cols[0].length; i++) { |
| | | colName += option.cols[0][i]["field"] + ","; |
| | | } |
| | | colName = encodeURI(colName.substring(0, colName.length - 1));//对 URI 进行编码 |
| | | |
| | | var contentUrl = ""; |
| | | var urlStr = window.document.location.pathname;//获取文件路径 |
| | | var urlLen = urlStr.split('/'); |
| | | for (var i = 0; i < urlLen.length - 4; i++) { |
| | | contentUrl += "../"; |
| | | } |
| | | contentUrl += '基础资料/隐藏列设置/Gy_GridView_Hide_New.html?HModName=' + HModName + '&colName=' + colName; |
| | | |
| | | layer.open({ |
| | | type: 2 |
| | | , skin: "layui-layer-rim" //加上边框 |
| | | , title: "隐藏列设置" //标题 |
| | | , closeBtn: 1 //窗体右上角关闭 的 样式 |
| | | , shift: 2 //弹出动画 |
| | | , area: ["50%", "90%"] //窗体大小 |
| | | , maxmin: true //设置最大最小按钮是否显示 |
| | | , content: [contentUrl, "yes"] |
| | | , btn: ["确定", "取消"] |
| | | , btn1: function (index, laero) { |
| | | //直接执行列表筛选 加载数据到网格 |
| | | get_FastQuery(); |
| | | //更新表格缓存的数据 |
| | | layer.close(index);//关闭弹窗 |
| | | } |
| | | }) |
| | | } |
| | | //#endregion |
| | | |
| | | //#region 设置表格页大小初始 |
| | | function DisPlay_HideColumn_GetPageSize(HModName, user,optionPage) { |
| | |
| | | }) |
| | | } |
| | | //#endregion |
| | | |
| | | //#region 显示列数据 |
| | | function DisPlay_HideColumn(HModName, user, option) { |
| | | function DisPlay_HideColumn(HModName, user, option, titleData) { |
| | | $.ajax({ |
| | | url: GetWEBURL() + '/Xt_grdAlignment_WMES/grdAlignmentWMESList', |
| | | type: "GET", |
| | |
| | | success: function (data1) { |
| | | if (data1.data.length != 0) { |
| | | var dataCol = [];//数据库查询出的列数据 |
| | | var titleData = []; |
| | | /* var titleData = [];*/ |
| | | var newCols = [[]];//对应数据库列顺序col |
| | | newCols[0].push(option.cols[0][0]);//放入第一个checkbox |
| | | dataCol = data1.data[0].HGridString.split(','); |
| | |
| | | option.cols[0][i + 1]["title"] = dataCols[4]; |
| | | } |
| | | newCols[0].push(option.cols[0][i + 1]); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | |
| | | } |
| | | } |
| | | } |
| | | } else { |
| | | } else { |
| | | } |
| | | }, error: function () { |
| | | layer.alert("接口请求失败!", { icon: 5 }); |
| | |
| | | }) |
| | | } |
| | | //#endregion |
| | | |
| | | |
| | | //#region 隐藏列设置编辑页面 |
| | | function get_HideColumnEdit(HModName,user,option,table) { |
| | | var colName = ""; |
| | | for (var i = 1; i < option.cols[0].length - 1; i++) { |
| | | colName += option.cols[0][i]["field"] + ","; |
| | | } |
| | | var colTitleName = ""; |
| | | for (var i = 1; i < option.cols[0].length - 1; i++) { |
| | | colTitleName += option.cols[0][i]["title"] + ","; |
| | | } |
| | | colName = encodeURI(colName.substring(0, colName.length - 1));//对 URI 进行编码 |
| | | colTitleName = encodeURI(colTitleName.substring(0, colTitleName.length - 1)); |
| | | /*urlStr.replace(/%/g, '%25');*/ |
| | | layer.open({ |
| | | type: 2 |
| | | , skin: "layui-layer-rim" //加上边框 |
| | | , title: "隐藏列设置" //标题 |
| | | , closeBtn: 1 //窗体右上角关闭 的 样式 |
| | | , shift: 2 //弹出动画 |
| | | , area: ["50%", "90%"] //窗体大小 |
| | | , maxmin: true //设置最大最小按钮是否显示 |
| | | , content: ['../../基础资料/隐藏列设置/Gy_GridView_Hide_New.html?HModName=' + HModName + '&colName=' + colName + '&colTitleName = ' + colTitleName, "yes"] |
| | | , btn: ["确定", "取消"] |
| | | , btn1: function (index, laero) { |
| | | //刷新表格数据 |
| | | DisPlay_HideColumnEdit(HModName, user, option,table); |
| | | //更新表格缓存的数据 |
| | | layer.close(index);//关闭弹窗 |
| | | } |
| | | }) |
| | | } |
| | | //#endregion |
| | | |
| | | //#region 显示列数据编辑页面 |
| | | function DisPlay_HideColumnEdit(HModName, user, option, table) { |
| | | $.ajax({ |
| | | url: GetWEBURL() + '/Xt_grdAlignment_WMES/grdAlignmentWMESList', |
| | | type: "GET", |
| | | async: false, |
| | | data: { "HModName": HModName, "user": user }, |
| | | success: function (data1) { |
| | | if (data1.data.length != 0) { |
| | | var dataCol = [];//数据库查询出的列数据 |
| | | var titleData = []; |
| | | var newCols = [[]];//对应数据库列顺序col |
| | | newCols[0].push(option.cols[0][0]);//放入第一个checkbox |
| | | dataCol = data1.data[0].HGridString.split(','); |
| | | //列设置列数与页面列数是否一致(去掉checkbox列和操作列) |
| | | if (dataCol.length == option.cols[0].length - 2) { |
| | | //遍历寻找列设置对应列按顺序插入 |
| | | for (var j = 0; j < option.cols[0].length - 2; j++) { |
| | | for (var i = 0; i < option.cols[0].length - 2; i++) { |
| | | var dataCols = dataCol[j].split('|'); |
| | | //选择与datacols相应列进行修改 |
| | | if (option.cols[0][i + 1]["field"] == dataCols[5]) { |
| | | //隐藏列 |
| | | if (dataCols[1] == 1) { |
| | | option.cols[0][i + 1]["hide"] = true; |
| | | } |
| | | //设置列宽 |
| | | if (dataCols[3] > 0) { |
| | | option.cols[0][i + 1]["width"] = dataCols[3]; |
| | | } |
| | | //设置内容字体大小 |
| | | if (data1.data[0].HFontSize != 0) { |
| | | option.cols[0][i + 1]["style"] = "font-size:" + data1.data[0].HFontSize + "px;"; |
| | | } else { |
| | | option.cols[0][i + 1]["style"] = "font-size:100%"; |
| | | } |
| | | //显示列 |
| | | if (dataCols[1] == 0 && $.inArray(option.cols[0][i + 1]["title"], titleData) == -1) { |
| | | option.cols[0][i + 1]["hide"] = false; |
| | | } |
| | | //统计列 |
| | | if (dataCols[6] == 1) { |
| | | option.cols[0][i + 1]["totalRow"] = true; |
| | | } |
| | | //字体所在位置(左 居中 右) |
| | | switch (dataCols[2]) { |
| | | case "L": |
| | | option.cols[0][i + 1]["align"] = "left"; |
| | | break; |
| | | case "M": |
| | | option.cols[0][i + 1]["align"] = "center"; |
| | | break; |
| | | case "R": |
| | | option.cols[0][i + 1]["align"] = "right"; |
| | | break; |
| | | } |
| | | //设置表格title属性显示别名 |
| | | if (dataCols[4] != null && dataCols[4] != "") { |
| | | option.cols[0][i + 1]["title"] = dataCols[4]; |
| | | } |
| | | newCols[0].push(option.cols[0][i + 1]); |
| | | } |
| | | } |
| | | } |
| | | //遍历循环后判断对应列数是否一致 |
| | | if (dataCol.length == newCols[0].length - 1) { |
| | | newCols[0].push(option.cols[0][dataCol.length+1])//放入最后的操作列 |
| | | option.cols = newCols; |
| | | //取消冻结列 |
| | | for (var i = 1; i < option.cols[0].length - 1; i++) { |
| | | if (option.cols[0][i]["fixed"] != null) { |
| | | option.cols[0][i]["fixed"] = null; |
| | | } |
| | | else { |
| | | break; |
| | | } |
| | | } |
| | | //冻结列 |
| | | if (data1.data[0].HFixCols != 0) { |
| | | for (var i = 0; i < data1.data[0].HFixCols; i++) { |
| | | if ($.inArray(option.cols[0][i + 1]["title"], titleData) != -1) { |
| | | data1.data[0].HFixCols += 1; |
| | | } |
| | | option.cols[0][i + 1]["fixed"] = "left"; |
| | | } |
| | | } |
| | | //设置列排序 |
| | | for (var i = 1; i < option.cols[0].length-1; i++) { |
| | | if (data1.data[0].HSortFlag == "是") { |
| | | option.cols[0][i]["sort"] = true; |
| | | } |
| | | else { |
| | | option.cols[0][i]["sort"] = false; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | table.render(option); |
| | | } else { |
| | | } |
| | | }, error: function () { |
| | | layer.alert("接口请求失败!", { icon: 5 }); |
| | | } |
| | | }) |
| | | } |
| | | //#endregion |
| | | |
| | | // 筛选函数:检查字符串是否符合格式筛选日期 |
| | | function isValidDate(dateStr) { |
| | | // 正则表达式验证格式 |
| | | const formatRegex = /^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])$/; |
| | | if (!formatRegex.test(dateStr)) return false; |
| | | |
| | | // 分割年月日并转换为数值 |
| | | const [year, month, day] = dateStr.split('-').map(Number); |
| | | |
| | | // 创建Date对象(月份从0开始) |
| | | const date = new Date(year, month - 1, day); |
| | | |
| | | // 检查日期是否有效(与输入的年月日一致) |
| | | return ( |
| | | date.getFullYear() === year && |
| | | date.getMonth() === month - 1 && |
| | | date.getDate() === day |
| | | ); |
| | | } |
| | | //统计函数,统计数组中日期格式的数量 |
| | | function countDate(strList) { |
| | | var count = 0; |
| | | for (var str of strList) { |
| | | if (isValidDate(str.field)) { |
| | | count++; |
| | | } |
| | | } |
| | | return count; |
| | | } |
| | | |
| | | //#region 隐藏列设置 没分页插件专门为排产有动态日期设置 |
| | | function get_HideColumnNoPageForPlan(HModName, option, get_FastQuery) { |
| | | var colName = ""; |
| | | let hasAddedData = false; |
| | | var colTitleName = ""; |
| | | for (var i = 1; i < option.cols[0].length; i++) { |
| | | //为日期格式时省略option的日期列,合成一列用于控制日期列格式 |
| | | if (isValidDate(option.cols[0][i]["field"])) { |
| | | if (!hasAddedData) { |
| | | colName += "通用计划日期格式,"; |
| | | colTitleName += "通用计划日期格式,"; |
| | | hasAddedData = true; |
| | | } |
| | | } else { |
| | | colName += option.cols[0][i]["field"] + ","; |
| | | colTitleName += option.cols[0][i]["title"] + ","; |
| | | } |
| | | |
| | | } |
| | | |
| | | colName = encodeURI(colName.substring(0, colName.length - 1));//对 URI 进行编码 |
| | | layer.open({ |
| | | type: 2 |
| | | , skin: "layui-layer-rim" //加上边框 |
| | | , title: "隐藏列设置" //标题 |
| | | , closeBtn: 1 //窗体右上角关闭 的 样式 |
| | | , shift: 2 //弹出动画 |
| | | , area: ["50%", "90%"] //窗体大小 |
| | | , maxmin: true //设置最大最小按钮是否显示 |
| | | , content: ['../../基础资料/隐藏列设置/Gy_GridView_Hide_New.html?HModName=' + HModName + '&colName=' + colName + '&colTitleName = ' + colTitleName, "yes"] |
| | | , btn: ["确定", "取消"] |
| | | , btn1: function (index, laero) { |
| | | //直接执行列表筛选 加载数据到网格 |
| | | get_FastQuery(); |
| | | //更新表格缓存的数据 |
| | | layer.close(index);//关闭弹窗 |
| | | } |
| | | }) |
| | | } |
| | | //#endregion |
| | | |
| | | //#region 显示列数据 专门为排产 |
| | | function DisPlay_HideColumnForPlan(HModName, user, option) { |
| | | $.ajax({ |
| | | url: GetWEBURL() + '/Xt_grdAlignment_WMES/grdAlignmentWMESList', |
| | | type: "GET", |
| | | async: false, |
| | | data: { "HModName": HModName, "user": user }, |
| | | success: function (data1) { |
| | | if (data1.data.length != 0) { |
| | | var dataCol = [];//数据库查询出的列数据 |
| | | var titleData = []; |
| | | var newCols = [[]];//对应数据库列顺序col |
| | | newCols[0].push(option.cols[0][0]);//放入第一个checkbox |
| | | dataCol = data1.data[0].HGridString.split(','); |
| | | var count = countDate(option.cols[0]); |
| | | //列设置列数与页面列数是否一致 |
| | | if (dataCol.length == option.cols[0].length - count) { |
| | | //遍历寻找列设置对应列按顺序插入 |
| | | for (var j = 0; j < option.cols[0].length - count; j++) { |
| | | for (var i = 0; i < option.cols[0].length - 1; i++) { |
| | | var dataCols = dataCol[j].split('|'); |
| | | //选择与datacols相应列进行修改 |
| | | if (option.cols[0][i + 1]["field"] == dataCols[5]) { |
| | | //隐藏列 |
| | | if (dataCols[1] == 1) { |
| | | option.cols[0][i + 1]["hide"] = true; |
| | | } |
| | | //设置列宽 |
| | | if (dataCols[3] > 0) { |
| | | option.cols[0][i + 1]["width"] = dataCols[3]; |
| | | } |
| | | //设置内容字体大小 |
| | | if (data1.data[0].HFontSize != 0) { |
| | | option.cols[0][i + 1]["style"] = "font-size:" + data1.data[0].HFontSize + "px;"; |
| | | } else { |
| | | option.cols[0][i + 1]["style"] = "font-size:100%"; |
| | | } |
| | | //显示列 |
| | | if (dataCols[1] == 0 && $.inArray(option.cols[0][i + 1]["title"], titleData) == -1) { |
| | | option.cols[0][i + 1]["hide"] = false; |
| | | } |
| | | //统计列 |
| | | if (dataCols[6] == 1) { |
| | | option.cols[0][i + 1]["totalRow"] = true; |
| | | } |
| | | //字体所在位置(左 居中 右) |
| | | switch (dataCols[2]) { |
| | | case "L": |
| | | option.cols[0][i + 1]["align"] = "left"; |
| | | break; |
| | | case "M": |
| | | option.cols[0][i + 1]["align"] = "center"; |
| | | break; |
| | | case "R": |
| | | option.cols[0][i + 1]["align"] = "right"; |
| | | break; |
| | | } |
| | | //设置表格title属性显示别名 |
| | | if (dataCols[4] != null && dataCols[4] != "") { |
| | | option.cols[0][i + 1]["title"] = dataCols[4]; |
| | | } |
| | | newCols[0].push(option.cols[0][i + 1]); |
| | | break; |
| | | } |
| | | //设置通用日期格式 |
| | | else if (dataCols[5] == "通用计划日期格式" && isValidDate(option.cols[0][i + 1]["field"])) { |
| | | //隐藏列 |
| | | if (dataCols[1] == 1) { |
| | | option.cols[0][i + 1]["hide"] = true; |
| | | } |
| | | //设置列宽 |
| | | if (dataCols[3] > 0) { |
| | | option.cols[0][i + 1]["width"] = dataCols[3]; |
| | | } |
| | | //设置内容字体大小 |
| | | if (data1.data[0].HFontSize != 0) { |
| | | option.cols[0][i + 1]["style"] = "font-size:" + data1.data[0].HFontSize + "px;"; |
| | | } else { |
| | | option.cols[0][i + 1]["style"] = "font-size:100%"; |
| | | } |
| | | //显示列 |
| | | if (dataCols[1] == 0 && $.inArray(option.cols[0][i + 1]["title"], titleData) == -1) { |
| | | option.cols[0][i + 1]["hide"] = false; |
| | | } |
| | | //统计列 |
| | | if (dataCols[6] == 1) { |
| | | option.cols[0][i + 1]["totalRow"] = true; |
| | | } |
| | | //字体所在位置(左 居中 右) |
| | | switch (dataCols[2]) { |
| | | case "L": |
| | | option.cols[0][i + 1]["align"] = "left"; |
| | | break; |
| | | case "M": |
| | | option.cols[0][i + 1]["align"] = "center"; |
| | | break; |
| | | case "R": |
| | | option.cols[0][i + 1]["align"] = "right"; |
| | | break; |
| | | } |
| | | newCols[0].push(option.cols[0][i + 1]); |
| | | } |
| | | } |
| | | } |
| | | //遍历循环后判断对应列数是否一致 |
| | | if (dataCol.length == newCols[0].length - count) { |
| | | option.cols = newCols; |
| | | //取消冻结列 |
| | | for (var i = 1; i < option.cols[0].length - 1; i++) { |
| | | if (option.cols[0][i]["fixed"] != null) { |
| | | option.cols[0][i]["fixed"] = null; |
| | | } |
| | | else { |
| | | break; |
| | | } |
| | | } |
| | | //冻结列 |
| | | if (data1.data[0].HFixCols != 0) { |
| | | for (var i = 0; i < data1.data[0].HFixCols; i++) { |
| | | if ($.inArray(option.cols[0][i + 1]["title"], titleData) != -1) { |
| | | data1.data[0].HFixCols += 1; |
| | | } |
| | | option.cols[0][i + 1]["fixed"] = "left"; |
| | | } |
| | | } |
| | | //设置列排序 |
| | | for (var i = 1; i < option.cols[0].length; i++) { |
| | | if (data1.data[0].HSortFlag == "是") { |
| | | option.cols[0][i]["sort"] = true; |
| | | } |
| | | else { |
| | | option.cols[0][i]["sort"] = false; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } else { |
| | | } |
| | | }, error: function () { |
| | | layer.alert("接口请求失败!", { icon: 5 }); |
| | | } |
| | | }) |
| | | } |
| | | //#endregion |
| | | |
| | | |