氚云根据后台的多表联查,渲染前端子表页面

 前端代码

    // 提交前事件
    BeforeSubmit:function(action, postValue){
        if(action == 'Submit'){
            var tableValue = postValue.Data.D000867prepinbody
            $.IConfirm("提示","是否确定提交库存,提交后无法修改",function(data){
                if(data) {
                    var params = {"tableValue": tableValue}
                    $.SmartForm.PostForm( "begins", params,
                        function( res) {
                            $.IShowSuccess( "成功", "添加成功" );//弹出成功消息
                        }
                    );
                }
                if( !data ) {   // 点击取消
                    return false
                }
            })
        }
        var self = this;
        var hospitalname = self.hospitalname.GetValue();//医院名称
        var sonlaboratoryname = self.sonlaboratoryname.GetValue();//科室
        var productname = self.productname.GetValue();//产品名称
        var productspecification = self.productspecification.GetValue();//规格

        // var dataParas= {"hospitalName":'北京市朝阳区三环肿瘤医院',"departmentName":'中医男科',"productName":'术三纱',"specificationsName":'100*50'}
        // console.log(dataParas);
        // if(action == 'begin'){
        //             $.SmartForm.PostForm("begins",dataParas,function(res){
        //             console.log(res)
        //         },function(err){},false)
        //         return false;
        // }

        if(action == 'begin'){
            if(hospitalname == "") {
                $.IShowWarn( "医院名称不能为空!" );
            }
            else if (productname == "") {
                $.IShowWarn( "产品名称不能为空!" );
            }
            else if (productspecification == "") {
                $.IShowWarn( "规格不能为空!" );
            } 
            else {
               var dataParas= {"hospitalName":hospitalname,"departmentName":sonlaboratoryname,"productName":productname,"specificationsName":productspecification}
                // console.log(dataParas);
                $.SmartForm.PostForm("begins",dataParas,
                    function(res){
                        // console.log(res);
                        if(res.Successful == true) {
                            doctorList = res.ReturnData;
                            var controlManager = self.D000867prepinbody;//获取子表控件
                            controlManager.ClearRows(); //清空子表所有数据
                            if(doctorList == null) {
                                if (doctorList.length == 0){
                                    $.IShowWarn("没找到数据!");
                                }
                                return;
                            }
                            var customerList = doctorList.customerList;
                            for(var i = 0;i < customerList.length;i++) {
                                var subObjectId = $.IGuid();
                                var subObject = customerList[i].ValueTable;
                                var product = doctorList.product.ValueTable;
                                var inventoryNumber = doctorList.inventoryNumber;
                                 controlManager.AddRow(subObjectId,{
                                    "D000867prepinbody.sonhospitalname":subObject.affiliatedhospital,
                                    "D000867prepinbody.sonlaboratoryname":subObject.department,
                                    "D000867prepinbody.sondoctorname":subObject.customername,
                                    "D000867prepinbody.sonproductname":product.tradename,
                                    "D000867prepinbody.sonproductspecification":product.specifications,
                                    "D000867prepinbody.sonproductunit":product.productunit,
                                    "D000867prepinbody.productprice":product.mediumbidprice,
                                    "D000867prepinbody.sonproductquantity":inventoryNumber
                                });// 添加子表行 
                            }
                        }
                    },
                    function(err){
                        $.IShowError( "错误", postValue.Errors[ 0 ] ); 
                    },
                    false);
            }
            postValue.Refresh = false;
            postValue.ClosePage = false;
            return false
        }  
    },

后端代码

        if(actionName == "begins")
        {
            string hospitalName = this.Request["hospitalName"] + string.Empty;
            string departmentName = this.Request["departmentName"] + string.Empty;
            string productName = this.Request["productName"] + string.Empty;
            string specificationsName = this.Request["specificationsName"] + string.Empty;
            response.ReturnData = new Dictionary<string,object>();
            //1.查询客户列表
            string sql = "select c.affiliatedhospital,c.department,c.customername from i_D000867client c where 1=1 ";
            if(hospitalName != null && hospitalName != "")
            {
                sql += " and c.affiliatedhospital = '" + hospitalName + "'";
            }
            if(departmentName != null && departmentName != "")
            {
                sql += " and c.department = '" + departmentName + "'";
            }
            System.Data.DataTable dtable = this.Engine.Query.QueryTable(sql, null);
            List < H3.Data.Serialization.VirtualObject > virtualList = new List<H3.Data.Serialization.VirtualObject>();
            if(!Convert.IsDBNull(dtable))
            {
                foreach(System.Data.DataRow row in dtable.Rows)
                {
                    H3.Data.Serialization.VirtualObject vobject = new H3.Data.Serialization.VirtualObject();
                    vobject.ValueTable["affiliatedhospital"] = row["affiliatedhospital"].ToString();
                    vobject.ValueTable["department"] = row["department"].ToString();
                    vobject.ValueTable["customername"] = row["customername"].ToString();
                    virtualList.Add(vobject);
                }
                response.ReturnData.Add("customerList", virtualList);
            }
            else 
            {
                ///没有数据,存入库存为0
                response.ReturnData.Add("inventoryNumber", 0);
            }
        }

猜你喜欢

转载自blog.csdn.net/qq_41973396/article/details/88707240