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

前端代码:

 1     // 提交前事件
 2     BeforeSubmit:function(action, postValue){
 3         if(action == 'Submit'){
 4             var tableValue = postValue.Data.D000867prepinbody
 5             $.IConfirm("提示","是否确定提交库存,提交后无法修改",function(data){
 6                 if(data) {
 7                     var params = {"tableValue": tableValue}
 8                     $.SmartForm.PostForm( "begins", params,
 9                         function( res) {
10                             $.IShowSuccess( "成功", "添加成功" );//弹出成功消息
11                         }
12                     );
13                 }
14                 if( !data ) {   // 点击取消
15                     return false
16                 }
17             })
18         }
19         var self = this;
20         var hospitalname = self.hospitalname.GetValue();//医院名称
21         var sonlaboratoryname = self.sonlaboratoryname.GetValue();//科室
22         var productname = self.productname.GetValue();//产品名称
23         var productspecification = self.productspecification.GetValue();//规格
24 
25         // var dataParas= {"hospitalName":'北京市朝阳区三环肿瘤医院',"departmentName":'中医男科',"productName":'术三纱',"specificationsName":'100*50'}
26         // console.log(dataParas);
27         // if(action == 'begin'){
28         //             $.SmartForm.PostForm("begins",dataParas,function(res){
29         //             console.log(res)
30         //         },function(err){},false)
31         //         return false;
32         // }
33 
34         if(action == 'begin'){
35             if(hospitalname == "") {
36                 $.IShowWarn( "医院名称不能为空!" );
37             }
38             else if (productname == "") {
39                 $.IShowWarn( "产品名称不能为空!" );
40             }
41             else if (productspecification == "") {
42                 $.IShowWarn( "规格不能为空!" );
43             } 
44             else {
45                var dataParas= {"hospitalName":hospitalname,"departmentName":sonlaboratoryname,"productName":productname,"specificationsName":productspecification}
46                 // console.log(dataParas);
47                 $.SmartForm.PostForm("begins",dataParas,
48                     function(res){
49                         // console.log(res);
50                         if(res.Successful == true) {
51                             doctorList = res.ReturnData;
52                             var controlManager = self.D000867prepinbody;//获取子表控件
53                             controlManager.ClearRows(); //清空子表所有数据
54                             if(doctorList == null) {
55                                 if (doctorList.length == 0){
56                                     $.IShowWarn("没找到数据!");
57                                 }
58                                 return;
59                             }
60                             var customerList = doctorList.customerList;
61                             for(var i = 0;i < customerList.length;i++) {
62                                 var subObjectId = $.IGuid();
63                                 var subObject = customerList[i].ValueTable;
64                                 var product = doctorList.product.ValueTable;
65                                 var inventoryNumber = doctorList.inventoryNumber;
66                                  controlManager.AddRow(subObjectId,{
67                                     "D000867prepinbody.sonhospitalname":subObject.affiliatedhospital,
68                                     "D000867prepinbody.sonlaboratoryname":subObject.department,
69                                     "D000867prepinbody.sondoctorname":subObject.customername,
70                                     "D000867prepinbody.sonproductname":product.tradename,
71                                     "D000867prepinbody.sonproductspecification":product.specifications,
72                                     "D000867prepinbody.sonproductunit":product.productunit,
73                                     "D000867prepinbody.productprice":product.mediumbidprice,
74                                     "D000867prepinbody.sonproductquantity":inventoryNumber
75                                 });// 添加子表行 
76                             }
77                         }
78                     },
79                     function(err){
80                         $.IShowError( "错误", postValue.Errors[ 0 ] ); 
81                     },
82                     false);
83             }
84             postValue.Refresh = false;
85             postValue.ClosePage = false;
86             return false
87         }  
88     },

后端代码:

 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);
            }
        }

 

posted @ 2019-08-20 16:39  放肆一下  阅读(840)  评论(0编辑  收藏  举报