From e26fb427a00a7feaa176ca26d2323249f09a3b31 Mon Sep 17 00:00:00 2001
From: zrg <z1873@LAPTOP-EAVL132E>
Date: 星期三, 05 十一月 2025 16:01:44 +0800
Subject: [PATCH] 销售出库增加一个excel导入不同页签,测试调试产量汇报下推生产汇报
---
WebTM/layuiadmin/SetColumn.js | 486 ++++++++++++++++++++++++++++++++++++++++++++----------
1 files changed, 396 insertions(+), 90 deletions(-)
diff --git a/WebTM/layuiadmin/SetColumn.js b/WebTM/layuiadmin/SetColumn.js
index cc5e74c..006e9c6 100644
--- a/WebTM/layuiadmin/SetColumn.js
+++ b/WebTM/layuiadmin/SetColumn.js
@@ -1,4 +1,7 @@
-锘�//#region 闅愯棌鍒楄缃�
+锘�
+//#region 鏌ヨ椤甸潰鐩稿叧鍒楀嚱鏁�
+
+//#region 闅愯棌鍒楄缃脊绐� 鏈夊悗绔垎椤�
function get_HideColumn(HModName, user, option, optionPage, get_FastQuery) {
var colName = "";
for (var i = 1; i < option.cols[0].length; i++) {
@@ -6,13 +9,15 @@
}
colName = encodeURI(colName.substring(0, colName.length - 1));//瀵� URI 杩涜缂栫爜
- var contentUrl = "";
+ var contentUrl = "";
var urlStr = window.document.location.pathname;//鑾峰彇鏂囦欢璺緞
+ var viewsLocation = urlStr.indexOf('views')
+ urlStr = urlStr.substring(viewsLocation + 6, urlStr.length)
var urlLen = urlStr.split('/');
- for (var i = 0; i < urlLen.length - 4; i++) {
+ for (var i = 0; i < urlLen.length - 1; i++) {
contentUrl += "../";
}
- contentUrl += '鍩虹璧勬枡/闅愯棌鍒楄缃�/Gy_GridView_Hide_New.html?HModName=' + HModName + '&colName=' + colName;
+ contentUrl += '鍩虹璧勬枡/闅愯棌鍒楄缃�/Gy_GridView_Hide_New.html?HModName=' + HModName + '&colName=' + colName;
layer.open({
type: 2
, skin: "layui-layer-rim" //鍔犱笂杈规
@@ -36,14 +41,23 @@
}
//#endregion
-//#region 闅愯棌鍒楄缃� 娌″垎椤垫彃浠�
+//#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 viewsLocation = urlStr.indexOf('views')
+ urlStr = urlStr.substring(viewsLocation + 6, urlStr.length)
+ var urlLen = urlStr.split('/');
+ for (var i = 0; i < urlLen.length - 1; i++) {
+ contentUrl += "../";
+ }
+ contentUrl += '鍩虹璧勬枡/闅愯棌鍒楄缃�/Gy_GridView_Hide_New.html?HModName=' + HModName + '&colName=' + colName;
layer.open({
type: 2
, skin: "layui-layer-rim" //鍔犱笂杈规
@@ -52,7 +66,7 @@
, 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) {
//鐩存帴鎵ц鍒楄〃绛涢�� 鍔犺浇鏁版嵁鍒扮綉鏍�
@@ -65,7 +79,7 @@
//#endregion
//#region 璁剧疆琛ㄦ牸椤靛ぇ灏忓垵濮�
-function DisPlay_HideColumn_GetPageSize(HModName, user,optionPage) {
+function DisPlay_HideColumn_GetPageSize(HModName, user, optionPage) {
$.ajax({
url: GetWEBURL() + '/Xt_grdAlignment_WMES/grdAlignmentWMESList',
type: "GET",
@@ -77,7 +91,7 @@
optionPage.limit = data1.data[0].HPageSize;
optionPage.limits.push(data1.data[0].HPageSize);
}
-
+
} else {
}
}, error: function () {
@@ -97,7 +111,7 @@
success: function (data1) {
if (data1.data.length != 0) {
var dataCol = [];//鏁版嵁搴撴煡璇㈠嚭鐨勫垪鏁版嵁
- /* var titleData = [];*/
+ /* var titleData = [];*/
var newCols = [[]];//瀵瑰簲鏁版嵁搴撳垪椤哄簭col
newCols[0].push(option.cols[0][0]);//鏀惧叆绗竴涓猚heckbox
dataCol = data1.data[0].HGridString.split(',');
@@ -117,11 +131,11 @@
if (dataCols[3] > 0) {
option.cols[0][i + 1]["width"] = dataCols[3];
}
- //璁剧疆鍐呭瀛椾綋澶у皬
+ //璁剧疆鍐呭瀛椾綋澶у皬 鐩存帴瑕嗙洊鐨勮瘽浼氬鑷村師鏈夌殑鏍峰紡娑堝け锛屾晠浣跨敤鍦╯tyle涓缃甶mportant寮哄埗鍚敤鐨勬柟寮�
if (data1.data[0].HFontSize != 0) {
- option.cols[0][i + 1]["style"] = "font-size:" + data1.data[0].HFontSize + "px;";
+ option.cols[0][i + 1]["style"]+="font-size:" + data1.data[0].HFontSize + " !important px;";
} else {
- option.cols[0][i + 1]["style"] = "font-size:100%";
+ option.cols[0][i + 1]["style"]+= "font-size:100% !important;";
}
//鏄剧ず鍒�
if (dataCols[1] == 0 && $.inArray(option.cols[0][i + 1]["title"], titleData) == -1) {
@@ -193,42 +207,9 @@
}
//#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) {
+//#region 鏄剧ず鍒楁暟鎹� 鏈夊洖璋冨嚱鏁�
+function DisPlay_HideColumnWithCallback(HModName, user, option, titleData, callback) {
+
$.ajax({
url: GetWEBURL() + '/Xt_grdAlignment_WMES/grdAlignmentWMESList',
type: "GET",
@@ -237,15 +218,15 @@
success: function (data1) {
if (data1.data.length != 0) {
var dataCol = [];//鏁版嵁搴撴煡璇㈠嚭鐨勫垪鏁版嵁
- var titleData = [];
+ /* var titleData = []; */
var newCols = [[]];//瀵瑰簲鏁版嵁搴撳垪椤哄簭col
newCols[0].push(option.cols[0][0]);//鏀惧叆绗竴涓猚heckbox
dataCol = data1.data[0].HGridString.split(',');
- //鍒楄缃垪鏁颁笌椤甸潰鍒楁暟鏄惁涓�鑷�(鍘绘帀checkbox鍒楀拰鎿嶄綔鍒�)
- if (dataCol.length == option.cols[0].length - 2) {
+ //鍒楄缃垪鏁颁笌椤甸潰鍒楁暟鏄惁涓�鑷�
+ if (dataCol.length == option.cols[0].length - 1) {
//閬嶅巻瀵绘壘鍒楄缃搴斿垪鎸夐『搴忔彃鍏�
- for (var j = 0; j < option.cols[0].length - 2; j++) {
- for (var i = 0; i < option.cols[0].length - 2; i++) {
+ for (var j = 0; j < option.cols[0].length - 1; j++) {
+ for (var i = 0; i < option.cols[0].length - 1; i++) {
var dataCols = dataCol[j].split('|');
//閫夋嫨涓巇atacols鐩稿簲鍒楄繘琛屼慨鏀�
if (option.cols[0][i + 1]["field"] == dataCols[5]) {
@@ -287,13 +268,12 @@
if (dataCols[4] != null && dataCols[4] != "") {
option.cols[0][i + 1]["title"] = dataCols[4];
}
- newCols[0].push(option.cols[0][i + 1]);
+ break;
}
}
}
//閬嶅巻寰幆鍚庡垽鏂搴斿垪鏁版槸鍚︿竴鑷�
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++) {
@@ -314,7 +294,7 @@
}
}
//璁剧疆鍒楁帓搴�
- for (var i = 1; i < option.cols[0].length-1; i++) {
+ for (var i = 1; i < option.cols[0].length; i++) {
if (data1.data[0].HSortFlag == "鏄�") {
option.cols[0][i]["sort"] = true;
}
@@ -323,8 +303,8 @@
}
}
}
+ callback.call()
}
- table.render(option);
} else {
}
}, error: function () {
@@ -334,37 +314,7 @@
}
//#endregion
-// 绛涢�夊嚱鏁帮細妫�鏌ュ瓧绗︿覆鏄惁绗﹀悎鏍煎紡绛涢�夋棩鏈�
-function isValidDate(dateStr) {
- // 姝e垯琛ㄨ揪寮忛獙璇佹牸寮�
- 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 闅愯棌鍒楄缃� 娌″垎椤垫彃浠朵笓闂ㄤ负鎺掍骇鏈夊姩鎬佹棩鏈熻缃�
+//#region 闅愯棌鍒楄缃脊绐� 娌″垎椤垫彃浠朵笓闂ㄤ负鎺掍骇鏈夊姩鎬佹棩鏈熻缃�
function get_HideColumnNoPageForPlan(HModName, option, get_FastQuery) {
var colName = "";
let hasAddedData = false;
@@ -381,7 +331,7 @@
colName += option.cols[0][i]["field"] + ",";
colTitleName += option.cols[0][i]["title"] + ",";
}
-
+
}
colName = encodeURI(colName.substring(0, colName.length - 1));//瀵� URI 杩涜缂栫爜
@@ -550,4 +500,360 @@
}
//#endregion
+//#endregion
+
+//#region 缂栬緫椤甸潰琛ㄦ牸鍒楄缃浉鍏冲嚱鏁�
+
+//#region 闅愯棌鍒楄缃脊绐� 缂栬緫椤甸潰
+function get_HideColumnEdit(HModName, user, option, table, cancelEditStyleList) {
+ 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, cancelEditStyleList);
+ //鏇存柊琛ㄦ牸缂撳瓨鐨勬暟鎹�
+ layer.close(index);//鍏抽棴寮圭獥
+ }
+ })
+}
+//#endregion
+
+//#region 闅愯棌鍒楄缃脊绐� 缂栬緫椤甸潰 甯﹀洖璋冿紝鐢ㄤ簬璁剧疆涓嶅彲缂栬緫鍒�
+function get_HideColumnEditWithCallback(HModName, user, option, table, callback) {
+ 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);//鍏抽棴寮圭獥
+ callback.call()
+ }
+ })
+}
+//#endregion
+
+//#region 鏄剧ず鍒楁暟鎹� 缂栬緫椤甸潰
+function DisPlay_HideColumnEdit(HModName, user, option, table, cancelEditStyleList) {
+ $.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]);//鏀惧叆绗竴涓猚heckbox
+ 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('|');
+ //閫夋嫨涓巇atacols鐩稿簲鍒楄繘琛屼慨鏀�
+ 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;
+ }
+ }
+ }
+ //璁剧疆涓嶅彲缂栬緫鏍峰紡
+ if (cancelEditStyleList !== undefined) {
+ ColumnAddNotEditableStyle(cancelEditStyleList, option);
+ }
+
+ }
+
+ table.render(option);
+
+ } else {
+ }
+ }, error: function () {
+ layer.alert("鎺ュ彛璇锋眰澶辫触!", { icon: 5 });
+ }
+ })
+}
+//#endregion
+
+//#endregion
+
+
+/**
+ * 缁欎笉鍏佽缂栬緫鐨勬暟鎹坊鍔犳牱寮�
+ * @param {any} regExp
+ * @param {any} _option
+ */
+function ColumnAddNotEditableStyle(regExp, _option) {
+ let notEditableStyle = "; background: #e2e2e2;"
+ opt = _option;
+ for (let col of opt.cols[0]) {
+ if (regExp.test(col.field) === true) {
+ col.style += notEditableStyle;
+ }
+ }
+}
+/**
+ * 绛涢�夊嚱鏁帮細妫�鏌ュ瓧绗︿覆鏄惁绗﹀悎鏍煎紡绛涢�夋棩鏈�
+ * @param {any} dateStr
+ */
+function isValidDate(dateStr) {
+ // 姝e垯琛ㄨ揪寮忛獙璇佹牸寮�
+ 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
+ );
+}
+/**
+ * 缁熻鍑芥暟锛岀粺璁℃暟缁勪腑鏃ユ湡鏍煎紡鐨勬暟閲�
+ * @param {any} strList
+ */
+function countDate(strList) {
+ var count = 0;
+ for (var str of strList) {
+ if (isValidDate(str.field)) {
+ count++;
+ }
+ }
+ return count;
+}
+
+
+function buildFilterWhere(colName, comparator, colContent, Logical_judgement, sWhere) {
+ if (!colName || !comparator || comparator === "0") return "";
+ else if (sWhere == "") {
+ var com = "";
+ switch (comparator) {
+ case "7":
+ com = "like''%" + colContent + "%''";
+ break;
+ case "8":
+ com = "like''%" + colContent + "''";
+ break;
+ case "9":
+ com = "like''" + colContent + "%''";
+ break;
+ case "10":
+ com = "not like''%" + colContent + "%''";
+ break;
+ default:
+ com = "" + comparator + "''" + colContent + "''";
+ break;
+ }
+ return " and " + "("+colName + " " + com ;
+ }
+ else if (sWhere != "")
+ {
+ var com = "";
+ switch (comparator) {
+ case "7":
+ com = "like''%" + colContent + "%''";
+ break;
+ case "8":
+ com = "like''%" + colContent + "''";
+ break;
+ case "9":
+ com = "like''" + colContent + "%''";
+ break;
+ case "10":
+ com = "not like''%" + colContent + "%''";
+ break;
+ default:
+ com = "" + comparator + "''" + colContent + "''";
+ break;
+ }
+ return Logical_judgement === "鎴�" ? " or " + colName + " " + com + ")" : " and " + colName + " " + com + ")";
+ }
+ else {
+
+ var com = "";
+ switch (comparator) {
+ case "7":
+ com = "like''%" + colContent + "%''";
+ break;
+ case "8":
+ com = "like''%" + colContent + "''";
+ break;
+ case "9":
+ com = "like''" + colContent + "%''";
+ break;
+ case "10":
+ com = "not like''%" + colContent + "%''";
+ break;
+ default:
+ com = "" + comparator + "''" + colContent + "''";
+ break;
+ }
+ return " and " + colName + " " + com;
+
+ }
+
+}
+function fixParenthesesMatching(swhere) {
+ const keywordEndPositions = [];
+ const keywordRegex = /\b(and|or)\b/gi;
+ let match;
+ while ((match = keywordRegex.exec(swhere)) !== null) {
+ keywordEndPositions.push(match.index + match[0].length);
+ }
+ keywordEndPositions.sort((a, b) => a - b);
+
+
+ let leftCount = 0;
+ const insertPositions = [];
+ const workingKeywordPositions = [...keywordEndPositions];
+
+ for (let i = 0; i < swhere.length; i++) {
+ if (swhere[i] === '(') {
+ leftCount++;
+ } else if (swhere[i] === ')') {
+ leftCount--;
+
+ if (leftCount < 0) {
+
+ let insertIndex = -1;
+ for (let j = workingKeywordPositions.length - 1; j >= 0; j--) {
+ if (workingKeywordPositions[j] < i) {
+ insertIndex = workingKeywordPositions[j];
+ workingKeywordPositions.splice(j, 1);
+ break;
+ }
+ }
+
+ insertPositions.push(insertIndex !== -1 ? insertIndex : 0);
+ leftCount = 0;
+ }
+ }
+ }
+
+ let result = swhere;
+ insertPositions
+ .sort((a, b) => b - a)
+ .forEach(pos => {
+ result = result.slice(0, pos) + '(' + result.slice(pos);
+ });
+
+ return result;
+}
+
--
Gitblit v1.9.1