binxie
2024-01-22 102afa21c115e8c8b9333a326c3d1af08fe76faf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?xml version="1.0" encoding="UTF-8"?>
<WebLink xmlns="http://soap.sforce.com/2006/04/metadata">
    <fullName>TerminateResponse</fullName>
    <availability>online</availability>
    <displayType>button</displayType>
    <linkType>javascript</linkType>
    <masterLabel>项目终止</masterLabel>
    <openType>onClickJavaScript</openType>
    <protected>false</protected>
    <url>var btns = document.getElementsByName(&quot;terminateresponse&quot;);
for (var i=0; i&lt;btns.length; i++) {
btns[i].disabled = true;
btns[i].className = &apos;btnDisabled&apos;;
}
 
{!RequireScript(&quot;/soap/ajax/51.0/connection.js&quot;)}
{!RequireScript(&quot;/soap/ajax/51.0/apex.js&quot;)}
{!RequireScript(&quot;/resource/CommonUtilJs&quot;)}
 
function IfResponse(){
 
if({!TEXT(Tender_information__c.TerminateApprovalStatus__c)= &apos;批准&apos; || TEXT(Tender_information__c.TerminateApprovalStatus__c)= &apos;申请中&apos;}){
alert(&quot;已存在申请中或者已批准的终止信息。&quot;);
return;
}
 
// 2023-05-12 增加询价状态1和状态2验证 start
// 取所有关联link的soql
var sql = &quot;select count(id) total_cnt, sum(Opp_StageName_Check__c) stage_cnt, sum(Opp_StatusF_Check__c) statusf_cnt from Tender_Opportunity_Link__c where Tender_information__c =&apos;&quot; + &apos;{!Tender_information__c.Id}&apos;+ &quot;&apos;&quot;;
// 执行查询
var sqlResult = sforce.connection.query(sql);
// alert(&apos;测试:&apos;+sqlResult);
if (sqlResult.size &gt; 0 &amp;&amp; parseInt(sqlResult.records.total_cnt) &gt; 0) {
// alert(&quot;测试:&quot; + sqlResult.records);
var total_cnt = parseInt(sqlResult.records.total_cnt);
var stage_cnt = parseInt(sqlResult.records.stage_cnt);
var statusf_cnt = parseInt(sqlResult.records.statusf_cnt);
// alert(&quot;测试:关联询价数:&quot;+total_cnt +&quot;|状态1符合数:&quot;+stage_cnt+&quot;|状态2符合数:&quot;+statusf_cnt+&quot;|&quot;+(total_cnt != stage_cnt || total_cnt != statusf_cnt));
// 判断总数和各状态符合数
if (total_cnt != stage_cnt || total_cnt != statusf_cnt) {
alert(&quot;关联询价状态不符合终止申请条件。&quot;);
return;
}
}
 
// 2023-05-12 增加询价状态1和状态2验证 end
 
window.open (&apos;/apex/Terminate?id={!Tender_information__c.Id}&apos;, &apos;&apos;, &apos;height=350, width=600, top=200, left=350,location=no&apos;);
 
}
IfResponse();</url>
</WebLink>