瀏覽代碼

前端"工件入库记录"页面,隐藏空白列

17491 2 天之前
父節點
當前提交
fbb022fa26
共有 1 個文件被更改,包括 21 次插入3 次删除
  1. 21 3
      src/main/resources/views/modules/mes/mesProductStorageRecordList.html

+ 21 - 3
src/main/resources/views/modules/mes/mesProductStorageRecordList.html

@@ -149,10 +149,28 @@ $('#dataGrid').dataGrid({
 			return actions.join('');
 		}}
 	],
-	frozenCols: true,
 	// 加载成功后执行事件
 	ajaxSuccess: function(data){
-		
+		var rows = data && (data.list || data.rows || data.data) || [];
+		if (!$.isArray(rows) || rows.length === 0) {
+			return;
+		}
+
+		// 当前页所有记录都为空的业务列不显示;有数据时恢复显示。
+		var hideWhenEmpty = [
+			'batchSn', 'batchSn2', 'relationSn2', 'customerName', 'productModel',
+			'orderNo', 'coldPlateQr', 'cpleak', 'slleak', 'createBy', 'createDate', 'remark'
+		];
+		var grid = $('#dataGrid');
+		grid.jqGrid('showCol', hideWhenEmpty);
+		$.each(hideWhenEmpty, function(index, name){
+			var hasValue = $.grep(rows, function(row){
+				return row[name] !== null && row[name] !== undefined && String(row[name]).trim() !== '';
+			}).length > 0;
+			if (!hasValue) {
+				grid.jqGrid('hideCol', name);
+			}
+		});
 	}
 });
 
@@ -203,4 +221,4 @@ $.ajax({
 		}
 	}
 });
-</script>
+</script>