<?xml version="1.0" encoding="UTF-8"?>
|
<WebLink xmlns="http://soap.sforce.com/2006/04/metadata">
|
<fullName>Loaner_arranged_e_mail</fullName>
|
<availability>online</availability>
|
<displayType>button</displayType>
|
<linkType>javascript</linkType>
|
<masterLabel>出库指示</masterLabel>
|
<openType>onClickJavaScript</openType>
|
<protected>false</protected>
|
<url>{!RequireScript("/soap/ajax/51.0/connection.js")}
|
{!RequireScript("/soap/ajax/51.0/apex.js")}
|
//2021-10-22 gwy 版本更改为51.0
|
var buttons = document.getElementsByName('loaner_arranged_e_mail');
|
for (var i=0; i<buttons.length; i++)
|
{
|
buttons[i].className = "btnDisabled";
|
buttons[i].disabled = true;
|
}
|
|
var campaignStatus = '';
|
if('{!Consum_Apply__c.Campaign__c}' != '') {
|
var DeliveryGood = new Array();
|
DeliveryGood = sforce.connection.query("select Status, Rental_Apply_Flag__c from Campaign where id ='{!Consum_Apply__c.CampaignId__c}'");
|
var records= DeliveryGood.getArray("records");
|
|
campaignStatus = records[0].Status;
|
|
}
|
if("{!Consum_Apply__c.Wei_Assigned_Cnt__c}" > "0") {
|
alert("申请单内存在未分配的耗材,请分配或分割申请单");
|
}else if(campaignStatus == '取消'){
|
alert("学会取消,不可出库指示");
|
}else if ("{!Consum_Apply__c.Status__c}" == "已出库指示" && "{!Consum_Apply__c.Assigned_Not_Shipment__c}" == "0") {
|
alert("所有的耗材备品Set一览都进行过出库指示了");
|
} else if ("{!Consum_Apply__c.Assigned_Not_Shipment__c}" == "0") {
|
alert("没有可以出库指示的明细");
|
} else {
|
sforce.connection.sessionId = "{!GETSESSIONID()}";
|
var raid = "{!Consum_Apply__c.Id}";
|
var rs1 = sforce.apex.execute("ConsumApplyWebService", "approvalCheck", {ConsumApplyId: raid});
|
if (rs1 != '1') {
|
alert(rs1);
|
} else {
|
//bp2 var rs2 = sforce.apex.execute("RentalApplyWebService", "reserve", {rentalApplyId: raid});
|
//bp2 if (rs2 != '1') {
|
//bp2 alert(rs2);
|
//bp2 } else {
|
//var rs1 = sforce.apex.execute("RentalApplyWebService", "setShipment_request", {raid : "{!Consum_Apply__c.Id}"});
|
|
sforce.apex.execute("ConsumApplyWebService", "setShipment_request", {raid: "{!Consum_Apply__c.Id}"},function(res) {
|
// if(event.status) {
|
if (res == "状态更新到已出库指示") {
|
alert("状态更新到已出库指示");
|
print();
|
setTimeout(function() {
|
location.href = "/{!Consum_Apply__c.Id}";
|
}
|
, 100
|
);
|
} else {
|
alert(res);
|
}
|
// } else {
|
// alert(event.message);
|
// }
|
});
|
|
//bp2 }
|
}
|
}
|
function print(){
|
var sql;
|
if('{!Consum_Apply__c.Bollow_Date__c}' != ''){
|
sql = "select Id from Consum_Apply_Equipment_Set__c where Consum_Apply__c = '{!Consum_Apply__c.Id}' and Shippment_loaner_time__c != null and RAES_Status__c != '已分配' and RAES_Status__c != '取消分配'";
|
}else{
|
sql = "select Id from Consum_Apply_Equipment_Set__c where Consum_Apply__c = '{!Consum_Apply__c.Id}' and RAES_Status__c != '已分配' and RAES_Status__c != '取消分配'";
|
}
|
var sqlResult = sforce.connection.query(sql);
|
var records = sqlResult.getArray("records");
|
var size =records.length;
|
//var length = size%10 ==0? size/10 : parseInt(size/10) +1;
|
//for(var i =0;i<length;i++){
|
window.open('/apex/ConsumTrialPDF?id={!Consum_Apply__c.Id}');
|
//}
|
}
|
|
|
function fixTime(time){
|
if(time < 10) {time = "0" + time};
|
return time;
|
}
|
function fixDate(date){
|
var Month = fixTime(date.getMonth() + 1);
|
var Day = fixTime(date.getDate());
|
var UTC = date.toUTCString();
|
var Time = UTC.substring(UTC.indexOf(':')-2, UTC.indexOf(':')+6);
|
var Minutes = fixTime(date.getMinutes());
|
var Seconds = fixTime(date.getSeconds());
|
return date.getFullYear() + "-" + Month + "-" + Day + "T" + Time;
|
}</url>
|
</WebLink>
|