windchill 11.0 新建文档客制化之文档类型联动

问题:在新建文档时,选择了文档类型,若文档有模板,系统无法自动选择一个模板,特别是文档只有一个模板时,若能自动选择模板,则能进一步提高工作效率。

客制化方法为修改\codebase\netmarkets\jsp\document\createDocumentSetTypeAndAttributesWizStep.jsp件

// 找到以下代码:
// From the common component we are calling our local pickerGo which calls the original pickerGo and then calls populateTemplates
pickerGo = pickerGo.wrap(function(original,value, currentObjectHandle, template) {
   original(value, currentObjectHandle, template);
   if (!template)
	   populateTemplates(value);
})
//将上面的代码替换成下面的代码
function custUpdateTemplatesCombo(){
	var templatesCombo = document.getElementById("templatesCombo");
	if(!templatesCombo){
		return;
	}
	var currentValue = "";
	var templatesOptions = templatesCombo.children;
	for(var i=0;i<templatesOptions.length;i++){
		var templatesOptionValue = templatesOptions[i].value;
		if(templatesOptionValue){
			currentValue = templatesOptionValue;
			break;
		}
	}
	templatesCombo.setValue(currentValue);
	custOnTemplateSelection(templatesCombo);
}
function custOnTemplateSelection(template){
    var urlForDriverAttributes = document.getElementsByName('urlForDriverAttributesForTemplate')[0];
    var objectHandle = document.getElementsByName('objectHandleForTemplate')[0];
    if (template.value == ""){
        noTemplateSelected();
        var lastSelectedType = document.getElementById('lastSelectedType');
        custPickerGo(lastSelectedType.value,objectHandle.value);
        refreshDriverAttributes(urlForDriverAttributes.value);
    } else{
        templateSelected();
        custPickerGo(template.value,objectHandle.value,'true');
        refreshDriverAttributes(urlForDriverAttributes.value);
        loadAttachmentsStep();
    }
}
custPickerGo = pickerGo.wrap(function(original,value, currentObjectHandle, template) {
   original(value, currentObjectHandle, template);
   if (!template){
	   populateTemplates(value);
   }
})
// From the common component we are calling our local pickerGo which calls the original pickerGo and then calls populateTemplates
pickerGo = pickerGo.wrap(function(original,value, currentObjectHandle, template) {
   original(value, currentObjectHandle, template);
   if (!template){
	   populateTemplates(value);
	   custUpdateTemplatesCombo();
   }
})

主要修改点为:

​ 1.新增custUpdateTemplatesCombo函数用以自动选择第一个模板,

​ 2.并调用模板下拉框的onchange事件处理方法OnTemplateSelection,但因为直接OnTemplateSelection方法会产生循环递归,所以需要修改下,即复制其定义的代码创建新的函数custOnTemplateSelection,并调用此方法。

​ 3.custOnTemplateSelection方法在原来调用pickerGo函数的地方改调用custPickerGo函数,此函数也是参照pickerGo函数定义的

​ 4.custPickerGo与原pickerGo函数代码完全一致

​ 5.修改pickerGo方法,在调用populateTemplates函数的后面增加调用custUpdateTemplatesCombo函数。

至此即实现了自动选择模板的功能。

— 客制化原因可能实际的有所不同,欢迎wx13451782717交流。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

蜗牛_snail

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值