
## 【二开分析】
> [【二开方案】如何在移动销售5.0的商品列表中单独加修改价格精度](https://vip.kingdee.com/article/594472102745426176)
按照上述二开方案进行二开后,移动销售5.0下单的商品列表中的单价的精度会被设置为2,但是客户还希望在 购物车页面、加入购物车页面的 价格精度设置为2,如何做到呢?
## 【二开步骤】
### 购物车页面物料明细列表中单价精度修改为2
1. 编写插件,继承Kingdee.K3.SCM.Mobile.Business.PlugIn.SaleMobileV5.MobShopCart
2. 编写私有方法FillOtherData,在其中对各行单价进行处理
2.1. 循环列表各行
2.2. this.View.Model.GetValue获取到各行FPriceText、FTaxNetPriceText的值
2.3. 然后通过拆分得到实际数值后通过使用.ToString("F2")可将精度设置为2
2.4. 再经拼接得到目标文本,然后this.View.Model.SetValue进行赋值
2.5. 在方法结束前调用this.View.UpdateView("FMobileListViewEntity")更新当前列表
3. 在不同时机调用私有方法FillOtherData,完成单价的处理
3.1. 重写FillData,调用完父类的FillData后执行FillOtherData
3.2. 重写MobileBillViewDataChanged,调用完父类的MobileBillViewDataChanged后判断当前为FSettleCurrId字段改变则执行FillOtherData
3.3. 重写ButtonClick,调用完父类的ButtonClick后判断当前为点击FBtnBomExpand按钮则执行FillOtherData
3.4. 重写MobileBillViewAfterDoOperation,调用完父类的MobileBillViewAfterDoOperation后判断当前为YLDeleteDetail操作则执行FillOtherData
4. 扩展 移动销售V5_购物车(SAL_MobileShopCartV5),将上述插件注册并启用,取消启用默认插件
参考代码如下:
```
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
using Kingdee.BOS.Util;
namespace ClassLibrary1.Sal
{
public class ShopCartPricePrecisionCustom : Kingdee.K3.SCM.Mobile.Business.PlugIn.SaleMobileV5.MobShopCart
{
protected override void MobileBillViewDataChanged(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.CustomEventsArgs e)
{
base.MobileBillViewDataChanged(e);
var args = e.PValue as DataChangedEventArgs;
if (args == null)
return;
if (args.Field.Key.EqualsIgnoreCase("FSettleCurrId"))
{
FillOtherData();
}
var updateEntryKeys = new HashSet<string>(StringComparer.OrdinalIgnoreCase) { "FTaxPrice", "FTaxNetPrice" };
if (updateEntryKeys.Contains(args.Field.Key))
{
FillOtherData();
}
}
protected override void FillData()
{
base.FillData();
FillOtherData();
}
public override void ButtonClick(ButtonClickEventArgs e)
{
base.ButtonClick(e);
if (e.Key.EqualsIgnoreCase("FBtnBomExpand"))
{
FillOtherData();
}
}
protected override void MobileBillViewAfterDoOperation(CustomEventsArgs e)
{
base.MobileBillViewAfterDoOperation(e);
var args = e.PValue as AfterDoOperationEventArgs;
if (args == null)
return;
if (args.Operation.Operation == "YLDeleteDetail" && args.ExecuteResult && isDeleteRowTypeParentLastRow)
{
FillOtherData();
}
}
public override void OnMobilePageActive(Kingdee.BOS.Mobile.PlugIn.Args.MobilePageActiveEventArgs e)
{
base.OnMobilePageActive(e);
if (e.PageActiveMode == Kingdee.BOS.Mobile.PlugIn.Args.MobilePageActiveEventArgs.ActiveMode.BACK)
{
FillOtherData();
}
}
private void FillOtherData()
{
int count = this.View.M