ShowForm表达式的python写法原创
金蝶云社区-空鹅机
空鹅机
33人赞赏了该文章 227次浏览 未经作者许可,禁止转载编辑于2024年10月16日 17:20:55

def BeforeF7Select(e):

    if e.FieldKey.lower() == "FComContractNo".lower() :
              showParam = ListShowParameter()
              showParam.Context = this.Context
              showParam.FormId = "BHD_IC_ImpContract"
        showParam.IsShowApproved = True
        showParam.ParentPageId = this.View.PageId
        showParam.MultiSelect = False
        showParam.PermissionItemId = PermissionConst.View
        showParam.OpenStyle.ShowType = ShowType.Modal
        showParam.IsLookUp = True
        showParam.PageId = Guid.NewGuid().ToString()
        this.View.ShowForm(showParam, lambda results: SetValue(results))
        
def SetValue(results):
    if results.ReturnData != None:
        billNo = results.ReturnData[0].BillNo
        sql = """
SELECT HEAD.FID, 
       GOOD.FEntryID, 
       PAY.FEntryID, 
       HEAD.FORDERBILLNO,
       GOOD.FMATERIALID, 
       PAY.FRAPSTYLEID, 
       HEAD.FBUYERID,
       HEAD.FSUMAMT, 
     HEAD.FCURRENCYID
FROM TP_IS_ImpContract HEAD
INNER JOIN TP_IS_ImpGoodsEntry GOOD ON HEAD.FID = GOOD.FID
INNER JOIN TP_IS_ImpRapEntry PAY ON HEAD.FID = PAY.FID
WHERE HEAD.FBILLNO = '{0}'
""".format(billNo)

        DynmObjClt = DBUtils.ExecuteDynamicObject(this.Context, sql)

        this.Model.SetValue("FExContractId", DynmObjClt[0]["FORDERBILLNO"])
        this.Model.SetValue("FPurPerson", DynmObjClt[0]["FBUYERID"])
        this.Model.SetValue("FRapStyleId", DynmObjClt[0]["FRAPSTYLEID"])
        this.Model.SetValue("FMeterialId", DynmObjClt[0]["FMATERIALID"])
        this.Model.SetValue("FInvoiceAmount", DynmObjClt[0]["FSUMAMT"])
        this.Model.SetValue("FDocumentAmount", DynmObjClt[0]["FSUMAMT"])
        this.Model.SetValue("FInvoiceBillCurId", DynmObjClt[0]["FCURRENCYID"])
        this.Model.SetValue("FComContractNo", results.ReturnData[0].BillNo)
        
    else:
        this.View.ShowMessage("请选择公司合同号")



## 重点代码解释
this.View.ShowForm(showParam, lambda results: SetValue(results))
这句话,在C#中是这样实现的
```C#
this.View.ShowForm(showParam, new Action((results) =>
{
ListSelectedRowCollection data = results.ReturnData as ListSelectedRowCollection;
if (data != null)
{
this.View.Model.SetValue(“F_abc_Text”, data.Select(m => m.BillNo).FirstOrDefault());
}
}));

```

在python中另外定义一个函数来实现其中的功能,并且使用lambda函数
```def SetValue(results):```


图标赞 33
33人点赞
还没有人点赞,快来当第一个点赞的人吧!
图标打赏
0人打赏
还没有人打赏,快来当第一个打赏的人吧!