勾选数据复制并跳转至新单

业务场景:复盘任务,将已盘点的任务进行复制生成新单并跳转新单,需要将原来的数据传到新表中。

//脚本示例
(function(){
  var selectId = getParameterAsText("_selects");
  var applicationId = getApplication(); 
  var request = $WEB.getParamsTable().getHttpRequest();
  var user = getWebUser();
  var userId = user.getId();

  var formProcess = new Packages.cn.myapps.designtime.form.service.FormDesignTimeServiceImpl();//4.4或5.0版本
  var newForm = formProcess.doViewByFormName("INVENTORY_FORM", applicationId); 				//创建盘点任务
  var newForm2 = formProcess.doViewByFormName("INVENTORY_DETAILS", applicationId);	 		//创建盘点任务明细
  var params = createParamsTable();
  var docProcess = getDocProcess(applicationId);

  if(selectId != ""){
    var newDoc = docProcess.doNew(newForm,user,params);
    var uuid = new Packages.cn.myapps.util.sequence.Sequence();
    var uid1 = uuid.getSequence();                         //盘点任务表uuid;
    var formid = "__aWFauYO1s3KUzpAzLKh";        		   //盘点任务formId
    var newDocid = uid1 + "--" + formid;                   //该处主要应用在5.0版本,5.0版本的docic由原来的docid和formid组成,如果是4.4或以下版本直接使用uid1
    newDoc.setId(newDocid); 
    newDoc.setApplicationid(applicationId);
    newDoc.setAuthor(userId);
    newDoc.setIstmp(false);    

    var number = countNext2("PDBH",true,true,true,4); 
    newDoc.addStringItem("TaskNumber",number);
    newDoc.addStringItem("Applicant",userId);
    newDoc.addDateItem("ReleaseTime", getToday());
    docProcess.doCreate(newDoc);

    var sql = "select * from tlk_inventory_details where 1 = 1 and parent = '"+selectId+"'";		
    var query = queryBySQL(sql);
    if(query!=null && query.size()>0){
        for(var iter = query.iterator();iter.hasNext();){
            var docs = iter.next();
            var newDoc2 = docProcess.doNew(newForm2,user,params); 
            var uuid2 = new Packages.cn.myapps.util.sequence.Sequence();                                                             
            var uid2 = uuid2.getSequence(); 						//盘点任务明细uuid;
            var newDocid2 = uid2 + "--" + "__nCAL0LGBNy3lrKfjh00"; 	//盘点任务明细formId
            newDoc2.setId(newDocid2);                                                             
            newDoc2.setParent(newDocid);                                                             
            newDoc2.setAuthor(userId);                                                             
            newDoc2.setIstmp(false);                                                             
            newDoc2.setApplicationid(applicationId); 
            newDoc2.addStringItem("ProjectCode", docs.getItemValueAsString("ProjectCode")); 
            newDoc2.addStringItem("ProjectName", docs.getItemValueAsString("ProjectName")); 
            newDoc2.addStringItem("ProjectPhase", docs.getItemValueAsString("ProjectPhase")); 
            newDoc2.addStringItem("PartDrawingNo", docs.getItemValueAsString("PartDrawingNo")); 
            newDoc2.addStringItem("PartName", docs.getItemValueAsString("PartName")); 
            newDoc2.addDoubleItem("BookQuantity", docs.getItemValueAsDouble("BookQuantity")); 
            newDoc2.addDoubleItem("ActualCountQuantity", docs.getItemValueAsDouble("ActualCountQuantity")); 
            newDoc2.addDoubleItem("ReplayQuantity", docs.getItemValueAsDouble("ReplayQuantity"));
            newDoc2.addDoubleItem("ReelsQuantity", docs.getItemValueAsDouble("ReelsQuantity"));
            newDoc2.addDoubleItem("InventoryVariance", docs.getItemValueAsDouble("InventoryVariance"));
            newDoc2.addStringItem("Location", docs.getItemValueAsString("Location"));
            newDoc2.addStringItem("AddressCode", docs.getItemValueAsString("AddressCode"));
            newDoc2.addStringItem("Designated", docs.getItemValueAsString("Designated"));
            newDoc2.addStringItem("Reality", docs.getItemValueAsString("Reality"));
            docProcess.doCreate(newDoc2); 
            }
        }
     }
	var url = "http://" + request.getServerName()+":" + request.getServerPort() + "/static";
	url += "/portal/vue/index.html#/open?appId="+applicationId+"&actionContent="+formid+"&docid="+newDocid+"&opentarget=detail&linkType=00";
	return url;	
})();

发布者:chain,转转请注明出处:https://chain996.top/?p=4119

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-04-20 23:00
下一篇 2022-05-18 21:11

相关推荐

发表回复

您的电子邮箱地址不会被公开。