function initLwc(SelectFieldParamList,flage){
|
for (var i = SelectFieldParamList.length - 1; i >= 0; i--) {
|
let parm=SelectFieldParamList[i]
|
if(flage&&parm.oldElm){
|
let clm=document.getElementById(parm.lightningId);
|
console.log(clm.parentNode.replaceChild(parm.oldElm,clm));
|
initLwcData(parm,0);
|
continue;
|
}
|
$Lightning.use("c:LexSelectFieldApp", function() {
|
$Lightning.createComponent(
|
"c:LexSelectFieldCmp",
|
{
|
"objApiName": parm.objType,
|
"fieldApiName": parm.field,
|
"recordId" : parm.recordId,
|
},
|
parm.lightningId,
|
function(cmp) {
|
console.log(cmp);
|
unblockUI();
|
setTimeout(()=>{
|
initLwcData(parm,0);
|
},1000);
|
// setTimeout(()=>{
|
// resetInitValue(parm,0);
|
// },1500);
|
}
|
);
|
});
|
}
|
}
|
function initLwcData(parm,count){
|
if(count>10){return;}
|
try{
|
console.log(document.getElementById(parm.lightningId));
|
console.log(document.getElementById(parm.lightningId).querySelectorAll('input'));
|
if(!document.getElementById(parm.lightningId).querySelectorAll('input')){
|
return;
|
}
|
let inp=document.getElementById(parm.lightningId).querySelectorAll('input')[0].id.replace('combobox-input-','');
|
console.log('combobox-input-'+inp+'-0-' + inp);
|
let comboxId='#combobox-input-'+inp+'-0-' + inp;
|
let style = document.createElement('style');
|
style.innerHTML=
|
comboxId+'{'+
|
'display:none'+
|
'}';
|
let ref=document.querySelector('script');
|
ref.parentNode.insertBefore(style, ref);
|
console.log(style);
|
}catch(e){
|
console.log("初始化失败:"+count);
|
console.log(e);
|
setTimeout(()=>{
|
initLwcData(parm,count+1);
|
},1000);
|
}
|
}
|
//重新设置初始数据
|
function resetInitValue(parm,count){
|
if(count>10){
|
return;
|
}
|
try{
|
lwcItem=document.getElementById(parm.lightningId);
|
let liIrtem=lwcItem.querySelectorAll('lightning-base-combobox-item');
|
console.log(liIrtem);
|
let objId=document.getElementById(parm.inputFieldId + '_lkid').value;
|
if(!liIrtem[1]){
|
setTimeout(()=>{
|
resetInitValue(parm,count+1);
|
},1000);
|
return;
|
}
|
setNodeValue(liIrtem[1],objId).then(function (){
|
liIrtem[1].click();
|
})
|
}catch(e){
|
console.log(e);
|
setTimeout(()=>{
|
resetInitValue(parm,count+1);
|
},1000);
|
}
|
}
|
//设置节点数值
|
function setNodeValue(node,setid){
|
return new Promise(function(resolve, reject) {
|
node.attributes.getNamedItem('data-value').value=setid;
|
resolve();
|
});
|
}
|
//刷新数据
|
function refreshSelectFieldValue(SelectFieldParamList,elm){
|
let elmId=elm.id;
|
let SelectFieldParamParam;
|
for (var i = SelectFieldParamList.length - 1; i >= 0; i--) {
|
if(SelectFieldParamList[i].lightningId==elmId){
|
SelectFieldParamParam=SelectFieldParamList[i];
|
break;
|
}
|
}
|
let lcm=document.getElementById(SelectFieldParamParam.lightningId);
|
const inputFields = lcm.querySelectorAll('input');
|
if (inputFields) {
|
try{
|
setTimeout(()=>{
|
let objName=inputFields[0].attributes.getNamedItem('data-value');
|
objName=objName.value;
|
let objId=inputFields[1].value;
|
if(objId==null||objId=='000000000000000AAA'||objId=='000000000000000'){
|
return;
|
}
|
j$(escapeVfId(SelectFieldParamParam.inputFieldId)).val(objName);
|
j$(escapeVfId(SelectFieldParamParam.inputFieldId + '_lkold')).val(objName);
|
j$(escapeVfId(SelectFieldParamParam.inputFieldId + '_lkid')).val(objId);
|
j$(escapeVfId(SelectFieldParamParam.inputHiddenId)).val(objId);
|
SelectFieldParamParam.oldElm=lcm;
|
console.log('更新数值:');
|
console.log(objName);
|
console.log(objId);
|
},100);
|
}catch(e){
|
console.log(e);
|
}
|
}
|
}
|
//标准控件修改 end
|
|
|
function resetOpenPage(SelectFieldParamList){
|
for (var i = SelectFieldParamList.length - 1; i >= 0; i--) {
|
try{
|
let parm=SelectFieldParamList[i];
|
console.log("dddd");
|
console.log(parm);
|
if(document.getElementById(parm.inputFieldId).type=='hidden'){
|
let newId=parm.inputFieldId+'_lkid';
|
console.log(newId);
|
console.log(document.getElementById(newId))
|
document.getElementById(newId).parentNode.children[1].removeAttribute("href");
|
document.getElementById(newId).parentNode.children[1].onclick = function() {
|
OpenSelectPage(parm);
|
};
|
}else{
|
console.log(document.getElementById(parm.inputFieldId));
|
document.getElementById(parm.inputFieldId).parentNode.children[2].removeAttribute("href");
|
document.getElementById(parm.inputFieldId).parentNode.children[2].onclick = function() {
|
OpenSelectPage(parm);
|
};
|
}
|
|
}catch(e){
|
console.log(e);
|
continue;
|
}
|
|
}
|
}
|
let newSelectPage;
|
function OpenSelectPage(parm){
|
let searchContactKeyWord = document.getElementById(parm.inputFieldId).value;
|
let responsibleNodeId = document.getElementById(parm.inputFieldId).value;
|
let accountValue=searchContactKeyWord;
|
console.log('accountValue:'+accountValue);
|
if (accountValue != '000000000000000') {
|
let baseUrl = "/apex/SearchContactPageLWC";
|
// let suffixUrl = "?contactId=" + responsibleNodeId + "&accountId=" + accountValue+"&searchContactKeyWord=" + searchContactKeyWord +
|
// "&Type=OFS" + '&ObjectType=' + parm.ObjectType + '&QueryFieldApiName=' + parm.QueryFieldApiName +
|
let suffixUrl = "?searchContactKeyWord=" + searchContactKeyWord + '&ObjectType=' + parm.ObjectType + '&QueryFieldApiName=' + parm.QueryFieldApiName +
|
'&inputFieldId=' + parm.inputFieldId +
|
// '&SelectObj=' + parm.SelectObj + '&SelectFld=' + parm.SelectFld;
|
'&SelectObj=' + parm.SelectObj + '&FilterSql='+ parm.FilterSql;
|
//20231104 李文涛 setVal查询条件 start
|
if(parm.setVal){
|
console.log('setVal:=');
|
console.log(parm.setVal);
|
suffixUrl = suffixUrl +'&setVal='+parm.setVal;
|
}
|
//20231104 李文涛 setVal查询条件 end
|
let newSearchContactParam = 'height=500,width=800,left=100,top=100,dialogHide=true,resizable=no,scrollbars=yes,toolbar=no,status=no';
|
newSelectPage = window.open(baseUrl + suffixUrl, 'Popup', newSearchContactParam);
|
if (window.focus) {
|
newSelectPage.focus();
|
}
|
return false;
|
} else {
|
alertErrorMessage('请先输入查询名称');
|
}
|
}
|