1264 lines
50 KiB
JavaScript
1264 lines
50 KiB
JavaScript
|
||
var allBasicAssetsObj//当前用户有权限的所有机器缓存对象
|
||
var allBasicAssetsObj_Timeout = null;
|
||
var BasicAssetsExpire = false;
|
||
var allAssets;//当前过滤条件下的全部机器
|
||
var selectedAsset = undefined;
|
||
var assetDictionary = [[]];
|
||
var allGroups;
|
||
var groupAssets = [[]];
|
||
var jobsiteAssets = [[]];
|
||
|
||
function updateAssets() {
|
||
assetDictionary = [[]];
|
||
groupAssets = [[]];
|
||
jobsiteAssets = [[]];
|
||
if (allAssets) {
|
||
for (var i = 0; i < allAssets.length; i++) {
|
||
var asset = allAssets[i];
|
||
var index = "" + asset.ID % 100;
|
||
if (!assetDictionary[index])
|
||
assetDictionary[index] = [];
|
||
assetDictionary[index].push(asset);
|
||
|
||
if (asset.AssetGroups && asset.AssetGroups.length > 0) {
|
||
for (var j = 0; j < asset.AssetGroups.length; j++) {
|
||
var gid = asset.AssetGroups[j].toLowerCase();
|
||
if (!groupAssets[gid])
|
||
groupAssets[gid] = [];
|
||
groupAssets[gid].push(asset);
|
||
}
|
||
}
|
||
else {
|
||
var gid = "-1";
|
||
if (!groupAssets[gid])
|
||
groupAssets[gid] = [];
|
||
groupAssets[gid].push(asset);
|
||
}
|
||
|
||
if (asset.JobSites && asset.JobSites.length > 0) {
|
||
for (var j = 0; j < asset.JobSites.length; j++) {
|
||
var jsid = asset.JobSites[j];
|
||
if (!jobsiteAssets[jsid])
|
||
jobsiteAssets[jsid] = [];
|
||
jobsiteAssets[jsid].push(asset);
|
||
}
|
||
}
|
||
else {
|
||
var jsid = -1;
|
||
if (!jobsiteAssets[jsid])
|
||
jobsiteAssets[jsid] = [];
|
||
jobsiteAssets[jsid].push(asset);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
function getAsset(aid) {
|
||
var index = "" + aid % 100;
|
||
var items = assetDictionary[index];
|
||
if (items) {
|
||
for (var i = 0; i < items.length; i++) {
|
||
if (items[i].ID == aid)
|
||
return items[i];
|
||
}
|
||
}
|
||
}
|
||
var unshownMachineID = [];//不需要显示的机器ID
|
||
|
||
/******************************AssetObject******************************/
|
||
/******************************机器信息获取及显示******************************/
|
||
if (typeof (AssetObject) != "function") {
|
||
AssetObject = function (mapHelper) {
|
||
var isFirstLoad = true;//是否第一次加载,第一次加载需定位
|
||
var allMachineCheckBox = [];
|
||
var inGettingAllBasicAssets = false;
|
||
var inGettingBasicAsset = false;
|
||
var inSearchingMachine = false;
|
||
|
||
var allLocations;
|
||
var _this = this;
|
||
var REDUN = 2;
|
||
var ROW_HEIGHT = 50;
|
||
var MIN_LENGTH = 40;
|
||
var trunc = function (val) {
|
||
return (val > 0 ? Math.floor : Math.ceil)(val);
|
||
};
|
||
var assetsummaryctr;
|
||
|
||
var vm = new Vue({
|
||
el: '#machineList',
|
||
data: {
|
||
machines: [],
|
||
startIndex: 0,
|
||
bodyContentStyle: { top: null },
|
||
bodyContainerHeight: 0,
|
||
bodyContainerStyle: { height: null },
|
||
scrollTop: 0,
|
||
HistoryTitle: GetTextByKey("P_MA_LOCATIONHISTORY", "Location History")
|
||
},
|
||
computed: {
|
||
bodyClientRowCount: function () {
|
||
var height = document.getElementById('contentCtrl').clientHeight;
|
||
return trunc((height - 1) / ROW_HEIGHT) + 1;
|
||
},
|
||
innerMachines: function () {
|
||
var start = this.startIndex;
|
||
if (start < 0) {
|
||
start = 0;
|
||
}
|
||
if (this.machines == null || this.machines.length < MIN_LENGTH) {
|
||
return this.machines.slice();
|
||
}
|
||
var end = this.bodyClientRowCount + start + (REDUN * 2) + 1;
|
||
if (end > this.machines.length) {
|
||
end = this.machines.length;
|
||
}
|
||
return this.machines.slice(start, end);
|
||
}
|
||
},
|
||
methods: {
|
||
reload: function (data) {
|
||
this.machines = data;
|
||
|
||
var height = data && data.length * ROW_HEIGHT;
|
||
this.bodyContainerHeight = height;
|
||
this.bodyContainerStyle.height = height && (height + 'px');
|
||
if (data.length < MIN_LENGTH) {
|
||
this.startIndex = -1;
|
||
this.startIndex = 0;
|
||
this.bodyContentStyle.top = '0px';
|
||
} else {
|
||
var index = this.startIndex;
|
||
var lastIndex = data.length - this.bodyClientRowCount;
|
||
if (index > lastIndex) {
|
||
index = lastIndex;
|
||
}
|
||
this.startIndex = -1;
|
||
this.startIndex = index;
|
||
}
|
||
},
|
||
refresh: function () {
|
||
var index = this.startIndex;
|
||
this.startIndex = -1;
|
||
this.startIndex = index;
|
||
},
|
||
chkMachineClick: function (m) {
|
||
chkMachineClick(m);
|
||
},
|
||
linkMachineClick: function (m) {
|
||
linkMachineClick(m);
|
||
this.refresh();
|
||
|
||
if (assetsummaryctr)
|
||
assetsummaryctr.status = 1;
|
||
$("#assetsummary").hide();
|
||
$("#assetsummarytrigle").hide();
|
||
},
|
||
locationHistoryClick: function (m, ev) {
|
||
if (selectedAsset)
|
||
selectedAsset.State.Highlight = false;
|
||
m.State.Highlight = true;
|
||
this.refresh();
|
||
selectedAsset = m;
|
||
var e = { data: m };
|
||
locationHistoryClick(e);
|
||
},
|
||
assetSummaryMouseover: function (m, ev) {
|
||
$("#assetsummary").empty();
|
||
$("#assetsummary").show();
|
||
$("#assetsummarytrigle").show();
|
||
|
||
var left = ev.clientX + 10;
|
||
|
||
left = $(ev.target).offset().left + $(ev.target).width() + 90;
|
||
//var left = $("#machineCtrl").width();
|
||
//var top = ev.clientY;
|
||
var top = $(ev.target).offset().top;
|
||
if (top + 10 + $("#assetsummary").height() > document.documentElement.clientHeight)
|
||
top = document.documentElement.clientHeight - $("#assetsummary").height() - 10;
|
||
top = top - 60;
|
||
|
||
$("#assetsummary").css({ 'left': left, 'top': top });
|
||
$("#assetsummarytrigle").css({ 'left': left + 1, 'top': $(ev.target).offset().top - 60 });
|
||
if (assetsummaryctr)
|
||
assetsummaryctr.status = 1;
|
||
assetsummaryctr = new $assetsummary($("#assetsummary"), m.CompanyID || "", m.ID, m.ViewAlertTypes, m.AlertTips, 0);
|
||
},
|
||
assetSummaryMouseleave: function (m, ev) {
|
||
if (assetsummaryctr)
|
||
assetsummaryctr.status = 1;
|
||
var to = $(ev.toElement);
|
||
if (to.prop('id') != "assetsummary"
|
||
&& to.parents("#assetsummary").length == 0
|
||
&& to.prop('id') != "assetsummarytrigle") {
|
||
$("#assetsummary").hide();
|
||
$("#assetsummarytrigle").hide();
|
||
}
|
||
}
|
||
}
|
||
});
|
||
this.onscrollAssets = function (e) {
|
||
if (vm.machines == null || vm.machines.length < MIN_LENGTH) {
|
||
return;
|
||
}
|
||
var top = e == null ? 0 : e.target.scrollTop;
|
||
top -= (top % ROW_HEIGHT) + (REDUN * ROW_HEIGHT);
|
||
if (top < 0) {
|
||
top = 0;
|
||
} else {
|
||
var bottomTop = vm.bodyContainerHeight - ((vm.bodyClientRowCount + (REDUN * 2) + 1) * ROW_HEIGHT);
|
||
if (top > bottomTop) {
|
||
top = bottomTop;
|
||
}
|
||
}
|
||
if (vm.scrollTop !== top) {
|
||
vm.scrollTop = top;
|
||
vm.startIndex = top / ROW_HEIGHT;
|
||
vm.bodyContentStyle.top = top && (top + 'px');
|
||
}
|
||
};
|
||
|
||
this.refreshAssetList = function () {
|
||
vm.refresh();
|
||
}
|
||
|
||
var ROW_GROUP_HEIGHT = 26;
|
||
var groupData = [];
|
||
var groupMachines = [];
|
||
var agvm = new Vue({
|
||
el: '#assetGroupList',
|
||
data: {
|
||
startIndex: 0,
|
||
bodyContentStyle: { top: null },
|
||
bodyContainerHeight: 0,
|
||
bodyContainerStyle: { height: null },
|
||
scrollTop: 0,
|
||
HistoryTitle: GetTextByKey("P_MA_LOCATIONHISTORY", "Location History")
|
||
},
|
||
computed: {
|
||
bodyClientRowCount: function () {
|
||
var height = document.getElementById('contentCtrl').clientHeight;
|
||
return trunc((height - 1) / ROW_GROUP_HEIGHT) + 1;
|
||
},
|
||
innerAssetgroupMachines: function () {
|
||
var start = this.startIndex;
|
||
if (start < 0) {
|
||
start = 0;
|
||
}
|
||
if (groupMachines == null || groupMachines.length < MIN_LENGTH) {
|
||
return groupMachines.slice();
|
||
}
|
||
var end = this.bodyClientRowCount + start + (REDUN * 2) + 1;
|
||
if (end > groupMachines.length) {
|
||
end = groupMachines.length;
|
||
}
|
||
return groupMachines.slice(start, end);
|
||
}
|
||
},
|
||
methods: {
|
||
fillMachines: function () {
|
||
var g = [];
|
||
var allindeterminate = false;
|
||
var gselcount = 0;
|
||
for (var i = 0; i < groupData.length; i++) {
|
||
var o = groupData[i];
|
||
o.__isGroup = true;
|
||
o.__indeterminate = false;
|
||
g.push(o);
|
||
var selcount = 0;
|
||
if (o.Machines && o.Machines.length > 0) {
|
||
for (var j = 0; j < o.Machines.length; j++) {
|
||
var om = o.Machines[j];
|
||
if (om.State.Selected) selcount++;
|
||
if (!o.Collapsed)
|
||
g.push(om);
|
||
}
|
||
|
||
if (selcount == 0) {
|
||
o.Selected = false;
|
||
o.__indeterminate = false;
|
||
}
|
||
else if (selcount == o.Machines.length) {
|
||
o.Selected = true;
|
||
o.__indeterminate = false;
|
||
}
|
||
else {
|
||
o.__indeterminate = true;
|
||
allindeterminate = true;
|
||
}
|
||
}
|
||
else
|
||
o.__indeterminate = false;
|
||
|
||
if (o.Selected) gselcount++;
|
||
}
|
||
groupMachines = g;
|
||
|
||
var chkSelectAllAssetGroup = document.getElementById("chkSelectAllAssetGroup");
|
||
chkSelectAllAssetGroup.indeterminate = allindeterminate;
|
||
if (gselcount == 0) {
|
||
chkSelectAllAssetGroup.checked = false;
|
||
}
|
||
else if (gselcount == groupData.length) {
|
||
chkSelectAllAssetGroup.checked = true;
|
||
}
|
||
else {
|
||
chkSelectAllAssetGroup.indeterminate = true;
|
||
}
|
||
|
||
var height = g.length * ROW_GROUP_HEIGHT;
|
||
this.bodyContainerHeight = height;
|
||
this.bodyContainerStyle.height = height && (height + 'px');
|
||
|
||
var index = this.startIndex;
|
||
this.startIndex = -1;
|
||
this.startIndex = index;
|
||
// this.$set(this, 'startIndex', index);
|
||
|
||
this.$nextTick(function () {
|
||
var content = document.getElementById('contentCtrl');
|
||
if (this.bodyContainerHeight + 26 <= content.clientHeight) {
|
||
this.bodyContentStyle.top = 0;
|
||
this.startIndex = 0;
|
||
}
|
||
});
|
||
},
|
||
reload: function (data) {
|
||
groupData = data;
|
||
//this.bodyContentStyle.top = '0px';
|
||
this.fillMachines();
|
||
},
|
||
refresh: function () {
|
||
var index = this.startIndex;
|
||
this.startIndex = -1;
|
||
this.startIndex = index;
|
||
},
|
||
treeIconClick: function (e, g) {
|
||
if (g) {
|
||
var t = $(e.target);
|
||
if (t.hasClass("treeiconc"))
|
||
t.removeClass("treeiconc").addClass("treeicone");
|
||
else
|
||
t.removeClass("treeicone").addClass("treeiconc");
|
||
|
||
g.Collapsed = !g.Collapsed;
|
||
|
||
this.fillMachines();
|
||
}
|
||
else
|
||
treeIconClick(e);
|
||
},
|
||
chkMachineClick: function (m) {
|
||
chkMachineClick(m);
|
||
},
|
||
linkMachineClick: function (m) {
|
||
linkMachineClick(m);
|
||
this.refresh();
|
||
},
|
||
locationHistoryClick: function (m, ev) {
|
||
if (selectedAsset)
|
||
selectedAsset.State.Highlight = false;
|
||
m.State.Highlight = true;
|
||
this.refresh();
|
||
selectedAsset = m;
|
||
var e = { data: m };
|
||
locationHistoryClick(e);
|
||
},
|
||
chkAssetGroupClick: function (e, group) {
|
||
chkAssetGroupClick(group);
|
||
this.fillMachines();
|
||
},
|
||
linkAssetGroupClick: function (e, group) {
|
||
if (group.Selected)
|
||
zoomAssetGroup(group);
|
||
else {
|
||
group.Selected = true;
|
||
chkAssetGroupClick(group);
|
||
this.fillMachines();
|
||
zoomAssetGroup(group);
|
||
}
|
||
}
|
||
}
|
||
});
|
||
this.onscrollGroupMachines = function (e) {
|
||
if (groupMachines == null || groupMachines.length < MIN_LENGTH) {
|
||
return;
|
||
}
|
||
var top = e == null ? 0 : e.target.scrollTop;
|
||
top -= (top % ROW_GROUP_HEIGHT) + (REDUN * ROW_GROUP_HEIGHT);
|
||
if (top < 0) {
|
||
top = 0;
|
||
} else {
|
||
var bottomTop = agvm.bodyContainerHeight - ((agvm.bodyClientRowCount + (REDUN * 2) + 1) * ROW_GROUP_HEIGHT);
|
||
if (top > bottomTop) {
|
||
top = bottomTop;
|
||
}
|
||
}
|
||
if (agvm.scrollTop !== top) {
|
||
agvm.scrollTop = top;
|
||
agvm.startIndex = top / ROW_GROUP_HEIGHT;
|
||
agvm.bodyContentStyle.top = top && (top + 'px');
|
||
}
|
||
};
|
||
|
||
this.refreshAssetGroupList = function () {
|
||
agvm.refresh();
|
||
}
|
||
|
||
this.selectAllAssetGroups = function (checked) {
|
||
if (groupData) {
|
||
for (var i = 0; i < groupData.length; i++) {
|
||
var g = groupData[i];
|
||
if (g.Selected != checked) {
|
||
g.Selected = checked;
|
||
chkAssetGroupClick(g);
|
||
}
|
||
}
|
||
agvm.fillMachines();
|
||
}
|
||
}
|
||
|
||
function chkAssetGroupClick(group) {
|
||
var checked = group.Selected;
|
||
if (group && group.Machines) {
|
||
var ams = [];
|
||
var rms = [];
|
||
var rids = [];
|
||
for (var i in group.Machines) {
|
||
var machine = group.Machines[i];
|
||
if (machine.State.Selected != checked) {
|
||
machine.State.Selected = checked;
|
||
|
||
if (checked) {
|
||
ams.push(machine);
|
||
//unshownMachineID.splice(unshownMachineID.indexOf(machine.ID), 1);
|
||
rids.push(machine.ID);
|
||
}
|
||
else {
|
||
rms.push(machine);
|
||
unshownMachineID.push(machine.ID);
|
||
}
|
||
}
|
||
}
|
||
if (rids.length > 0) {
|
||
var unshownids = [];
|
||
for (var i = 0; i < unshownMachineID.length; i++) {
|
||
var id = unshownMachineID[i];
|
||
if (rids.indexOf(id) < 0)
|
||
unshownids.push(id);
|
||
}
|
||
unshownMachineID = unshownids;
|
||
}
|
||
if (ams.length > 0)
|
||
mapHelper.showMachines(ams);
|
||
if (rms.length > 0)
|
||
mapHelper.removeMachines(rms);
|
||
|
||
displayFilerIcon();
|
||
}
|
||
}
|
||
|
||
this.getUnShownMachines = function () {
|
||
return unshownMachineID;
|
||
}
|
||
this.setUnShownMachines = function (machines) {
|
||
unshownMachineID = [];
|
||
if (machines) {
|
||
for (var i in machines) {
|
||
unshownMachineID.push(eval(machines[i]));//asset id 为数值类型
|
||
}
|
||
}
|
||
}
|
||
|
||
this.searchMachine = function (isauto) {
|
||
if (inSearchingMachine)
|
||
return;
|
||
inSearchingMachine = true;
|
||
$('#loadingDiv').show();
|
||
|
||
currentShownIndex = -1;
|
||
allMachineCheckBox.splice(0, allMachineCheckBox.length);//清空CheckBox数组
|
||
//this.getMachines(isauto);//getMachines放在loadMapAlertLayer加载完成后执行
|
||
|
||
if (allBasicAssetsObj && !BasicAssetsExpire) {
|
||
this.loadMapAlertLayer(isauto);
|
||
}
|
||
else {
|
||
this.getAssetBasicInfos(function () {
|
||
_this.loadMapAlertLayer(isauto);
|
||
});
|
||
}
|
||
this.getCompanyLocations();
|
||
|
||
displayFilerIcon();
|
||
}
|
||
this.searchMachine1 = function (isauto) {
|
||
if (inSearchingMachine)
|
||
return;
|
||
inSearchingMachine = true;
|
||
$('#loadingDiv').show();
|
||
|
||
currentShownIndex = -1;
|
||
allMachineCheckBox.splice(0, allMachineCheckBox.length);//清空CheckBox数组
|
||
//this.getMachines(isauto);//getMachines放在loadMapAlertLayer加载完成后执行
|
||
|
||
if (allBasicAssetsObj && !BasicAssetsExpire) {
|
||
if (!IsDealer && MapViewSearchAssetsApiAddress != "")
|
||
this.loadMapAlertLayer1(isauto);
|
||
else //Dealer站点用旧方式
|
||
this.loadMapAlertLayer(isauto);
|
||
}
|
||
else {
|
||
if (!IsDealer && MapViewSearchAssetsApiAddress != "")
|
||
this.getAssetBasicInfos1(function () {
|
||
_this.loadMapAlertLayer1(isauto);
|
||
});
|
||
else//Dealer站点用旧方式
|
||
this.getAssetBasicInfos(function () {
|
||
_this.loadMapAlertLayer(isauto);
|
||
});
|
||
}
|
||
this.getCompanyLocations();
|
||
|
||
displayFilerIcon();
|
||
}
|
||
|
||
this.getAssetBasicInfos = function (next) {
|
||
if (inGettingAllBasicAssets)
|
||
return;
|
||
inGettingAllBasicAssets = true;
|
||
_network.mapviewquery("GetAssetBasicInfos", htmlencode(JSON.stringify([companyids])), function (data) {
|
||
inGettingAllBasicAssets = false;
|
||
if (typeof (data) !== "string") {
|
||
allBasicAssetsObj = new AllBasicAssetsObject();
|
||
allBasicAssetsObj.setAssets(data);
|
||
BasicAssetsExpire = false;
|
||
|
||
if (allBasicAssetsObj_Timeout)
|
||
clearTimeout(allBasicAssetsObj_Timeout)
|
||
allBasicAssetsObj_Timeout = setTimeout(function () {
|
||
BasicAssetsExpire = true;
|
||
}, 5 * 60 * 1000);
|
||
|
||
if (next)
|
||
next();
|
||
}
|
||
else {
|
||
showMachineAlert();
|
||
}
|
||
}, function () {
|
||
inGettingAllBasicAssets = false;
|
||
showMachineAlert();
|
||
});
|
||
}
|
||
this.getAssetBasicInfos1 = function (next) {
|
||
var mal = $("#selMapAlertLayer").val();
|
||
if (!mal) mal = "";
|
||
|
||
var item = {
|
||
'ViewID': mal,
|
||
'ContractorID': companyids,
|
||
'SearchText': htmlencode($("#txtMachineSearchText").val()),
|
||
'Onroad': $("#selOnroad").val(),
|
||
'Layers': parametervalues,
|
||
'ExcludeNoLocation': $("#exclude00Div").attr("state") != "0", //$("#chkExcludeNoLoc").prop("checked"),
|
||
'Attachment': $("#selAttachment").val()
|
||
};
|
||
_network.apipost(MapViewSearchAssetsApiAddress, companyid, item, function (data) {
|
||
inGettingAllBasicAssets = false;
|
||
if (data !== "0") {
|
||
data = convertAssetBasicObjs(data);
|
||
allBasicAssetsObj = new AllBasicAssetsObject();
|
||
allBasicAssetsObj.setAssets(data);
|
||
BasicAssetsExpire = false;
|
||
|
||
if (allBasicAssetsObj_Timeout)
|
||
clearTimeout(allBasicAssetsObj_Timeout)
|
||
allBasicAssetsObj_Timeout = setTimeout(function () {
|
||
BasicAssetsExpire = true;
|
||
}, 5 * 60 * 1000);
|
||
|
||
if (next)
|
||
next();
|
||
}
|
||
else {
|
||
showMachineAlert();
|
||
}
|
||
}, function (request, textStatus, errorThrown) {
|
||
inGettingAllBasicAssets = false;
|
||
showMachineAlert();
|
||
});
|
||
}
|
||
function convertAssetBasicObjs(data) {
|
||
if (typeof data === 'string')
|
||
data = data.split(String.fromCharCode(175));
|
||
if (data == '') return [];
|
||
var assets = [];
|
||
for (var i = 0; i < data.length; i++) {
|
||
var a = {};
|
||
|
||
var s = data[i];
|
||
var ss = s.split(String.fromCharCode(170));
|
||
a.Id = Number(ss[0]);
|
||
a.VIN = ss[1];
|
||
a.Name = ss[2];
|
||
a.MakeName = ss[3];
|
||
a.ModelName = ss[4];
|
||
a.TypeName = ss[5];
|
||
a.OnRoad = ss[6] == "1";
|
||
a.Attachment = ss[7] == "1";
|
||
if (ss[8])
|
||
a.AssetGroups = ss[8].split(',');
|
||
else
|
||
a.AssetGroups = ["-1"];
|
||
|
||
if (ss[9])
|
||
a.JobSites = ss[9].split(',');
|
||
else
|
||
a.JobSites = ["-1"];
|
||
|
||
assets.push(a);
|
||
}
|
||
return assets;
|
||
}
|
||
|
||
var notificationAssetQueue = [];
|
||
this.getAssetBasicInfoByAssets = function (aids) {
|
||
if (inGettingBasicAsset) {
|
||
for (var i = 0; i < aids.length; i++) {
|
||
var aid = aids[i];
|
||
if (notificationAssetQueue.indexOf(aid) < 0)
|
||
notificationAssetQueue.push(aid);
|
||
}
|
||
return;
|
||
}
|
||
inGettingBasicAsset = true;
|
||
|
||
_network.mapviewquery("GetAssetBasicInfoByAssets", htmlencode(JSON.stringify([companyids, JSON.stringify(aids)])), function (data) {
|
||
inGettingBasicAsset = false;
|
||
if (typeof (data) !== "string") {
|
||
if (allBasicAssetsObj)
|
||
allBasicAssetsObj.changeAssets(data);
|
||
}
|
||
if (notificationAssetQueue.length > 0) {
|
||
_this.getAssetBasicInfoByAssets(notificationAssetQueue);
|
||
notificationAssetQueue = [];
|
||
}
|
||
}, function () {
|
||
inGettingBasicAsset = false;
|
||
if (notificationAssetQueue.length > 0) {
|
||
_this.getAssetBasicInfoByAssets(notificationAssetQueue);
|
||
notificationAssetQueue = [];
|
||
}
|
||
});
|
||
}
|
||
|
||
this.getMachines = function (isauto) {
|
||
var mal = $("#selMapAlertLayer").val();
|
||
if (!mal) mal = "";
|
||
|
||
var item = {
|
||
'IsAutoRefresh': isauto,
|
||
'ViewID': mal,
|
||
'ContractorID': companyids,
|
||
'SearchText': htmlencode($("#txtMachineSearchText").val()),
|
||
'Onroad': $("#selOnroad").val(),
|
||
'Layers': parametervalues,
|
||
'ExcludeNoLocation': $("#exclude00Div").attr("state") != "0", //$("#chkExcludeNoLoc").prop("checked"),
|
||
'Attachment': $("#selAttachment").val()
|
||
};
|
||
|
||
_network.mapviewquery("GetAssets", JSON.stringify(item), function (data) {
|
||
if (typeof (data) !== "string") {
|
||
mapHelper.clearMachine();
|
||
allAssets = convertAssetObjs(data);
|
||
updateAssets();
|
||
|
||
_this.getAssetGroups(item);//Asset取完再取group
|
||
jobsiteObject.searchJobSite(isauto);//Asset取完再取jobsite
|
||
|
||
showAssets();
|
||
|
||
if (isFirstLoad || $("#autoRecenterDiv").attr("state") == "1") {
|
||
isFirstLoad = false;
|
||
zoomMap();
|
||
}
|
||
getNowFormatDate();
|
||
}
|
||
else {
|
||
showMachineAlert();
|
||
}
|
||
inSearchingMachine = false;
|
||
$('#loadingDiv').hide();
|
||
}, function () {
|
||
inSearchingMachine = false;
|
||
showMachineAlert();
|
||
$('#loadingDiv').hide();
|
||
});
|
||
}
|
||
this.getMachines1 = function (isauto) {
|
||
var mal = $("#selMapAlertLayer").val();
|
||
if (!mal) mal = "";
|
||
|
||
var item = {
|
||
'IsAutoRefresh': isauto,
|
||
'ViewID': mal,
|
||
'ContractorID': companyids,
|
||
'SearchText': htmlencode($("#txtMachineSearchText").val()),
|
||
'Onroad': Number($("#selOnroad").val()),
|
||
'Layers': parametervalues,
|
||
'ExcludeNoLocation': $("#exclude00Div").attr("state") != "0", //$("#chkExcludeNoLoc").prop("checked"),
|
||
'Attachment': Number($("#selAttachment").val())
|
||
};
|
||
_network.apipost(MapViewQueryViewAssetsApiAddress, companyid, item, function (data) {
|
||
if (data !== "0") {
|
||
mapHelper.clearMachine();
|
||
allAssets = convertAssetObjs(data);
|
||
updateAssets();
|
||
|
||
_this.getAssetGroups(item);//Asset取完再取group
|
||
jobsiteObject.searchJobSite(isauto);//Asset取完再取jobsite
|
||
|
||
showAssets();
|
||
|
||
if (isFirstLoad || $("#autoRecenterDiv").attr("state") == "1") {
|
||
isFirstLoad = false;
|
||
zoomMap();
|
||
}
|
||
getNowFormatDate();
|
||
}
|
||
else {
|
||
showMachineAlert();
|
||
}
|
||
inSearchingMachine = false;
|
||
$('#loadingDiv').hide();
|
||
}, function (request, textStatus, errorThrown) {
|
||
inSearchingMachine = false;
|
||
showMachineAlert();
|
||
$('#loadingDiv').hide();
|
||
});
|
||
}
|
||
|
||
function convertAssetObjs(data) {
|
||
if (typeof data === 'string')
|
||
data = data.split(String.fromCharCode(175));
|
||
if (data == '') return [];
|
||
var assets = [];
|
||
for (var i = 0; i < data.length; i++) {
|
||
var a = {};
|
||
|
||
var s = data[i];
|
||
var s1 = s.split(String.fromCharCode(171));
|
||
if (s1.length == 2) {//Dealer站点返回的数据,包含公司信息
|
||
var cinfos = s1[0].split(String.fromCharCode(170));
|
||
a.CompanyID = cinfos[0];
|
||
a.CompanyName = cinfos[1];
|
||
s = s1[1];
|
||
}
|
||
var ss = s.split(String.fromCharCode(170));
|
||
a.ID = Number(ss[0]);
|
||
a.Latitude = Number(ss[1]);
|
||
a.Longitude = Number(ss[2]);
|
||
a.IconUrl = ss[3];
|
||
a.AlertTips = ss[4];
|
||
a.Priority = Number(ss[5]);
|
||
a.ViewAlertTypes = ss[6];
|
||
|
||
if (allBasicAssetsObj) {
|
||
var ta = allBasicAssetsObj.getAsset(a.ID);
|
||
if (ta) {
|
||
a.VIN = ta.VIN;
|
||
a.DisplayName = ta.Name;
|
||
a.Make = ta.MakeName;
|
||
a.Model = ta.ModelName;
|
||
a.AssetType = ta.TypeName;
|
||
a.OnRoad = ta.OnRoad;
|
||
a.Attachment = ta.Attachment;
|
||
a.AssetGroups = ta.AssetGroups;
|
||
a.JobSites = ta.JobSites;
|
||
}
|
||
}
|
||
|
||
assets.push(a);
|
||
}
|
||
return assets;
|
||
}
|
||
|
||
this.getAssetGroups = function () {
|
||
var item = {
|
||
'ContractorID': companyids,
|
||
'SearchText': "",//htmlencode($("#txtAssetGroupSearchText").val()) //在前端过滤Group,后端不再过滤
|
||
};
|
||
_network.mapviewquery("GetAssetGroups", JSON.stringify(item), function (data) {
|
||
if (typeof (data) !== "string") {
|
||
showAssetGroups(data);
|
||
}
|
||
}, function () {
|
||
});
|
||
}
|
||
|
||
function showMachineAlert() {
|
||
if (machineAlert) {
|
||
_dialog.close(machineAlert);
|
||
machineAlert = null;
|
||
}
|
||
machineAlert = _dialog.showAlert(GetTextByKey("P_MV_UNABLETOOBTAINASSETDATAATTEMPTINGTORECONNECT", 'Unable to obtain asset data. Attempting to reconnect...'), GetTextByKey("P_MV_REFRESHMACHINEDATA", 'Refresh machine data'));
|
||
}
|
||
|
||
function showAssets() {
|
||
var ams = [];
|
||
for (var i = 0; i < allAssets.length; i++) {
|
||
var m = allAssets[i];
|
||
m.State = getMachineStateObj(m.ID);
|
||
if (unshownMachineID.indexOf(m.ID) < 0) {//需要显示
|
||
m.State.Selected = true;
|
||
ams.push(m);
|
||
allJobSiteMachine["MID" + m.ID] = m;
|
||
}
|
||
}
|
||
mapHelper.showMachines(ams);
|
||
vm.reload(allAssets);
|
||
}
|
||
|
||
function showAssetGroups(groups) {
|
||
for (var i = groups.length - 1; i >= 0; i--) {
|
||
var g = groups[i];
|
||
g.Collapsed = true;
|
||
g.Selected = true;
|
||
if (allGroups) {//get group state
|
||
for (var j = 0; j < allGroups.length; j++) {
|
||
var lg = allGroups[j];
|
||
if (g.ID === lg.ID) {
|
||
g.Collapsed = lg.Collapsed;
|
||
g.Selected = lg.Selected;
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
|
||
var filter = $.trim($("#txtAssetGroupSearchText").val());
|
||
g.Matched = true;
|
||
if (filter != "" && g.Name.toLowerCase().indexOf(filter.toLocaleLowerCase()) < 0)
|
||
g.Matched = false;
|
||
|
||
var assets = [];
|
||
if (groupAssets[g.ID.toLowerCase()]) {
|
||
var tempAssets = groupAssets[g.ID.toLowerCase()];
|
||
for (var j = 0; j < tempAssets.length; j++) {//Assets
|
||
var a = tempAssets[j];
|
||
if (g.Matched || isAssetMatch(a, filter)) {
|
||
assets.push(a);
|
||
}
|
||
}
|
||
}
|
||
g.Machines = assets;
|
||
|
||
if (!g.Matched && g.Machines.length == 0)
|
||
groups.splice(i, 1);
|
||
}
|
||
|
||
allGroups = groups;
|
||
agvm.reload(allGroups);
|
||
}
|
||
|
||
function zoomAssetGroup(group) {
|
||
zoomMap(group.Machines);
|
||
}
|
||
|
||
function zoomMap(assets) {
|
||
if (!assets)
|
||
assets = allAssets;
|
||
if (assets && assets.length > 0) {
|
||
var maxLong, minLong, maxLat, minLat = null;
|
||
for (var i in assets) {
|
||
var m = assets[i];
|
||
if (!m.State.Selected) continue;//不计算不显示的
|
||
//if (m.Longitude == 0 && m.Latitude == 0) continue;//不计算经纬度都为0的
|
||
|
||
if (maxLong == null || maxLong < m.Longitude)
|
||
maxLong = m.Longitude;
|
||
if (minLong == null || minLong > m.Longitude)
|
||
minLong = m.Longitude;
|
||
if (maxLat == null || maxLat < m.Latitude)
|
||
maxLat = m.Latitude;
|
||
if (minLat == null || minLat > m.Latitude)
|
||
minLat = m.Latitude;
|
||
}
|
||
if (maxLong != minLong || maxLat != minLat) {//至少一个不相同
|
||
var ext = new ExtentC();
|
||
ext.xmax = maxLong + 0.001;
|
||
ext.xmin = minLong - 0.001;
|
||
ext.ymax = maxLat + 0.001;
|
||
ext.ymin = minLat - 0.001;
|
||
mapHelper.gotoMap(ext);
|
||
}
|
||
else {
|
||
var point = new PointC({
|
||
longitude: assets[0].Longitude,
|
||
latitude: assets[0].Latitude
|
||
});
|
||
mapHelper.centerAt(point);
|
||
}
|
||
}
|
||
else if (assets.length == 1) {
|
||
var point = new PointC({
|
||
longitude: assets[0].Longitude,
|
||
latitude: assets[0].Latitude
|
||
});
|
||
mapHelper.centerAt(point);
|
||
}
|
||
}
|
||
|
||
function chkMachineClick(machine) {
|
||
if (machine) {
|
||
if (machine.State.Selected) {
|
||
mapHelper.showMachine(machine);
|
||
unshownMachineID.splice(unshownMachineID.indexOf(machine.ID), 1);
|
||
}
|
||
else {
|
||
mapHelper.removeMachine(machine);
|
||
unshownMachineID[unshownMachineID.length] = machine.ID;
|
||
}
|
||
|
||
agvm.reload(allGroups);
|
||
displayFilerIcon();
|
||
}
|
||
}
|
||
|
||
function linkMachineClick(machine) {
|
||
if (machine) {
|
||
if (machine.State.Selected) {
|
||
mapHelper.locateMachine(machine);
|
||
}
|
||
else {
|
||
machine.State.Selected = true;
|
||
unshownMachineID.splice(unshownMachineID.indexOf(machine.ID), 1);
|
||
mapHelper.showMachine(machine);
|
||
mapHelper.locateMachine(machine);
|
||
}
|
||
|
||
displayFilerIcon();
|
||
}
|
||
}
|
||
|
||
this.selectAllMachine = function (checked) {
|
||
var ams = [];
|
||
var rms = [];
|
||
for (var i = 0; i < allMachineCheckBox.length; i++) {
|
||
var item = allMachineCheckBox[i];
|
||
var itemChecked = item.attr("checked") == "checked";
|
||
if (checked != itemChecked) {
|
||
item.attr("checked", checked);
|
||
var machine = allMachineCheckBox[i].machine;
|
||
if (checked) {
|
||
ams.push(machine);
|
||
unshownMachineID.splice(unshownMachineID.indexOf(machine.ID), 1);
|
||
}
|
||
else {
|
||
unshownMachineID[unshownMachineID.length] = machine.ID;
|
||
rms.push(machine);
|
||
}
|
||
}
|
||
}
|
||
mapHelper.showMachines(ams);
|
||
mapHelper.removeMachines(rms);
|
||
|
||
displayFilerIcon();
|
||
}
|
||
|
||
this.getContractor = function (callback) {
|
||
_network.mapviewquery("GetContractors", "", function (data) {
|
||
showContractors(data);
|
||
if (callback)
|
||
callback();
|
||
});
|
||
}
|
||
|
||
function showContractors(data) {
|
||
if (data && data.length > 0) {
|
||
hasContractor = true;
|
||
var sel = $("#selContractor");
|
||
//for (var i = 0; i < data.length; i++) {
|
||
// var c = data[i];
|
||
// var opt = $('<option></option>').val(c.Key).text(c.Value);
|
||
// sel.append(opt);
|
||
//}
|
||
sel.data('dropdown').setSource(data);
|
||
if (userParams && userParams.MapViewContratorID && userParams.MapViewContratorID != "") {
|
||
companyids = userParams.MapViewContratorID;
|
||
sel.dropdownVals(userParams.MapViewContratorID.split(","));
|
||
}
|
||
$("#contractorCtrl").css("display", "inline-flex");
|
||
}
|
||
else {
|
||
$("#btnToggleTimeline").show();
|
||
$("#btnImportShapeFile").show();
|
||
}
|
||
// $("#contentCtrl").css("top", $("#divleft1").height() + $("#divleft2").height());//移到splitIcon事件里面执行
|
||
}
|
||
|
||
|
||
this.getCompanyLocations = function () {
|
||
_network.mapviewquery("GetCompanyLocations", companyids, function (data) {
|
||
allLocations = data;
|
||
if (allLocations && allLocations.length > 0)
|
||
$("#showDealerLocationsDiv").css("display", "inline-block");
|
||
else
|
||
$("#showDealerLocationsDiv").hide();
|
||
if ($("#showDealerLocationsDiv").attr("state") == "1")
|
||
_this.showLocations();
|
||
}, function () {
|
||
$('#loadingDiv').hide();
|
||
});
|
||
}
|
||
|
||
this.showLocations = function () {
|
||
if (allLocations) {
|
||
for (var li in allLocations) {
|
||
var loc = allLocations[li];
|
||
mapHelper.showLocation(loc);
|
||
}
|
||
}
|
||
}
|
||
|
||
this.clearLocations = function () {
|
||
if (allLocations) {
|
||
for (var li in allLocations) {
|
||
var loc = allLocations[li];
|
||
mapHelper.removeLocation(loc);
|
||
}
|
||
}
|
||
}
|
||
|
||
this.loadMapAlertLayer = function (isauto) {
|
||
var sel = $("#selMapAlertLayer");
|
||
var selmal = sel.val();//记录已选择的值
|
||
if (!selmal) selmal = userParams.MapAlertLayer;
|
||
|
||
var p = companyids + ";" + selmal;
|
||
_network.mapviewquery("GetMapAlertLayers", p, function (data) {
|
||
if (data && data.length > 0) {
|
||
$("#mapAlertLayerDiv").show();
|
||
$("#splitIconRight").show();
|
||
$("#rightCtrl").show();
|
||
showMapAlertLayer(data);
|
||
}
|
||
else {
|
||
$("#mapAlertLayerDiv").hide();
|
||
$("#splitIconRight").hide();
|
||
$("#rightCtrl").hide();
|
||
}
|
||
|
||
_this.getMachines(isauto);
|
||
}, function () {
|
||
$('#loadingDiv').hide();
|
||
});
|
||
}
|
||
this.loadMapAlertLayer1 = function (isauto) {
|
||
var sel = $("#selMapAlertLayer");
|
||
var selmal = sel.val();//记录已选择的值
|
||
if (!selmal) selmal = userParams.MapAlertLayer;
|
||
|
||
var p = companyids + ";" + selmal;
|
||
_network.mapviewquery("GetMapAlertLayers", p, function (data) {
|
||
if (data && data.length > 0) {
|
||
$("#mapAlertLayerDiv").show();
|
||
$("#splitIconRight").show();
|
||
$("#rightCtrl").show();
|
||
showMapAlertLayer(data);
|
||
}
|
||
else {
|
||
$("#mapAlertLayerDiv").hide();
|
||
$("#splitIconRight").hide();
|
||
$("#rightCtrl").hide();
|
||
}
|
||
|
||
_this.getMachines1(isauto);
|
||
}, function () {
|
||
$('#loadingDiv').hide();
|
||
});
|
||
}
|
||
|
||
var _websocket;
|
||
function openmsgwebsocket() {
|
||
if (typeof MSGWebSocketURL !== "undefined") {
|
||
_websocket = new $websocket(MSGWebSocketURL);
|
||
_websocket.onreceive = onmsgreceived;
|
||
_websocket.connect();
|
||
}
|
||
}
|
||
|
||
function onmsgreceived(data) {
|
||
console.log(JSON.stringify(data));
|
||
if (data) {
|
||
if (data.Code == "200" || data.Code == "201")//add, update
|
||
_this.getAssetBasicInfoByAssets([data.Message]);
|
||
}
|
||
}
|
||
|
||
try {
|
||
openmsgwebsocket();
|
||
}
|
||
catch { }
|
||
}
|
||
}
|
||
|
||
if (typeof AllBasicAssetsObject != "function") {
|
||
AllBasicAssetsObject = function () {
|
||
var assetObjArray = [];
|
||
this.setAssets = function (assets) {
|
||
var obj = { MaxId: 0, Assets: [] };
|
||
assetObjArray.push(obj);
|
||
for (var i = 0; i < assets.length; i++) {
|
||
var asset = assets[i];
|
||
if (obj.Assets.length >= 500) {
|
||
var obj = { MaxId: 0, Assets: [] };
|
||
assetObjArray.push(obj);
|
||
}
|
||
obj.MaxId = asset.Id;
|
||
obj.Assets.push(asset);
|
||
}
|
||
}
|
||
|
||
this.getAsset = function (id) {
|
||
for (var i = 0; i < assetObjArray.length; i++) {
|
||
var obj = assetObjArray[i];
|
||
if (obj.MaxId < id)
|
||
continue;
|
||
|
||
for (var j = 0; j < obj.Assets.length; j++) {
|
||
var asset = obj.Assets[j];
|
||
if (asset.Id == id)
|
||
return asset;
|
||
}
|
||
}
|
||
}
|
||
|
||
this.changeAssets = function (assets) {
|
||
var obj = { MaxId: 0, Assets: [] };
|
||
assetObjArray.push(obj);
|
||
for (var i = 0; i < assets.length; i++) {
|
||
var asset = assets[i];
|
||
var ta = this.getAsset(asset.Id);
|
||
if (ta) {
|
||
Object.assign(ta, asset);
|
||
}
|
||
else
|
||
this.addAsset(asset);
|
||
}
|
||
}
|
||
|
||
this.addAsset = function (asset) {
|
||
for (var i = 0; i < assetObjArray.length; i++) {
|
||
var obj = assetObjArray[i];
|
||
if (obj.MaxId < asset.Id && i != assetObjArray.length - 1)
|
||
continue;
|
||
|
||
obj.Assets.push(asset);
|
||
if (asset.Id > obj.MaxId)
|
||
obj.MaxId = asset.Id;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
function getAssetByID(assetid) {//加载机器的详细信息
|
||
_network.mapviewquery("GetAssetByID", JSON.stringify([assetid, companyids]), function (data) {
|
||
if (data && typeof (data) !== "string") {
|
||
mapHelper.showAssetDetailInfo(data);
|
||
}
|
||
}, function () {
|
||
});
|
||
}
|
||
|
||
var assetLocations = [];//当前的位置信息
|
||
var assetHisLocations = [];//历史记录的位置信息
|
||
function getAssetPopupContent(cid, asset) {
|
||
var loc = asset.Location;
|
||
|
||
var popContent = "<b>" + GetTextByKey("P_MV_NAME_COLON", "Name:") + " </b> " + htmlencode(asset.DisplayName) + "<br/>";
|
||
//popContent += "<b>" + GetTextByKey("P_MV_NAMECUSTOM_COLON", "Name (Custom):") + " </b>" + htmlencode(asset.Name2) + "<br/>";
|
||
popContent += "<b>" + GetTextByKey("P_MV_SN_COLON", "SN:") + " </b>" + asset.VIN + "<br/>";
|
||
popContent += "<b>" + GetTextByKey("P_MV_MAKE_COLON", "Make:") + " </b>" + asset.Make + "<br/>";
|
||
popContent += "<b>" + GetTextByKey("P_MV_MODEL_COLON", "Model:") + " </b>" + asset.Model + "<br/>";
|
||
popContent += "<b>" + GetTextByKey("P_MV_TYPE_COLON", "Type:") + " </b>" + asset.AssetType + "<br/>";
|
||
if (asset.EngineHours > 0) {
|
||
popContent += "<b>" + GetTextByKey("P_MV_ENGINEHOURS_COLON", "Engine Hours:") + " </b>" + asset.EngineHours.toLocaleString() + "<br/>";
|
||
}
|
||
if (asset.Odometer > 0) {
|
||
var odometerInfo = asset.Odometer.toLocaleString();
|
||
if (asset.Odometer > 0 && asset.OdometerUOM) {
|
||
odometerInfo += " " + asset.OdometerUOM;
|
||
}
|
||
popContent += "<b>" + GetTextByKey("P_MV_ODOMETER_COLON", "Odometer:") + " </b>" + odometerInfo + "<br/>";
|
||
}
|
||
if (loc.LocationTimeText !== "")
|
||
popContent += "<b>" + GetTextByKey("P_MV_LOCATIONUPDATED_COLON", "Location Updated:") + " </b>" + loc.LocationTimeText + "<br/>";
|
||
if (asset.EngineHours > 0 && asset.EngineHoursDateText !== "")
|
||
popContent += "<b>" + GetTextByKey("P_MV_ENGINEHOURSUPDATED_COLON", "Engine Hours Updated:") + " </b>" + asset.EngineHoursDateText + "<br/>";
|
||
var speed = "";
|
||
if (loc.Speed >= 0)
|
||
speed = loc.Speed + " " + (loc.SpeedUnit === "mi/h" ? "mph" : loc.SpeedUnit);
|
||
if (speed !== "")
|
||
popContent += "<b>" + GetTextByKey("P_MV_CURRENTSPEED_COLON", "Current Speed:") + " </b>" + speed + "<br/>";
|
||
var postedspeed = "";
|
||
if (loc.PostedSpeed > 0)
|
||
postedspeed = loc.PostedSpeed + " " + loc.PostedSpeedUnit;
|
||
if (postedspeed !== "")
|
||
popContent += "<b>" + GetTextByKey("P_MV_POSTEDSPEED_COLON", "Posted Speed:") + " </b>" + postedspeed + "<br/>";
|
||
if (loc.Street !== "")
|
||
popContent += "<b>" + GetTextByKey("P_MV_STREET_COLON", "Street:") + " </b>" + loc.Street + "<br/>";
|
||
if (asset.GroupNames !== "")
|
||
popContent += "<b>" + GetTextByKey("P_MV_GROUPS_COLON", "Groups:") + " </b>" + htmlencode(asset.GroupNames) + "<br/>";
|
||
if (asset.Description && asset.Description !== "") {
|
||
asset.Description = htmlencode(asset.Description)
|
||
if (asset.Description.indexOf("\r\n") > -1) {
|
||
var reg = new RegExp("\r\n", "g");
|
||
asset.Description = asset.Description.replace(reg, "<br/>");
|
||
}
|
||
if (asset.Description.indexOf("\n") > -1) {
|
||
var reg = new RegExp("\n", "g");
|
||
asset.Description = asset.Description.replace(reg, "<br/>");
|
||
}
|
||
popContent += "<br/><b>" + GetTextByKey("P_MV_DESCRIPTION_COLON", "Description:") + " </b><br/>" + asset.Description + "<br/>";
|
||
}
|
||
if (asset.AlertTip) {
|
||
asset.AlertTip = htmlencode(asset.AlertTip)
|
||
if (asset.AlertTip.indexOf("\r\n") > -1) {
|
||
var reg = new RegExp("\r\n", "g");
|
||
asset.AlertTip = asset.AlertTip.replace(reg, "<br/>");
|
||
}
|
||
popContent += "<br/>" + asset.AlertTip + "<br/>";
|
||
}
|
||
if (!notShowIcons) {
|
||
var div_icon = '<div style="margin-top:10px;">';
|
||
|
||
div_icon += '<span class="icondetail" style="margin-right: 10px; cursor: pointer; " onclick="showMachineDetail(\'' + cid + '\',' + asset.ID + ', \'' + encodeURIComponent(asset.VIN).replace("'", "\\'") + '\')" title="' + GetTextByKey("P_MV_DETAIL", "Detail") + '"></span>';
|
||
div_icon += '<span class="icondirection" style="margin-right: 10px;cursor: pointer;" onclick="doDirections(' + loc.Latitude + ',\'' + loc.Longitude + '\')" title="' + GetTextByKey("P_MV_DIRECTIONS", "Directions") + '"></span>';
|
||
|
||
if (loc.FromSmartWitness && enableSmartWitness)
|
||
div_icon += "<span class='iconvideo' style='margin-right: 10px;cursor:pointer;' onclick='openRequestVideoDialog(\"" + cid + "\"," + asset.ID + ")' title='" + GetTextByKey("P_MV_VIDEOREQUEST", "Video Request") + "'></span>";
|
||
|
||
div_icon += "<span class='iconmail' style='margin-right: 10px;cursor:pointer;' onclick='openSendEmails(\"" + cid + "\"," + asset.ID + ",0)' title='" + GetTextByKey("P_MV_SENDLOCATION", "Send Location") + "'></span>";
|
||
assetLocations[asset.ID] = loc;
|
||
|
||
div_icon += '<span class="iconweather" style="margin-right: 10px; cursor: pointer; " onclick="doWeather(' + loc.Latitude + ',\'' + loc.Longitude + '\')" title="' + GetTextByKey("P_MV_WEATHER", "Weather") + '"></span>';
|
||
|
||
if (canEditAsset)
|
||
div_icon += '<span class="iconasset" style="margin-right: 10px; cursor: pointer; " onclick="OnEditAsset(\'' + cid + '\',\'' + asset.ID + '\')" title="' + GetTextByKey("P_MV_EDITASSET", "Edit Asset") + '"></span>';
|
||
if (canViewWorkOrder)
|
||
div_icon += '<span class="iconmapworkorder" style="margin-right: 10px; cursor: pointer; " onclick="OnViewWorkOrder(\'' + cid + '\',\'' + asset.ID + '\')" title="' + GetTextByKey("P_MV_WORKORDERS", "Work Orders") + '"></span>';
|
||
if (canViewMR)
|
||
div_icon += '<span class="iconmaintenancerecord" style="margin-right: 10px; cursor: pointer; " onclick="OnViewMaintenanceRecord(\'' + cid + '\',\'' + asset.ID + '\')" title="' + GetTextByKey("P_MV_MAINTENANCERECORD", "Maintenance Record") + '"></span>';
|
||
|
||
div_icon += '<span class="iconlochis" style="margin-right: 10px; cursor: pointer; " onclick="doLocationHistory(\'' + cid + '\',' + asset.ID + ', \'' + encodeURIComponent(asset.DisplayName).replace("'", "\\'") + '\')" title="' + GetTextByKey("P_MA_LOCATIONHISTORY", "Location History") + '" data-asset=' + asset + '></span>';
|
||
|
||
div_icon += "</div>";
|
||
popContent += div_icon;
|
||
}
|
||
|
||
return popContent;
|
||
}
|
||
|