氚云--用时间判断数据带入关联数据到子表
场景:用户需要对销售订单进行开票,开票是以时间段进行批量开票,不想进行选择,想要选完时间段后,数据直接带入到子表中,进行开票
解决:先设置两个时间选择的控件,用控件获取对应的开始月份,结束月份,开始日期,结束日期,后端获取这四个时间,形成时间段,作为判断依据。销售订单中设置两个控件获取销售月份与日期。在开票页面后端进行数据筛选销售订单是否等于开票客户,开始月份或者结束月份是否相等。获取数据后,进行数据判断,数据是否在开始日到结束日中,进行日的判断,之后将符合数据,纳入数组传值到前端。
开票页面表单设计后端代码
if(actionName == "GetCurrentLoginUser" && this.Request.ActivityCode == "Activity8") { string id = this.Request.BizObject["ObjectId"] + string.Empty; string strsh = "SELECT * FROM i_D278272Sme5lwsi20iy0weiox1noohbo6 where ObjectId='" + id + "'"; System.Data.DataTable dtacsh = this.Engine.Query.QueryTable(strsh, null); //获取相关数据 string yuefen = this.Request.BizObject["F0000009"] + string.Empty; int ksyuefen = int.Parse(this.Request.BizObject["F0000018"].ToString()); int jsyuefen = int.Parse(this.Request.BizObject["F0000024"].ToString()); int ksriqi = int.Parse(this.Request.BizObject["F0000025"].ToString()); int jsriqi = int.Parse(this.Request.BizObject["F0000026"].ToString()); string kehu=this.Request.BizObject["F0000003"]+string.Empty; string str = "SELECT * FROM i_D278272Sq1l43md0o9z530c24m1o3dzw4 where F0000001='"+kehu+"' and (F0000062 ='" + ksyuefen + "' or F0000062='" + jsyuefen + "')"; System.Data.DataTable dtac = this.Engine.Query.QueryTable(str, null); //查询销售订单表符合开始月到结束月以及客户相等的数据 String[] yuefencz = null; if(dtac.Rows.Count > 0) { List < string > yuefenczf=new List<string>(); for(int i = 0;i < dtac.Rows.Count; i++) { string dtriq = dtac.Rows[i]["F0000066"] + string.Empty; int dtddriq = int.Parse(dtriq); if(dtddriq <= jsriqi && dtddriq >= ksriqi) { //判断数据是否在开始日到结束日之间 yuefenczf.Add(dtac.Rows[i]["ObjectId"] + string.Empty); } //yuefencz = yuefenczf.ToArray(); } yuefencz = yuefenczf.ToArray(); } H3.Organization.User user = this.Request.UserContext.User; //获取当前登录用户的用户对象 response.ReturnData = new Dictionary<string, object>();//传值 response.ReturnData.Add("yuefencz", yuefencz); }
开票页面表单设计前端代码
OnLoad:function(){ var parent = this; // debugger; debugger; var enviroment = $.SmartForm.ResponseContext; //if( enviroment.IsCreateMode ) { //PostForm请求后端,actionName为"GetCurrentLoginUser" //var yuefencz = ""; var yuefencz=new Array(); var result=""; var ActivityCode = $.SmartForm.ResponseContext.ActivityCode; $.SmartForm.PostForm( "GetCurrentLoginUser", {}, function( data ) { debugger; console.log(data); if( data.Errors && data.Errors.length ) { $.IShowError( "错误", JSON.stringify( data.Errors ) );//将后端添加到Errors集合里的异常信息弹出 } else { result = data.ReturnData; console.log( result[ "yuefencz" ] ); var arr = result[ "yuefencz" ]; var details = parent.D278272Fwp2z6tu3fq2ub3k4no2p199l3;//获取子表控件对象 details.ClearRows(); //清除子表中的所有行 for( var t = 0;t < arr.length;t++ ) { var controlManager = parent.D278272Fwp2z6tu3fq2ub3k4no2p199l3;//获取子表控件对象 var subObjectId = $.IGuid(); //创建行ID controlManager.AddRow( subObjectId, { "D278272Fwp2z6tu3fq2ub3k4no2p199l3.F0000004": arr[ t ] }) } // ActivityCode = result[ "ActivityCode" ];//取出result对象的UnitId属性值,并赋值到一个部门单选控件中 } }, function( error ) { $.IShowError( "错误", JSON.stringify( error ) );//将后端未知异常弹出 }, false ); }