Przeglądaj źródła

调整同步按钮显示问题 和 文件类型同步限制

huangguoce 1 tydzień temu
rodzic
commit
a2b22c789e

+ 67 - 23
src/main/webapp/webpage/modules/projectcontentinfo/projectCaseBaseSupplementAudit.jsp

@@ -2015,7 +2015,7 @@
 														<c:when test="${projectReportRecord.uploadMode == 2}">
 															<c:choose>
 																<c:when test="${fn:containsIgnoreCase(workClientAttachment.attachmentName,'pdf')}">
-																	<a href="${workClientAttachment.temporaryUrl}" target="_blank" class="op-btn op-btn-download"><i class="fa fa-download"></i>&nbsp;下载</a>
+																	<a href="${workClientAttachment.temporaryUrl}" target="_blank" class="op-btn op-btn-download"><i class="fa fa-download"></i>&nbsp;下载1</a>
 																</c:when>
 																<c:otherwise>
 																	<a href="${workClientAttachment.temporaryUrl}" class="op-btn op-btn-download"><i class="fa fa-download"></i>&nbsp;下载</a>
@@ -2247,6 +2247,7 @@
 		}
 		top.layer.open({
 			type: 2,
+			name : "iframeRefresh",
 			area: [width, height],
 			title: title,
 			skin:"two-btns",
@@ -2271,7 +2272,7 @@
 
 			},
 			cancel: function(index){
-			}
+			},
 		});
 	}
 	function formSubmit2($document,inputForm,index,tableId){
@@ -2292,24 +2293,26 @@
 			}
 		});
 		if(validateForm.form()){
-			var action = $document.getElementById(inputForm).action;
-			var handleInfo = $($document.getElementById(inputForm)).serialize();
-			$.ajax({
-				type : "POST",
-				url : action,
-				data : handleInfo,
-				//请求成功
-				success:function(data) {
-					var d = data;
-					//输出提示信息
-					if(d.str.length>0){
-						parent.layer.msg(d.str,{icon:1});
+				var action = $document.getElementById(inputForm).action;
+				var handleInfo = $($document.getElementById(inputForm)).serialize();
+				$.ajax({
+					type : "POST",
+					url : action,
+					data : handleInfo,
+					//请求成功
+					success:function(data) {
+						var d = data;
+						//输出提示信息
+						if(d.str.length>0){
+							parent.layer.msg(d.str,{icon:1});
+						}
+                        //将数据临时挂载在父级页面
+                        parent.tempSyncIds = [...confirmIdList]
+                        location.reload();
+						top.layer.close(index)
 					}
-					$("#"+tableId).load(location.href + " #"+tableId);
-					//关闭当前页
-					top.layer.close(index)
-				}
-			});
+				});
+
 		}
 	}
 
@@ -2526,7 +2529,8 @@
 		<c:forEach var="attachment" items="${item.workAttachments}">
 		{
 			id: '${attachment.id}',
-			syncDifySync: '${attachment.syncDifySync}'
+			syncDifySync: '${attachment.syncDifySync}',
+			attachmentName:'${attachment.attachmentName}'
 		}
 		<c:if test="${!i.last || !attachment.last}">,</c:if>
 		</c:forEach>
@@ -2535,6 +2539,36 @@
 
 	var confirmIdList = [];  // 用于存储已同步的项的 id
 
+	//文件类型列表
+	const fileExtensions = [
+		"MARKDOWN",
+		"MDX",
+		"PDF",
+		"XLSX",
+		"XLS",
+		"DOCX",
+		"TXT",
+		"HTML",
+		"CSV",
+		"VTT",
+		"PROPERTIES",
+		"MD",
+		"HTM"
+	];
+
+	// 判断后缀
+	function isSupportedExtension(attachmentName) {
+		if (typeof attachmentName !== 'string') return false;
+
+		const parts = attachmentName.split('.');
+		if (parts.length < 2) return false; // 没有后缀
+
+		const ext = parts.pop().toUpperCase();
+
+		return fileExtensions.includes(ext);
+	}
+
+
 	// 初始化同步状态列表
 	function initConfirmIdList() {
 		confirmIdList = allDataList.filter(item => item.syncDifySync === '1').map(item => item.id);
@@ -2544,6 +2578,10 @@
 	// 渲染按钮
 	function renderButtons() {
 		allDataList.forEach(function(item) {
+			// 判断文件类型
+			if(!isSupportedExtension(item.attachmentName)){
+				return
+			}
 			// 获取当前行(tr)元素和最后一个 td 元素
 			var trEl = document.getElementById('addFile_caseBase_' + item.id + '_tr');
 			if (!trEl) return;
@@ -2553,7 +2591,6 @@
 
 			// 获取现有的同步或取消同步按钮
 			var existingConfirmBtn = tdEl.querySelector('.op-btn-confirm'); // 只选择同步按钮
-
 			// 如果同步按钮已存在
 			if (existingConfirmBtn) {
 				if (confirmIdList.indexOf(item.id) !== -1) {
@@ -2592,7 +2629,6 @@
 				trEl.style.backgroundColor = '';  // 清除背景色
 			}
 		});
-
 		// 每次渲染按钮后更新 selectedIds
 		updateSelectedIds();
 	}
@@ -2620,7 +2656,15 @@
 	}
 
 	window.onload = function() {
-		initConfirmIdList();
+		// 获取临时挂载在父级页面的数据
+		var tempConfirmIdList = parent.tempSyncIds
+		// 判断临时数据是否存在
+		if(tempConfirmIdList){
+			confirmIdList =	[...tempConfirmIdList]
+			parent.tempSyncIds = null
+		}else{
+			initConfirmIdList();
+		}
 		renderButtons();
 	};