1基于视图的删除功能
、
var id = getWebUser().getLoginno();
var params = getParameter("_selects");
var docids = splitText(params,";");
var process = createProcess("cn.myapps.core.dynaform.dts.datasource.ejb.DataSourceProcess");
for(var i=0;i<docids.length;i++){
var doc = docids[i];
if(doc!=null && doc!=""){
var sql ="update TLK_collect set item_status='1' where id='"+doc+"'";
process.createOrUpdate("ks",sql,getApplication());
}
}
2:基于值脚本的写法
两个主要的参数:_parformid _parDocID
模式窗口的写法,得到父窗体的事件
var send=getItemValueAsString("sendp");
if(send==""||"".equals(send)){
var send= getDocItemValueAsString(getParameter("_parDocID"),"from_to");
}
send;
var tit="";
var process = createProcess("cn.myapps.core.dynaform.dts.datasource.ejb.DataSourceProcess");
var para=getItemValueAsString("person1");
var docids = splitText(para,";");
for(i=0;i<docids.length;i++){
var doc = docids[i];
var sql="select loginno from T_USER where ID='"+doc+"'";
var data = process.queryDataSourceSQL("qa",sql,getApplication());
if(data!=null){
for(var iterator = data.iterator();iterator.hasNext();){;
var iii = iterator.next();
tit += iii.get("loginno")+";";
}
}
}
tit.substring(0, tit.length-1);
createOrUpdate("数据名",sql语句,应用id);
3: 基于按扭的多次插入的操作
ID Formname FormID APPLicationID DomainId MappIngID T_document
var doc = getCurrentDocument();
var send=getItemValue("sendp");
var pser=getItemValue("person1");
var topic=getItemValue("topic");
var context=getItemValue("context");
var upload=getItemValue("upload");
var ft=getItemValue("from_to");
var tody=getItemValue("tody");
var id=countNext2("br112555-",true,true,true,3);
var app=getApplication();
var process = createProcess("cn.myapps.core.dynaform.dts.datasource.ejb.DataSourceProcess");
$PRINTER.println(">>>>>>>>>>>>11111111111"+id)
var sql1="insert into t_document(id,formname,author,formid,applicationid,domainid,mappingid) values('"+id+"','test/test/draft','11e1-b3b4-b4fc3cb4-a432-5f0941b8ae27','11e1-b3a9-2a9db97d-bbd9-9fee94890356','"+app+"','11e1-b37f-62766494-bbd9-9fee94890356','"+id+"')";
$PRINTER.println(">>>>>>>>>>>>2222222222222221")
process.createOrUpdate("ks",sql1,getApplication());
$PRINTER.println(">>>>>>>>>>>>2333333333333333")
var sql2="insert into tlk_draft(formname,author,formid,applicationid,domainid,item_sendp,item_topic,item_context,item_upload,item_from_to,item_status,item_tody,id)values ('test/test/draft','11e1-b3b4-b4fc3cb4-a432-5f0941b8ae27','11e1-b3a9-2a9db97d-bbd9-9fee94890356','"+app+"','11e1-b37f-62766494-bbd9-9fee94890356','"+send+"','"+topic+"','"+context+"','"+upload+"','"+ft+"','2','"+tody+"','"+id+"')";
process.createOrUpdate("ks",sql2,getApplication());
4.基于文档的的操作
var params = getParameter("_select");
var process = getDocProcess(getApplication());
var docids = Packages.cn.myapps.util.StringUtil.split(params,";");
for(var i=0;i<docids.length();i++){
var doc = process.doView(docids[i]);
doc.findItem("字段名").setValue(字段值); //这里要做修改
process.doUpdate(doc);
}
对于父文档的操作
var doc = $CURRDOC.getCurrDoc();
var value = "";
var parent = doc.getParent();
if(parent!=null){
value =parent.getItemValueAsString("topic");
}
value;
基于DQL语句的操作
var user = getWebUser();
var formProcess = new Packages.cn.myapps.core.dynaform.form.ejb.FormProcessBean();
var form = formProcess.doView("11de-be17-e5489db5-afb8-71b3d9f11779"); //查询出表单
var process = getDocProcess(getApplication()); //Document操作类
for (var it = cleints.iterator();it.hasNext();){
var tmp = it.next();
var prdName = tmp.getItemValueAsString("产品编码");
var dql1 = "$formname ='TB_BDM_Material' and MaterialCode='" + prdName + "'";
var docs = queryByDQL(dql1);
if (docs!=null && docs.size()>0){
var sdoc = docs.get(0);
var doc = process.doNew(form,user,new Packages.cn.myapps.base.action.ParamsTable());
doc.setParent(cdoc.getId());
doc.findItem("ProductName").setValue(sdoc.getItemValueAsString("MaterialName"));
doc.findItem("Specs").setValue(sdoc.getItemValueAsString("Specs"));
doc.findItem("ClientPrice").setValue(sdoc.getItemValueAsString("UnitPrice"));
doc.findItem("productID").setValue(sdoc.getItemValueAsString("MaterialCode"));
process.doUpdate(doc);
}
}
}
}
}
基于url的写法
var annex = getItemValueAsString("annex");
var pathlist = splitText(annex,";");
var rtn = "";
for(var i=0;i<pathlist.length;i++){
var fileFullName = pathlist[i];
var index = fileFullName.indexOf("_");
var uploadactionurl="/portal/download/annex.action?annexName=";
var webPath = fileFullName.substring(0, index);
var showName= fileFullName.substring(index + 1, fileFullName.length());
var url = $WEB.getParamsTable().getContextPath()+uploadactionurl+webPath;
rtn += "<a class='color_blue' href=\""+url+"\" target='_blank' >"+showName+"</a> ";
}
rtn;
//获取所在企业域的全部用户
var opts =createOptions();
var userProcess = $PROCESSFACTORY.createProcess("cn.myapps.core.user.ejb.UserProcess");
opts.add("","");
var params = new Packages.cn.myapps.base.action.ParamsTable();
params.setParameter("domain",getDomainid());
var userlist= userProcess.doSimpleQuery(params);
if(userlist!=null && userlist.size()>0){
for(var iter = userlist.iterator();iter.hasNext();){
var user = iter.next();
opts.add(user.getName(),user.getId());
}
}
opts;
//自增长函数的应用
var number = getItemValue("字段名");
if(number ==null || number.trim().length()<=0){
number = countNext2("前缀",true,false,false,4);
}
number;
//headText: 作为前缀的字符串 isYear: boolean型,前缀中是否包含年份 isMonth: boolean型,前缀中是否包含月份
//isDay: boolean型,前缀中是否包含日期 digit: 数值型,指定随机序列号的位数
countNext2(headText, isYear, isMonth, isDay, digit)方法
var user= getWebUser();
var doc = getCurrentDocument();
var author = doc.getAuthor();
var param=$WEB.getParamsTable();
var url = param.getParameterAsString("url");
var rtn = "<script>window.top.location='"+url+"'</script>";
$PRINTER.println("###################### " + rtn);
createConfirm("您确定要删除选中的公文?");
createAlert("");
$PRINTER.println("");//打印功能
var value=getWebUser().getDefaultDepartment(); 登录用户的部门
user.getDepartments();
流程状态的查询
var i = getId();
var process = createProcess("cn.myapps.core.dynaform.dts.datasource.ejb.DataSourceProcess");
var sql = "select p.stateint as s,cast(p.AUDITORNAMES as nvarchar(2000)) as name from TLK_FM_DOC_TABS p where p.id='"+i+"'";
var datas = process.queryDataSourceSQL("apm",sql,getApplication());
var s = "";
var n = "";
var url = "";
if(datas!=null && datas.size()>0){
s=datas.get(0).get("s");
n=datas.get(0).get("name");
}
if(s==257 || s=="257"){
url ="<a href=javascript:viewDoc('"+getId()+"',%20'11df-63d6-b530cee4-84e7-f1221b60f108',%20'false')>未申报</a>";
}
else if(s==256 || s=="256"){
url ="<a href=javascript:viewDoc('"+getId()+"',%20'11df-63d6-b530cee4-84e7-f1221b60f108',%20'false')>"+n+"</a>";
}else{
url ="<a href=javascript:viewDoc('"+getId()+"',%20'11df-63d6-b530cee4-84e7-f1221b60f108',%20'false')>已审批</a>";
}
url;
6.怎么配置获取项目中的图片的
rtn = "<image src=\"" + $WEB.getParamsTable().getContextPath() + "/resource/imgnew/sf.gif/\">" + value + "</a>"
//流程的操作
var doc = getCurrentDocument();
var aa=doc.getStateLabel();
var bb=doc.getStateInt();
if(bb==257)
{
aa="未申报";
}
if(bb==256)
{
aa="审核中";
}
if(bb==1048576)
{
aa="发布成功";
}
aa;
审批脚本的写法
var doc = getCurrentDocument();
var aa = doc.getItemValueAsString("用户选择框"); //表单字段
var docids = splitText(aa, ";");
var userlist = createObject("java.util.ArrayList");
for (var i = 0; i < docids.length; i++) {
var doc = getCurrentDocument();
var aa = doc.getItemValueAsString("用户选择框"); //表单字段
var docids = splitText(aa, ";");
var userlist = createObject("java.util.ArrayList");
for (var i = 0; i < docids.length; i++) {
if (docids != null) {
var userVO = getUserById(docids[i]);
userlist.add(userVO);
}
}
userlist;
var doc = getCurrentDocument();
var aa = doc.getItemValueAsString("用户选择框"); //表单字段
var docids = splitText(aa, ";");
var userlist = createObject("java.util.ArrayList");
for (var i = 0; i < docids.length; i++) {
if (docids != null) {
var userVO = getUserById(docids[i]);
userlist.add(userVO);
}
}
userlist;
if (docids != null) {
var userVO = getUserById(docids[i]);
userlist.add(userVO);
}
}
userlist;