using System; using BP.DA; using BP.En; using BP.Sys; namespace BP.CCFast.CCMenu { /// /// 菜单 /// public class MenuAttr : EntityTreeAttr { /// /// 系统 /// public const string ModuleNo = "ModuleNo"; /// /// 系统编号 /// public const string SystemNo = "SystemNo"; /// /// 图片 /// public const string WorkType = "WorkType"; /// /// 连接 /// public const string Url = "Url"; /// /// 连接(pc) /// public const string UrlExt = "UrlExt"; /// /// 连接(移动端) /// public const string MobileUrlExt = "MobileUrlExt"; /// /// 是否启用 /// public const string IsEnable = "IsEnable"; /// /// 打开方式 /// public const string OpenWay = "OpenWay"; /// /// 标记 /// public const string Mark = "Mark"; /// /// 扩展1 /// public const string Tag0 = "Tag0"; public const string Tag1 = "Tag1"; /// /// 扩展2 /// public const string Tag2 = "Tag2"; /// /// 扩展3 /// public const string Tag3 = "Tag3"; public const string Tag4 = "Tag4"; public const string Tag5 = "Tag5"; public const string Tag6 = "Tag6"; /// /// 扩展2 /// public const string MenuModel = "MenuModel"; /// /// 列表模式 /// public const string ListModel = "ListModel"; /// /// 组织编号 /// public const string OrgNo = "OrgNo"; /// /// 图标 /// public const string Icon = "Icon"; /// /// 标题 /// public const string Title = "Title"; public const string FrmID = "FrmID"; public const string FlowNo = "FlowNo"; /// /// 风格:比如Tab,的风格. /// public const string Style = "Style"; public const string TagInt1 = "TagInt1"; public const string TagInt2 = "TagInt2"; public const string TagInt3 = "TagInt3"; } /// /// 菜单 /// public class Menu : EntityNoName { #region 属性 public override UAC HisUAC { get { UAC uac = new UAC(); if (BP.Web.WebUser.IsAdmin == true) { uac.IsDelete = true; uac.IsUpdate = true; uac.IsInsert = false; return uac; } else { uac.Readonly(); } return uac; } } /// /// 系统编号 /// public string SystemNo { get { return this.GetValStringByKey(MenuAttr.SystemNo); } set { this.SetValByKey(MenuAttr.SystemNo, value); } } /// /// 组织编号 /// public string OrgNo { get { return this.GetValStringByKey(MenuAttr.OrgNo); } set { this.SetValByKey(MenuAttr.OrgNo, value); } } /// /// 标记 /// public string Mark { get { return this.GetValStringByKey(MenuAttr.Mark); } set { this.SetValByKey(MenuAttr.Mark, value); } } /// /// Tag 1 /// public string Tag1 { get { return this.GetValStringByKey(MenuAttr.Tag1); } set { this.SetValByKey(MenuAttr.Tag1, value); } } //public CtrlWay HisCtrlWay //{ // get // { // return (CtrlWay)this.GetValIntByKey(MenuAttr.CtrlWay); // } // set // { // this.SetValByKey(MenuAttr.CtrlWay, (int)value); // } //} /// /// 功能 /// public MenuType HisMenuType { get { return (MenuType)this.GetValIntByKey(MenuAttr.MenuType); } set { this.SetValByKey(MenuAttr.MenuType, (int)value); } } /// /// 是否启用 /// public bool IsEnable { get { return this.GetValBooleanByKey(MenuAttr.IsEnable); } set { this.SetValByKey(MenuAttr.IsEnable, value); } } /// /// 是否是ccSytem /// //public MenuType MenuType //{ // get // { // return (MenuType)this.GetValIntByKey(MenuAttr.MenuType); // } // set // { // this.SetValByKey(MenuAttr.MenuType, (int)value); // } //} /// /// 类别编号 /// public string ModuleNo { get { return this.GetValStringByKey(MenuAttr.ModuleNo); } set { this.SetValByKey(MenuAttr.ModuleNo, value); } } /// /// 模式 /// public string MenuModel { get { return this.GetValStringByKey(MenuAttr.MenuModel); } set { this.SetValByKey(MenuAttr.MenuModel, value); } } public string Icon { get { return this.GetValStringByKey(MenuAttr.Icon); } set { this.SetValByKey(MenuAttr.Icon, value); } } /// /// 菜单工作类型 0=自定义菜单, 1=系统菜单,不可以删除. /// public int WorkType { get { return this.GetValIntByKey(MenuAttr.WorkType); } set { this.SetValByKey(MenuAttr.WorkType, value); } } public string UrlExt { get { return this.GetValStringByKey(MenuAttr.UrlExt); } set { this.SetValByKey(MenuAttr.UrlExt, value); } } public string MobileUrlExt { get { return this.GetValStringByKey(MenuAttr.MobileUrlExt); } set { this.SetValByKey(MenuAttr.MobileUrlExt, value); } } public bool IsCheck = false; /// /// 标记 /// public int Idx { get { return this.GetValIntByKey(MenuAttr.Idx); } set { this.SetValByKey(MenuAttr.Idx, value); } } #endregion #region 构造方法 /// /// 菜单 /// public Menu() { } /// /// 业务处理. /// /// protected override bool beforeInsert() { if (DataType.IsNullOrEmpty(this.No) == true) this.No = DBAccess.GenerGUID(); this.OrgNo = BP.Web.WebUser.OrgNo; return base.beforeInsert(); } protected override bool beforeDelete() { //如果是数据源列表. if (this.MenuModel.Equals("DBList") == true) { //MapData md = new MapData(this.UrlExt); //md.Delete(); MapAttrs attrs = new MapAttrs(); attrs.Delete(MapAttrAttr.FK_MapData, this.Mark + "Bak"); } //删除窗体信息. if (this.MenuModel.Equals("Windows") == true) { BP.CCFast.Portal.WindowTemplates ens = new BP.CCFast.Portal.WindowTemplates(); ens.Delete(BP.CCFast.Portal.WindowTemplateAttr.PageID, this.No); // BP.CCFast.Portal.WindowExt.HtmlVarDtls dtls = new Home.WindowExt.HtmlVarDtls(); // dtls.Delete(BP.CCFast.Portal.WindowTemplateAttr.PageID, this.No); } return base.beforeDelete(); } /// /// EnMap /// public override Map EnMap { get { if (this._enMap != null) return this._enMap; Map map = new Map("GPM_Menu", "菜单"); // 类的基本属性. map.setEnType(EnType.Sys); map.AddTBStringPK(MenuAttr.No, null, "编号", false, false, 1, 90, 50); map.AddTBString(MenuAttr.Name, null, "名称", true, false, 0, 300, 200, true); map.AddTBString(MenuAttr.MenuModel, null, "菜单模式", true, true, 0, 50, 50); map.AddTBString(MenuAttr.Mark, null, "标记", true, false, 0, 300, 200, false); map.AddTBString(MenuAttr.Tag1, null, "Tag1", true, false, 0, 300, 200, false); map.AddTBString(MenuAttr.FrmID, null, "FrmID", false, false, 0, 300, 200, false); map.AddTBString(MenuAttr.FlowNo, null, "FlowNo", false, false, 0, 300, 200, false); // @0=系统根目录@1=系统类别@2=系统. map.AddDDLSysEnum(MenuAttr.OpenWay, 1, "打开方式", true, true, MenuAttr.OpenWay, "@0=新窗口@1=本窗口@2=覆盖新窗口"); map.AddTBString(MenuAttr.UrlExt, null, "PC端连接", true, false, 0, 500, 200, true); map.AddTBString(MenuAttr.MobileUrlExt, null, "移动端连接", true, false, 0, 500, 200, true); map.AddBoolean(MenuAttr.IsEnable, true, "是否启用?", true, true); map.AddTBString(MenuAttr.Icon, null, "Icon", true, false, 0, 50, 50, true); // map.AddTBString(MenuAttr.ModuleNo, null, "ModuleNo", false, false, 0, 50, 50); map.AddTBString(MenuAttr.SystemNo, null, "SystemNo", false, false, 0, 50, 50); //隶属模块,可以让用户编辑。 map.AddDDLSQL(MenuAttr.ModuleNo, null, "隶属模块编号", "SELECT No,Name FROM GPM_Module WHERE SystemNo='@SystemNo'", true); map.AddDDLSysEnum(MenuAttr.ListModel, 0, "列表模式", true, true, MenuAttr.ListModel, "@0=编辑模式@1=视图模式"); string msg = "提示"; msg += "\t\n 1. 编辑模式就是可以批量的编辑方式打开数据, 可以批量的表格方式编辑数据."; msg += "\t\n 2. 视图模式就是查询的模式打开数据.."; map.SetHelperAlert(MenuAttr.ListModel, msg); map.AddTBString(MenuAttr.OrgNo, null, "OrgNo", true, false, 0, 50, 20); map.AddTBInt(MenuAttr.Idx, 0, "顺序号", true, false); map.AddTBAtParas(500); this._enMap = map; return this._enMap; } } #endregion protected override bool beforeUpdateInsertAction() { if (DataType.IsNullOrEmpty(this.ModuleNo) == true) throw new Exception("err@模块编号不能为空."); //获取他的系统编号. Module md = new Module(this.ModuleNo); this.SystemNo = md.SystemNo; if (this.MenuModel.Equals("Dict") || this.MenuModel.Equals("DBList") || this.MenuModel.Equals("Bill") == true) { this.Mark = DataType.ParseStringForNo(this.Mark, 100); this.UrlExt = DataType.ParseStringForNo(this.UrlExt, 100); } return base.beforeUpdateInsertAction(); } protected override void afterDelete() { string sql = ""; #region 删除实体。 if (this.MenuModel.Equals("Dict") == true || this.MenuModel.Equals("DBList") == true || this.MenuModel.Equals("Bill") == true) { string frmID = this.UrlExt; if (frmID.Contains("?") || frmID.Contains("=")) frmID = this.GetParaString("EnPKVal"); //删除实体. MapData md = new MapData(frmID); md.Delete(); //删除集合方法. sql = "DELETE FROM Frm_Collection WHERE FrmID='" + frmID + "'"; DBAccess.RunSQL(sql); //删除实体组件. sql = "DELETE FROM Frm_Method WHERE FrmID='" + frmID + "'"; DBAccess.RunSQL(sql); //删除实体组件. sql = "DELETE FROM Frm_ToolbarBtn WHERE FrmID='" + frmID + "'"; DBAccess.RunSQL(sql); //删除实体组件. sql = "DELETE FROM GPM_PowerCenter WHERE CtrlObj='Menu' AND CtrlPKVal='" + this.No + "'"; DBAccess.RunSQL(sql); } #endregion 删除实体。 //删除权限控制.. sql = "DELETE FROM GPM_PowerCenter WHERE CtrlObj='Menu' AND CtrlPKVal='" + this.No + "'"; DBAccess.RunSQL(sql); base.afterDelete(); } #region 移动方法. /// /// 向上移动 /// public void DoUp() { this.DoOrderUp(MenuAttr.ModuleNo, this.ModuleNo, ModuleAttr.Idx); } /// /// 向下移动 /// public void DoDown() { this.DoOrderDown(MenuAttr.ModuleNo, this.ModuleNo, ModuleAttr.Idx); } #endregion 移动方法. } /// /// 菜单s /// public class Menus : EntitiesNoName { #region 构造 /// /// 菜单s /// public Menus() { } /// /// 得到它的 Entity /// public override Entity GetNewEntity { get { return new Menu(); } } public override int RetrieveAll() { if (BP.Difference.SystemConfig.CCBPMRunModel != CCBPMRunModel.SAAS) return base.RetrieveAll("Idx"); ////集团模式下的角色体系: @0=每套组织都有自己的角色体系@1=所有的组织共享一套岗则体系. //if (BP.Difference.SystemConfig.GroupStationModel == 1) // return base.RetrieveAll("Idx"); //按照orgNo查询. return this.Retrieve("OrgNo", BP.Web.WebUser.OrgNo, "Idx"); } #endregion #region 为了适应自动翻译成java的需要,把实体转换成List. /// /// 转化成 java list,C#不能调用. /// /// List public System.Collections.Generic.IList ToJavaList() { return (System.Collections.Generic.IList)this; } /// /// 转化成list /// /// List public System.Collections.Generic.List Tolist() { System.Collections.Generic.List list = new System.Collections.Generic.List(); for (int i = 0; i < this.Count; i++) { list.Add((Menu)this[i]); } return list; } #endregion 为了适应自动翻译成java的需要,把实体转换成List. } }