From 1e955583470b47f7636eaba800c52c258ac24296 Mon Sep 17 00:00:00 2001
From: wanglizhong <wlz>
Date: 星期一, 28 四月 2025 21:26:10 +0800
Subject: [PATCH] fix:将开单人跟单人放到服务单中

---
 ServiceOrder.gds |  321 +++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 308 insertions(+), 13 deletions(-)

diff --git a/ServiceOrder.gds b/ServiceOrder.gds
index db338b0..21baf3a 100644
--- a/ServiceOrder.gds
+++ b/ServiceOrder.gds
@@ -1181,6 +1181,289 @@
 										
 										</div>
 							</div>
+							<div class="field">
+								<!-- 寮�鍗曚汉 -->
+								<%
+								EntourageID_OpenUser = "-8"
+								departmentID_OpenUser = "9"
+								OpenUserID = ""
+								OpenUserName = ""
+								OpenUserRatio = ""
+								OpenerAndFollowerEnableModify = False
+								if isDepartment("020140")=1 then
+									OpenerAndFollowerEnableModify=True
+								End If
+
+								If ServiceOrdID<>"" Then
+									openSql="select * from ServiceOrderCommissionDetails where ServiceOrderID="&ServiceOrdID&" and PersonType='Opener'"
+									rs.open openSql,objConn,1,1
+									If not rs.Eof Then
+									OpenUserID = rs("PersonID")
+									OpenUserName = rs("PersonName")
+									OpenUserRatio = rs("CommissionRatio")
+									End If
+									rs.close()
+								End If
+								%>
+								
+								<div class="label" style="float: left;margin-left: 0px;"><label for="input-small">寮�鍗曚汉:</label></div>
+								<div class="input" style="float:left;margin-left: 70px;">
+									<input id="Entourage_<%=EntourageID_OpenUser%>" name="OpenUserID" type="hidden" value="<%=OpenUserID%>">
+									<input type="text" id="EntourageName_<%=EntourageID_OpenUser%>" name="OpenUserName" <% if OpenerAndFollowerEnableModify=False Then%> disabled <% end If%> class="small" <%If OpenUserID="" Or OpenerAndFollowerEnableModify=True Then%>onclick="javascript:JS_EntourageOpen('<%=EntourageID_OpenUser%>','-<%=departmentID_OpenUser%>');"<%End If%> style="width:138px;" value="<%=OpenUserName%>" readonly="true">
+								</div>
+								<%
+									followerCount = 0
+									showFollower = False
+									If ServiceOrdID<>"" Then
+										followerSqlCount="select count(1) from ServiceOrderCommissionDetails where ServiceOrderID="&ServiceOrdID&" and PersonType='Follower'"
+										rs.open followerSqlCount,objConn,1,1
+										If Not rs.EOF Then
+											' 鑾峰彇鏌ヨ缁撴灉
+											followerCount = rs.Fields(0).Value
+											if followerCount>0 then
+												showFollower = True
+											else
+												showFollower = False
+											end if
+										Else
+											' 濡傛灉璁板綍闆嗕负绌猴紝灏嗙粨鏋滆涓� 0
+											followerCount = 0
+											showFollower = False
+										End If
+										rs.close()
+									End If
+									EditFollower=True
+									showTopFollowerAdd=True
+									if showFollower=True then
+										showTopFollowerAdd=False
+									End If
+									if OpenerAndFollowerEnableModify=False Then
+										EditFollower=False
+										showTopFollowerAdd=False
+									End If
+									
+									
+
+								%>
+								
+								<div class="label" style="float: left;margin-left: 226px;"><label for="input-small">鎻愭垚姣斾緥(%):</label></div>
+								<div class="input" style="float:left;margin-left: 86px;">								
+									<input type="text" id="OpenUserRatio" name="OpenUserRatio" <% if EditFollower=False Then%> disabled <% end If%> value="<%=OpenUserRatio%>" class="small" style="width:50px;">
+								</div>
+								<div class="input" style="float:left;margin-left: 10px;">
+								<button class="ui-state-default" <% If showTopFollowerAdd=False then %> style='display:none' <% End If%> id="inputTopAddFollower" onclick="return showFollower();">娣诲姞璺熷崟浜�</button>
+								</div>
+								</div>
+							
+								<div class="field" id="followerDiv" <% If showFollower<>True  then %> style="display:none;" <% end if%>>
+									<!-- 璺熷崟浜� -->
+									<input type="hidden" id="hidFollowerCount" name="FollowersCount" value="<%=followerCount%>"/>
+									<div class="label" style="float: left;margin-left: 10px;"><label for="input-small">璺熷崟浜�:</label></div>
+									<div class="input" style="float:left;margin-left: 70px;">
+										<div id="FollowersList">
+											<%
+											FollowerCount = 1
+											EntourageID_Follower = "-9"
+											departmentID_Follower = "9"			
+											if ServiceOrdID<>"" then							
+												followerSql="select * from ServiceOrderCommissionDetails where ServiceOrderID="&ServiceOrdID&" and PersonType='Follower'"
+												rs.open followerSql,objConn,1,1
+												FollowerIndex=1
+												do while not rs.Eof
+													FollowerID = rs("PersonID")
+													FollowerName = rs("PersonName")
+													FollowerRatio = rs("CommissionRatio")
+
+											%>
+											<div class="follower-item">
+												<input  name="FollowerID_<%=FollowerIndex%>" id="FollowerId_<%=FollowerIndex%>" type="hidden" value="<%=FollowerID%>">
+												<input type="text" name="FollowerName_<%=FollowerIndex%>"  <% if EditFollower=False Then %> disabled <% End If%> id="FollowerName_<%=FollowerIndex%>" class="small" <%If FollowerID="" Or isDepartment("020140")=1 Then%>onclick="javascript:JS_EntourageOpen('<%=EntourageID_Follower%>_<%=FollowerCount%>','-<%=departmentID_Follower%>');"<%End If%> style="width:138px;" value="<%=FollowerName%>" readonly="true">
+												<div class="label" style="float: left;margin-left: 226px;"><label for="input-small">鎻愭垚姣斾緥(%):</label></div>
+												<div class="input" style="float:left;margin-left: 87px;">
+													<input type="text" id="FollowerRatio_<%=FollowerIndex%>"  <% if EditFollower=False Then %> disabled <% End If%> name="FollowerRatio_<%=FollowerIndex%>" class="small" style="width:50px;" value="<%=FollowerRatio%>" />
+												</div>
+												<div class="input" style="float:left;margin-left: 10px;"> 
+													<button <% if EditFollower=False Then %> style="display:none" <% End If%> onclick="return removeFollower();">鍒犻櫎</button>
+												</div>
+											</div>
+											<%
+												FollowerIndex=FollowerIndex+1
+												rs.movenext
+												loop
+												rs.close()
+											End If
+											%>
+										</div>
+										<button  <% if EditFollower=False Then %> style="display:none" <% End If%> class="ui-state-default" onclick="return addFollower()">娣诲姞璺熷崟浜�</button>
+									</div>
+									
+								</div>
+								<style>
+									/* 鍏朵粬宸叉湁鏍峰紡... */
+									.follower-item {
+										margin-bottom: 10px; /* 姣忎釜璺熷崟浜洪」涔嬮棿鐨勯棿璺� */
+										clear: both; /* 娓呴櫎娴姩 */
+										overflow: hidden; /* 澶勭悊娴姩鍏冪礌 */
+									}
+									.follower-item input {
+										margin-right: 10px; /* 杈撳叆妗嗕箣闂寸殑闂磋窛 */
+									}
+								</style>
+							<script LANGUAGE="javascript">
+							function showFollower(){		
+								document.getElementById("followerDiv").style.display="";
+								document.getElementById("inputTopAddFollower").style.display="none";
+								addFollower()
+								return false;
+								
+							}
+							function checkOpenerAndFollower(){
+								// 鑾峰彇寮�鍗曚汉淇℃伅
+								var openerNameInput = document.getElementById("EntourageName_<%=EntourageID_OpenUser%>");
+								var openerName = openerNameInput.value;
+								var openerRatioInput = document.getElementById("OpenUserRatio");
+								var openerRatio = openerRatioInput.value;
+
+								// 妫�娴嬪紑鍗曚汉濮撳悕鏄惁涓虹┖
+								//if (openerName === "") {
+								//	alert("寮�鍗曚汉濮撳悕涓嶈兘涓虹┖");
+								//	return false;
+								//}
+
+								// 妫�娴嬪紑鍗曚汉鎻愭垚姣斾緥鏄惁涓虹┖
+								if (openerName !="" && openerRatio === "") {
+									alert("寮�鍗曚汉鎻愭垚姣斾緥涓嶈兘涓虹┖");
+									return false;
+								}
+
+								// 瀛樺偍璺熷崟浜哄鍚嶅拰鎻愭垚姣斾緥
+								var followerNames = [];
+								var followerRatios = [];
+								var followersList = document.getElementById('FollowersList');
+								var followerItems = followersList.getElementsByClassName('follower-item');
+
+								// 閬嶅巻璺熷崟浜猴紝鏀堕泦濮撳悕鍜屾彁鎴愭瘮渚嬪苟杩涜妫�娴�
+								for (var i = 0; i < followerItems.length; i++) {
+									var followerNameInput = followerItems[i].querySelector('input[name^="FollowerName_"]');
+									var followerName = followerNameInput.value;
+									var followerRatioInput = followerItems[i].querySelector('input[name^="FollowerRatio_"]');
+									var followerRatio = followerRatioInput.value;
+
+									// 妫�娴嬭窡鍗曚汉濮撳悕鏄惁涓虹┖
+									if (followerName === "") {
+										alert("璺熷崟浜哄鍚嶄笉鑳戒负绌�");
+										return false;
+									}
+
+									// 妫�娴嬭窡鍗曚汉鎻愭垚姣斾緥鏄惁涓虹┖
+									if (followerRatio === "") {
+										alert("璺熷崟浜烘彁鎴愭瘮渚嬩笉鑳戒负绌�");
+										return false;
+									}
+
+									followerNames.push(followerName);
+									followerRatios.push(parseFloat(followerRatio));
+								}
+
+								// 灏嗗紑鍗曚汉鎻愭垚姣斾緥杞崲涓烘诞鐐规暟
+								openerRatio = parseFloat(openerRatio);
+
+								// 妫�娴嬮�昏緫 1: 寮�鍗曚汉涓庤窡鍗曚汉姣斾緥鍔犺捣涓嶈兘瓒呰繃 100
+								var totalRatio = openerRatio;
+								for (var j = 0; j < followerRatios.length; j++) {
+									totalRatio += followerRatios[j];
+								}
+								if (totalRatio > 100) {
+									alert("寮�鍗曚汉涓庤窡鍗曚汉鎻愭垚姣斾緥鎬诲拰涓嶈兘瓒呰繃 100%");
+									return false;
+								}
+
+								// 妫�娴嬮�昏緫 2: 寮�鍗曚汉涓庤窡鍗曚汉涓嶈鍑虹幇閲嶅
+								if (followerNames.includes(openerName)) {
+									alert("寮�鍗曚汉涓庤窡鍗曚汉涓嶈兘閲嶅");
+									return false;
+								}
+
+								// 妫�娴嬮�昏緫 3: 澶氫釜璺熷崟浜轰箣闂翠篃涓嶈鍑虹幇閲嶅
+								var uniqueFollowerNames = [];
+								for (var k = 0; k < followerNames.length; k++) {
+									if (uniqueFollowerNames.includes(followerNames[k])) {
+										alert("璺熷崟浜轰箣闂翠笉鑳介噸澶�");
+										return false;
+									}
+									uniqueFollowerNames.push(followerNames[k]);
+								}
+
+								return true;
+							}
+							function addFollower() {
+								
+								var followersList = document.getElementById('FollowersList');
+								var newFollower = document.createElement('div');
+								newFollower.className = 'follower-item';
+								var followerCount = followersList.children.length + 1;
+								newFollower.innerHTML = `
+									<input id="Entourage_<%=EntourageID_Follower%>_${followerCount}" name="FollowerID_${followerCount}" type="hidden" value="">
+									<input type="text" id="EntourageName_<%=EntourageID_Follower%>_${followerCount}" name="FollowerName_${followerCount}" class="small" onclick="javascript:JS_EntourageOpen('<%=EntourageID_Follower%>_${followerCount}','-<%=departmentID_Follower%>');" style="width:138px;" value="" readonly="true">
+									<div class="label" style="float: left;margin-left: 226px;"><label for="input-small">鎻愭垚姣斾緥(%):</label></div>
+									<div class="input" style="float:left;margin-left: 87px;">
+										<input type="text" id="FollowerRatio_${followerCount}" name="FollowerRatio_${followerCount}" class="small" style="width:50px;">
+									</div>
+									<div class="input" style="float:left;margin-left: 10px;"> 
+										<button onclick="return removeFollower();">鍒犻櫎</button>
+									</div>
+								`;
+								followersList.appendChild(newFollower);
+								addFollowerCount(1);
+								return false;
+							}
+							function removeFollower(index){
+								var followersList = document.getElementById('FollowersList');
+							
+								var followerItems = followersList.getElementsByClassName('follower-item');
+								// 濡傛灉浼犲叆浜� index 鍙傛暟锛屽垹闄ゆ寚瀹氱储寮曠殑鍏冪礌锛涘惁鍒欏垹闄ゆ渶鍚庝竴涓厓绱�
+								var elementToRemove = index !== undefined ? followerItems[index] : followersList.lastElementChild;
+								if (elementToRemove) {
+									elementToRemove.remove();
+								}
+								followersList = document.getElementById('FollowersList');
+								let len=followersList.children.length;
+								
+								// 鏇存柊鍓╀綑鍏冪礌鐨� name 灞炴�у拰绱㈠紩
+								var newFollowerCount = 1;
+								for (var i = 0; i < len; i++) {
+									var item = followerItems[i];
+									var followerIdInput = item.querySelector('input[name^="FollowerID_"]');
+									var followerNameInput = item.querySelector('input[name^="FollowerName_"]');
+									var followerRatioInput = item.querySelector('input[name^="FollowerRatio_"]');
+									if (followerIdInput) {
+										followerIdInput.name = `FollowerID_${newFollowerCount}`;
+										followerIdInput.id = `FollowerId_${newFollowerCount}`;
+									}
+									if (followerNameInput) {
+										followerNameInput.name = `FollowerName_${newFollowerCount}`;
+										followerNameInput.id = `FollowerName_${newFollowerCount}`;
+									}
+									if (followerRatioInput) {
+										followerRatioInput.name = `FollowerRatio_${newFollowerCount}`;
+										followerRatioInput.id = `FollowerRatio_${newFollowerCount}`;
+									}
+									newFollowerCount++;
+								}
+								if(followersList.children.length==0){
+									document.getElementById("followerDiv").style.display="none";
+									document.getElementById("inputTopAddFollower").style.display="";
+								}
+								addFollowerCount(-1);
+								return false;
+							}
+							function addFollowerCount(val){
+								var hid=document.getElementById("hidFollowerCount");
+								var oldv=hid.value;
+								hid.value=parseInt(oldv)+val;
+							}
+							
+							</script>
 							<%If isDepartment("070127")=1 Then%>
 							<div class="field">
 										<%'涓昏浼佸井瀹㈡湇
@@ -1483,22 +1766,30 @@
 					<script LANGUAGE="javascript">
 						//鐢熸垚鍜ㄨ鍗�(鏂板)
 						function form1_submit19_1(){
-						document.form1.action = "admin_save.gds";
-						document.form1.admin_save.value = "19";
-						document.form1.NEWOrder.value = "";
-						document.form1.ServiceOrdState.value = "1";
-						document.getElementById("zhezhao").style.display="block"; 
-						document.getElementById("login").style.display="block";
-						form1.submit();
+							let checkResult=checkOpenerAndFollower();
+							if(!checkResult){
+								return;
+							}
+							document.form1.action = "admin_save.gds";
+							document.form1.admin_save.value = "19";
+							document.form1.NEWOrder.value = "";
+							document.form1.ServiceOrdState.value = "1";
+							document.getElementById("zhezhao").style.display="block"; 
+							document.getElementById("login").style.display="block";
+							form1.submit();
 						}
 						//鐢熸垚鏈嶅姟鍗�(鏂板)
 						function form1_submit19_2(){
-						document.form1.action = "admin_save.gds";
-						document.form1.admin_save.value = "19";
-						document.form1.ServiceOrdState.value = "2";
-						document.getElementById("zhezhao").style.display="block"; 
-						document.getElementById("login").style.display="block";
-						form1.submit();
+							let checkResult=checkOpenerAndFollower();
+							if(!checkResult){
+								return;
+							}
+							document.form1.action = "admin_save.gds";
+							document.form1.admin_save.value = "19";
+							document.form1.ServiceOrdState.value = "2";
+							document.getElementById("zhezhao").style.display="block"; 
+							document.getElementById("login").style.display="block";
+							form1.submit();
 						}
 						//鐢熸垚鏃犳晥鐢佃瘽(鏂板)
 						function form1_submit19_4(){
@@ -1527,6 +1818,10 @@
 						}
 						//鐢熸垚/淇濆瓨鏈嶅姟鍗�(淇敼)
 						function form1_submit20_2(){
+							let checkResult=checkOpenerAndFollower();
+							if(!checkResult){
+								return;
+							}
 							document.getElementById("MessageContents_form1").value=document.getElementById("MessageContents").value;
 							document.form1.action = "admin_save.gds";
 							document.form1.admin_save.value = "20";

--
Gitblit v1.9.1