二开插件,去除物料规格型号中特殊字符,导入时提示“规格型号值”未填写成功,已解决

栏目:云星空知识作者:金蝶来源:金蝶云社区发布:2024-09-16浏览:1

二开插件,去除物料规格型号中特殊字符,导入时提示“规格型号值”未填写成功,已解决

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...
点击下载文档
确认删除?
回到顶部
客服QQ
  • 客服QQ点击这里给我发消息