wbc
9 天以前 855d6d0e62af450f66e8a4ebcd06415f5a6814f1
DevApp/Gs.DevApp/DevFrm/WOM/Frm_Wompba.cs
@@ -33,6 +33,12 @@
            toolBarMenu1.btnLogClick += ToolBarMenu1_btnLogClick;
            this.toolBarMenu1.getXmlConfig();
            Gs.DevApp.ToolBox.UtilityHelper.SetGridViewParameterMx(gvMx1);
            Gs.DevApp.ToolBox.UtilityHelper.SetGridViewParameter(gridView1, null, null, null, "", (value) =>
            {
                Gs.DevApp.ToolBox.UtilityHelper.JumpTab(xtraTabControl1, 0);
            }, tips, true, (strGuid) => {
                getModelList(strGuid);
            });
            Gs.DevApp.ToolBox.UtilityHelper.SetGridViewParameter(gridView1, picCheckBox, this, "fstatus", "", (value) =>
            {
                Gs.DevApp.ToolBox.UtilityHelper.JumpTab(xtraTabControl1, 0);
@@ -44,6 +50,8 @@
            {
                getPageList(this.pageBar1.CurrentPage);
            }, lbGuid);
            getPageList(1);
            pageBar1.PagerEvent += PageBar1_PagerEvent;
            //选存组织(变明细中的物料和车间)
@@ -596,6 +604,57 @@
        }
        /// <summary>
        ///  新增方法:列表显示
        /// </summary>
        /// <param name="strGuid">主表id</param>
        private void getModelList(string strGuid)
        {
            gcMxL1.DataSource = null;
            var _obj = new
            {
                guid = strGuid,//主建
            };
            try
            {
                string strJson = UtilityHelper.HttpPost("", _webServiceName + "GetModel", JsonConvert.SerializeObject(_obj));
                ReturnModel<dynamic> _rtn = ToolBox.UtilityHelper.ReturnToDynamic(strJson);
                if (_rtn.rtnCode > 0)
                {
                    dynamic dy = _rtn.rtnData;
                    JArray array1 = new JArray();
                    foreach (var a in dy["list"])
                    {
                        array1.Add(a);
                    }
                    DataTable dt1 = JsonConvert.DeserializeObject<DataTable>(array1.ToString());
                    if (dt1.Rows.Count > 0)
                    {
                        gcMxL1.BindingContext = new BindingContext();
                        gcMxL1.DataSource = dt1;
                        gcMxL1.ForceInitialize();
                        gridView4.BestFitColumns();
                        Gs.DevApp.ToolBox.UtilityHelper.SetGridLayout(gridView4);
                    }
                    else
                    {
                        Gs.DevApp.ToolBox.UtilityHelper.SetDefaultTable(gcMxL1, gridView4);
                    }
                }
                else
                    ToolBox.MsgHelper.Warning("提示:" + _rtn.rtnMsg);
            }
            catch (Exception ex)
            {
                ToolBox.MsgHelper.Warning("提示:" + ex.Message);
            }
        }
        /// <summary>
        /// 工具条事件
        /// </summary>
        /// <param name="inFieldValue"></param>
@@ -650,5 +709,88 @@
                MsgHelper.ShowError("提示:" + ex.Message);
            }
        }
        /// <summary>
        /// 批量处理明细按钮点击事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnMultiSelect_Click(object sender, EventArgs e)
        {
            try
            {
                // 获取明细表格的GridView
                GridView myView = (gcMx1.MainView as GridView);
                if (myView == null)
                {
                    MsgHelper.Warning("无法获取明细表格!");
                    return;
                }
                // 获取选中的行
                int[] selectedRows = myView.GetSelectedRows();
                if (selectedRows == null || selectedRows.Length == 0)
                {
                    MsgHelper.Warning("请先选择要处理的明细行!");
                    return;
                }
                // 构建选中行的数据列表
                var selectedData = new List<object>();
                foreach (int rowHandle in selectedRows)
                {
                    if (rowHandle >= 0) // 确保是有效的数据行
                    {
                        var rowData = new
                        {
                            guid = myView.GetRowCellValue(rowHandle, "guid")?.ToString(),
                            daa002 = myView.GetRowCellValue(rowHandle, "daa002")?.ToString(),
                            daa003 = myView.GetRowCellValue(rowHandle, "daa003")?.ToString(),
                            daa005 = myView.GetRowCellValue(rowHandle, "daa005")?.ToString(),
                            daa010 = myView.GetRowCellValue(rowHandle, "daa010")?.ToString()
                        };
                        selectedData.Add(rowData);
                    }
                }
                if (selectedData.Count == 0)
                {
                    MsgHelper.Warning("没有有效的明细数据被选中!");
                    return;
                }
                // 确认操作
                if (!MsgHelper.AskQuestion($"您选择了 {selectedData.Count} 条明细记录,确定要进行批量处理吗?"))
                    return;
                // 构建API请求参数
                var requestData = new
                {
                    selectedDetails = selectedData,
                    operationType = "BatchProcess", // 操作类型
                    operatorGuid = lbGuid.Text.Trim() // 当前操作的主单据GUID
                };
                // 调用API(仿照现有的API调用模式)
                string apiUrl = "WompbaGxManager/BatchProcessDetails"; // API地址
                var strJson = UtilityHelper.HttpPost("", apiUrl, JsonConvert.SerializeObject(requestData));
                var _rtn = UtilityHelper.ReturnToDynamic(strJson);
                // 处理返回结果
                MsgHelper.Warning(_rtn.rtnData.outMsg.ToString());
                if (_rtn.rtnCode > 0 && _rtn.rtnData.outSum * 1 > 0)
                {
                    // 成功后刷新明细数据
                    getModel(lbGuid.Text.Trim());
                    //MsgHelper.Information("批量处理完成!");
                }
            }
            catch (Exception ex)
            {
                MsgHelper.Warning("批量处理失败:" + ex.Message);
            }
        }
    }
}
}