attachment(非attachmentSimple)相关的附件组件上传文件后要执行业务数据data的保存才会生成fileID的值,才可以操作附件
因此要确保附件上传完之后再保存数据,没上传完就保存,附件组件的数据有可能会不正确导致附件操作失败
attachment(非attachmentSimple)相关的附件组件提供的有:
onStart开始上传前事件
onSuccess上传完成事件
因此可以用这两个去控制附件没有上传完时不允许保存
1.在model中定义一个实例变量this.attachmentSuccess
var Model = function() {
this.callParent();
this.attachmentSuccess = true;
};
2.在onStart事件中设置实例变量的值为false
Model.prototype.attachmentPC1Start = function(event){
this.attachmentSuccess = false;
};
3.在onSuccess事件中设置实例变量的值为true
Model.prototype.attachmentPC1Success = function(event){
this.attachmentSuccess = true;
};
4.在data的onBeforeSave事件中判断变量的值,如果为false就进行提示并中断保存
Model.prototype.mainDataBeforeSave = function(event){
if(!this.attachmentSuccess){
alert("附件未上传完,请稍候再执行保存");
event.cancel = true;
}
};
评一波