平台默认的attachmenPC组件文件名的click调用的是$model.previewOrRemoveItem.bind($model,$model.$activeDoc.get())打开附件查看,如下
<a class="btn btn-link" data-bind="enable:($model.$activeDoc.get().fileID.get() && $model.$access.get() % 4 >= 2),click:$model.previewOrRemoveItem.bind($model,$model.$activeDoc.get()),text:$model.$activeDoc.get().docName.get()" xid="a4"/>
如果要调用自己当前.w对应的js中的方法,可以如下修改
$model.getModel().attachmentClick.bind($model.getModel(),$model.$activeDoc.get())
其中attachmentClick是js中的函数名
js文件中定义如下:
Model.prototype.attachmentClick = function(event) { var docPath = event.docPath.get(); var fileID = event.fileID.get(); var url = DocUtils.InnerUtils.getdocServerAction({ "docPath" : docPath, urlPattern : "/repository/file/view/" + fileID + "/last/content", isFormAction : false, context : this.getContext() }); window.open(url); };
评一波