var allItemUrls = []; function initMapMenuItems(data) { if (data) { var ul = $('#mapmenu ul').empty(); var wspItemAdded = false; var items = {}; var wspitems = {}; var hasMemuItems = false; //mids用于菜单排序 var mids = ['100', '150', '200', '250', '300', '350', '400', '450', '500', '550', '600', '650', '675', '700', '9999']; //675为从150分离出来的Dispatch & Scheduling,9999 为Dashboard for (var k = 0; k < mids.length; k++) { var mid = mids[k]; for (var i = 0; i < data.length; i++) { var m = data[i]; if (!m.Visible || m.ID == "100") continue; if (m.ID == mid || (mid == '675' && m.ID == "150") || (mid == '9999' && m.ModuleType == 1)) { hasMemuItems = true; if (m.ModuleType == 0) { var item = {}; item.name = m.CurrentName; item.icon = createicon; allItemUrls['m' + mid] = m.Url; if (mid == '675') { item.name = GetTextByKey("P_JS_ASSETSCHEDULINGANDDISPATCHING", "Asset Scheduling and Dispatching"); allItemUrls['m' + mid] = "JobSite/img/dispatch.png"; } var subcount = 0; if (m.SubItems && m.SubItems.length > 0) { var sitems = {} if (mid == "150" && canEditJobsite) { var addjs = { FeatureID: 150, ID: "nav_addjobsite", IconPath: "img/jobsite.png", PageUrl: "AddJobSite.aspx", Title: "Add JobSite", Url: "JobSite/AddJobSite.aspx" }; m.SubItems.push(addjs); } for (var j = 0; j < m.SubItems.length; j++) { var sm = m.SubItems[j]; if (mid == "150" && sm.FeatureID != 100 && sm.FeatureID != 150)//13178-不显示Jobsite Requirements, dispatch requirements and scheduler continue; if (mid == "675" && (sm.FeatureID == 100 || sm.FeatureID == 150))//13178-Dispatch & Scheduling单独显示 continue; var sitem = {} sitem.name = getitemname(sm.ID, sm.Title); sitem.icon = function () { return 'context-menu-icon menuicon' }; sitems['sm' + sm.ID] = sitem; subcount++; allItemUrls['sm' + sm.ID] = sm.Url; } item.items = sitems; } if ((mid != "150" && mid != "675") || subcount > 0) items['m' + mid] = item; } else if (m.ModuleType == 1) { if (!wspItemAdded) { items['sep1'] = "---------"; var item = {}; item.name = "Dashboards"; item.icon = createicon; item.items = wspitems; items['wsp'] = item; wspItemAdded = true; } var wspitem = {} wspitem.name = m.Name; wspitem.icon = createicon; wspitems['w' + m.ID] = wspitem; allItemUrls['w' + m.ID] = m.Url; } } else continue; } } if (hasMemuItems) { $.contextMenu({ selector: '#mapView', callback: function (key, options, e) { var url = allItemUrls[key]; if (!url) return; if (url.length > 4 && url.substring(0, 4) == 'http') { } else if (url.length > 0 && url[0] == '/') { } else { url = _network.root + url; } if (key.indexOf('nav_addjobsite') >= 0) { OnAddJobsite(); } else window.open(url, "_blank"); }, items: items }); } $(".context-menu-item .context-menu-list").css({ "max-height": $(document).height() - 150, 'overflow-x': 'hidden', 'overflow-y': 'auto', }); $(window).resize(function () { $(".context-menu-item .context-menu-list").css("max-height", $(window).height() - 150); }); } } function createicon($element, item, key) { var cls = 'context-menu-icon menuicon'; var id = key.substr(1); if (id == "100") cls += ' menuiconmap'; else if (id == "150") cls += ' menuiconjobsite'; else if (id == "200") cls += ' menuiconpmalerts'; else if (id == "250") cls += ' menuiconfilterq'; else if (id == "300") cls += ' menuiconcredentials'; else if (id == "350") cls += ' menuiconpmsecurity'; else if (id == "400") cls += ' menuiconassets'; else if (id == "450") cls += ' menuiconfic'; else if (id == "500") cls += ' menuiconm3'; else if (id == "550") cls += ' menuiconjobsitelimit'; else if (id == "600") cls += ' menuiconotrconfig'; else if (id == "650") cls += ' menuiconinspection'; else if (id == "675") cls += ' menuicondispatch'; else if (id == "700") cls += ' menuiconteam'; else { if (id === "sp") cls += ' menuicondashboard'; else cls += ' menuiconwsp'; } return cls; } function getitemname(id, name) { //Jobsite if (id === "nav_jobsiterequirements") { name = GetTextByKey("P_JS_JOBSITEREQUIREMENTS", name); } else if (id === "nav_dispatchrequests") { name = GetTextByKey("P_JS_DISPATCHREQUESTS", name); } else if (id === "nav_jobsitemanage") { name = GetTextByKey("P_JOBSITES", name); } else if (id === "nav_scheduler") { name = GetTextByKey("P_JS_SCHEDULER", name); } //Asset Health else if (id === "nav_alertsmanagement") { name = GetTextByKey("P_ALERTSMANAGEMENTNEW", name); } else if (id === "nav_workorder") { name = GetTextByKey("P_WORKORDERNEW", name); } else if (id === "nav_workorderhis") { name = GetTextByKey("P_WORKORDERHISTORY", name); } else if (id === "nav_record") { name = GetTextByKey("P_MAINTENANCERECORDLEGACY", name); } else if (id === "nav_fuelrecord") { name = GetTextByKey("P_FUELRECORDS", name); } else if (id === "nav_maintenanceschedule") { name = GetTextByKey("P_PM_MAINTENANCESCHEDULES", name); } else if (id === "nav_scheduler") { name = GetTextByKey("P_JS_SCHEDULER", name); } //Credentials else if (id === "nav_credential") { name = GetTextByKey("P_CREDENTIALS", name); } else if (id === "nav_jdlink") { name = GetTextByKey("P_JOHNDEERE", name); } else if (id === "nav_jdnotification") { name = GetTextByKey("P_JOHNDEERENOTIFICATIONS", name); } else if (id === "nav_apicredential") { name = GetTextByKey("P_APICREDENTIALS", name); } //Security else if (id === "nav_users") { name = GetTextByKey("P_USERS", name); } else if (id === "nav_user_group") { name = GetTextByKey("P_USERSGROUP", name); } else if (id === "nav_dts") { name = GetTextByKey("P_DATATABLEPERMISSION", name); } else if (id === "nav_filters") { name = GetTextByKey("P_DASHBOARDFILTERS", name); } else if (id === "nav_curfew") { name = GetTextByKey("P_CURFEWCONFIGURATION", name); } else if (id === "nav_curfewmt") { name = GetTextByKey("P_CURFEWMOVEMENTTOLERANCE", name); } else if (id === "nav_usertocontractor") { name = GetTextByKey("P_USERTOCONTRACTOR", name); } //Manage Asset else if (id === "nav_managmachines") { name = GetTextByKey("P_MANAGEASSETS", name); } else if (id === "nav_managrentals") { name = GetTextByKey("P_MANAGERENTALS", name); } else if (id === "nav_machinegroups") { name = GetTextByKey("P_ASSETGROUPS", name); } else if (id === "nav_managegpsdevices") { name = GetTextByKey("P_MANAGEDEVICES", name); } else if (id === "nav_managmodels") { name = GetTextByKey("P_MANAGEMODELS", name); } else if (id === "nav_customerrecord") { name = GetTextByKey("P_CUSTOMERRECORD", name); } else if (id === "nav_addjobsite") { name = GetTextByKey("P_JS_ADDJOBSITE", name); } return name; }