add site
This commit is contained in:
63
Site/js/assetalertfilter.js
Normal file
63
Site/js/assetalertfilter.js
Normal file
@ -0,0 +1,63 @@
|
||||
var $assetalertfilter = function (id) {
|
||||
this.containerId = id;
|
||||
this.title = GetTextByKey("P_XXX", 'Asset Alert Filter Templates');
|
||||
this.onOK = null;
|
||||
this.onDialogClosed = null;
|
||||
this.includechild = true;
|
||||
};
|
||||
|
||||
(function () {
|
||||
var __proto = $assetalertfilter.prototype;
|
||||
|
||||
function createDialog() {
|
||||
var dialog = $('<div class="dialog" style="display: none; width: 1300px; height: 800px">').attr('id', this.containerId);
|
||||
|
||||
var title = $('<div class="dialog-title"></div>').appendTo(dialog);
|
||||
title.append($('<span class="title"></span>').text(this.title));
|
||||
title.append('<em class="dialog-close"></em>');
|
||||
|
||||
var content = $('<div class="dialog-content" style="width: 98%; height: 90%; "></div>').appendTo(dialog);
|
||||
$('<div style="clear: both"></div>').appendTo(content);
|
||||
|
||||
this.iframeFilter = $('<iframe style="width: 100%; height: 100%; display: block; border: none;"></iframe>').appendTo(content);
|
||||
this.iframeFilter.attr("src", _network.root + "SystemSettings/AssetAertFilter.aspx");
|
||||
var dialogFunction = $('<div class="dialog-func"></div>').appendTo(dialog);
|
||||
$('<input type="button" value="' + GetTextByKey("P_CP_CLOSE", "Close") + '" class="dialog-close" />').appendTo(dialogFunction).css("height", 26);//height与Workspace.css冲突
|
||||
$('<input type="button" value="' + GetTextByKey("P_IPT_SAVE", "Save") + '" />').click(onOKClick.bind(this)).appendTo(dialogFunction);
|
||||
$('<div class="clear"></div>').appendTo(dialogFunction);
|
||||
|
||||
$('<div class="maskbg" style="display: none"><div class="loading_icon icon c-spin"></div></div>').appendTo(dialog);
|
||||
|
||||
// init
|
||||
$(document.body).append(dialog);
|
||||
|
||||
dialog.dialog(this.onDialogClosed);
|
||||
return dialog;
|
||||
}
|
||||
|
||||
__proto.showAssetAlertFilter = function (topRatio, force) {
|
||||
var dialog;
|
||||
if (force) {
|
||||
$('#' + this.containerId).remove();
|
||||
dialog = createDialog.call(this);
|
||||
} else {
|
||||
dialog = $('#' + this.containerId);
|
||||
if (!dialog.length) {
|
||||
dialog = createDialog.call(this);
|
||||
}
|
||||
}
|
||||
this.dialog = dialog;
|
||||
dialog.attr('init', '1').showDialog().css({
|
||||
'top': (document.documentElement.clientHeight - $('#dialog_assetalertfilter').height()) / (topRatio || 3),
|
||||
'left': (document.documentElement.clientWidth - $('#dialog_assetalertfilter').width()) / 2
|
||||
});
|
||||
//this.gridAssets.setData([]);
|
||||
};
|
||||
|
||||
|
||||
function onOKClick() {
|
||||
execIframeFunc("onSaveAssetAlertFilter", [], this.iframeFilter);
|
||||
//this.iframeFilter.onSaveAssetAlertFilter();
|
||||
this.dialog.hideDialog();
|
||||
}
|
||||
})();
|
418
Site/js/assetselector.js
Normal file
418
Site/js/assetselector.js
Normal file
@ -0,0 +1,418 @@
|
||||
var $assetselector = function (id) {
|
||||
this.containerId = id;
|
||||
this.title = GetTextByKey("P_SELECTASSETS", 'Select Assets');
|
||||
this.companyId = null;
|
||||
this.jobsiteId = null;
|
||||
this.forceSingle = false;
|
||||
this.exceptSource = null;
|
||||
this.exceptShareAsset = false;
|
||||
this.onOK = null;
|
||||
this.onDialogClosed = null;
|
||||
this.includechild = true;
|
||||
this.allowhidden = true;
|
||||
this.allowotherfilter = true;
|
||||
this.uid = null;
|
||||
};
|
||||
|
||||
(function () {
|
||||
var __proto = $assetselector.prototype;
|
||||
|
||||
function initMachinesGrid(parent) {
|
||||
var grid = new GridView(parent);
|
||||
grid.lang = {
|
||||
all: GetTextByKey("P_GRID_ALL", "(All)"),
|
||||
ok: GetTextByKey("P_GRID_OK", "OK"),
|
||||
reset: GetTextByKey("P_GRID_RESET", "Reset")
|
||||
};
|
||||
var styleFilter = function (item) {
|
||||
if (item.Suggested) {
|
||||
return {
|
||||
//'background-color': 'yellow',
|
||||
'display': 'block',
|
||||
'margin': 0,
|
||||
'box-sizing': 'border-box',
|
||||
'padding': '0 4px',
|
||||
'height': '27px',
|
||||
'line-height': '27px',
|
||||
'overflow': 'hidden',
|
||||
'text-overflow': 'ellipsis'
|
||||
};
|
||||
}
|
||||
};
|
||||
var bgFilter = function (item) {
|
||||
if (item.Suggested)
|
||||
return 'yellow';
|
||||
};
|
||||
var columns = [];
|
||||
if (!this.forceSingle) {
|
||||
columns.push({
|
||||
// checkbox
|
||||
name: 'check',
|
||||
key: 'Selected',
|
||||
width: 30,
|
||||
align: 'center',
|
||||
sortable: false,
|
||||
allcheck: true,
|
||||
type: 3
|
||||
});
|
||||
}
|
||||
columns.push({
|
||||
key: 'VIN',
|
||||
caption: GetTextByKey("P_SELECTASSETS_VIN", 'VIN'),
|
||||
width: 160,
|
||||
styleFilter: styleFilter,
|
||||
bgFilter: bgFilter
|
||||
},
|
||||
{
|
||||
key: 'Name',
|
||||
caption: GetTextByKey("P_SELECTASSETS_NAME", 'Name'),
|
||||
width: 160,
|
||||
styleFilter: styleFilter,
|
||||
bgFilter: bgFilter
|
||||
});
|
||||
if (this.jobsiteId != null) {
|
||||
columns.push(
|
||||
{
|
||||
key: 'Suggested',
|
||||
caption: GetTextByKey("P_SELECTASSETS_CURRENTSTATE", 'Current State'),
|
||||
width: 110,
|
||||
allowFilter: true,
|
||||
filter: function (item) {
|
||||
return item.Suggested ? GetTextByKey("P_SELECTASSETS_SUGGESTED", 'SUGGESTED') : GetTextByKey("P_SELECTASSETS_UNASSIGNED", 'UNASSIGNED');
|
||||
},
|
||||
styleFilter: styleFilter,
|
||||
bgFilter: bgFilter
|
||||
},
|
||||
{
|
||||
key: 'DistanceFromSite',
|
||||
caption: GetTextByKey("P_SELECTASSETS_DISTANCEFROMSITE", 'Distance From Site'),
|
||||
align: 'right',
|
||||
width: 130,
|
||||
styleFilter: styleFilter,
|
||||
bgFilter: bgFilter
|
||||
},
|
||||
{
|
||||
key: 'DistanceUnits',
|
||||
caption: GetTextByKey("P_SELECTASSETS_UNITS", 'Units'),
|
||||
width: 80,
|
||||
allowFilter: true,
|
||||
styleFilter: styleFilter,
|
||||
bgFilter: bgFilter
|
||||
}
|
||||
);
|
||||
}
|
||||
columns.push(
|
||||
{
|
||||
key: 'MakeName',
|
||||
caption: GetTextByKey("P_SELECTASSETS_MAKE", 'Make'),
|
||||
width: 120,
|
||||
allowFilter: true,
|
||||
styleFilter: styleFilter,
|
||||
bgFilter: bgFilter
|
||||
},
|
||||
{
|
||||
key: 'ModelName',
|
||||
caption: GetTextByKey("P_SELECTASSETS_MODEL", 'Model'),
|
||||
width: 120,
|
||||
allowFilter: true,
|
||||
styleFilter: styleFilter,
|
||||
bgFilter: bgFilter
|
||||
},
|
||||
{
|
||||
key: 'TypeName',
|
||||
caption: GetTextByKey("P_SELECTASSETS_TYPE", 'Type'),
|
||||
width: 120,
|
||||
allowFilter: true,
|
||||
styleFilter: styleFilter,
|
||||
bgFilter: bgFilter
|
||||
},
|
||||
{
|
||||
key: 'AcquisitionType',
|
||||
caption: GetTextByKey("P_MA_ACQUISITIONTYPE", "Acquisition Type"),
|
||||
width: 120,
|
||||
allowFilter: true,
|
||||
styleFilter: styleFilter,
|
||||
bgFilter: bgFilter
|
||||
},
|
||||
{
|
||||
key: 'AssetGroups',
|
||||
caption: GetTextByKey("P_JS_ASSETGROUP", "Asset Group"),
|
||||
width: 160,
|
||||
allowFilter: false,
|
||||
styleFilter: styleFilter,
|
||||
bgFilter: bgFilter,
|
||||
filter: function (item) {
|
||||
if (item.AssetGroups)
|
||||
return item.AssetGroups.join(", ");
|
||||
else
|
||||
return "";
|
||||
}
|
||||
},
|
||||
{
|
||||
key: 'Jobsites',
|
||||
caption: GetTextByKey("P_JOBSITE", "Jobsite"),
|
||||
width: 160,
|
||||
allowFilter: false,
|
||||
styleFilter: styleFilter,
|
||||
bgFilter: bgFilter,
|
||||
filter: function (item) {
|
||||
if (item.Jobsites && item.Jobsites.length > 0) {
|
||||
var r = "";
|
||||
for (var i = 0; i < item.Jobsites.length; i++) {
|
||||
r += item.Jobsites[i].Key;
|
||||
if (item.Jobsites[i].Value && item.Jobsites[i].Value != "")
|
||||
r += "(" + item.Jobsites[i].Value + ")";
|
||||
r += ", ";
|
||||
}
|
||||
r = r.substring(0, r.length - 2);
|
||||
return r;
|
||||
}
|
||||
else
|
||||
return "";
|
||||
}
|
||||
}
|
||||
);
|
||||
//grid.canMultiSelect = true;
|
||||
grid.columns = columns;
|
||||
grid.init();
|
||||
|
||||
this.gridAssets = grid;
|
||||
}
|
||||
|
||||
function createDialog() {
|
||||
var dialog = $('<div class="dialog" style="display: none; width: 1210px; height: 520px">').attr('id', this.containerId);
|
||||
|
||||
var title = $('<div class="dialog-title"></div>').appendTo(dialog);
|
||||
title.append($('<span class="title"></span>').text(this.title));
|
||||
title.append('<em class="dialog-close"></em>');
|
||||
|
||||
var content = $('<div class="dialog-content"></div>').appendTo(dialog);
|
||||
var searchdiv = $('<div style="position: relative; width: 280px; margin-top: 4px; float: left"></div>').appendTo(content);
|
||||
this.machineSearch = $('<input type="text" placeholder="' + GetTextByKey("P_SELECTASSETS_SEARCH", "Search") + '" />')
|
||||
.css({
|
||||
width: '100%',
|
||||
paddingRight: 28,
|
||||
height: 25,
|
||||
lineHeight: '25px',
|
||||
boxSizing: 'border-box',
|
||||
textIndent: '4px'
|
||||
})
|
||||
.keypress(onKeyPress.bind(this)).appendTo(searchdiv);
|
||||
$('<div></div>').css({
|
||||
position: 'absolute',
|
||||
top: 0, right: 0, height: 25, width: 28,
|
||||
textAlign: 'center',
|
||||
lineHeight: '25px',
|
||||
fontSize: '1.2em',
|
||||
fontFamily: 'FontAwesome',
|
||||
fontWeight: 900,
|
||||
color: 'rgb(123,28,33)',
|
||||
cursor: 'pointer'
|
||||
}).click(onSearch.bind(this)).appendTo(searchdiv);
|
||||
|
||||
var labeldiv = $('<div style="margin: 4px 0 0 10px; float: left; line-height: 25px"></div>').appendTo(content);
|
||||
if (this.jobsiteId == null && this.allowhidden) {
|
||||
this.showHidden = $('<input type="checkbox" id="checkShowHidden"/>').click(onSearch.bind(this)).appendTo(labeldiv);
|
||||
$('<label for="checkShowHidden"></label>').text(GetTextByKey("P_SELECTASSETS_SHOWHIDDEN", 'Show Hidden')).appendTo(labeldiv);
|
||||
}
|
||||
|
||||
if (this.allowotherfilter) {
|
||||
var filterdiv = $('<div style="margin: 4px 0 0 10px; float: left; line-height: 25px"></div>').appendTo(content);
|
||||
$('<label style="margin-left:5px;margin-right:5px;"></label>').text(GetTextByKey("P_JS_ASSETGROUP", 'Asset Group')).appendTo(filterdiv);
|
||||
this.selgroup = $('<select style="width:120px;height:22px;"></select>').change(onSearch.bind(this)).appendTo(filterdiv);
|
||||
getAssetGroups(this.selgroup);
|
||||
$('<label style="margin-left:5px;margin-right:5px;"></label>').text(GetTextByKey("P_XXXXXX", 'Jobsite')).appendTo(filterdiv);
|
||||
this.seljs = $('<select style="width:120px;height:22px;"></select>').change(onSearch.bind(this)).appendTo(filterdiv);
|
||||
$('<label style="margin-left:5px;margin-right:5px;"></label>').text(GetTextByKey("P_XXXXXX", 'Jobsite Code')).appendTo(filterdiv);
|
||||
this.seljscode = $('<select style="width:120px;height:22px;"></select>').change(onSearch.bind(this)).appendTo(filterdiv);
|
||||
getJobSites(this.seljs, this.seljscode);
|
||||
}
|
||||
|
||||
$('<div style="clear: both"></div>').appendTo(content);
|
||||
|
||||
this.machineList = $('<div style="width: 1188px; height: 400px; margin: 10px 0 4px"></div>').appendTo(content);
|
||||
|
||||
var dialogFunction = $('<div class="dialog-func"></div>').appendTo(dialog);
|
||||
$('<input type="button" value="' + GetTextByKey("P_SELECTASSETS_CANCEL", "Cancel") + '" class="dialog-close" />').appendTo(dialogFunction).css("height", 26);//height与Workspace.css冲突
|
||||
$('<input type="button" value="' + GetTextByKey("P_SELECTASSETS_OK", "OK") + '" />').click(onOKClick.bind(this)).appendTo(dialogFunction);
|
||||
$('<div class="clear"></div>').appendTo(dialogFunction);
|
||||
|
||||
$('<div class="maskbg" style="display: none"><div class="loading_icon icon c-spin"></div></div>').appendTo(dialog);
|
||||
|
||||
// init
|
||||
initMachinesGrid.call(this, this.machineList);
|
||||
$(document.body).append(dialog);
|
||||
|
||||
dialog.dialog(this.onDialogClosed);
|
||||
return dialog;
|
||||
}
|
||||
|
||||
__proto.showSelector = function (topRatio, force) {
|
||||
var dialog;
|
||||
if (force) {
|
||||
$('#' + this.containerId).remove();
|
||||
dialog = createDialog.call(this);
|
||||
} else {
|
||||
dialog = $('#' + this.containerId);
|
||||
if (!dialog.length) {
|
||||
dialog = createDialog.call(this);
|
||||
}
|
||||
}
|
||||
this.dialog = dialog;
|
||||
this.machineSearch.val('');
|
||||
if (this.jobsiteId == null && this.allowhidden) {
|
||||
this.showHidden.prop('checked', false);
|
||||
}
|
||||
dialog.attr('init', '1').showDialog().css({
|
||||
'top': (document.documentElement.clientHeight - $('#dialog_machines').height()) / (topRatio || 3),
|
||||
'left': (document.documentElement.clientWidth - $('#dialog_machines').width()) / 2
|
||||
});
|
||||
this.gridAssets.setData([]);
|
||||
onSearch.call(this);
|
||||
};
|
||||
|
||||
function onKeyPress(e) {
|
||||
if (e.keyCode === 13) {
|
||||
onSearch.call(this);
|
||||
}
|
||||
};
|
||||
|
||||
function devicerequest(method, param, callback, error) {
|
||||
var path = "";
|
||||
if (_network.root != null && _network.root.length > 0) {
|
||||
path = "MachineDeviceManagement/";
|
||||
}
|
||||
_network.request(path + "ManageMachines.aspx", -1, method, param, callback, error || function (e) {
|
||||
console.log(e);
|
||||
});
|
||||
}
|
||||
|
||||
function jobsiterequest(method, param, callback, error) {
|
||||
var path = "";
|
||||
if (_network.root != null && _network.root.length > 0) {
|
||||
path = "JobSite/";
|
||||
}
|
||||
_network.request(path + "JobSite.aspx", -1, method, param, callback, error || function (e) {
|
||||
console.log(e);
|
||||
});
|
||||
}
|
||||
|
||||
function hasMachine(id, source) {
|
||||
for (var i = 0; i < source.length; i++) {
|
||||
if (source[i] === id) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function onSearch() {
|
||||
var maskbg = this.dialog.find('.maskbg');
|
||||
maskbg.show();
|
||||
var search = this.machineSearch;
|
||||
search.blur();
|
||||
var excepts = this.exceptSource;
|
||||
var exceptShareAsset = this.exceptShareAsset;
|
||||
var gridAssets = this.gridAssets;
|
||||
var title = this.title;
|
||||
var companyId = this.companyId || '';
|
||||
|
||||
var assetgroup = this.selgroup && this.selgroup.val();
|
||||
if (!assetgroup) assetgroup = "-1";
|
||||
var js = this.seljs && this.seljs.val();
|
||||
if (!js) js = "-1";
|
||||
var jscode = this.seljscode && this.seljscode.val();
|
||||
if (!jscode) jscode = "-1";
|
||||
|
||||
var params = [
|
||||
companyId,
|
||||
search.val(),
|
||||
this.jobsiteId || !this.allowhidden || (this.showHidden.prop('checked') ? '1' : '0'),
|
||||
this.includechild ? '1' : '0',
|
||||
assetgroup,
|
||||
js,
|
||||
jscode,
|
||||
this.uid
|
||||
];
|
||||
|
||||
var method = "GetAssetList";
|
||||
if (this.jobsiteId != null)
|
||||
method = "GetJobsiteAssetList";
|
||||
else if (this.uid != null)
|
||||
method = "GetUserAssignedAssets";
|
||||
|
||||
devicerequest(method, params.join(String.fromCharCode(170)), function (data) {
|
||||
if (typeof data === 'string') {
|
||||
showAlert(GetTextByKey("P_SELECTASSETS_FAILEDGETLIST", 'Failed to get the machine list: ') + data, title);
|
||||
maskbg.hide();
|
||||
return;
|
||||
}
|
||||
var items = [];
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
var it = data[i];
|
||||
if (exceptShareAsset && it.ShareStatus == 2)
|
||||
continue;
|
||||
if (excepts == null || !hasMachine(it.Id, excepts)) {
|
||||
items.push({ Values: it });
|
||||
}
|
||||
}
|
||||
gridAssets.setData(items);
|
||||
maskbg.hide();
|
||||
search.focus();
|
||||
}, function () {
|
||||
showAlert(GetTextByKey("P_SELECTASSETS_FAILEDGETLIST1", 'Failed to get the machine list.'), title);
|
||||
maskbg.hide();
|
||||
});
|
||||
}
|
||||
|
||||
function onOKClick() {
|
||||
var index = this.gridAssets.selectedIndex;
|
||||
if (this.forceSingle && index < 0) {
|
||||
showAlert(GetTextByKey("P_SELECTASSETS_SELECTASSET", 'Please select an asset.'), this.title);
|
||||
return;
|
||||
}
|
||||
this.onOK && this.onOK(this.gridAssets.source, index);
|
||||
this.dialog.hideDialog();
|
||||
}
|
||||
|
||||
function getAssetGroups(ctrl) {
|
||||
devicerequest('GetMachineGroups', '' + String.fromCharCode(170) + '', function (data) {
|
||||
if (typeof data === 'string') {
|
||||
return;
|
||||
}
|
||||
ctrl.empty();
|
||||
ctrl.append($("<option value='-1'> </option>"));
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
var it = data[i];
|
||||
ctrl.append($("<option></option>").val(it.GroupID).text(it.GroupName));
|
||||
}
|
||||
}, function () {
|
||||
});
|
||||
}
|
||||
|
||||
function getJobSites(ctrl, ctrl1) {
|
||||
jobsiterequest('GetJobSiteDataSource', '', function (data) {
|
||||
if (typeof data === 'string') {
|
||||
return;
|
||||
}
|
||||
ctrl.empty();
|
||||
ctrl.append($("<option value='-1'> </option>"));
|
||||
if (data.Jobsites) {
|
||||
for (var i = 0; i < data.Jobsites.length; i++) {
|
||||
var it = data.Jobsites[i];
|
||||
ctrl.append($("<option></option>").val(it.ID).text(it.Name));
|
||||
}
|
||||
}
|
||||
|
||||
ctrl1.empty();
|
||||
ctrl1.append($("<option value='-1'> </option>"));
|
||||
if (data.Codes) {
|
||||
for (var i = 0; i < data.Codes.length; i++) {
|
||||
var it = data.Codes[i];
|
||||
ctrl1.append($("<option></option>").val(it).text(it));
|
||||
}
|
||||
}
|
||||
}, function () {
|
||||
});
|
||||
}
|
||||
})();
|
766
Site/js/assetsummary.js
Normal file
766
Site/js/assetsummary.js
Normal file
@ -0,0 +1,766 @@
|
||||
|
||||
if (typeof ($assetsummary) != "function") {
|
||||
var ctrlindex = 0;
|
||||
var assetIconCollapsed = false;
|
||||
var alertsCollapsed = false;
|
||||
var infowindowScrollTop = 0;
|
||||
$assetsummary = function (p, cid, assetid, alerttips, type, assets) {//type 0.left;1.bottom
|
||||
if (typeof p === "string")
|
||||
p = $("#" + p);
|
||||
if (!p)
|
||||
p = document;
|
||||
this.companyid = cid || "";
|
||||
this.assetid = assetid;
|
||||
this.alerttips = alerttips;
|
||||
this.type = type;
|
||||
this.assets = assets;
|
||||
this.asset = undefined;
|
||||
this.assetext = undefined;
|
||||
this.status = 0;
|
||||
this.ctrlindex = ctrlindex++;
|
||||
this.grid_alertsdt;
|
||||
this.assetchanged = null;
|
||||
var _this = this;
|
||||
|
||||
this.basectrl = $('<div></div>');
|
||||
|
||||
//if (this.assets && this.assets.length > 1) {
|
||||
// this.basectrl.css('margin-top', 10);
|
||||
|
||||
// var div_assets = $('<div style="width: 450px;margin-left:46px;"></div>');
|
||||
// div_assets.dropdown(this.assets, {
|
||||
// search: true,
|
||||
// valueKey: 'ID',
|
||||
// textKey: 'DisplayName'
|
||||
// });
|
||||
// div_assets.find(".dropdown-wrapper").css("border", "1px solid #b9b9b9");
|
||||
// if (this.assetid)
|
||||
// div_assets.dropdownVal(this.assetid);
|
||||
|
||||
// div_assets.on('select', function (_e, item) {
|
||||
// if (item.ID != _this.assetid) {
|
||||
// var temps = _this.assets.filter(function (a) { return a.ID == item.ID })
|
||||
// if (_this.assetchanged && temps && temps.length > 0)
|
||||
// _this.assetchanged(_this.assets.indexOf(temps[0]));
|
||||
// }
|
||||
// });
|
||||
|
||||
// p.append(div_assets);
|
||||
//}
|
||||
|
||||
p.append(this.basectrl);
|
||||
|
||||
this.maskbgctrl = $('<div class="maskbg"><div class="loading_icon icon c-spin"></div></div>');
|
||||
p.append(this.maskbgctrl);
|
||||
|
||||
this.refresh = function () {
|
||||
p.parent(".contentPane").unbind();
|
||||
_this.basectrl.empty();
|
||||
loadAssetInfo();
|
||||
loadAssetExtInfo();
|
||||
}
|
||||
|
||||
|
||||
if (this.assetid) {
|
||||
loadAssetInfo();
|
||||
loadAssetExtInfo();
|
||||
}
|
||||
|
||||
function setIconBr(div_icon) {
|
||||
var br = '<br />';
|
||||
//if (_this.type == 0)
|
||||
div_icon.append(br);
|
||||
}
|
||||
|
||||
function showAssetIcon() {
|
||||
var asset = _this.asset;
|
||||
var loc = asset.Location;
|
||||
var div_icon = $('<div></div>');
|
||||
var iconheight = p.height();
|
||||
if (iconheight == 0)
|
||||
iconheight = p.parent().height();
|
||||
if (_this.type == 0) {
|
||||
div_icon.css({ 'height': iconheight - 4, 'margin-top': -20 });
|
||||
}
|
||||
else {
|
||||
div_icon.css({ 'height': iconheight + 5 });
|
||||
//if (_this.assets && _this.assets.length > 1) {
|
||||
// div_icon.css({ 'height': p.parent().height() + 5, 'margin-top': -42 });
|
||||
//}
|
||||
div_icon.removeClass("divicon_left");
|
||||
div_icon.addClass("divicon_bottom");
|
||||
}
|
||||
div_icon.removeClass("divicon_bottom");
|
||||
div_icon.addClass("divicon_left");
|
||||
|
||||
var span = $('<span class="icondetail" style="cursor: pointer; " onclick="showMachineDetail(\'' + _this.companyid + '\',' + asset.Id + ', \'' + encodeURIComponent(asset.VIN).replace("'", "\\'") + '\')" title="' + GetTextByKey("P_MV_DETAIL", "Detail") + '"></span>');
|
||||
div_icon.append(span);
|
||||
setIconBr(div_icon);
|
||||
span = $('<span class="icondirection" style="cursor: pointer;" onclick="doDirections(' + loc.Latitude + ',' + loc.Longitude + ')" title="' + GetTextByKey("P_MV_DIRECTIONS", "Directions") + '"></span>');
|
||||
div_icon.append(span);
|
||||
setIconBr(div_icon);
|
||||
if (loc.FromSmartWitness && enableSmartWitness) {
|
||||
span = $("<span class='iconvideo' style='cursor:pointer;' onclick='openRequestVideoDialog(\"" + _this.companyid + "\"," + asset.Id + ")' title='" + GetTextByKey("P_MV_VIDEOREQUEST", "Video Request") + "'></span>");
|
||||
div_icon.append(span);
|
||||
setIconBr(div_icon);
|
||||
}
|
||||
span = $("<span class='iconmail' style='cursor:pointer;' onclick='openSendEmails(\"" + _this.companyid + "\"," + asset.Id + ",0)' title='" + GetTextByKey("P_MV_SENDLOCATION", "Send Location") + "'></span>");
|
||||
div_icon.append(span);
|
||||
setIconBr(div_icon);
|
||||
assetLocations[asset.Id] = loc;
|
||||
|
||||
span = $('<span class="iconweather" style="cursor: pointer; " onclick="doWeather(' + loc.Latitude + ',' + loc.Longitude + ')" title="' + GetTextByKey("P_MV_WEATHER", "Weather") + '"></span>');
|
||||
div_icon.append(span);
|
||||
setIconBr(div_icon);
|
||||
if (canEditAsset) {
|
||||
span = $('<span class="iconasset" style="cursor: pointer; " onclick="OnEditAsset(\'' + _this.companyid + '\',\'' + asset.Id + '\')" title="' + GetTextByKey("P_MV_EDITASSET", "Edit Asset") + '"></span>');
|
||||
div_icon.append(span);
|
||||
setIconBr(div_icon);
|
||||
}
|
||||
if (canViewWorkOrder) {
|
||||
span = $('<span class="iconmapworkorder" style="cursor: pointer; " onclick="OnViewWorkOrder(\'' + _this.companyid + '\',\'' + asset.Id + '\')" title="' + GetTextByKey("P_MV_WORKORDERS", "Work Orders") + '"></span>');
|
||||
div_icon.append(span);
|
||||
setIconBr(div_icon);
|
||||
}
|
||||
if (canViewMR) {
|
||||
span = $('<span class="iconmaintenancerecord" style="cursor: pointer; " onclick="OnViewMaintenanceRecord(\'' + _this.companyid + '\',\'' + asset.Id + '\')" title="' + GetTextByKey("P_MV_MAINTENANCERECORD", "Maintenance Record") + '"></span>');
|
||||
div_icon.append(span);
|
||||
setIconBr(div_icon);
|
||||
}
|
||||
span = $('<span class="iconlochis" style="cursor: pointer; " onclick="doLocationHistory(\'' + _this.companyid + '\',' + asset.Id + ', \'' + encodeURIComponent(asset.DisplayName).replace("'", "\\'") + '\')" title="' + GetTextByKey("P_MA_LOCATIONHISTORY", "Location History") + '" data-asset=' + asset + '></span>');
|
||||
div_icon.append(span);
|
||||
setIconBr(div_icon);
|
||||
|
||||
if (canViewAlertsManagement) {
|
||||
span = $('<span class="iconmapmanagealerts" style="cursor: pointer; " onclick="OnViewAlertsManagement(\'' + _this.companyid + '\',\'' + asset.Id + '\')" title="' + GetTextByKey("P_ALERTSMANAGEMENT", "Alerts Management") + '"></span>');
|
||||
div_icon.append(span);
|
||||
setIconBr(div_icon);
|
||||
}
|
||||
if (canViewFuelRecords) {
|
||||
span = $('<span class="iconmapfuelrecord" style="cursor: pointer; " onclick="OnViewFuelRecords(\'' + _this.companyid + '\',\'' + asset.Id + '\')" title="' + GetTextByKey("P_FUELRECORDS", "Fuel Records") + '"></span>');
|
||||
div_icon.append(span);
|
||||
setIconBr(div_icon);
|
||||
}
|
||||
if (canEditJobsite) {
|
||||
span = $('<span class="iconjobsite" style="cursor: pointer;" title="' + GetTextByKey("P_JS_ADDJOBSITE", "Add Jobsite") + '"></span>');
|
||||
span.click(asset.Id, function (e) {
|
||||
OnAddJobsite(e.data);
|
||||
});
|
||||
div_icon.append(span);
|
||||
setIconBr(div_icon);
|
||||
}
|
||||
|
||||
if (asset.AttachmentCount > 0) {
|
||||
span = $('<span class="iconatta" style="cursor: pointer;" title="' + GetTextByKey("P_WO_ATTACHMENTS", "Attachments") + '"></span>');
|
||||
span.click(asset.Id, function (e) {
|
||||
getAssetMapAttachments(_this.companyid, e.data);
|
||||
});
|
||||
div_icon.append(span);
|
||||
setIconBr(div_icon);
|
||||
}
|
||||
|
||||
if (type == 0) {
|
||||
div_icon.find("span").click(function (e) {
|
||||
p.hide();
|
||||
$('#assetsummarytrigle').hide();
|
||||
});
|
||||
}
|
||||
|
||||
return div_icon;
|
||||
}
|
||||
|
||||
function showAssetInfo() {
|
||||
if (!_this.asset) return;
|
||||
var asset = _this.asset;
|
||||
var loc = asset.Location;
|
||||
var br = '<br />';
|
||||
|
||||
if (_this.type == 0) {
|
||||
var div_close = $('<div style="height:20px;"></div>');
|
||||
_this.basectrl.append(div_close);
|
||||
var span_close = $('<span class="clearbtn" style="float: right; padding: 5px;cursor:pointer;"></span>').click(function () {
|
||||
p.hide();
|
||||
$('#assetsummarytrigle').hide();
|
||||
});
|
||||
div_close.append(span_close);
|
||||
}
|
||||
|
||||
if (showTooltipIcons) {
|
||||
var div_icon = showAssetIcon();
|
||||
_this.basectrl.append(div_icon);
|
||||
}
|
||||
|
||||
var div_summary = $('<div class="assetsummaryinfo_div"></div>');
|
||||
if (!showTooltipIcons)
|
||||
div_summary.css("margin-left", 10);
|
||||
_this.basectrl.append(div_summary);
|
||||
|
||||
if (asset.AssetIconUrl) {
|
||||
var div_assetpic = $('<div style="text-align:center;"></div>');
|
||||
var pic = $('<img style="max-width: 98%;max-height:60px;" />').attr('src', asset.AssetIconUrl);
|
||||
div_assetpic.append(pic);
|
||||
var span_picfold = $('<span class="iconpicup" style="float: right; padding: 5px;cursor:pointer;"></span>').click(function () {
|
||||
if ($(this).hasClass('iconpicup')) {
|
||||
$(this).removeClass("iconpicup");
|
||||
$(this).addClass("iconpicdown");
|
||||
div_assetpic.hide();
|
||||
assetIconCollapsed = true;
|
||||
}
|
||||
else {
|
||||
$(this).removeClass("iconpicdown");
|
||||
$(this).addClass("iconpicup");
|
||||
div_assetpic.show();
|
||||
assetIconCollapsed = false;
|
||||
}
|
||||
});
|
||||
if (assetIconCollapsed) {
|
||||
span_picfold.removeClass("iconpicup");
|
||||
span_picfold.addClass("iconpicdown");
|
||||
div_assetpic.hide();
|
||||
}
|
||||
div_summary.append(span_picfold);
|
||||
|
||||
div_summary.append(div_assetpic);
|
||||
}
|
||||
|
||||
var b = $('<b style="font-weight:700;font-size:16px;"></b>').text(asset.DisplayName);
|
||||
div_summary.append(b).append(br);
|
||||
b = $('<b>' + GetTextByKey("P_MV_SN_COLON", "SN:") + ' </b>');
|
||||
div_summary.append(b);
|
||||
var label = $('<label></label>').text(asset.VIN);
|
||||
div_summary.append(label);
|
||||
b = $('<b style="margin-left:10px;">' + GetTextByKey("P_MV_TYPE_COLON", "Type:") + ' </b>');
|
||||
div_summary.append(b);
|
||||
label = $('<label></label>').text(asset.TypeName);
|
||||
div_summary.append(label).append(br);
|
||||
|
||||
b = $('<b>' + GetTextByKey("P_MV_MAKE_COLON", "Make:") + ' </b>');
|
||||
div_summary.append(b);
|
||||
label = $('<label></label>').text(asset.MakeName);
|
||||
div_summary.append(label);
|
||||
b = $('<b style="margin-left:10px;">' + GetTextByKey("P_MV_MODEL_COLON", "Model:") + ' </b>');
|
||||
div_summary.append(b);
|
||||
label = $('<label></label>').text(asset.ModelName);
|
||||
div_summary.append(label).append(br).append(br);
|
||||
|
||||
b = $('<b>' + GetTextByKey("P_MV_GROUPS_COLON", "Group(s):") + ' </b>');
|
||||
div_summary.append(b);
|
||||
label = $('<label></label>').text(asset.Groups);
|
||||
div_summary.append(label).append(br).append(br);
|
||||
|
||||
var text = ""
|
||||
var value = "";
|
||||
var timevalue = "";
|
||||
if (asset.OnRoad) {
|
||||
text = GetTextByKey("P_MV_ODOMETER_COLON", "Odometer:");
|
||||
if (asset.Odometer && asset.Odometer.Corrected >= 0)
|
||||
value = asset.Odometer.Corrected.toFixed(2) + " " + asset.Odometer.UOM
|
||||
timevalue = asset.OdometerAsofTimeLocalStr;
|
||||
}
|
||||
else {
|
||||
text = GetTextByKey("P_MV_HOURS_COLON", "Hours:");
|
||||
if (asset.EngineHours && asset.EngineHours.Corrected >= 0)
|
||||
value = asset.EngineHours.Corrected.toFixed(2);
|
||||
timevalue = asset.EngineHoursAsofTimeLocalStr;
|
||||
}
|
||||
|
||||
b = $('<b>' + text + ' </b>');
|
||||
div_summary.append(b);
|
||||
label = $('<label></label>').text(value);
|
||||
div_summary.append(label);
|
||||
if ((IsSupperAdmin || isAllowed) && canAddReading() && canEditAsset) {
|
||||
var span = $('<span class="assetsummaryplus" style="margin-left:15px;cursor:pointer;"></span>').click(openAddDialog);
|
||||
span.attr("title", GetTextByKey("P_MV_ADDREADING", "Add Reading"));
|
||||
div_summary.append(span);
|
||||
}
|
||||
div_summary.append(br);
|
||||
if (timevalue !== "") {
|
||||
label = $('<label></label>').text("(" + GetTextByKey("P_MV_ASOF", "as of ") + timevalue + ")");
|
||||
if ((asset.OnRoad && asset.IsOdometerRed) || (!asset.OnRoad && asset.IsEngineHoursRed))
|
||||
label.css('color', 'red');
|
||||
div_summary.append(label).append(br);
|
||||
}
|
||||
div_summary.append(br);
|
||||
|
||||
if (canViewPM) {
|
||||
var tb = $('<table style="width: 100%;display:none;" id="pmtable' + _this.ctrlindex + '"></table>');
|
||||
div_summary.append(tb);
|
||||
}
|
||||
|
||||
b = $('<b>' + GetTextByKey("P_MV_JOBSITES_COLON", "Jobsite(s):") + ' </b>');
|
||||
div_summary.append(b);
|
||||
if (asset.Jobsites && asset.Jobsites !== "")
|
||||
label = $('<label></label>').text(asset.Jobsites);
|
||||
else
|
||||
label = $('<label></label>').text(GetTextByKey("P_MV_NOJOBSITEASSIGNED", "No Jobsite Assigned"));
|
||||
div_summary.append(label).append(br);
|
||||
if (asset.LocationAddress && asset.LocationAddress != "") {
|
||||
b = $('<b>' + GetTextByKey("P_MV_LOCATION_COLON", "Location:") + ' </b>');
|
||||
div_summary.append(b);
|
||||
label = $('<label></label>').text(asset.LocationAddress);
|
||||
div_summary.append(label).append(br);
|
||||
if (asset.LocationAsofTimeLocalStr !== "") {
|
||||
label = $('<label></label>').text("(" + GetTextByKey("P_MV_ASOF", "as of ") + asset.LocationAsofTimeLocalStr + ")");
|
||||
if (asset.IsLocationRed)
|
||||
label.css('color', 'red');
|
||||
div_summary.append(label).append(br);
|
||||
}
|
||||
}
|
||||
|
||||
if (canViewInspection) {
|
||||
var div_inspection = $('<div style="min-width:450px;display:none;" id="divinspection_' + _this.ctrlindex + '"></div>');
|
||||
div_summary.append(div_inspection);
|
||||
}
|
||||
|
||||
var tb = $('<table style="width:100%;"></table>');
|
||||
div_summary.append(tb);
|
||||
var tr = $('<tr></tr>');
|
||||
tb.append(tr);
|
||||
//asset.FuelLevel = 25;
|
||||
if (!isNaN(asset.FuelLevel) && asset.FuelLevel > 0) {
|
||||
var td_fuellevel = $('<td></td>');
|
||||
tr.append(td_fuellevel);
|
||||
var fuellevel_div = $('<div id="fuelleveldiv' + _this.ctrlindex + '" style="width:40px;height:120px;display:inline-block;padding-left:10px;padding-right:10px;"></div>');
|
||||
td_fuellevel.append(fuellevel_div);
|
||||
showFuelLevelChart1("fuelleveldiv" + _this.ctrlindex, 120, asset.FuelLevel);
|
||||
}
|
||||
if (loc) {
|
||||
if (asset.OnRoad && (loc.Speed > 0 || (loc.Speed == 0 && asset.MoveStatus != 0))) {
|
||||
var isspeeding = false;
|
||||
if (loc.PostedSpeedLimit > 0 && loc.Speed != 0 && loc.Speed > loc.PostedSpeedLimit)
|
||||
isspeeding = true;
|
||||
|
||||
var td_speed = $('<td></td>');
|
||||
tr.append(td_speed);
|
||||
|
||||
var speedtext = "";
|
||||
if (loc.Speed == 0) {
|
||||
if (asset.MoveStatus == 2)
|
||||
speedtext = "Stopped On";
|
||||
else if (asset.MoveStatus == 3)
|
||||
speedtext = "Stopped Off";
|
||||
}
|
||||
|
||||
var speed_div = $('<div id="speeddiv' + _this.ctrlindex + '" style="width:160px;height:160px;display:inline-block;"></div>');
|
||||
td_speed.append(speed_div);
|
||||
showSpeedChart("speeddiv" + _this.ctrlindex, loc.Speed, loc.PostedSpeedLimit, loc.SpeedUnits, speedtext);
|
||||
|
||||
if (loc.Heading > 0) {
|
||||
var td_heading = $('<td></td>');
|
||||
tr.append(td_heading);
|
||||
var compass_div = $('<div id="compass_' + _this.ctrlindex + '" style="display:inline-block;"></div>');
|
||||
td_heading.append(compass_div);
|
||||
createCompass(compass_div, loc.Heading);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
div_summary.append(br);
|
||||
if (asset.Description && asset.Description !== "") {
|
||||
asset.Description = replaceHtmlText(asset.Description);
|
||||
b = $('<b>' + GetTextByKey("P_MV_DESCRIPTION_COLON", "Description:") + ' </b>');
|
||||
div_summary.append(b);
|
||||
label = $('<label></label>').html(asset.Description);
|
||||
div_summary.append(label).append(br).append(br);
|
||||
}
|
||||
|
||||
if (_this.alerttips && _this.alerttips !== "") {
|
||||
var atips = replaceHtmlText(_this.alerttips)
|
||||
label = $('<label></label>').html(atips);
|
||||
div_summary.append(label).append(br);
|
||||
}
|
||||
if (canViewAlertsManagement) {
|
||||
var div_alerts = $('<div style="height:150px;min-width:450px;display:none;" id="divalerts_' + _this.ctrlindex + '"></div>');
|
||||
div_summary.append(div_alerts);
|
||||
}
|
||||
|
||||
if (_this.assetext)
|
||||
showAssetExtInfo(_this.assetext);
|
||||
}
|
||||
|
||||
function showAssetExtInfo(assetext) {
|
||||
var br = '<br />';
|
||||
if (canViewPM) {
|
||||
var tb = $('#pmtable' + _this.ctrlindex).empty().show();
|
||||
if (assetext.PMPlanItems && assetext.PMPlanItems.length > 0) {
|
||||
for (var i = 0; i < assetext.PMPlanItems.length; i++) {
|
||||
var pmplan = assetext.PMPlanItems[i];
|
||||
var tr = $('<tr></tr>');
|
||||
tb.append(tr);
|
||||
var td = $('<td style="width:100px;vertical-align:top;"></td>');
|
||||
tr.append(td);
|
||||
if (i == 0) {
|
||||
td.append($('<b>' + GetTextByKey("P_MV_NEXTSERVICE_COLON", "Next Service:") + ' </b>'));
|
||||
}
|
||||
td = $('<td style="text-align:left;"></td>').text(pmplan.NextPlanDetail);
|
||||
tr.append(td);
|
||||
}
|
||||
}
|
||||
|
||||
if (assetext.MaintenanceRecordItem && assetext.MaintenanceRecordItem.ID) {
|
||||
var item = assetext.MaintenanceRecordItem;
|
||||
var tr = $('<tr></tr>');
|
||||
tb.append(tr);
|
||||
var td = $('<td style="width:100px;vertical-align:top;"></td>');
|
||||
tr.append(td);
|
||||
td.append($('<b>' + GetTextByKey("P_MV_LASTCOMPLETED_COLON", "Last Completed:") + ' </b>'));
|
||||
td = $('<td style="text-align:left;"></td>').text(item.LastCompletedText);
|
||||
tr.append(td);
|
||||
}
|
||||
}
|
||||
|
||||
if (canViewInspection && assetext.InspectReportItem && assetext.InspectReportItem.Id !== "") {
|
||||
var divinspection = $('#divinspection_' + _this.ctrlindex).empty().show();
|
||||
b = $('<b>' + GetTextByKey("P_MV_LASTINSPECTION_COLON", "Last Inspection:") + ' </b>');
|
||||
divinspection.append(b);
|
||||
label = $('<a href="#"></a>').text(assetext.CommitTimeStr).click(openInspectionReport);
|
||||
divinspection.append(label).append(br).append(br);
|
||||
}
|
||||
|
||||
if (canViewAlertsManagement && assetext.AlertItems && assetext.AlertItems.length > 0) {
|
||||
var divalerts = $('#divalerts_' + _this.ctrlindex).empty().show();
|
||||
var div_alertgrid = $('<div style="height:150px;min-width:450px;" id="divalertgrid_' + _this.ctrlindex + '"></div>');
|
||||
var div_alertstitle = $('<div style="min-width:450px;background-color:#0079c1;position:relative;"></div>');
|
||||
var span_alertstitle = $('<span></span>').text(GetTextByKey("P_MV_ALERTLAST14DAYS", "Alerts Last 14 Days"));
|
||||
div_alertstitle.append(span_alertstitle);
|
||||
var span_alertsicon = $('<span class="iconalertsup" style=right:10px;position:absolute;"></span>').click(function () {
|
||||
if ($(this).hasClass('iconalertsup')) {
|
||||
$(this).removeClass("iconalertsup");
|
||||
$(this).addClass("iconalerts");
|
||||
div_alertgrid.hide();
|
||||
alertsCollapsed = true;
|
||||
}
|
||||
else {
|
||||
$(this).removeClass("iconalerts");
|
||||
$(this).addClass("iconalertsup");
|
||||
div_alertgrid.show();
|
||||
alertsCollapsed = false;
|
||||
}
|
||||
});
|
||||
if (alertsCollapsed) {
|
||||
span_alertsicon.removeClass("iconalertsup");
|
||||
span_alertsicon.addClass("iconalerts");
|
||||
div_alertgrid.hide();
|
||||
}
|
||||
div_alertstitle.append(span_alertsicon);
|
||||
divalerts.append(div_alertstitle);
|
||||
divalerts.append(div_alertgrid);
|
||||
|
||||
InitAlertsGridData();
|
||||
showAlertsList(assetext.AlertItems);
|
||||
}
|
||||
srcollInfowindow();
|
||||
}
|
||||
|
||||
function showAlertsList(data) {
|
||||
var rows = [];
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
var r = data[i];
|
||||
for (var j in r) {
|
||||
if (j === "AlertLocalTime")
|
||||
r[j] = { DisplayValue: r["AlertLocalTimeStr"], Value: r[j] };
|
||||
}
|
||||
var fr = { Values: r };
|
||||
rows.push(fr);
|
||||
}
|
||||
|
||||
_this.grid_alertsdt.setData(rows);
|
||||
}
|
||||
|
||||
function InitAlertsGridData() {
|
||||
_this.grid_alertsdt = new GridView('#divalertgrid_' + _this.ctrlindex);
|
||||
_this.grid_alertsdt.lang = {
|
||||
all: GetTextByKey("P_GRID_ALL", "(All)"),
|
||||
ok: GetTextByKey("P_GRID_OK", "OK"),
|
||||
reset: GetTextByKey("P_GRID_RESET", "Reset")
|
||||
};
|
||||
var list_columns = [
|
||||
{ name: 'AlertLocalDateStr', caption: GetTextByKey("P_MV_DATE", "Date"), valueIndex: 'AlertLocalDateStr', css: { 'width': 70, 'text-align': 'left' } },
|
||||
{ name: 'AlertLocalTimeStr', caption: GetTextByKey("P_MV_TIME", "Time"), valueIndex: 'AlertLocalTimeStr', css: { 'width': 75, 'text-align': 'left' } },
|
||||
{ name: 'Level', caption: GetTextByKey("P_MV_LEVEL", "Level"), valueIndex: 'Level', css: { 'width': 60, 'text-align': 'left' } },
|
||||
{ name: 'Description', caption: GetTextByKey("P_MV_DESCRIPTION", "Description"), valueIndex: 'Description', css: { 'width': 200, 'text-align': 'left' } }
|
||||
];
|
||||
var columns = [];
|
||||
// head
|
||||
for (var hd in list_columns) {
|
||||
var col = {};
|
||||
col.name = list_columns[hd].name;
|
||||
col.caption = list_columns[hd].caption;
|
||||
col.visible = true;
|
||||
col.sortable = true;
|
||||
col.width = list_columns[hd].css.width;
|
||||
col.align = list_columns[hd].css["text-align"]
|
||||
col.key = list_columns[hd].valueIndex;
|
||||
col.allowFilter = list_columns[hd].allowFilter;
|
||||
columns.push(col);
|
||||
}
|
||||
_this.grid_alertsdt.canMultiSelect = false;
|
||||
_this.grid_alertsdt.columns = columns;
|
||||
_this.grid_alertsdt.init();
|
||||
|
||||
_this.grid_alertsdt.selectedrowchanged = function (rowindex) {
|
||||
var rowdata = _this.grid_alertsdt.source[rowindex];
|
||||
if (rowdata) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function devicerequest(method, param, callback, error) {
|
||||
var path = "";
|
||||
if (_network.root != null && _network.root.length > 0) {
|
||||
path = "MachineDeviceManagement/";
|
||||
}
|
||||
_network.request(path + "ManageMachines.aspx", -1, method, param, callback, error || function (e) {
|
||||
console.log(e);
|
||||
});
|
||||
}
|
||||
|
||||
function createCompass(container, heading) {
|
||||
var options = {
|
||||
lineColor: '#8cc8ad',
|
||||
pointerColor: '#cc3735',
|
||||
lineWidth: 10,
|
||||
circleWidth: 10,
|
||||
radius: 50,
|
||||
//font: 'Verdana',
|
||||
fontSize: 14
|
||||
}
|
||||
var compass = new $compass(container, options);
|
||||
compass.draw(heading);
|
||||
}
|
||||
|
||||
function loadAssetInfo() {
|
||||
_this.maskbgctrl.show();
|
||||
devicerequest('GetAssetSummaryInfo', _this.companyid + String.fromCharCode(170) + _this.assetid, function (data) {
|
||||
if (typeof data === 'string') {
|
||||
_dialog.showAlert(GetTextByKey("P_SELECTASSETS_FAILEDGETLIST", 'Failed to get the machine list: ') + data, "Asset Summary");
|
||||
return;
|
||||
}
|
||||
_this.asset = data;
|
||||
if (_this.status == 0)
|
||||
showAssetInfo();
|
||||
_this.maskbgctrl.hide();
|
||||
}, function () {
|
||||
_this.maskbgctrl.hide();
|
||||
});
|
||||
}
|
||||
|
||||
function loadAssetExtInfo() {
|
||||
//_this.maskbgctrl.show();
|
||||
devicerequest('GetAssetExtInfo', _this.companyid + String.fromCharCode(170) + _this.assetid, function (data) {
|
||||
if (typeof data === 'string') {
|
||||
return;
|
||||
}
|
||||
_this.assetext = data;
|
||||
if (_this.status == 0 && _this.asset)
|
||||
showAssetExtInfo(_this.assetext);
|
||||
//_this.maskbgctrl.hide();
|
||||
}, function () {
|
||||
//_this.maskbgctrl.hide();
|
||||
});
|
||||
}
|
||||
|
||||
function canAddReading() {
|
||||
if (!_this.asset)
|
||||
return false;
|
||||
if (_this.asset.ShareStatus == 2)
|
||||
return false;
|
||||
if (!_this.asset.TelematicsEnabled)
|
||||
return true;
|
||||
else {
|
||||
if (_this.asset.OnRoad)
|
||||
return _this.asset.Odometer && (_this.asset.Odometer.IsEmpty ||
|
||||
_this.asset.Odometer.DataSource.toLowerCase() == "calamp" ||
|
||||
_this.asset.Odometer.DataSource.toLowerCase() == "pedigree");
|
||||
|
||||
else
|
||||
return _this.asset.EngineHours && (_this.asset.EngineHours.IsEmpty ||
|
||||
_this.asset.EngineHours.DataSource.toLowerCase() == "calamp" ||
|
||||
_this.asset.EngineHours.DataSource.toLowerCase() == "pedigree");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function openAddDialog() {
|
||||
if (_this.asset.OnRoad) {
|
||||
openAddOdometer(_this.asset);
|
||||
}
|
||||
else {
|
||||
openAddEnginHours(_this.asset, _this.companyid);
|
||||
}
|
||||
}
|
||||
|
||||
function openInspectionReport() {
|
||||
window.open("inspection/report.aspx?rid=" + _this.assetext.InspectReportItem.Id, "_blank");
|
||||
}
|
||||
|
||||
function showSpeedChart(id, speed, postspeed, units, speedtext) {
|
||||
var max = Math.max(speed, postspeed);
|
||||
max = (parseInt(max / 25) + 1) * 25;
|
||||
if (postspeed <= 0)
|
||||
postspeed = max;
|
||||
// 基于准备好的dom,初始化echarts实例
|
||||
var dom = document.getElementById(id);
|
||||
if (!dom)
|
||||
return;
|
||||
var myChart = echarts.init(dom);
|
||||
|
||||
option = {
|
||||
tooltip: {
|
||||
formatter: '{c} {b}'
|
||||
},
|
||||
toolbox: {
|
||||
},
|
||||
//backgroundColor: 'black',
|
||||
series: [
|
||||
{
|
||||
name: units,
|
||||
type: 'gauge',
|
||||
max: max,
|
||||
detail: {
|
||||
//formatter: '{value}',
|
||||
formatter: function (value) {
|
||||
var v = value + " " + units
|
||||
if (speedtext != "")
|
||||
v += "\r\n\r\n" + speedtext
|
||||
return v;
|
||||
},
|
||||
offsetCenter: speedtext != "" ? ["0", "60%"] : ["0", "40%"],
|
||||
fontSize: 12,
|
||||
color: speedtext != "" ? "black" : "auto"
|
||||
},
|
||||
data: [{ value: speed.toFixed(0)/*, name: units*/ }],
|
||||
radius: "98%",
|
||||
axisLine: {
|
||||
show: true,
|
||||
lineStyle: {
|
||||
width: 12,
|
||||
//color: [[postspeed / max, '#91c7ae'], [1, '#c23531']]
|
||||
color: [[postspeed / max, '#91c7ae'], [1, '#ff0000']]
|
||||
}
|
||||
},
|
||||
splitLine: {
|
||||
show: true,
|
||||
length: 12
|
||||
},
|
||||
axisTick: {
|
||||
splitNumber: 2
|
||||
},
|
||||
axisLabel: {
|
||||
show: true,
|
||||
fontSize: 10,
|
||||
//fontWeight: "bold",
|
||||
distance: 3,
|
||||
formatter: function (value) {
|
||||
return value.toFixed(0);
|
||||
},
|
||||
},
|
||||
title: {
|
||||
fontSize: 11,
|
||||
offsetCenter: ["0", -15]
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
||||
myChart.setOption(option, true);
|
||||
}
|
||||
|
||||
function showFuelLevelChart1(id, height, value) {
|
||||
// 基于准备好的dom,初始化echarts实例
|
||||
var p = $("#" + id);
|
||||
|
||||
p.append($("<div></div>").text("Fuel"));
|
||||
var bar = $("<div></div>").css("height", height).css("border", "2px #0079c1 solid").css("position", "relative");
|
||||
p.append(bar);
|
||||
|
||||
var topbar = $("<div></div>").css("height", height * (1 - value / 100));
|
||||
bar.append(topbar);
|
||||
var bottombar = $("<div></div>").css("height", height * (value / 100));
|
||||
bar.append(bottombar);
|
||||
if (value > 40)
|
||||
bottombar.css("background-color", "#91c7ae");
|
||||
else if (value > 25)
|
||||
bottombar.css("background-color", "#ffc000");
|
||||
else
|
||||
bottombar.css("background-color", "#ff0000");
|
||||
|
||||
for (var i = 0; i < 10; i++) {
|
||||
var cell = $("<div></div>").css("height", height / 10).css("border-bottom", "1px #0079c1 solid")
|
||||
.css("width", "100%").css("position", "absolute").css("top", i * height / 10);
|
||||
bar.append(cell);
|
||||
}
|
||||
p.append($("<div></div>").text(value + "%"));
|
||||
}
|
||||
|
||||
function showFuelLevelChart(id, value) {
|
||||
// 基于准备好的dom,初始化echarts实例
|
||||
var myChart = echarts.init(document.getElementById(id));
|
||||
|
||||
option = {
|
||||
tooltip: {
|
||||
formatter: '{b} : {c}%'
|
||||
},
|
||||
toolbox: {
|
||||
//feature: {
|
||||
// restore: {},
|
||||
// saveAsImage: {}
|
||||
//}
|
||||
},
|
||||
series: [
|
||||
{
|
||||
name: 'Fuel level',
|
||||
type: 'gauge',
|
||||
detail: {
|
||||
formatter: '{value}',
|
||||
fontSize: 15
|
||||
},
|
||||
data: [{ value: value.toFixed(0), name: 'Fuel level' }],
|
||||
radius: "98%",
|
||||
axisLine: {
|
||||
show: true,
|
||||
lineStyle: {
|
||||
width: 12,
|
||||
//color: [[0.2, '#91c7ae'], [0.8, '#63869e'], [1, '#c23531']] default
|
||||
color: [[0.2, '#ff0000'], [0.4, '#ffc000'], [1, '#91c7ae']]
|
||||
}
|
||||
},
|
||||
splitLine: {
|
||||
show: true,
|
||||
length: 12
|
||||
},
|
||||
axisLabel: {
|
||||
show: true,
|
||||
fontSize: 10,
|
||||
distance: 3
|
||||
},
|
||||
title: {
|
||||
fontSize: 11,
|
||||
offsetCenter: ["0", -15]
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
||||
myChart.setOption(option, true);
|
||||
|
||||
//setInterval(function () {
|
||||
// option.series[0].data[0].value = (Math.random() * 100).toFixed(2) - 0;
|
||||
// myChart.setOption(option, true);
|
||||
//}, 2000);
|
||||
}
|
||||
|
||||
this.setInfowindowScrollTop = function (top) {
|
||||
infowindowScrollTop = top;
|
||||
}
|
||||
|
||||
function srcollInfowindow() {
|
||||
var infowindow = p.parent(".contentPane");
|
||||
if (infowindow.length > 0) {
|
||||
infowindow.unbind();
|
||||
infowindow.scrollTop(infowindowScrollTop);
|
||||
infowindow.scroll(function () {
|
||||
infowindowScrollTop = infowindow.scrollTop();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
115
Site/js/compass.js
Normal file
115
Site/js/compass.js
Normal file
@ -0,0 +1,115 @@
|
||||
var $compass = function (parent, option) {
|
||||
if (typeof parent === 'string') {
|
||||
parent = $(parent);
|
||||
}
|
||||
this.parent = parent;
|
||||
this.option = option;
|
||||
};
|
||||
|
||||
(function () {
|
||||
var __proto = $compass.prototype;
|
||||
|
||||
var $defcolors = {
|
||||
line: '#8cc8ad',
|
||||
pointer: '#cc3735',
|
||||
background: null
|
||||
};
|
||||
var $widths = {
|
||||
line: 10,
|
||||
circle: 10
|
||||
};
|
||||
var $vars = {
|
||||
radius: 50,
|
||||
font: 'Verdana',
|
||||
fontSize: 14
|
||||
};
|
||||
|
||||
function round(num) { return (num + 0.5) << 0; }
|
||||
function radians(degress) { return degress * Math.PI / 180; }
|
||||
|
||||
__proto.draw = function (value) {
|
||||
var r = this.option.radius || $vars.radius;
|
||||
var line = this.option.lineWidth || $widths.line;
|
||||
var canvas = $('<canvas></canvas>');
|
||||
var size = (r + line) * 2;
|
||||
canvas.css({
|
||||
'width': size,
|
||||
'height': size
|
||||
}).appendTo(this.parent.empty());
|
||||
|
||||
try {
|
||||
var ctx = canvas[0].getContext('2d');
|
||||
canvas[0].width = size;
|
||||
canvas[0].height = size;
|
||||
this.startDraw(ctx, size, value);
|
||||
} catch (e) {
|
||||
console.error('failed when init context: ' + e);
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
__proto.startDraw = function (ctx, size, value) {
|
||||
var background = this.option.background || $defcolors.background;
|
||||
if (background != null) {
|
||||
ctx.fillStyle = background;
|
||||
ctx.fillRect(0, 0, size, size);
|
||||
}
|
||||
ctx.textAlign = 'center';
|
||||
ctx.textBaseline = 'middle';
|
||||
|
||||
var lineColor = this.option.lineColor || $defcolors.line;
|
||||
var lineWidth = this.option.lineWidth || $widths.line;
|
||||
var radius = this.option.radius || $vars.radius;
|
||||
var pos = size / 2;
|
||||
ctx.translate(pos, pos);
|
||||
ctx.strokeStyle = lineColor;
|
||||
ctx.lineWidth = lineWidth;
|
||||
ctx.beginPath();
|
||||
ctx.arc(0, 0, radius, 0, radians(360), false);
|
||||
ctx.stroke();
|
||||
|
||||
if (background != null) {
|
||||
ctx.fillStyle = background;
|
||||
} else {
|
||||
ctx.fillStyle = '#fff';
|
||||
}
|
||||
var drawSegment = function () {
|
||||
ctx.beginPath();
|
||||
ctx.fillRect(radius - lineWidth / 2, -1, lineWidth, 2);
|
||||
ctx.rotate(radians(9));
|
||||
for (var i = 0; i < 9; i++) {
|
||||
ctx.beginPath();
|
||||
ctx.fillRect(radius - lineWidth / 6, 0, lineWidth * 2 / 3, 1);
|
||||
ctx.rotate(radians(9));
|
||||
}
|
||||
};
|
||||
for (var i = 0; i < 4; i++) {
|
||||
drawSegment();
|
||||
}
|
||||
|
||||
var font = 'bold ' + (this.option.fontSize || $vars.fontSize) + 'px ' + (this.option.font || $vars.font);
|
||||
ctx.fillStyle = '#000';
|
||||
ctx.font = font;
|
||||
ctx.fillText('E', radius - lineWidth - 4, 0);
|
||||
ctx.fillText('S', 0, radius - lineWidth - 4);
|
||||
ctx.fillText('W', lineWidth + 6 - radius, 0);
|
||||
ctx.fillText('N', 0, lineWidth + 6 - radius);
|
||||
|
||||
// value
|
||||
var rc = (this.option.circleWidth || $widths.circle) / 2;
|
||||
ctx.rotate(radians(value - 90));
|
||||
ctx.save();
|
||||
ctx.fillStyle = this.option.pointerColor || $defcolors.pointer;
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(0, -rc);
|
||||
ctx.lineTo(radius > 20 ? (radius - 20) : 1, 0);
|
||||
ctx.lineTo(0, rc);
|
||||
ctx.fill();
|
||||
ctx.restore();
|
||||
|
||||
ctx.fillStyle = lineColor;
|
||||
ctx.beginPath();
|
||||
ctx.arc(0, 0, rc, 0, radians(360), false);
|
||||
ctx.fill();
|
||||
};
|
||||
})();
|
1
Site/js/components/css/datagrid.css
Normal file
1
Site/js/components/css/datagrid.css
Normal file
File diff suppressed because one or more lines are too long
2
Site/js/components/css/design-grid.min.css
vendored
Normal file
2
Site/js/components/css/design-grid.min.css
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
.d-grid{border:1px solid #a2adb8;position:relative;font-size:.75rem;font-family:Tahoma,Geneva,Verdana,sans-serif;overflow:hidden}.d-grid .d-grid-table-header{width:100%;margin:0;padding:0;border:none;border-collapse:collapse;border-spacing:0;table-layout:fixed;position:relative;border-bottom:1px solid #bababa}.d-grid .d-grid-table-header th{margin:0;padding:0;word-wrap:break-word;white-space:normal}.d-grid .d-grid-table-header th div{overflow:hidden;line-height:18px}.d-grid .d-grid-header{overflow:hidden;background-color:#e0e0e0;white-space:nowrap}.d-grid .d-grid-header .d-column-header{-moz-user-select:none;-webkit-user-select:none;-ms-user-select:none;-khtml-user-select:none;user-select:none;cursor:default;border-right:1px solid #bababa;font-weight:400;position:relative}.d-grid .d-grid-header .d-column-header:first-child{width:30px;min-width:30px;max-width:30px}.d-grid .d-grid-header .d-column-selected{background-color:#ccc}.d-grid .d-grid-header .d-column-header-text{margin:4px;box-sizing:border-box}.d-grid .d-grid-header .d-column-header-text>span>input{margin-left:0;margin-right:4px}.d-grid .d-grid-header .d-column-header-split{position:absolute;height:100%;top:0;right:-4px;width:8px;z-index:1;cursor:ew-resize}.d-grid .d-grid-body{width:100%;overflow:auto;-webkit-overflow-scrolling:touch;position:absolute;top:27px;bottom:0}.d-grid .d-grid-body .d-grid-body-content{position:absolute;min-width:100%;table-layout:fixed;border-collapse:collapse}.d-grid .d-grid-body .d-grid-row{white-space:nowrap;background-color:#fff;border-bottom:1px solid #cacaca;min-width:100%}.d-grid .d-grid-body .d-grid-row:nth-child(2n){background-color:#f4f4f4}.d-grid .d-grid-body .d-grid-row:hover,.d-grid .d-grid-body .d-grid-row:hover>td>input[type=text]{background-color:#f0f0f0}.d-grid .d-grid-body .d-grid-row.d-grid-row-selected{background-color:#e6e6e6}.d-grid .d-grid-body .d-grid-row.d-grid-row-selected>td:first-child>div{background-color:#ccc}.d-grid .d-grid-body .d-grid-row.d-grid-row-selected>td>input[type=text]{background-color:#e6e6e6}.d-grid .d-grid-body .d-grid-row.d-grid-row-selected .d-grid-cell-selected,.d-grid .d-grid-body .d-grid-row.d-grid-row-selected .d-grid-cell-selected>input[type=text]{background-color:#fff}.d-grid .d-grid-body .d-grid-row .d-grid-cell-selected,.d-grid .d-grid-body .d-grid-row .d-grid-cell-selected>input[type=text]{background-color:#e6e6e6}.d-grid .d-grid-body .d-grid-row>td{border-right:1px solid #cacaca;overflow:hidden;text-overflow:ellipsis;margin:0;padding:0}.d-grid .d-grid-body .d-grid-row>td:first-child{-moz-user-select:none;-webkit-user-select:none;-ms-user-select:none;-khtml-user-select:none;user-select:none;cursor:default;text-align:center;position:relative;width:30px;min-width:30px;max-width:30px}.d-grid .d-grid-body .d-grid-row>td:first-child>div{background-color:#e0e0e0}.d-grid .d-grid-body .d-grid-row>td:first-child .d-row-header-split{position:absolute;width:100%;left:0;bottom:0;height:6px;z-index:1;cursor:ns-resize}.d-grid .d-grid-body .d-grid-row>td:last-child{border-right:none}.d-grid .d-grid-body .d-grid-row>td>div{height:inherit;box-sizing:border-box}.d-grid .d-grid-body .d-grid-row>td>div>div{height:inherit;box-sizing:border-box;overflow:hidden;position:relative}.d-grid .d-grid-body .d-grid-row>td>div>div>input[type=text]{padding:0 4px;vertical-align:top;border:none;height:100%;width:100%;box-sizing:border-box}.d-grid .d-grid-body .d-grid-row>td>div>div>input[type=text]::-ms-clear,.d-grid .d-grid-body .d-grid-row>td>div>div>input[type=text]::-ms-reveal{display:none}.d-grid .d-grid-body .d-grid-row>td>div>div>input[type=text].readonly-input{color:gray;background-color:#ebebe4}.d-grid .d-grid-body .d-grid-row>td>div>div>.fi-multilangs{position:absolute;height:14px;top:50%;right:4px;margin-top:-8px;font-size:14px;font-weight:300;cursor:pointer}.d-grid .d-grid-body .d-grid-row>td>div>div>.fi-multilangs:before{content:"\F022"}
|
||||
/*# sourceMappingURL=design-grid.min.css.map*/
|
1
Site/js/components/css/design-grid.min.css.map
Normal file
1
Site/js/components/css/design-grid.min.css.map
Normal file
File diff suppressed because one or more lines are too long
1
Site/js/components/css/entrygrid.css
Normal file
1
Site/js/components/css/entrygrid.css
Normal file
File diff suppressed because one or more lines are too long
1
Site/js/components/css/gridview.css
Normal file
1
Site/js/components/css/gridview.css
Normal file
File diff suppressed because one or more lines are too long
2
Site/js/components/css/modal.css
Normal file
2
Site/js/components/css/modal.css
Normal file
File diff suppressed because one or more lines are too long
1
Site/js/components/css/modal.css.map
Normal file
1
Site/js/components/css/modal.css.map
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"sources":["webpack:///./src/components/modal/modal.css"],"names":[],"mappings":"AAAA,iBACI,eAEA,MACA,OACA,WACA,YACA,gCACA,cACA,2BAA6B,CAGjC,oBACI,mBACA,qBAAuB,CAG3B,sBACI,YACA,cACA,eACA,sBACA,kBACA,qCACA,wBACA,sCAA0C,CAG9C,mBACI,kBACA,mBACA,iBACA,+BAAiC,CAErC,sBACI,aAEA,WACA,SACA,gBACA,gBAAkB,CAEtB,4CACI,+CACA,eACA,YACA,YACA,UAAY,CAGhB,iBACI,iBACA,eAAiB,CAErB,uCACI,YACA,WACA,WACA,kBACA,qBACA,2BAA6B,CAEjC,mDACI,8CAAiD,CAErD,6CACI,8CAA2C,CAE/C,gDACI,8CAA8C,CAElD,+CACI,8CAA6C,CAGjD,mBACI,aACA,mBACA,yBACA,wBAGA,aAAe,CAEnB,yBACI,kBAAoB,CAGxB,2BACI,YACA,eAAiB,CAgBrB,2CACI,SAAW,CAGf,uFAEI,6BACA,oBAAsB,CACzB","file":"css/modal.css?77e42eace3ddaf9279a0d03b4a25a70b","sourcesContent":[".modal-form-mask {\r\n position: fixed;\r\n /*z-index: 9998;*/\r\n top: 0;\r\n left: 0;\r\n width: 100%;\r\n height: 100%;\r\n background-color: rgba(0, 0, 0, .5);\r\n display: table;\r\n transition: opacity .2s ease;\r\n}\r\n\r\n.modal-form-wrapper {\r\n display: table-cell;\r\n vertical-align: middle;\r\n}\r\n\r\n.modal-form-container {\r\n width: 400px;\r\n margin: 0px auto;\r\n padding: 0 10px;\r\n background-color: #fff;\r\n border-radius: 2px;\r\n box-shadow: 0 2px 8px rgba(0, 0, 0, .33);\r\n transition: all .3s ease;\r\n font-family: Helvetica, Arial, sans-serif;\r\n}\r\n\r\n.modal-form-header {\r\n padding: 12px 10px;\r\n padding-bottom: 6px;\r\n line-height: 24px;\r\n border-bottom: 1px solid #e6e6e6;\r\n}\r\n.modal-form-header h3 {\r\n margin-top: 0;\r\n /*color: #42b983;*/\r\n color: #000;\r\n margin: 0;\r\n font-size: 1.2em;\r\n line-height: 24px;\r\n}\r\n.modal-form-header .modal-form-close-button {\r\n background-image: url('./assets/close.png');\r\n cursor: pointer;\r\n float: right;\r\n height: 24px;\r\n width: 24px;\r\n}\r\n\r\n.modal-form-body {\r\n margin: 20px 10px;\r\n min-height: 60px;\r\n}\r\n.modal-form-body .modal-form-body-icon {\r\n height: 64px;\r\n width: 64px;\r\n float: left;\r\n margin-right: 20px;\r\n background-size: 64px;\r\n background-repeat: no-repeat;\r\n}\r\n.modal-form-body .modal-form-body-icon.information {\r\n background-image: url('./assets/information.png')\r\n}\r\n.modal-form-body .modal-form-body-icon.error {\r\n background-image: url('./assets/error.png')\r\n}\r\n.modal-form-body .modal-form-body-icon.question {\r\n background-image: url('./assets/question.png')\r\n}\r\n.modal-form-body .modal-form-body-icon.warning {\r\n background-image: url('./assets/warning.png')\r\n}\r\n\r\n.modal-form-footer {\r\n display: flex;\r\n align-items: center;\r\n justify-content: flex-end;\r\n padding: 4px 10px 16px 0;\r\n}\r\n.modal-form-footer {\r\n height: 26px\\0;\r\n}\r\n.modal-form-footer::after {\r\n box-sizing: inherit;\r\n}\r\n\r\n.modal-form-default-button {\r\n float: right;\r\n margin-left: 8px;\r\n}\r\n\r\n/*\r\n * The following styles are auto-applied to elements with\r\n * transition=\"modal\" when their visibility is toggled\r\n * by Vue.js.\r\n *\r\n * You can easily play with the modal transition by editing\r\n * these styles.\r\n */\r\n\r\n.modal-form-enter {\r\n opacity: 0;\r\n}\r\n\r\n.modal-form-leave-active {\r\n opacity: 0;\r\n}\r\n\r\n.modal-form-enter .modal-form-container,\r\n.modal-form-leave-active .modal-form-container {\r\n -webkit-transform: scale(1.1);\r\n transform: scale(1.1);\r\n}\r\n\n\n\n// WEBPACK FOOTER //\n// ./src/components/modal/modal.css"],"sourceRoot":""}
|
68
Site/js/components/css/override.css
Normal file
68
Site/js/components/css/override.css
Normal file
@ -0,0 +1,68 @@
|
||||
label {
|
||||
margin-bottom: 0.1rem;
|
||||
}
|
||||
|
||||
.btn {
|
||||
padding: .25rem .5rem;
|
||||
font-size: .875rem;
|
||||
border-radius: .2rem
|
||||
}
|
||||
|
||||
.btn+.dropdown-toggle-split {
|
||||
padding-right: .375rem;
|
||||
padding-left: .375rem
|
||||
}
|
||||
|
||||
.form-control {
|
||||
font-size: .875rem;
|
||||
padding: .25rem .45rem;
|
||||
display: inline-block;
|
||||
display: initial;
|
||||
}
|
||||
|
||||
.data-grid {
|
||||
border: none;
|
||||
border-top: 1px solid #a0a0a0;
|
||||
}
|
||||
.dialog .data-grid {
|
||||
box-sizing: border-box;
|
||||
height: 100%;
|
||||
}
|
||||
.data-grid .data-grid-body-content,
|
||||
.data-grid .data-grid-total table,
|
||||
.data-grid .data-grid-hover-holder,
|
||||
.data-grid .data-grid-body .data-grid-row .fi-input-wrapper > input[type="text"],
|
||||
.data-grid .data-grid-body .data-grid-row .data-select > select {
|
||||
font-size: 11px;
|
||||
font-family: Verdana, 'PingFang SC', 'Microsoft YaHei UI';
|
||||
}
|
||||
.data-grid .data-grid-table-header {
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.data-grid .data-grid-body .data-grid-row .alert-icon {
|
||||
background-position: center center;
|
||||
background-repeat: no-repeat;
|
||||
width: 16px;
|
||||
height: 26px;
|
||||
display: block;
|
||||
margin: 0 auto;
|
||||
cursor: pointer;
|
||||
transition: ease-in-out .2s;
|
||||
}
|
||||
.data-grid .data-grid-body .data-grid-row .alert-lock-check {
|
||||
background-image: url('../../../../image/lock_check.png');
|
||||
}
|
||||
.data-grid .data-grid-body .data-grid-row .alert-lock-normal {
|
||||
background-image: url('../../../../image/lock_normal.png');
|
||||
}
|
||||
.data-grid .data-grid-body .data-grid-row .alert-lock-check:hover,
|
||||
.data-grid .data-grid-body .data-grid-row .alert-lock-normal:hover {
|
||||
background-image: url('../../../../image/lock_hover.png');
|
||||
}
|
||||
.data-grid .data-grid-body .data-grid-row .alert-delete {
|
||||
background-image: url('../../../../image/del_normal.png');
|
||||
}
|
||||
.data-grid .data-grid-body .data-grid-row .alert-delete:hover {
|
||||
background-image: url('../../../../image/del_hover.png');
|
||||
}
|
2
Site/js/components/css/vue-ctrls.css
Normal file
2
Site/js/components/css/vue-ctrls.css
Normal file
@ -0,0 +1,2 @@
|
||||
div[data-v-9fe03e78]{height:24px;border-bottom:1px solid #a0a0a0}.fi-input-wrapper[data-v-9fe03e78]{width:30%;position:relative;display:inline-block}.caption[data-v-9fe03e78]{height:24px;width:100%;padding-right:22px;box-sizing:border-box}.fi-multilangs[data-v-9fe03e78]{position:absolute;height:14px;top:50%;right:4px;margin-top:-8px;font-size:14px;font-weight:300;cursor:pointer}.fi-multilangs[data-v-9fe03e78]:before{content:"\F022"}.type[data-v-9fe03e78]{width:30%;border-left:1px solid #a0a0a0;border-right:1px solid #a0a0a0}.expr[data-v-9fe03e78]{width:40%}input[data-v-9fe03e78]{text-indent:2px}input[data-v-9fe03e78],select[data-v-9fe03e78]{border:none;height:100%;padding:0;margin:0;vertical-align:top;outline:none}input.readonly[data-v-9fe03e78]{background:#d3d3d3}.selector[data-v-2b1cb026]{display:inline-block;vertical-align:bottom;height:20px;line-height:20px;border:1px solid #aaa;border-radius:2px;position:relative;cursor:default;background-color:#fff}.selector[data-v-2b1cb026]:hover{border-color:#7f7f7f}.color-block[data-v-2b1cb026]{float:left;width:28px;height:100%;box-sizing:border-box;padding:4px 6px}.color-block>div[data-v-2b1cb026]{position:absolute;width:16px;top:4px;bottom:4px}.color-block .color-block-bg[data-v-2b1cb026]{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAMCAMAAABcOc2zAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAAZQTFRF5ubm////MURL2QAAAAJ0Uk5T/wDltzBKAAAAGElEQVR42mJggAJGKGCgiQBtTYcCgAADACcMAGFqutcTAAAAAElFTkSuQmCC)}.color-block .color-block-cell[data-v-2b1cb026]{border:1px solid hsla(0,0%,50%,.2);margin-top:-1px;margin-left:-1px;bottom:3px}.color-label[data-v-2b1cb026]{margin-right:16px}.color-drop[data-v-2b1cb026]{position:absolute;top:50%;right:4px;margin-top:-2px;width:0;height:0;border-top:4px solid #000;border-left:4px solid transparent;border-right:4px solid transparent}.wrapper[data-v-2b1cb026]{position:fixed;left:0;top:0;right:0;bottom:0;z-index:1000}.wrapper-color[data-v-2b1cb026]{margin-top:6px;position:absolute;z-index:1001}
|
||||
/*# sourceMappingURL=vue-ctrls.css.map?654b88473f5b50ce7bb77553ba8b7aa1*/
|
1
Site/js/components/css/vue-ctrls.css.map
Normal file
1
Site/js/components/css/vue-ctrls.css.map
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"sources":["webpack:///./src/components/vue-ctrls/aggregateItem.vue","webpack:///./src/components/vue-ctrls/colorbox.vue"],"names":[],"mappings":"AACA,qBACI,YACA,+BAAiC,CAErC,mCACI,UACA,kBACA,oBAAsB,CAE1B,0BACI,YACA,WACA,mBACA,qBAAuB,CAE3B,gCACI,kBACA,YACA,QACA,UACA,gBACA,eACA,gBACA,cAAgB,CAEpB,uCACI,eAAiB,CAErB,uBACI,UAEA,8BACA,8BAAgC,CAEpC,uBAAyB,SAAW,CAEpC,uBACI,eAAiB,CAErB,+CACI,YACA,YACA,UACA,SACA,mBACA,YAAc,CAElB,gCACI,kBAAsB,CChD1B,2BACI,qBACA,sBACA,YACA,iBACA,sBACA,kBACA,kBACA,eACA,qBAAwB,CAE5B,iCACI,oBAAsB,CAE1B,8BACI,WACA,WACA,YACA,sBACA,eAAiB,CAErB,kCACI,kBACA,WACA,QACA,UAAY,CAEhB,8CACI,8CAA0C,CAE9C,gDACI,mCACA,gBACA,iBACA,UAAY,CAEhB,8BAGI,iBAAmB,CAEvB,6BACI,kBACA,QACA,UACA,gBACA,QACA,SACA,0BACA,kCACA,kCAAoC,CAExC,0BACI,eACA,OACA,MACA,QACA,SACA,YAAc,CAElB,gCACI,eACA,kBACA,YAAc,CACjB","file":"css/vue-ctrls.css?654b88473f5b50ce7bb77553ba8b7aa1","sourcesContent":["\ndiv[data-v-9fe03e78] {\n height: 24px;\n border-bottom: 1px solid #a0a0a0;\n}\n.fi-input-wrapper[data-v-9fe03e78] {\n width: 30%;\n position: relative;\n display: inline-block;\n}\n.caption[data-v-9fe03e78] {\n height: 24px;\n width: 100%;\n padding-right: 22px;\n box-sizing: border-box;\n}\n.fi-multilangs[data-v-9fe03e78] {\n position: absolute;\n height: 14px;\n top: 50%;\n right: 4px;\n margin-top: -8px;\n font-size: 14px;\n font-weight: 300;\n cursor: pointer;\n}\n.fi-multilangs[data-v-9fe03e78]::before {\n content: '\\f022';\n}\n.type[data-v-9fe03e78] {\n width: 30%;\n /*margin-left: -1px;*/\n border-left: 1px solid #a0a0a0;\n border-right: 1px solid #a0a0a0;\n}\n.expr[data-v-9fe03e78] { width: 40%;\n}\ninput[data-v-9fe03e78] {\n text-indent: 2px;\n}\ninput[data-v-9fe03e78], select[data-v-9fe03e78] {\n border: none;\n height: 100%;\n padding: 0;\n margin: 0;\n vertical-align: top;\n outline: none;\n}\ninput.readonly[data-v-9fe03e78] {\n background: lightgray;\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/components/vue-ctrls/aggregateItem.vue","\n.selector[data-v-2b1cb026] {\r\n display: inline-block;\r\n vertical-align: bottom;\r\n height: 20px;\r\n line-height: 20px;\r\n border: 1px solid #aaa;\r\n border-radius: 2px;\r\n position: relative;\r\n cursor: default;\r\n background-color: white;\n}\n.selector[data-v-2b1cb026]:hover {\r\n border-color: #7f7f7f;\n}\n.color-block[data-v-2b1cb026] {\r\n float: left;\r\n width: 28px;\r\n height: 100%;\r\n box-sizing: border-box;\r\n padding: 4px 6px;\n}\n.color-block > div[data-v-2b1cb026] {\r\n position: absolute;\r\n width: 16px;\r\n top: 4px;\r\n bottom: 4px;\n}\n.color-block .color-block-bg[data-v-2b1cb026] {\r\n background-image: url('assets/alpha.png');\n}\n.color-block .color-block-cell[data-v-2b1cb026] {\r\n border: 1px solid rgba(127, 127, 127, 0.2);\r\n margin-top: -1px;\r\n margin-left: -1px;\r\n bottom: 3px;\n}\n.color-label[data-v-2b1cb026] {\r\n /* font-size: 0.875em; */\r\n /* vertical-align: top; */\r\n margin-right: 16px;\n}\n.color-drop[data-v-2b1cb026] {\r\n position: absolute;\r\n top: 50%;\r\n right: 4px;\r\n margin-top: -2px;\r\n width: 0;\r\n height: 0;\r\n border-top: 4px solid #000;\r\n border-left: 4px solid transparent;\r\n border-right: 4px solid transparent;\n}\n.wrapper[data-v-2b1cb026] {\r\n position: fixed;\r\n left: 0;\r\n top: 0;\r\n right: 0;\r\n bottom: 0;\r\n z-index: 1000;\n}\n.wrapper-color[data-v-2b1cb026] {\r\n margin-top: 6px;\r\n position: absolute;\r\n z-index: 1001;\n}\r\n\n\n\n// WEBPACK FOOTER //\n// ./src/components/vue-ctrls/colorbox.vue"],"sourceRoot":""}
|
2
Site/js/components/datagrid.js
Normal file
2
Site/js/components/datagrid.js
Normal file
File diff suppressed because one or more lines are too long
1
Site/js/components/datagrid.js.map
Normal file
1
Site/js/components/datagrid.js.map
Normal file
File diff suppressed because one or more lines are too long
2
Site/js/components/design-grid.min.js
vendored
Normal file
2
Site/js/components/design-grid.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
Site/js/components/design-grid.min.js.map
Normal file
1
Site/js/components/design-grid.min.js.map
Normal file
File diff suppressed because one or more lines are too long
2
Site/js/components/entrygrid.js
Normal file
2
Site/js/components/entrygrid.js
Normal file
File diff suppressed because one or more lines are too long
1
Site/js/components/entrygrid.js.map
Normal file
1
Site/js/components/entrygrid.js.map
Normal file
File diff suppressed because one or more lines are too long
2
Site/js/components/gridview.js
Normal file
2
Site/js/components/gridview.js
Normal file
File diff suppressed because one or more lines are too long
1
Site/js/components/gridview.js.map
Normal file
1
Site/js/components/gridview.js.map
Normal file
File diff suppressed because one or more lines are too long
2
Site/js/components/modal.js
Normal file
2
Site/js/components/modal.js
Normal file
@ -0,0 +1,2 @@
|
||||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("Vue")):"function"==typeof define&&define.amd?define(["Vue"],e):"object"==typeof exports?exports["g5-modal"]=e(require("Vue")):t["g5-modal"]=e(t.Vue)}(this,function(t){return function(t){function e(n){if(o[n])return o[n].exports;var s=o[n]={i:n,l:!1,exports:{}};return t[n].call(s.exports,s,s.exports,e),s.l=!0,s.exports}var o={};return e.m=t,e.c=o,e.i=function(t){return t},e.d=function(t,o,n){e.o(t,o)||Object.defineProperty(t,o,{configurable:!1,enumerable:!0,get:n})},e.n=function(t){var o=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(o,"a",o),o},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="/dist/",e(e.s=16)}({0:function(t,e){t.exports=function(t,e,o,n,s){var r,a=t=t||{},i=typeof t.default;"object"!==i&&"function"!==i||(r=t,a=t.default);var l="function"==typeof a?a.options:a;e&&(l.render=e.render,l.staticRenderFns=e.staticRenderFns),n&&(l._scopeId=n);var c;if(s?(c=function(t){t=t||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext,t||"undefined"==typeof __VUE_SSR_CONTEXT__||(t=__VUE_SSR_CONTEXT__),o&&o.call(this,t),t&&t._registeredComponents&&t._registeredComponents.add(s)},l._ssrRegister=c):o&&(c=o),c){var d=l.functional,u=d?l.render:l.beforeCreate;d?l.render=function(t,e){return c.call(e),u(t,e)}:l.beforeCreate=u?[].concat(u,c):[c]}return{esModule:r,exports:a,options:l}}},10:function(t,e,o){var n=o(0)(o(29),o(54),null,null,null);t.exports=n.exports},14:function(e,o){e.exports=t},16:function(t,e,o){function n(t,e,o,n){var s=n.$mount();return s.message=t,s.header=e,s.icon=o,s.$on("close",function(){s.show=!1,setTimeout(function(){s.$destroy(),document.body.removeChild(s.$el),s=null},0)}),document.body.appendChild(s.$el),s.show=!0,s}var s=o(14),r=o(10),a=o(9),i=s.extend(r),l=s.extend(a);t.exports={vueModal:r,showMessage:function(t,e,o,s){var r=n(t,e,o||"information",new i);null!=s&&r.$on("close",s)},showConfirm:function(t,e,o,s){var r=n(t,e,"question",new l);null==o&&null==s||r.$on("close",function(t){t&&null!=o&&o(),t||null==s||s()})}}},28:function(t,e,o){var n=o(4);o(5);var s=n();s.methods={close:function(t){this.$emit("close",t)}},t.exports=s},29:function(t,e,o){var n=o(4);o(5);var s=n();s.methods={close:function(){this.$emit("close",this)}},t.exports=s},4:function(t,e){var o=1e3;t.exports=function(){return{props:{show:{type:Boolean,default:!1},message:String,header:String,icon:String},data:function(){return{zindex:0}},watch:{show:function(t){t?(o+=1,this.zindex=o):o-=1}},computed:{zindexStyle:function(){return{zIndex:this.zindex}},dialogHeader:function(){return this.header||"Header"}}}}},5:function(t,e){},50:function(t,e){t.exports={render:function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("transition",{attrs:{name:"modal-form"}},[t.show?o("div",{ref:"mask",staticClass:"modal-form-mask",style:t.zindexStyle},[o("div",{staticClass:"modal-form-wrapper"},[o("div",{staticClass:"modal-form-container"},[o("div",{staticClass:"modal-form-header"},[o("em",{staticClass:"modal-form-close-button",on:{click:t.close}}),t._v(" "),t._t("header",[o("h3",[t._v(t._s(t.dialogHeader))])])],2),t._v(" "),o("div",{staticClass:"modal-form-body"},[t._t("default",[t.icon?o("em",{staticClass:"modal-form-body-icon",class:t.icon}):t._e(),t._v(" "),o("span",{staticClass:"modal-form-body-message"},[t._v(t._s(t.message))])])],2),t._v(" "),o("div",{staticClass:"modal-form-footer"},[t._t("footer",[o("button",{staticClass:"modal-form-default-button",on:{click:function(e){t.close(!0)}}},[t._v("Yes")]),t._v(" "),o("button",{staticClass:"modal-form-default-button",on:{click:function(e){t.close(!1)}}},[t._v("No")])])],2)])])]):t._e()])},staticRenderFns:[]}},54:function(t,e){t.exports={render:function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("transition",{attrs:{name:"modal-form"}},[t.show?o("div",{ref:"mask",staticClass:"modal-form-mask",style:t.zindexStyle},[o("div",{staticClass:"modal-form-wrapper"},[o("div",{staticClass:"modal-form-container"},[o("div",{staticClass:"modal-form-header"},[o("em",{staticClass:"modal-form-close-button",on:{click:t.close}}),t._v(" "),t._t("header",[o("h3",[t._v(t._s(t.dialogHeader))])])],2),t._v(" "),o("div",{staticClass:"modal-form-body"},[t._t("default",[t.icon?o("em",{staticClass:"modal-form-body-icon",class:t.icon}):t._e(),t._v(" "),o("span",{staticClass:"modal-form-body-message"},[t._v(t._s(t.message))])])],2),t._v(" "),o("div",{staticClass:"modal-form-footer"},[t._t("footer",[o("button",{staticClass:"btn btn-primary modal-form-default-button",on:{click:t.close}},[t._v("OK")])])],2)])])]):t._e()])},staticRenderFns:[]}},9:function(t,e,o){var n=o(0)(o(28),o(50),null,null,null);t.exports=n.exports}})});
|
||||
//# sourceMappingURL=modal.js.map?82c05412763fe0ccff3b
|
1
Site/js/components/modal.js.map
Normal file
1
Site/js/components/modal.js.map
Normal file
File diff suppressed because one or more lines are too long
2
Site/js/components/vue-ctrls.js
Normal file
2
Site/js/components/vue-ctrls.js
Normal file
File diff suppressed because one or more lines are too long
1
Site/js/components/vue-ctrls.js.map
Normal file
1
Site/js/components/vue-ctrls.js.map
Normal file
File diff suppressed because one or more lines are too long
BIN
Site/js/contextmenu/font/context-menu-icons.eot
Normal file
BIN
Site/js/contextmenu/font/context-menu-icons.eot
Normal file
Binary file not shown.
BIN
Site/js/contextmenu/font/context-menu-icons.ttf
Normal file
BIN
Site/js/contextmenu/font/context-menu-icons.ttf
Normal file
Binary file not shown.
BIN
Site/js/contextmenu/font/context-menu-icons.woff
Normal file
BIN
Site/js/contextmenu/font/context-menu-icons.woff
Normal file
Binary file not shown.
BIN
Site/js/contextmenu/font/context-menu-icons.woff2
Normal file
BIN
Site/js/contextmenu/font/context-menu-icons.woff2
Normal file
Binary file not shown.
16
Site/js/contextmenu/jquery.contextMenu.min.css
vendored
Normal file
16
Site/js/contextmenu/jquery.contextMenu.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
2
Site/js/contextmenu/jquery.contextMenu.min.js
vendored
Normal file
2
Site/js/contextmenu/jquery.contextMenu.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
6
Site/js/contextmenu/jquery.ui.position.min.js
vendored
Normal file
6
Site/js/contextmenu/jquery.ui.position.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
50
Site/js/controls.js
vendored
Normal file
50
Site/js/controls.js
vendored
Normal file
@ -0,0 +1,50 @@
|
||||
/// <reference path="../js/jquery-3.6.0.min.js" />
|
||||
/// <reference path="../js/utility.js" />
|
||||
|
||||
$.fn.tab = function (obj) {
|
||||
obj = obj || {};
|
||||
|
||||
return this.each(function () {
|
||||
var _this = $(this);
|
||||
_this.data('tabparam', obj);
|
||||
|
||||
function switchPage(page) {
|
||||
_this.children('div[data-page]').hide();
|
||||
_this.children('div[data-page="' + page + '"]').show();
|
||||
}
|
||||
|
||||
var titles = _this.children('.tab_header').children('[data-href]');
|
||||
titles.each(function () {
|
||||
var n_li = $(this);
|
||||
if (n_li.attr('data-disabled') != null) {
|
||||
return;
|
||||
}
|
||||
if (_this.data('inited'))
|
||||
n_li.unbind('click');
|
||||
n_li.click(function (e) {
|
||||
var dfor = n_li.attr('data-href');
|
||||
// invoke function
|
||||
function next() {
|
||||
if (typeof obj.onnext === 'function') {
|
||||
obj.onnext(dfor);
|
||||
}
|
||||
titles.removeClass('selected');
|
||||
n_li.addClass('selected');
|
||||
//var dfor = n_li.addClass('selected').attr('data-href');
|
||||
switchPage(dfor);
|
||||
}
|
||||
if (typeof obj.onclick === 'function') {
|
||||
obj.onclick(n_li, next, _this.children('div[data-page="' + dfor + '"]'), dfor);
|
||||
} else {
|
||||
next();
|
||||
}
|
||||
});
|
||||
});
|
||||
//var datafor = titles.removeClass('selected').first().addClass('selected').attr('data-href');
|
||||
// 由默认选中第一页修改为默认选中页面中指定的页,cl,2017/4/20
|
||||
var datafor = _this.children('.tab_header').children('.selected').attr('data-href');
|
||||
switchPage(datafor);
|
||||
|
||||
_this.data('inited', true);
|
||||
});
|
||||
};
|
36
Site/js/cookie.js
Normal file
36
Site/js/cookie.js
Normal file
@ -0,0 +1,36 @@
|
||||
function setCookie(cname, cvalue, exdays) {
|
||||
if (exdays === undefined) {
|
||||
document.cookie = cname + "=" + cvalue + "; path=/" + "; document=" + document.domain;
|
||||
} else {
|
||||
var d = new Date();
|
||||
d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
|
||||
var expires = "expires=" + d.toUTCString();
|
||||
document.cookie = cname + "=" + cvalue + "; " + expires + "; path=/" + "; document=" + document.domain;
|
||||
}
|
||||
}
|
||||
|
||||
function setCookieSeconds(cname, cvalue, seconds) {
|
||||
if (seconds === undefined) {
|
||||
document.cookie = cname + "=" + cvalue + "; path=/" + "; document=" + document.domain;
|
||||
} else {
|
||||
var d = new Date();
|
||||
d.setTime(d.getTime() + (seconds * 1000));
|
||||
var expires = "expires=" + d.toUTCString();
|
||||
document.cookie = cname + "=" + cvalue + "; " + expires + "; path=/" + "; document=" + document.domain;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function getCookie(name) {
|
||||
var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");
|
||||
if (arr = document.cookie.match(reg))
|
||||
return unescape(decodeURI(arr[2]));
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
function SetClientTimeoffset() {
|
||||
var d = new Date();
|
||||
var offset = d.getTimezoneOffset();
|
||||
setCookie("clienttimeoffset", offset, 360);
|
||||
}
|
10
Site/js/datepicker.min.js
vendored
Normal file
10
Site/js/datepicker.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
22
Site/js/echarts.min.js
vendored
Normal file
22
Site/js/echarts.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
278
Site/js/editableselect.js
Normal file
278
Site/js/editableselect.js
Normal file
@ -0,0 +1,278 @@
|
||||
|
||||
if (typeof ($editableselect) != "function") {
|
||||
|
||||
$(document).mousedown(function (e) {
|
||||
var drop = $('#dropdowndiv');
|
||||
if (drop.length > 0) {
|
||||
var editselctrl = drop.parent();
|
||||
var t = $(e.target);
|
||||
if (!t.is(editselctrl)
|
||||
&& !t.parent().is(editselctrl)
|
||||
&& !t.parent().parent().is(editselctrl)
|
||||
&& !t.parent().parent().parent().is(editselctrl))
|
||||
$('#dropdowndiv').remove();
|
||||
}
|
||||
});
|
||||
$(window).resize(function (e) {
|
||||
$('#dropdowndiv').remove();
|
||||
});
|
||||
|
||||
$editableselect = function (parent, maxlength, maxwidth) {
|
||||
this.datasource = undefined;
|
||||
this.valuepath = undefined;
|
||||
this.displaypath = undefined;
|
||||
this.changedhandler = undefined;
|
||||
this.isEnabled = true;
|
||||
this.maxshowncount = 2000;
|
||||
this.maxlength = maxlength > 0 ? maxlength : 50;
|
||||
|
||||
var basectrl = undefined;
|
||||
var inputctrl = undefined;
|
||||
var iconctrl = undefined;
|
||||
var _this = this;
|
||||
|
||||
this.val = function (value) {
|
||||
if (arguments.length === 0)
|
||||
return inputctrl.data("val");
|
||||
else {
|
||||
inputctrl.data("val", value);
|
||||
if (this.datasource) {
|
||||
for (var i = 0, j = 0; i < this.datasource.length; i++) {
|
||||
var obj = this.datasource[i];
|
||||
var v = "";
|
||||
if (this.valuepath)
|
||||
v += obj[this.valuepath];
|
||||
else
|
||||
v += obj;
|
||||
if (v.toLowerCase() == ("" + value).toLowerCase()) {
|
||||
var text = "";
|
||||
if (this.displaypath)
|
||||
text = obj[this.displaypath];
|
||||
else
|
||||
text += obj;
|
||||
inputctrl.val(text);
|
||||
inputctrl.data("obj", obj);
|
||||
return;
|
||||
}
|
||||
}
|
||||
inputctrl.val("");
|
||||
inputctrl.data("obj", null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.text = function (text) {
|
||||
if (arguments.length === 0)
|
||||
return inputctrl.val();
|
||||
else {
|
||||
inputctrl.val(text);
|
||||
if (this.datasource) {
|
||||
for (var i = 0, j = 0; i < this.datasource.length; i++) {
|
||||
var obj = this.datasource[i];
|
||||
var t = "";
|
||||
if (this.displaypath)
|
||||
t += obj[this.displaypath];
|
||||
else
|
||||
t += obj;
|
||||
|
||||
if (t.toLowerCase() == ("" + text).toLowerCase()) {
|
||||
var value = "";
|
||||
if (this.valuepath)
|
||||
value = obj[this.valuepath];
|
||||
else
|
||||
value += obj;
|
||||
inputctrl.data("val", value);
|
||||
inputctrl.data("obj", obj);
|
||||
return;
|
||||
}
|
||||
}
|
||||
inputctrl.data("val", "");
|
||||
inputctrl.data("obj", null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.selecteditem = function () {
|
||||
return inputctrl.data("obj");
|
||||
}
|
||||
this.selectedindex = function () {
|
||||
return _this.datasource.indexOf(inputctrl.data("obj"));
|
||||
}
|
||||
|
||||
this.change = function (func) {
|
||||
this.changedhandler = func;
|
||||
}
|
||||
|
||||
this.tabIndex = function (tabindex) {
|
||||
inputctrl.attr("tabIndex", tabindex);
|
||||
}
|
||||
|
||||
this.setEnable = function (enable) {
|
||||
this.isEnabled = enable;
|
||||
inputctrl.attr("disabled", !enable);
|
||||
}
|
||||
|
||||
this.reload = function () {
|
||||
setTimeout(function () {
|
||||
inputctrl.css("width", parent.width() - 22);
|
||||
});
|
||||
}
|
||||
|
||||
basectrl = $('<div class="editseldiv"></div>');
|
||||
inputctrl = $('<input class="editselinput" autocomplete="off" style="padding-top:0;padding-bottom:0;" />').attr("maxlength", this.maxlength)
|
||||
.css("width", parent.width() - 22)
|
||||
.css("border", "none").css("height", 20)
|
||||
.bind('input propertychange', function () { changeSearchvalue(this); });
|
||||
inputctrl.keydown(onkeydown);
|
||||
iconctrl = $('<div class="dropdownicon"></div>')
|
||||
.css("line-height", "normal").click(iconClick);
|
||||
basectrl.append(inputctrl).append(iconctrl);
|
||||
parent.append(basectrl);
|
||||
|
||||
function onkeydown(e) {
|
||||
if (e.keyCode == 13 || e.keyCode == 38 || e.keyCode == 40) {//Enter Up Down键
|
||||
var drop = $('#dropdowndiv');
|
||||
if (e.keyCode == 13) {
|
||||
if (drop.length > 0) {
|
||||
drop.find("li.itemselected").click();
|
||||
}
|
||||
}
|
||||
else {//Up
|
||||
var selectedIndex = -1;
|
||||
var lis = drop.find("li");
|
||||
lis.each(function () {
|
||||
var li = $(this);
|
||||
if (li.hasClass("itemselected")) {
|
||||
selectedIndex = $(this).attr("index");
|
||||
li.removeClass("itemselected");
|
||||
}
|
||||
});
|
||||
|
||||
if (e.keyCode == 38)
|
||||
selectedIndex--;
|
||||
else if (e.keyCode == 40)
|
||||
selectedIndex++;
|
||||
if (selectedIndex < 0)
|
||||
selectedIndex = lis.length - 1;
|
||||
if (selectedIndex > lis.length - 1)
|
||||
selectedIndex = 0;
|
||||
|
||||
var next = drop.find("li[index=" + selectedIndex + "]");
|
||||
if (next.length > 0) {
|
||||
$(next[0]).addClass("itemselected");
|
||||
var offsetTop = next[0].offsetTop;
|
||||
if (offsetTop >= drop.height() - drop.scrollTop() - 20) {
|
||||
drop.scrollTop(offsetTop - drop.height() + 20);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function iconClick(e) {
|
||||
if (_this.isEnabled) {
|
||||
var drop = $('#dropdowndiv');
|
||||
if (drop.length > 0) {
|
||||
$('#dropdowndiv').remove();
|
||||
}
|
||||
else {
|
||||
createDropdown(_this, undefined);
|
||||
inputctrl.select();
|
||||
inputctrl.focus();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//搜索
|
||||
function changeSearchvalue(obj) {
|
||||
var inp = $(obj);
|
||||
var text = $.trim(inp.val());
|
||||
var matched = false;
|
||||
for (var i = 0, j = 0; i < _this.datasource.length; i++) {
|
||||
var obj = _this.datasource[i];
|
||||
var t = "";
|
||||
if (_this.displaypath)
|
||||
t += obj[_this.displaypath];
|
||||
else
|
||||
t += obj;
|
||||
|
||||
if (t.toLowerCase() == ("" + text).toLowerCase()) {
|
||||
var value = "";
|
||||
if (_this.valuepath)
|
||||
value = obj[_this.valuepath];
|
||||
else
|
||||
value += obj;
|
||||
inp.data("val", value);
|
||||
inputctrl.data("obj", obj);
|
||||
matched = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!matched) {
|
||||
inp.data("val", "");
|
||||
inputctrl.data("obj", null);
|
||||
}
|
||||
|
||||
if (_this.changedhandler)
|
||||
_this.changedhandler();
|
||||
createDropdown(_this, text);
|
||||
}
|
||||
|
||||
function createDropdown(selctrl, searchtext) {
|
||||
$("#dropdowndiv").remove();//移除已创建的下拉框
|
||||
|
||||
var dropdiv = $('<div id="dropdowndiv" class="editseldorp"></div>');
|
||||
dropdiv.css("min-width", basectrl.width());
|
||||
if (maxwidth != undefined)
|
||||
dropdiv.css("max-width", maxwidth);
|
||||
var ul = $('<ul style="padding:0px;list-style:none;margin:0px;"></ul>');
|
||||
|
||||
if (!selctrl.datasource) return;
|
||||
|
||||
if (basectrl.css("position") !== "relative") {
|
||||
dropdiv.css('top', basectrl.position().top + 22);
|
||||
dropdiv.css('left', basectrl.position().left);
|
||||
}
|
||||
|
||||
var index = 0;
|
||||
for (var i = 0, j = 0; i < selctrl.datasource.length && j < selctrl.maxshowncount; i++) {
|
||||
var obj = selctrl.datasource[i];
|
||||
var text = "";
|
||||
if (selctrl.displaypath)
|
||||
text = obj[selctrl.displaypath];
|
||||
else
|
||||
text += obj;
|
||||
|
||||
var value = "";
|
||||
if (selctrl.valuepath)
|
||||
value = obj[selctrl.valuepath];
|
||||
else
|
||||
value += obj;
|
||||
|
||||
if (!searchtext || text.toLowerCase().indexOf(searchtext.toLowerCase()) >= 0) {
|
||||
var item = $('<li class="editselitem"></li>').data("obj", obj).data("val", value).text(text).attr("index", index++)
|
||||
.click(function () { itemClick(this) });
|
||||
ul.append(item);
|
||||
j++;
|
||||
}
|
||||
}
|
||||
ul.appendTo(dropdiv);
|
||||
basectrl.append(dropdiv);
|
||||
}
|
||||
|
||||
//drop选中
|
||||
function itemClick(item) {
|
||||
item = $(item);
|
||||
inputctrl.val(item.text());
|
||||
var oldValue = inputctrl.data("val");
|
||||
var newValue = item.data("val");
|
||||
inputctrl.data("val", newValue);
|
||||
inputctrl.data("obj", item.data("obj"));
|
||||
|
||||
if (_this.changedhandler && newValue != oldValue)
|
||||
_this.changedhandler();
|
||||
|
||||
$('#dropdowndiv').remove();
|
||||
}
|
||||
}
|
||||
}
|
212
Site/js/editmultiselect.js
Normal file
212
Site/js/editmultiselect.js
Normal file
@ -0,0 +1,212 @@
|
||||
|
||||
var ALL_TEXT = "(All)";
|
||||
var paramindex = -1;
|
||||
function editmultiselect(param) {
|
||||
var divcontrol = $('<div class="div_filter"></div>');
|
||||
var seldiv = $('<div class="left dropdown"></div>');
|
||||
var span = $('<span class="text_span"></span>');
|
||||
var spanimg = $('<span class="fa dropdown_button"></span>');
|
||||
var divpanel = $('<div class="div_panel" style="display: none;z-index:10;margin-top:20px;margin-left:-1px;"></div>');
|
||||
divpanel.data("self", divpanel);
|
||||
if (param.width && param.width > 0)
|
||||
divpanel.css('width', param.width);
|
||||
|
||||
$(document).mousedown(function (e) {
|
||||
var t = $(e.target);
|
||||
$('.div_panel').each(function () {
|
||||
if (!t.is(divpanel)
|
||||
&& !t.parent().is(divpanel)
|
||||
&& !t.parent().parent().is(divpanel)
|
||||
&& !t.parent().parent().parent().is(divpanel)) {
|
||||
var v = divpanel.is(":visible");
|
||||
divpanel.hide();
|
||||
if (v && param.oncompleted)
|
||||
param.oncompleted();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
divpanel.completed = function () {
|
||||
if (param.oncompleted)
|
||||
param.oncompleted();
|
||||
}
|
||||
|
||||
var inputctrl;
|
||||
//if (param.allowsearch === true) {
|
||||
var inputdiv = $('<div style="margin:3px;"></div>');
|
||||
divpanel.append(inputdiv);
|
||||
inputctrl = $('<input maxlength="100" style="padding-top:0;padding-bottom:0;width:96%;" />');
|
||||
inputctrl.bind('input propertychange', function () { changeSearchvalue(this); });
|
||||
inputdiv.append(inputctrl);
|
||||
//}
|
||||
|
||||
var ul = $('<ul></ul>');
|
||||
divpanel.append(ul);
|
||||
ul.mousedown(false);
|
||||
seldiv.append(span).append(spanimg).append(divpanel);
|
||||
divcontrol.append(seldiv);
|
||||
|
||||
var ctrlclick = function () {
|
||||
$('.div_panel').each(function (e) {
|
||||
var t = $(this);
|
||||
var v = t.is(":visible");
|
||||
if (!t.is(divpanel)) {
|
||||
t.css('display', 'none');
|
||||
if (v)
|
||||
t.data("self").completed();
|
||||
}
|
||||
});
|
||||
|
||||
var display = divpanel.css('display');
|
||||
if (display == 'none') {
|
||||
divpanel.css({ 'display': 'block' });
|
||||
} else {
|
||||
divpanel.css('display', 'none');
|
||||
}
|
||||
return false;
|
||||
}
|
||||
span.mousedown(ctrlclick);
|
||||
spanimg.mousedown(ctrlclick);
|
||||
|
||||
var itemclick = function (isall, checked) {
|
||||
var chks = ul.find('input');
|
||||
if (isall) {
|
||||
chks.prop('checked', checked);
|
||||
if (checked) {
|
||||
span.attr('title', ALL_TEXT).text(ALL_TEXT);
|
||||
}
|
||||
else {
|
||||
span.attr('title', "").text("");
|
||||
}
|
||||
param.selectedvalue = [];
|
||||
param.selecteditems = [];
|
||||
return;
|
||||
}
|
||||
else {
|
||||
if (chkall)
|
||||
chkall.prop('checked', false);//(ALL)取消选中
|
||||
}
|
||||
|
||||
var texts = [];
|
||||
var paramvalues = [];
|
||||
var paramitems = [];
|
||||
for (var i = 0; i < chks.length; i++) {
|
||||
var c = $(chks[i]);
|
||||
if (c.prop('checked')) {
|
||||
var text = c.next('label').text();
|
||||
if (!text) text = c.data("value");
|
||||
texts.push(text);
|
||||
paramvalues.push(c.data("value"));
|
||||
paramitems.push(c);
|
||||
}
|
||||
}
|
||||
texts = texts.join(', ');
|
||||
span.attr('title', texts).text(texts);
|
||||
param.selectedvalue = paramvalues;
|
||||
param.selecteditems = paramitems;
|
||||
};
|
||||
|
||||
divcontrol.setValues = function (values) {
|
||||
var chks = ul.find('input');
|
||||
|
||||
for (var i = 0; i < chks.length; i++) {
|
||||
var chk = $(chks[i]);
|
||||
if (values.indexOf(chk.data("value")) >= 0)
|
||||
chk.prop('checked', true);
|
||||
else
|
||||
chk.prop('checked', false);
|
||||
}
|
||||
|
||||
var texts = [];
|
||||
var paramvalues = [];
|
||||
var paramitems = [];
|
||||
for (var i = 0; i < chks.length; i++) {
|
||||
var c = $(chks[i]);
|
||||
if (c.prop('checked')) {
|
||||
var text = c.next('label').text();
|
||||
if (!text) text = c.data("value");
|
||||
texts.push(text);
|
||||
paramvalues.push(c.data("value"));
|
||||
paramitems.push(c);
|
||||
}
|
||||
}
|
||||
texts = texts.join(', ');
|
||||
span.attr('title', texts).text(texts);
|
||||
param.selectedvalue = paramvalues;
|
||||
param.selecteditems = paramitems;
|
||||
}
|
||||
|
||||
var chkall = undefined;
|
||||
var showItems = function (searchtext) {
|
||||
ul.empty();
|
||||
if (param.allowall !== false) {
|
||||
var liall = $('<li></li>');
|
||||
chkall = $('<input type="checkbox" style="width:16px;"/>');
|
||||
chkall.change(function () {//全选
|
||||
itemclick(true, $(this).prop('checked'));
|
||||
});
|
||||
liall.append(chkall);
|
||||
liall.append($('<label for="chkall"></label>').text(ALL_TEXT));
|
||||
ul.append(liall);
|
||||
}
|
||||
|
||||
if (param && param.items) {
|
||||
var texts = [];
|
||||
for (var s = 0; s < param.items.length; s++) {
|
||||
var item = param.items[s];
|
||||
var value = item[param.valuepath || "Key"];
|
||||
var txt = item[param.textpath || "Value"];
|
||||
var li = $('<li></li>').data("item", item);
|
||||
var chk = $('<input type="checkbox" style="width:16px;"/>').data("value", value).attr("id", "chkp" + ++paramindex);
|
||||
if (item.sublevel > 0)
|
||||
chk.css("margin-left", "" + (20 * item.sublevel) + "px");
|
||||
chk.change(function () {
|
||||
itemclick(false, $(this).prop('checked'));
|
||||
});
|
||||
li.append(chk);
|
||||
var lbl = $('<label for=' + ("chkp" + paramindex) + '></label>').text(txt)
|
||||
li.append(lbl);
|
||||
ul.append(li);
|
||||
}
|
||||
texts = texts.join(', ');
|
||||
span.attr('title', texts).text(texts);
|
||||
|
||||
divcontrol.setValues(param.selectedvalue);
|
||||
}
|
||||
}
|
||||
|
||||
var filterItems = function (searchtext) {
|
||||
if (!searchtext)
|
||||
searchtext = "";
|
||||
searchtext = $.trim(searchtext);
|
||||
ul.find("li").each(function () {
|
||||
var li = $(this);
|
||||
var item = li.data("item");
|
||||
if (item) {
|
||||
var txt = item[param.textpath || "Value"];
|
||||
if (searchtext != "" && txt.toLowerCase().indexOf(searchtext.toLowerCase()) < 0)
|
||||
li.hide();
|
||||
else
|
||||
li.show();
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
//搜索
|
||||
function changeSearchvalue(obj) {
|
||||
var inp = $(obj);
|
||||
var text = inp.val();
|
||||
filterItems(text);
|
||||
}
|
||||
|
||||
divcontrol.reset = function () {
|
||||
if (inputctrl)
|
||||
inputctrl.val("");
|
||||
showItems();
|
||||
itemclick(true, false);
|
||||
}
|
||||
|
||||
showItems();
|
||||
|
||||
return divcontrol;
|
||||
}
|
990
Site/js/favorite.js
Normal file
990
Site/js/favorite.js
Normal file
@ -0,0 +1,990 @@
|
||||
|
||||
var userfavorates = [];
|
||||
var navigate;
|
||||
|
||||
$(function () {
|
||||
$('#dialog_favorite').dialog(function () {
|
||||
$('#mask_bg').hide();
|
||||
$('.maskbg').hide();
|
||||
});
|
||||
});
|
||||
|
||||
function refreshFavorites() {
|
||||
getFavoriteItems(onInitFavorites);
|
||||
}
|
||||
|
||||
function setFavoriteDisplay(isshow, mouduleid, name, type) {
|
||||
//$('#button_fav').removeClass('fav').removeClass('nofav').addClass('unfav');
|
||||
if (isshow)
|
||||
$('#button_fav').show();
|
||||
else
|
||||
$('#button_fav').hide();
|
||||
if (mouduleid)
|
||||
navigate = setAppMoudule(mouduleid, name, type);
|
||||
|
||||
//if (!navigate)
|
||||
// $('#button_fav').removeClass('fav').removeClass('unfav').addClass('nofav');
|
||||
|
||||
getFavoriteItems();
|
||||
}
|
||||
|
||||
function getFavoriteItems(oninit) {
|
||||
_network.mainpagequery("GetFavoriteItems", "", function (data) {
|
||||
if (typeof data === 'string') {
|
||||
_dialog.showAlert(data, GetTextByKey("P_FAV_GETFAVORITES", 'Get Favorites'));
|
||||
} else {
|
||||
userfavorates = data;
|
||||
if (navigate)
|
||||
setFavorateStyle();
|
||||
if (oninit)
|
||||
oninit();
|
||||
showFavoritesGridList(userfavorates);
|
||||
if (typeof showChartFavorite === "function")
|
||||
showChartFavorite(isUserFavorate(chartiid));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function setFavorateStyle(id, name) {
|
||||
if (id) {
|
||||
var navid = id.substring(1);
|
||||
if (navid === "nav_manageharshdriving") {
|
||||
navid = "600";
|
||||
}
|
||||
navigate = setNavigate(navid, name);
|
||||
}
|
||||
$('#divfavadd').hide();
|
||||
$('#divfav').hide();
|
||||
//$('#button_fav').removeClass('fav').removeClass('nofav').addClass('unfav');
|
||||
var isfav = false;
|
||||
if (userfavorates && navigate) {
|
||||
for (var i = 0; i < userfavorates.length; i++) {
|
||||
if (userfavorates[i].ID === navigate.ID) {
|
||||
//$('#button_fav').addClass('fav').removeClass('unfav').removeClass('nofav');
|
||||
$('#divfav').show();
|
||||
isfav = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!isfav)
|
||||
$('#divfavadd').show();
|
||||
}
|
||||
}
|
||||
|
||||
function isUserFavorate(id) {
|
||||
if (userfavorates && navigate) {
|
||||
for (var i = 0; i < userfavorates.length; i++) {
|
||||
if (userfavorates[i].ID === id) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function setFavorate(isdelete) {
|
||||
if (!navigate)
|
||||
return;
|
||||
if (navigate.ID === "nav_manageharshdriving")
|
||||
navigate = setNavigate("600", "OTR Config");
|
||||
|
||||
if (isdelete) {
|
||||
isdelete = true;
|
||||
$('#divfavadd').show();
|
||||
$('#divfav').hide();
|
||||
}
|
||||
else {
|
||||
$('#divfavadd').hide();
|
||||
$('#divfav').show();
|
||||
}
|
||||
|
||||
setFavoritesData(isdelete, navigate);
|
||||
}
|
||||
|
||||
function setFavoritesData(isdelete, nav) {
|
||||
if (isdelete) {
|
||||
if (userfavorates) {
|
||||
for (var i = 0; i < userfavorates.length; i++) {
|
||||
if (userfavorates[i].ID === nav.ID) {
|
||||
userfavorates.splice(i, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
userfavorates.push(nav);
|
||||
|
||||
saveFavorites(userfavorates);
|
||||
}
|
||||
|
||||
function saveFavorites(data, issort) {
|
||||
_network.mainpagequery("SetFavorites", JSON.stringify(data), function (data) {
|
||||
if (data !== 'OK') {
|
||||
_dialog.showAlert(data, GetTextByKey("P_FAV_SETFAVORITES", 'Set Favorites'));
|
||||
}
|
||||
else {
|
||||
if (issort) {
|
||||
$('#dialog_favorite').hideDialog();
|
||||
$('#mask_bg').hide();
|
||||
}
|
||||
refreshFavorites();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function onInitFavorites() {
|
||||
var ids = ['100', '250', '500', '550', '650', '700', '600'];
|
||||
var favdiv = $('#favorite_panel');
|
||||
favdiv.empty();
|
||||
if (userfavorates && userfavorates.length > 0) {
|
||||
var div = $('<div class="panel_favorites"></div>')
|
||||
.css("max-height", $(window).height() - 180).appendTo(favdiv);
|
||||
var ulFavorites = $('<ul class="lefttitlemenu_ul" style="line-height:32px;"></ul>');
|
||||
div.append(ulFavorites);
|
||||
for (var i = 0; i < userfavorates.length; i++) {
|
||||
var fav = userfavorates[i];
|
||||
if (!fav) continue;
|
||||
if (fav.FavoriteType == 10) {
|
||||
createChartFavorite(fav, ulFavorites);
|
||||
continue;
|
||||
}
|
||||
|
||||
for (var j = 0; j < appmoudulesdata.length; j++) {
|
||||
var m = appmoudulesdata[j];
|
||||
if (m.ModuleType == 0)//Features
|
||||
{
|
||||
if (ids.indexOf(fav.ID) >= 0) {
|
||||
if (fav.ID.toLowerCase() === m.ID.toLowerCase()) {
|
||||
createMenuItem(m, ulFavorites);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (m.SubItems) {//有子项
|
||||
for (var k = 0; k < m.SubItems.length; k++) {
|
||||
var sub = m.SubItems[k];
|
||||
if (sub.ID.toLowerCase() === fav.ID.toLowerCase()) {
|
||||
createMenuItem(m, ulFavorites, sub);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (m.ModuleType == 1) {//WSP
|
||||
var id = "wsp" + m.ID;
|
||||
if (fav.ID.toLowerCase() === id.toLowerCase()) {
|
||||
createMenuItem(m, ulFavorites);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var editfav = $('<div class="viewall" style="height: 32px;text-align: center; margin-top: 10px;"><span class="sbutton iconedit">' + GetTextByKey("P_FAV_EDITFAVORITES", "Edit Favorites") + '</span</div>');
|
||||
favdiv.append(editfav);
|
||||
editfav.click(function () {
|
||||
openFavoriteDialog();
|
||||
});
|
||||
favdiv.append('<div class="trigle"></div>') // trigle
|
||||
favdiv.append('<div class="trigle white"></div>');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function getFavoriteNavInfoByID(id, text, icon) {
|
||||
var title = text;
|
||||
$(icon).addClass("lefttitlemenu_icon");
|
||||
if (id === "nav_credential") {
|
||||
title = GetTextByKey("P_CREDENTIALS", title);
|
||||
$(icon).addClass("iconcredentail");
|
||||
}
|
||||
else if (id === "nav_jdlink") {
|
||||
title = GetTextByKey("P_JDLINK", title);
|
||||
$(icon).addClass("iconjdlink");
|
||||
}
|
||||
else if (id === "nav_jdnotification") {
|
||||
title = GetTextByKey("P_JOHNDEERENOTIFICATIONS", title);
|
||||
$(icon).addClass("iconjdnotification");
|
||||
}
|
||||
else if (id === "nav_apicredential") {
|
||||
title = GetTextByKey("P_APICREDENTIALS", title);
|
||||
$(icon).addClass("iconcredentail");
|
||||
}
|
||||
else if (id === "nav_users") {
|
||||
title = GetTextByKey("P_USERS", title);
|
||||
$(icon).addClass("iconusers");
|
||||
}
|
||||
else if (id === "nav_user_group") {
|
||||
title = GetTextByKey("P_USERSGROUP", title);
|
||||
$(icon).addClass("iconusergroup");
|
||||
}
|
||||
else if (id === "nav_dts") {
|
||||
title = GetTextByKey("P_DATATABLEPERMISSION", title);
|
||||
$(icon).addClass("icondatatablepermission");
|
||||
}
|
||||
else if (id === "nav_filters") {
|
||||
title = GetTextByKey("P_DASHBOARDFILTERS", title);
|
||||
$(icon).addClass("icondashboardfilters");
|
||||
}
|
||||
else if (id === "nav_curfew") {
|
||||
title = GetTextByKey("P_CURFEWCONFIGURATION", title);
|
||||
$(icon).addClass("iconcurfew");
|
||||
}
|
||||
else if (id === "nav_curfewmt") {
|
||||
title = GetTextByKey("P_CURFEWMOVEMENTTOLERANCE", title);
|
||||
$(icon).addClass("iconcurfewmt");
|
||||
}
|
||||
else if (id === "nav_usertocontractor") {
|
||||
title = GetTextByKey("P_USERTOCONTRACTOR", title);
|
||||
$(icon).addClass("iconusertocontractor");
|
||||
}
|
||||
else if (id === "nav_alertsmanagement") {
|
||||
title = GetTextByKey("P_ALERTSMANAGEMENTNEW", title);
|
||||
$(icon).addClass("iconmanagealerts");
|
||||
}
|
||||
else if (id === "nav_workorder") {
|
||||
title = GetTextByKey("P_WORKORDERNEW", title);
|
||||
$(icon).addClass("iconworkorder");
|
||||
}
|
||||
else if (id === "nav_workorderhis") {
|
||||
title = GetTextByKey("P_XXX", title);
|
||||
$(icon).addClass("iconhistory");
|
||||
}
|
||||
else if (id === "nav_maintenanceschedule") {
|
||||
title = GetTextByKey("P_PM_MAINTENANCESCHEDULES", title);
|
||||
$(icon).addClass("iconmaintenanceschedule");
|
||||
}
|
||||
else if (id === "nav_record") {
|
||||
title = GetTextByKey("P_MAINTENANCERECORDLEGACY", title);
|
||||
$(icon).addClass("iconrecord");
|
||||
}
|
||||
else if (id === "nav_fuelrecord") {
|
||||
title = GetTextByKey("P_FUELRECORDS", title);
|
||||
$(icon).addClass("iconfuelrecord");
|
||||
}
|
||||
else if (id === "nav_manageharshdriving") {
|
||||
title = GetTextByKey("P_MANAGEHARSHDRIVING", title);
|
||||
$(icon).addClass("iconotrconfig");
|
||||
}
|
||||
else if (id === "nav_managmachines") {
|
||||
title = GetTextByKey("P_MANAGEASSETS", title);
|
||||
$(icon).addClass("iconmanageasset");
|
||||
}
|
||||
else if (id === "nav_managrentals") {
|
||||
title = GetTextByKey("P_MANAGERENTALS", title);
|
||||
$(icon).addClass("iconmanagerentals");
|
||||
}
|
||||
else if (id === "nav_machinegroups") {
|
||||
title = GetTextByKey("P_ASSETGROUPS", title);
|
||||
$(icon).addClass("iconassetgroups");
|
||||
}
|
||||
else if (id === "nav_managegpsdevices") {
|
||||
title = GetTextByKey("P_MANAGEDEVICES", title);
|
||||
$(icon).addClass("iconmanagegpsdevices");
|
||||
}
|
||||
else if (id === "nav_managmodels") {
|
||||
title = GetTextByKey("P_MANAGEMODELS", title);
|
||||
$(icon).addClass("iconmanagmodels");
|
||||
}
|
||||
else if (id === "nav_managmodels") {
|
||||
title = GetTextByKey("P_MANAGEMODELS", title);
|
||||
$(icon).addClass("iconmanagmodels");
|
||||
}
|
||||
else if (id === "nav_managmodels") {
|
||||
title = GetTextByKey("P_MANAGEMODELS", title);
|
||||
$(icon).addClass("iconmanagmodels");
|
||||
}
|
||||
else if (id === "nav_jobsiterequirements") {
|
||||
title = GetTextByKey("P_JS_JOBSITEREQUIREMENTS", title);
|
||||
}
|
||||
else if (id === "nav_dispatchrequests") {
|
||||
title = GetTextByKey("P_JS_DISPATCHREQUESTS", title);
|
||||
}
|
||||
else if (id === "nav_jobsitemanage") {
|
||||
title = GetTextByKey("P_JOBSITES", title);
|
||||
}
|
||||
else if (id === "nav_scheduler") {
|
||||
title = GetTextByKey("P_JS_SCHEDULER", title);
|
||||
}
|
||||
return title;
|
||||
}
|
||||
|
||||
function createMenuItem(m, ul, sub) {
|
||||
var name = m.ModuleType === 1 ? m.Name : m.CurrentName;
|
||||
var title = name;
|
||||
var sm = JSON.parse(JSON.stringify(m));
|
||||
if (sm.ID == '150' && sm.Url.indexOf("#") < 0)
|
||||
sm.Url += "#nav_jobsitemanage";
|
||||
|
||||
var icon = $('<button class="lefttitlemenu_icon titleicon" style="line-height:normal;"></button>');
|
||||
if (sub) {
|
||||
name = sub.Title;
|
||||
title = getFavoriteNavInfoByID(sub.ID, name, icon);
|
||||
sm.Url = sub.Url;
|
||||
if (sm.ID === "350" && !sub.IconPath)
|
||||
sub.IconPath = 'img/none.png';
|
||||
sm.IconPath = sm.Url.split('/')[0] + "/" + sub.IconPath;
|
||||
|
||||
if ([100, 120, 130, 140, 210, 235].indexOf(sub.FeatureID) >= 0) {//nav_jobsitemanage/nav_jobsiterequirements/nav_dispatchrequests/nav_scheduler/nav_workorder/nav_customerrecord
|
||||
icon = createMouduleIcon(sm, 1);
|
||||
}
|
||||
}
|
||||
else {
|
||||
icon = createMouduleIcon(sm, 1);
|
||||
title = getFavoriteNavInfoByID(sm.ID, name, icon);
|
||||
}
|
||||
var li = $('<li></li>').click(function () {
|
||||
onOpenSite(sm);
|
||||
});
|
||||
var a = $('<a style="padding-left:0;"></a>');
|
||||
li.append(a);
|
||||
a.append($('<div></div>').append(icon));
|
||||
a.append($('<span></span>').text(title));
|
||||
ul.append(li);
|
||||
}
|
||||
|
||||
function createFullMenuSite(m, ul) {
|
||||
var name = m.ModuleType === 1 ? m.Name : m.CurrentName;
|
||||
var sm = JSON.parse(JSON.stringify(m));
|
||||
var icon = createMouduleIcon(sm, 1);
|
||||
var li = $('<li></li>').click(function () {
|
||||
onOpenSite(sm);
|
||||
});
|
||||
var a = $('<a style="padding-left:0;"></a>');
|
||||
li.append(a);
|
||||
a.append($('<div></div>').append(icon));
|
||||
a.append($('<span></span>').text(name));
|
||||
ul.append(li);
|
||||
}
|
||||
|
||||
function createChartFavorite(fav, ulFavorites) {
|
||||
var li = $('<li></li>').click(function () {
|
||||
openFleetChart(fav.ID, fav.Name);
|
||||
});
|
||||
var fav_a = $('<a style="padding-left:0;"></a>');
|
||||
li.append(fav_a);
|
||||
icon = $('<img class="lefttitlemenu_icon"/>').attr('src', _network.root + "img/modules/chart.png");
|
||||
fav_a.append($('<div></div>').append(icon));
|
||||
fav_a.append($('<span></span>').text(fav.Name));
|
||||
ulFavorites.append(li);
|
||||
}
|
||||
|
||||
function onOpenSite(m) {
|
||||
if (!m)
|
||||
return;
|
||||
|
||||
//if (m.ModuleType === 1) //Workspace保存最近打开
|
||||
// setRecentOpenedDashboard(m.ID);
|
||||
|
||||
var url = m.Url.toLowerCase();
|
||||
if (url.length > 4 && url.substring(0, 4) == 'http') {
|
||||
} else if (url.length > 0 && url[0] == '/') {
|
||||
} else {
|
||||
url = _network.root + url;
|
||||
}
|
||||
if (m.OpenInNewWindow) {
|
||||
window.open(url, "_blank");
|
||||
} else {
|
||||
window.location = url;
|
||||
}
|
||||
}
|
||||
|
||||
function setAppMoudule(mouduleid, name, type) {
|
||||
if (!name) {
|
||||
if (mouduleid === 100)
|
||||
name = "Map View";
|
||||
else if (mouduleid === 150)
|
||||
name = "Jobsites";
|
||||
else if (mouduleid === 250)
|
||||
name = "FilterQ";
|
||||
else if (mouduleid === 500)
|
||||
name = "M3";
|
||||
else if (mouduleid === 550)
|
||||
name = "Over/Under Trucking Alerts";
|
||||
else if (mouduleid === 650)
|
||||
name = "Inspection";
|
||||
else if (mouduleid === 700)
|
||||
name = "Team Intelligence";
|
||||
}
|
||||
|
||||
return setNavigate(mouduleid + '', name, type);
|
||||
}
|
||||
|
||||
function setNavigate(id, name, type) {
|
||||
var obj = { "ID": id, "Name": name };
|
||||
if (type != undefined)
|
||||
obj.FavoriteType = type;
|
||||
return obj;
|
||||
}
|
||||
|
||||
|
||||
/*****************************Edit*************************************/
|
||||
|
||||
|
||||
function showFavConfirm(msg, title, fok, fcancel) {
|
||||
$('#favorites_mask_bg').show();
|
||||
_dialog.showConfirm(msg, title, function (e) {
|
||||
if (typeof fok === 'function') {
|
||||
$('#favorites_mask_bg').hide();
|
||||
fok(e);
|
||||
}
|
||||
}, function () {
|
||||
$('#favorites_mask_bg').hide();
|
||||
});
|
||||
}
|
||||
|
||||
var grid_favoritedt;
|
||||
function InitFavoriteGrid() {
|
||||
grid_favoritedt = new GridView('#favoritelist');
|
||||
grid_favoritedt.lang = {
|
||||
all: GetTextByKey("P_GRID_ALL", "(All)"),
|
||||
ok: GetTextByKey("P_GRID_OK", "OK"),
|
||||
reset: GetTextByKey("P_GRID_RESET", "Reset")
|
||||
};
|
||||
var list_columns = [
|
||||
{ name: 'Name', caption: GetTextByKey("P_FAV_FAVORITE", "Favorite"), valueIndex: 'Name', css: { 'width': 400, 'text-align': 'left' } },
|
||||
{ name: 'Delete', caption: "", css: { 'width': 32, 'text-align': 'center' } },
|
||||
{ name: 'Up', caption: "", css: { 'width': 32, 'text-align': 'center' } },
|
||||
{ name: 'Down', caption: "", css: { 'width': 32, 'text-align': 'center' } }
|
||||
];
|
||||
var columns = [];
|
||||
// head
|
||||
for (var hd in list_columns) {
|
||||
var col = {};
|
||||
col.name = list_columns[hd].name;
|
||||
col.caption = list_columns[hd].caption;
|
||||
col.visible = true;
|
||||
col.sortable = true;
|
||||
col.width = list_columns[hd].css.width;
|
||||
col.align = list_columns[hd].css["text-align"]
|
||||
col.key = list_columns[hd].valueIndex;
|
||||
if (list_columns[hd].type) {
|
||||
col.type = list_columns[hd].type;
|
||||
}
|
||||
if (col.name === "Delete") {
|
||||
col.isurl = true;
|
||||
col.text = "\uf00d";
|
||||
col.events = {
|
||||
onclick: function () {
|
||||
OnDeleteFavorite(this);
|
||||
}
|
||||
};
|
||||
col.classFilter = function (e) {
|
||||
return "icon-col";
|
||||
};
|
||||
col.attrs = { 'title': GetTextByKey("P_FAV_DELETE", 'Delete') };
|
||||
}
|
||||
else if (col.name === "Up") {
|
||||
col.isurl = true;
|
||||
col.text = "\uf062";
|
||||
col.events = {
|
||||
onclick: function () {
|
||||
onSortFavorite(true, this);
|
||||
}
|
||||
};
|
||||
col.classFilter = function (e) {
|
||||
return "icon-col";
|
||||
};
|
||||
col.attrs = { 'title': GetTextByKey("P_FAV_UP", 'Up') };
|
||||
}
|
||||
else if (col.name === "Down") {
|
||||
col.isurl = true;
|
||||
col.text = "\uf063";
|
||||
col.events = {
|
||||
onclick: function () {
|
||||
onSortFavorite(false, this);
|
||||
}
|
||||
};
|
||||
col.classFilter = function (e) {
|
||||
return "icon-col";
|
||||
};
|
||||
col.attrs = { 'title': GetTextByKey("P_FAV_DOWN", 'Down') };
|
||||
}
|
||||
columns.push(col);
|
||||
}
|
||||
grid_favoritedt.canMultiSelect = false;
|
||||
grid_favoritedt.columns = columns;
|
||||
grid_favoritedt.init();
|
||||
|
||||
grid_favoritedt.selectedrowchanged = function (rowindex) {
|
||||
var rowdata = grid_favoritedt.source[rowindex];
|
||||
if (rowdata) {
|
||||
}
|
||||
};
|
||||
|
||||
grid_favoritedt.rowdblclick = function (rowindex) {
|
||||
var rowdata = grid_favoritedt.source[rowindex];
|
||||
if (rowdata) {
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
var favgridinited = false;
|
||||
function showFavoritesGridList(data) {
|
||||
if (!favgridinited) {
|
||||
favgridinited = true;
|
||||
InitFavoriteGrid();
|
||||
}
|
||||
grid_favoritedt.setData([]);
|
||||
if (!data || data.length === 0)
|
||||
return;
|
||||
var rows = [];
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
var r = data[i];
|
||||
var fr = { Values: r };
|
||||
rows.push(fr);
|
||||
}
|
||||
|
||||
grid_favoritedt.setData(rows);
|
||||
}
|
||||
|
||||
function openFavoriteDialog() {
|
||||
$('#mask_bg').show();
|
||||
$('#dialog_favorite .dialog-title span.title').text(GetTextByKey("P_FAV_EDITFAVORITES", 'Edit Favorites'));
|
||||
|
||||
$('#dialog_favorite')
|
||||
.attr('act', 'edit')
|
||||
.css({
|
||||
'width': 540,
|
||||
'top': (document.documentElement.clientHeight - $('#dialog_favorite').height()) / 4,
|
||||
'left': (document.documentElement.clientWidth - $('#dialog_favorite').width()) / 2
|
||||
}).showDialogfixed();
|
||||
$("#btnfavsave").focus();
|
||||
|
||||
if (userfavorates)
|
||||
showFavoritesGridList(userfavorates);
|
||||
}
|
||||
|
||||
function OnDeleteFavorite(fav) {
|
||||
if (!fav)
|
||||
return;
|
||||
|
||||
showFavConfirm(GetTextByKey("P_FAV_DELETEFAVORITECONTINUE", 'Favorite {0} will be deleted.Do you want to continue?').replace('{0}', fav.Name), GetTextByKey("P_FAV_DELETEFAVORITE", 'Delete Favorite'), function () {
|
||||
setFavoritesData(true, fav);
|
||||
});
|
||||
}
|
||||
|
||||
function onSortFavorite(isasc, fav) {
|
||||
if (!fav || !userfavorates)
|
||||
return;
|
||||
|
||||
var index;
|
||||
var currentfavs = [];
|
||||
for (var i = 0; i < grid_favoritedt.source.length; i++) {
|
||||
var userfav = grid_favoritedt.source[i].Values;
|
||||
if (fav.ID === userfav.ID)
|
||||
index = i;
|
||||
else
|
||||
currentfavs.push(userfav);
|
||||
}
|
||||
if (isasc) {
|
||||
if (index == 0)
|
||||
index = currentfavs.length;
|
||||
else
|
||||
index = index - 1;
|
||||
}
|
||||
else {
|
||||
if (index == currentfavs.length)
|
||||
index = 0;
|
||||
else
|
||||
index = index + 1;
|
||||
}
|
||||
currentfavs.splice(index, 0, fav);
|
||||
showFavoritesGridList(currentfavs);
|
||||
}
|
||||
|
||||
function onSaveFavoriteSort() {
|
||||
if (!grid_favoritedt)
|
||||
return;
|
||||
var data = [];
|
||||
for (var i = 0; i < grid_favoritedt.source.length; i++) {
|
||||
data.push(grid_favoritedt.source[i].Values);
|
||||
}
|
||||
|
||||
saveFavorites(data, true);
|
||||
}
|
||||
|
||||
|
||||
/*****************************Title Sites**************************************/
|
||||
|
||||
function onInitTitleSites() {
|
||||
if (appmoudulesdata) {
|
||||
var menudiv = $("#divfavmenu");
|
||||
var syssetli = $("#lisyssetting");
|
||||
var liversion = $("#liVersion");
|
||||
|
||||
menudiv.parent().find(".dynamicmenu").remove();
|
||||
syssetli.parent().find(".dynamicmenu").remove();
|
||||
|
||||
var mids = ['150', '650', '200', '400', 'dashboards', '100'];
|
||||
var smids = ['350', '150', '350', '300', '600', '650', '700'];
|
||||
for (var i = 0; i < mids.length; i++) {
|
||||
var id = mids[i];
|
||||
if (id === "dashboards") {
|
||||
if (!isReadonlyUser)
|
||||
createDashboardTitle(menudiv);
|
||||
}
|
||||
else {
|
||||
for (var j = 0; j < appmoudulesdata.length; j++) {
|
||||
var m = appmoudulesdata[j];
|
||||
if (!m.Visible) continue;
|
||||
if (id == parseInt(m.ID)) {
|
||||
if (id == '150') {
|
||||
for (var k = 0; k < m.SubItems.length; k++) {
|
||||
var sub = m.SubItems[k];
|
||||
if (sub.ID == "nav_jobsiterequirements"
|
||||
|| sub.ID == "nav_dispatchrequests"
|
||||
|| sub.ID == "nav_scheduler") {
|
||||
m = $.extend(true, {}, m);
|
||||
m.CurrentName = GetTextByKey("P_JS_ASSETSCHEDULINGANDDISPATCHING", "Asset Scheduling and Dispatching");
|
||||
m.IconPath = m.Url.split('/')[0] + "/img/dispatch.png";
|
||||
createTitleSite(m, menudiv);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
createTitleSite(m, menudiv);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (var i = 0; i < smids.length; i++) {
|
||||
var id = parseInt(smids[i]);
|
||||
for (var j = 0; j < appmoudulesdata.length; j++) {
|
||||
var m = appmoudulesdata[j];
|
||||
if (!m.Visible) continue;
|
||||
if (id == parseInt(m.ID)) {
|
||||
if (id == 350 && i == 0 && m.SubItems) {
|
||||
for (var k = 0; k < m.SubItems.length; k++) {
|
||||
var sub = m.SubItems[k];
|
||||
if (sub.ID === "nav_users") {
|
||||
createSettingSite(m, syssetli, sub);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (id == 350 && i == 2 && m.SubItems) {
|
||||
for (var k = 0; k < m.SubItems.length; k++) {
|
||||
var sub = m.SubItems[k];
|
||||
if (sub.ID === "nav_curfew") {
|
||||
createSettingSite(m, liversion, sub);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (id == 150) {
|
||||
m = $.extend(true, {}, m);
|
||||
m.Url += "#nav_jobsitemanage";
|
||||
createSettingSite(m, syssetli);
|
||||
} else {
|
||||
createSettingSite(m, liversion);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function createTitleSite(m, menudiv) {
|
||||
var name = m.CurrentName;
|
||||
var sm = JSON.parse(JSON.stringify(m));
|
||||
var mctrl = $("<div class='button dynamicmenu'></div>").click(function () {
|
||||
onOpenSite(sm);
|
||||
});
|
||||
|
||||
var icon;
|
||||
icon = $('<div class="titleicon"></div>').append($('<img class="titleimgicon"/>').attr('src', _network.root + m.IconPath));
|
||||
|
||||
mctrl.append(icon);
|
||||
|
||||
mctrl.attr("title", name);
|
||||
menudiv.after(mctrl);
|
||||
}
|
||||
|
||||
function createSettingSite(m, syssetli, sub) {
|
||||
var name = m.CurrentName;
|
||||
if (m.ID === "650")
|
||||
name = GetTextByKey("P_MODULE_INSPECTIONTEMPLATES", "Inspection Templates");
|
||||
var sm = JSON.parse(JSON.stringify(m));
|
||||
var icon = $('<button class="lefttitlemenu_icon"></button>');
|
||||
if (sub) {
|
||||
if (sub.ID === "nav_users")
|
||||
name = GetTextByKey("P_USERSETUP", "User Setup");
|
||||
else if (sub.ID === "nav_curfew")
|
||||
name = GetTextByKey("P_CURFEWCONFIGURATION", sub.Title);
|
||||
sm.Url = sub.Url;
|
||||
sm.IconPath = sm.Url.split('/')[0] + "/" + sub.IconPath;
|
||||
}
|
||||
icon = createMouduleIcon(sm, 1);
|
||||
|
||||
var li = $('<li class="dynamicmenu"></li>').click(function () {
|
||||
onOpenSite(sm);
|
||||
});
|
||||
var fav_a = $('<a style="padding-left:0;"></a>');
|
||||
li.append(fav_a);
|
||||
fav_a.append($('<div></div>').append(icon));
|
||||
fav_a.append($('<span></span>').text(name));
|
||||
|
||||
syssetli.before(li);
|
||||
}
|
||||
|
||||
//*************************************Dashboards**********************************//
|
||||
var dashboarddata;
|
||||
var grid_dbdt;
|
||||
function InitDBGridData() {
|
||||
grid_dbdt = new GridView('#dashboardslist');
|
||||
grid_dbdt.lang = {
|
||||
all: GetTextByKey("P_GRID_ALL", "(All)"),
|
||||
ok: GetTextByKey("P_GRID_OK", "OK"),
|
||||
reset: GetTextByKey("P_GRID_RESET", "Reset")
|
||||
};
|
||||
var list_columns = [
|
||||
{ name: 'Name', caption: GetTextByKey("P_DASHBOARDS_NAME", "Name"), valueIndex: 'Name', css: { 'width': 240, 'text-align': 'left' } },
|
||||
{ name: 'Type', caption: GetTextByKey("P_DASHBOARDS_CHARTTYPE", "Chart Type"), valueIndex: 'Type', css: { 'width': 140, 'text-align': 'left' } },
|
||||
{ name: 'Notes', caption: GetTextByKey("P_DASHBOARDS_NOTES", "Notes"), valueIndex: 'NoteTag', css: { 'width': 80, 'text-align': 'left' } },
|
||||
{ name: 'IsChart', caption: GetTextByKey("P_DASHBOARDS_TYPE", "Type"), valueIndex: 'IsChart', css: { 'width': 80, 'text-align': 'left' } }
|
||||
];
|
||||
var columns = [];
|
||||
// head
|
||||
for (var hd in list_columns) {
|
||||
var col = {};
|
||||
col.name = list_columns[hd].name;
|
||||
col.caption = list_columns[hd].caption;
|
||||
col.visible = true;
|
||||
col.sortable = true;
|
||||
col.width = list_columns[hd].css.width;
|
||||
col.align = list_columns[hd].css["text-align"]
|
||||
col.key = list_columns[hd].valueIndex;
|
||||
col.allowFilter = list_columns[hd].allowFilter;
|
||||
if (list_columns[hd].type) {
|
||||
col.type = list_columns[hd].type;
|
||||
}
|
||||
if (col.name == "Notes") {
|
||||
col.css = { 'text-align': 'center' };
|
||||
col.styleFilter = function () {
|
||||
return {
|
||||
color: 'blue', cursor: 'pointer', 'text-decoration': 'underline'
|
||||
};
|
||||
};
|
||||
col.events = {
|
||||
onclick: function () {
|
||||
showChartNotes(this.ID, this.Notes);
|
||||
}
|
||||
}
|
||||
}
|
||||
columns.push(col);
|
||||
}
|
||||
grid_dbdt.canMultiSelect = false;
|
||||
grid_dbdt.columns = columns;
|
||||
grid_dbdt.init();
|
||||
grid_dbdt.rowdblclick = openDashboard;
|
||||
|
||||
grid_dbdt.selectedrowchanged = function (rowindex) {
|
||||
var rowdata = grid_dbdt.source[rowindex];
|
||||
if (rowdata) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function showChartNotes(iid, notes) {
|
||||
$("#prechartnotes").text(notes);
|
||||
$('#mask_bgcn').show();
|
||||
$('#dialog_chartnotes .dialog-title span.title').text(GetTextByKey("P_MAIN_CHARTNOTES", 'Chart Notes'));
|
||||
|
||||
$('#dialog_chartnotes')
|
||||
.attr('act', 'edit')
|
||||
.css({
|
||||
'width': 400,
|
||||
'top': (document.documentElement.clientHeight - $('#dialog_chartnotes').height()) / 4,
|
||||
'left': (document.documentElement.clientWidth - $('#dialog_chartnotes').width()) / 2
|
||||
}).showDialogfixed();
|
||||
//_network.ficquery('GetChartNote', [iid], function (r) {
|
||||
// if (r != null) {
|
||||
// if (r.ErrorCode != 0) {
|
||||
// $("#prechartnotes").text(r.ErrorMessage);
|
||||
// } else {
|
||||
// $("#prechartnotes").html(unescape(r.Result));
|
||||
// }
|
||||
// }
|
||||
//});
|
||||
};
|
||||
|
||||
function requestFIC(service, method, param, callback, error) {
|
||||
$.ajax({
|
||||
url: _network.root + 'fic/fic/FICSvc.ashx?fmt=json&SN=' + Math.random(),
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
cache: false,
|
||||
data: encodeURIComponent(JSON.stringify({
|
||||
LanguageID: _fleet.currentLang,
|
||||
UtcOffset: new Date().getTimezoneOffset(),
|
||||
Flag: 0,
|
||||
AppName: '',
|
||||
ServiceType: service,
|
||||
MethodName: method,
|
||||
Parameters: param
|
||||
})),
|
||||
async: true,
|
||||
success: callback,
|
||||
error: error || function (e) {
|
||||
console.log(e);
|
||||
showmaskbg(false, true);
|
||||
showAlert(GetTextByKey('P_UM_PAGEERROR', 'An unknown error occurred. Please refresh page.'), GetTextByKey('P_UM_QUERY', 'Query'));
|
||||
}
|
||||
});
|
||||
}
|
||||
_network.ficquery = function (method, param, callback, error) {
|
||||
requestFIC('FI.FIC.IFICQuery', method, param, callback, error);
|
||||
};
|
||||
|
||||
function showDashboards(data) {
|
||||
var rows = [];
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
var r = data[i];
|
||||
r.NoteTag = (r.Notes && r.Notes != "") ? "?" : "";
|
||||
for (var j in r) {
|
||||
if (j === "IsChart")
|
||||
r[j] = { DisplayValue: r["IsChart"] ? "Chart" : "Dashboard", Value: r[j] };
|
||||
}
|
||||
|
||||
var fr = { Values: r };
|
||||
rows.push(fr);
|
||||
}
|
||||
|
||||
grid_dbdt.setData(rows);
|
||||
}
|
||||
|
||||
function createDashboardTitle(menudiv) {
|
||||
var mctrl = $("<div class='button dynamicmenu'></div>").click(function () {
|
||||
openDashboardsDialog();
|
||||
});
|
||||
//var icon = $('<button class="reportsdashboard"></button>');
|
||||
var icon = $('<div class="titleicon"></div>').append($('<img class="titleimgicon"/>').attr('src', _network.root + "img/modules/dashboards.png?t=7"));
|
||||
mctrl.append(icon);
|
||||
|
||||
mctrl.attr("title", GetTextByKey("P_MAIN_REPORTSDASHBOARDS", "Reports & Dashboards"));
|
||||
menudiv.after(mctrl);
|
||||
}
|
||||
|
||||
function openDashboardsDialog() {
|
||||
$('#mask_bg').show();
|
||||
$('#dialog_dashboards .dialog-title span.title').text(GetTextByKey("P_MAIN_REPORTSDASHBOARDS", 'Reports & Dashboards'));
|
||||
|
||||
$('#dialog_dashboards')
|
||||
.attr('act', 'edit')
|
||||
.css({
|
||||
'width': 850,
|
||||
'top': (document.documentElement.clientHeight - $('#dialog_dashboards').height()) / 4,
|
||||
'left': (document.documentElement.clientWidth - $('#dialog_dashboards').width()) / 2
|
||||
}).showDialogfixed(false);//参数为了兼容inspection页面
|
||||
|
||||
getDashboardList();
|
||||
}
|
||||
|
||||
function openDashboard() {
|
||||
var index = grid_dbdt.selectedIndex;
|
||||
if (index < 0) {
|
||||
_dialog.showAlert(GetTextByKey("P_DASHBOARDS_SELECTWSPORCHART", "Please select a Workspace or Chart."), GetTextByKey("P_MAIN_DASHBOARDS", 'Dashboards'));
|
||||
return;
|
||||
}
|
||||
|
||||
var dah = grid_dbdt.source[index].Values;
|
||||
if (dah.IsChart.Value) {
|
||||
setRecentOpenedDashboard(dah.ID);
|
||||
$('#dialog_dashboards').hideDialog();
|
||||
$('#mask_bg').hide();
|
||||
openFleetChart(dah.ID, dah.Name);
|
||||
}
|
||||
else {
|
||||
var m = {
|
||||
'ID': dah.ID,
|
||||
'ModuleType': 1,
|
||||
'OpenInNewWindow': false,
|
||||
'Url': "fic/Workspace.aspx?IID=" + dah.ID
|
||||
};
|
||||
onOpenSite(m);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function getDashboardList() {
|
||||
var flag;
|
||||
if ($('#ipt_charts_only').prop('checked')) {
|
||||
flag = '1';
|
||||
} else if ($('#ipt_notes_only').prop('checked')) {
|
||||
flag = '2';
|
||||
} else {
|
||||
flag = '0';
|
||||
}
|
||||
var filter = JSON.stringify({
|
||||
'$type': 'System.String[], mscorlib',
|
||||
'$values': [htmlencode($.trim($('#ipt_dashboardfilter').val())), flag]
|
||||
});
|
||||
_network.mainpagequery("GetDashboardList", filter, function (data) {
|
||||
if (typeof data === 'string') {
|
||||
_dialog.showAlert(data, GetTextByKey("P_MAIN_DASHBOARDS", 'Dashboards'));
|
||||
} else {
|
||||
dashboarddata = data;
|
||||
showDashboards(data);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function setRecentOpenedDashboard(id) {
|
||||
_network.mainpagequery("SetRecentOpenedDashboard", id, function (data) {
|
||||
if (typeof data === 'string') {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function createMouduleIcon(m, type) {//type 0.moudule;1.fav/settings
|
||||
var icon = $('<img/>').attr('src', _network.root + m.IconPath);
|
||||
//if (m.ID === "100")//Map View
|
||||
// icon = $("<button class='iconmapview'></button>");
|
||||
//else if (m.ID === "150")//Jobsites
|
||||
// icon = $("<button class='iconjobsite'></button>");
|
||||
//else if (m.ID === "200")//Asset Health
|
||||
// icon = $("<button class='iconassethealth'></button>");
|
||||
//else if (m.ID === "250")//FilterQ
|
||||
// icon = $("<button class='iconassethealth'></button>");
|
||||
//else if (m.ID === "300")//Credentials
|
||||
// icon = $("<button class='iconcredentails'></button>");
|
||||
//if (m.ID === "350")//Security Setting
|
||||
// icon = $("<button class='iconsecuritysetting'></button>");
|
||||
//if (m.ID === "400")//Manage Assets
|
||||
// icon = $("<button class='iconmanageasset'></button>");
|
||||
//else if (m.ID === "450")//FIC Management
|
||||
// icon = $("<button class='iconficmanagement'></button>");
|
||||
//else if (m.ID === "500")//M3
|
||||
// icon = $("<button class='iconficmanagement'></button>");
|
||||
//else if (m.ID === "550")//Over/Under Trucking Alerts
|
||||
// icon = $("<button class='icontruck'></button>");
|
||||
//else if (m.ID === "600")//OTR Config
|
||||
// icon = $("<button class='iconotrconfig'></button>");
|
||||
//else if (m.ID === "650")//Inspection
|
||||
// icon = $("<button class='iconinspection'></button>");
|
||||
//else if (m.ID === "700")//Team Intelligence
|
||||
// icon = $("<button class='iconteamintelligence'></button>");
|
||||
|
||||
//if (m.ModuleType == 1)
|
||||
// //icon = $("<button class='iconworkspace'></button>");
|
||||
// icon = $('<img/>').attr('src', _network.root + "img/modules/dashboard.png");
|
||||
|
||||
if (type == 0)
|
||||
icon.addClass("moduleicon");
|
||||
else if (type == 1)
|
||||
icon.addClass("lefttitlemenu_icon");
|
||||
|
||||
return icon;
|
||||
}
|
||||
|
734
Site/js/filterq.js
Normal file
734
Site/js/filterq.js
Normal file
@ -0,0 +1,734 @@
|
||||
/// <reference path="jquery-3.6.0.min.js" />
|
||||
/// <reference path="utility.js" />
|
||||
|
||||
var colspan = 16;
|
||||
|
||||
// FilterQ
|
||||
function filterQuery(method, param, callback, error) {
|
||||
_network.request("FilterQ.aspx?tp=ashx&method=" + method, -1, '', param, callback, error);
|
||||
}
|
||||
|
||||
function clickIcon() {
|
||||
var _this = $(this);
|
||||
var expand = _this.hasClass('collapse');
|
||||
_this.attr('class', 'icon ' + (expand ? 'expand' : 'collapse'))
|
||||
var tr = _this.parents('.subheader_tr');
|
||||
// fill if there isn't trs
|
||||
var row = tr.data('row');
|
||||
if (row) {
|
||||
var trs = [];
|
||||
fillGroup(row, trs);
|
||||
$(trs).insertAfter(tr);
|
||||
tr.removeData('row');
|
||||
return;
|
||||
}
|
||||
|
||||
var ship = tr.attr('shipdate');
|
||||
while ((tr = tr.next()).length) {
|
||||
if (tr.attr('shipdate') == ship) {
|
||||
tr.css('display', expand ? '' : 'none');
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function fillTr1(tr, j, dt, item) {
|
||||
var td;
|
||||
tr.append(td);
|
||||
if (j > 0) {
|
||||
isdealer && tr.append($('<td style="font-size:13px;" class="bold hide"></td>').text(dt.OrganizationName));
|
||||
tr.append($('<td class="bold hide"></td>').text(item.OrgMachineCode));
|
||||
td = $('<td style="font-size:13px;" class="bold hide"></td>').text(dt.JobSite);
|
||||
} else {
|
||||
tr.addClass('top');
|
||||
var attr = {
|
||||
'rowspan': dt.Children.length,
|
||||
'rspan': dt.Children.length
|
||||
};
|
||||
isdealer && tr.append($('<td style="font-size:13px;" class="bold"></td>').text(dt.OrganizationName).attr(attr));
|
||||
td = $('<td class="bold"></td>').text(item.OrgMachineCode).attr(attr);
|
||||
if ((iscontractor || isdealer)) {
|
||||
td.append($('<input type="button" onclick="OnExpand(this);" class="expand_button" value="" style="font-size:13px;"/>'));
|
||||
}
|
||||
tr.append(td);
|
||||
td = $('<td style="font-size:13px;" class="bold"></td>').text(dt.JobSite).attr(attr);
|
||||
}
|
||||
tr.append(td);
|
||||
|
||||
var jobsite_str = item.JobContact
|
||||
+ '\n' + item.JobContactNumber
|
||||
+ '\n' + item.JobAddress1.replace(/\n$/g, '')
|
||||
+ '\n' + item.JobAddress2.replace(/\n$/g, '')
|
||||
+ '\n' + item.JobAddressCity
|
||||
+ '\n' + item.JobAddressState
|
||||
+ '\n' + item.JobAddressZip
|
||||
;
|
||||
td = $('<td style="font-size:11px;"></td>').html(htmlencode(jobsite_str).replace(/\n/g, '<br/>'));
|
||||
if (isdealer) {
|
||||
td.attr('colspan', 4);
|
||||
tr.append(td);
|
||||
//tr.append(createInputTd('org_machine_code', item.OrgMachineCode)); // 50
|
||||
} else {
|
||||
td.attr('colspan', 3);
|
||||
tr.append(td);
|
||||
}
|
||||
var make_str = 'Make: ' + item.ManufactuerMake
|
||||
+ '\nModel: ' + item.Model
|
||||
+ '\nSN: ' + item.SN
|
||||
;
|
||||
tr.append($('<td style=""></td>').html(htmlencode(make_str).replace(/\n/g, '<br/>')));
|
||||
//if (iscontractor) {
|
||||
tr.append($('<td></td>').text(item.EstShipDate));
|
||||
//}
|
||||
//tr.append(createInputTd('hours_atservice', item.TaskCompletedHours));
|
||||
tr.append($('<td></td>').text(item.DiffToService));
|
||||
}
|
||||
|
||||
function fillTr2(tr, j, dt, item) {
|
||||
|
||||
//isdealer && tr.append($('<td style="font-size:13px;" class="bold hide"></td>').text(dt.OrganizationName));
|
||||
//tr.append($('<td style="font-size:13px;" class="bold hide"></td>').text(dt.JobSite));
|
||||
|
||||
if (isdealer) {
|
||||
tr.append(createCheckboxTd('task_complete', item.TaskComplete));
|
||||
tr.append(createInputTd('ups_tracking_number', item.UPSTrackingNumber));
|
||||
}
|
||||
//tr.append($('<td></td>').text(item.UpsStatus));
|
||||
if ((iscontractor || isdealer)) {
|
||||
tr.append(createCheckboxTd('request_jre_to_service', item.RequestJREToService));
|
||||
//tr.append(createDropTd('priority', item.Priority));
|
||||
} else {
|
||||
tr.append(createCheckboxTd('request_jre_to_service', item.RequestJREToService, true));
|
||||
//tr.append($('<td></td>').text(getPriority(item.Priority)));
|
||||
}
|
||||
if (iscontractor) {
|
||||
tr.append(createCheckboxTd('approved_by', item.Approved));
|
||||
tr.append(createInputTd('po', item.CustomerPO));
|
||||
} else {
|
||||
tr.append(createCheckboxTd('approved_by', item.Approved, true));
|
||||
}
|
||||
if (isdealer) {
|
||||
tr.append(createInputTd('wonumber', item.CustomerWO));
|
||||
}
|
||||
if ((iscontractor || isdealer)) {
|
||||
tr.append(createTextareaTd('shipnotes', item.ShipNotes, true, isdealer ? 1 : 3));
|
||||
} else {
|
||||
var d = $('<td></td>').text(item.ShipNotes);
|
||||
var s = d.html().replace(/\n/g, '<br/>');
|
||||
tr.append(d.html(s));
|
||||
}
|
||||
|
||||
return tr;
|
||||
}
|
||||
|
||||
function fillGroup(row, trs, hidden) {
|
||||
|
||||
if (!row || !row.Groups) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (var i = 0; i < row.Groups.length; i++) {
|
||||
var dt = row.Groups[i];
|
||||
|
||||
for (var j = 0; j < dt.Children.length; j++) {
|
||||
var item = dt.Children[j];
|
||||
if (!item) {
|
||||
continue;
|
||||
}
|
||||
|
||||
tr = $('<tr></tr>').data('item', item); // .attr('shipdate', row.ShipDate)
|
||||
if (hidden) {
|
||||
tr.css('display', 'none');
|
||||
}
|
||||
fillTr1(tr, j, dt, item);
|
||||
//trs.push(tr);
|
||||
|
||||
//tr = $('<tr></tr>').attr('shipdate', row.ShipDate);
|
||||
//if (hidden) {
|
||||
// tr.css('display', 'none');
|
||||
//}
|
||||
fillTr2(tr, j, dt, item);
|
||||
trs.push(tr);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function getPriority(priority) {
|
||||
if (priority == 'next') {
|
||||
return 'Next Day Air';
|
||||
} else if (priority == '2nd') {
|
||||
return '2nd Day Air';
|
||||
}
|
||||
return 'Standard';
|
||||
}
|
||||
|
||||
function createInputTd(clsName, val, colspan) {
|
||||
var td = $('<td class="input"></td>');
|
||||
if (!isNaN(colspan)) {
|
||||
td.attr('colspan', colspan);
|
||||
}
|
||||
td.append($('<input type="text"/>').addClass(clsName).val(val).data('original', val).focus(clearRed));
|
||||
return td;
|
||||
}
|
||||
function createDateTd(clsName, val) {
|
||||
var td = $('<td class="input"></td>');
|
||||
var inp = $('<input type="text"/>').addClass(clsName).val(val).data('original', val).focus(startDate);
|
||||
//inp.datetimepicker({
|
||||
// timepicker: false,
|
||||
// format: 'm/d/Y'
|
||||
//});
|
||||
td.append(inp);
|
||||
return td;
|
||||
}
|
||||
function createTextareaTd(clsName, val, flag, colspan) {
|
||||
var td = $('<td class="input" style="text-align: left;"></td>');
|
||||
if (!isNaN(colspan)) {
|
||||
td.attr('colspan', colspan);
|
||||
}
|
||||
var area = $('<textarea></textarea>').addClass(clsName).val(val).data('original', val).focus(clearRed);
|
||||
if (flag) {
|
||||
area.attr('wrap', 'off');
|
||||
area.css({
|
||||
'overflow-x': 'hidden',
|
||||
'overflow-y': 'hidden',
|
||||
'min-height': '100%'
|
||||
});
|
||||
//if (typeof val === 'string' && val.indexOf('\n') >= 0) {
|
||||
// area.css('min-height', 36);
|
||||
//} else {
|
||||
// area.css('min-height', 24);
|
||||
//}
|
||||
doAutoHeight(area);
|
||||
area.bind('propertychange', autoHeight).bind('input', autoHeight);
|
||||
} else {
|
||||
area.css('height', '100%');
|
||||
}
|
||||
td.append(area);
|
||||
return td;
|
||||
}
|
||||
function startDate() {
|
||||
clearRed();
|
||||
$('.dt_picker').datetimepicker('destroy').remove();
|
||||
|
||||
var _this = $(this);
|
||||
var dt = $('<input type="text" class="dt_picker"/>').val(_this.val()).data({
|
||||
'original': _this.val(),
|
||||
'control': _this
|
||||
}).blur(destroyDate);
|
||||
dt.datetimepicker({
|
||||
timepicker: false,
|
||||
format: 'm/d/Y',
|
||||
onSelectDate: changeDate
|
||||
});
|
||||
dt.bind('propertychange', changeDate).bind('input', changeDate);
|
||||
_this.css('display', 'none');
|
||||
dt.appendTo(_this.parent());
|
||||
dt.focus();
|
||||
}
|
||||
function changeDate(text, inst) {
|
||||
inst.data('control').val(inst.val());
|
||||
}
|
||||
function destroyDate() {
|
||||
$(this).data('control').css('display', '');
|
||||
$(this).css('display', 'none');
|
||||
}
|
||||
function autoHeight() {
|
||||
doAutoHeight($(this));
|
||||
}
|
||||
function doAutoHeight(ele) {
|
||||
var s = ele.val();
|
||||
var lbl = $('#lbl_calc').html(htmlencode(s).replace(/\n/g, '<br/>'));
|
||||
var tdwidth = ele.parent().width();
|
||||
var lblwidth = lbl.width() + 6;
|
||||
if (lblwidth < 200) {
|
||||
lblwidth = 200;
|
||||
}
|
||||
ele.css({
|
||||
'height': getLinesNumber(ele.val()) * 13,
|
||||
'width': isNaN(tdwidth) ? lblwidth : Math.max(tdwidth, lblwidth)
|
||||
});
|
||||
}
|
||||
function getLinesNumber(val) {
|
||||
if (typeof val !== 'string') {
|
||||
return 1;
|
||||
}
|
||||
var lines = val.split(/\n/).length;
|
||||
return (lines > 0 ? lines : 1);
|
||||
}
|
||||
function createCheckboxTd(clsName, val, ro) {
|
||||
var td = $('<td class="input"></td>');
|
||||
var inp = $('<input type="checkbox"/>').addClass(clsName).prop({
|
||||
'checked': val,
|
||||
'disabled': ro
|
||||
}).data('original', val).focus(clearRed);
|
||||
if (ro) {
|
||||
td.addClass('ro');
|
||||
inp.css('background', 'none');
|
||||
}
|
||||
td.append(inp);
|
||||
return td;
|
||||
}
|
||||
function createDropTd(clsName, val) {
|
||||
var td = $('<td class="input"></td>');
|
||||
var opts = [
|
||||
$('<option selected="selected" value="standard"></option>').text(getPriority('standard')),
|
||||
$('<option value="next"></option>').text(getPriority('next')),
|
||||
$('<option value="2nd"></option>').text(getPriority('2nd'))
|
||||
];
|
||||
td.append($('<select></select>').append(opts).addClass(clsName).val(val).data('original', val).focus(clearRed));
|
||||
return td;
|
||||
}
|
||||
|
||||
function clearRed(e) {
|
||||
$(this).removeClass('red');
|
||||
}
|
||||
|
||||
|
||||
function getFilterQGroups() {
|
||||
|
||||
function checkAll(e) {
|
||||
var flag = $(this).prop('checked');
|
||||
$(this).parents('ul:first').find('input').prop('checked', flag);
|
||||
}
|
||||
|
||||
function fillList(data) {
|
||||
var shipdates = [];
|
||||
var li = $('<li></li>');
|
||||
var chk = $('<input type="checkbox" id="chk_shipdate_all"/>');
|
||||
chk.change(checkAll);
|
||||
li.append(chk);
|
||||
li.append($('<label for="chk_shipdate_all">All</label>'));
|
||||
shipdates.push(li);
|
||||
|
||||
var tbody = $('#bodyFilters');
|
||||
tbody.removeData('datas').empty();
|
||||
if (!data) {
|
||||
tbody.append('<tr><td colspan="' + colspan + '" class="errorText">Error occurs, please contact your administrator.</td></tr>');
|
||||
} else {
|
||||
var datas = [];
|
||||
var trs = [];
|
||||
for (var g = 0; g < data.length; g++) {
|
||||
var row = data[g];
|
||||
|
||||
// filters
|
||||
var dates = row.ShipDates;
|
||||
for (var i = 0; i < dates.length; i++) {
|
||||
var d = dates[i];
|
||||
li = $('<li></li>');
|
||||
chk = $('<input type="checkbox"/>').attr('id', 'chk_shipdate_' + d).val(d);
|
||||
//if (row && row.Groups && row.Groups.length > 0) {
|
||||
// chk.prop('checked', true);
|
||||
//}
|
||||
if (!row.SelectedShipDates || !row.SelectedShipDates.length || $.inArray(d, row.SelectedShipDates) >= 0) {
|
||||
chk.prop('checked', true);
|
||||
}
|
||||
li.append(chk);
|
||||
li.append($('<label></label>').attr('for', 'chk_shipdate_' + d).text(d));
|
||||
shipdates.push(li);
|
||||
}
|
||||
|
||||
//var tr = $('<tr class="subheader_tr"></tr>').attr('shipdate', row.ShipDate);
|
||||
//var td = $('<td></td>').attr('colspan', colspan);
|
||||
//var expand = (g == 0 ? 'expand' : 'collapse');
|
||||
//td.append($('<em class="icon"></em>').addClass(expand).click(clickIcon));
|
||||
//td.append($('<span class="subheader"></span>').text('Estimated Ship Date: ' + row.ShipDate));
|
||||
//tr.append(td);
|
||||
//trs.push(tr);
|
||||
|
||||
//if (g > 0) {
|
||||
// tr.data('row', row);
|
||||
//} else {
|
||||
fillGroup(row, trs);
|
||||
//}
|
||||
if (row && row.Groups) {
|
||||
for (var i = 0; i < row.Groups.length; i++) {
|
||||
var dt = row.Groups[i];
|
||||
|
||||
for (var j = 0; j < dt.Children.length; j++) {
|
||||
var item = dt.Children[j];
|
||||
datas.push(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
tbody.append(trs).data('datas', datas);
|
||||
}
|
||||
$('#ul_shipdates').empty().append(shipdates);
|
||||
}
|
||||
|
||||
var query = {
|
||||
'ColumnSort': column_sort,
|
||||
'IsAsc': isasc,
|
||||
'TaskComplete': task_complete,
|
||||
'ShipDates': ship_dates
|
||||
};
|
||||
|
||||
filterQuery('GetFilterQGroups', JSON.stringify(query), function (data) {
|
||||
if (typeof data === 'string') {
|
||||
if (data == 'not login.') {
|
||||
_dialog.showAlert('Unknown error occurred. Please refresh.', 'Query Groups');
|
||||
} else {
|
||||
// err message
|
||||
_dialog.showAlert('Unknown error occurred. Please refresh:\n\n' + data, 'Query Groups');
|
||||
}
|
||||
} else {
|
||||
fillList(data);
|
||||
}
|
||||
//$('#mask_bg').css('height', $('#filterTable').height());
|
||||
}, function (err) {
|
||||
_dialog.showAlert('Unknown error occurred. Please refresh.', 'Query Groups');
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function OnCancel() {
|
||||
var inputs = $('#bodyFilters').find('input');
|
||||
for (var i = 0; i < inputs.length; i++) {
|
||||
var inp = $(inputs[i]);
|
||||
var dt = inp.data('original');
|
||||
if (dt !== undefined) {
|
||||
if (inp.attr('type') == 'checkbox') {
|
||||
inp.prop('checked', dt);
|
||||
} else {
|
||||
inp.val(dt);
|
||||
}
|
||||
}
|
||||
}
|
||||
var sels = $('#bodyFilters').find('select');
|
||||
for (var i = 0; i < sels.length; i++) {
|
||||
var inp = $(sels[i]);
|
||||
var dt = inp.data('original');
|
||||
if (dt !== undefined) {
|
||||
inp.val(dt);
|
||||
}
|
||||
}
|
||||
var txts = $('#bodyFilters').find('textarea');
|
||||
for (var i = 0; i < sels.length; i++) {
|
||||
var inp = $(sels[i]);
|
||||
var dt = inp.data('original');
|
||||
if (dt !== undefined) {
|
||||
inp.val(dt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function AlertLimit(input, limit) {
|
||||
if (!input || typeof input.val !== 'function')
|
||||
return true;
|
||||
if (input.val().length > limit) {
|
||||
input.addClass('red');
|
||||
alert('The field size cannot be greater than ' + limit);
|
||||
input.focus();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function AlertNumber(input) {
|
||||
if (!input || typeof input.val !== 'function')
|
||||
return true;
|
||||
if (isNaN(input.val())) {
|
||||
input.addClass('red');
|
||||
alert('The field must be a number.');
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function AlertInt(input) {
|
||||
if (!input || typeof input.val !== 'function')
|
||||
return true;
|
||||
if (isNaN(parseInt(input.val()))) {
|
||||
input.addClass('red');
|
||||
alert('The field must be an integer.');
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function AlertDate(input) {
|
||||
if (!input || typeof input.val !== 'function')
|
||||
return true;
|
||||
/*/ TODO
|
||||
if (isNaN(parseInt(input.val()))) {
|
||||
input.addClass('red');
|
||||
alert('The field must be an integer.');
|
||||
return true;
|
||||
}
|
||||
//*/
|
||||
return false;
|
||||
}
|
||||
|
||||
function OnRefresh() {
|
||||
var td = $('<td style="height:30px;line-height:30px;"></td>').attr('colspan', colspan);
|
||||
td.append('<span class="loading c-spin" style="margin-left:0;"></span>');
|
||||
td.append('<span style="margin-left:20px;">Loading...</span>');
|
||||
var tr = $('<tr></tr>').append(td);
|
||||
$('#bodyFilters').empty().append(tr);
|
||||
|
||||
enableUI(false);
|
||||
getFilterQGroups();
|
||||
}
|
||||
|
||||
function enableUI(flag, noloading) {
|
||||
$('#search_bar').prop('disabled', !flag);
|
||||
$('#button_save').prop('disabled', (!isdealer && !iscontractor) || !flag);
|
||||
$('#button_cancel').prop('disabled', (!isdealer && !iscontractor) || !flag);
|
||||
$('#button_refresh').prop('disabled', (!isdealer && !iscontractor) || !flag);
|
||||
|
||||
$('#mask_bg').css('display', flag ? 'none' : '');
|
||||
!noloading && $('#span_loading').css('display', flag ? 'none' : '');
|
||||
}
|
||||
|
||||
// expand
|
||||
var nowItem;
|
||||
var editor_saved;
|
||||
|
||||
function OnExpand(e) {
|
||||
editor_saved = undefined;
|
||||
nowItem = $(e).parents('tr').data('item'); //.next('tr');
|
||||
enableUI(false, true);
|
||||
var dialog = fillValue(nowItem);
|
||||
dialog.css('top', Math.max(0, ($(window).height() - dialog.height()) / 2)).show();
|
||||
}
|
||||
|
||||
var editor_changed;
|
||||
|
||||
function showEditorBg(flag) {
|
||||
$('#popup_editor').children('.maskbg').css('display', flag ? '' : 'none');
|
||||
}
|
||||
|
||||
function FillNext(n) {
|
||||
if (editor_changed) {
|
||||
showEditorBg(true);
|
||||
_dialog.showButtonDialog('Some values have changed. Would you like to save the changes?', 'Save', 'question', undefined, [{
|
||||
value: 'Cancel',
|
||||
func: function () {
|
||||
showEditorBg(false);
|
||||
}
|
||||
}, {
|
||||
value: 'No',
|
||||
func: function () {
|
||||
showEditorBg(false);
|
||||
doFillNext(n);
|
||||
editor_changed = false;
|
||||
}
|
||||
}, {
|
||||
value: 'Yes',
|
||||
func: function () {
|
||||
showEditorBg(false);
|
||||
SaveEditor(function () {
|
||||
doFillNext(n);
|
||||
});
|
||||
}
|
||||
}]);
|
||||
} else {
|
||||
doFillNext(n);
|
||||
}
|
||||
}
|
||||
|
||||
function doFillNext(n) {
|
||||
if (!nowItem) {
|
||||
return;
|
||||
}
|
||||
var tr;
|
||||
var datas = $('#bodyFilters').data('datas');
|
||||
if (!datas) {
|
||||
alert('Logical error: No data is found.');
|
||||
return;
|
||||
}
|
||||
var i = 0;
|
||||
for (; i < datas.length; i++) {
|
||||
if (nowItem.TaskID == datas[i].TaskID) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i >= datas.length) {
|
||||
alert('Logical error: Current item is not found.');
|
||||
return;
|
||||
}
|
||||
if (n > 0) {
|
||||
i++;
|
||||
if (i >= datas.length) {
|
||||
alert('This is the last one.');
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
i--;
|
||||
if (i < 0) {
|
||||
alert('This is the first one.');
|
||||
return;
|
||||
}
|
||||
}
|
||||
nowItem = datas[i];
|
||||
fillValue(nowItem);
|
||||
}
|
||||
function findNextDataTR(tr) {
|
||||
if (typeof tr.next !== 'function')
|
||||
return [];
|
||||
while ((tr = tr.next('tr')).length > 0) {
|
||||
if (tr.hasClass('subheader_tr'))
|
||||
continue;
|
||||
return tr;
|
||||
}
|
||||
return [];
|
||||
}
|
||||
function findPrevDataTR(tr) {
|
||||
if (typeof tr.prev !== 'function')
|
||||
return [];
|
||||
while ((tr = tr.prev('tr')).length > 0) {
|
||||
if (tr.hasClass('subheader_tr'))
|
||||
continue;
|
||||
return tr;
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
function fillValue(item) {
|
||||
var disableAll = !(isdealer || iscontractor);
|
||||
var disableContractor = iscontractor && !isdealer;
|
||||
var disableDealer = isdealer && !iscontractor;
|
||||
|
||||
var editor = $('#popup_editor');
|
||||
// top
|
||||
editor.find('.jobsite').text(item.CurrentJob);
|
||||
editor.find('.org_name').text(item.OrganizationName);
|
||||
editor.find('.eqp_code').text(item.OrgMachineCode);
|
||||
// second
|
||||
editor.find('.jobsite_contact').text(item.JobContact);
|
||||
editor.find('.contact_number').text(item.JobContactNumber);
|
||||
editor.find('.addrses1').text(item.JobAddress1);
|
||||
editor.find('.address2').text(item.JobAddress2);
|
||||
editor.find('.city').text(item.JobAddressCity);
|
||||
editor.find('.state').text(item.JobAddressState);
|
||||
editor.find('.zip').text(item.JobAddressZip);
|
||||
editor.find('.make').text(item.ManufactuerMake);
|
||||
editor.find('.model').text(item.Model);
|
||||
editor.find('.sn').text(item.SN);
|
||||
editor.find('.hours').text(item.CumulativeHours);
|
||||
editor.find('.service_needed').text(item.MachineTaskHourCheck);
|
||||
editor.find('.due').text(item.DiffToService);
|
||||
var dContractors = [];
|
||||
var dDealers = [];
|
||||
//dContractors.push(editor.find('.hours').val(item.CumulativeHours).prop('disabled', disableContractor)); // editable, double
|
||||
//dContractors.push(editor.find('.service_needed').val(item.MachineTaskHourCheck).prop('disabled', disableContractor)); // int
|
||||
//dContractors.push(editor.find('.due').val(item.DiffToService).prop('disabled', disableContractor)); // double
|
||||
dContractors.push(editor.find('.est_due_date').val(item.EstDueDate).prop('disabled', disableContractor)); // ESTServiceNeededBy
|
||||
dContractors.push(editor.find('.est_ship_date').val(item.EstShipDate).prop('disabled', disableContractor)); // ESTShopDate
|
||||
dContractors.push(editor.find('.ups_tracking').val(item.UPSTrackingNumber).prop('disabled', disableContractor));
|
||||
// third
|
||||
//editor.find('.hours_atservice').val(item.TaskCompletedHours);
|
||||
editor.find('.priority_val').val(item.Priority);
|
||||
editor.find('.wo_number').val(item.CustomerWO);
|
||||
editor.find('.alt_ship_address1').val(item.AlternateAddress1);
|
||||
editor.find('.alt_ship_address2').val(item.AlternateAddress2);
|
||||
editor.find('.alt_ship_city').val(item.AlternateAddressCity);
|
||||
editor.find('.alt_ship_state').val(item.AlternateAddressState);
|
||||
editor.find('.alt_ship_zip').val(item.AlternateAddressZip);
|
||||
editor.find('.alt_job').val(item.AltJob);
|
||||
editor.find('.alt_jobsite_contact').val(item.AltJobSiteContact);
|
||||
editor.find('.ship_notes').val(item.ShipNotes);
|
||||
// last
|
||||
editor.find('.req_jre').prop('checked', item.RequestJREToService);
|
||||
editor.find('.po').val(item.CustomerPO);
|
||||
editor.find('.po_approved').prop('checked', item.Approved);
|
||||
//dDealers.push(editor.find('.req_jre').prop('checked', item.RequestJREToService).prop('disabled', disableDealer));
|
||||
//dDealers.push(editor.find('.po').val(item.CustomerPO).prop('disabled', disableDealer));
|
||||
//dDealers.push(editor.find('.po_approved').prop('checked', item.Approved).prop('disabled', disableDealer));
|
||||
dContractors.push(editor.find('.task_complete').prop('checked', item.TaskComplete).prop('disabled', disableContractor));
|
||||
|
||||
for (var i = 0; i < dContractors.length; i++) {
|
||||
if (disableContractor) {
|
||||
dContractors[i].parents('.item').removeClass('editor');
|
||||
} else {
|
||||
dContractors[i].parents('.item').addClass('editor');
|
||||
}
|
||||
}
|
||||
for (var i = 0; i < dDealers.length; i++) {
|
||||
if (disableDealer) {
|
||||
dDealers[i].parents('.item').removeClass('editor');
|
||||
} else {
|
||||
dDealers[i].parents('.item').addClass('editor');
|
||||
}
|
||||
}
|
||||
|
||||
return editor;
|
||||
}
|
||||
|
||||
function SaveEditor(func) {
|
||||
if (!(isdealer || iscontractor)) {
|
||||
alert('You do not have permission to save it.')
|
||||
return;
|
||||
}
|
||||
|
||||
if (!nowItem) { // || typeof prevTr.data !== 'function'
|
||||
alert('Logic error, there is no data.');
|
||||
return;
|
||||
}
|
||||
var item = nowItem; //prevTr.data('item');
|
||||
if (!item) {
|
||||
alert('Data is undefined.');
|
||||
return;
|
||||
}
|
||||
|
||||
var editor = $('#popup_editor');
|
||||
//var inp = editor.find('.hours_atservice');
|
||||
//if (AlertNumber(inp)) { return; }
|
||||
//item.TaskCompletedHours = parseFloat(inp.val());
|
||||
item.Priority = editor.find('.priority_val').val();
|
||||
item.CustomerWO = editor.find('.wo_number').val(); // 20
|
||||
item.AlternateAddress1 = editor.find('.alt_ship_address1').val(); // 50
|
||||
item.AlternateAddress2 = editor.find('.alt_ship_address2').val(); // 50
|
||||
item.AlternateAddressCity = editor.find('.alt_ship_city').val(); // 50
|
||||
item.AlternateAddressState = editor.find('.alt_ship_state').val(); // 50
|
||||
item.AlternateAddressZip = editor.find('.alt_ship_zip').val(); // 50
|
||||
item.AltJob = editor.find('.alt_job').val(); // 200
|
||||
item.AltJobSiteContact = editor.find('.alt_jobsite_contact').val(); // 200
|
||||
item.ShipNotes = editor.find('.ship_notes').val(); // 250
|
||||
|
||||
if (isdealer) {
|
||||
//inp = editor.find('.hours');
|
||||
//if (AlertNumber(inp)) { return; }
|
||||
//item.CumulativeHours = parseFloat(inp.val());
|
||||
//inp = editor.find('.service_needed');
|
||||
//if (AlertInt(inp)) { return; }
|
||||
//item.MachineTaskHourCheck = parseInt(inp.val());
|
||||
//inp = editor.find('.due');
|
||||
//if (AlertNumber(inp)) { return; }
|
||||
//item.DiffToService = parseFloat(inp.val());
|
||||
item.EstDueDate = editor.find('.est_due_date').val();
|
||||
item.EstShipDate = editor.find('.est_ship_date').val();
|
||||
item.ESTServiceNeededBy = editor.find('.est_due_date').val();
|
||||
item.ESTShopDate = editor.find('.est_ship_date').val();
|
||||
item.UPSTrackingNumber = editor.find('.ups_tracking').val(); // 100
|
||||
item.TaskComplete = editor.find('.task_complete').prop('checked');
|
||||
}
|
||||
|
||||
if (iscontractor || isdealer) {
|
||||
item.RequestJREToService = editor.find('.req_jre').prop('checked');
|
||||
item.CustomerPO = editor.find('.po').val(); // 20
|
||||
item.Approved = editor.find('.po_approved').prop('checked');
|
||||
}
|
||||
|
||||
var json = JSON.stringify([item]);
|
||||
json = htmlencode(json);
|
||||
$('#mask_editor_bg').show();
|
||||
filterQuery('SaveFilterQ', json, function (data) {
|
||||
if (data == true) {
|
||||
editor_saved = true;
|
||||
editor_changed = false;
|
||||
if (typeof func == 'function') {
|
||||
func();
|
||||
} else {
|
||||
alert('Save data successful.');
|
||||
}
|
||||
} else {
|
||||
alert(data);
|
||||
}
|
||||
$('#mask_editor_bg').hide();
|
||||
}, function (err) {
|
||||
console.log(err);
|
||||
alert('Save error. Please update data as needed and try again.');
|
||||
$('#mask_editor_bg').hide();
|
||||
});
|
||||
|
||||
}
|
909
Site/js/gridlayout.js
Normal file
909
Site/js/gridlayout.js
Normal file
@ -0,0 +1,909 @@
|
||||
|
||||
var $layoutcolumnselector = function (grid) {
|
||||
this.title = GetTextByKey("P_GRID_XXXXXX", 'Layout');
|
||||
this.dialogId = 'dialog_layouts';
|
||||
$("#" + this.dialogId).remove();
|
||||
this.grid = grid;
|
||||
this.dialog = null;
|
||||
this.onOK = null;
|
||||
this.onDialogClosed = null;
|
||||
};
|
||||
|
||||
(function () {
|
||||
var __proto = $layoutcolumnselector.prototype;
|
||||
|
||||
var tbdata;
|
||||
|
||||
function initColumnsGrid(parent) {
|
||||
var divheader = $("<div style='font-size:14px;background-color:#fafafa;'></div>").appendTo(parent);
|
||||
var tbheader = $("<table style='width:100%;'></table>").appendTo(divheader);
|
||||
var trheader = $("<tr></tr>").appendTo(tbheader);
|
||||
trheader.append();
|
||||
var td = $("<td style='width:30px'></td>");
|
||||
trheader.append(td);
|
||||
$("<input type='checkbox' />").appendTo(td).on('click', function (e) {
|
||||
tbdata.find("input[type='checkbox']:enabled").prop("checked", $(e.target).prop("checked"));
|
||||
});
|
||||
trheader.append($("<td style='width:220px'></td>").text(GetTextByKey("P_GRID_COLUMN", "Column")));
|
||||
trheader.append($("<td style='width:220px'></td>").text(GetTextByKey("P_GRID_CAPTION", "Caption")));
|
||||
trheader.append($("<td></td>").text(GetTextByKey("P_XXXXXX", "Width")));
|
||||
|
||||
var divdata = $("<div style=' height: 400px; overflow: auto;line-height:30px;'></div>").appendTo(parent);
|
||||
tbdata = $("<table style='width:100%;'></table>").appendTo(divdata);
|
||||
}
|
||||
|
||||
function createDialog() {
|
||||
var dialog = $('<div class="dialog" style="display: none; width: 605px; height: 610px;min-width: 560px;line-height:30px;">').attr('id', this.dialogId);
|
||||
|
||||
var title = $('<div class="dialog-title"></div>').appendTo(dialog);
|
||||
title.append($('<span class="title"></span>').text(this.title));
|
||||
title.append('<em class="dialog-close"></em>');
|
||||
|
||||
var _this = this;
|
||||
var layoutOptionDiv = $('<div style="margin-left:10px;margin-right:10px;"></div>').appendTo(dialog);
|
||||
var rdoCurrentLayout = $("<input type='radio' id='rdoCurrentLayout' checked='checked' name='layoutoption' style='margin-left:20px;' />").on('click', function () {
|
||||
txtSearch && txtSearch.val("");
|
||||
showdata.call(_this, false);
|
||||
}).appendTo(layoutOptionDiv);
|
||||
$("<label for='rdoCurrentLayout'></label>").text(GetTextByKey("P_XXXXXX", "Show Current Layout")).appendTo(layoutOptionDiv);
|
||||
var rdoDefaultLayout = $("<input type='radio' id='rdoDefaultLayout' name='layoutoption' style='margin-left:60px;' />").on('click', function () {
|
||||
txtSearch && txtSearch.val("");
|
||||
showdata.call(_this, true);
|
||||
}).appendTo(layoutOptionDiv);
|
||||
$("<label for='rdoDefaultLayout'></label>").text(GetTextByKey("P_XXXXXX", "Show Default Layout")).appendTo(layoutOptionDiv);
|
||||
var chkDisplayedOnly = $("<input type='checkbox' id='chkDisplayedOnly' name='layoutoption' style='margin-left:60px;' />").on('click', function () {
|
||||
searchColumns(txtSearch.val().trim());
|
||||
}).appendTo(layoutOptionDiv);
|
||||
$("<label for='chkDisplayedOnly'></label>").text(GetTextByKey("P_XXXXXX", "Displayed Only")).appendTo(layoutOptionDiv);
|
||||
|
||||
$('<div style="margin-left:20px;"></div>').text(GetTextByKey("P_XXXXXX", "To move columns, drag and drop on column name.")).appendTo(dialog);
|
||||
|
||||
var searchDiv = $('<div style="margin-left:10px;margin-right:10px;"></div>').appendTo(dialog);
|
||||
var txtSearch = $("<input type='text' style='margin-left: 7px;width:95%;' />").appendTo(searchDiv);
|
||||
txtSearch.attr("placeholder", GetTextByKey("P_XXXXXX", "Search Columns"));
|
||||
txtSearch.on('input propertychange', function () {
|
||||
searchColumns($(this).val().trim());
|
||||
});
|
||||
txtSearch.on('keydown', function () {
|
||||
searchColumns($(this).val().trim());
|
||||
});
|
||||
|
||||
var columnListDiv = $('<div style="width: 580px; height: 440px; margin: 5px 10px 4px 10px;overflow:auto;"></div>').appendTo(dialog);
|
||||
|
||||
var dialogFunction = $('<div class="dialog-func"></div>').appendTo(dialog);
|
||||
$('<input type="button" value="' + GetTextByKey("P_GRID_CANCEL", "Cancel") + '" class="dialog-close" />').appendTo(dialogFunction);
|
||||
$('<input type="button" value="' + GetTextByKey("P_GRID_OK", "OK") + '" />').on('click', onOKClick.bind(this)).appendTo(dialogFunction);
|
||||
$('<div class="clear"></div>').appendTo(dialogFunction);
|
||||
|
||||
$('<div class="maskbg" style="display: none"><div class="loading_icon icon c-spin"></div></div>').appendTo(dialog);
|
||||
|
||||
// init
|
||||
initColumnsGrid.call(this, columnListDiv);
|
||||
$(document.body).append(dialog);
|
||||
|
||||
dialog.dialog(this.onDialogClosed);
|
||||
return dialog;
|
||||
}
|
||||
|
||||
function searchColumns(filter) {
|
||||
var trs = tbdata.find("tr");
|
||||
for (var i = 0; i < trs.length; i++) {
|
||||
var tr = $(trs[i]);
|
||||
var rowInfo = tr.data("rowInfo");
|
||||
if (rowInfo) {
|
||||
var col = rowInfo.ColumnData;
|
||||
var colinfo = {
|
||||
'Column': col.OriginalCaption,
|
||||
'Caption': rowInfo.txtCaption.val().trim()
|
||||
}
|
||||
|
||||
if ((!$("#chkDisplayedOnly").prop("checked") || rowInfo.chkSelected.prop("checked"))
|
||||
&& (colinfo.Column.toLowerCase().indexOf(filter.toLowerCase()) >= 0 || colinfo.Caption.toLowerCase().indexOf(filter.toLowerCase()) >= 0))
|
||||
tr.show();
|
||||
else
|
||||
tr.hide();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
__proto.showLayoutSelector = function (topRatio, force) {
|
||||
var dialog;
|
||||
if (force) {
|
||||
$('#' + this.dialogId).remove();
|
||||
dialog = createDialog.call(this);
|
||||
} else {
|
||||
dialog = $('#' + this.dialogId);
|
||||
if (!dialog.length) {
|
||||
dialog = createDialog.call(this);
|
||||
}
|
||||
}
|
||||
this.dialog = dialog;
|
||||
dialog.attr('init', '1').showDialog().css({
|
||||
'top': (document.documentElement.clientHeight - $('#dialog_machines').height()) / (topRatio || 3),
|
||||
'left': (document.documentElement.clientWidth - $('#dialog_machines').width()) / 2
|
||||
});
|
||||
showdata.call(this, false);
|
||||
};
|
||||
|
||||
function showdata(showall) {
|
||||
if (!this.grid.allcolumns || this.grid.allcolumns.length <= 0)
|
||||
return;
|
||||
|
||||
var tmpColumns = [];
|
||||
if (showall) {
|
||||
for (var j = 0; j < this.grid.allcolumns.length; j++) {
|
||||
var dc = this.grid.allcolumns[j];
|
||||
|
||||
dc = $.extend(true, {}, dc);
|
||||
dc.OriginalCaption = dc.caption;
|
||||
dc.UserCaption = "";
|
||||
dc.Width = dc.width;
|
||||
dc.Selected = dc.visible !== false;
|
||||
tmpColumns.push(dc);
|
||||
|
||||
}
|
||||
}
|
||||
else if (this.grid.columns && this.grid.columns.length > 0) {
|
||||
for (var i = 0; i < this.grid.columns.length; i++) {
|
||||
var cc = $.extend(true, {}, this.grid.columns[i]);
|
||||
|
||||
//if (!cc.alwaysshow) {
|
||||
cc.Width = cc.width;
|
||||
cc.Selected = cc.visible !== false;
|
||||
tmpColumns.push(cc);
|
||||
//}
|
||||
}
|
||||
|
||||
for (var j = 0; j < this.grid.allcolumns.length; j++) {
|
||||
var dc = this.grid.allcolumns[j];
|
||||
//if (dc.alwaysshow) continue;
|
||||
|
||||
var selected = false;
|
||||
for (var i = 0; i < tmpColumns.length; i++) {
|
||||
var tc = tmpColumns[i];
|
||||
if (tc.name == dc.name) {
|
||||
selected = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!selected) {
|
||||
dc = $.extend(true, {}, dc);
|
||||
dc.OriginalCaption = dc.caption;
|
||||
dc.UserCaption = "";
|
||||
dc.Width = dc.width;
|
||||
dc.Selected = false;
|
||||
tmpColumns.push(dc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tbdata.empty();
|
||||
for (var i = 0; i < tmpColumns.length; i++) {
|
||||
var c = tmpColumns[i];
|
||||
var rowInfo = {};
|
||||
rowInfo.ColumnData = c;
|
||||
var tr = $("<tr></tr>").appendTo(tbdata).data("rowInfo", rowInfo);
|
||||
|
||||
var td = $("<td style='width:30px'></td>").appendTo(tr);
|
||||
rowInfo.chkSelected = $("<input type='checkbox' />").appendTo(td);
|
||||
rowInfo.chkSelected.prop("checked", c.Selected);
|
||||
if (c.alwaysshow)
|
||||
rowInfo.chkSelected.prop("checked", true).prop("disabled", true);
|
||||
|
||||
td = $("<td style='width:220px'></td>").appendTo(tr);
|
||||
rowInfo.txtOriginalCaption = $("<span></span>").appendTo(td);
|
||||
rowInfo.txtOriginalCaption.text(c.alwaysshow ? c.text : c.OriginalCaption);
|
||||
if (c.name === "Selected")
|
||||
rowInfo.txtOriginalCaption.text('\uf0c8');
|
||||
if (c.alwaysshow)
|
||||
rowInfo.txtOriginalCaption.addClass('icon-col').css('cursor', 'default');
|
||||
|
||||
td = $("<td style='width:220px'></td>").appendTo(tr);
|
||||
rowInfo.txtCaption = $("<input type='text' style='width:210px' maxlength='200' />").appendTo(td);
|
||||
rowInfo.txtCaption.val(c.UserCaption);
|
||||
if (c.alwaysshow)
|
||||
rowInfo.txtCaption.prop("disabled", true);
|
||||
|
||||
td = $("<td></td>").appendTo(tr);
|
||||
rowInfo.txtWidth = $("<input type='text' style='width:70px' maxlength='6' />").appendTo(td);
|
||||
rowInfo.txtWidth.val(c.Width || c.width);
|
||||
if (c.alwaysshow)
|
||||
rowInfo.txtWidth.prop("disabled", true);
|
||||
|
||||
if (c.name !== "Selected")
|
||||
bindDrag(tr);
|
||||
}
|
||||
}
|
||||
|
||||
var draggingrow = null;
|
||||
function bindDrag(tr) {//拖动调整顺序
|
||||
tr.attr('draggable', true);
|
||||
tr.bind('dragstart', function (e) {
|
||||
draggingrow = $(this);
|
||||
});
|
||||
tr.find('input').attr('draggable', true).bind('dragstart', function (e) {
|
||||
e.originalEvent.preventDefault()
|
||||
});
|
||||
tr.bind('dragend', function (e) {
|
||||
draggingrow = null;
|
||||
});
|
||||
tr.bind('dragover', function (e) {
|
||||
e.originalEvent.preventDefault()
|
||||
});
|
||||
tr.bind('drop', function (e) {
|
||||
var t = $(this);
|
||||
if (t.is(draggingrow))
|
||||
return;
|
||||
var t = $(this);
|
||||
var after = e.originalEvent.clientY > t.offset().top + t.height() / 2;
|
||||
if (after) {
|
||||
t.after(draggingrow);
|
||||
}
|
||||
else {
|
||||
t.before(draggingrow);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function onOKClick() {
|
||||
var colinfos = [];
|
||||
var trs = tbdata.find("tr");
|
||||
for (var i = 0; i < trs.length; i++) {
|
||||
var tr = $(trs[i]);
|
||||
var rowInfo = tr.data("rowInfo");
|
||||
var col = rowInfo.ColumnData;
|
||||
if (rowInfo) {
|
||||
var sort = 0;
|
||||
if (col.sortDesc != undefined)
|
||||
sort = col.sortDesc ? 2 : 1;
|
||||
var colinfo = {
|
||||
'Visible': rowInfo.chkSelected.prop("checked"),
|
||||
'ColumnKey': col.name,
|
||||
'Caption': $.trim(rowInfo.txtCaption.val()),
|
||||
'Width': $.trim(rowInfo.txtWidth.val()),
|
||||
'Sort': sort
|
||||
}
|
||||
if (isNaN(colinfo.Width) || eval(colinfo.Width) <= 0)
|
||||
colinfo.Width = col.width;
|
||||
colinfos.push(colinfo);
|
||||
}
|
||||
}
|
||||
|
||||
if (colinfos.length == 0) {
|
||||
showAlert(GetTextByKey("P_GRID_PLEASESELECTATLEASTONECOLUMN", "Please select at least one column."), GetTextByKey("P_GRID_XXXXXX", 'Layout'));
|
||||
return;
|
||||
}
|
||||
|
||||
this.onOK && this.onOK(colinfos);
|
||||
}
|
||||
})();
|
||||
|
||||
var $layoutsavedialog = function (grid, layoutid, type) {
|
||||
this.title = GetTextByKey("P_GRID_XXXXXX", 'Save Layout');
|
||||
this.type = type;
|
||||
this.dialogId = 'dialog_savelayout';
|
||||
$("#" + this.dialogId).remove();
|
||||
this.grid = grid;
|
||||
this.layoutid = layoutid;
|
||||
this.dialog = null;
|
||||
this.onOK = null;
|
||||
this.onDialogClosed = null;
|
||||
};
|
||||
|
||||
(function () {
|
||||
var __proto = $layoutsavedialog.prototype;
|
||||
|
||||
var txtLayoutName;
|
||||
var chkMyDefault;
|
||||
var chkPublic;
|
||||
var chkCompanyDefault;
|
||||
|
||||
var _this = null;
|
||||
__proto.showSaveLayoutDialog = function (topRatio, force) {
|
||||
_this = this;
|
||||
var dialog;
|
||||
if (force) {
|
||||
$('#' + this.dialogId).remove();
|
||||
dialog = createSaveLayoutDialog.call(this);
|
||||
} else {
|
||||
dialog = $('#' + this.dialogId);
|
||||
if (!dialog.length) {
|
||||
dialog = createSaveLayoutDialog.call(this);
|
||||
}
|
||||
}
|
||||
this.dialog = dialog;
|
||||
dialog.attr('init', '1').showDialog().css({
|
||||
'top': (document.documentElement.clientHeight - $('#dialog_machines').height()) / (topRatio || 3),
|
||||
'left': (document.documentElement.clientWidth - $('#dialog_machines').width()) / 2
|
||||
});
|
||||
|
||||
getAllGridLayoutsForSave(this.layoutid);
|
||||
};
|
||||
|
||||
function createSaveLayoutDialog() {
|
||||
var dialog = $('<div class="dialog" style="display: none; width: 440px; height: 220px;min-width:440px;line-height:30px;">').attr('id', this.dialogId);
|
||||
|
||||
var title = $('<div class="dialog-title"></div>').appendTo(dialog);
|
||||
title.append($('<span class="title"></span>').text(this.title));
|
||||
title.append('<em class="dialog-close"></em>');
|
||||
|
||||
var layoutNameDiv = $('<div style="margin-left:10px;margin-right:10px;margin-top:10px;"></div>').appendTo(dialog);
|
||||
layoutNameDiv.append($('<span style="margin-left:10px;"></span>').text(GetTextByKey("P_XXXXXX", "Layout Name:")));
|
||||
txtLayoutName = $("<input type='text' style='width:320px;margin-left:5px;' maxlength='200' />").appendTo(layoutNameDiv);
|
||||
if (currentLayout && this.type == 1) {//type == 1 在列表上直接保存
|
||||
if (!currentLayout.IsPublic || IsAdmin)
|
||||
txtLayoutName.val(currentLayout.LayoutName || "");
|
||||
}
|
||||
|
||||
var layoutAttrDiv = $('<div style="margin-left:10px;margin-right:10px;"></div>').appendTo(dialog);
|
||||
chkMyDefault = $("<input type='checkbox' id='chkMyDefault' style='margin-left: 83px;' />").appendTo(layoutAttrDiv);
|
||||
$("<label for='chkMyDefault'></label>").text(GetTextByKey("P_XXXXXX", "Save as my Default")).appendTo(layoutAttrDiv);
|
||||
|
||||
if (IsAdmin) {
|
||||
layoutAttrDiv = $('<div style="margin-left:10px;margin-right:10px;"></div>').appendTo(dialog);
|
||||
chkPublic = $("<input type='checkbox' id='chkPublic' style='margin-left: 83px;' />").appendTo(layoutAttrDiv);
|
||||
$("<label for='chkPublic'></label>").text(GetTextByKey("P_XXXXXX", "Make Public")).appendTo(layoutAttrDiv);
|
||||
|
||||
layoutAttrDiv = $('<div style="margin-left:10px;margin-right:10px;"></div>').appendTo(dialog);
|
||||
chkCompanyDefault = $("<input type='checkbox' id='chkCompanyDefault' style='margin-left: 83px;' />").appendTo(layoutAttrDiv);
|
||||
$("<label for='chkCompanyDefault'></label>").text(GetTextByKey("P_XXXXXX", "Save as Company Default")).appendTo(layoutAttrDiv);
|
||||
|
||||
chkMyDefault.on('click', function (e) {
|
||||
if (chkMyDefault.prop("checked")) {
|
||||
chkPublic.prop("checked", false);
|
||||
chkCompanyDefault.prop("checked", false);
|
||||
}
|
||||
});
|
||||
|
||||
chkPublic.on('click', function (e) {
|
||||
if (chkPublic.prop("checked"))
|
||||
chkMyDefault.prop("checked", false);
|
||||
else
|
||||
chkCompanyDefault.prop("checked", false);
|
||||
});
|
||||
|
||||
chkCompanyDefault.on('click', function (e) {
|
||||
if (chkCompanyDefault.prop("checked")) {
|
||||
chkMyDefault.prop("checked", false);
|
||||
chkPublic.prop("checked", true);
|
||||
}
|
||||
});
|
||||
|
||||
if (currentLayout && this.type == 1) {//type == 1 在列表上直接保存
|
||||
if (!currentLayout.IsPublic)
|
||||
chkMyDefault.prop('checked', currentLayout.IsDefault);
|
||||
if (IsAdmin) {
|
||||
chkPublic.prop('checked', currentLayout.IsPublic);
|
||||
if (currentLayout.IsPublic)
|
||||
chkCompanyDefault.prop('checked', currentLayout.IsDefault);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
dialog.css('height', 140);
|
||||
}
|
||||
|
||||
var dialogFunction = $('<div class="dialog-func"></div>').appendTo(dialog);
|
||||
$('<input type="button" value="' + GetTextByKey("P_GRID_CANCEL", "Cancel") + '" class="dialog-close" />').appendTo(dialogFunction);
|
||||
$('<input type="button" value="' + GetTextByKey("P_GRID_XXXXXX", "Save Layout") + '" />').on('click', onSaveLayoutClick.bind(this)).appendTo(dialogFunction);
|
||||
$('<div class="clear"></div>').appendTo(dialogFunction);
|
||||
|
||||
$('<div class="maskbg" style="display: none"></div>').appendTo(dialog);
|
||||
|
||||
$(document.body).append(dialog);
|
||||
|
||||
dialog.dialog(this.onDialogClosed);
|
||||
return dialog;
|
||||
}
|
||||
|
||||
function onSaveLayoutClick() {
|
||||
var layoutinfo = {
|
||||
LayoutName: txtLayoutName.val().trim(),
|
||||
IsPublic: chkPublic == null ? false : chkPublic.prop("checked"),
|
||||
};
|
||||
if (!layoutinfo.LayoutName || layoutinfo.LayoutName.trim() == '') {
|
||||
showAlert(GetTextByKey("P_GRID_XXXXXX", "Layout name is required."), GetTextByKey("P_GRID_XXXXXX", 'Layout'));
|
||||
return;
|
||||
}
|
||||
if (layoutinfo.IsPublic)
|
||||
layoutinfo.IsDefault = chkCompanyDefault == null ? false : chkCompanyDefault.prop("checked");
|
||||
else
|
||||
layoutinfo.IsDefault = chkMyDefault.prop("checked");
|
||||
|
||||
var overwrite = false;//private and name not changed, overwrite without prompt
|
||||
if (currentLayout && !currentLayout.IsPublic && layoutinfo.IsPublic && currentLayout.LayoutName == layoutinfo.LayoutName)
|
||||
overwrite = true;
|
||||
|
||||
this.onOK && this.onOK(layoutinfo, overwrite);
|
||||
}
|
||||
|
||||
function getAllGridLayoutsForSave(layoutid) {
|
||||
_network.commonpagequery(15, layoutid, function (data) {//getGridLayouts
|
||||
if (typeof data !== 'string') {
|
||||
loadLayoutTip(data);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function loadLayoutTip(data) {
|
||||
$("#div_layout_tooltip").remove();
|
||||
|
||||
if (data.length == 0) return;
|
||||
var text = "";
|
||||
var priLayouts = [];
|
||||
var pubLayouts = [];
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
var item = data[i];
|
||||
if (!item) continue;
|
||||
|
||||
var ls = item.IsPublic ? pubLayouts : priLayouts;
|
||||
if (item.IsDefault)
|
||||
ls.splice(0, 0, item);
|
||||
else
|
||||
ls.push(item);
|
||||
}
|
||||
|
||||
if (priLayouts.length > 0) {
|
||||
text += GetTextByKey("P_XXXXXX", "My Saved Layouts");
|
||||
for (var i = 0; i < priLayouts.length; i++) {
|
||||
var item = priLayouts[i];
|
||||
text += "<br/> " + item.LayoutName + (item.IsDefault ? " *" : "");
|
||||
}
|
||||
}
|
||||
|
||||
if (IsAdmin) {
|
||||
if (pubLayouts.length > 0) {
|
||||
if (text != "")
|
||||
text += "<br/>";
|
||||
text += GetTextByKey("P_XXXXXX", "Company Layouts");
|
||||
for (var i = 0; i < pubLayouts.length; i++) {
|
||||
var item = pubLayouts[i];
|
||||
text += "<br/> " + item.LayoutName + (item.IsDefault ? " *" : "");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var div = $("<div id='div_layout_tooltip' class='div_tooltip' style='display:none; '></div>").html(text);
|
||||
var left = _this.dialog.offset().left + _this.dialog.width() + 2;
|
||||
var top = _this.dialog.offset().top;
|
||||
div.css({ 'display': '', 'left': left, 'top': top, 'max-height': 320, 'max-width': 240, 'overflow': 'hidden' });
|
||||
$(window.document.body).append(div);
|
||||
}
|
||||
})();
|
||||
|
||||
|
||||
|
||||
var $managelayoutdialog = function (layoutid) {
|
||||
this.title = GetTextByKey("P_GRID_XXXXXX", 'Manage Layout');
|
||||
this.dialogId = 'dialog_managelayout';
|
||||
$("#" + this.dialogId).remove();
|
||||
this.layoutid = layoutid;
|
||||
this.dialog = null;
|
||||
this.onDialogClosed = null;
|
||||
};
|
||||
|
||||
(function () {
|
||||
var __proto = $managelayoutdialog.prototype;
|
||||
|
||||
var myLayoutsDiv = null;
|
||||
var companyLayoutsDiv = null;
|
||||
|
||||
var _this = null;
|
||||
__proto.showManageLayoutDialog = function (topRatio, force) {
|
||||
var dialog;
|
||||
_this = this;
|
||||
if (force) {
|
||||
$('#' + this.dialogId).remove();
|
||||
dialog = createManageLayoutDialog.call(this);
|
||||
} else {
|
||||
dialog = $('#' + this.dialogId);
|
||||
if (!dialog.length) {
|
||||
dialog = createManageLayoutDialog.call(this);
|
||||
}
|
||||
}
|
||||
this.dialog = dialog;
|
||||
dialog.attr('init', '1').showDialog().css({
|
||||
'top': (document.documentElement.clientHeight - $('#dialog_machines').height()) / (topRatio || 3),
|
||||
'left': (document.documentElement.clientWidth - $('#dialog_machines').width()) / 2
|
||||
});
|
||||
|
||||
getAllGridLayoutsForManage(this.layoutid);
|
||||
};
|
||||
|
||||
function createManageLayoutDialog() {
|
||||
var dialog = $('<div class="dialog" style="display: none; width: 540px; height: 440px;min-width:440px;line-height:30px;">').attr('id', this.dialogId);
|
||||
|
||||
var title = $('<div class="dialog-title"></div>').appendTo(dialog);
|
||||
title.append($('<span class="title"></span>').text(this.title));
|
||||
title.append('<em class="dialog-close"></em>');
|
||||
|
||||
var content = $('<div style="height: 360px;overflow:auto;">').appendTo(dialog);
|
||||
|
||||
var labelDiv = $('<div style="margin-left:10px;margin-right:10px;margin-top:10px;"></div>').appendTo(content);
|
||||
labelDiv.append($('<span style="margin-left:10px;"></span>').text(GetTextByKey("P_XXXXXX", "My Saved Layouts")));
|
||||
myLayoutsDiv = $('<div style="margin-left:10px;margin-right:10px;margin-top:10px;"></div>').appendTo(content);
|
||||
|
||||
if (IsAdmin) {
|
||||
labelDiv = $('<div style="margin-left:10px;margin-right:10px;margin-top:10px;"></div>').appendTo(content);
|
||||
labelDiv.append($('<span style="margin-left:10px;"></span>').text(GetTextByKey("P_XXXXXX", "Company Layouts")));
|
||||
companyLayoutsDiv = $('<div style="margin-left:10px;margin-right:10px;margin-top:10px;"></div>').appendTo(content);
|
||||
}
|
||||
|
||||
var dialogFunction = $('<div class="dialog-func"></div>').appendTo(dialog);
|
||||
$('<input type="button" value="' + GetTextByKey("P_GRID_OK", "OK") + '" class="dialog-close" />').appendTo(dialogFunction);
|
||||
$('<div class="clear"></div>').appendTo(dialogFunction);
|
||||
|
||||
$('<div class="maskbg" style="display: none"></div>').appendTo(dialog);
|
||||
|
||||
$(document.body).append(dialog);
|
||||
|
||||
dialog.dialog(this.onDialogClosed);
|
||||
return dialog;
|
||||
}
|
||||
|
||||
function getAllGridLayoutsForManage(layoutid) {
|
||||
_network.commonpagequery(15, layoutid, function (data) {//getGridLayouts
|
||||
if (typeof data !== 'string') {
|
||||
var priLayouts = [];
|
||||
var pubLayouts = [];
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
var item = data[i];
|
||||
if (!item) continue;
|
||||
|
||||
var ls = item.IsPublic ? pubLayouts : priLayouts;
|
||||
if (item.IsDefault)
|
||||
ls.splice(0, 0, item);
|
||||
else
|
||||
ls.push(item);
|
||||
}
|
||||
|
||||
if (priLayouts.length > 0) {
|
||||
for (var i = 0; i < priLayouts.length; i++) {
|
||||
var item = priLayouts[i];
|
||||
var div = $('<div style="padding-left:50px;clear:both;"></div>');
|
||||
div.append($('<span style="width:400px;overflow:hidden;"></span>').text(item.LayoutName + (item.IsDefault ? " *" : "")));
|
||||
var icon = $('<span class="sbutton icondelete" style="float:right;padding: 0px 5px 0px 10px;"></span>').appendTo(div);
|
||||
icon.on('click', item, function (e) {
|
||||
deleteLayout(e.data.ID, $(e.target).parent());
|
||||
});
|
||||
myLayoutsDiv.append(div);
|
||||
}
|
||||
}
|
||||
|
||||
if (IsAdmin) {
|
||||
if (pubLayouts.length > 0) {
|
||||
for (var i = 0; i < pubLayouts.length; i++) {
|
||||
var item = pubLayouts[i];
|
||||
var div = $('<div style="padding-left:50px;clear:both;"></div>');
|
||||
div.append($('<span style="width:400px;overflow:hidden;"></span>').text(item.LayoutName + (item.IsDefault ? " *" : "")));
|
||||
var icon = $('<span class="sbutton icondelete" style="float:right;padding: 0px 5px 0px 10px;"></span>').appendTo(div);
|
||||
icon.on('click', item, function (e) {
|
||||
deleteLayout(e.data.ID, $(e.target).parent());
|
||||
});
|
||||
companyLayoutsDiv.append(div);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function deleteLayout(id, div) {
|
||||
var msg = GetTextByKey("P_GRID_XXXXXX", 'Are you sure you want to delete this layout?');
|
||||
var title = GetTextByKey("P_GRID_XXXXXX", 'Layout');
|
||||
showLayoutConfirm(_this.dialog, msg, title, function (e) {
|
||||
div.remove();
|
||||
_network.commonpagequery(9, id, function (data) { }, function (e) { });
|
||||
}, function (e) {
|
||||
}, function (e) {
|
||||
});
|
||||
}
|
||||
})();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/***************************Public Method********************************************/
|
||||
function CreateLayoutMenus(sender, layoutid, grid) {
|
||||
hidePanels();//hide other menu
|
||||
$("#layout_panel_holder").remove();// remove layout_panel_holder
|
||||
|
||||
var panel_holder = $('<div id="layout_panel_holder" class="panel_holder"></div>').appendTo(document.body);
|
||||
var funmenu = $('<div class="menupanel panel" style="box-shadow: rgba(0, 0, 0, 0.24) 0px 4px 8px 0px;"></div>');
|
||||
panel_holder.append(funmenu);
|
||||
var ulmenus = $('<ul class="lefttitlemenu_ul" style="line-height:32px;max-height:480px;max-width:400px; overflow: hidden auto;"></ul>');
|
||||
funmenu.append(ulmenus);
|
||||
|
||||
var li = $('<li style="line-height:32px;"></li>').text(GetTextByKey("P_GRID_XXXXXX", 'Update Layout'));
|
||||
ulmenus.append(li);
|
||||
li.on('click', function () {
|
||||
ShowSelectLayoutColumnsDialog(layoutid, grid);
|
||||
});
|
||||
li = $('<li style="line-height:32px;"></li>').text(GetTextByKey("P_GRID_XXXXXX", 'Save Layout'));
|
||||
ulmenus.append(li);
|
||||
li.on('click', function () {
|
||||
ShowSaveLayoutDialog(null, null, layoutid, grid, 1);
|
||||
});
|
||||
li = $('<li style="line-height:32px;"></li>').text(GetTextByKey("P_GRID_XXXXXX", 'Manage Layout'));
|
||||
ulmenus.append(li);
|
||||
li.on('click', function () {
|
||||
ShowManageLayoutDialog(layoutid);
|
||||
});
|
||||
|
||||
var left = $(sender).offset().left;
|
||||
var top = $(sender).offset().top + $(sender).height();
|
||||
var minwidth = 150;
|
||||
if (minwidth < $(sender).width())
|
||||
minwidth = $(sender).width()
|
||||
panel_holder.css({
|
||||
'opacity': 0,
|
||||
'left': left,
|
||||
'right': 'auto',
|
||||
'top': top + 4,
|
||||
'min-width': minwidth,
|
||||
|
||||
}).show().animate({ 'opacity': 1 }, 100);
|
||||
|
||||
getAllGridLayouts(layoutid, grid, ulmenus);
|
||||
}
|
||||
|
||||
function getAllGridLayouts(layoutid, grid, ulmenus) {
|
||||
_network.commonpagequery(15, layoutid, function (data) {//getGridLayouts
|
||||
if (typeof data !== 'string') {
|
||||
var priLayouts = [];
|
||||
var pubLayouts = [];
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
var item = data[i];
|
||||
if (!item) continue;
|
||||
|
||||
var ls = item.IsPublic ? pubLayouts : priLayouts;
|
||||
if (item.IsDefault)
|
||||
ls.splice(0, 0, item);
|
||||
else
|
||||
ls.push(item);
|
||||
}
|
||||
|
||||
if (priLayouts.length > 0) {
|
||||
var li = $('<li style="line-height:unset;height:1px;padding: 0; margin: 0.35em 0; border-bottom: 1px solid #d0d0d0;"></li>');
|
||||
ulmenus.append(li);
|
||||
for (var i = 0; i < priLayouts.length; i++) {
|
||||
var item = priLayouts[i];
|
||||
var li = $('<li></li>');
|
||||
if (item.LayoutName.length > 35) {
|
||||
li.text(item.LayoutName.substring(0, 35) + '...' + (item.IsDefault ? " *" : ""));
|
||||
li.attr("title", item.LayoutName);
|
||||
}
|
||||
else
|
||||
li.text(item.LayoutName + (item.IsDefault ? " *" : ""));
|
||||
li.on('click', item, function (e) {
|
||||
currentLayout = e.data;
|
||||
showGridLayout(grid, JSON.parse(e.data.Layout), OnRefresh);
|
||||
});
|
||||
ulmenus.append(li);
|
||||
}
|
||||
}
|
||||
|
||||
if (pubLayouts.length > 0) {
|
||||
var li = $('<li style="line-height:unset;height:1px;padding: 0; margin: 0.35em 0; border-bottom: 1px solid #d0d0d0;"></li>');
|
||||
ulmenus.append(li);
|
||||
for (var i = 0; i < pubLayouts.length; i++) {
|
||||
var item = pubLayouts[i];
|
||||
var li = $('<li></li>');
|
||||
if (item.LayoutName.length > 35) {
|
||||
li.text(item.LayoutName.substring(0, 35) + '...' + (item.IsDefault ? " *" : ""));
|
||||
li.attr("title", item.LayoutName);
|
||||
}
|
||||
else
|
||||
li.text(item.LayoutName + (item.IsDefault ? " *" : ""));
|
||||
li.on('click', item, function (e) {
|
||||
currentLayout = e.data;
|
||||
showGridLayout(grid, JSON.parse(e.data.Layout), OnRefresh);
|
||||
});
|
||||
ulmenus.append(li);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function ShowSelectLayoutColumnsDialog(layoutid, grid) {
|
||||
showmaskbg(true);
|
||||
|
||||
var dialogColumns = new $layoutcolumnselector(grid);
|
||||
dialogColumns.onDialogClosed = function () {
|
||||
showmaskbg(false);
|
||||
};
|
||||
dialogColumns.onOK = function (colinfos) {
|
||||
dialogColumns.dialog.find('.maskbg').css('display', '');
|
||||
ShowSaveLayoutDialog(dialogColumns, colinfos, layoutid, grid, 0, function () {
|
||||
currentLayout = currentLayout || {};
|
||||
currentLayout.Layout = JSON.stringify(colinfos);
|
||||
showGridLayout(grid, colinfos, OnRefresh);
|
||||
dialogColumns && dialogColumns.dialog.hideDialog();
|
||||
showmaskbg(false);
|
||||
});
|
||||
};
|
||||
dialogColumns.showLayoutSelector(3, true);
|
||||
}
|
||||
|
||||
function ShowSaveLayoutDialog(sender, colinfos, layoutid, grid, type, next) {
|
||||
showmaskbg(true);
|
||||
|
||||
var dialogSaveLayout = new $layoutsavedialog(grid, layoutid, type);
|
||||
dialogSaveLayout.onDialogClosed = function () {
|
||||
if (sender)
|
||||
sender.dialog.find('.maskbg').css('display', 'none');
|
||||
else
|
||||
showmaskbg(false);
|
||||
$("#div_layout_tooltip").remove();
|
||||
};
|
||||
dialogSaveLayout.onOK = function (layoutinfo, overwrite) {
|
||||
saveGridLayout(dialogSaveLayout.dialog, layoutid, grid, layoutinfo, colinfos, next, overwrite);
|
||||
};
|
||||
dialogSaveLayout.showSaveLayoutDialog(3, true);
|
||||
}
|
||||
|
||||
function ShowManageLayoutDialog(layoutid) {
|
||||
showmaskbg(true);
|
||||
|
||||
var dialogManageLayout = new $managelayoutdialog(layoutid);
|
||||
dialogManageLayout.onDialogClosed = function () {
|
||||
showmaskbg(false);
|
||||
};
|
||||
dialogManageLayout.showManageLayoutDialog(3, true);
|
||||
}
|
||||
|
||||
var currentLayout = null;
|
||||
function getGridLayout(layoutid, grid, next) {
|
||||
_network.commonpagequery(7, layoutid, function (data) {//GetGridLayout
|
||||
currentLayout = data;
|
||||
showGridLayout(grid, data == null ? null : JSON.parse(data.Layout), next);
|
||||
});
|
||||
}
|
||||
|
||||
function showGridLayout(grid, columninfos, next) {
|
||||
var allColumns = $.extend(true, [], grid.allcolumns);
|
||||
for (var i = 0; i < allColumns.length; i++) {
|
||||
allColumns[i].OriginalCaption = allColumns[i].caption;
|
||||
if (allColumns[i].alwaysshow && columninfos && columninfos.length > 0) {//new alwaysshow column
|
||||
var exists = false;
|
||||
for (var j = 0; j < columninfos.length; j++) {
|
||||
if (allColumns[i].name == columninfos[j].ColumnKey) {
|
||||
exists = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!exists)
|
||||
columninfos.push({ ColumnKey: allColumns[i].name, Caption: allColumns[i].caption, Width: allColumns[i].width });
|
||||
}
|
||||
}
|
||||
|
||||
grid.sortIndex = -1;
|
||||
var tmpColumns = allColumns;
|
||||
if (columninfos && columninfos.length > 0) {
|
||||
tmpColumns = [];
|
||||
for (var i = 0; i < columninfos.length; i++) {
|
||||
var tmpcol = readColumnWidthSort(allColumns, columninfos[i]);
|
||||
if (tmpcol) {
|
||||
if (tmpcol.Sort != undefined && tmpcol.Sort != 0) {
|
||||
if (grid.$refs && grid.$refs.grid) {//datagrid:vue
|
||||
grid.$refs.grid.sortKey = tmpcol.name;
|
||||
grid.$refs.grid.sortDirection = tmpcol.Sort;
|
||||
}
|
||||
else {
|
||||
grid.sortIndex = i;
|
||||
grid.sortDirection = tmpcol.Sort;
|
||||
}
|
||||
}
|
||||
if (tmpcol.name == "Selected")
|
||||
tmpColumns.splice(0, 0, tmpcol);
|
||||
else
|
||||
tmpColumns.push(tmpcol);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//grid.setColumns(tmpColumns);
|
||||
grid.columns = tmpColumns;
|
||||
if (grid.sortIndex >= grid.columns.length)
|
||||
grid.sortIndex = -1;
|
||||
if (typeof grid.init == "function")
|
||||
grid.init();
|
||||
|
||||
if (next) {
|
||||
next(tmpColumns);
|
||||
}
|
||||
}
|
||||
|
||||
function readColumnWidthSort(columns, colinfo) {
|
||||
for (var i = 0; i < columns.length; i++) {
|
||||
if (columns[i].name == colinfo.ColumnKey) {
|
||||
if (colinfo.Caption && colinfo.Caption.trim() != "") {
|
||||
columns[i].caption = colinfo.Caption;
|
||||
columns[i].UserCaption = colinfo.Caption;
|
||||
}
|
||||
columns[i].width = parseInt(colinfo.Width);
|
||||
columns[i].Sort = colinfo.Sort;
|
||||
if (columns[i].visible !== false || !columns[i].alwaysshow)
|
||||
columns[i].visible = colinfo.Visible == undefined ? true : colinfo.Visible;
|
||||
return columns[i];
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function saveGridLayout(dialog, layoutid, grid, layoutinfo, colinfos, next, overwrite) {
|
||||
if (!colinfos) {
|
||||
colinfos = getLayoutOnGrid(grid);
|
||||
}
|
||||
|
||||
layoutinfo.LayoutId = layoutid;
|
||||
layoutinfo.Layout = JSON.stringify(colinfos)
|
||||
_network.commonpagequery(8, htmlencode(JSON.stringify([JSON.stringify(layoutinfo), overwrite ? 1 : 0])), function (e) {
|
||||
if (e == -1) {
|
||||
showAlert(GetTextByKey("P_GRID_XXXXXX", "Layout {0} is in use by the Organization and cannot be used. Please select another name.").replace('{0}', layoutinfo.LayoutName)
|
||||
, GetTextByKey("P_GRID_XXXXXX", 'Layout'));
|
||||
}
|
||||
else if (e == -2) {
|
||||
showLayoutConfirm(dialog, GetTextByKey('P_GRID_XXXXXX', 'Layout {0} already exists, Do you want to overwrite it?').replace('{0}', layoutinfo.LayoutName)
|
||||
, GetTextByKey('P_GRID_XXXXXX', 'Layout'), function () {
|
||||
saveGridLayout(dialog, layoutid, grid, layoutinfo, colinfos, next, true);
|
||||
});
|
||||
}
|
||||
else {//Successfully
|
||||
dialog && dialog.hideDialog();
|
||||
$("#div_layout_tooltip").remove();
|
||||
if (next) {
|
||||
next();
|
||||
return;
|
||||
}
|
||||
showmaskbg(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function getLayoutOnGrid(grid) {
|
||||
colinfos = [];
|
||||
for (var i = 0; i < grid.columns.length; i++) {
|
||||
var sort = 0;
|
||||
var sortKey = "";
|
||||
var sortDirection = 0;
|
||||
if (grid.$refs && grid.$refs.grid) { //datagrid:vue
|
||||
sortKey = grid.$refs.grid.sortKey;
|
||||
sortDirection = grid.$refs.grid.sortDirection;
|
||||
}
|
||||
else {
|
||||
sortKey = grid.sortKey;
|
||||
sortDirection = grid.sortDirection;
|
||||
}
|
||||
if (sortKey && (sortKey == grid.columns[i].name || sortKey == grid.columns[i].key))
|
||||
sort = sortDirection;
|
||||
if (isNaN(sort))
|
||||
sort = 0;
|
||||
var columnwidth = {
|
||||
'Visible': grid.columns[i].visible !== false,
|
||||
'ColumnKey': grid.columns[i].name,
|
||||
'Caption': grid.columns[i].UserCaption,
|
||||
'Width': grid.columns[i].width,
|
||||
'Sort': sort
|
||||
}
|
||||
colinfos.push(columnwidth);
|
||||
}
|
||||
return colinfos;
|
||||
}
|
||||
|
||||
function showLayoutConfirm(dialog, msg, title, fok, fcancel) {
|
||||
dialog.find('.maskbg').css('display', '');
|
||||
_dialog.showConfirm(msg, title, function (e) {
|
||||
dialog.find('.maskbg').css('display', 'none');
|
||||
if (typeof fok === 'function') {
|
||||
fok(e);
|
||||
}
|
||||
}, function () {
|
||||
dialog.find('.maskbg').css('display', 'none');
|
||||
});
|
||||
}
|
203
Site/js/jobsitesummary.js
Normal file
203
Site/js/jobsitesummary.js
Normal file
@ -0,0 +1,203 @@
|
||||
|
||||
if (typeof ($jobsitesummary) != "function") {
|
||||
var ctrlindex = 0;
|
||||
var assetIconCollapsed = false;
|
||||
var alertsCollapsed = false;
|
||||
$jobsitesummary = function (p, js, type, jobsites) {//type 0.left;1.bottom
|
||||
if (typeof p === "string")
|
||||
p = $("#" + p);
|
||||
if (!p)
|
||||
p = document;
|
||||
this.type = type;
|
||||
this.jobsite = js;
|
||||
this.jobsites = jobsites;
|
||||
this.status = 0;
|
||||
this.ctrlindex = ctrlindex++;
|
||||
this.jobsitechanged = null;
|
||||
|
||||
var _this = this;
|
||||
|
||||
this.basectrl = $('<div></div>');
|
||||
|
||||
//if (this.jobsites && this.jobsites.length > 1) {
|
||||
// this.basectrl.css('margin-top', 10);
|
||||
|
||||
// var div_jobsite = $('<div style="width: 360px;margin-left:40px;"></div>');
|
||||
// div_jobsite.dropdown(this.jobsites, {
|
||||
// search: true,
|
||||
// valueKey: 'ID',
|
||||
// textKey: 'Name'
|
||||
// });
|
||||
// div_jobsite.find(".dropdown-wrapper").css("border", "1px solid #b9b9b9");
|
||||
// if (this.jobsite)
|
||||
// div_jobsite.dropdownVal(this.jobsite.ID);
|
||||
|
||||
// div_jobsite.on('select', function (_e, item) {
|
||||
// if (item.ID != _this.jobsite.ID) {
|
||||
// var temps = _this.jobsites.filter(function (a) { return a.ID == item.ID })
|
||||
// if (_this.jobsitechanged && temps && temps.length > 0)
|
||||
// _this.jobsitechanged(_this.jobsites.indexOf(temps[0]));
|
||||
// }
|
||||
// });
|
||||
|
||||
// p.append(div_jobsite);
|
||||
//}
|
||||
|
||||
p.append(this.basectrl);
|
||||
//this.maskbgctrl = $('<div class="maskbg"><div class="loading_icon icon c-spin"></div></div>');
|
||||
//p.append(this.maskbgctrl);
|
||||
this.contractid = $("#selContractor").val();
|
||||
if (!this.contractid) this.contractid = "";
|
||||
|
||||
this.refresh = function (js) {
|
||||
_this.basectrl.empty();
|
||||
_this.jobsite = js;
|
||||
showJobsiteInfo();
|
||||
}
|
||||
|
||||
if (this.jobsite) {
|
||||
showJobsiteInfo();
|
||||
}
|
||||
|
||||
function setIconBr(div_icon) {
|
||||
var br = '<br />';
|
||||
//if (_this.type == 0)
|
||||
div_icon.append(br);
|
||||
}
|
||||
|
||||
function showJobsiteIcon() {
|
||||
var js = _this.jobsite;
|
||||
var div_icon = $('<div></div>');
|
||||
var iconheight = p.height();
|
||||
if (iconheight == 0)
|
||||
iconheight = p.parent().height();
|
||||
if (_this.type == 0) {
|
||||
div_icon.css({ 'height': iconheight - 4, 'margin-top': -20 });
|
||||
}
|
||||
else {
|
||||
div_icon.css({ 'height': iconheight + 5 });
|
||||
|
||||
//if (_this.jobsites && _this.jobsites.length > 1) {
|
||||
// div_icon.css({ 'height': p.parent().height() + 5, 'margin-top': -42 });
|
||||
//}
|
||||
div_icon.removeClass("divicon_left");
|
||||
div_icon.addClass("divicon_bottom");
|
||||
}
|
||||
div_icon.removeClass("divicon_bottom");
|
||||
div_icon.addClass("divicon_left");
|
||||
|
||||
var span;
|
||||
if (canEditJobsite) {
|
||||
span = $('<span class="iconjobsite" style="cursor: pointer;" title="' + GetTextByKey("P_JS_EDITJOBSITE", "Edit Jobsite") + '"></span>');
|
||||
span.click(js, function (e) {
|
||||
OnEditJobsite(js);
|
||||
});
|
||||
div_icon.append(span);
|
||||
setIconBr(div_icon);
|
||||
}
|
||||
|
||||
span = $("<span class='iconmail' style='cursor:pointer;' onclick='openSendEmails(\"" + js.CompanyID + "\"," + js.ID + ",1)' title='" + GetTextByKey("P_MV_SENDJOBSITE", "Send Jobsite") + "'></span>");
|
||||
div_icon.append(span);
|
||||
setIconBr(div_icon);
|
||||
|
||||
if (type == 0) {
|
||||
div_icon.find("span").click(function (e) {
|
||||
p.hide();
|
||||
$('#assetsummarytrigle').hide();
|
||||
});
|
||||
}
|
||||
|
||||
return div_icon;
|
||||
}
|
||||
|
||||
function showJobsiteInfo() {
|
||||
if (!_this.jobsite) return;
|
||||
var js = _this.jobsite;
|
||||
var br = '<br />';
|
||||
|
||||
if (_this.type == 0) {
|
||||
var div_close = $('<div style="height:20px;"></div>');
|
||||
_this.basectrl.append(div_close);
|
||||
var span_close = $('<span class="clearbtn" style="float: right; padding: 5px;cursor:pointer;"></span>').click(function () {
|
||||
p.hide();
|
||||
$('#assetsummarytrigle').hide();
|
||||
});
|
||||
div_close.append(span_close);
|
||||
}
|
||||
|
||||
if (showTooltipIcons) {
|
||||
var div_icon = showJobsiteIcon();
|
||||
_this.basectrl.append(div_icon);
|
||||
}
|
||||
|
||||
var div_summary = $('<div class="assetsummaryinfo_div"></div>').css("text-align", "left");
|
||||
if (!showTooltipIcons)
|
||||
div_summary.css("margin-left", 10);
|
||||
_this.basectrl.append(div_summary);
|
||||
|
||||
var b = $('<b>' + GetTextByKey("P_MV_NAME_COLON", "Name:") + ' </b>');
|
||||
div_summary.append(b);
|
||||
var label = $('<label></label>').text(js.Name);
|
||||
div_summary.append(label).append(br);
|
||||
|
||||
b = $('<b>' + GetTextByKey("P_JS_CODE_COLON", "Code:") + ' </b>');
|
||||
div_summary.append(b);
|
||||
var label = $('<label></label>').text(js.Code);
|
||||
div_summary.append(label).append(br);
|
||||
|
||||
b = $('<b>' + GetTextByKey("P_JS_NUMBER_COLON", "Number:") + ' </b>');
|
||||
div_summary.append(b);
|
||||
var label = $('<label></label>').text(js.Number);
|
||||
div_summary.append(label).append(br);
|
||||
|
||||
b = $('<b>' + GetTextByKey("P_MV_LATLONG_COLON", "Lat/Long:") + ' </b>');
|
||||
div_summary.append(b);
|
||||
var label = $('<label></label>').text(js.Latitude + ", " + js.Longitude);
|
||||
div_summary.append(label).append(br);
|
||||
|
||||
b = $('<b>' + GetTextByKey("P_MV_DELIVERYADDRESS_COLON", "Delivery Address:") + ' </b>');
|
||||
div_summary.append(b);
|
||||
label = $('<label></label>').text(js.Address1);
|
||||
div_summary.append(label).append(br);
|
||||
|
||||
div_summary.append(br);
|
||||
b = $('<b>' + GetTextByKey("P_JS_FOREMAN_COLON", "Foreman:") + ' </b>');
|
||||
div_summary.append(b);
|
||||
var ftxt = js.Foreman;
|
||||
if (ftxt === "") {
|
||||
if (js.Phone !== "")
|
||||
ftxt = js.Phone;
|
||||
}
|
||||
else {
|
||||
if (js.Phone !== "")
|
||||
ftxt = ftxt + "," + js.Phone;
|
||||
}
|
||||
var label = $('<label></label>').text(ftxt);
|
||||
div_summary.append(label).append(br);
|
||||
|
||||
div_summary.append(br);
|
||||
b = $('<b>' + GetTextByKey("P_JS_STATDATE_COLON", "Start Date:") + ' </b>');
|
||||
div_summary.append(b);
|
||||
var label = $('<label></label>').text(js.StartDateStr);
|
||||
div_summary.append(label).append(br);
|
||||
|
||||
b = $('<b>' + GetTextByKey("P_JS_PROJECTEDENDDATE_COLON", "Projected End Date:") + ' </b>');
|
||||
div_summary.append(b);
|
||||
var label = $('<label></label>').text(js.ProjectedEndDateStr);
|
||||
div_summary.append(label).append(br);
|
||||
|
||||
b = $('<b>' + GetTextByKey("P_JS_ENDDATE_COLON", "End Date:") + ' </b>');
|
||||
div_summary.append(b);
|
||||
var label = $('<label></label>').text(js.EndDateStr);
|
||||
div_summary.append(label).append(br);
|
||||
|
||||
div_summary.append(br);
|
||||
b = $('<b>' + GetTextByKey("P_MV_NOTES_COLON", "Notes:") + ' </b>');
|
||||
div_summary.append(b);
|
||||
|
||||
var notes = (js.Notes && js.Notes !== "") ? replaceHtmlText(js.Notes) : "";
|
||||
var label = $('<label></label>').html(notes);
|
||||
div_summary.append(label).append(br);
|
||||
}
|
||||
}
|
||||
}
|
2
Site/js/jquery-3.6.0.min.js
vendored
Normal file
2
Site/js/jquery-3.6.0.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
3188
Site/js/jquery.datetimepicker.full.js
Normal file
3188
Site/js/jquery.datetimepicker.full.js
Normal file
File diff suppressed because it is too large
Load Diff
121
Site/js/language.js
Normal file
121
Site/js/language.js
Normal file
@ -0,0 +1,121 @@
|
||||
|
||||
// multi-language
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
function getKey(ele, attr) {
|
||||
var key = ele.attr(attr).replace(/[.]/g, '_');
|
||||
return key;
|
||||
}
|
||||
|
||||
$.fn.applyFleetLanguageText = function (includeTitle) {
|
||||
return this.each(function () {
|
||||
var es = $(this).find('[data-lgid]');
|
||||
var ele, key;
|
||||
for (var i = 0; i < es.length; i++) {
|
||||
ele = $(es[i]);
|
||||
key = getKey(ele, 'data-lgid');
|
||||
if (ele.is('input')) {
|
||||
ele.val(GetTextByKey(key, ele.val()));
|
||||
} else {
|
||||
ele.text(GetTextByKey(key, ele.text()));
|
||||
}
|
||||
}
|
||||
es = $(this).find('input[data-holder-lgid]');
|
||||
for (var i = 0; i < es.length; i++) {
|
||||
ele = $(es[i]);
|
||||
key = getKey(ele, 'data-holder-lgid');
|
||||
ele.attr('placeholder', GetTextByKey(key, ele.attr('placeholder')));
|
||||
}
|
||||
if (includeTitle) {
|
||||
es = $(this).find('[data-title-lgid]');
|
||||
for (var j = 0; j < es.length; j++) {
|
||||
ele = $(es[j]);
|
||||
key = getKey(ele, 'data-title-lgid');
|
||||
ele.attr('title', GetTextByKey(key, key));
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
})();
|
||||
|
||||
|
||||
var langObj = undefined;
|
||||
function GetTextByKey(key, defaultValue) {
|
||||
if (langObj == undefined) {
|
||||
loadLanguage();
|
||||
}
|
||||
try {
|
||||
if (langObj && langObj.Values) {
|
||||
key = key.toUpperCase();
|
||||
var val = langObj.Values[key];
|
||||
if (val)
|
||||
return val;
|
||||
}
|
||||
} catch (e) { }
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
function loadLanguage() {
|
||||
var lang = _fleet.currentLang;
|
||||
if (!lang)
|
||||
lang = "en-us";
|
||||
var ver = getFileVersion();
|
||||
var langversion = window.localStorage[lang + "_v"];
|
||||
if (!langversion || langversion == "" || eval(langversion) < ver) {
|
||||
langObj = loadLanguageRes(ver);
|
||||
window.localStorage[lang + "_v"] = ver;
|
||||
window.localStorage[lang + "_res"] = JSON.stringify(langObj);
|
||||
}
|
||||
else {
|
||||
var jsonstr = window.localStorage[lang + "_res"];
|
||||
if (jsonstr && jsonstr != "")
|
||||
langObj = JSON.parse(jsonstr);
|
||||
if (!langObj) {
|
||||
langObj = loadLanguageRes(ver);
|
||||
window.localStorage[lang + "_res"] = JSON.stringify(langObj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getFileVersion() {
|
||||
var ver = 0;
|
||||
_network.commonpagequery(6, "", function (data) {
|
||||
ver = data;
|
||||
}, function (err) {
|
||||
}, true, true);
|
||||
|
||||
return ver;
|
||||
};
|
||||
|
||||
function loadLanguageRes(ver) {
|
||||
if (langObj == undefined) {
|
||||
var sp;
|
||||
if (typeof _network.root === 'string') {
|
||||
sp = _network.root;
|
||||
} else if (typeof sitePath === 'string') {
|
||||
sp = sitePath;
|
||||
} else {
|
||||
sp = '';
|
||||
}
|
||||
var lang = _fleet.currentLang;
|
||||
if (!lang)
|
||||
lang = "en-us";
|
||||
return loadJsonFromServer(sp + "Languages\\" + lang + ".json?s=" + ver);
|
||||
}
|
||||
}
|
||||
|
||||
function loadJsonFromServer(path) {//path 是json文件的地址
|
||||
var result = null;
|
||||
$.ajax({
|
||||
url: path,
|
||||
dataType: 'json',
|
||||
type: 'GET',
|
||||
async: false,
|
||||
success: function (data) {
|
||||
result = data;
|
||||
}
|
||||
});
|
||||
return result;
|
||||
};
|
1
Site/js/lib/app.min.css
vendored
Normal file
1
Site/js/lib/app.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
12
Site/js/lib/app.min.js
vendored
Normal file
12
Site/js/lib/app.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
Site/js/lib/app.min.js.map
Normal file
1
Site/js/lib/app.min.js.map
Normal file
File diff suppressed because one or more lines are too long
24129
Site/js/lib/index.js
Normal file
24129
Site/js/lib/index.js
Normal file
File diff suppressed because one or more lines are too long
5
Site/js/lib/require-2.3.6.min.js
vendored
Normal file
5
Site/js/lib/require-2.3.6.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
27
Site/js/lib/style.css
Normal file
27
Site/js/lib/style.css
Normal file
File diff suppressed because one or more lines are too long
1
Site/js/lib/ui.min.css
vendored
Normal file
1
Site/js/lib/ui.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
3
Site/js/lib/ui.min.js
vendored
Normal file
3
Site/js/lib/ui.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
Site/js/lib/ui.min.js.map
Normal file
1
Site/js/lib/ui.min.js.map
Normal file
File diff suppressed because one or more lines are too long
4
Site/js/lib/utility.min.js
vendored
Normal file
4
Site/js/lib/utility.min.js
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
(function(i,c){typeof exports=="object"&&typeof module<"u"?c(exports):typeof define=="function"&&define.amd?define(["exports"],c):(i=typeof globalThis<"u"?globalThis:i||self,c(i["lib-utility"]={}))})(this,function(i){"use strict";function c(e,t,n){if(e==null)return;let r=`; domain=${location.host}; path=/`;if(n!=null){const l=new Date;l.setTime(l.getTime()+n*24*60*60*1e3),r+=`; expires=${l.toGMTString()}`}/^(https|wss):$/.test(location.protocol)&&(r+="; secure"),document.cookie=`${e}=${encodeURIComponent(t)}${r}`}function f(e){if(e==null)return null;e+="=";const t=document.cookie.split(";");for(let n of t)if(n=n.trim(),n.indexOf(e)===0)return decodeURIComponent(n.substring(e.length));return null}function $(e){c(e,"",-1)}function d(e){return/^(https?|wss?|ftp):/.test(e)||typeof consts>"u"?e:(consts.path||"")+e}function w(e,t={}){return fetch(d(e),{method:t.method||"GET",headers:{...t.customerHeaders,Accept:t.accept||"application/json"},signal:t.signal,cache:"default"})}function A(e,t,n={}){return t instanceof FormData||(typeof t!="string"&&(t=JSON.stringify(t)),n.customerHeaders==null&&(n.customerHeaders={}),n.customerHeaders["Content-Type"]==null&&(n.customerHeaders["Content-Type"]="application/json")),fetch(d(e),{method:n.method||"POST",headers:n.customerHeaders,body:t,signal:n.signal,cache:"no-cache"})}function O(e,t,n={}){return new Promise((r,l)=>{const a=new XMLHttpRequest;if(a.onreadystatechange=function(){this.readyState===XMLHttpRequest.DONE&&(this.status===200?r(this):l(`${this.status} ${this.statusText}: ${this.responseText}`))},typeof n.progress=="function"&&a.upload.addEventListener("progress",function(u){u.lengthComputable&&n.progress.call(this,u)},!1),a.open("POST",d(e)),n.customerHeaders!=null)for(let u of Object.entries(n.customerHeaders))a.setRequestHeader(u[0],u[1]);a.send(t)})}function o(e){return e==null||typeof e!="string"||e.length===0}function C(e,t,n){return o(e)||t==null?!1:(typeof t!="string"&&(t=String(t)),n?e.toLowerCase().indexOf(t.toLowerCase())>=0:e.indexOf(t)>=0)}function L(e,t){return o(e)||o(t)?!1:e.indexOf(t)===e.length-t.length}function N(e,t,n){return o(e)||isNaN(t)||t<=e.length?e:(n??" ").repeat(t-e.length)}function H(e){const t=/(http|ftp|https):\/\/.+?(\s|\r\n|\r|\n|\"|\'|\*|$)/g,n=e.match(t);if(e=m(e),(n==null?void 0:n.length)>0){const r=[];for(let l of n)l=l.replace(/["'\r\n ]/g,""),r.indexOf(l)<0&&r.push(l);for(let l of r)e=e.replaceAll(l,'<a target="_blank" href="'+l+'"><svg><use xlink:href="'+(typeof consts<"u"&&consts.path||"")+'fonts/fa-regular.svg#link"></use></svg></a>')}return e}function m(e){return e==null?"":String(e).replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll(`\r
|
||||
`,"<br/>").replaceAll(`
|
||||
`,"<br/>").replaceAll(" "," ")}let g;function h(){var n,r;let e;switch(typeof consts<"u"&&(e=f((n=consts.cookie)==null?void 0:n.lang),o(e)&&(e=(r=consts.user)==null?void 0:r.language)),o(e)&&(e=f("lgid")),o(e)&&(e=navigator.language||"en-us"),e=e.toLowerCase().replace(/-/g,"_"),o(e)&&(e="en"),e){case"en":case"en_au":case"fr":case"zh_cn":return e}const t=e.split("_")[0];switch(t){case"en":case"fr":return t}return"en"}function T(e){return typeof consts<"u"?(consts.prefix||"")+`res_${e}`:`res_${e}`}async function v(e=""){const t=h(),r=await(await w(`language/${t}${e}`)).json();return localStorage.setItem(T(t),JSON.stringify(r)),r}async function p(e,t){(t==null||typeof consts>"u")&&(t=await v(e));const n=Number(consts.resver);return(isNaN(t.ver)||isNaN(n)||n>t.ver)&&(console.log(`found new language res version: ${t.ver} => ${n}`),t=await v(e)),Object.defineProperty(t,"r",{writable:!1,configurable:!1,enumerable:!1,value:function(r,l){return s(this,r,l)}}),g=t,t}function s(e,t,n){return e[t]??n}function S(e,t){for(let n of e.querySelectorAll("[data-lgid]")){const r=n.dataset.lgid;n.tagName==="INPUT"?n.value=s(t,r,n.value):n.innerText=s(t,r,n.innerText)}for(let n of e.querySelectorAll("[data-title-lgid]")){const r=n.dataset.titleLgid;n.setAttribute("title",s(t,r,n.getAttribute("title")))}for(let n of e.querySelectorAll("[data-placeholder-lgid]")){const r=n.dataset.placeholderLgid;n.setAttribute("placeholder",s(t,r,n.getAttribute("placeholder")))}}async function P(e=document.body,t={}){const n=h();let r=localStorage.getItem(T(n)),l;if(r!=null)try{r=JSON.parse(r),l=await p(t.template,r)}catch(a){console.error("error while parsing lgres, try refresh ...",a),l=await p(t.template)}else l=await p(t.template);try{return document.readyState==="loading"?await new Promise((a,u)=>{let k=setTimeout(()=>u("timeout"),3e4);document.addEventListener("DOMContentLoaded",()=>{clearTimeout(k),k=void 0,typeof t.callback=="function"&&t.callback(l),S(e,l),a(l)})}):(typeof t.callback=="function"&&t.callback(l),S(e,l),l)}catch(a){console.error("error while loading language res ...",a)}}function y(e,t){return g!=null?s(g,e,t):t}const E={get current(){return h()},get unknownError(){return y("unknownError","An unknown error occurred, please contact the administrator.")},get savedSuccessfully(){return y("savedSuccessfully","Saved successfully.")}};let b=typeof globalThis<"u"?globalThis:self;function M(e){return!isNaN(e)&&e>0}function j(){return/mobile/i.test(navigator.userAgent)}function q(e,t=100,n=b,...r){if(e==null)return;e.tiid&&clearTimeout(e.tiid);const l=new Date;e.tdate==null||l-e.tdate>t?(e.apply(n,r),e.tdate=l):e.tiid=setTimeout(()=>e.apply(n,r),t)}function _(e,t=100,n=b,...r){e!=null&&(e.tiid&&clearTimeout(e.tiid),e.tiid=setTimeout(()=>e.apply(n,r),t))}function I(e){return(e>0?Math.floor:Math.ceil)(e)}function R(e){return/^\w[-\w.+]*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/.test(e)}function U(e){return/^[1-9]\d{9,}$/.test(e)}i.contains=C,i.debounce=_,i.deleteCookie=$,i.endsWith=L,i.escapeHtml=m,i.formatUrl=H,i.get=w,i.getCookie=f,i.global=b,i.init=P,i.isEmail=R,i.isMobile=j,i.isPhone=U,i.isPositive=M,i.lang=E,i.nullOrEmpty=o,i.padStart=N,i.post=A,i.r=y,i.setCookie=c,i.throttle=q,i.truncate=I,i.upload=O,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})});
|
||||
//# sourceMappingURL=utility.min.js.map
|
1
Site/js/lib/utility.min.js.map
Normal file
1
Site/js/lib/utility.min.js.map
Normal file
File diff suppressed because one or more lines are too long
416
Site/js/machinealertview.js
Normal file
416
Site/js/machinealertview.js
Normal file
@ -0,0 +1,416 @@
|
||||
var ALL_TEXT = "(All)";
|
||||
var ALL_VALUE = "@all";
|
||||
|
||||
$(function () {
|
||||
// global event
|
||||
}());
|
||||
|
||||
function showMapAlertLayer(data) {
|
||||
var opt = $('<option></option>').val("").text("(None)");
|
||||
var sel = $("#selMapAlertLayer");
|
||||
sel.empty();
|
||||
sel.append(opt);
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
var mal = data[i];
|
||||
opt = $('<option></option>').val(mal.ID).text(mal.Name).data("mal", mal);
|
||||
sel.append(opt);
|
||||
}
|
||||
if (userParams && userParams.MapAlertLayer) {
|
||||
sel.val(userParams.MapAlertLayer);
|
||||
}
|
||||
showMapAlertLayerDetail();
|
||||
}
|
||||
|
||||
function showMapAlertLayerDetail() {
|
||||
var mal = $("#selMapAlertLayer").find("option:selected").data("mal");
|
||||
var tb = $("#tbLegend");
|
||||
tb.empty();
|
||||
var haspramameter = false;
|
||||
if (mal && mal.Layers) {
|
||||
//var tr = $("<tr></tr>");
|
||||
//tb.append(tr);
|
||||
//var td = $("<td class='mapalertlayertitle'></td>").html("Icon Definition").css("width", 100);
|
||||
//tr.append(td);
|
||||
//td = $("<td class='mapalertlayertitle'></td>").html("Alert Title").css("width", 150);
|
||||
//tr.append(td);
|
||||
for (var i = 0; i < mal.Layers.length; i++) {
|
||||
var layer = mal.Layers[i];
|
||||
if ((layer.CriteriaSQLParameters && layer.CriteriaSQLParameters.length > 0)
|
||||
|| (layer.AlertSQLParameters && layer.AlertSQLParameters.length > 0))
|
||||
haspramameter = true;
|
||||
|
||||
var tr = $("<tr style='border-bottom: 1px solid lightgray;'></tr>");
|
||||
tb.append(tr);
|
||||
|
||||
if (layer.IconColor.length == 9)
|
||||
layer.IconColor = "#" + layer.IconColor.substring(3);
|
||||
var td = $("<td></td>").css("width", 30);
|
||||
td.append($("<img></img>").attr("src", layer.LegendUrl).css({ "width": 18, "vertical-align": "middle" }));
|
||||
//td.append($("<div></div>").css({ "background-color": layer.IconColor, "width": 24, "height": 16 }));
|
||||
tr.append(td);
|
||||
|
||||
td = $("<td></td>").html(layer.Title).css({ "padding-left": 10, "width": 220 });
|
||||
tr.append(td);
|
||||
}
|
||||
}
|
||||
|
||||
var staticlegend = ["InMotion", "StoppedOn", "StoppedOff", "CGain", "CLoss"];
|
||||
var staticlegendtitle = ["In Motion", "Stopped On", "Stopped Off", "Connectivity Recovery", "Connectivity Loss"];
|
||||
for (var i = 0; i < staticlegend.length; i++) {
|
||||
var tr = $("<tr style='border-bottom: 1px solid lightgray;'></tr>");
|
||||
tb.append(tr);
|
||||
|
||||
var url = userParams.MachineIconURL + "?legend=" + staticlegend[i];
|
||||
var td = $("<td></td>").css("width", 30);
|
||||
td.append($("<img></img>").attr("src", url).css({ "width": 18, "vertical-align": "middle" }));
|
||||
tr.append(td);
|
||||
|
||||
td = $("<td></td>").html(staticlegendtitle[i]).css({ "padding-left": 10, "width": 220 });
|
||||
tr.append(td);
|
||||
}
|
||||
|
||||
var harshdrivinglegend = ["#ff3f48cc", "#ff00a8f3", "#fffff200", "#ffff7f27", "#ffec1c24"];
|
||||
var harshdrivingtitle = ["Hard Acceleration", "Hard Brake", "Hard Turn", "Speeding: Low Severity", "Speeding: High Severity"];
|
||||
for (var i = 0; i < harshdrivinglegend.length; i++) {
|
||||
var tr = $("<tr style='border-bottom: 1px solid lightgray;'></tr>");
|
||||
tb.append(tr);
|
||||
|
||||
var ironurl = userParams.MachineIconURL.toLowerCase().replace("machinetypeicon.ashx", "machinemovingicon.ashx");
|
||||
var url = ironurl + "?tp=0&bkcolor=" + encodeURIComponent(harshdrivinglegend[i]) + "&heading=45";
|
||||
var td = $("<td></td>").css("width", 30);
|
||||
td.append($("<img></img>").attr("src", url).css({ "width": 18, "vertical-align": "middle" }));
|
||||
tr.append(td);
|
||||
|
||||
td = $("<td></td>").html(harshdrivingtitle[i]).css({ "padding-left": 10, "width": 220 });
|
||||
tr.append(td);
|
||||
}
|
||||
|
||||
if (haspramameter) {
|
||||
$('#setparameter').css('display', '');
|
||||
}
|
||||
else {
|
||||
$('#setparameter').css('display', 'none');
|
||||
}
|
||||
var right = $('#mapAlertLayerDiv').width() + 100;
|
||||
$('#filterIconDiv').css('right', right);
|
||||
}
|
||||
|
||||
function setParameterDatimeTimePicker(ipt) {
|
||||
ipt.datetimepicker({
|
||||
timepicker: false,
|
||||
format: 'm/d/Y',
|
||||
enterLikeTab: false,
|
||||
onSelectDate: function (v, inp) {
|
||||
var date = new DateFormatter().formatDate(v, 'm/d/Y 00:00:00');
|
||||
inp.parent().data('val', [date]);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function getAlertLayerParameters() {
|
||||
if (parameterinput.length > 0) {//更新参数选择的值
|
||||
for (var l = 0; l < parameterinput.length; l++) {
|
||||
var ipt = parameterinput[l];
|
||||
var param = ipt.data("parameter");
|
||||
if (ipt.data('commoninput'))
|
||||
param.ParameterValue = ipt.val();
|
||||
}
|
||||
}
|
||||
|
||||
var mal = $("#selMapAlertLayer").find("option:selected").data("mal");
|
||||
if (mal)
|
||||
return mal.Layers;
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
var parameterinput = [];
|
||||
var paramindex = -1;
|
||||
function setAlertLayerParameters() {
|
||||
parameterinput = [];
|
||||
paramindex = -1;
|
||||
var ul = $("#ul_parameter");
|
||||
ul.empty();
|
||||
var pdiv = $("#parameter_right");
|
||||
pdiv.empty();
|
||||
var mal = $("#selMapAlertLayer").find("option:selected").data("mal");
|
||||
|
||||
var layerHasParam = 0;
|
||||
if (mal && mal.Layers) {
|
||||
for (var i = 0; i < mal.Layers.length; i++) {
|
||||
var layer = mal.Layers[i];
|
||||
|
||||
var criteriaparam = layer.CriteriaSQLParameters;
|
||||
var alertparam = layer.AlertSQLParameters;
|
||||
|
||||
if (layer && (criteriaparam || alertparam)) {
|
||||
var li = $("<li class='nav_item'></li>").data("layerid", layer.ID).click(layerHasParam++, layerclick);
|
||||
|
||||
if (layer.IconColor.length == 9)
|
||||
layer.IconColor = "#" + layer.IconColor.substring(3);
|
||||
var img = $("<img></img>").attr("src", layer.LegendUrl).css({ "width": 18, "vertical-align": "middle" });
|
||||
var span = $("<span></span>").text(layer.Title).css({ "margin-left": 10, "vertical-align": "middle" });
|
||||
li.append(img).append(span);
|
||||
ul.append(li);
|
||||
var tb = $("<table class='tb_parameter'></table>").data("layerid", layer.ID);
|
||||
if (layerHasParam == 1)
|
||||
li.addClass("selected");
|
||||
else
|
||||
tb.css('display', 'none');
|
||||
|
||||
pdiv.append(tb);
|
||||
if (criteriaparam && criteriaparam.length > 0)
|
||||
createParameters(criteriaparam, tb, 1);
|
||||
|
||||
if (alertparam && alertparam.length > 0)
|
||||
createParameters(alertparam, tb, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function createParameters(params, tb, type) {
|
||||
var tr = $("<tr></tr>").append("<td colspan='2' style='padding-left:10px;font-weight:bold;font-size:16px;'>Criteria</td>");
|
||||
tb.append(tr);
|
||||
for (var j = 0; j < params.length; j++) {
|
||||
var param = params[j];
|
||||
var tr_param = $("<tr></tr>");
|
||||
tb.append(tr_param);
|
||||
tr_param.append($("<td></td>").addClass('td_paramtype').html(param.Caption));
|
||||
var td = $("<td></td>");
|
||||
|
||||
var ipt = createParameterInput(param, type, j);
|
||||
parameterinput.push(ipt);
|
||||
if (param.DataType == 3 && param.DisplayStyle != 1 && param.DisplayStyle != 2) {
|
||||
setParameterDatimeTimePicker(ipt);
|
||||
}
|
||||
td.append(ipt);
|
||||
tr_param.append(td);
|
||||
}
|
||||
}
|
||||
|
||||
function FALSE() { return false; }
|
||||
|
||||
function createParameterInput(param, type) {
|
||||
var paramvalue = getParameterValue(param.ID, type);
|
||||
if (paramvalue == null)
|
||||
paramvalue = param.DefaultValue;
|
||||
|
||||
if (param.DisplayStyle == 0) {//inputbox
|
||||
return $("<input type='text' />").val(paramvalue).data("parameter", param).data('commoninput', true)
|
||||
.attr("paramcaption", param.Name.toLowerCase())
|
||||
.keyup(function () {
|
||||
$("[paramcaption='" + param.Name.toLowerCase() + "']").val($(this).val());
|
||||
}).change(function () {
|
||||
$("[paramcaption='" + param.Name.toLowerCase() + "']").val($(this).val());
|
||||
});
|
||||
}
|
||||
else if (param.DisplayStyle == 1 || param.DisplayStyle == 2) {//Dropdown or Combobox
|
||||
var defaultcheckall = false;
|
||||
if (param.IsAllAllowed && paramvalue === ALL_VALUE)
|
||||
defaultcheckall = true;
|
||||
if (param.IsField && param.MutipleSelect) {//多选
|
||||
var divcontrol = $('<div class="div_filter"></div>').data("parameter", param);
|
||||
var seldiv = $('<div class="left dropdown"></div>');
|
||||
var span = $('<span class="text_span"></span>');
|
||||
var spanimg = $('<span class="fa dropdown_button"></span>');
|
||||
var divpanel = $('<div class="div_panel" style="display: none;z-index:10;margin-top:20px;margin-left:-1px;"></div>');
|
||||
var ul = $('<ul></ul>');
|
||||
divpanel.append(ul).mousedown(FALSE);
|
||||
seldiv.append(span).append(spanimg).append(divpanel);
|
||||
seldiv.mousedown(function () {
|
||||
$('.div_panel').each(function () {
|
||||
var t = $(this);
|
||||
if (!t.is(divpanel))
|
||||
t.css('display', 'none');
|
||||
});
|
||||
|
||||
var display = divpanel.css('display');
|
||||
if (display == 'none') {
|
||||
divpanel.css({ 'display': 'block' });
|
||||
} else {
|
||||
divpanel.css('display', 'none');
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
var itemclick = function (isall, checked) {
|
||||
var chks = ul.find('input');
|
||||
if (isall) {
|
||||
chks.prop('checked', checked);
|
||||
if (checked) {
|
||||
span.attr('title', ALL_TEXT).text(ALL_TEXT);
|
||||
param.ParameterValue = ALL_VALUE;
|
||||
}
|
||||
else {
|
||||
span.attr('title', "").text("");
|
||||
param.ParameterValue = "";
|
||||
}
|
||||
return;
|
||||
}
|
||||
else {
|
||||
if (chkall)
|
||||
chkall.prop('checked', false);//(ALL)取消选中
|
||||
}
|
||||
|
||||
var texts = [];
|
||||
var paramvalues = [];
|
||||
for (var i = 0; i < chks.length; i++) {
|
||||
var c = $(chks[i]);
|
||||
if (c.prop('checked')) {
|
||||
var text = c.next('label').text();
|
||||
if (!text) text = c.val();
|
||||
texts.push(text);
|
||||
paramvalues.push(c.val());
|
||||
}
|
||||
}
|
||||
texts = texts.join(', ');
|
||||
span.attr('title', texts).text(texts);
|
||||
paramvalues = paramvalues.join('^');
|
||||
param.ParameterValue = paramvalues;
|
||||
};
|
||||
|
||||
var chkall = undefined;
|
||||
if (param.IsAllAllowed) {
|
||||
var liall = $('<li></li>');
|
||||
chkall = $('<input type="checkbox" id="chkall" style="width:16px;"/>');
|
||||
if (defaultcheckall)
|
||||
chkall.attr('checked', true);
|
||||
chkall.change(function () {//全选
|
||||
itemclick(true, $(this).prop('checked'));
|
||||
});
|
||||
liall.append(chkall);
|
||||
liall.append($('<label for="chkall"></label>').text(ALL_TEXT));
|
||||
ul.append(liall);
|
||||
}
|
||||
var ds = getLookupDatasource(param.LookupDatasourceID)
|
||||
if (ds && ds.Items) {
|
||||
var paramvalueAry = paramvalue.split("^");
|
||||
var texts = [];
|
||||
for (var s = 0; s < ds.Items.length; s++) {
|
||||
var item = ds.Items[s];
|
||||
var txt = param.DisplayCaptionField ? item.Value : item.Key;
|
||||
var li = $('<li></li>');
|
||||
var chk = $('<input type="checkbox" style="width:16px;"/>').val(item.Key).attr("id", "chkp" + ++paramindex);
|
||||
chk.change(function () {
|
||||
itemclick(false, $(this).prop('checked'));
|
||||
});
|
||||
li.append(chk);
|
||||
li.append($('<label for=' + ("chkp" + paramindex) + '></label>').text(txt));
|
||||
ul.append(li);
|
||||
|
||||
if (defaultcheckall || paramvalueAry.indexOf(item.Key) > -1) {//选中默认值
|
||||
chk.attr('checked', true);
|
||||
var text = chk.next('label').text();
|
||||
if (!text) text = chk.val();
|
||||
texts.push(text);
|
||||
}
|
||||
}
|
||||
|
||||
if (defaultcheckall)
|
||||
texts = ALL_TEXT;
|
||||
else
|
||||
texts = texts.join(', ');
|
||||
span.attr('title', texts).text(texts);
|
||||
param.ParameterValue = paramvalue;
|
||||
}
|
||||
|
||||
divcontrol.append(seldiv);
|
||||
|
||||
return divcontrol;
|
||||
}
|
||||
else {
|
||||
var sel = $("<select></select>").data("parameter", param).data('commoninput', true)
|
||||
.attr("paramcaption", param.Name.toLowerCase())
|
||||
.change(function () {
|
||||
$("[paramcaption='" + param.Name.toLowerCase() + "']").val($(this).val());
|
||||
});
|
||||
var ds = getLookupDatasource(param.LookupDatasourceID)
|
||||
if (ds && ds.Items) {
|
||||
if (param.IsField && param.IsAllAllowed) {
|
||||
var opall = $("<option></option>").val(ALL_VALUE).text(ALL_TEXT);
|
||||
sel.append(opall);
|
||||
}
|
||||
for (var s = 0; s < ds.Items.length; s++) {
|
||||
var item = ds.Items[s];
|
||||
var opt = $("<option></option>").val(item.Key);
|
||||
var txt = param.DisplayCaptionField ? item.Value : item.Key;
|
||||
opt.text(txt);
|
||||
|
||||
sel.append(opt);
|
||||
}
|
||||
sel.val(paramvalue);
|
||||
}
|
||||
return sel;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getLookupDatasource(dsid) {
|
||||
var mal = $("#selMapAlertLayer").find("option:selected").data("mal");
|
||||
if (mal && mal.LookupDataSources) {
|
||||
for (var i = 0; i < mal.LookupDataSources.length; i++) {
|
||||
var ds = mal.LookupDataSources[i];
|
||||
if (ds.ID.toLowerCase() == dsid.toLowerCase())
|
||||
return ds;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function layerclick(e) {
|
||||
$('#ul_parameter li').removeClass("selected");
|
||||
$(this).addClass("selected");
|
||||
var index = e.data;
|
||||
var tbs = $('.tb_parameter');
|
||||
tbs.hide();
|
||||
$(tbs[index]).show();
|
||||
|
||||
}
|
||||
|
||||
function getParameterValue(paramid, paramtype) {
|
||||
if (parametervalues && parametervalues.length > 0) {
|
||||
for (var i = 0; i < parametervalues.length; i++) {
|
||||
var layer = parametervalues[i];
|
||||
var params;
|
||||
if (paramtype == 1)
|
||||
params = layer.CriteriaSQLParameters;
|
||||
else
|
||||
params = layer.AlertSQLParameters;
|
||||
|
||||
if (layer && (params || params)) {
|
||||
for (var j = 0; j < params.length; j++) {
|
||||
var param = params[j];
|
||||
if (param.ID == paramid)
|
||||
return param.ParameterValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function openSetAlertLayerParameters() {
|
||||
setAlertLayerParameters();
|
||||
$('#mask_bg').show();
|
||||
$('#dialog_parameter .dialog-title span.title').text('Pivots');
|
||||
//$('#mask_bg').show();
|
||||
$('#dialog_parameter')
|
||||
.attr('act', 'edit')
|
||||
.css({
|
||||
'width': 570,
|
||||
'top': (document.documentElement.clientHeight - $('#dialog_parameter').height()) / 4,
|
||||
'left': (document.documentElement.clientWidth - $('#dialog_parameter').width()) / 2
|
||||
})
|
||||
.showDialog();
|
||||
pivotsDialogOpend = true;
|
||||
}
|
||||
|
||||
var parametervalues;
|
||||
function setParameterCompleted() {
|
||||
parametervalues = getAlertLayerParameters();
|
||||
machineObject.searchMachine(false);
|
||||
$('#dialog_parameter').hideDialog();
|
||||
$('#mask_bg').hide();
|
||||
pivotsDialogOpend = false;
|
||||
}
|
244
Site/js/mapcontrol.js
Normal file
244
Site/js/mapcontrol.js
Normal file
@ -0,0 +1,244 @@
|
||||
/***********Map*******************/
|
||||
|
||||
if (typeof $mapcontrol !== 'object') {
|
||||
var onmaploaded = undefined;
|
||||
var onselectchanged = undefined;
|
||||
$mapcontrol = function (a, b) {
|
||||
onmaploaded = a;
|
||||
onselectchanged = b;
|
||||
loadMap();
|
||||
}
|
||||
$mapcontrol.prototype.getLocation = function () {
|
||||
return [selLatitude, selLongitude];
|
||||
}
|
||||
$mapcontrol.prototype.setLocation = function (lat, long) {
|
||||
selLatitude = lat;
|
||||
selLongitude = long;
|
||||
showPonit();
|
||||
}
|
||||
|
||||
var isLoadingMap = false;
|
||||
var mapObj;
|
||||
var graphicLayer = undefined;
|
||||
var TransportationLayer = undefined;
|
||||
var GraphicC = undefined;
|
||||
var PointC = undefined;
|
||||
var PictureMarkerSymbolC = undefined;
|
||||
var UnitsC = undefined;
|
||||
var CircleC = undefined;
|
||||
var SimpleFillSymbolC = undefined;
|
||||
var ExtentC = undefined;
|
||||
var DrawC = undefined;
|
||||
var toolbar = undefined;
|
||||
var PolygonC = undefined;
|
||||
var ClusterLayerC = undefined;
|
||||
var BasemapGalleryC = undefined;
|
||||
var FontC = undefined;
|
||||
|
||||
var MultipointC = undefined;
|
||||
var SimpleMarkerSymbolC = undefined;
|
||||
var SimpleLineSymbolC = undefined;
|
||||
var PolylineC = undefined;
|
||||
var ColorC = undefined;
|
||||
|
||||
function loadMap() {
|
||||
require(["esri/map", "esri/graphic", "esri/geometry/Point",
|
||||
"esri/geometry/Multipoint",
|
||||
"esri/geometry/Polyline", "esri/symbols/PictureMarkerSymbol", "esri/units",
|
||||
"esri/geometry/Circle", "esri/symbols/SimpleFillSymbol", "esri/geometry/Extent", "esri/toolbars/draw", "esri/symbols/SimpleMarkerSymbol",
|
||||
"esri/symbols/SimpleLineSymbol", "esri/symbols/SimpleFillSymbol", "esri/geometry/Polygon",
|
||||
"extras1/clusterlayer", "esri/dijit/BasemapGallery",
|
||||
"esri/symbols/Font",
|
||||
"esri/Color", "esri/layers/ArcGISTiledMapServiceLayer"],
|
||||
function (Map, Graphic, Point, Multipoint, Polyline, PictureMarkerSymbol, Units, Circle, SimpleFillSymbol, Extent, Draw, SimpleMarkerSymbol,
|
||||
SimpleLineSymbol, SimpleFillSymbol, Polygon, clusterlayer, BasemapGallery, Font, Color, ArcGISTiledMapServiceLayer) {
|
||||
MapC = Map;
|
||||
GraphicC = Graphic;
|
||||
PointC = Point;
|
||||
PictureMarkerSymbolC = PictureMarkerSymbol;
|
||||
UnitsC = Units;
|
||||
CircleC = Circle;
|
||||
SimpleFillSymbolC = SimpleFillSymbol;
|
||||
ExtentC = Extent;
|
||||
DrawC = Draw;
|
||||
PolygonC = Polygon;
|
||||
ClusterLayerC = clusterlayer;
|
||||
BasemapGalleryC = BasemapGallery;
|
||||
FontC = Font;
|
||||
|
||||
MultipointC = Multipoint;
|
||||
SimpleMarkerSymbolC = SimpleMarkerSymbol;
|
||||
SimpleLineSymbolC = SimpleLineSymbol;
|
||||
PolylineC = Polyline;
|
||||
ColorC = Color;
|
||||
|
||||
|
||||
mapObj = new MapC("mapdiv", {
|
||||
basemap: "topo",
|
||||
center: [0, 0], // longitude, latitude
|
||||
zoom: 3
|
||||
});
|
||||
mapObj.disableKeyboardNavigation();
|
||||
|
||||
dojo.connect(mapObj, "onClick", showCoordinates);
|
||||
$('div.esriControlsBR').remove();
|
||||
|
||||
graphicLayer = new esri.layers.GraphicsLayer();
|
||||
mapObj.addLayer(graphicLayer);
|
||||
|
||||
mapObj.on("load", function (e) {
|
||||
$("#mapdiv_zoom_slider").css("z-index", 0);
|
||||
});
|
||||
|
||||
TransportationLayer = new esri.layers.ArcGISTiledMapServiceLayer("http://server.arcgisonline.com/arcgis/rest/services/Reference/World_Transportation/MapServer");
|
||||
|
||||
initBasemapGallery(mapObj);
|
||||
|
||||
$("#basemapgalleryDiv").click(null, function (e) {
|
||||
$("#basemapGallery").show();
|
||||
});
|
||||
|
||||
if (onmaploaded)
|
||||
onmaploaded();
|
||||
//mapObj.centerAndZoom(point, 3);
|
||||
});
|
||||
}
|
||||
|
||||
function initBasemapGallery(map) {
|
||||
$(window).click(function (e) {
|
||||
if ($(e.target).attr("id") != "basemapImg")
|
||||
$("#basemapGallery").hide();
|
||||
});
|
||||
var basemap = "topo";
|
||||
$("#basemapImg").css("background-image", "url('https://js.arcgis.com/3.40/esri/images/basemap/topo.jpg')");
|
||||
$("#basemapTitle").text(GetTextByKey("P_MAP_TOPOGRAPHIC", "Topographic"));
|
||||
|
||||
var basemapGallery = new BasemapGalleryC({
|
||||
showArcGISBasemaps: false,
|
||||
map: map
|
||||
}, "basemapGallery");
|
||||
|
||||
var satellitemap = new esri.dijit.Basemap({
|
||||
layers: [new esri.dijit.BasemapLayer({
|
||||
url: "http://server.arcgisonline.com/arcgis/rest/services/World_Imagery/MapServer"
|
||||
})],
|
||||
title: GetTextByKey("P_MAP_IMAGERY", "Imagery"),
|
||||
thumbnailUrl: "https://js.arcgis.com/3.40/esri/images/basemap/satellite.jpg"
|
||||
});
|
||||
basemapGallery.add(satellitemap);
|
||||
|
||||
var topomap = new esri.dijit.Basemap({
|
||||
layers: [new esri.dijit.BasemapLayer({
|
||||
url: "http://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer"
|
||||
})],
|
||||
title: GetTextByKey("P_MAP_TOPOGRAPHIC", "Topographic"),
|
||||
thumbnailUrl: "https://js.arcgis.com/3.40/esri/images/basemap/topo.jpg"
|
||||
});
|
||||
basemapGallery.add(topomap);
|
||||
|
||||
var streetmap = new esri.dijit.Basemap({
|
||||
layers: [new esri.dijit.BasemapLayer({
|
||||
//type: "OpenStreetMap",
|
||||
url: "http://server.arcgisonline.com/arcgis/rest/services/World_Street_Map/MapServer"
|
||||
})],
|
||||
title: GetTextByKey("P_MAP_STREETS", "Streets"),
|
||||
thumbnailUrl: "https://js.arcgis.com/3.40/esri/images/basemap/streets.jpg"
|
||||
|
||||
});
|
||||
basemapGallery.add(streetmap);
|
||||
|
||||
basemapGallery.startup();
|
||||
|
||||
basemapGallery.on("selection-change", function () {
|
||||
var basemap = basemapGallery.getSelected();
|
||||
if (basemap) {
|
||||
if (basemap.title == "Imagery")
|
||||
map.addLayer(TransportationLayer);
|
||||
else
|
||||
map.removeLayer(TransportationLayer);
|
||||
|
||||
$("#basemapImg").css("background-image", "url('" + basemap.thumbnailUrl + "')");
|
||||
$("#basemapTitle").text(basemap.title);
|
||||
}
|
||||
$("#basemapGallery").hide();
|
||||
});
|
||||
|
||||
basemapGallery.on("error", function (msg) {
|
||||
console.log("basemap gallery error: ", msg);
|
||||
});
|
||||
}
|
||||
|
||||
var selLatitude, selLongitude = 0;
|
||||
function showCoordinates(evt) {
|
||||
if (evt) {
|
||||
var mp = evt.mapPoint;
|
||||
selLatitude = mp.getLatitude().toFixed(6);
|
||||
selLongitude = mp.getLongitude().toFixed(6);
|
||||
showPonit();
|
||||
if (onselectchanged)
|
||||
onselectchanged(selLatitude, selLongitude);
|
||||
}
|
||||
}
|
||||
|
||||
var maxLong, minLong, maxLat, minLat = null;
|
||||
function zoomMap(allMachines) {
|
||||
if (allMachines && allMachines.length > 0) {
|
||||
for (var i in allMachines) {
|
||||
var m = allMachines[i];
|
||||
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 (!jobsiteid)
|
||||
setMapExtent();
|
||||
}
|
||||
}
|
||||
|
||||
function setMapExtent() {
|
||||
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;
|
||||
|
||||
mapObj.setExtent(ext, true)
|
||||
}
|
||||
}
|
||||
|
||||
function showPonit() {
|
||||
graphicLayer.clear();
|
||||
var latitude = selLatitude;
|
||||
var longitude = selLongitude;
|
||||
if (latitude == 0 && longitude == 0) return;
|
||||
var point = new esri.geometry.Point({
|
||||
latitude: latitude,
|
||||
longitude: longitude
|
||||
});
|
||||
|
||||
var symbol = new esri.symbol.TextSymbol({
|
||||
color: [0xf7, 0xc0, 0x03],//#f7c003
|
||||
haloColor: "black",
|
||||
haloSize: "1px",
|
||||
text: "\uf3c5",
|
||||
xoffset: 3,
|
||||
yoffset: 3,
|
||||
font: { // autocast as esri/symbols/Font
|
||||
size: 32,
|
||||
family: "FontAwesome",
|
||||
weight: "bolder"
|
||||
}
|
||||
});
|
||||
var graphic = new esri.Graphic(point, symbol);
|
||||
graphicLayer.add(graphic);
|
||||
|
||||
mapObj.centerAt(graphic.geometry);
|
||||
}
|
||||
}
|
169
Site/js/mapview/adj_enginehours.js
Normal file
169
Site/js/mapview/adj_enginehours.js
Normal file
@ -0,0 +1,169 @@
|
||||
|
||||
//************************Add Engine Hours**************************************//
|
||||
var isAddEH = true;
|
||||
var primarydatadourceMVEH;
|
||||
var assetdataEH;
|
||||
function openAddEnginHours(asset) {
|
||||
primarydatadourceMVEH = undefined;
|
||||
assetdataEH = asset;
|
||||
var datetime = customerdatetime.split(' ');
|
||||
var time = datetime[0];
|
||||
var st = datetime[1].split(':');
|
||||
var hours = st[0].length == 1 ? "0" + st[0] : st[0];
|
||||
var minutes = st[1];
|
||||
$('#dialogaddgenginehours_enginehours').val('');
|
||||
$('#dialogadd_enginehourstimezone').val(customertimezone ? customertimezone : "UTC");
|
||||
$('#dialogaddenginehours_date').val(time);
|
||||
$('#dialogaddenginehours_timehour').val(hours);
|
||||
$('#dialogaddenginehours_timeminute').val(minutes);
|
||||
$('#dialogaddenginehours_Notes').val('');
|
||||
if (assetdataEH.TelematicsEnabled && !assetdataEH.EngineHours.IsEmpty &&
|
||||
(assetdataEH.EngineHours.DataSource.toLowerCase() == "calamp" || assetdataEH.EngineHours.DataSource.toLowerCase() == "pedigree")) {
|
||||
isAddEH = false;
|
||||
primarydatadourceMVEH = assetdataEH.EngineHours.DataSource;
|
||||
}
|
||||
else
|
||||
isAddEH = true;
|
||||
|
||||
$('#dialog_addenginehours .dialog-title span.title').text(isAddEH ? GetTextByKey("P_MV_ADDENGINEHOURS", 'Add Engine Hours') : GetTextByKey("P_MV_ADJUSTENGINEHOURS", 'Adjust Engine Hours'));
|
||||
showmaskbg(true);
|
||||
$('#dialog_addenginehours')
|
||||
.attr('act', 'add')
|
||||
.css({
|
||||
'top': (document.documentElement.clientHeight - $('#dialog_addenginehours').height()) / 3,
|
||||
'left': (document.documentElement.clientWidth - $('#dialog_addenginehours').width()) / 2
|
||||
})
|
||||
.showDialogfixed();
|
||||
$('#dialogaddgenginehours_enginehours').focus();
|
||||
}
|
||||
|
||||
|
||||
function OnAddEngineHours() {
|
||||
$('#addenginehoursmask').show();
|
||||
|
||||
var alerttitle = isAddEH ? GetTextByKey("P_MV_ADDENGINEHOURS", 'Add Engine Hours') : GetTextByKey("P_MV_ADJUSTENGINEHOURS", 'Adjust Engine Hours');
|
||||
var contractorid = $("#selContractor").val();
|
||||
if (!contractorid) contractorid = "";
|
||||
var item = {
|
||||
'CustomerID': contractorid,
|
||||
'AssetID': assetdataEH.Id,
|
||||
'EngineHours': $('#dialogaddgenginehours_enginehours').val(),
|
||||
'EngineHoursDate': $('#dialogaddenginehours_date').val(),
|
||||
'Notes': $('#dialogaddenginehours_Notes').val(),
|
||||
'DataSource': primarydatadourceMVEH
|
||||
};
|
||||
if (item.EngineHours !== "") {
|
||||
if (isNaN(item.EngineHours)) {
|
||||
_dialog.showAlert(GetTextByKey("P_MV_ENGINEHOURSFORMATERROR", 'Engine Hours format error.'), alerttitle);
|
||||
$('#addenginehoursmask').hide();
|
||||
return;
|
||||
}
|
||||
else {
|
||||
if (item.EngineHours <= 0) {
|
||||
_dialog.showAlert(GetTextByKey("P_MV_ENGINEHOURSMUSTBEGREATERTHAN0", 'Engine Hours must be greater than 0.'), alerttitle);
|
||||
$('#addenginehoursmask').hide();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
_dialog.showAlert(GetTextByKey("P_MV_ENGINEHOURSCANNOTBEEMPTY", "Engine Hours cannot be empty."), alerttitle);
|
||||
$('#addenginehoursmask').hide();
|
||||
return;
|
||||
}
|
||||
|
||||
if (item.EngineHoursDate === "") {
|
||||
_dialog.showAlert(GetTextByKey("P_MV_ENGINEHOURSDATECANNOTBEEMPTY", "Engine Hours Date cannot be empty."), alerttitle);
|
||||
$('#addenginehoursmask').hide();
|
||||
return;
|
||||
}
|
||||
var offset = $('#dialogadd_enginehourstimezone').find("option:selected").attr("offset");
|
||||
item.OffsetMinute = offset;
|
||||
var timezonetext = $('#dialogadd_enginehourstimezone').find("option:selected").text();
|
||||
var hour = $('#dialogaddenginehours_timehour').val();
|
||||
var minute = $('#dialogaddenginehours_timeminute').val();
|
||||
item.EngineHoursDate = item.EngineHoursDate.replace("-", "/") + " " + hour + ":" + minute + ":" + "00";
|
||||
|
||||
var time = hour + ":" + minute
|
||||
var alertmsg = "";
|
||||
if (isAddEH) {
|
||||
alertmsg = GetTextByKey("P_MV_UPDATEENGINEHOURS", "Do you want to update the engine hours to reflect: {0} hours at {1} {2}?").replace('{0}', item.EngineHours).replace('{1}', time).replace('{2}', timezonetext);
|
||||
}
|
||||
else {
|
||||
alertmsg = GetTextByKey("P_MV_UPDATEENGINEHOURS1", "If you proceed, engine hours will be updated to reflect: {0} hours at {1} <br/>" +
|
||||
" {2}. <br/><br/>Note that this asset is telematic enabled and the primary data source is {3}." +
|
||||
"<br/><br/> Would you like to proceed?").replace('{0}', item.EngineHours).replace('{1}', time).replace('{2}', timezonetext).replace('{3}', assetdataEH.EngineHours.DataSourceName);
|
||||
}
|
||||
|
||||
showConfirm1(alertmsg, alerttitle, function () {
|
||||
$('#addenginehoursmask').hide();
|
||||
if (isAddEH)
|
||||
AddManuallyInputEngineHours(item, alerttitle);
|
||||
else
|
||||
CheckEngineHourMinimumTime(item, alerttitle);
|
||||
|
||||
}, function () {
|
||||
$('#addenginehoursmask').hide();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function AddManuallyInputEngineHours(item, alerttitle) {
|
||||
var param = JSON.stringify(item);
|
||||
param = htmlencode(param);
|
||||
|
||||
devicerequest("AddManuallyInputEngineHours", param, function (data) {
|
||||
if (data !== 'OK') {
|
||||
_dialog.showAlert(data, alerttitle);
|
||||
} else {
|
||||
//loadAssetInfo();
|
||||
_dialog.showAlert(GetTextByKey("P_MV_ENGINEHOURSUPDATESUCCESSFUL", "Engine Hours Update Successful."), alerttitle);
|
||||
}
|
||||
|
||||
$('#dialog_addenginehours').hideDialog();
|
||||
$('#addenginehoursmask').hide();
|
||||
}, function (err) {
|
||||
console.log(err);
|
||||
_dialog.showAlert(GetTextByKey("P_MV_FAILEDTOADDENGINEHOURS", 'Failed to add Engine Hours.'), alerttitle);
|
||||
$('#addenginehoursmask').hide();
|
||||
});
|
||||
}
|
||||
|
||||
function CheckEngineHourMinimumTime(item, alerttitle) {
|
||||
var param = JSON.stringify(item);
|
||||
param = htmlencode(param);
|
||||
devicerequest("CheckEngineHourMinimumTime", param, function (data) {
|
||||
if (data > 0) {
|
||||
if (data == 1)
|
||||
_dialog.showAlert(GetTextByKey("P_MV_CHECKENGINEHOURSMINNIMUMTIME", "The adjustment cannot be completed as provided. The engine hours reading date provided cannot be prior to initial telematic data available for the asset."), alerttitle);
|
||||
else
|
||||
_dialog.showAlert(GetTextByKey("P_MV_CHECKENGINEHOURSMINNIMUMTIME1", "The adjustment cannot be completed as provided. The engine hours reading date provided must be prior to or equal to the latest telematic data available for the asset."), alerttitle);
|
||||
$('#addenginehoursmask').hide();
|
||||
return;
|
||||
} else {
|
||||
SaveAdjustEngineHours(item, alerttitle);
|
||||
}
|
||||
}, function (err) {
|
||||
});
|
||||
}
|
||||
|
||||
function SaveAdjustEngineHours(item, alerttitle) {
|
||||
var param = JSON.stringify(item);
|
||||
param = htmlencode(param);
|
||||
|
||||
devicerequest("SaveAdjustEngineHours", param, function (data) {
|
||||
if (data !== 'OK') {
|
||||
_dialog.showAlert(data, alerttitle);
|
||||
} else {
|
||||
//loadAssetInfo();
|
||||
_dialog.showAlert(GetTextByKey("P_MV_ENGINEHOURSUPDATESUCCESSFUL", "Engine Hours Update Successful."), alerttitle);
|
||||
}
|
||||
|
||||
$('#dialog_addenginehours').hideDialog();
|
||||
$('#addenginehoursmask').hide();
|
||||
}, function (err) {
|
||||
console.log(err);
|
||||
_dialog.showAlert(GetTextByKey("P_MV_FAILEDTOADJUSTENGINEHOURS", 'Failed to adjust Engine Hours.'), alerttitle);
|
||||
$('#addenginehoursmask').hide();
|
||||
});
|
||||
}
|
165
Site/js/mapview/adj_odometer.js
Normal file
165
Site/js/mapview/adj_odometer.js
Normal file
@ -0,0 +1,165 @@
|
||||
|
||||
//************************Add Odometer**************************************//
|
||||
var isAddOdo = true;
|
||||
var primarydatadourceMVOdo;
|
||||
var assetdataOdo;
|
||||
function openAddOdometer(asset) {
|
||||
primarydatadourceMVOdo = undefined;
|
||||
assetdataOdo = asset;
|
||||
var datetime = customerdatetime.split(' ');
|
||||
var time = datetime[0];
|
||||
var st = datetime[1].split(':');
|
||||
var hours = st[0].length == 1 ? "0" + st[0] : st[0];
|
||||
var minutes = st[1];
|
||||
$('#dialogadd_odometer').val('');
|
||||
$('#dialogadd_sel_odometeruom').val(systemunitofodometer);
|
||||
$('#dialogadd_odometertimezone').val(customertimezone ? customertimezone : "UTC");
|
||||
$('#dialogadd_odometerdate').val(time);
|
||||
$('#dialogadd_timehour').val(hours);
|
||||
$('#dialogadd_timeminute').val(minutes);
|
||||
$('#dialogadd_notes').val('');
|
||||
if (assetdataOdo.TelematicsEnabled && !assetdataOdo.Odometer.IsEmpty &&
|
||||
(assetdataOdo.Odometer.DataSource.toLowerCase() == "calamp" || assetdataOdo.Odometer.DataSource.toLowerCase() == "pedigree")) {
|
||||
isAddOdo = false;
|
||||
primarydatadourceMVOdo = assetdataOdo.Odometer.DataSource;
|
||||
}
|
||||
else
|
||||
isAddOdo = true;
|
||||
|
||||
$('#dialog_addodometer .dialog-title span.title').text(isAddOdo ? GetTextByKey("P_MV_ADDODOMETER", 'Add Odometer') : GetTextByKey("P_MV_ADJUSTODOMETER", 'Adjust Odometer'));
|
||||
showmaskbg(true);
|
||||
$('#dialog_addodometer')
|
||||
.attr('act', 'add')
|
||||
.css({
|
||||
'top': (document.documentElement.clientHeight - $('#dialog_addodometer').height()) / 3,
|
||||
'left': (document.documentElement.clientWidth - $('#dialog_addodometer').width()) / 2
|
||||
})
|
||||
.showDialogfixed();
|
||||
$('#dialogadd_odometer').focus();
|
||||
}
|
||||
|
||||
function OnAddOdometer() {
|
||||
$('#addodomask').show();
|
||||
var alerttitle = isAddOdo ? GetTextByKey("P_MV_ADDODOMETER", 'Add Odometer') : GetTextByKey("P_MV_ADJUSTODOMETER", 'Adjust Odometer');
|
||||
var contractorid = $("#selContractor").val();
|
||||
if (!contractorid) contractorid = "";
|
||||
var item = {
|
||||
'CustomerID': contractorid,
|
||||
'AssetID': assetdataOdo.Id,
|
||||
'Odometer': $('#dialogadd_odometer').val(),
|
||||
'UOM': $('#dialogadd_sel_odometeruom').val(),
|
||||
'OdometerDate': $('#dialogadd_odometerdate').val(),
|
||||
'Notes': $('#dialogadd_notes').val(),
|
||||
'DataSource': primarydatadourceMVOdo
|
||||
};
|
||||
if (item.Odometer !== "") {
|
||||
if (isNaN(item.Odometer)) {
|
||||
_dialog.showAlert(GetTextByKey("P_MV_ODOMETERFORMATERROR", 'Odometer format error.'), alerttitle);
|
||||
$('#addodomask').hide();
|
||||
return;
|
||||
}
|
||||
else {
|
||||
if (item.Odometer <= 0) {
|
||||
_dialog.showAlert(GetTextByKey("P_MV_ODOMETERMUSTBEGREATERTHAN0", 'ODOMeter must be greater than 0.'), alerttitle);
|
||||
$('#addodomask').hide();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
_dialog.showAlert(GetTextByKey("P_MV_ODOMETRCANNOTBEEMPTY", "Odometer cannot be empty."), alerttitle);
|
||||
$('#addodomask').hide();
|
||||
return;
|
||||
}
|
||||
|
||||
if (item.OdometerDate === "") {
|
||||
_dialog.showAlert(GetTextByKey("P_MV_ODOMETRDATACANNOTBEEMPTY", "Odometer date cannot be empty."), alerttitle);
|
||||
$('#addodomask').hide();
|
||||
return;
|
||||
}
|
||||
var offset = $('#dialogadd_odometertimezone').find("option:selected").attr("offset");
|
||||
item.OffsetMinute = offset;
|
||||
var timezonetext = $('#dialogadd_enginehourstimezone').find("option:selected").text();
|
||||
|
||||
var hour = $('#dialogadd_timehour').val();
|
||||
var minute = $('#dialogadd_timeminute').val();
|
||||
|
||||
item.OdometerDate = item.OdometerDate.replace("-", "/") + " " + hour + ":" + minute + ":" + "00";
|
||||
|
||||
var time = hour + ":" + minute
|
||||
var alertmsg = "";
|
||||
if (isAddOdo) {
|
||||
alertmsg = GetTextByKey("P_MV_UPDATETHEODOMETER", "Do you want to update the odometer to reflect: {0} {1} at {2} {3}?").replace('{0}', item.Odometer).replace('{1}', item.UOM).replace('{2}', time).replace('{3}', timezonetext);
|
||||
}
|
||||
else {
|
||||
alertmsg = GetTextByKey("P_MV_UPDATETHEODOMETER1", "If you proceed, odometer will be updated to reflect: {0} {1} at {2} <br/> {3}.<br/><br/> Note that this asset is telematic enabled and the primary data source is {4}.<br/><br/>Would you like to proceed?").replace('{0}', item.Odometer).replace('{1}', item.UOM).replace('{2}', time).replace('{3}', timezonetext).replace('{4}', assetdataOdo.Odometer.DataSourceName);
|
||||
}
|
||||
|
||||
showConfirm1(alertmsg, alerttitle, function () {
|
||||
$('#addodomask').hide();
|
||||
if (isAddOdo)
|
||||
AddManuallyInputOdometer(item, alerttitle);
|
||||
else
|
||||
CheckOdometerMinnimumTime(item, alerttitle);
|
||||
|
||||
}, function () {
|
||||
$('#addodomask').hide();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function AddManuallyInputOdometer(item, alerttitle) {
|
||||
var param = JSON.stringify(item);
|
||||
param = htmlencode(param);
|
||||
devicerequest("AddManuallyInputOdometer", param, function (data) {
|
||||
if (data !== 'OK') {
|
||||
_dialog.showAlert(data, alerttitle);
|
||||
} else {
|
||||
//loadAssetInfo();
|
||||
_dialog.showAlert(GetTextByKey("P_MV_ODOMETERUPDATESUCCESSFUL", "Odometer Update Successful."), alerttitle);
|
||||
}
|
||||
|
||||
$('#dialog_addodometer').hideDialog();
|
||||
$('#addodomask').hide();
|
||||
}, function (err) {
|
||||
_dialog.showAlert(GetTextByKey("P_MV_FAILEDTOADDODOMETER", 'Failed to add Odometer.'), alerttitle);
|
||||
$('#addodomask').hide();
|
||||
});
|
||||
}
|
||||
|
||||
function CheckOdometerMinnimumTime(item, alerttitle) {
|
||||
var param = JSON.stringify(item);
|
||||
param = htmlencode(param);
|
||||
devicerequest("CheckOdometerMinnimumTime", param, function (data) {
|
||||
if (data > 0) {
|
||||
if (data == 1)
|
||||
_dialog.showAlert(GetTextByKey("P_MA_CHECKODOMETERMINNIMUMTIME", "The adjustment cannot be completed as provided. The odometer reading date provided cannot be prior to initial telematic data available for the asset."), alerttitle);
|
||||
else
|
||||
_dialog.showAlert(GetTextByKey("P_MA_CHECKODOMETERMINNIMUMTIME1", "The adjustment cannot be completed as provided. The odometer reading date provided must be prior to or equal to the latest telematic data available for the asset."), alerttitle);
|
||||
$('#addodomask').hide();
|
||||
return;
|
||||
} else {
|
||||
SaveAdjustOdometer(item, alerttitle);
|
||||
}
|
||||
}, function (err) {
|
||||
});
|
||||
}
|
||||
|
||||
function SaveAdjustOdometer(item, alerttitle) {
|
||||
var param = JSON.stringify(item);
|
||||
param = htmlencode(param);
|
||||
devicerequest("SaveAdjustOdometer", param, function (data) {
|
||||
if (data !== 'OK') {
|
||||
_dialog.showAlert(data, alerttitle);
|
||||
} else {
|
||||
//loadAssetInfo();
|
||||
_dialog.showAlert(GetTextByKey("P_MV_ODOMETERUPDATESUCCESSFUL", "Odometer Update Successful."), alerttitle);
|
||||
}
|
||||
|
||||
$('#dialog_addodometer').hideDialog();
|
||||
$('#addodomask').hide();
|
||||
}, function (err) {
|
||||
_dialog.showAlert(GetTextByKey("P_MV_FAILEDTOADJUSTODOMETER", 'Failed to adjust Odometer.'), alerttitle);
|
||||
$('#addodomask').hide();
|
||||
});
|
||||
}
|
948
Site/js/mapview/asset.js
Normal file
948
Site/js/mapview/asset.js
Normal file
@ -0,0 +1,948 @@
|
||||
|
||||
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 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
|
||||
},
|
||||
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();
|
||||
},
|
||||
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.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
|
||||
},
|
||||
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加载完成后执行
|
||||
this.getCompanyLocations();
|
||||
this.loadMapAlertLayer(isauto);
|
||||
|
||||
displayFilerIcon();
|
||||
}
|
||||
|
||||
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();
|
||||
});
|
||||
}
|
||||
|
||||
function convertAssetObjs(data) {
|
||||
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.VIN = ss[1];
|
||||
a.Name = ss[2];
|
||||
a.Name2 = ss[3];
|
||||
a.Make = ss[4];
|
||||
a.Model = ss[5];
|
||||
a.AssetType = ss[6];
|
||||
|
||||
a.Latitude = Number(ss[7]);
|
||||
a.Longitude = Number(ss[8]);
|
||||
a.IconUrl = ss[9];
|
||||
a.AlertTips = ss[10];
|
||||
a.Priority = Number(ss[11]);
|
||||
|
||||
if (ss[12] && ss[12] !== "") {
|
||||
a.AssetGroups = ss[12].split(",")
|
||||
}
|
||||
else {
|
||||
a.AssetGroups = [];
|
||||
}
|
||||
|
||||
if (ss[13] && ss[13] !== "") {
|
||||
a.JobSites = ss[13].split(",");
|
||||
}
|
||||
else {
|
||||
a.JobSites = [];
|
||||
}
|
||||
|
||||
a.DisplayName = a.Name2;
|
||||
if (!a.DisplayName || a.DisplayName === "")
|
||||
a.DisplayName = a.Name;
|
||||
if (!a.DisplayName || a.DisplayName === "")
|
||||
a.DisplayName = a.VIN;
|
||||
if (!a.DisplayName || a.DisplayName === "")
|
||||
a.DisplayName = a.ID;
|
||||
|
||||
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");
|
||||
$("#contentCtrl").css("top", 115 + 30);
|
||||
}
|
||||
else {
|
||||
$("#btnToggleTimeline").show();
|
||||
$("#btnImportShapeFile").show();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
this.getCompanyLocations = function () {
|
||||
var _this = this;
|
||||
_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;
|
||||
var _this = this;
|
||||
_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();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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.Name) + "<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;
|
||||
}
|
||||
|
33
Site/js/mapview/assetview.js
Normal file
33
Site/js/mapview/assetview.js
Normal file
@ -0,0 +1,33 @@
|
||||
/***this file is used in MapView.aspx****/
|
||||
var PopupViewShowing = false;
|
||||
|
||||
function machineDetailClick(m) {
|
||||
if (m) {
|
||||
showMachineDetail(m.CompanyID, m.ID, m.VIN);
|
||||
|
||||
clearLocationHistory();//关闭历史记录
|
||||
$("#locationhistoryDiv").hide();
|
||||
$("#tripDiv").hide();
|
||||
|
||||
if (selectedAsset)
|
||||
selectedAsset.State.Highlight = false;
|
||||
m.State.Highlight = true;
|
||||
selectedAsset = m;
|
||||
}
|
||||
}
|
||||
|
||||
function showMachineDetail(cid, mid, vin) {
|
||||
$("#divassetview").show();
|
||||
$('#divtimelineview').hide();
|
||||
$("#divmapview").hide();
|
||||
execIframeFunc("loadAsset", [cid, mid, vin, 0], "ifassetview");
|
||||
PopupViewShowing = true;
|
||||
}
|
||||
function closePopupView() {
|
||||
$("#divassetview").hide();
|
||||
$('#divtimelineview').hide();
|
||||
$("#divmapview").show();
|
||||
PopupViewShowing = false;
|
||||
if (selectedAsset)
|
||||
selectedAsset.State.Highlight = false;
|
||||
}
|
603
Site/js/mapview/clusterlayer.js
Normal file
603
Site/js/mapview/clusterlayer.js
Normal file
@ -0,0 +1,603 @@
|
||||
define([
|
||||
"dojo/_base/declare",
|
||||
"dojo/_base/array",
|
||||
"esri/Color",
|
||||
"dojo/_base/connect",
|
||||
|
||||
"esri/SpatialReference",
|
||||
"esri/geometry/Point",
|
||||
"esri/graphic",
|
||||
"esri/symbols/SimpleMarkerSymbol",
|
||||
"esri/symbols/PictureMarkerSymbol",
|
||||
"esri/symbols/TextSymbol",
|
||||
"esri/symbols/Font",
|
||||
"esri/geometry/webMercatorUtils",
|
||||
|
||||
"esri/dijit/PopupTemplate",
|
||||
"esri/layers/GraphicsLayer"
|
||||
], function (
|
||||
declare, arrayUtils, Color, connect,
|
||||
SpatialReference, Point, Graphic, SimpleMarkerSymbol, PictureMarkerSymbol, TextSymbol, Font, webMercatorUtils,
|
||||
PopupTemplate, GraphicsLayer
|
||||
) {
|
||||
return declare([GraphicsLayer], {
|
||||
constructor: function (options) {
|
||||
// options:
|
||||
// data: Object[]
|
||||
// Array of objects. Required. Object are required to have properties named x, y and attributes. The x and y coordinates have to be numbers that represent a points coordinates.
|
||||
// distance: Number?
|
||||
// Optional. The max number of pixels between points to group points in the same cluster. Default value is 50.
|
||||
// labelColor: String?
|
||||
// Optional. Hex string or array of rgba values used as the color for cluster labels. Default value is #fff (white).
|
||||
// labelOffset: String?
|
||||
// Optional. Number of pixels to shift a cluster label vertically. Defaults to -5 to align labels with circle symbols. Does not work in IE.
|
||||
// resolution: Number
|
||||
// Required. Width of a pixel in map coordinates. Example of how to calculate:
|
||||
// map.extent.getWidth() / map.width
|
||||
// showSingles: Boolean?
|
||||
// Optional. Whether or graphics should be displayed when a cluster graphic is clicked. Default is true.
|
||||
// singleSymbol: MarkerSymbol?
|
||||
// Marker Symbol (picture or simple). Optional. Symbol to use for graphics that represent single points. Default is a small gray SimpleMarkerSymbol.
|
||||
// singleTemplate: PopupTemplate?
|
||||
// PopupTemplate</a>. Optional. Popup template used to format attributes for graphics that represent single points. Default shows all attributes as "attribute = value" (not recommended).
|
||||
// maxSingles: Number?
|
||||
// Optional. Threshold for whether or not to show graphics for points in a cluster. Default is 1000.
|
||||
// webmap: Boolean?
|
||||
// Optional. Whether or not the map is from an ArcGIS.com webmap. Default is false.
|
||||
// spatialReference: SpatialReference?
|
||||
// Optional. Spatial reference for all graphics in the layer. This has to match the spatial reference of the map. Default is 102100. Omit this if the map uses basemaps in web mercator.
|
||||
|
||||
this._clusterTolerance = options.distance || 60;
|
||||
this._clusterData = options.data || [];
|
||||
this._clusters = [];
|
||||
this._clusterLabelColor = options.labelColor || "#000";
|
||||
this._clusterLabelFontSize = options.labelFontSize || "12px";
|
||||
this._clusterLabelFontFamily = options.labelFontFamily || "Calibri";
|
||||
this._clusterLabelFontWeight = options.labelFontWeight || Font.WEIGHT_NORMAL;
|
||||
// labelOffset can be zero so handle it differently
|
||||
this._clusterLabelOffset = (options.hasOwnProperty("labelOffset")) ? options.labelOffset : -5;
|
||||
// graphics that represent a single point
|
||||
this._singles = []; // populated when a graphic is clicked
|
||||
this._showSingles = options.hasOwnProperty("showSingles") ? options.showSingles : false;
|
||||
// symbol for single graphics
|
||||
var SMS = SimpleMarkerSymbol;
|
||||
this._singleSym = options.singleSymbol || new SMS("circle", 6, null, new Color("#888"));
|
||||
this._singleTemplate = options.singleTemplate || new PopupTemplate({ "title": "", "description": "{infoContent}" });
|
||||
this._maxSingles = options.maxSingles || 1000;
|
||||
|
||||
this._webmap = options.hasOwnProperty("webmap") ? options.webmap : false;
|
||||
|
||||
this._sr = options.spatialReference;// || new SpatialReference({ "wkid": 4326 });
|
||||
|
||||
this._zoomEnd = null;
|
||||
//this._popupChanged = null;
|
||||
this._getClusterResolution = null;
|
||||
|
||||
this._popupedClusterData = null;//当前Popup显示的点
|
||||
},
|
||||
|
||||
// override esri/layers/GraphicsLayer methods
|
||||
_setMap: function (map, surface) {
|
||||
this._getClusterResolution = function (map) {
|
||||
// calculate and set the initial resolution
|
||||
var ext = map.extent;
|
||||
ext = webMercatorUtils.webMercatorToGeographic(ext);
|
||||
// update resolution
|
||||
this._clusterResolution = ext.getHeight() / map.height;
|
||||
};
|
||||
|
||||
// connect to onZoomEnd so data is re-clustered when zoom level changes
|
||||
this._zoomEnd = connect.connect(map, "onZoomEnd", this, function () {
|
||||
this.reloadData();
|
||||
});
|
||||
|
||||
//this._popupChanged = connect.connect(map.infoWindow, "onSelectionChange", function () {
|
||||
// var graphic = map.infoWindow.getSelectedFeature();
|
||||
// //showInfoWindow(graphic);
|
||||
// //map.infoWindow.selectedIndex
|
||||
// //map.infoWindow.count
|
||||
//});
|
||||
|
||||
this._getClusterResolution(map);
|
||||
this.clear();
|
||||
this._clusterGraphics();
|
||||
|
||||
// GraphicsLayer will add its own listener here
|
||||
var div = this.inherited(arguments);
|
||||
return div;
|
||||
},
|
||||
|
||||
_unsetMap: function () {
|
||||
this.inherited(arguments);
|
||||
connect.disconnect(this._zoomEnd);
|
||||
connect.disconnect(this._popupChanged);
|
||||
},
|
||||
|
||||
reloadData: function () {
|
||||
if (typeof this._getClusterResolution !== 'function') {
|
||||
var _this = this;
|
||||
setTimeout(function () {
|
||||
_this.reloadData();
|
||||
}, 200);
|
||||
console.log("reloadData");
|
||||
return;
|
||||
}
|
||||
this._getClusterResolution(this._map);
|
||||
this.clear();
|
||||
this._clusterGraphics();
|
||||
|
||||
//重新显示Popup
|
||||
//this._map.infoWindow.hide();
|
||||
//this.clearSingles();
|
||||
if (this._popupedClusterData != null)
|
||||
this.locate(this._popupedClusterData);
|
||||
},
|
||||
|
||||
// public ClusterLayer methods
|
||||
add: function (p) {
|
||||
// Summary: The argument is a data point to be added to an existing cluster. If the data point falls within an existing cluster, it is added to that cluster and the cluster's label is updated. If the new point does not fall within an existing cluster, a new cluster is created.
|
||||
//
|
||||
// if passed a graphic, use the GraphicsLayer's add method
|
||||
if (p.declaredClass) {
|
||||
this.inherited(arguments);
|
||||
return;
|
||||
}
|
||||
|
||||
// add the new data to _clusterData so that it's included in clusters
|
||||
// when the map level changes
|
||||
this._clusterData.push(p);
|
||||
var clustered = false;
|
||||
// look for an existing cluster for the new point
|
||||
for (var i = 0; i < this._clusters.length; i++) {
|
||||
var c = this._clusters[i];
|
||||
if (this._clusterTest(p, c)) {
|
||||
// add the point to an existing cluster
|
||||
this._clusterAddPoint(p, c);
|
||||
// update the cluster's geometry
|
||||
this._updateClusterGeometry(c);
|
||||
// update the label
|
||||
this._updateLabel(c);
|
||||
clustered = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!clustered) {
|
||||
this._clusterCreate(p);
|
||||
p.attributes.clusterCount = 1;
|
||||
this._showCluster(p);
|
||||
}
|
||||
},
|
||||
|
||||
// public ClusterLayer methods
|
||||
adds: function (ps) {
|
||||
for (var j = 0; j < ps.length; j++) {
|
||||
var p = ps[j];
|
||||
// Summary: The argument is a data point to be added to an existing cluster. If the data point falls within an existing cluster, it is added to that cluster and the cluster's label is updated. If the new point does not fall within an existing cluster, a new cluster is created.
|
||||
//
|
||||
// if passed a graphic, use the GraphicsLayer's add method
|
||||
if (p.declaredClass) {
|
||||
this.inherited(arguments);
|
||||
return;
|
||||
}
|
||||
|
||||
// add the new data to _clusterData so that it's included in clusters
|
||||
// when the map level changes
|
||||
this._clusterData.push(p);
|
||||
}
|
||||
this.reloadData();
|
||||
},
|
||||
|
||||
remove: function (p) {
|
||||
if (p.declaredClass) {
|
||||
this.inherited(arguments);
|
||||
return;
|
||||
}
|
||||
// look for an existing cluster for the new point
|
||||
for (var i = 0; i < this._clusterData.length; i++) {
|
||||
var cd = this._clusterData[i];
|
||||
if (cd.id == p.id) {
|
||||
this._clusterData.splice(i, 1);
|
||||
this.reloadData();
|
||||
break;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
removes: function (ps) {
|
||||
for (var j = 0; j < ps.length; j++) {
|
||||
var p = ps[j];
|
||||
if (p.declaredClass) {
|
||||
this.inherited(p);
|
||||
continue;
|
||||
}
|
||||
// look for an existing cluster for the new point
|
||||
for (var i = 0; i < this._clusterData.length; i++) {
|
||||
var cd = this._clusterData[i];
|
||||
if (cd.id == p.id) {
|
||||
this._clusterData.splice(i, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.reloadData();
|
||||
},
|
||||
|
||||
removebyid: function (psid) {
|
||||
var clusterdata = [];
|
||||
for (var i = 0; i < this._clusterData.length; i++) {
|
||||
var cd = this._clusterData[i];
|
||||
if (psid.indexOf(cd.id) < 0) {
|
||||
clusterdata.push(cd);
|
||||
}
|
||||
}
|
||||
this._clusterData = clusterdata;
|
||||
this.reloadData();
|
||||
},
|
||||
|
||||
locate: function (p, center, notShowInfowindow) {
|
||||
// look for an existing cluster for the new point
|
||||
var _this = this;
|
||||
if (!this._map) {
|
||||
setTimeout(function () {
|
||||
_this.locate(p, center, notShowInfowindow);
|
||||
},200)
|
||||
return;
|
||||
}
|
||||
var cp = null;
|
||||
for (var i = 0; i < this._clusterData.length; i++) {
|
||||
var cd = this._clusterData[i];
|
||||
if (cd.id == p.id) {
|
||||
cp = cd;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (cp) {
|
||||
// remove any previously showing single features
|
||||
this.clearSingles(this._singles);
|
||||
var cg = arrayUtils.filter(this.graphics, function (g) {
|
||||
return g.symbol &&
|
||||
g.symbol.declaredClass == "esri.symbol.PictureMarkerSymbol" &&
|
||||
g.attributes.clusterId == cp.attributes.clusterId;
|
||||
});
|
||||
if (cg.length == 1) {
|
||||
this._popupedClusterData = null;
|
||||
var singles = [];
|
||||
var index = 0;
|
||||
for (var i = 0, il = this._clusterData.length; i < il; i++) {
|
||||
if (cg[0].attributes.clusterId == this._clusterData[i].attributes.clusterId) {
|
||||
singles.push(this._clusterData[i]);
|
||||
if (this._popupedClusterData == null)
|
||||
this._popupedClusterData = this._clusterData[i];
|
||||
if (this._clusterData[i].id == p.id) {
|
||||
index = singles.length - 1;
|
||||
this._popupedClusterData = this._clusterData[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
var tmap = this._map;
|
||||
this._addSingles(singles);
|
||||
setTimeout(function () {
|
||||
if (enableInfoWindow && !notShowInfowindow) {
|
||||
tmap.infoWindow.show(cg[0].geometry);
|
||||
tmap.infoWindow.resize(320, 340);//resize只能设置max-height
|
||||
$(".contentPane").css("height", 340);
|
||||
}
|
||||
tmap.infoWindow.select(index);
|
||||
|
||||
if (center) {
|
||||
var point = new Point({
|
||||
longitude: p.x,
|
||||
latitude: p.y
|
||||
});
|
||||
tmap.centerAt(point);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
else {
|
||||
var tmap = this._map;
|
||||
setTimeout(function () {
|
||||
tmap.infoWindow.hide();
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
clear: function () {
|
||||
// Summary: Remove all clusters and data points.
|
||||
this.inherited(arguments);
|
||||
this._clusters.length = 0;
|
||||
},
|
||||
|
||||
clearData: function () {
|
||||
// Summary: Remove all clusters, data and points.
|
||||
this.clear();
|
||||
this._clusterData = [];
|
||||
this._popupedClusterData = null;
|
||||
arrayUtils.clearCache();
|
||||
},
|
||||
|
||||
clearSingles: function (singles) {
|
||||
// Summary: Remove graphics that represent individual data points.
|
||||
var s = singles || this._singles;
|
||||
if (this._showSingles) {
|
||||
arrayUtils.forEach(s, function (g) {
|
||||
this.remove(g);
|
||||
}, this);
|
||||
}
|
||||
this._singles.length = 0;
|
||||
this._map.infoWindow.clearFeatures();
|
||||
},
|
||||
|
||||
onClick: function (e) {
|
||||
// remove any previously showing single features
|
||||
this.clearSingles(this._singles);
|
||||
|
||||
// find single graphics that make up the cluster that was clicked
|
||||
// would be nice to use filter but performance tanks with large arrays in IE
|
||||
this._popupedClusterData = null;
|
||||
var singles = [];
|
||||
for (var i = 0, il = this._clusterData.length; i < il; i++) {
|
||||
if (e.graphic.attributes.clusterId == this._clusterData[i].attributes.clusterId) {
|
||||
singles.push(this._clusterData[i]);
|
||||
if (this._popupedClusterData == null)
|
||||
this._popupedClusterData = this._clusterData[i];
|
||||
}
|
||||
}
|
||||
|
||||
//if (singles.length > this._maxSingles) {
|
||||
// alert("Sorry, that cluster contains more than " + this._maxSingles + " points. Zoom in for more detail.");
|
||||
// return;
|
||||
//} else {
|
||||
// stop the click from bubbling to the map
|
||||
e.stopPropagation();
|
||||
if (enableInfoWindow) {
|
||||
this._map.infoWindow.show(e.graphic.geometry);
|
||||
this._map.infoWindow.resize(320, 340);//resize只能设置max-height
|
||||
$(".contentPane").css("height", 340);
|
||||
}
|
||||
this._addSingles(singles);
|
||||
//}
|
||||
},
|
||||
|
||||
// internal methods
|
||||
_clusterGraphics: function () {
|
||||
// first time through, loop through the points
|
||||
for (var j = 0, jl = this._clusterData.length; j < jl; j++) {
|
||||
// see if the current feature should be added to a cluster
|
||||
var point = this._clusterData[j];
|
||||
var clustered = false;
|
||||
var numClusters = this._clusters.length;
|
||||
for (var i = 0; i < this._clusters.length; i++) {
|
||||
var c = this._clusters[i];
|
||||
if (this._clusterTest(point, c)) {
|
||||
this._clusterAddPoint(point, c);
|
||||
clustered = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!clustered) {
|
||||
this._clusterCreate(point);
|
||||
}
|
||||
}
|
||||
this._showAllClusters();
|
||||
},
|
||||
|
||||
_clusterTest: function (p, cluster) {
|
||||
var distance = (
|
||||
Math.sqrt(
|
||||
Math.pow((cluster.x - p.x), 2) + Math.pow((cluster.y - p.y), 2)
|
||||
) / this._clusterResolution
|
||||
);
|
||||
return (distance <= this._clusterTolerance);
|
||||
},
|
||||
|
||||
// points passed to clusterAddPoint should be included
|
||||
// in an existing cluster
|
||||
// also give the point an attribute called clusterId
|
||||
// that corresponds to its cluster
|
||||
_clusterAddPoint: function (p, cluster) {
|
||||
// average in the new point to the cluster geometry
|
||||
var count, x, y;
|
||||
count = cluster.attributes.clusterCount;
|
||||
x = (p.x + (cluster.x * count)) / (count + 1);
|
||||
y = (p.y + (cluster.y * count)) / (count + 1);
|
||||
cluster.x = x;
|
||||
cluster.y = y;
|
||||
|
||||
// build an extent that includes all points in a cluster
|
||||
// extents are for debug/testing only...not used by the layer
|
||||
if (p.x < cluster.attributes.extent[0]) {
|
||||
cluster.attributes.extent[0] = p.x;
|
||||
} else if (p.x > cluster.attributes.extent[2]) {
|
||||
cluster.attributes.extent[2] = p.x;
|
||||
}
|
||||
if (p.y < cluster.attributes.extent[1]) {
|
||||
cluster.attributes.extent[1] = p.y;
|
||||
} else if (p.y > cluster.attributes.extent[3]) {
|
||||
cluster.attributes.extent[3] = p.y;
|
||||
}
|
||||
|
||||
// increment the count
|
||||
cluster.attributes.clusterCount++;
|
||||
// attributes might not exist
|
||||
if (!p.hasOwnProperty("attributes")) {
|
||||
p.attributes = {};
|
||||
}
|
||||
// give the graphic a cluster id
|
||||
p.attributes.clusterId = cluster.attributes.clusterId;
|
||||
|
||||
if (p.attributes.Priority < cluster.attributes.Priority) {
|
||||
cluster.attributes.Priority = p.attributes.Priority;
|
||||
cluster.attributes.EmptyIconUrl = p.attributes.EmptyIconUrl;
|
||||
}
|
||||
},
|
||||
|
||||
// point passed to clusterCreate isn't within the
|
||||
// clustering distance specified for the layer so
|
||||
// create a new cluster for it
|
||||
_clusterCreate: function (p) {
|
||||
var clusterId = this._clusters.length + 1;
|
||||
// console.log("cluster create, id is: ", clusterId);
|
||||
// p.attributes might be undefined
|
||||
if (!p.attributes) {
|
||||
p.attributes = {};
|
||||
}
|
||||
p.attributes.clusterId = clusterId;
|
||||
// create the cluster
|
||||
var cluster = {
|
||||
"x": p.x,
|
||||
"y": p.y,
|
||||
"attributes": JSON.parse(JSON.stringify(p.attributes))
|
||||
};
|
||||
cluster.attributes.clusterCount = 1;
|
||||
cluster.attributes.extent = [p.x, p.y, p.x, p.y];
|
||||
this._clusters.push(cluster);
|
||||
},
|
||||
|
||||
_showAllClusters: function () {
|
||||
for (var i = 0, il = this._clusters.length; i < il; i++) {
|
||||
var c = this._clusters[i];
|
||||
this._showCluster(c);
|
||||
}
|
||||
},
|
||||
|
||||
_showCluster: function (c) {
|
||||
var point = new Point(c.x, c.y, this._sr);
|
||||
|
||||
var iconUrl = "";
|
||||
if (c.attributes.clusterCount > 1)
|
||||
iconUrl = c.attributes.EmptyIconUrl;
|
||||
else
|
||||
iconUrl = c.attributes.IconUrl;
|
||||
|
||||
var picSym = new PictureMarkerSymbol(iconUrl, 40, 65);//url,width,height
|
||||
picSym.setOffset(0, 29);
|
||||
this.add(
|
||||
new Graphic(
|
||||
point,
|
||||
picSym,
|
||||
c.attributes
|
||||
)
|
||||
);
|
||||
// code below is used to not label clusters with a single point
|
||||
if (c.attributes.clusterCount == 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
// show number of points in the cluster
|
||||
var label = new TextSymbol(c.attributes.clusterCount.toString())
|
||||
.setColor(new Color(this._clusterLabelColor))
|
||||
.setOffset(0, this._clusterLabelOffset);
|
||||
var font = new Font();
|
||||
font.setSize(this._clusterLabelFontSize);
|
||||
font.setFamily(this._clusterLabelFontFamily);
|
||||
font.setWeight(this._clusterLabelFontWeight);
|
||||
label.setFont(font);
|
||||
|
||||
this.add(
|
||||
new Graphic(
|
||||
point,
|
||||
label,
|
||||
c.attributes
|
||||
)
|
||||
);
|
||||
},
|
||||
|
||||
_addSingles: function (singles) {
|
||||
// add single graphics to the map
|
||||
arrayUtils.forEach(singles, function (p) {
|
||||
var g = new Graphic(
|
||||
new Point(p.x, p.y, this._sr),
|
||||
this._singleSym,
|
||||
p.attributes,
|
||||
this._singleTemplate
|
||||
);
|
||||
this._singles.push(g);
|
||||
if (this._showSingles) {
|
||||
this.add(g);
|
||||
}
|
||||
}, this);
|
||||
this._map.infoWindow.setFeatures(this._singles);
|
||||
},
|
||||
|
||||
_updateClusterGeometry: function (c) {
|
||||
// find the cluster graphic
|
||||
var cg = arrayUtils.filter(this.graphics, function (g) {
|
||||
return g.symbol &&
|
||||
g.symbol.declaredClass == "esri.symbol.PictureMarkerSymbol" &&
|
||||
g.attributes.clusterId == c.attributes.clusterId;
|
||||
});
|
||||
if (cg.length == 1) {
|
||||
// console.log("update label...found: ", label);
|
||||
this.remove(cg[0]);
|
||||
}
|
||||
var picSym = new PictureMarkerSymbol(c.attributes.EmptyIconUrl, 40, 65);//url,width,height
|
||||
picSym.setOffset(0, 29);
|
||||
this.add(
|
||||
new Graphic(
|
||||
new Point(c.x, c.y, this._sr),
|
||||
picSym,
|
||||
c.attributes
|
||||
)
|
||||
);
|
||||
|
||||
//if (cg.length == 1) {
|
||||
// cg[0].geometry.update(c.x, c.y);
|
||||
//} else {
|
||||
// console.log("didn't find exactly one cluster geometry to update: ", cg);
|
||||
//}
|
||||
},
|
||||
|
||||
_updateLabel: function (c) {
|
||||
// find the existing label
|
||||
var label = arrayUtils.filter(this.graphics, function (g) {
|
||||
return g.symbol &&
|
||||
g.symbol.declaredClass == "esri.symbol.TextSymbol" &&
|
||||
g.attributes.clusterId == c.attributes.clusterId;
|
||||
});
|
||||
if (label.length == 1) {
|
||||
// console.log("update label...found: ", label);
|
||||
this.remove(label[0]);
|
||||
}
|
||||
var newLabel = new TextSymbol(c.attributes.clusterCount)
|
||||
.setColor(new Color(this._clusterLabelColor))
|
||||
.setOffset(0, this._clusterLabelOffset);
|
||||
var font = new Font();
|
||||
font.setSize(this._clusterLabelFontSize);
|
||||
font.setFamily(this._clusterLabelFontFamily);
|
||||
font.setWeight(this._clusterLabelFontWeight);
|
||||
newLabel.setFont(font);
|
||||
|
||||
this.add(
|
||||
new Graphic(
|
||||
new Point(c.x, c.y, this._sr),
|
||||
newLabel,
|
||||
c.attributes
|
||||
)
|
||||
);
|
||||
// console.log("updated the label");
|
||||
|
||||
//else {
|
||||
// console.log("didn't find exactly one label: ", label);
|
||||
//}
|
||||
},
|
||||
|
||||
// debug only...never called by the layer
|
||||
_clusterMeta: function () {
|
||||
// print total number of features
|
||||
console.log("Total: ", this._clusterData.length);
|
||||
|
||||
// add up counts and print it
|
||||
var count = 0;
|
||||
arrayUtils.forEach(this._clusters, function (c) {
|
||||
count += c.attributes.clusterCount;
|
||||
});
|
||||
console.log("In clusters: ", count);
|
||||
}
|
||||
|
||||
});
|
||||
});
|
412
Site/js/mapview/jobsite.js
Normal file
412
Site/js/mapview/jobsite.js
Normal file
@ -0,0 +1,412 @@
|
||||
|
||||
|
||||
var unshownJobSiteID = [];//不需要显示的JobSiteID
|
||||
/******************************JobsiteObject******************************/
|
||||
/******************************JobSite信息获取及显示******************************/
|
||||
if (typeof (JobsiteObject) != "function") {
|
||||
JobsiteObject = function (mapHelper) {
|
||||
var allJobsites;
|
||||
var REDUN = 2;
|
||||
var MIN_LENGTH = 40;
|
||||
var trunc = function (val) {
|
||||
return (val > 0 ? Math.floor : Math.ceil)(val);
|
||||
};
|
||||
|
||||
this.getUnShownMachines = function () {
|
||||
return unshownMachineID;
|
||||
}
|
||||
this.setUnShownMachines = function (machines) {
|
||||
//if (machines)
|
||||
// unshownMachineID = JSON.parse(JSON.stringify(machines));
|
||||
//else
|
||||
// unshownMachineID = [];
|
||||
}
|
||||
this.getUnShownJobsites = function () {
|
||||
return unshownJobSiteID;
|
||||
}
|
||||
this.setUnShownJobsites = function (jobsites) {
|
||||
unshownJobSiteID = [];
|
||||
if (jobsites) {
|
||||
for (var i in jobsites) {
|
||||
unshownJobSiteID.push(eval(jobsites[i]));//jobsite id 为数值类型
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var ROW_JOBSITE_HEIGHT = 26;
|
||||
var jobsiteData = [];
|
||||
var jobsiteMachines = [];
|
||||
var jsvm = new Vue({
|
||||
el: '#jobsiteList',
|
||||
data: {
|
||||
startIndex: 0,
|
||||
bodyContentStyle: { top: null },
|
||||
bodyContainerHeight: 0,
|
||||
bodyContainerStyle: { height: null },
|
||||
scrollTop: 0
|
||||
},
|
||||
computed: {
|
||||
bodyClientRowCount: function () {
|
||||
var height = document.getElementById('contentCtrl').clientHeight;
|
||||
return trunc((height - 1) / ROW_JOBSITE_HEIGHT) + 1;
|
||||
},
|
||||
innerJobsiteMachines: function () {
|
||||
var start = this.startIndex;
|
||||
if (start < 0) {
|
||||
start = 0;
|
||||
}
|
||||
if (jobsiteMachines == null || jobsiteMachines.length < MIN_LENGTH) {
|
||||
return jobsiteMachines.slice();
|
||||
}
|
||||
var end = this.bodyClientRowCount + start + (REDUN * 2) + 1;
|
||||
if (end > jobsiteMachines.length) {
|
||||
end = jobsiteMachines.length;
|
||||
}
|
||||
return jobsiteMachines.slice(start, end);
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
fillMachines: function () {
|
||||
var g = [];
|
||||
var allindeterminate = false;
|
||||
var jsselcount = 0;
|
||||
for (var i = 0; i < jobsiteData.length; i++) {
|
||||
var o = jobsiteData[i];
|
||||
o.__isJobsite = 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(o.Machines[j]);
|
||||
}
|
||||
|
||||
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) jsselcount++;
|
||||
}
|
||||
jobsiteMachines = g;
|
||||
|
||||
var chkSelectAll = document.getElementById("chkSelectAll");
|
||||
chkSelectAll.indeterminate = allindeterminate;
|
||||
if (jsselcount == 0) {
|
||||
chkSelectAll.checked = false;
|
||||
}
|
||||
else if (jsselcount == jobsiteData.length) {
|
||||
chkSelectAll.checked = true;
|
||||
}
|
||||
else {
|
||||
chkSelectAll.indeterminate = true;
|
||||
}
|
||||
|
||||
var height = g.length * ROW_JOBSITE_HEIGHT;
|
||||
this.bodyContainerHeight = height;
|
||||
this.bodyContainerStyle.height = height && (height + 'px');
|
||||
|
||||
var index = this.startIndex;
|
||||
this.startIndex = -1;
|
||||
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) {
|
||||
jobsiteData = data;
|
||||
this.fillMachines();
|
||||
},
|
||||
refresh: function () {
|
||||
var index = this.startIndex;
|
||||
this.startIndex = -1;
|
||||
this.startIndex = index;
|
||||
},
|
||||
treeIconClick: function (e, js) {
|
||||
if (js) {
|
||||
var t = $(e.target);
|
||||
if (t.hasClass("treeiconc"))
|
||||
t.removeClass("treeiconc").addClass("treeicone");
|
||||
else
|
||||
t.removeClass("treeicone").addClass("treeiconc");
|
||||
|
||||
js.Collapsed = !js.Collapsed;
|
||||
this.fillMachines();
|
||||
}
|
||||
else
|
||||
treeIconClick(e);
|
||||
},
|
||||
chkJobsiteClick: function (e, js) {
|
||||
chkJobsiteClick(js);
|
||||
this.fillMachines();
|
||||
},
|
||||
linkJobSiteClick: function (e, js) {
|
||||
if (!js.Selected) {
|
||||
js.Selected = true;
|
||||
chkJobsiteClick(js);
|
||||
|
||||
this.fillMachines();
|
||||
}
|
||||
|
||||
if (js.Shown)
|
||||
mapHelper.locateJobSite(js);
|
||||
else {
|
||||
js.Shown = true;
|
||||
showJobsiteClick(e, js);
|
||||
mapHelper.locateJobSite(js);
|
||||
}
|
||||
},
|
||||
showJobsiteClick: function (e, js) {
|
||||
js.Shown = !js.Shown;
|
||||
showJobsiteClick(e, js);
|
||||
},
|
||||
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;
|
||||
selectedAsset = m;
|
||||
|
||||
var e = { data: m };
|
||||
locationHistoryClick(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
this.refreshJobsiteList = function () {
|
||||
jsvm.refresh();
|
||||
}
|
||||
|
||||
this.selectAllJobsites = function (checked) {
|
||||
if (jobsiteData) {
|
||||
for (var i = 0; i < jobsiteData.length; i++) {
|
||||
var js = jobsiteData[i];
|
||||
if (js.Selected != checked) {
|
||||
js.Selected = checked;
|
||||
chkJobsiteClick(js);
|
||||
}
|
||||
}
|
||||
jsvm.fillMachines();
|
||||
}
|
||||
}
|
||||
|
||||
this.onscrollJobsiteMachines = function (e) {
|
||||
if (jobsiteMachines == null || jobsiteMachines.length < MIN_LENGTH) {
|
||||
return;
|
||||
}
|
||||
var top = e == null ? 0 : e.target.scrollTop;
|
||||
top -= (top % ROW_JOBSITE_HEIGHT) + (REDUN * ROW_JOBSITE_HEIGHT);
|
||||
if (top < 0) {
|
||||
top = 0;
|
||||
} else {
|
||||
var bottomTop = jsvm.bodyContainerHeight - ((jsvm.bodyClientRowCount + (REDUN * 2) + 1) * ROW_JOBSITE_HEIGHT);
|
||||
if (top > bottomTop) {
|
||||
top = bottomTop;
|
||||
}
|
||||
}
|
||||
if (jsvm.scrollTop !== top) {
|
||||
jsvm.scrollTop = top;
|
||||
jsvm.startIndex = top / ROW_JOBSITE_HEIGHT;
|
||||
jsvm.bodyContentStyle.top = top && (top + 'px');
|
||||
}
|
||||
};
|
||||
|
||||
function chkJobsiteClick(js) {
|
||||
var checked = js.Selected;
|
||||
if (js && js.Machines) {
|
||||
var ams = [];
|
||||
var rms = [];
|
||||
var rids = [];
|
||||
for (var i in js.Machines) {
|
||||
var machine = js.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[unshownMachineID.length] = 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.searchJobSite = function (isauto) {
|
||||
this.getJobSites(isauto);
|
||||
}
|
||||
|
||||
this.getJobSites = function (isauto) {
|
||||
var item = {
|
||||
'IsAutoRefresh': isauto,
|
||||
'ContractorID': companyids,
|
||||
'SearchText': "",//htmlencode($("#txtJobSiteSearchText").val()), //在前端过滤,后端不再过滤
|
||||
'Onroad': $("#selOnroad").val(),
|
||||
};
|
||||
_network.mapviewquery("GetJobSites", JSON.stringify(item), function (data) {
|
||||
if (data != "-1") {
|
||||
showJobSite(data);
|
||||
}
|
||||
else {
|
||||
showJobSiteAlert();
|
||||
}
|
||||
}, function () {
|
||||
showJobSiteAlert();
|
||||
});
|
||||
}
|
||||
|
||||
function showJobSiteAlert() {
|
||||
if (jobSiteAlert) {
|
||||
_dialog.close(jobSiteAlert);
|
||||
jobSiteAlert = null;
|
||||
}
|
||||
jobSiteAlert = _dialog.showAlert(GetTextByKey("P_MV_UNABLETOOBTAINJOBSITEDATAATTEMPTINGTORECONNECT", 'Unable to obtain jobsite data. Attempting to reconnect...'), GetTextByKey("P_MV_REFRESHJOBSITEDATA", 'Refresh jobsite data'));
|
||||
}
|
||||
|
||||
function showJobSite(jobsites) {
|
||||
mapHelper.removeJobsites(allJobsites);
|
||||
var shownJobsites = [];
|
||||
for (var i = jobsites.length - 1; i >= 0; i--) {
|
||||
var js = jobsites[i];
|
||||
js.Collapsed = true;
|
||||
js.Selected = true;
|
||||
js.Shown = true;
|
||||
if (allJobsites) {//get josbite state
|
||||
for (var j = 0; j < allJobsites.length; j++) {
|
||||
var ljs = allJobsites[j];
|
||||
if (js.ID === ljs.ID) {
|
||||
js.Collapsed = ljs.Collapsed;
|
||||
js.Selected = ljs.Selected;
|
||||
js.Shown = ljs.Shown;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var filter = $.trim($("#txtJobSiteSearchText").val());
|
||||
js.Matched = true;
|
||||
if (filter != "" && js.Name.toLowerCase().indexOf(filter.toLocaleLowerCase()) < 0)
|
||||
js.Matched = false;
|
||||
|
||||
var assets = [];
|
||||
if (jobsiteAssets[js.ID]) {
|
||||
var tempAssets = jobsiteAssets[js.ID];
|
||||
for (var j = 0; j < tempAssets.length; j++) {//Assets
|
||||
var a = tempAssets[j];
|
||||
if (js.Matched || isAssetMatch(a, filter)) {
|
||||
assets.push(a);
|
||||
}
|
||||
}
|
||||
}
|
||||
js.Machines = assets;
|
||||
|
||||
if (!js.Matched && js.Machines.length == 0) {
|
||||
jobsites.splice(i, 1);
|
||||
}
|
||||
else if (js.Shown) { //需要显示的JobSite
|
||||
mapHelper.showJobSite(js);
|
||||
shownJobsites.push(js);
|
||||
}
|
||||
}
|
||||
mapHelper.refreshJobsiteTooltip(shownJobsites);
|
||||
|
||||
allJobsites = jobsites;
|
||||
jsvm.reload(allJobsites);
|
||||
return;
|
||||
}
|
||||
|
||||
function showJobsiteClick(e, js) {
|
||||
var t = $(e.target);
|
||||
if (!t.is("span"))
|
||||
t = t.prev();
|
||||
if (js.Shown) {
|
||||
t.removeClass("switchoff").addClass("switchon");
|
||||
mapHelper.showJobSite(js);
|
||||
unshownJobSiteID.splice(unshownJobSiteID.indexOf(js.ID), 1);
|
||||
}
|
||||
else {
|
||||
t.removeClass("switchon").addClass("switchoff");
|
||||
mapHelper.removeJobSite(js, true);
|
||||
unshownJobSiteID[unshownJobSiteID.length] = js.ID;
|
||||
}
|
||||
|
||||
displayFilerIcon();
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
jsvm.reload(allJobsites);
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
436
Site/js/mapview/machinealertview.js
Normal file
436
Site/js/mapview/machinealertview.js
Normal file
@ -0,0 +1,436 @@
|
||||
var ALL_TEXT = "(All)";
|
||||
var ALL_VALUE = "@all";
|
||||
|
||||
$(function () {
|
||||
// global event
|
||||
|
||||
$(document).mousedown(function (e) {
|
||||
var t = $(e.target);
|
||||
if (!t.hasClass("div_filter"))
|
||||
t = t.parents(".div_filter");
|
||||
if (t.length == 0) $('.div_panel').hide();
|
||||
var divpanel = t.find(".div_panel");
|
||||
$('.div_panel').each(function () {
|
||||
if (!$(this).is(divpanel))
|
||||
divpanel.hide();
|
||||
});
|
||||
});
|
||||
}());
|
||||
|
||||
function showMapAlertLayer(data) {
|
||||
var opt = $('<option></option>').val("").text("(None)");
|
||||
var sel = $("#selMapAlertLayer");
|
||||
sel.empty();
|
||||
sel.append(opt);
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
var mal = data[i];
|
||||
opt = $('<option></option>').val(mal.ID).text(mal.Name).data("mal", mal);
|
||||
sel.append(opt);
|
||||
}
|
||||
if (userParams && userParams.MapAlertLayer) {
|
||||
sel.val(userParams.MapAlertLayer);
|
||||
}
|
||||
showMapAlertLayerDetail();
|
||||
}
|
||||
|
||||
function showMapAlertLayerDetail() {
|
||||
var mal = $("#selMapAlertLayer").find("option:selected").data("mal");
|
||||
var tb = $("#tbLegend");
|
||||
tb.empty();
|
||||
var haspramameter = false;
|
||||
if (mal && mal.Layers) {
|
||||
for (var i = 0; i < mal.Layers.length; i++) {
|
||||
var layer = mal.Layers[i];
|
||||
if ((layer.Pivots && layer.Pivots.length > 0))
|
||||
haspramameter = true;
|
||||
|
||||
var tr = $("<tr style='border-bottom: 1px solid lightgray;'></tr>");
|
||||
tb.append(tr);
|
||||
|
||||
var td = $("<td></td>").css("width", 30);
|
||||
td.append($("<img></img>").attr("src", layer.LegendUrl).css({ "width": 18, "vertical-align": "middle" }));
|
||||
tr.append(td);
|
||||
|
||||
td = $("<td></td>").html(layer.Title).css({ "padding-left": 10, "width": 220 });
|
||||
tr.append(td);
|
||||
}
|
||||
}
|
||||
|
||||
var staticlegend = ["InMotion", "StoppedOn", "StoppedOff", "CGain", "CLoss", "RoadClosure", "LaneClosure"];
|
||||
var staticlegendtitle = ["In Motion", "Stopped On", "Stopped Off", "Connectivity Recovery", "Connectivity Loss", "Road Closure", "Lane Closure"];
|
||||
for (var i = 0; i < staticlegend.length; i++) {
|
||||
var tr = $("<tr style='border-bottom: 1px solid lightgray;'></tr>");
|
||||
tb.append(tr);
|
||||
|
||||
var url = userParams.MachineIconURL + "?legend=" + staticlegend[i];
|
||||
var td = $("<td></td>").css("width", 30);
|
||||
td.append($("<img></img>").attr("src", url).css({ "width": 18, "vertical-align": "middle" }));
|
||||
tr.append(td);
|
||||
|
||||
td = $("<td></td>").html(staticlegendtitle[i]).css({ "padding-left": 10, "width": 220 });
|
||||
tr.append(td);
|
||||
}
|
||||
|
||||
var harshdrivinglegend = ["#ff3f48cc", "#ff00a8f3", "#fffff200", "#ffff7f27", "#ffec1c24"];
|
||||
var harshdrivingtitle = ["Hard Acceleration", "Hard Brake", "Hard Turn", "Speeding: Low Severity", "Speeding: High Severity"];
|
||||
for (var i = 0; i < harshdrivinglegend.length; i++) {
|
||||
var tr = $("<tr style='border-bottom: 1px solid lightgray;'></tr>");
|
||||
tb.append(tr);
|
||||
|
||||
var ironurl = userParams.MachineIconURL.toLowerCase().replace("machinetypeicon.ashx", "machinemovingicon.ashx");
|
||||
var url = ironurl + "?tp=0&bkcolor=" + encodeURIComponent(harshdrivinglegend[i]) + "&heading=45";
|
||||
var td = $("<td></td>").css("width", 30);
|
||||
td.append($("<img></img>").attr("src", url).css({ "width": 18, "vertical-align": "middle" }));
|
||||
tr.append(td);
|
||||
|
||||
td = $("<td></td>").html(harshdrivingtitle[i]).css({ "padding-left": 10, "width": 220 });
|
||||
tr.append(td);
|
||||
}
|
||||
|
||||
if (haspramameter) {
|
||||
$('#setparameter').css('display', '');
|
||||
}
|
||||
else {
|
||||
$('#setparameter').css('display', 'none');
|
||||
}
|
||||
var right = $('#mapAlertLayerDiv').width() + 100;
|
||||
$('#filterIconDiv').css('right', right);
|
||||
}
|
||||
|
||||
function setParameterDatimeTimePicker(ipt) {
|
||||
ipt.datetimepicker({
|
||||
timepicker: false,
|
||||
format: 'm/d/Y',
|
||||
enterLikeTab: false,
|
||||
onSelectDate: function (v, inp) {
|
||||
var date = new DateFormatter().formatDate(v, 'm/d/Y 00:00:00');
|
||||
inp.parent().data('val', [date]);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function getAlertLayerParameters() {
|
||||
if (parameterinput.length > 0) {//更新参数选择的值
|
||||
for (var l = 0; l < parameterinput.length; l++) {
|
||||
var ipt = parameterinput[l];
|
||||
var param = ipt.data("parameter");
|
||||
if (ipt.data('commoninput'))
|
||||
param.ParameterValue = ipt.val();
|
||||
}
|
||||
}
|
||||
|
||||
var mal = $("#selMapAlertLayer").find("option:selected").data("mal");
|
||||
if (mal)
|
||||
return mal.Layers;
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
var parameterinput = [];
|
||||
var paramindex = -1;
|
||||
function setAlertLayerParameters() {
|
||||
parameterinput = [];
|
||||
paramindex = -1;
|
||||
var ul = $("#ul_parameter");
|
||||
ul.empty();
|
||||
var pdiv = $("#parameter_right");
|
||||
pdiv.empty();
|
||||
var mal = $("#selMapAlertLayer").find("option:selected").data("mal");
|
||||
|
||||
var layerHasParam = 0;
|
||||
if (mal && mal.Layers) {
|
||||
for (var i = 0; i < mal.Layers.length; i++) {
|
||||
var layer = mal.Layers[i];
|
||||
|
||||
if (layer && layer.Pivots) {
|
||||
var li = $("<li class='nav_item'></li>").data("layerid", layer.ID).click(layerHasParam++, layerclick);
|
||||
|
||||
var img = $("<img></img>").attr("src", layer.LegendUrl).css({ "width": 18, "vertical-align": "middle" });
|
||||
var span = $("<span></span>").text(layer.Title).css({ "margin-left": 10, "vertical-align": "middle" });
|
||||
li.append(img).append(span);
|
||||
ul.append(li);
|
||||
var tb = $("<table class='tb_parameter'></table>").data("layerid", layer.ID);
|
||||
if (layerHasParam == 1)
|
||||
li.addClass("selected");
|
||||
else
|
||||
tb.css('display', 'none');
|
||||
|
||||
pdiv.append(tb);
|
||||
//if (criteriaparam && criteriaparam.length > 0)
|
||||
// createParameters(criteriaparam, tb, 1);
|
||||
|
||||
//if (alertparam && alertparam.length > 0)
|
||||
// createParameters(alertparam, tb, 2);
|
||||
|
||||
if (layer.Pivots && layer.Pivots.length > 0)
|
||||
createParameters(layer.Pivots, tb);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function createParameters(params, tb) {
|
||||
var criteriaTitle = false;
|
||||
var alertTitle = false;
|
||||
for (var j = 0; j < params.length; j++) {
|
||||
var param = params[j];
|
||||
|
||||
if (param.IsCriteriaSQL && !criteriaTitle) {
|
||||
var tr = $("<tr></tr>").append("<td colspan='2' style='padding-left:10px;font-weight:bold;font-size:16px;'>" + GetTextByKey("P_MV_CRITERIA", "Criteria") + "</td>");
|
||||
tb.append(tr);
|
||||
criteriaTitle = true;
|
||||
}
|
||||
|
||||
if (!param.IsCriteriaSQL && !alertTitle) {
|
||||
var tr = $("<tr></tr>").append("<td colspan='2' style='padding-left:10px;font-weight:bold;font-size:16px;'>" + GetTextByKey("P_MV_ALERT", "Alert") + "</td>");
|
||||
tb.append(tr);
|
||||
alertTitle = true;
|
||||
}
|
||||
|
||||
var tr_param = $("<tr></tr>");
|
||||
tb.append(tr_param);
|
||||
tr_param.append($("<td></td>").addClass('td_paramtype').html(param.Caption));
|
||||
var td = $("<td></td>");
|
||||
|
||||
var ipt = createParameterInput(param);
|
||||
parameterinput.push(ipt);
|
||||
if (param.DataType == 3 && param.DisplayStyle != 1 && param.DisplayStyle != 2) {
|
||||
setParameterDatimeTimePicker(ipt);
|
||||
}
|
||||
td.append(ipt);
|
||||
tr_param.append(td);
|
||||
}
|
||||
}
|
||||
|
||||
function FALSE() { return false; }
|
||||
var idindex = 0;
|
||||
|
||||
function createParameterInput(param) {
|
||||
var paramvalue = getParameterValue(param.ID, param.IsCriteriaSQL);
|
||||
if (paramvalue == null)
|
||||
paramvalue = param.DefaultValue;
|
||||
|
||||
if (param.DisplayStyle == 0) {//inputbox
|
||||
return $("<input type='text' />").val(paramvalue).data("parameter", param).data('commoninput', true)
|
||||
.attr("paramcaption", param.Name.toLowerCase())
|
||||
.keyup(function () {
|
||||
$("[paramcaption='" + param.Name.toLowerCase() + "']").val($(this).val());
|
||||
}).change(function () {
|
||||
$("[paramcaption='" + param.Name.toLowerCase() + "']").val($(this).val());
|
||||
});
|
||||
}
|
||||
else if (param.DisplayStyle == 1 || param.DisplayStyle == 2) {//Dropdown or Combobox
|
||||
var defaultcheckall = false;
|
||||
if (param.IsAllAllowed && paramvalue === ALL_VALUE)
|
||||
defaultcheckall = true;
|
||||
if (param.IsField && param.MutipleSelect) {//多选
|
||||
var divcontrol = $('<div class="div_filter"></div>').data("parameter", param);
|
||||
var seldiv = $('<div class="left dropdown"></div>');
|
||||
var span = $('<span class="text_span"></span>');
|
||||
var spanimg = $('<span class="fa dropdown_button"></span>');
|
||||
var divpanel = $('<div class="div_panel" style="display: none;z-index:10;margin-left:-1px;position:fixed;"></div>');
|
||||
var ul = $('<ul></ul>');
|
||||
divpanel.append(ul).mousedown(FALSE);
|
||||
seldiv.append(span).append(spanimg).append(divpanel);
|
||||
seldiv.mousedown(function (e) {
|
||||
$('.div_panel').each(function () {
|
||||
var t = $(this);
|
||||
if (!t.is(divpanel))
|
||||
t.css('display', 'none');
|
||||
});
|
||||
|
||||
var display = divpanel.css('display');
|
||||
if (display == 'none') {
|
||||
var t = $(e.target);
|
||||
divpanel.css('top', seldiv.offset().top + seldiv.height());
|
||||
if (seldiv.offset().top + seldiv.height() + divpanel.height() > $(document).height())
|
||||
divpanel.css({ 'bottom': 0 });
|
||||
else
|
||||
divpanel.css({ 'bottom': 'unset' });
|
||||
divpanel.css({ 'display': 'block' });
|
||||
} else {
|
||||
divpanel.css('display', 'none');
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
var itemclick = function (isall, checked) {
|
||||
var chks = ul.find('input');
|
||||
if (isall) {
|
||||
chks.prop('checked', checked);
|
||||
if (checked) {
|
||||
span.attr('title', ALL_TEXT).text(ALL_TEXT);
|
||||
param.ParameterValue = ALL_VALUE;
|
||||
}
|
||||
else {
|
||||
span.attr('title', "").text("");
|
||||
param.ParameterValue = "";
|
||||
}
|
||||
return;
|
||||
}
|
||||
else {
|
||||
if (chkall)
|
||||
chkall.prop('checked', false);//(ALL)取消选中
|
||||
}
|
||||
|
||||
var texts = [];
|
||||
var paramvalues = [];
|
||||
for (var i = 0; i < chks.length; i++) {
|
||||
var c = $(chks[i]);
|
||||
if (c.prop('checked')) {
|
||||
var text = c.next('label').text();
|
||||
if (!text) text = c.val();
|
||||
texts.push(text);
|
||||
paramvalues.push(c.val());
|
||||
}
|
||||
}
|
||||
texts = texts.join(', ');
|
||||
span.attr('title', texts).text(texts);
|
||||
paramvalues = paramvalues.join('^');
|
||||
param.ParameterValue = paramvalues;
|
||||
};
|
||||
|
||||
var chkall = undefined;
|
||||
if (param.IsAllAllowed) {
|
||||
var liall = $('<li></li>');
|
||||
chkall = $('<input type="checkbox" id="chkall' + (++idindex) + '" style="width:16px;"/>');
|
||||
if (defaultcheckall)
|
||||
chkall.attr('checked', true);
|
||||
chkall.change(function () {//全选
|
||||
itemclick(true, $(this).prop('checked'));
|
||||
});
|
||||
liall.append(chkall);
|
||||
liall.append($('<label for="chkall' + idindex + '"></label>').text(ALL_TEXT));
|
||||
ul.append(liall);
|
||||
}
|
||||
var ds = getLookupDatasource(param.LookupDatasourceID)
|
||||
if (ds && ds.Items) {
|
||||
var paramvalueAry = paramvalue.split("^");
|
||||
var texts = [];
|
||||
for (var s = 0; s < ds.Items.length; s++) {
|
||||
var item = ds.Items[s];
|
||||
var txt = param.DisplayCaptionField ? item.Value : item.Key;
|
||||
var li = $('<li></li>');
|
||||
var chk = $('<input type="checkbox" style="width:16px;"/>').val(item.Key).attr("id", "chkp" + ++paramindex);
|
||||
chk.change(function () {
|
||||
itemclick(false, $(this).prop('checked'));
|
||||
});
|
||||
li.append(chk);
|
||||
li.append($('<label for=' + ("chkp" + paramindex) + '></label>').text(txt));
|
||||
ul.append(li);
|
||||
|
||||
if (defaultcheckall || paramvalueAry.indexOf(item.Key) > -1) {//选中默认值
|
||||
chk.attr('checked', true);
|
||||
var text = chk.next('label').text();
|
||||
if (!text) text = chk.val();
|
||||
texts.push(text);
|
||||
}
|
||||
}
|
||||
|
||||
if (defaultcheckall)
|
||||
texts = ALL_TEXT;
|
||||
else
|
||||
texts = texts.join(', ');
|
||||
span.attr('title', texts).text(texts);
|
||||
param.ParameterValue = paramvalue;
|
||||
}
|
||||
|
||||
divcontrol.append(seldiv);
|
||||
|
||||
return divcontrol;
|
||||
}
|
||||
else {
|
||||
var sel = $("<select></select>").data("parameter", param).data('commoninput', true)
|
||||
.attr("paramcaption", param.Name.toLowerCase())
|
||||
.change(function () {
|
||||
$("[paramcaption='" + param.Name.toLowerCase() + "']").val($(this).val());
|
||||
});
|
||||
var ds = getLookupDatasource(param.LookupDatasourceID)
|
||||
if (ds && ds.Items) {
|
||||
if (param.IsField && param.IsAllAllowed) {
|
||||
var opall = $("<option></option>").val(ALL_VALUE).text(ALL_TEXT);
|
||||
sel.append(opall);
|
||||
}
|
||||
for (var s = 0; s < ds.Items.length; s++) {
|
||||
var item = ds.Items[s];
|
||||
var opt = $("<option></option>").val(item.Key);
|
||||
var txt = param.DisplayCaptionField ? item.Value : item.Key;
|
||||
opt.text(txt);
|
||||
|
||||
sel.append(opt);
|
||||
}
|
||||
sel.val(paramvalue);
|
||||
}
|
||||
return sel;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getLookupDatasource(dsid) {
|
||||
var mal = $("#selMapAlertLayer").find("option:selected").data("mal");
|
||||
if (mal && mal.LookupDataSources) {
|
||||
for (var i = 0; i < mal.LookupDataSources.length; i++) {
|
||||
var ds = mal.LookupDataSources[i];
|
||||
if (ds.ID.toLowerCase() == dsid.toLowerCase())
|
||||
return ds;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function layerclick(e) {
|
||||
$('#ul_parameter li').removeClass("selected");
|
||||
$(this).addClass("selected");
|
||||
var index = e.data;
|
||||
var tbs = $('.tb_parameter');
|
||||
tbs.hide();
|
||||
$(tbs[index]).show();
|
||||
|
||||
}
|
||||
|
||||
function getParameterValue(paramid, isCriteria) {
|
||||
if (parametervalues && parametervalues.length > 0) {
|
||||
for (var i = 0; i < parametervalues.length; i++) {
|
||||
var layer = parametervalues[i];
|
||||
var params = [];
|
||||
for (var j = 0; j < layer.Pivots.length; j++) {
|
||||
if (layer.Pivots[j].IsCriteriaSQL == isCriteria)
|
||||
params.push(layer.Pivots[j])
|
||||
}
|
||||
|
||||
if (layer && (params || params)) {
|
||||
for (var k = 0; k < params.length; k++) {
|
||||
var param = params[k];
|
||||
if (param.ID == paramid)
|
||||
return param.ParameterValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function openSetAlertLayerParameters() {
|
||||
setAlertLayerParameters();
|
||||
$('#mask_bg').show();
|
||||
$('#dialog_parameter .dialog-title span.title').text(GetTextByKey("P_MV_PIVOTS", 'Pivots'));
|
||||
//$('#mask_bg').show();
|
||||
$('#dialog_parameter')
|
||||
.attr('act', 'edit')
|
||||
.css({
|
||||
'width': 570,
|
||||
'top': (document.documentElement.clientHeight - $('#dialog_parameter').height()) / 2,
|
||||
'left': (document.documentElement.clientWidth - $('#dialog_parameter').width()) / 2
|
||||
})
|
||||
.showDialogfixed();
|
||||
pivotsDialogOpend = true;
|
||||
}
|
||||
|
||||
var parametervalues;
|
||||
function setParameterCompleted() {
|
||||
parametervalues = getAlertLayerParameters();
|
||||
assetObject.searchMachine(false);
|
||||
$('#dialog_parameter').hideDialog();
|
||||
$('#mask_bg').hide();
|
||||
pivotsDialogOpend = false;
|
||||
}
|
1589
Site/js/mapview/maphelper.js
Normal file
1589
Site/js/mapview/maphelper.js
Normal file
File diff suppressed because it is too large
Load Diff
252
Site/js/mapview/mapmenu.js
Normal file
252
Site/js/mapview/mapmenu.js
Normal file
@ -0,0 +1,252 @@
|
||||
|
||||
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;
|
||||
}
|
640
Site/js/mapview/mapview.js
Normal file
640
Site/js/mapview/mapview.js
Normal file
@ -0,0 +1,640 @@
|
||||
|
||||
|
||||
|
||||
|
||||
/******************************全局代码******************************/
|
||||
var currentLocationHistoryMachine;
|
||||
var LocationHistoryInfo;
|
||||
var allJobSiteMachine = [];//全部已显示机器的数据字典,Key为"MID"+Machine.ID,Value为Machine对象
|
||||
var machineStates = [];//所以tab下的相同机器使用同一个State状态对象
|
||||
|
||||
var enableInfoWindow = true;//是否显示InfoWindow
|
||||
var showMapSlider = true;
|
||||
var currentbasemap = "topo";
|
||||
|
||||
function getMachineStateObj(machineid) {
|
||||
var stateObj = machineStates["MID" + machineid];
|
||||
if (!stateObj) {
|
||||
stateObj = { Selected: false, Highlight: false, ShowSummary: false }
|
||||
machineStates["MID" + machineid] = stateObj;
|
||||
}
|
||||
return stateObj;
|
||||
}
|
||||
|
||||
function resetMachineState() {
|
||||
machineStates = [];
|
||||
clearLocationHistory();
|
||||
$("#locationhistoryDiv").hide();
|
||||
$("#tripDiv").hide();
|
||||
|
||||
allJobsites = [];
|
||||
allGroups = [];
|
||||
}
|
||||
|
||||
function initPlayBar() {
|
||||
$.playBar.addBar($("#divPlayBar"), 0);//第一个参数是需要显示播放器的容器,第二个参数为时间,单位毫秒
|
||||
$.playBar.changeBarColor("#FFA500");//设置进度条颜色
|
||||
$.playBar.changeFontColor("#000000")//设置时间颜色
|
||||
//$.playBar.Stop()//进度条停止
|
||||
//$.playBar.Begin()//进度条开始
|
||||
//$.playBar.restTime(1000)//重新设置时间,并重新开始播放
|
||||
//var t = $.playBar.getTheTime()//获得当前的时间
|
||||
|
||||
$.playBar.onPlayClick = onPlayClick;
|
||||
}
|
||||
|
||||
function onPlayClick(last) {
|
||||
var r = getLocationHistory(last);
|
||||
if (r === 1) {
|
||||
if (last)
|
||||
$.playBar.PlayEnd();
|
||||
else
|
||||
$.playBar.Play();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function openSetLocationHistory() {
|
||||
$('#dialog_locationhistory .dialog-title span.title').text(GetTextByKey("P_MA_LOCATIONHISTORY", 'Location History'));
|
||||
//$('#mask_bg').show();
|
||||
getLocationPrimaryDataSource();
|
||||
$('#locationhistoryDiv').show();
|
||||
}
|
||||
|
||||
|
||||
|
||||
function locationHistoryClick(e) {
|
||||
locationTimeperiodChange();
|
||||
$('#tripDiv').hide();
|
||||
$('#tbTrips').empty();
|
||||
|
||||
if (PopupViewShowing) {
|
||||
if (e) {
|
||||
$('#mask_bg').show();
|
||||
$('#dialog_lochis')
|
||||
.css({
|
||||
'top': 50,
|
||||
'right': 100,
|
||||
'bottom': 50,
|
||||
'left': 100,
|
||||
})
|
||||
.showDialog();
|
||||
execIframeFunc("getlocationhis", [e.data.CompanyID, e.data.ID, e.data.DisplayName], "iframelochis");
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (e)
|
||||
currentLocationHistoryMachine = e.data;
|
||||
if (currentLocationHistoryMachine) {
|
||||
$.playBar.Clear();
|
||||
LocationHistoryInfo = null;
|
||||
mapHelper.clearLocationHistory();
|
||||
|
||||
var mText = currentLocationHistoryMachine.DisplayName;
|
||||
if (!mText || mText == "")
|
||||
mText += " - " + currentLocationHistoryMachine.DisplayName;
|
||||
$("#spMachineName").text(mText);
|
||||
|
||||
openSetLocationHistory();
|
||||
}
|
||||
}
|
||||
|
||||
function locationTimeperiodChange() {
|
||||
var currentdate = getCurrentDate();
|
||||
var timeperiod = $("#dialog_timeperiod").val();
|
||||
var disabled = false;
|
||||
|
||||
if (timeperiod !== "4") {
|
||||
disabled = true;
|
||||
var time = new Date(currentdate);
|
||||
var nowtime = new Date(currentdate);
|
||||
var hours = nowtime.getHours();
|
||||
var minutes = nowtime.getMinutes();
|
||||
if (timeperiod === "2") {
|
||||
time.setDate(time.getDate() - 1);
|
||||
nowtime.setDate(nowtime.getDate() - 1);
|
||||
}
|
||||
else if (timeperiod === "3") {
|
||||
time.setDate(time.getDate() - 6);
|
||||
}
|
||||
else if (timeperiod === "5") {
|
||||
time.setDate(time.getDate() - 1);
|
||||
}
|
||||
|
||||
time = time.getMonth() + 1 + "/" + time.getDate() + "/" + time.getFullYear();
|
||||
nowtime = nowtime.getMonth() + 1 + "/" + nowtime.getDate() + "/" + nowtime.getFullYear();
|
||||
$('#dateFrom').val(time);
|
||||
$('#dateTo').val(nowtime);
|
||||
$('#dialog_starttimehour').val('00');
|
||||
$('#dialog_starttimeminute').val('00');
|
||||
$('#dialog_endtimehour').val('23');
|
||||
$('#dialog_endtimeminute').val('59');
|
||||
|
||||
if (timeperiod === "5") {
|
||||
var s_minutes = minutes + 1;
|
||||
var s_hours = hours;
|
||||
|
||||
if (minutes == 59) {
|
||||
s_hours = s_hours + 1;
|
||||
s_minutes = 0;
|
||||
}
|
||||
|
||||
$('#dialog_starttimehour').val(setTimeSelect(s_hours));
|
||||
$('#dialog_starttimeminute').val(setTimeSelect(s_minutes));
|
||||
$('#dialog_endtimehour').val(setTimeSelect(hours));
|
||||
$('#dialog_endtimeminute').val(setTimeSelect(minutes));
|
||||
}
|
||||
} }
|
||||
|
||||
var lastHisFromDT;
|
||||
var lastHisToDT;
|
||||
function getLocationHistory(last) {
|
||||
var dtfrom = $("#dateFrom").val();
|
||||
var dtto = $("#dateTo").val();
|
||||
|
||||
var start_hour = $('#dialog_starttimehour').val();
|
||||
var start_minute = $('#dialog_starttimeminute').val();
|
||||
var end_hour = $('#dialog_endtimehour').val();
|
||||
var end_minute = $('#dialog_endtimeminute').val();
|
||||
|
||||
dtfrom = dtfrom.replace("-", "/") + " " + start_hour + ":" + start_minute + ":" + "00";
|
||||
dtto = dtto.replace("-", "/") + " " + end_hour + ":" + end_minute + ":" + "59";
|
||||
|
||||
if (new Date(dtfrom) > new Date(dtto)) {
|
||||
_dialog.showAlert(GetTextByKey("P_MV_FROMDATETIMEMUSTBEPRIORTOTODATETIME", 'From Date/Time must be prior to To Date/Time.'), GetTextByKey("P_MA_LOCATIONHISTORY", 'Location History'));
|
||||
return;
|
||||
}
|
||||
|
||||
if ($.playBar.getAllTime() > 0 && lastHisFromDT == dtfrom && lastHisToDT == dtto)
|
||||
return 1;
|
||||
else {
|
||||
$.playBar.Clear();
|
||||
LocationHistoryInfo = null;
|
||||
mapHelper.clearLocationHistory();
|
||||
lastHisFromDT = dtfrom;
|
||||
lastHisToDT = dtto;
|
||||
}
|
||||
|
||||
var cid = currentLocationHistoryMachine.CompanyID;
|
||||
var mid = currentLocationHistoryMachine.ID;
|
||||
var p = mid + ";" + dtfrom + ";" + dtto;
|
||||
var notShow00loc = $("#chkExclude00Loc").is(":checked");
|
||||
p += ";" + cid + ";" + (notShow00loc ? "1" : "0") + ";" + Datasource;
|
||||
|
||||
$("#btnHisLoading").show();
|
||||
_network.mapviewquery("GetHistoryLocation", p, function (data) {
|
||||
$("#btnHisLoading").hide();
|
||||
if (data && data.Machine.ID === currentLocationHistoryMachine.ID) {
|
||||
showLocationHistory(data, last);
|
||||
}
|
||||
}, function () {
|
||||
$("#btnHisLoading").hide();
|
||||
});
|
||||
}
|
||||
|
||||
function showLocationHistory(data, last) {
|
||||
LocationHistoryInfo = data
|
||||
//currentTimer = setInterval(function () { locationHistoryTimer(data) }, 1000);
|
||||
|
||||
if (LocationHistoryInfo.Machine && LocationHistoryInfo.Locations) {
|
||||
$.playBar.onBarChanged = doShowLocationHistory;
|
||||
if (last) {
|
||||
$.playBar.restTime(LocationHistoryInfo.Locations.length * 1000, true, true);
|
||||
} else {
|
||||
$.playBar.restTime(LocationHistoryInfo.Locations.length * 1000)//重新设置时间,并重新开始播放
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function doShowLocationHistory(time, fromStart) {
|
||||
var pointIndex = parseInt(time / 1000) - 1;
|
||||
if (pointIndex < 0)
|
||||
pointIndex = 0;
|
||||
if (LocationHistoryInfo.Machine && LocationHistoryInfo.Locations) {
|
||||
if (fromStart) {
|
||||
mapHelper.showLocationHistoryFromStart(LocationHistoryInfo.Machine, LocationHistoryInfo.Locations, pointIndex, true);
|
||||
}
|
||||
else if (pointIndex < LocationHistoryInfo.Locations.length) {
|
||||
mapHelper.showLocationHistory(LocationHistoryInfo.Machine, LocationHistoryInfo.Locations[pointIndex], true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function clearLocationHistory() {
|
||||
$.playBar.Clear();
|
||||
LocationHistoryInfo = null;
|
||||
if (isMapLoaded)
|
||||
mapHelper.clearLocationHistory();
|
||||
}
|
||||
|
||||
function setUserParams() {
|
||||
_network.mapviewquery("SetUserParams", JSON.stringify(userParams), function (data) {
|
||||
});
|
||||
}
|
||||
|
||||
function displayFilerIcon() {
|
||||
var filterText = $("#txtMachineSearchText").val();
|
||||
filterText += $("#txtJobSiteSearchText").val();
|
||||
filterText += $("#txtAssetGroupSearchText").val();
|
||||
|
||||
var unshownmachines = assetObject.getUnShownMachines();
|
||||
var unshownjss = jobsiteObject.getUnShownJobsites();
|
||||
var unshownjsmachines = jobsiteObject.getUnShownMachines();
|
||||
|
||||
if ($.trim(filterText) === ""
|
||||
&& $("#selOnroad").val() == "-1"
|
||||
&& $("#exclude00Div").attr("state") == "0"//!($("#chkExcludeNoLoc").prop("checked"))
|
||||
&& unshownmachines.length == 0
|
||||
&& unshownjss.length == 0
|
||||
&& unshownjsmachines.length == 0)
|
||||
$("#filterIconDiv").hide();
|
||||
else
|
||||
$("#filterIconDiv").show();
|
||||
}
|
||||
|
||||
function doDirections(lat, lng) {
|
||||
var directionURL = "https://www.google.com/maps/dir/?api=1&destination=" + lat + "," + lng + "&travelmode=driving";
|
||||
window.open(directionURL);
|
||||
}
|
||||
|
||||
function doWeather(lat, lng) {
|
||||
var weatherURL = "https://www.wunderground.com/weather/" + lat + "," + lng;
|
||||
window.open(weatherURL);
|
||||
}
|
||||
|
||||
function doLocationHistory(cid, id, name) {
|
||||
if (selectedAsset)
|
||||
selectedAsset.State.Highlight = false;
|
||||
var m = { CompanyID: cid, ID: id, DisplayName: decodeURIComponent(name) };
|
||||
var e = { data: m };
|
||||
locationHistoryClick(e);
|
||||
}
|
||||
|
||||
|
||||
// Machine
|
||||
_network.mapviewquery = function (method, param, callback, error, nolog) {
|
||||
_network.request("mapview.ashx?tp=ashx", -1, method, param, callback, error, nolog);
|
||||
}
|
||||
|
||||
function getNowFormatDate() {
|
||||
_network.mapviewquery("GetNowFormatDate", '', function (data) {
|
||||
$("#refreshTimeDiv").text(GetTextByKey("P_MV_LASTREFRESHED", "Last Refreshed: ") + data);
|
||||
});
|
||||
}
|
||||
|
||||
function treeIconClick(e) {
|
||||
var t = $(e.target);
|
||||
var subItems = t.parent().children(".subul");
|
||||
if (t.hasClass("treeiconc")) {
|
||||
t.removeClass("treeiconc").addClass("treeicone");
|
||||
subItems.show();
|
||||
}
|
||||
else {
|
||||
t.removeClass("treeicone").addClass("treeiconc");
|
||||
subItems.hide();
|
||||
}
|
||||
}
|
||||
|
||||
function isAssetMatch(asset, filter) {
|
||||
if (!filter || filter == "") return true;
|
||||
if (asset) {
|
||||
filter = filter.toLowerCase();
|
||||
if (asset.ID.toString().indexOf(filter) >= 0
|
||||
|| asset.VIN.toLowerCase().indexOf(filter) >= 0
|
||||
|| asset.Name.toLowerCase().indexOf(filter) >= 0
|
||||
|| asset.Name2.toLowerCase().indexOf(filter) >= 0
|
||||
|| asset.Make.toLowerCase().indexOf(filter) >= 0
|
||||
|| asset.Model.toLowerCase().indexOf(filter) >= 0
|
||||
|| asset.AssetType.toLowerCase().indexOf(filter) >= 0)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function openVideoDialog(url) {
|
||||
var videourl = $.trim(decodeURIComponent(url));
|
||||
var form = new $form();
|
||||
form.createForm('', $('body'), 600, 400);
|
||||
var gridcontent = $('<div style="height: 100%"><video width="100%" height="100%" src="' + videourl + '" controls="controls" autoplay="autoplay"></video></div>');
|
||||
form.bodyCtrlAppend(gridcontent);
|
||||
form.show();
|
||||
form.maskbg && form.maskbg.css('z-index', 650);
|
||||
form.formCtrl && form.formCtrl.css('z-index', 700);
|
||||
form.maskbg.hide();
|
||||
}
|
||||
|
||||
var _videoRequestAssetID;
|
||||
function openRequestVideoDialog(assetid, logid) {
|
||||
_videoRequestAssetID = assetid;
|
||||
var loc;
|
||||
if (logid === undefined) {
|
||||
loc = assetLocations[assetid];
|
||||
$('#dialog_hlogid').val("-1");
|
||||
}
|
||||
else {
|
||||
loc = assetHisLocations[logid];
|
||||
$('#dialog_hlogid').val(logid);
|
||||
}
|
||||
var dtstr = loc.LocationTimeText;
|
||||
|
||||
var timestr;
|
||||
var dt;
|
||||
if (!loc || !loc.LocationTimeText || loc.LocationTimeText == "") {
|
||||
var dt = new Date(currentdate);
|
||||
timestr = dt.getMonth() + 1 + "/" + dt.getDate() + "/" + dt.getFullYear();
|
||||
}
|
||||
else {
|
||||
dt = new Date(dtstr);
|
||||
timestr = dt.getMonth() + 1 + "/" + dt.getDate() + "/" + dt.getFullYear();
|
||||
}
|
||||
$('#dialog_videodate').val(timestr);
|
||||
var h = dt.getHours();
|
||||
h = (h < 10 ? '0' : '') + h;
|
||||
$('#dialog_videohour').val(h);
|
||||
var m = dt.getMinutes();
|
||||
m = (m < 10 ? '0' : '') + m;
|
||||
$('#dialog_videominute').val(m);
|
||||
$("#dialog_videoct").prop("checked", false);
|
||||
$("#dialog_videoct").change();
|
||||
|
||||
$('#mask_bg').show();
|
||||
$('#dialog_requestvideo')
|
||||
.attr('act', 'edit')
|
||||
.css({
|
||||
'width': 300,
|
||||
'top': (document.documentElement.clientHeight - $('#dialog_requestvideo').height()) / 4,
|
||||
'left': (document.documentElement.clientWidth - $('#dialog_requestvideo').width()) / 2
|
||||
}).showDialogfixed();
|
||||
}
|
||||
|
||||
function requestVideo() {
|
||||
var ct = $("#dialog_videoct").prop("checked") ? 1 : 0;
|
||||
var dt = $("#dialog_videodate").val();
|
||||
var hour = $('#dialog_videohour').val();
|
||||
var minute = $('#dialog_videominute').val();
|
||||
dt = dt.replace("-", "/") + " " + hour + ":" + minute + ":" + "00";
|
||||
|
||||
var sec = $('#r30sec').prop("checked") ? 1 : 0;
|
||||
|
||||
var loc;
|
||||
if ($('#dialog_hlogid').val() == "-1")
|
||||
loc = assetLocations[_videoRequestAssetID];
|
||||
else
|
||||
loc = assetHisLocations[parseInt($('#dialog_hlogid').val())];
|
||||
|
||||
var cid = loc.CompanyID;
|
||||
var logid = loc.LogId;
|
||||
var src = loc.DataSource;
|
||||
var subsrc = loc.SubSource;
|
||||
var et = loc.EventType;
|
||||
var msguid = loc.MsgUID;
|
||||
|
||||
_network.mapviewquery("RequestVideo", JSON.stringify([cid, _videoRequestAssetID, ct, dt, sec, logid, src, subsrc, et, msguid]), function (data) {
|
||||
if (data == "OK") {
|
||||
_dialog.showAlert(GetTextByKey("P_MV_REQUESTVIDEOSUCCESSFULLY", 'A video has been successfully requested for this Asset at the timestamp indicated. The requested video will be emailed to you once it is available. If the Asset or Camera are currently offline, the requested video will be sent as soon as it is available.'), GetTextByKey("P_MV_REQUESTVIDEO", 'Request Video'));
|
||||
}
|
||||
else {
|
||||
_dialog.showAlert(GetTextByKey("P_MV_REQUESTVIDEOFAILED", 'Request video failed.'), GetTextByKey("P_MV_REQUESTVIDEO", 'Request Video'));
|
||||
}
|
||||
}, function () {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function openTrips(detail) {
|
||||
$("#tbTrips").empty();
|
||||
getAssetTripLins(detail);
|
||||
}
|
||||
|
||||
|
||||
function getLocationPrimaryDataSource() {
|
||||
var cid = currentLocationHistoryMachine.CompanyID || "";
|
||||
var mid = currentLocationHistoryMachine.ID;
|
||||
var p = mid + ";" + cid;
|
||||
|
||||
_network.mapviewquery("GetLocationPrimaryDataSource", p, function (data) {
|
||||
if (data && data.Item1.toLowerCase() === "calamp")
|
||||
$("#btnLoadTrip").show();
|
||||
else
|
||||
$("#btnLoadTrip").hide();
|
||||
}, function () {
|
||||
});
|
||||
}
|
||||
|
||||
function getAssetTripLins(detail) {
|
||||
var cid = currentLocationHistoryMachine.CompanyID;
|
||||
var mid = currentLocationHistoryMachine.ID;
|
||||
var dtfrom = $("#dateFrom").val();
|
||||
var dtto = $("#dateTo").val();
|
||||
|
||||
var start_hour = $('#dialog_starttimehour').val();
|
||||
var start_minute = $('#dialog_starttimeminute').val();
|
||||
var end_hour = $('#dialog_endtimehour').val();
|
||||
var end_minute = $('#dialog_endtimeminute').val();
|
||||
|
||||
dtfrom = dtfrom.replace("-", "/") + " " + start_hour + ":" + start_minute + ":" + "00";
|
||||
dtto = dtto.replace("-", "/") + " " + end_hour + ":" + end_minute + ":" + "59";
|
||||
|
||||
if (new Date(dtfrom) > new Date(dtto)) {
|
||||
return;
|
||||
}
|
||||
if (detail)
|
||||
$("#tripDiv").css({ 'left': 'unset', 'right': 11, 'bottom': 0, 'height': '65%' });
|
||||
else
|
||||
$("#tripDiv").css({ 'left': 0, 'right': 'unset', 'bottom': 52, 'height': 450 });
|
||||
|
||||
$("#tripDiv").show();
|
||||
|
||||
var p = mid + ";" + dtfrom + ";" + dtto;
|
||||
p += ";" + cid
|
||||
|
||||
_network.mapviewquery("GetAssetTripLins", p, function (data) {
|
||||
showAssetTripLins(data);
|
||||
}, function () {
|
||||
});
|
||||
}
|
||||
|
||||
function showAssetTripLins(data) {
|
||||
var tb = $("#tbTrips");
|
||||
tb.empty();
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
var trip = data[i];
|
||||
var color = getTripColor(trip);
|
||||
var tr = $("<tr style='border-bottom: 1px solid lightgray;'></tr>");
|
||||
tb.append(tr);
|
||||
|
||||
var td = $('<td></td>').css('width', 30);
|
||||
tr.append(td);
|
||||
var div = $(' <div class="div_check"></div>');
|
||||
var id = "tripitem" + i;
|
||||
var chk = $('<input type="checkbox" value="1" name="" id="' + id + '"/>').data("trip", trip).data("row", tr);
|
||||
var label = $('<label for="' + id + '" class="la1_check"></label>');
|
||||
label.css('background-color', color);
|
||||
div.append(chk).append(label);
|
||||
td.append(div);
|
||||
|
||||
chk.click(function (e) {
|
||||
var t = $(e.target).data("trip");
|
||||
var row = $(e.target).data("row");
|
||||
if (t && (t.TripOn || t.TripOff)) {
|
||||
if ($(e.target).prop("checked")) {
|
||||
mapHelper.changeLineColor(t.TripOn ? t.TripOn.LocalAsofTime : null, t.TripOff ? t.TripOff.LocalAsofTime : null, getTripColorArray(t));
|
||||
row.css("background-color", "lightgray");
|
||||
}
|
||||
else {
|
||||
mapHelper.changeLineColor(t.TripOn ? t.TripOn.LocalAsofTime : null, t.TripOff ? t.TripOff.LocalAsofTime : null, null);
|
||||
row.css("background-color", "white");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
td = $("<td></td>").css('width', 150);
|
||||
tr.append(td);
|
||||
var span = $('<span></span>').text(trip.TripOnLocalAsofTimeStr);
|
||||
td.append(span).append($('<br>'));
|
||||
span = $('<span></span>').text(trip.TripOffLocalAsofTimeStr);
|
||||
td.append(span);
|
||||
|
||||
td = $("<td></td>").css('width', 180);
|
||||
tr.append(td);
|
||||
span = $('<span class="tripaddress_span"></span>').attr('title', trip.TripOnAddress).text(trip.TripOnAddress);
|
||||
td.append(span).append($('<br>'));
|
||||
span = $('<span class="tripaddress_span"></span>').attr('title', trip.TripOffAddress).text(trip.TripOffAddress);
|
||||
td.append(span);
|
||||
|
||||
td = $("<td></td>").css({ 'width': 100, "text-align": "right" });
|
||||
tr.append(td);
|
||||
span = $('<span></span>').text(trip.TripDistance ? trip.TripDistance : "");
|
||||
td.append(span);
|
||||
span = $('<span></span>').text(trip.TripDistance ? " " + trip.TripDistanceUnit : "");
|
||||
td.append(span);
|
||||
|
||||
td = $("<td></td>").css('width', 60);
|
||||
tr.append(td);
|
||||
span = $('<span style="padding-left:6px;"></span>').text(trip.TripTimeStr);
|
||||
td.append(span);
|
||||
}
|
||||
}
|
||||
|
||||
function getTripColor(trip) {
|
||||
var color = "#c8c4c4";
|
||||
if (trip.Color === 0)
|
||||
color = "#0000FF";
|
||||
else if (trip.Color === 1)
|
||||
color = "#4FBC20";
|
||||
else if (trip.Color === 2)
|
||||
color = "#FF00FF";
|
||||
else if (trip.Color === 3)
|
||||
color = "#FFFF00";
|
||||
else if (trip.Color === 4)
|
||||
color = "#ebbeb3";
|
||||
else if (trip.Color === 5)
|
||||
color = "#ff0000";
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
function getTripColorArray(trip) {
|
||||
var color = [225, 95, 72];
|
||||
if (trip.Color === 0)
|
||||
color = [0x0, 0x0, 0xFF];
|
||||
else if (trip.Color === 1)
|
||||
color = [0x4F, 0xBC, 0x20];
|
||||
else if (trip.Color === 2)
|
||||
color = [0xFF, 0x0, 0xFF];
|
||||
else if (trip.Color === 3)
|
||||
color = [0xFF, 0xFF, 0x0];
|
||||
else if (trip.Color === 4)
|
||||
color = [0xEB, 0xBE, 0xB3];
|
||||
else if (trip.Color === 5)
|
||||
color = [0xFF, 0x00, 0x00];
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
|
||||
var imgTypes = [".jfif", ".jpg", ".jpeg", ".bmp", ".png", ".tiff", ".gif"];
|
||||
var printTypes = ['.pdf', ".jfif", ".jpg", ".jpeg", ".bmp", ".png", ".tiff", ".gif"];//types to be loaded to print
|
||||
function getAssetMapAttachments(cid, assetid) {
|
||||
showmaskbg(true);
|
||||
$('#dialog_assetattachments').css({
|
||||
'top': (document.documentElement.clientHeight - $('#dialog_assetattachments').height()) / 4,
|
||||
'left': (document.documentElement.clientWidth - $('#dialog_assetattachments').width()) / 2
|
||||
}).showDialogfixed();
|
||||
|
||||
var div_aatts = $("#divassetattachments").empty();
|
||||
div_aatts.find(".attachmentsmask").show();
|
||||
_network.mapviewquery("GetAssetMapAttachments", JSON.stringify([cid, assetid]), function (data) {
|
||||
div_aatts.find(".attachmentsmask").hide();
|
||||
if (data && data.length > 0) {
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
var att = data[i];
|
||||
if (imgTypes.indexOf(att.FileType.toLowerCase()) >= 0)
|
||||
att.ThumbnailUrl = att.Url + "&thumb=1";
|
||||
var div = createAttaDiv(att);
|
||||
|
||||
if ($.inArray(att.FileType.toLowerCase(), printTypes) >= 0) {
|
||||
var sprint = $('<span class="attaprint"></span>').attr('title', GetTextByKey("P_WO_PRINT", 'Print')).click(att, function (e) {
|
||||
openPrintFrame(e.data.AttachmentType, e.data.AttachmentIdStr);
|
||||
});
|
||||
div.append(sprint);
|
||||
}
|
||||
|
||||
if (att.FileType.toLowerCase() != "url") {
|
||||
var sdownload = $('<span class="attadownload"></span>').attr('title', GetTextByKey("P_WO_DOWNLOAD", 'Download')).click(att, function (e) {
|
||||
openDownloadFrame(e.data.Url + "&d=1");
|
||||
});
|
||||
div.append(sdownload);
|
||||
}
|
||||
|
||||
div_aatts.append(div);
|
||||
}
|
||||
}
|
||||
}, function () {
|
||||
div_aatts.find(".attachmentsmask").hide();
|
||||
});
|
||||
}
|
||||
|
||||
function createAttaDiv(att, iswoatta) {
|
||||
var div = $('<div class="divatt"></div>').attr('title', att.Name);
|
||||
|
||||
if (!att.FileType || att.FileType == "") att.FileType = ".jpg";
|
||||
if (imgTypes.indexOf(att.FileType.toLowerCase()) >= 0) {
|
||||
var pic = $('<img class="picture"></img>').attr('src', att.ThumbnailUrl);
|
||||
pic.click(att, function (e) {
|
||||
window.open(e.data.Url, "_blank")
|
||||
});
|
||||
div.append(pic);
|
||||
}
|
||||
else {
|
||||
var sdown = $('<img class="picture" />').click(att, function (e) {
|
||||
window.open(e.data.Url);
|
||||
});
|
||||
setAttachemntIcon(att.FileType, sdown);
|
||||
div.append(sdown);
|
||||
}
|
||||
return div
|
||||
}
|
||||
|
||||
function setAttachemntIcon(filetype, sdown) {
|
||||
if ([".doc", ".docx"].indexOf(filetype) >= 0) {
|
||||
sdown.attr('src', 'img/icon/word.jpg')
|
||||
} else if ([".xls", ".xlsx"].indexOf(filetype) >= 0) {
|
||||
sdown.attr('src', 'img/icon/excel.jpg')
|
||||
} else if ([".ppt", ".pptx"].indexOf(filetype) >= 0) {
|
||||
sdown.attr('src', 'img/icon/ppt.jpg')
|
||||
} else if ([".pdf", ".xps"].indexOf(filetype) >= 0) {
|
||||
sdown.attr('src', 'img/icon/pdf.jpg')
|
||||
} else if ([".mp4", ".mov", ".avi", ".mkv", ".3gp", ".ts", ".m2ts"].indexOf(filetype) >= 0) {
|
||||
sdown.attr('src', 'img/icon/vedio.jpg')
|
||||
} else if ([".zip", ".rar", ".7z"].indexOf(filetype) >= 0) {
|
||||
sdown.attr('src', 'img/icon/zip.jpg')
|
||||
} else if ([".msg"].indexOf(filetype) >= 0) {
|
||||
sdown.attr('src', 'img/icon/msg.jpg')
|
||||
} else if ([".xml"].indexOf(filetype) >= 0) {
|
||||
sdown.attr('src', 'img/icon/xml.jpg')
|
||||
} else {
|
||||
sdown.attr('src', 'img/icon/txt.jpg')
|
||||
}
|
||||
}
|
303
Site/js/mapview/mapviewsearch.js
Normal file
303
Site/js/mapview/mapviewsearch.js
Normal file
@ -0,0 +1,303 @@
|
||||
$(function () {
|
||||
InitSavedSearchGrid();
|
||||
InitSaveSearchGrid();
|
||||
|
||||
$("#btnSavedSearches").click(openSavedSearches);
|
||||
$("#btnSaveSearchDetault").click(openSaveSearch);
|
||||
$('#dialog_savedsearches').dialog(function () {
|
||||
$('#mask_bg').hide();
|
||||
});
|
||||
|
||||
$('#dialog_savesearch').dialog(function () {
|
||||
$('#mask_bg').hide();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
function showGridList(grid_dt) {
|
||||
showSearchList(grid_dt, userParams.MapViewSearches);
|
||||
}
|
||||
|
||||
function showSearchList(grid_dt, data) {
|
||||
grid_dt.setData([]);
|
||||
if (!data || data.length === 0)
|
||||
return;
|
||||
var rows = [];
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
var r = data[i];
|
||||
for (var j in r) {
|
||||
if (j === "IsDefault") {
|
||||
r.IsDefaultText = r.IsDefault ? GetTextByKey("P_MV_YES", "Yes") : GetTextByKey("P_MV_NO", "No");
|
||||
}
|
||||
}
|
||||
r.Text = false;
|
||||
r.Email = false;
|
||||
var fr = { Values: r };
|
||||
rows.push(fr);
|
||||
}
|
||||
|
||||
grid_dt.setData(rows);
|
||||
}
|
||||
|
||||
/**********************Saved Searches***********************************/
|
||||
function openSavedSearches() {
|
||||
$('#mask_bg').show();
|
||||
$('#dialog_savedsearches .dialog-title span.title').text(GetTextByKey("P_MV_SAVEDSEARCHES", 'Saved Searches'));
|
||||
$('#dialog_savedsearches')
|
||||
.attr('act', 'edit')
|
||||
.css({
|
||||
'width': 450,
|
||||
'top': (document.documentElement.clientHeight - $('#dialog_savedsearches').height()) / 4,
|
||||
'left': (document.documentElement.clientWidth - $('#dialog_savedsearches').width()) / 2
|
||||
})
|
||||
.showDialogfixed();
|
||||
showGridList(savedsearches_dt)
|
||||
}
|
||||
|
||||
var savedsearches_dt;
|
||||
function InitSavedSearchGrid() {
|
||||
savedsearches_dt = new GridView('#savedsearchlist');
|
||||
savedsearches_dt.lang = {
|
||||
all: GetTextByKey("P_GRID_ALL", "(All)"),
|
||||
ok: GetTextByKey("P_GRID_OK", "OK"),
|
||||
reset: GetTextByKey("P_GRID_RESET", "Reset")
|
||||
};
|
||||
var list_columns = [
|
||||
{ name: 'Name', caption: GetTextByKey("P_MV_SEARCHNAME", "Search Name"), valueIndex: 'Name', css: { 'width': 250, 'text-align': 'left' } },
|
||||
{ name: 'IsDefault', caption: GetTextByKey("P_MV_DEFAULT", "Default"), valueIndex: 'IsDefaultText', css: { 'width': 70, 'text-align': 'left' } },
|
||||
{ name: 'Apply', caption: "", css: { 'width': 30, 'text-align': 'center' } },
|
||||
{ name: 'Delete', caption: "", css: { 'width': 30, 'text-align': 'center' } }
|
||||
];
|
||||
var columns = [];
|
||||
// head
|
||||
for (var hd in list_columns) {
|
||||
var col = {};
|
||||
col.name = list_columns[hd].name;
|
||||
col.caption = list_columns[hd].caption;
|
||||
col.visible = true;
|
||||
col.sortable = true;
|
||||
col.width = list_columns[hd].css.width;
|
||||
col.align = list_columns[hd].css["text-align"]
|
||||
col.key = list_columns[hd].valueIndex;
|
||||
if (list_columns[hd].type) {
|
||||
col.type = list_columns[hd].type;
|
||||
}
|
||||
if (col.name === "Apply") {
|
||||
col.isurl = true;
|
||||
col.text = "\uf1da";
|
||||
col.events = {
|
||||
onclick: function () {
|
||||
onLoadSavedSearches(this);
|
||||
}
|
||||
};
|
||||
col.classFilter = function (e) {
|
||||
return "icon-col";
|
||||
}
|
||||
col.attrs = { 'title': GetTextByKey("P_MV_APPLY", 'Apply') };
|
||||
}
|
||||
else if (col.name === "Delete") {
|
||||
col.isurl = true;
|
||||
col.text = "\uf00d";
|
||||
col.events = {
|
||||
onclick: function () {
|
||||
OnDeleteSavedSearches(this);
|
||||
}
|
||||
};
|
||||
col.classFilter = function (e) {
|
||||
return "icon-col";
|
||||
};
|
||||
col.attrs = { 'title': GetTextByKey("P_MV_DELETE", 'Delete') };
|
||||
}
|
||||
columns.push(col);
|
||||
}
|
||||
savedsearches_dt.canMultiSelect = false;
|
||||
savedsearches_dt.columns = columns;
|
||||
savedsearches_dt.init();
|
||||
|
||||
savedsearches_dt.selectedrowchanged = function (rowindex) {
|
||||
var rowdata = savedsearches_dt.source[rowindex];
|
||||
if (rowdata) {
|
||||
$('#savedsearch_searchname').val(rowdata.Values.Name);
|
||||
}
|
||||
};
|
||||
|
||||
savedsearches_dt.rowdblclick = function (rowindex) {
|
||||
var rowdata = savedsearches_dt.source[rowindex];
|
||||
if (rowdata) {
|
||||
onLoadSavedSearches(rowdata.Values);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
function OnDeleteSavedSearches(search) {
|
||||
if (!search) {
|
||||
return;
|
||||
}
|
||||
showConfirm(GetTextByKey("P_MV_SEARCHDELETEWANTTOCONTINUE", 'Search {0} will be permanently deleted.Do you want to continue?').replace('{0}', search.Name), GetTextByKey("P_MV_DELETESEARCH", 'Delete Search'), function () {
|
||||
_network.mapviewquery("DeleteMapViewSearch", search.Name, function (data) {
|
||||
if (data) {
|
||||
userParams.MapViewSearches = data;
|
||||
showGridList(savedsearches_dt);
|
||||
}
|
||||
}, function (err) {
|
||||
_dialog.showAlert(GetTextByKey("P_MV_FAILEDTODELETETHISSEARCH", 'Failed to delete this search.'), GetTextByKey("P_MV_DELETESEARCH", 'Delete Search'));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function onLoadSavedSearches(search) {
|
||||
if (!search) {
|
||||
var name = $('#savedsearch_searchname').val();
|
||||
if (name === "")
|
||||
return;
|
||||
if (!userParams.MapViewSearches || userParams.MapViewSearches.length == 0) {
|
||||
_dialog.showAlert(GetTextByKey("P_MV_YOUHAVENOSAVEDSEARCHES", 'You have no saved searches.'), '');
|
||||
return;
|
||||
}
|
||||
|
||||
for (var i = 0; i < userParams.MapViewSearches.length; i++) {
|
||||
if (userParams.MapViewSearches[i].Name.toLowerCase() === name.toLowerCase()) {
|
||||
search = userParams.MapViewSearches[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!search) {
|
||||
_dialog.showAlert(GetTextByKey("P_MV_SEARCHDOESNOTEXIST", 'Search {0} does not exist.').replace('{0}', $('#savedsearch_searchname').val()), '');
|
||||
return;
|
||||
}
|
||||
setSavedSearche(search);
|
||||
refreshData();
|
||||
$('#dialog_savedsearches').hideDialog();
|
||||
$('#mask_bg').hide();
|
||||
}
|
||||
|
||||
function setSavedSearche(search) {
|
||||
$("#selOnroad").val(search.Onroad);
|
||||
$("#selAttachment").val(search.Attachment);
|
||||
$('#txtMachineSearchText').val(search.AssetDefaultSearch);
|
||||
$('#txtJobSiteSearchText').val(search.JobSiteDefaultSearch);
|
||||
$('#txtAssetGroupSearchText').val(search.AssetGroupDefaultSearch);
|
||||
//$('#chkExcludeNoLoc').prop("checked", search.ExcludeNoLocation);
|
||||
setExclude00(search.ExcludeNoLocation);
|
||||
assetObject.setUnShownMachines(search.UnShownMachines);
|
||||
jobsiteObject.setUnShownJobsites(search.UnShownJobsites);
|
||||
jobsiteObject.setUnShownMachines(search.UnShownJobsiteMachines);
|
||||
|
||||
resetMachineState();
|
||||
}
|
||||
|
||||
|
||||
/**********************Save Searche***********************************/
|
||||
|
||||
function openSaveSearch() {
|
||||
$('#savesearch_searchname').val('');
|
||||
$('#savesearch_default').prop('checked', false);
|
||||
$('#mask_bg').show();
|
||||
$('#dialog_savesearch .dialog-title span.title').text(GetTextByKey("P_MV_SAVESEARCH", 'Save Search'));
|
||||
$('#dialog_savesearch')
|
||||
.attr('act', 'edit')
|
||||
.css({
|
||||
'width': 450,
|
||||
'top': (document.documentElement.clientHeight - $('#dialog_savesearch').height()) / 4,
|
||||
'left': (document.documentElement.clientWidth - $('#dialog_savesearch').width()) / 2
|
||||
})
|
||||
.showDialogfixed();
|
||||
|
||||
showGridList(savesearch_dt);
|
||||
}
|
||||
|
||||
var savesearch_dt;
|
||||
function InitSaveSearchGrid() {
|
||||
savesearch_dt = new GridView('#savesearchlist');
|
||||
savesearch_dt.lang = {
|
||||
all: GetTextByKey("P_GRID_ALL", "(All)"),
|
||||
ok: GetTextByKey("P_GRID_OK", "OK"),
|
||||
reset: GetTextByKey("P_GRID_RESET", "Reset")
|
||||
};
|
||||
var list_columns = [
|
||||
{ name: 'Name', caption: GetTextByKey("P_MV_SEARCHNAME", "Search Name"), valueIndex: 'Name', css: { 'width': 250, 'text-align': 'left' } },
|
||||
{ name: 'IsDefault', caption: GetTextByKey("P_MV_DEFAULT", "Default"), valueIndex: 'IsDefaultText', css: { 'width': 70, 'text-align': 'left' } }
|
||||
];
|
||||
var columns = [];
|
||||
// head
|
||||
for (var hd in list_columns) {
|
||||
var col = {};
|
||||
col.name = list_columns[hd].name;
|
||||
col.caption = list_columns[hd].caption;
|
||||
col.visible = true;
|
||||
col.sortable = true;
|
||||
col.width = list_columns[hd].css.width;
|
||||
col.align = list_columns[hd].css["text-align"]
|
||||
col.key = list_columns[hd].valueIndex;
|
||||
if (list_columns[hd].type) {
|
||||
col.type = list_columns[hd].type;
|
||||
}
|
||||
columns.push(col);
|
||||
}
|
||||
savesearch_dt.canMultiSelect = false;
|
||||
savesearch_dt.columns = columns;
|
||||
savesearch_dt.init();
|
||||
|
||||
savesearch_dt.selectedrowchanged = function (rowindex) {
|
||||
var rowdata = savesearch_dt.source[rowindex];
|
||||
if (rowdata) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function onSaveSearch() {
|
||||
var name = $('#savesearch_searchname').val();
|
||||
var item = {
|
||||
'Name': name,
|
||||
'IsDefault': $('#savesearch_default').prop('checked'),
|
||||
'Onroad': $("#selOnroad").val(),
|
||||
'Attachment': $("#selAttachment").val(),
|
||||
'AssetDefaultSearch': $('#txtMachineSearchText').val(),
|
||||
'JobSiteDefaultSearch': $('#txtJobSiteSearchText').val(),
|
||||
'AssetGroupDefaultSearch': $('#txtAssetGroupSearchText').val(),
|
||||
'ExcludeNoLocation': $("#exclude00Div").attr("state") != "0", //$("#chkExcludeNoLoc").prop("checked"),
|
||||
'UnShownMachines': assetObject.getUnShownMachines(),
|
||||
'UnShownJobsites': jobsiteObject.getUnShownJobsites(),
|
||||
'UnShownJobsiteMachines': jobsiteObject.getUnShownMachines()
|
||||
};
|
||||
if (item.Name === "") {
|
||||
_dialog.showAlert(GetTextByKey("P_MV_SEARCHNAMEISREQUIRED", 'Search Name is required.'), GetTextByKey("P_MV_SAVESEARCH", 'Save Search'));
|
||||
return;
|
||||
}
|
||||
|
||||
var exists = false;
|
||||
if (userParams.MapViewSearches) {
|
||||
for (var i = 0; i < userParams.MapViewSearches.length; i++) {
|
||||
var search = userParams.MapViewSearches[i];
|
||||
if (search.Name.toLowerCase() === item.Name.toLowerCase()) {
|
||||
exists = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (exists) {
|
||||
showConfirm(GetTextByKey("P_MV_SEARCHALREADYEXIST", 'Search {0} already exists. Would you like to replace?').replace('{0}', item.Name), GetTextByKey("P_MV_SAVESEARCH", 'Save Search'), function () {
|
||||
SaveMapViewSearch(item);
|
||||
});
|
||||
} else
|
||||
SaveMapViewSearch(item);
|
||||
}
|
||||
|
||||
function SaveMapViewSearch(item) {
|
||||
_network.mapviewquery("SaveMapViewSearch", JSON.stringify(item), function (data) {
|
||||
if (data) {
|
||||
userParams.MapViewSearches = data;
|
||||
showGridList(savesearch_dt);
|
||||
|
||||
$('#savesearch_searchname').val('');
|
||||
$('#savesearch_default').prop('checked', false);
|
||||
_dialog.showAlert(GetTextByKey("P_MV_SAVSUCCESSFULLY", 'Saved successfully.'), GetTextByKey("P_MV_SAVESEARCH", 'Save Search'));
|
||||
$('#dialog_savesearch').hideDialog();
|
||||
$('#mask_bg').hide();
|
||||
}
|
||||
}, function (err) {
|
||||
_dialog.showAlert(GetTextByKey("P_MV_FAILEDTOSAVETHISSEARCH", 'Failed to save this search.'), GetTextByKey("P_MV_SAVESEARCH", 'Save Search'));
|
||||
});
|
||||
}
|
237
Site/js/mapview/mapviewshape.js
Normal file
237
Site/js/mapview/mapviewshape.js
Normal file
@ -0,0 +1,237 @@
|
||||
var shapevm;
|
||||
$(function () {
|
||||
initshape();
|
||||
});
|
||||
|
||||
var selectedShapeFileID = [];
|
||||
function initshape() {
|
||||
shapevm = new Vue({
|
||||
el: '#shapeList',
|
||||
data: {
|
||||
shapes: []
|
||||
},
|
||||
methods: {
|
||||
reload: function (data) {
|
||||
this.shapes = data;
|
||||
|
||||
var selcount = 0;
|
||||
for (var i = 0; i < this.shapes.length; i++) {
|
||||
var o = this.shapes[i];
|
||||
if (o.Selected) selcount++;
|
||||
}
|
||||
|
||||
var chkSelectAllShape = document.getElementById("chkSelectAllShape");
|
||||
if (selcount == 0) {
|
||||
chkSelectAllShape.checked = false;
|
||||
chkSelectAllShape.indeterminate = false;
|
||||
}
|
||||
else if (selcount == this.shapes.length) {
|
||||
chkSelectAllShape.checked = true;
|
||||
chkSelectAllShape.indeterminate = false;
|
||||
}
|
||||
else {
|
||||
chkSelectAllShape.indeterminate = true;
|
||||
}
|
||||
},
|
||||
chkShapeClick: function (e, s) {
|
||||
var t = $(e.target);
|
||||
var checked = t.prop("checked");
|
||||
if (checked) {
|
||||
getShapeFileData(s);
|
||||
if (selectedShapeFileID.indexOf(s.ID) < 0) {
|
||||
selectedShapeFileID.push(s.ID);
|
||||
}
|
||||
}
|
||||
else {
|
||||
mapHelper.removeShape(s);
|
||||
selectedShapeFileID.splice(selectedShapeFileID.indexOf(s.ID), 1);
|
||||
}
|
||||
|
||||
this.reload(this.shapes);
|
||||
},
|
||||
linkShapeClick: function (s) {
|
||||
locateShape(s);
|
||||
s.Selected = true;
|
||||
if (selectedShapeFileID.indexOf(s.ID) < 0) {
|
||||
selectedShapeFileID.push(s.ID);
|
||||
}
|
||||
|
||||
this.reload(this.shapes);
|
||||
},
|
||||
deleteShapeClick: function (m, ev) {
|
||||
var e = { data: m };
|
||||
deleteShapeClick(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function getShapeFileInfos() {
|
||||
var item = {
|
||||
'Key': companyids,
|
||||
'Value': htmlencode($("#txtShapeSearchText").val())
|
||||
};
|
||||
|
||||
_network.mapviewquery("GetShapeFileInfos", JSON.stringify(item), function (data) {
|
||||
if (typeof (data) === "string") {
|
||||
_dialog.showAlert(data, GetTextByKey("P_MV_ERROR", 'Error'));
|
||||
return;
|
||||
}
|
||||
for (var i in data) {
|
||||
if (selectedShapeFileID.indexOf(data[i].ID) < 0)
|
||||
data[i].Selected = false;
|
||||
else
|
||||
data[i].Selected = true;
|
||||
}
|
||||
shapevm.reload(data);
|
||||
}, function () {
|
||||
});
|
||||
}
|
||||
|
||||
function showConfirm1(msg, title, fok, fcancel) {
|
||||
$('#mask_bg').show();
|
||||
$('#addodomask').show();
|
||||
$('#addenginehoursmask').show();
|
||||
_dialog.showConfirm(msg, title, function (e) {
|
||||
$('#mask_bg').hide();
|
||||
$('#addodomask').hide();
|
||||
$('#addenginehoursmask').hide();
|
||||
if (typeof fok === 'function') {
|
||||
fok(e);
|
||||
}
|
||||
}, function () {
|
||||
$('#mask_bg').hide();
|
||||
$('#addodomask').hide();
|
||||
$('#addenginehoursmask').hide();
|
||||
});
|
||||
}
|
||||
|
||||
function deleteShapeClick(e) {
|
||||
if (!e.data) {
|
||||
return;
|
||||
}
|
||||
var item = {
|
||||
'Key': e.data.CompanyID,
|
||||
'Value': e.data.ID
|
||||
};
|
||||
$('#mask_bg').show();
|
||||
showConfirm1(GetTextByKey("P_MV_DOYOUWANTTODELETETHESHAPEFILE", 'Do you want to delete the shape file?'), GetTextByKey("p_MV_DELETESHAPEFILE", 'Delete Shape File'), function () {
|
||||
_network.mapviewquery("DeleteShape", JSON.stringify(item), function (data) {
|
||||
mapHelper.removeShape(e.data);
|
||||
getShapeFileInfos();
|
||||
}, function (err) {
|
||||
_dialog.showAlert(GetTextByKey("P_MV_FAILEDTODELETETHISSHAPLEFILE", 'Failed to delete this shaple file.'), GetTextByKey("p_MV_DELETESHAPEFILE", 'Delete Shape File'));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function openImportShapeFile() {
|
||||
$('#dialog_shapename').val('');
|
||||
$('#dialog_shapenotes').val('');
|
||||
$('#span_filename').text('');
|
||||
$('#mask_bg').show();
|
||||
$('#dialog_importshapefile .dialog-title span.title').text(GetTextByKey("P_MV_IMPORTSHAPEFILE", 'Import Shape File'));
|
||||
$('#dialog_importshapefile')
|
||||
.attr('act', 'edit')
|
||||
.css({
|
||||
'width': 500,
|
||||
'top': (document.documentElement.clientHeight - $('#dialog_importshapefile').height()) / 4,
|
||||
'left': (document.documentElement.clientWidth - $('#dialog_importshapefile').width()) / 2
|
||||
})
|
||||
.showDialogfixed();
|
||||
}
|
||||
|
||||
var shapefiledata;
|
||||
function UploadImportShapeFile() {
|
||||
var file = $('<input type="file" style="display: none;" accept=".shp,.kml,.kmz"/>');
|
||||
file.change(function () {
|
||||
var file = this.files[0];
|
||||
shapefiledata = file;
|
||||
$('#span_filename').text(file.name);
|
||||
var name = $("#dialog_shapename").val();
|
||||
if (!name || name.length == 0) {
|
||||
if (file.name.length > 100)
|
||||
$("#dialog_shapename").val(file.name.substring(0, 100));
|
||||
else
|
||||
$("#dialog_shapename").val(file.name);
|
||||
}
|
||||
|
||||
}).click();
|
||||
}
|
||||
|
||||
function SaveImportShapeFile() {
|
||||
if (!shapefiledata)
|
||||
return;
|
||||
|
||||
var item = {
|
||||
'Key': companyids,
|
||||
'Value': $("#dialog_shapename").val(),
|
||||
'Tag1': $("#dialog_shapenotes").val(),
|
||||
};
|
||||
|
||||
if (!item.Value || item.Value.length == 0) {
|
||||
_dialog.showAlert(GetTextByKey("P_MV_SHAPENAMECANNOTBEEMPTY", 'Shape name cannot be empty.'), GetTextByKey("P_MV_IMPORTSHAPEFILE", 'Import Shape File'));
|
||||
return;
|
||||
}
|
||||
var param = JSON.stringify(item);
|
||||
param = htmlencode(param);
|
||||
|
||||
var formData = new FormData();
|
||||
formData.append("iconFile", shapefiledata);
|
||||
formData.append("MethodName", "ImportShape");
|
||||
formData.append("ClientData", param);
|
||||
$.ajax({
|
||||
url: 'mapview.ashx?tp=ashx',
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
processData: false,
|
||||
contentType: false,
|
||||
data: formData,
|
||||
async: true,
|
||||
success: function (data) {
|
||||
if (data !== "OK") {
|
||||
_dialog.showAlert(data, GetTextByKey("P_MV_ERROR", 'Error'));
|
||||
return;
|
||||
}
|
||||
getShapeFileInfos();
|
||||
shapefiledata = undefined;
|
||||
$('#dialog_importshapefile').hideDialog();
|
||||
$('#mask_bg').hide();
|
||||
},
|
||||
error: function (err) {
|
||||
_dialog.showAlert(err.statusText, GetTextByKey("P_MV_IMPORTSHAPEFILE", 'Import Shape File'));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function getShapeFileData(s, needLocate) {
|
||||
var item = {
|
||||
'Key': s.CompanyID,
|
||||
'Value': s.ID,
|
||||
'Tag1': s.FileName
|
||||
};
|
||||
|
||||
_network.mapviewquery("GetShapeData", JSON.stringify(item), function (data) {
|
||||
if (typeof (data) === "string") {
|
||||
_dialog.showAlert(data, GetTextByKey("P_MV_ERROR", 'Error'));
|
||||
return;
|
||||
}
|
||||
s.Shape = data;
|
||||
|
||||
if (needLocate)
|
||||
locateShape(s);
|
||||
else
|
||||
mapHelper.showShape(s);
|
||||
}, function () {
|
||||
});
|
||||
}
|
||||
|
||||
function locateShape(s) {
|
||||
if (s.Shape) {
|
||||
mapHelper.showShape(s);
|
||||
mapHelper.locateShape(s);
|
||||
}
|
||||
else
|
||||
getShapeFileData(s, true);
|
||||
}
|
354
Site/js/mapview/playbar.js
Normal file
354
Site/js/mapview/playbar.js
Normal file
@ -0,0 +1,354 @@
|
||||
// JavaScript Document
|
||||
(function ($) {
|
||||
var isAction = true;
|
||||
var width = 0;
|
||||
var thewidth = 0;
|
||||
var CurrTime = 0;
|
||||
var t;
|
||||
var addHour = 0,
|
||||
addMinute = 0,
|
||||
addSecond = 0,
|
||||
TheHour = 0,
|
||||
TheMinute = 0,
|
||||
TheSecond = 0;
|
||||
var flag = 0;
|
||||
var alltime = 0;
|
||||
var addwidth = 0;
|
||||
var offsetW = 0;
|
||||
var times = 0;
|
||||
var rwidth = 0;
|
||||
var valueChanged = false;
|
||||
|
||||
jQuery.playBar = {
|
||||
addBar: function (DOM, allTime) {
|
||||
CleanAll();
|
||||
alltime = allTime;
|
||||
DOM.empty();
|
||||
DOM.append("<div class='BarControl'><div class='BarBeginTime'>00:00</div></div>");
|
||||
$(".BarControl").append('<div class="TheBar"><div class="TimeBall"></div><div class="TheColorBar"></div><div class="TheWhiteBar"></div></div><div class="BarFinishTime">10:35</div><div id="btnPlay" class="BarPlay"></div><div id="btnPlayEnd" class="BarPlayEnd">');
|
||||
width = $('.TheBar').width();
|
||||
times = allTime / 1000;
|
||||
rwidth = width - 8;
|
||||
addwidth = (width - 10) / times;
|
||||
var t = TransitionTime(allTime);
|
||||
$('.BarFinishTime').html(t.StringTime);
|
||||
|
||||
$('#btnPlay').click(function () {
|
||||
if ($.playBar.onPlayClick)
|
||||
$.playBar.onPlayClick(false);
|
||||
}).attr("title", GetTextByKey("P_MV_PLAYBACK", "Playback"));
|
||||
$('#btnPlayEnd').click(function () {
|
||||
if ($.playBar.onPlayClick)
|
||||
$.playBar.onPlayClick(true);
|
||||
}).attr("title", GetTextByKey("P_MV_QUICKLOADSKIPTOEND", "Quick Load/Skip to End"));
|
||||
|
||||
OpenBar();
|
||||
},
|
||||
restTime: function (allTime, valuechanged, jump) {
|
||||
CleanAll();
|
||||
StopBar();
|
||||
alltime = allTime;
|
||||
width = $('.TheBar').width();
|
||||
times = allTime / 1000;
|
||||
rwidth = width - 8;
|
||||
addwidth = (width - 10) / times;
|
||||
var t = TransitionTime(allTime);
|
||||
$('.BarFinishTime').html(t.StringTime);
|
||||
$('.TheColorBar').css("width", 0);
|
||||
$('.TimeBall').css("left", 0);
|
||||
|
||||
if (valuechanged === undefined)
|
||||
valueChanged = false;
|
||||
else
|
||||
valueChanged = valuechanged;
|
||||
|
||||
if (allTime > 0) {
|
||||
if (jump) {
|
||||
thewidth = rwidth;
|
||||
timechange();
|
||||
changeBar();
|
||||
} else {
|
||||
OpenBar();
|
||||
}
|
||||
}
|
||||
},
|
||||
Play: function () {
|
||||
if (isAction)
|
||||
jQuery.playBar.Stop();
|
||||
else
|
||||
jQuery.playBar.Begin();
|
||||
},
|
||||
PlayEnd: function () {
|
||||
jQuery.playBar.restTime(alltime, true, true);
|
||||
},
|
||||
Stop: function () {
|
||||
StopBar();
|
||||
},
|
||||
Clear: function () {
|
||||
StopBar();
|
||||
this.restTime(0);
|
||||
$('#btnPlay').removeClass("BarPause");
|
||||
$('#btnPlay').addClass("BarPlay");
|
||||
},
|
||||
Begin: function () {
|
||||
if (CurrTime >= alltime) {
|
||||
this.restTime(alltime, true);
|
||||
}
|
||||
else
|
||||
OpenBar()
|
||||
},
|
||||
changeBarColor: function (COLOR) {
|
||||
var color = typeof (COLOR) != "undefined" ? COLOR : '#3498DB';
|
||||
$('.TheColorBar').css("background", color);
|
||||
$('.TimeBall').css("background", color)
|
||||
},
|
||||
changeFontColor: function (COLOR) {
|
||||
var color = typeof (COLOR) != "undefined" ? COLOR : '#3498DB';
|
||||
$('.BarBeginTime,.BarFinishTime').css("color", color)
|
||||
},
|
||||
getAllTime: function () {
|
||||
return alltime;
|
||||
},
|
||||
getTheTime: function () {
|
||||
return CurrTime
|
||||
},
|
||||
onBarChanged: undefined,
|
||||
onPlayClick: undefined
|
||||
};
|
||||
|
||||
function CleanAll() {
|
||||
isAction = true;
|
||||
thewidth = 0;
|
||||
CurrTime = 0;
|
||||
addHour = 0;
|
||||
addMinute = 0;
|
||||
addSecond = 0;
|
||||
TheHour = 0;
|
||||
TheMinute = 0;
|
||||
TheSecond = 0;
|
||||
offsetW = 0;
|
||||
thewidth = 0;
|
||||
flag = 0
|
||||
}
|
||||
var down = false;
|
||||
var BarMove = false;
|
||||
var lastX = 0,
|
||||
NewX = 0;
|
||||
$(document).on("mousedown", '.TimeBall', function (event) {
|
||||
lastX = event.clientX;
|
||||
//event.preventDefault();
|
||||
down = true;
|
||||
BarMove = true;
|
||||
if (isAction) {
|
||||
StopBar()
|
||||
}
|
||||
|
||||
$(document).mousemove(dragmove);
|
||||
$(document).mouseup(dragup);
|
||||
});
|
||||
|
||||
function dragmove(event) {
|
||||
//event.preventDefault();
|
||||
NewX = event.clientX;
|
||||
if (BarMove) {
|
||||
var mcs = NewX - lastX;
|
||||
lastX = NewX;
|
||||
if (mcs < 0) {
|
||||
if (thewidth - (-mcs) > 0) {
|
||||
thewidth = thewidth - (-mcs)
|
||||
}
|
||||
} else {
|
||||
if (thewidth + mcs < rwidth) {
|
||||
thewidth = thewidth + mcs
|
||||
} else {
|
||||
thewidth = rwidth
|
||||
}
|
||||
}
|
||||
timechange();
|
||||
$('.TheColorBar').css("width", thewidth + 1);
|
||||
$('.TimeBall').css("left", thewidth)
|
||||
}
|
||||
}
|
||||
|
||||
function dragup() {
|
||||
if (BarMove) {
|
||||
BarMove = false;
|
||||
down = false;
|
||||
NewX = 0;
|
||||
var xo = parseInt(CurrTime / 1000);
|
||||
offsetW = thewidth - xo * addwidth;
|
||||
if (isAction) {
|
||||
OpenBar()
|
||||
}
|
||||
valueChanged = true;
|
||||
}
|
||||
|
||||
$(document).unbind('mousemove', dragmove);
|
||||
$(document).unbind('mouseup', dragup);
|
||||
};
|
||||
|
||||
function timechange() {
|
||||
CurrTime = parseInt(thewidth / rwidth * alltime);
|
||||
var ltx = TransitionTime(CurrTime);
|
||||
if (TheHour > 0) {
|
||||
if (ltx.hHour) {
|
||||
$('.BarBeginTime').html(ltx.StringTime)
|
||||
} else {
|
||||
$('.BarBeginTime').html("00:" + ltx.StringTime)
|
||||
}
|
||||
} else {
|
||||
$('.BarBeginTime').html(ltx.StringTime)
|
||||
}
|
||||
addSecond = ltx.Tsec;
|
||||
addMinute = ltx.Tmin;
|
||||
addHour = ltx.Thour
|
||||
}
|
||||
|
||||
function changeBar() {
|
||||
var second, minute, hour;
|
||||
thewidth = thewidth * 1 + addwidth - offsetW;
|
||||
if (offsetW > 0) {
|
||||
offsetW = 0
|
||||
}
|
||||
if (thewidth < rwidth && CurrTime < alltime) {
|
||||
CurrTime = CurrTime + 1 * 1000;
|
||||
addSecond = addSecond + 1;
|
||||
if (addSecond > 59) {
|
||||
addSecond = 0;
|
||||
addMinute = addMinute + 1;
|
||||
if (addMinute > 59) {
|
||||
addMinute = 0;
|
||||
addHour = addHour + 1
|
||||
}
|
||||
}
|
||||
if (addSecond > 9) {
|
||||
second = "" + addSecond
|
||||
} else {
|
||||
second = "0" + addSecond
|
||||
} if (addMinute > 9) {
|
||||
minute = "" + addMinute
|
||||
} else {
|
||||
minute = "0" + addMinute
|
||||
} if (addHour > 9) {
|
||||
hour = "" + addHour
|
||||
} else {
|
||||
hour = "0" + addHour
|
||||
} if (addHour > 0) {
|
||||
flag = 1
|
||||
}
|
||||
if (flag == 0) {
|
||||
$('.BarBeginTime').html(minute + ":" + second)
|
||||
} else {
|
||||
$('.BarBeginTime').html(hour + ":" + minute + ":" + second)
|
||||
}
|
||||
} else {
|
||||
thewidth = rwidth;
|
||||
StopBar();
|
||||
}
|
||||
$('.TheColorBar').css("width", thewidth + 1);
|
||||
$('.TimeBall').css("left", thewidth)
|
||||
|
||||
if ($.playBar.onBarChanged)
|
||||
$.playBar.onBarChanged(CurrTime, valueChanged);
|
||||
valueChanged = false;
|
||||
}
|
||||
|
||||
function TransitionTime(str) {
|
||||
var m = parseFloat(str) / 1000;
|
||||
var time = "";
|
||||
var second, minute, hour;
|
||||
var haveHour = false;
|
||||
var ch = 0,
|
||||
csx = 0,
|
||||
cm = 0;
|
||||
if (m >= 60 && m < 60 * 60) {
|
||||
if (parseInt(m / 60.0) < 10) {
|
||||
minute = "0" + parseInt(m / 60.0)
|
||||
} else {
|
||||
minute = parseInt(m / 60.0)
|
||||
}
|
||||
var cs = parseInt(m - parseInt(m / 60.0) * 60);
|
||||
if (cs < 10) {
|
||||
second = "0" + cs
|
||||
} else {
|
||||
second = "" + cs
|
||||
}
|
||||
TheMinute = parseInt(m / 60.0);
|
||||
TheSecond = cs;
|
||||
cm = TheMinute;
|
||||
TheHour = 0;
|
||||
csx = cs;
|
||||
time = minute + ":" + second;
|
||||
$('.BarBeginTime').html("00:00")
|
||||
} else if (m >= 60 * 60) {
|
||||
flag = 1;
|
||||
haveHour = true;
|
||||
ch = parseInt(m / 3600.0);
|
||||
cm = parseInt((parseFloat(m / 3600.0) - parseInt(m / 3600.0)) * 60);
|
||||
csx = parseInt((parseFloat((parseFloat(m / 3600.0) - parseInt(m / 3600.0)) * 60) - parseInt((parseFloat(m / 3600.0) - parseInt(m / 3600.0)) * 60)) * 60);
|
||||
if (ch < 10) {
|
||||
hour = "0" + ch
|
||||
} else {
|
||||
hour = "" + ch
|
||||
} if (cm < 10) {
|
||||
minute = "0" + cm
|
||||
} else {
|
||||
minute = "" + cm
|
||||
} if (csx < 10) {
|
||||
second = "0" + csx
|
||||
} else {
|
||||
second = "" + csx
|
||||
}
|
||||
TheHour = ch;
|
||||
TheMinute = cm;
|
||||
TheSecond = csx;
|
||||
time = hour + ":" + minute + ":" + second;
|
||||
$('.BarBeginTime').html("00:00:00")
|
||||
} else {
|
||||
$('.BarBeginTime').html("00:00");
|
||||
csx = parseInt(m);
|
||||
if (parseInt(m) > 9) {
|
||||
second = "" + parseInt(m)
|
||||
} else {
|
||||
second = "0" + parseInt(m)
|
||||
}
|
||||
TheMinute = 0;
|
||||
TheSecond = parseInt(m);
|
||||
TheHour = 0;
|
||||
time = "00:" + second
|
||||
}
|
||||
var tt = {
|
||||
hHour: haveHour,
|
||||
Thour: ch,
|
||||
Tmin: cm,
|
||||
Tsec: csx,
|
||||
StringTime: time
|
||||
};
|
||||
return tt
|
||||
}
|
||||
|
||||
function StopBar() {
|
||||
if (!down) {
|
||||
isAction = false
|
||||
}
|
||||
clearInterval(t)
|
||||
$('#btnPlay').removeClass("BarPause");
|
||||
$('#btnPlay').addClass("BarPlay");
|
||||
}
|
||||
|
||||
function OpenBar() {
|
||||
if (CurrTime <= alltime) {
|
||||
if (valueChanged && $.playBar.onBarChanged) {
|
||||
$.playBar.onBarChanged(CurrTime, valueChanged);
|
||||
valueChanged = false;
|
||||
}
|
||||
|
||||
isAction = true;
|
||||
if (t) clearInterval(t);
|
||||
t = setInterval(changeBar, 1000);
|
||||
|
||||
$('#btnPlay').removeClass("BarPlay");
|
||||
$('#btnPlay').addClass("BarPause");
|
||||
}
|
||||
}
|
||||
})(jQuery);
|
118
Site/js/modulelang.js
Normal file
118
Site/js/modulelang.js
Normal file
@ -0,0 +1,118 @@
|
||||
|
||||
function setAppModulesLang(data, include) {
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
var m = data[i];
|
||||
if (m.ModuleType === 1)
|
||||
continue;
|
||||
setMoudulesLang(m);
|
||||
if (include && m.SubItems)
|
||||
setSubItemsLang(m.SubItems);
|
||||
}
|
||||
}
|
||||
|
||||
function setMoudulesLang(m) {
|
||||
if (!m.ID)
|
||||
m.ID = m.Id;
|
||||
if (parseInt(m.ID) === 100) {
|
||||
m.CurrentName = GetTextByKey("P_MODULE_MAPVIEW", m.Name);
|
||||
m.CurrentDesc = m.CurrentName;
|
||||
}
|
||||
else if (parseInt(m.ID) === 150) {
|
||||
m.CurrentName = GetTextByKey("P_MODULE_JOBSITES", m.Name);
|
||||
m.CurrentDesc = m.CurrentName;
|
||||
}
|
||||
else if (parseInt(m.ID) === 200) {
|
||||
m.CurrentName = GetTextByKey("P_MODULE_ASSETHEALTH", m.Name);
|
||||
m.CurrentDesc = m.CurrentName;
|
||||
}
|
||||
else if (parseInt(m.ID) === 250) {
|
||||
m.CurrentName = GetTextByKey("P_MODULE_FILTERQ", m.Name);
|
||||
m.CurrentDesc = m.CurrentName;
|
||||
}
|
||||
else if (parseInt(m.ID) === 300) {
|
||||
m.CurrentName = GetTextByKey("P_MODULE_CREDENTIALS", m.Name);
|
||||
m.CurrentDesc = m.CurrentName;
|
||||
}
|
||||
else if (parseInt(m.ID) === 350) {
|
||||
m.CurrentName = GetTextByKey("P_MODULE_SECURITYSETTING", m.Name);
|
||||
m.CurrentDesc = m.CurrentName;
|
||||
}
|
||||
else if (parseInt(m.ID) === 400) {
|
||||
m.CurrentName = GetTextByKey("P_MODULE_MANAGEASSETS", m.Name);
|
||||
m.CurrentDesc = m.CurrentName;
|
||||
}
|
||||
else if (parseInt(m.ID) === 450) {
|
||||
m.CurrentName = GetTextByKey("P_MODULE_FICMANAGEMENT", m.Name);
|
||||
m.CurrentDesc = m.CurrentName;
|
||||
}
|
||||
else if (parseInt(m.ID) === 500) {
|
||||
m.CurrentName = GetTextByKey("P_MODULE_M3", m.Name);
|
||||
m.CurrentDesc = m.CurrentName;
|
||||
}
|
||||
else if (parseInt(m.ID) === 550) {
|
||||
m.CurrentName = GetTextByKey("P_MODULE_OVERUNDERTRUCKINGALERTS", m.Name);
|
||||
m.CurrentDesc = m.CurrentName;
|
||||
}
|
||||
else if (parseInt(m.ID) === 600) {
|
||||
m.CurrentName = GetTextByKey("P_MODULE_OTRCONFIG", m.Name);
|
||||
m.CurrentDesc = m.CurrentName;
|
||||
}
|
||||
else if (parseInt(m.ID) === 650) {
|
||||
m.CurrentName = GetTextByKey("P_MODULE_INSPECTION", m.Name);
|
||||
m.CurrentDesc = m.CurrentName;
|
||||
}
|
||||
else if (parseInt(m.ID) === 700) {
|
||||
m.CurrentName = GetTextByKey("P_MODULE_TEAMINTELLIGENCE", m.Name);
|
||||
m.CurrentDesc = m.CurrentName;
|
||||
}
|
||||
}
|
||||
|
||||
function setSubItemsLang(subitems) {
|
||||
for (var i = 0; i < subitems.length; i++) {
|
||||
var sub = subitems[i];
|
||||
if (sub.ID === "nav_credential")
|
||||
sub.CurrentTitle = GetTextByKey("P_CREDENTIALS", sub.Title);
|
||||
else if (sub.ID === "nav_jdlink")
|
||||
sub.CurrentTitle = GetTextByKey("P_JDLINK", sub.Title);
|
||||
else if (sub.ID === "nav_jdnotification")
|
||||
sub.CurrentTitle = GetTextByKey("P_JOHNDEERENOTIFICATIONS", sub.Title);
|
||||
else if (sub.ID === "nav_apicredential")
|
||||
sub.CurrentTitle = GetTextByKey("P_APICREDENTIALS", sub.Title);
|
||||
else if (sub.ID === "nav_users")
|
||||
sub.CurrentTitle = GetTextByKey("P_USERS", sub.Title);
|
||||
else if (sub.ID === "nav_user_group")
|
||||
sub.CurrentTitle = GetTextByKey("P_USERSGROUP", sub.Title);
|
||||
else if (sub.ID === "nav_dts")
|
||||
sub.CurrentTitle = GetTextByKey("P_DATATABLEPERMISSION", sub.Title);
|
||||
else if (sub.ID === "nav_filters")
|
||||
sub.CurrentTitle = GetTextByKey("P_DASHBOARDFILTERS", sub.Title);
|
||||
else if (sub.ID === "nav_curfew")
|
||||
sub.CurrentTitle = GetTextByKey("P_CURFEWCONFIGURATION", sub.Title);
|
||||
else if (sub.ID === "nav_curfewmt")
|
||||
sub.CurrentTitle = GetTextByKey("P_CURFEWMOVEMENTTOLERANCE", sub.Title);
|
||||
else if (sub.ID === "nav_alertsmanagement")
|
||||
sub.CurrentTitle = GetTextByKey("P_ALERTSMANAGEMENTNEW", sub.Title);
|
||||
else if (sub.ID === "nav_workorder")
|
||||
sub.CurrentTitle = GetTextByKey("P_WORKORDERNEW", sub.Title);
|
||||
else if (sub.ID === "nav_workorderhis")
|
||||
sub.CurrentTitle = GetTextByKey("P_WORKORDERHISTORY", sub.Title);
|
||||
else if (sub.ID === "nav_maintenanceschedule")
|
||||
sub.CurrentTitle = GetTextByKey("P_PM_MAINTENANCESCHEDULES", sub.Title);
|
||||
else if (sub.ID === "nav_record")
|
||||
sub.CurrentTitle = GetTextByKey("P_MAINTENANCERECORDLEGACY", sub.Title);
|
||||
else if (sub.ID === "nav_fuelrecord")
|
||||
sub.CurrentTitle = GetTextByKey("P_FUELRECORDS", sub.Title);
|
||||
else if (sub.ID === "nav_manageharshdriving")
|
||||
sub.CurrentTitle = GetTextByKey("P_MANAGEHARSHDRIVING", sub.Title);
|
||||
else if (sub.ID === "nav_managmachines")
|
||||
sub.CurrentTitle = GetTextByKey("P_MANAGEASSETS", sub.Title);
|
||||
else if (sub.ID === "nav_managrentals")
|
||||
sub.CurrentTitle = GetTextByKey("P_MANAGERENTALS", sub.Title);
|
||||
else if (sub.ID === "nav_machinegroups")
|
||||
sub.CurrentTitle = GetTextByKey("P_ASSETGROUPS", sub.Title);
|
||||
else if (sub.ID === "nav_managegpsdevices")
|
||||
sub.CurrentTitle = GetTextByKey("P_MANAGEDEVICES", sub.Title);
|
||||
else if (sub.ID === "nav_managmodels")
|
||||
sub.CurrentTitle = GetTextByKey("P_MANAGEMODELS", sub.Title);
|
||||
}
|
||||
}
|
2341
Site/js/spectrum.js
Normal file
2341
Site/js/spectrum.js
Normal file
File diff suppressed because it is too large
Load Diff
123
Site/js/split.js
Normal file
123
Site/js/split.js
Normal file
@ -0,0 +1,123 @@
|
||||
/// <reference path="../../js/jquery-3.6.0.min.js" />
|
||||
/// <reference path="../../js/utility.js" />
|
||||
|
||||
var old_hash;
|
||||
var default_page;
|
||||
|
||||
(function () {
|
||||
|
||||
window.onmaskbg = function (flag, noanimation) {
|
||||
if (noanimation) {
|
||||
$(document.body).find('.hostmask').css('display', flag ? '' : 'none');
|
||||
} else {
|
||||
if (flag) {
|
||||
$(document.body).find('.hostmask').fadeIn(100);
|
||||
} else {
|
||||
$(document.body).find('.hostmask').fadeOut(100);
|
||||
}
|
||||
}
|
||||
};
|
||||
window.ondocumentclick = function (e) {
|
||||
$(document.body).click();
|
||||
};
|
||||
window.showconfirm = function (msg, title, fok, fcancel) {
|
||||
var mask = $(document.body).children('.maskbg');
|
||||
mask.children().hide();
|
||||
mask.fadeIn(100);
|
||||
_dialog.showConfirm(msg, title, function (e) {
|
||||
mask.fadeOut(100);
|
||||
if (typeof fok === 'function') {
|
||||
fok(e);
|
||||
}
|
||||
}, function () {
|
||||
if (typeof fcancel === 'function') {
|
||||
fcancel();
|
||||
}
|
||||
mask.fadeOut(100);
|
||||
}, true);
|
||||
}
|
||||
window.showalert = function (msg, title, icon, next) {
|
||||
_dialog.showAlert(msg, title, icon, next, true);
|
||||
}
|
||||
window.onsubpageloaded = function () {
|
||||
$('#set_right .loading_holder').fadeOut('fast');
|
||||
$('#set_right iframe').fadeIn();
|
||||
};
|
||||
|
||||
window.changePage = function (e) {
|
||||
if (!e) {
|
||||
if (old_hash == default_page) {
|
||||
return;
|
||||
}
|
||||
e = default_page;
|
||||
}
|
||||
old_hash = e;
|
||||
var iframe = $('<iframe class="set_iframe"></iframe').css('display', 'none');
|
||||
var li = $(e); // '#nav_' + e.substring(1)
|
||||
if (!li.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
$('#set_left li').removeClass('selected');
|
||||
li.addClass('selected');
|
||||
iframe.attr('src', li.attr('page') + location.search);
|
||||
//document.title = 'Iron Intel - ' + li.attr('title');
|
||||
$('#set_right iframe').remove();
|
||||
$('#set_right .loading_holder').fadeIn();
|
||||
$('#set_right').append(iframe);
|
||||
|
||||
var name = $(li).find('span').text();
|
||||
if (typeof afterpagechanged === 'function')
|
||||
afterpagechanged(e, name);
|
||||
};
|
||||
|
||||
old_hash = location.hash;
|
||||
|
||||
window.onhashchange = function (e) {
|
||||
var hash = location.hash;
|
||||
if (hash == old_hash) {
|
||||
return;
|
||||
}
|
||||
window.changePage(hash);
|
||||
};
|
||||
})();
|
||||
|
||||
$(function () {
|
||||
var ANIMATION_DURATION = 120;
|
||||
var ANIMATION_DURATION_NORMAL = 'fast';
|
||||
|
||||
default_page = $('#set_left li.nav_item:visible:first').attr('id');
|
||||
if (default_page) {
|
||||
default_page = '#' + default_page;
|
||||
if (!old_hash) {
|
||||
old_hash = default_page;
|
||||
}
|
||||
}
|
||||
|
||||
$('#nav_arrow').click(function () {
|
||||
var flag = !$('#set_left').prop('isexpanded');
|
||||
setCookie("LeftPanelExpanded", flag ? "1" : "0");
|
||||
$('#set_left').stop()
|
||||
.prop('isexpanded', flag)
|
||||
.animate({ 'width': flag ? 250 : 50 }, ANIMATION_DURATION)
|
||||
//.find('li a').css('display', flag ? 'none' : '')
|
||||
;
|
||||
if (flag)
|
||||
$('#set_left').find(".subitem").show();
|
||||
else
|
||||
$('#set_left').find(".subitem").hide();
|
||||
|
||||
$('#set_right').stop()
|
||||
.animate({ 'margin-left': flag ? 250 : 50 }, ANIMATION_DURATION);
|
||||
|
||||
$('#nav_arrow div').attr('class', 'icn')
|
||||
.addClass(flag ? 'expand' : 'collapse');
|
||||
});
|
||||
|
||||
$('#set_left').prop('isexpanded', false);
|
||||
var leftexpanded = getCookie("LeftPanelExpanded") === "1";
|
||||
if (leftexpanded)
|
||||
$('#nav_arrow').click();
|
||||
|
||||
});
|
256
Site/js/usermessage.js
Normal file
256
Site/js/usermessage.js
Normal file
@ -0,0 +1,256 @@
|
||||
if (typeof (UserMessage) != "function") {
|
||||
UserMessage = function () {
|
||||
var _this = this;
|
||||
var REDUN = 2;
|
||||
var ROW_HEIGHT = 129;
|
||||
var MIN_LENGTH = 40;
|
||||
var trunc = function (val) {
|
||||
return (val > 0 ? Math.floor : Math.ceil)(val);
|
||||
};
|
||||
|
||||
var vusermsg = new Vue({
|
||||
el: '#divmsgs',
|
||||
data: {
|
||||
startIndex: 0,
|
||||
bodyContentStyle: { top: null },
|
||||
bodyContainerHeight: 0,
|
||||
bodyContainerStyle: { height: null },
|
||||
scrollTop: 0,
|
||||
allmessages: []
|
||||
},
|
||||
computed: {
|
||||
bodyClientRowCount: function () {
|
||||
var height = document.getElementById('divmsgcontainer').clientHeight;
|
||||
return trunc((height - 1) / ROW_HEIGHT) + 1;
|
||||
},
|
||||
innerMessages: function () {
|
||||
var start = this.startIndex;
|
||||
if (start < 0) {
|
||||
start = 0;
|
||||
}
|
||||
if (this.allmessages == null || this.allmessages.length == 0)
|
||||
return [];
|
||||
if (this.allmessages.length < MIN_LENGTH) {
|
||||
return this.allmessages.slice();
|
||||
}
|
||||
var end = this.bodyClientRowCount + start + (REDUN * 2) + 1;
|
||||
if (end > this.allmessages.length) {
|
||||
end = this.allmessages.length;
|
||||
}
|
||||
return this.allmessages.slice(start, end);
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
reload: function (data) {
|
||||
for (var i = 0; i < this.allmessages.length; i++) {
|
||||
data.push(this.allmessages[i]);
|
||||
}
|
||||
this.allmessages = 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;
|
||||
},
|
||||
linkClick: function (m) {
|
||||
if (m.Source == "WorkOrder")
|
||||
openWorkOrder(m.SourceId);
|
||||
},
|
||||
readMessage: function (m, ev) {
|
||||
var t = $(ev.target);
|
||||
if (t.attr("type") == "checkbox")
|
||||
return;
|
||||
var msgids = [];
|
||||
if (m) {
|
||||
m.Readed = true;
|
||||
msgids.push(m.Id);
|
||||
}
|
||||
else {
|
||||
for (var i = 0; i < this.allmessages.length; i++) {
|
||||
if (this.allmessages[i].Selected) {
|
||||
this.allmessages[i].Readed = true;
|
||||
msgids.push(this.allmessages[i].Id);
|
||||
}
|
||||
}
|
||||
}
|
||||
this.refresh();
|
||||
if (msgids.length > 0)
|
||||
_this.readUserMessages(msgids);
|
||||
},
|
||||
deleteMessage: function (m) {
|
||||
var msgids = [];
|
||||
var this_t = this;
|
||||
if (m) {
|
||||
msgids.push(m.Id);
|
||||
showConfirm(GetTextByKey("P_MAIN_DOYOUWANTTODELETETHEMESSAGE", 'Do you want to delete the message?'), GetTextByKey("P_MAIN_DELETEMESSAGES", 'Delete Message'), function () {
|
||||
var i = this_t.allmessages.indexOf(m);
|
||||
this_t.allmessages.splice(i, 1);
|
||||
_this.deleteUserMessages(msgids);
|
||||
this_t.reload([]);
|
||||
});
|
||||
}
|
||||
else {
|
||||
for (var i = 0; i < this.allmessages.length; i++) {
|
||||
if (this.allmessages[i].Selected) {
|
||||
msgids.push(this.allmessages[i].Id);
|
||||
}
|
||||
}
|
||||
if (msgids.length > 0) {
|
||||
showConfirm(GetTextByKey("P_MAIN_DOYOUWANTTODELETESELECTEDMESSAGES", 'Do you want to delete selected message(s)?'), GetTextByKey("P_MAIN_DELETEMESSAGES", 'Delete Message'), function () {
|
||||
for (var i = this_t.allmessages.length - 1; i >= 0; i--) {
|
||||
if (this_t.allmessages[i].Selected) {
|
||||
this_t.allmessages.splice(i, 1);
|
||||
}
|
||||
}
|
||||
_this.deleteUserMessages(msgids);
|
||||
this_t.reload([]);
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
closeMessage: function () {
|
||||
$("#divmsgs").hide();
|
||||
},
|
||||
refreshMessage: function () {
|
||||
_this.getUserMessages();
|
||||
},
|
||||
selectAll: function (ev) {
|
||||
var t = $(ev.target);
|
||||
var checked = t.prop("checked");
|
||||
for (var i = 0; i < this.allmessages.length; i++) {
|
||||
this.allmessages[i].Selected = checked;
|
||||
}
|
||||
this.refresh();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
function onscrollMessages(e) {
|
||||
if (vusermsg.allmessages == null || vusermsg.allmessages.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 = vusermsg.bodyContainerHeight - ((vusermsg.bodyClientRowCount + (REDUN * 2) + 1) * ROW_HEIGHT);
|
||||
if (top > bottomTop) {
|
||||
top = bottomTop;
|
||||
}
|
||||
}
|
||||
if (vusermsg.scrollTop !== top) {
|
||||
vusermsg.scrollTop = top;
|
||||
vusermsg.startIndex = top / ROW_HEIGHT;
|
||||
vusermsg.bodyContentStyle.top = top && (top + 'px');
|
||||
}
|
||||
};
|
||||
|
||||
document.getElementById('divmsgcontainer').addEventListener('scroll', onscrollMessages, { passive: true });
|
||||
|
||||
$("#iconmessage").click(function () {
|
||||
_this.getUserMessages();
|
||||
$("#divmsgs").show();
|
||||
});
|
||||
|
||||
function openWorkOrder(woid) {
|
||||
var p = "jt=woe;woid=" + woid;
|
||||
p = window.btoa(p);
|
||||
window.open(_network.root + "Jump.aspx?p=" + p, "_blank");
|
||||
}
|
||||
|
||||
var lastmsgid = 0;
|
||||
var loadingusermsg = false;
|
||||
this.getUserMessages = function () {
|
||||
if (loadingusermsg) return;
|
||||
loadingusermsg = false;
|
||||
_network.commonpagequery(10, lastmsgid, function (data) {
|
||||
loadingusermsg = false;
|
||||
$("#iconmessage").show();
|
||||
showUserMessages(data);
|
||||
}, function (err) {
|
||||
loadingusermsg = false;
|
||||
}, true);
|
||||
}
|
||||
|
||||
function showUserMessages(data) {
|
||||
if (data && typeof data != "string" && data.length > 0) {
|
||||
lastmsgid = data[0].Id;
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
var msg = data[i];
|
||||
msg.Selected = false;
|
||||
if (msg.Source == "WorkOrder") {
|
||||
msg.LinkText = msg.Title;
|
||||
}
|
||||
if (msg.Message.toLowerCase().indexOf("http://") >= 0 || msg.Message.toLowerCase().indexOf("https://") >= 0) {
|
||||
msg.Message = formatUrl(msg.Message);
|
||||
}
|
||||
else {
|
||||
msg.Message = htmlencode(msg.Message);
|
||||
}
|
||||
}
|
||||
vusermsg.reload(data);
|
||||
}
|
||||
}
|
||||
|
||||
this.readUserMessages = function (msgids) {
|
||||
_network.commonpagequery(11, JSON.stringify(msgids), function (data) {
|
||||
_this.getUnreadCount();
|
||||
}, function (err) {
|
||||
}, true);
|
||||
}
|
||||
|
||||
this.deleteUserMessages = function (msgids) {
|
||||
_network.commonpagequery(12, JSON.stringify(msgids), function (data) {
|
||||
_this.getUnreadCount();
|
||||
}, function (err) {
|
||||
}, true);
|
||||
}
|
||||
|
||||
var unreadcount = 0;
|
||||
this.getUnreadCount = function () {
|
||||
_network.commonpagequery(13, '', function (data) {
|
||||
$("#iconmessage").show();
|
||||
if (!isNaN(data) && eval(data) > 0) {
|
||||
var count = eval(data);
|
||||
if (unreadcount != count && $("#divmsgs").is(":visible"))
|
||||
_this.getUserMessages();
|
||||
|
||||
unreadcount = count;
|
||||
if (unreadcount > 99)
|
||||
$("#divunreadcount").text("99+");
|
||||
else
|
||||
$("#divunreadcount").text(unreadcount);
|
||||
$("#divunreadcount").show();
|
||||
}
|
||||
else
|
||||
$("#divunreadcount").hide();
|
||||
}, function (err) {
|
||||
}, true);
|
||||
}
|
||||
|
||||
setInterval(function () {
|
||||
_this.getUnreadCount();
|
||||
//if ($("#divmsgs").is(":visible"))
|
||||
// _this.getUserMessages();
|
||||
}, 45000);
|
||||
_this.getUnreadCount();
|
||||
}
|
||||
}
|
1639
Site/js/utility.js
Normal file
1639
Site/js/utility.js
Normal file
File diff suppressed because it is too large
Load Diff
12014
Site/js/vue.js
Normal file
12014
Site/js/vue.js
Normal file
File diff suppressed because it is too large
Load Diff
6
Site/js/vue.min.js
vendored
Normal file
6
Site/js/vue.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user