二开插件,去除物料规格型号中特殊字符,导入时提示“规格型号值”未填写成功,已解决
C#版
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Kingdee.BOS; using System.ComponentModel; using Kingdee.BOS.Core.Base; using Kingdee.BOS.Core.Base.PlugIn; using Kingdee.BOS.JSON; using Kingdee.BOS.Util; namespace Kingdee.ZHNK.Report.PlugIn { [Description("物料基础")] public class MaterialBase:AbstractBasePlugIn { public override void BeforeUpdateValue(BOS.Core.DynamicForm.PlugIn.Args.BeforeUpdateValueEventArgs e) { //规格型号 if (e.Key.Equals("FSpecification")) { if (!e.Value.IsNullOrEmptyOrWhiteSpace()) { //手工新增 if (e.Value is object[]) { //存储的是语言Id 跟 内容的集合 var jak = e.Value as object[]; //接收修改后的语言集合 var objs = new List<object>(); if (jak.Length > 0) { JSONObject jobj = JSONObject.Parse(Convert.ToString(jak[0])); if (jobj.ContainsKey("Value")) { var spc = Convert.ToString(jobj["Value"]); //去掉规格型号首尾空格,以及内容中的换行符和制表符 spc = spc.Trim().Replace("\n", "").Replace("\t", "").Replace("\r", ""); jobj["Value"] = spc; } objs.Add(jobj); } if (objs.Count > 0) { //重新填充给规格型号 e.Value = objs.ToArray(); } } else if (e.Value is LocaleValue) //导入 由于没有启用多语言,所以只修改 2052 { //多语言 var ev = e.Value as LocaleValue; var spc = ev[2052]; //去掉规格型号首尾空格,以及内容中的换行符和制表符 spc = spc.Trim().Replace("\n", "").Replace("\t", "").Replace("\r", ""); ev[2052] = spc; e.Value = ev; } } } } } }
Python
#去掉规格中的空格和换行符 import clr clr.AddReference('System') clr.AddReference('Kingdee.BOS') clr.AddReference('Kingdee.BOS.Core') from System import * from Kingdee.BOS import * from Kingdee.BOS.Core.Base import * from Kingdee.BOS.Core.Base.PlugIn import * from Kingdee.BOS.JSON import * def BeforeUpdateValue(e): #规格型号 if e.Key == "FSpecification": if e.Value is not None and len(e.Value)>0: lv =e.Value #导入 if type(lv)==LocaleValue: ev = e.Value spc = ev[2052] #去掉首尾空格和换行符 spc1 = spc.strip().replace('\n', '').replace('\r', '') ev[2052] = spc1 e.Value = ev else: jak = e.Value objs = list() if len(jak)>0: jobj = JSONObject.Parse(str(jak[0])) spc = str(jobj["Value"]) #去掉首尾空格和换行符 spc = spc.strip().replace("\n", "").replace("\r", "") jobj["Value"] = spc objs.append(jobj) if len(objs)>0: e.Value = tuple(objs)
二开插件,去除物料规格型号中特殊字符,导入时提示“规格型号值”未填写成功,已解决
C#版using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;using Kingdee.B...
点击下载文档
上一篇:误删K3DBConfiger开头数据库处理方法下一篇:申请注册用户免激活
本文2024-09-16 18:40:00发表“云星空知识”栏目。
本文链接:https://wenku.my7c.com/article/kingdee-k3cloud-23623.html
您需要登录后才可以发表评论, 登录登录 或者 注册
最新文档
热门文章