public with sharing class CustContController {
|
//合成url
|
public String ccUrl { get; private set; }
|
//两个用来拼接url
|
public String accid { get; private set; }
|
public String conid { get; private set; }
|
//初始化
|
public loaner_user__c lou { get; private set; }
|
public loaner_user__c lu { get; private set; }
|
//判断
|
public String isOk {get; private set; }
|
|
public CustContController() {
|
accid = System.currentPageReference().getParameters().get('accid');
|
conid = System.currentPageReference().getParameters().get('conid');
|
}
|
|
public void init(){
|
|
lou = new loaner_user__c();
|
List<Account> accList = new List<Account>();
|
List<Contact> conList = new List<Contact>();
|
if (String.isNotBlank(accid)) {
|
accList = [select id from Account where id =: accid];
|
}
|
if (String.isNotBlank(conid)) {
|
conList = [select id from Contact where id =: conid];
|
}
|
|
if(accList.size() >0){
|
lou.Customer__c = accid;
|
}
|
|
if(conList.size() > 0 ){
|
lou.Contact__c = conid;
|
}
|
}
|
|
public void getisOk(){
|
isOk = '';
|
//前台选的客户与联系人都可以取到他俩的id,选没选没关系,只需要查询比较他俩都被选中的情况下
|
Contact cont = new Contact();
|
if (String.isNotBlank(lou.Contact__c)) {
|
cont = [select AccountId from Contact where id =:lou.Contact__c];
|
}
|
System.debug(cont.AccountId);
|
if (cont.AccountId != null) {
|
if (String.isNotBlank(lou.Customer__c) && String.isNotBlank(lou.Contact__c)) {
|
isOk = cont.AccountId == lou.Customer__c ? '1' : '0';
|
}
|
if (String.isBlank(lou.Customer__c)) {
|
isOk = '2';
|
}
|
}else if (String.isNotBlank(lou.Customer__c)){
|
isOk = '1';
|
}
|
System.debug(isOk);
|
}
|
}
|