当前位置: 代码迷 >> 综合 >> dorado7 动态生成图片
  详细解决方案

dorado7 动态生成图片

热度:44   发布时间:2023-11-18 08:08:07.0

最近做了一个dorado 7 的动态生成图片的功能恶心了我一星期,甚是烦躁,现在付代码如下,希望能够帮助到那些被dorado摧残的人 ;

主要思路是动态的放在container中

1.由dataSet获取到后台的数据(包括动态生成的label的数据,以及需要生成的图片路径)

2.通过autoform来以及container填充的方式调整位置,以及图片的位置

 

view.detailData = function(data){//保存detail的数据
debugger;
var emergenciesId = view.get("#dsEmergencies.data:#").get("emergenciesId");
//form
if(emergenciesId == null){return;
}
var container = null;
if(data == 0){ //控制按钮显示container = view.get("#container_add_detail");container.removeAllChildren();
}else if(data == 2){container = view.get("#container_add_detail");container.removeAllChildren();
}else if(data == 3){container = view.get("#container_audi_detail");container.removeAllChildren();
}else if(data == 4){container = view.get("#container_view_detail");container.removeAllChildren();
}flag = true;if(flag){with (view.get("#dsEmergenciesDetailsLabel")){set("parameter",{emergenciesId:emergenciesId});flush();}//突发事件详情Setvar detailSet = view.get("#dsEmergenciesDetailsLabel.data");	detailSet.each(function(record){var fieldset = new dorado.widget.FieldSet();fieldset.set("contentOverflowY","visible");var autoform = new dorado.widget.AutoForm();		autoform.set ("cols" ,"150,*,90,90") var titleLabel = new dorado.widget.Label({text:record.get("detailTitle")});var contentLabel = new dorado.widget.Label({text:record.get("detailContent")});var contentCon = new dorado.widget.Container({//	height:100});var contentForm = new dorado.widget.AutoForm({//	height:80});;contentForm.set("cols","*")contentForm.addElement(contentLabel);contentCon.addChild(contentForm);autoform.addElement(titleLabel);autoform.addElement(contentCon);with (view.get("#dsEmergenciesDetailsAtt")){set("parameter",{detailId:record.get("detailId")});flush();}var picAutoForm = new dorado.widget.AutoForm();picAutoForm.set ("cols" ,"*,*,*,*,*,*,*,*");var detailAttSet = view.get("#dsEmergenciesDetailsAtt.data");//图片附件detailAttSet.each(function(result){//图片附件		var SimpleBlockRenderer2 = $extend(dorado.widget.blockview.DefaultBlockRenderer,{render: function(dom, arg) {dom.innerHTML = "<img src='"+ arg.data +"' class='attachment_operation_img' height='120' width='100' />";}});var pic = new dorado.widget.BlockView({allowNoCurrent:true,lineSize:8,height:120,blockHeight:100,blockWidth:100,onReady: function(self, arg){self.set("renderer", new SimpleBlockRenderer2());//修改默认的块渲染器对象self.set("items",[result.get("fileUrl")]);;},onClick: function(self, arg){url='com.hisense.smartroad.common.view.ShowImg.d?fileUrl=' + result.get("fileUrl");tabName='查看图片'+result.get('attachmentName').split('.')[0];top.window.viewMain.openUrlInMainTab(url,tabName);}});		picAutoForm.addElement(pic);				});var editBtn = new dorado.widget.Button({caption:'编辑',onClick: function(self, arg){var detailId = record.get("detailId");var detailTitle = record.get("detailTitle");var detailContent = record.get("detailContent");var createUid = record.get("createUid");var createDate = record.get("createDate");var updateUid = record.get("updateUid");var updateDate = record.get("updateDate");var entity ={};entity.detailId = detailId;entity.detailTitle = detailTitle;entity.detailContent = detailContent;view.get('#dsEmergenciesDetails').insert(entity);var entitylist=view.get('#dsEmergenciesDetails.data:#').get('emeDetailAttachments');//图片附件detailAttSet.each(function(result){	//往dataset里面设置	var pic = {};pic.emeAttId = result.get("emeAttId");pic.createUid = result.get("createUid");pic.createDate = result.get("createDate");pic.updateUid = result.get("updateUid");pic.updateDate = result.get("updateDate");									pic.attachmentId = result.get("attachmentId");pic.attachmentName = result.get("attachmentName");pic.fileUrl = result.get("fileUrl");entitylist.insert(pic);});view.get("#add_detail_dialog").show();}});var delBtn = new dorado.widget.Button({caption:'删除',onClick: function(self, arg){var detailId = record.get("detailId");dorado.MessageBox.confirm("确定要删除吗,删除后将不可恢复?",function(){
//							container.removeChild(fieldset);container.removeChild(autoform);view.get("#ajaxDelDetailData").set("parameter",detailId).execute();	})		}});if(data == 0 || data == 2) { autoform.addElement(editBtn);autoform.addElement(delBtn);}if(data == 4){editBtn.set("visible",false);delBtn.set("visible",false);autoform.addElement(editBtn);autoform.addElement(delBtn);}var label1 = new dorado.widget.Label();autoform.addElement(label1);var picCon = new dorado.widget.Container();picCon.addChild(picAutoForm);autoform.addElement(picCon);
//			fieldset.addChild(autoform);container.addChild(autoform);	});}
}