This commit is contained in:
2024-03-26 15:56:31 +08:00
parent 634e8b71ab
commit 0855ae42cd
547 changed files with 94818 additions and 60463 deletions

View File

@ -10,22 +10,20 @@ $(function () {
var items = [];
var ids = [];
for (var i = 0; i < source.length; i++) {
var it = source[i].Values;
var it = source[i];
if (it.Selected) {
items.push({
Values: {
ID: it.Id,
VIN: it.VIN,
Name: it.Name,
MakeName: it.MakeName,
ModelName: it.ModelName,
TypeName: it.TypeName
}
});
});
ids.push(it.Id);
}
}
grid_dtassets.setData(grid_dtassets.innerSource.concat(items));
grid_dtassets.setData(grid_dtassets.source.concat(items));
if (ids.length > 0)
assignAssets(ids);
showmaskbg(false);
@ -45,12 +43,7 @@ function getAssignData() {
//**************************************Asset(s)****************************************************//
var grid_dtassets;
function InitGridSelectedMachines() {
grid_dtassets = new GridView('#selectedmachinelist');
grid_dtassets.lang = {
all: GetTextByKey("P_GRID_ALL", "(All)"),
ok: GetTextByKey("P_GRID_OK", "OK"),
reset: GetTextByKey("P_GRID_RESET", "Reset")
};
grid_dtassets = createGridView('#selectedmachinelist');
var list_columns = [
{ name: 'VIN', caption: GetTextByKey("P_UM_SN", "SN"), valueIndex: 'VIN', css: { 'width': 200, 'text-align': 'left' } },
{ name: 'Name', caption: GetTextByKey("P_UM_NAME", "Name"), valueIndex: 'Name', css: { 'width': 200, 'text-align': 'left' } },
@ -88,23 +81,16 @@ function InitGridSelectedMachines() {
columns.push(col);
}
grid_dtassets.canMultiSelect = true;
grid_dtassets.multiSelect = true;
grid_dtassets.columns = columns;
grid_dtassets.init();
grid_dtassets.selectedrowchanged = function (rowindex) {
var rowdata = grid_dtassets.source[rowindex];
if (rowdata) {
}
}
}
function showSelectedMachine(data) {
var rows = [];
for (var i = 0; i < data.length; i++) {
var r = data[i];
var fr = { Values: r };
rows.push(fr);
rows.push(r);
}
grid_dtassets.setData(rows);
@ -148,8 +134,8 @@ function assignAssets(ids, next) {
function OnAssetAdd() {
showmaskbg(true);
dialogAUAssets.exceptSource = grid_dtassets.innerSource.map(function (s) {
return s.Values.ID;
dialogAUAssets.exceptSource = grid_dtassets.source.map(function (s) {
return s.ID;
});
dialogAUAssets.showSelector();
}
@ -157,22 +143,17 @@ function OnAssetAdd() {
function OnMachineDelete() {
showConfirm(GetTextByKey("P_UM_DELETESELECTEDASSET", 'Are you sure you want to delete these selected assets?'), GetTextByKey("P_UM_ASSETASSIGNMENT", "Asset Assignment"), function () {
var ids = [];
for (var i = grid_dtassets.innerSource.length - 1; i >= 0; i--) {
var s = grid_dtassets.innerSource[i].Values;
if (s.selected) {
grid_dtassets.innerSource.splice(i, 1);
ids.push(s.ID);
}
}
if (grid_dtassets.source != null) {
for (var j = grid_dtassets.source.length - 1; j >= 0; j--) {
var l = grid_dtassets.source[j].Values;
var tmp = grid_dtassets.source;
if (tmp != null) {
for (var j = tmp.length - 1; j >= 0; j--) {
var l = tmp[j];
if (l.selected) {
grid_dtassets.source.splice(j, 1);
tmp.splice(j, 1);
}
}
}
grid_dtassets.reset();
grid_dtassets.setData(tmp);
grid_dtassets.reload(true);
var params = [
custid,
@ -202,12 +183,7 @@ function showsalespersonmask(flag) {
var grid_dtsp;
function InitSPGridData() {
grid_dtsp = new GridView('#salespersonlist');
grid_dtsp.lang = {
all: GetTextByKey("P_GRID_ALL", "(All)"),
ok: GetTextByKey("P_GRID_OK", "OK"),
reset: GetTextByKey("P_GRID_RESET", "Reset")
};
grid_dtsp = createGridView('#salespersonlist');
var list_columns = [
{ name: 'ID', caption: GetTextByKey("P_UM_USERIDOREMAIL", "User ID/Email"), valueIndex: 'ID', css: { 'width': 180, 'text-align': 'left' } },
{ name: 'DisplayName', caption: GetTextByKey("P_UM_USERNAME", "User Name"), valueIndex: 'DisplayName', css: { 'width': 200, 'text-align': 'left' } },
@ -227,22 +203,14 @@ function InitSPGridData() {
col.allowFilter = list_columns[hd].allowFilter;
columns.push(col);
}
grid_dtsp.canMultiSelect = false;
grid_dtsp.multiSelect = false;
grid_dtsp.columns = columns;
grid_dtsp.init();
}
function showSalespersons(data) {
var rows = [];
for (var i = 0; i < data.length; i++) {
var r = data[i];
for (var j in r) {
}
var fr = { Values: r };
rows.push(fr);
}
grid_dtsp.setData(rows);
grid_dtsp.setData(data);
}
function GetSalespersons() {
@ -288,7 +256,7 @@ function onSetSalesperson() {
showmaskbg(false);
return;
}
var salesperson = grid_dtsp.source[index].Values;
var salesperson = grid_dtsp.source[index];
$('#dialog_salespersoncode').data('spiid', salesperson.IID);
$('#dialog_salespersoncode').val(salesperson.FOB);
$('#dialog_salespersonname').val(salesperson.DisplayName);

View File

@ -69,12 +69,7 @@ function saveWorkOrderCollapsed() {
var customerid;
var grid_dtcustomer;
function InitGridCustomers() {
grid_dtcustomer = new GridView('#customerlist');
grid_dtcustomer.lang = {
all: GetTextByKey("P_GRID_ALL", "(All)"),
ok: GetTextByKey("P_GRID_OK", "OK"),
reset: GetTextByKey("P_GRID_RESET", "Reset")
};
grid_dtcustomer = createGridView('#customerlist');
var list_columns = [
{ name: 'Code', caption: GetTextByKey("P_CR_CODE", "Code"), valueIndex: 'Code', css: { 'width': 120, 'text-align': 'left' } },
{ name: 'Name', caption: GetTextByKey("P_CR_COMPANYNAME", "Company Name"), valueIndex: 'Name', css: { 'width': 200, 'text-align': 'left' } },
@ -94,27 +89,20 @@ function InitGridCustomers() {
col.key = list_columns[hd].valueIndex;
columns.push(col);
}
grid_dtcustomer.canMultiSelect = true;
grid_dtcustomer.multiSelect = true;
grid_dtcustomer.columns = columns;
grid_dtcustomer.init();
grid_dtcustomer.rowdblclick = function (rowindex) {
grid_dtcustomer.onRowDblClicked = function (rowindex) {
var rowdata = grid_dtcustomer.source[rowindex];
if (rowdata) {
//setCustomerData(rowdata.Values);
OnSetSelectCustomer();
}
};
}
function showCustomerList(data) {
var rows = [];
for (var i = 0; i < data.length; i++) {
var r = data[i];
var fr = { Values: r };
rows.push(fr);
}
grid_dtcustomer.setData(rows);
grid_dtcustomer.setData(data);
}
function onSelectCustomer() {
@ -130,7 +118,7 @@ function onSelectCustomer() {
'top': (document.documentElement.clientHeight - $('#dialog_customer').height()) / 3,
'left': (document.documentElement.clientWidth - $('#dialog_customer').width()) / 2
})
.showDialog();
.showDialogfixed();
GetCustomerList();
}
@ -207,7 +195,7 @@ function OnSetSelectCustomer() {
if (index < 0) {
showAlert(GetTextByKey("P_WO_PLEASESELECTACUSTOMER", "Please select a customer."), GetTextByKey("P_WO_SELECTCUSTOMER", "Select Customer")); return;
}
var cust = grid_dtcustomer.source[index].Values;
var cust = grid_dtcustomer.source[index];
setCustomerData(cust);
}
@ -231,7 +219,7 @@ function setCustomerData(cust) {
}
function OnAddCustomer() {
execIframeFunc("init", [null, machineid], "iframeuser");
execIframeFunc("init", [null, machineid], "iframecr");
$('#contatcmask').show();
$('#dialog_addcustomer')
.showDialogRight();
@ -314,12 +302,16 @@ function showCustomerContacts(data) {
}
if (customer) {
customer.setData('contacts', customercontacts);
//customer.setData('contacts', customercontacts);
customer.contacts = customercontacts;
}
if (internal) {
internal.contacts = customercontacts;
}
woestimateobj?.updatecontact(customercontacts);
woinvoiceobj?.updatecontact(customercontacts);
woattachmentobj?.updatecontact(customercontacts);
setPhoneNumber_statuschange();
}
@ -490,3 +482,192 @@ function onSaveCompletedStatus() {
}
/*****************************************End Completed Status**************************************************/
/********************************************Begin Stauts Change Select Attachment*************************************************/
var imgTypes = [".jfif", ".jpg", ".jpeg", ".bmp", ".png", ".tiff", ".gif"];
var grid_selectattachments;
function InitGridSelectedAttachments() {
grid_selectattachments = new GridView("#div_selectattachmentlist");
var list_columns = [
{ name: 'Selected', caption: "", valueIndex: 'Selected', type: 3, css: { 'width': 45, 'text-align': 'center' } },
{ name: 'ThumbnailUrl', caption: "", valueIndex: 'ThumbnailUrl', css: { 'width': 42, 'text-align': 'center' } },
{ name: 'Notes', caption: GetTextByKey("P_WO_NAME", "Name"), valueIndex: 'Notes', css: { 'width': 280, 'text-align': 'left' } }
];
var columns = [];
for (var hd in list_columns) {
var col = {};
if (list_columns[hd].type) {
col.type = list_columns[hd].type;
}
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;
columns.push(col);
if (col.name == "Selected") {
col.allcheck = false;
col.sortable = false;
col.events = {
onchange: function () {
if (this.Selected) {
for (var i in grid_selectattachments.source) {
var a = grid_selectattachments.source[i];
if (a.Id !== this.Id)
a.Selected = false;
}
grid_selectattachments.reload();
}
}
};
}
else if (col.name == "ThumbnailUrl") {
col.type = ThumbnailUrlColumn;
//col.filter = function (item) {
// if (imgTypes.indexOf(item.FileType.toLowerCase()) >= 0)
// return $('<img style="height:30px;width:30px;"></img>').attr('src', item.ThumbnailUrl);
// else {
// var sdown = $('<img style="height:30px;width:30px;line-height:40px;" />')
// setAttachemntIcon(item.FileType, sdown);
// return sdown;
// }
//}
//col.styleFilter = function () {
// return { "width": "100%", 'margin': 0 };
//}
}
}
grid_selectattachments.multiSelect = false;
grid_selectattachments.columns = columns;
grid_selectattachments.init();
}
function showSelectAttachment(data) {
var rows = [];
for (var i = 0; i < data.length; i++) {
var att = data[i];
if (att.FileType.toLowerCase() == "url") continue;
var fr = {
Id: att.AttachmentIdStr,
AttaType: att.AttachmentType,
FileName: att.FileName,
Caption: att.Notes,
FileType: att.FileType,
Url: att.Url,
ThumbnailUrl: att.ThumbnailUrl,
Notes: att.Notes === "" ? att.FileName : att.Notes,
Selected: false,
};
rows.push(fr);
}
grid_selectattachments.setData(rows);
$('#dialogattmask').hide();
}
function openSelectAttachment() {
$('#dialogattmask').show();
$('#statuschange_maskbg').show();
GetWorkorderAttachemnt();
$('#dialog_selecteattachments .dialog-title span.title').text(GetTextByKey("P_WO_SELECTATTACHMENT", 'Select Attachment'));
$('#dialog_selecteattachments')
.attr('act', 'add')
.css({
'top': (document.documentElement.clientHeight - $('#dialog_selecteattachments').height()) / 3,
'left': (document.documentElement.clientWidth - $('#dialog_selecteattachments').width()) / 2
})
.showDialogfixed();
}
var woattachments;
function GetWorkorderAttachemnt() {
grid_selectattachments.setData([]);
if (!workorderid || workorderid == "")
return;
worequest('GetWorkOrderAttachments', htmlencode(workorderid), function (data) {
if (typeof (data) === "string") {
showAlert(data, GetTextByKey('P_WO_SELECTATTACHMENT', "Select Attachment"));
$('#dialogattmask').hide();
$('#statuschange_maskbg').hide();
return;
}
showSelectAttachment(data);
}, function () {
});
}
var _selectedattachment;
function onSetSelectAttachment() {
$("#dialogattmask").show();
$('#statuschange_maskbg').show();
_selectedattachment = undefined;
$('#span_attachmentname').text('').attr('title', '');
$('#span_attachmentdelete').hide();
var alerttitle = GetTextByKey('P_WO_SELECTATTACHMENT', "Select Attachment");
var selatt;
if (grid_selectattachments) {
var tempsource = grid_selectattachments.source || [];
for (var i = 0; i < tempsource.length; i++) {
var a = tempsource[i];
if (a.Selected) {
selatt = a;
break;
}
}
}
if (selatt) {
if (imgTypes.indexOf(selatt.FileType.toLowerCase()) >= 0) {//图片无需验证大小
_selectedattachment = selatt;
$('#span_attachmentname').text(_selectedattachment.Notes).attr('title', _selectedattachment.Notes);
$('#span_attachmentdelete').show();
$("#dialogattmask").hide();
$('#statuschange_maskbg').hide();
$('#dialog_selecteattachments').hideDialog();
}
else {
worequest('IsAttachmentExceedsLimit', htmlencode(selatt.Id), function (data) {
$("#dialogattmask").hide();
if (typeof (data) === "string") {
showAlert(data, alerttitle);
return;
}
if (data) {
showAlert(GetTextByKey('P_WO_ATTACHMENTSIZEEXCEEDSTHEMAXIMUMTIPS', 'Attachment size exceeds the maximum allowed to be sent (1.2MB).'), alerttitle);
return;
}
else {
_selectedattachment = selatt;
$('#span_attachmentname').text(_selectedattachment.Notes).attr('title', _selectedattachment.Notes);
$('#span_attachmentdelete').show();
$('#statuschange_maskbg').hide();
$('#dialog_selecteattachments').hideDialog();
}
}, function () {
$("#dialogattmask").hide();
$('#statuschange_maskbg').hide();
});
}
}
else {
$('#dialog_selecteattachments').hideDialog();
$("#dialogattmask").hide();
$('#statuschange_maskbg').hide();
}
}
function onRemoveSelectedAttachment() {
_selectedattachment = undefined;
$('#span_attachmentname').text('').attr('title', '');
$('#span_attachmentdelete').hide();
}
/********************************************End Stauts Change Select Attachment*************************************************/

View File

@ -0,0 +1,265 @@
/// <reference path="../../js/jquery-3.6.0.min.js" />
/// <reference path="../../js/utility.js" />
_am = {};
(function () {
_am.focusAlertMappingItem = function (tr) {
tr.find('.general').css('display', 'none');
tr.find('.editing').css('display', 'block');
};
_am.addAlertMappingItem = function (mappingid, edesc) {
$('#dialog_make').dropdownVal(null);
$('#dialog_model').dropdownVals([]);
$('#dialog_alerttype').dropdownVal(null);
//$('#dialog_description').dropdownVal(null);
$('#dialog_description').text(edesc);
$('#dialog_category').dropdownVal(null);
showmaskbg(true);
$('#dialog_alertmappingitem').attr('data-mappingid', mappingid)
.css({
'top': ($(window).height() - $('#dialog_alertmappingitem').height()) / 3,
'left': ($(window).width() - $('#dialog_alertmappingitem').width()) / 3
}).showDialogfixed();
$('#dig_name').focus();
};
_am.deleteAlertMappingItem = function (e, alertmapping) {
var tr = $(this).parents('tr:first');
var id = tr.attr('data-id');
var alerttitle = GetTextByKey("P_AMP_DELETE", 'Delete');
var comfirmmsg = GetTextByKey("P_AMP_DOYOUWANTTODELETETHISALERTMAPPINGITEM", 'Do you want to delete this alert mapping item?');
if (e.data || !id) {
showConfirm(comfirmmsg, alerttitle, function (e) {
tr.remove();
});
} else {
showConfirm(comfirmmsg, alerttitle, function (e) {
alertquery('DeleteAlertMappingItem', id, function (data) {
if (!data || data.length == 0) {
var subctrls = tr.data('subctrls');
alertmapping.Items.splice(alertmapping.Items.indexOf(subctrls.item), 1);
tr.remove();
} else {
showAlert(data, alerttitle);
}
});
});
}
};
_am.checkAlertMappingItem = function (item) {
var alerttitle = GetTextByKey("P_AMP_SAVEALERTMAPPINGITEM", 'Save Alert Mapping Item');
if (!item.Make) {
showAlert(GetTextByKey("P_AMP_MAKEISREQUIRED", 'Make is required.'), alerttitle);
return false;
}
if (!item.Models || item.Models.length == 0) {
showAlert(GetTextByKey("P_AMP_MODELISREQUIRED", 'Model is required.'), alerttitle);
return false;
}
//if (!item.AlertType || item.AlertType.length == 0) {
// showAlert(GetTextByKey("P_AMP_ALERTTYPEISREQUIRED", 'Alert Type is required.'), alerttitle);
// return false;
//}
//if (!item.DescriptionId || item.DescriptionId <= 0) {
// showAlert(GetTextByKey("P_AMP_DESCRIPTIONISREQUIRED", 'Description is required.'), alerttitle);
// return false;
//}
//if (!item.CategoryId || item.CategoryId <= 0) {
// showAlert(GetTextByKey("P_AMP_CATEGORYISREQUIRED", 'Category is required.'), alerttitle);
// return false;
//}
return true;
};
_am.saveAlertMappingItem = function (alertmapping) {
var tr = $(this).parents('tr:first');
function next() {
subctrls.item.Make = item.Make;
subctrls.item.Models = item.Models;
subctrls.item.AlertType = item.AlertType;
//subctrls.item.DescriptionId = item.DescriptionId;
subctrls.item.CategoryId = item.CategoryId;
createAlertMappingItem(alertmapping, tr.parents('tbody:first'));
}
var subctrls = tr.data('subctrls');
var item = {
'Id': parseInt(tr.attr('data-id')),
'MappingId': parseInt(tr.attr('data-mappingid')),
'Make': subctrls.divmake.dropdownVal(),
'Models': subctrls.divmodel.dropdownVals(),
'AlertType': subctrls.divalerttype.dropdownVal(),
//'DescriptionId': subctrls.divdesc.dropdownVal(),
'CategoryId': subctrls.divcategory.dropdownVal() || "-1"
};
if (item.Models.length == 0 && subctrls.divmodel.allselected())
item.Models = [-1];
if (!_am.checkAlertMappingItem(item)) {
return;
}
alertquery('SaveAlertMappingItem', htmlencode(JSON.stringify(item)), function (data) {
if (data > 0) {
next();
}
else if (data == -1) {
showAlert(GetTextByKey('P_AMP_THISCOMBINATIONOFMAKEANDMODELSALREADYEXISTS', 'This combination of Make and Models already exists. '), title);
}
else {
showAlert(data, GetTextByKey("P_AMP_SAVEALERTMAPPINGITEM", 'Save Alert Mapping Item'));
}
});
};
_am.cancelAlertMappingSave = function (e) {
var tr = $(this).parents('tr:first');
tr.find('input[type="text"]').removeClass('focused');
tr.find('textarea').removeClass('focused');
tr.find('select').removeClass('focused');
tr.find('.general').css('display', 'block');
tr.find('.editing').css('display', 'none');
var inps = tr.find('input');
for (var i = 0; i < inps.length; i++) {
var inp = $(inps[i]);
var data = inp.attr('data-ori');
if (inp.attr('type') == 'text') {
inp.val(data || '');
} else if (inp.attr('type') == 'checkbox') {
inp.prop('checked', eval(data));
}
}
var recurring = tr.find('.inp_recurring').prop('checked');
var inp = tr.find('.inp_priority');
inp.prop('disabled', !recurring);
if (recurring) {
inp.parent('td').removeClass('gray_field');
} else {
inp.parent('td').addClass('gray_field');
}
var textarea = tr.find('.textarea_desc');
var desc = $(textarea).attr('data-ori');
$(textarea).val(desc);
};
_am.createAlertMappingTr = function (item, alertmapping) {
var tr = $('<tr></tr>').attr('data-id', item.Id).attr('data-mappingid', item.MappingId);
var td;
td = $('<td></td>');
var divmake = $('<div></div>');
td.append(divmake);
tr.append(td);
divmake.css('width', 200).css('position', 'relative').dropdown(alertMappingDataSource.Makes, {
search: true,
valueKey: 'ID',
textKey: 'Name'
}).on('select', function (_e, it) {
_am.focusAlertMappingItem(tr);
if (it) {
var r = filterModels(it.ID, item.Id, alertmapping);
divmodel.allowselectall(r.allowAll).dropdownSource(r.models).dropdownVals([]);
if (it.ID == -1 && r.allowAll)
divmodel.allselected(true);
else
divmodel.dropdownVals([]);
}
}).dropdownVal(item.Make);
td = $('<td></td>');
var divmodel = $('<div></div>');
td.append(divmodel);
tr.append(td);
divmodel.css('width', 320).css('position', 'relative').dropdown([], {
search: true,
multiselect: true,
//allowselectall: false,
valueKey: 'ID',
textKey: 'Name',
enableKey: 'Enable'
}).on('collapsed', function (_e) {
if (item.Models.toString() != divmodel.dropdownVals().toString())
_am.focusAlertMappingItem(tr);
});
var r = filterModels(item.Make, item.Id, alertmapping);
divmodel.allowselectall(r.allowAll).dropdownSource(r.models).dropdownVals(item.Models);
if (item.Models.length == 1 && item.Models[0] == -1)
divmodel.allselected(true);
td = $('<td></td>');
var divalerttype = $('<div></div>');
td.append(divalerttype);
tr.append(td);
divalerttype.css('width', 200).css('position', 'relative').dropdown(alertMappingDataSource.AlertTypes, {
search: false,
valueKey: 'ID',
textKey: 'Name'
}).on('select', function (_e, it) {
_am.focusAlertMappingItem(tr);
}).dropdownVal(item.AlertType);
td = $('<td></td>');
var divdesc = $('<div></div>').css('width', 400).text(alertmapping.EnhancedDescription);
td.append(divdesc);
tr.append(td);
//td = $('<td></td>');
//var divdesc = $('<div class="descdropdown"></div>');
//td.append(divdesc);
//tr.append(td);
//divdesc.css('width', 400).css('position', 'relative').dropdown(alertMappingDataSource.Descriptions, {
// search: true,
// valueKey: 'ID',
// textKey: 'Name'
//}).on('select', function (_e, it) {
// if (it && it.ID == "") {
// divdesc.dropdownVal(item.DescriptionId);
// OnAddAlertMappingSource(1);
// }
// else
// _am.focusAlertMappingItem(tr);
//}).dropdownVal(item.DescriptionId);
td = $('<td></td>');
var divcategory = $('<div class="categorydropdown"></div>');
td.append(divcategory);
tr.append(td);
divcategory.css('width', 200).css('position', 'relative').dropdown(alertMappingDataSource.Categories, {
search: true,
valueKey: 'ID',
textKey: 'Name'
}).on('select', function (_e, it) {
if (it && it.ID == "") {
divcategory.dropdownVal(item.CategoryId);
OnAddAlertMappingSource(2);
}
else
_am.focusAlertMappingItem(tr);
}).dropdownVal(item.CategoryId);
td = $('<td class="td_funcs"></td>');
// 常规操作
var div = $('<div class="general"></div>');
div.append($('<a onclick="return false;">' + GetTextByKey("P_PM_DELETE", "Delete") + '</a>').on('click', function (e) { _am.deleteAlertMappingItem.call(this, e, alertmapping) }));
td.append(div);
div = $('<div class="editing" style="display:none;"></div>');
div.append($('<input type="button" value="' + GetTextByKey("P_PM_SAVE", "Save") + '"/>').on('click', function () { _am.saveAlertMappingItem.call(this, alertmapping) }));
div.append($('<input type="button" style="margin-left:5px;" value="' + GetTextByKey("P_PM_CANCEL", "Cancel") + '"/>').on('click', _am.cancelAlertMappingSave));
td.append(div);
tr.append(td);
tr.data('subctrls', {
item: item,
divmake: divmake,
divmodel: divmodel,
divalerttype: divalerttype,
//divdesc: divdesc,
divcategory: divcategory
});
return tr;
};
})();

View File

@ -10,23 +10,21 @@ $(function () {
dialogAssets.onOK = function (source) {
var items = [];
for (var i = 0; i < source.length; i++) {
var it = source[i].Values;
var it = source[i];
if (it.Selected) {
items.push({
Values: {
ID: it.Id,
VIN: it.VIN,
Name: it.Name,
MakeName: it.MakeName,
ModelName: it.ModelName,
TypeName: it.TypeName
}
});
});
}
}
var p = [
custrecordid,
JSON.stringify(items.map(function (f) { return f.Values.ID; }))
JSON.stringify(items.map(function (f) { return f.ID; }))
];
$("#dialogmask").show();
@ -34,7 +32,7 @@ $(function () {
showmaskbg(false);
$("#dialogmask").hide();
if (r === 'OK') {
grid_dtsm.setData(grid_dtsm.innerSource.concat(items));
grid_dtsm.setData(grid_dtsm.source.concat(items));
} else {
showAlert(r, GetTextByKey("P_UM_ASSETASSIGNMENT", 'Asset Assignment'));
}
@ -47,8 +45,8 @@ $(function () {
function OnMachineAdd() {
showmaskbg(true);
dialogAssets.exceptSource = grid_dtsm.innerSource.map(function (s) {
return s.Values.ID;
dialogAssets.exceptSource = grid_dtsm.source.map(function (s) {
return s.ID;
});
dialogAssets.showSelector();
}
@ -68,13 +66,13 @@ function OnManageMachine(u) {
var title = GetTextByKey("P_UM_ASSETASSIGNMENT", "Asset Assignment");// + "&nbsp;&nbsp;&nbsp;&nbsp;" + jobsite.Name + "&nbsp;&nbsp;&nbsp;&nbsp;" + "Radius_UOM: " + jobsite.Radius_UOM
$('#dialog_managemahchine .dialog-title span.title').html(title);
$('.machine_maskbg').show();
showmaskbg(true);
$('#dialog_managemahchine')
.attr('init', 1)
.css({
'top': (document.documentElement.clientHeight - $('#dialog_managemahchine').height()) / 5,
'left': (document.documentElement.clientWidth - $('#dialog_managemahchine').width()) / 2
}).showDialog();
}).showDialogfixed();
grid_dtsm.setData([]);
$('#selectedmachinelist input[type="checkbox"]').prop('checked', false);
@ -99,14 +97,8 @@ function GetAssignedMachines() {
}
function showSelectedMachine(data) {
var rows = [];
for (var i = 0; i < data.length; i++) {
var r = data[i];
var fr = { Values: r };
rows.push(fr);
}
grid_dtsm.setData(rows);
grid_dtsm.setData(data);
}
function OnMachineDeleteSingle(item) {
@ -121,22 +113,16 @@ function OnMachineDeleteSingle(item) {
if (r !== 'OK') {
showAlert(r, GetTextByKey("P_UM_ASSETASSIGNMENT", "Asset Assignment"));
} else {
for (var i = 0; i < grid_dtsm.innerSource.length; i++) {
var s = grid_dtsm.innerSource[i].Values;
if (s.ID === item.ID) {
grid_dtsm.innerSource.splice(i, 1);
break;
}
}
if (grid_dtsm.source != null) {
for (var j = 0; j < grid_dtsm.source.length; j++) {
if (item.ID === grid_dtsm.source[j].Values.ID) {
grid_dtsm.source.splice(j, 1);
var tmp = grid_dtsm.source;
if (tmp != null) {
for (var j = 0; j < tmp.length; j++) {
if (item.ID === tmp[j].ID) {
tmp.splice(j, 1);
break;
}
}
}
grid_dtsm.reset();
grid_dtsm.setData(tmp);
}
});
});
@ -144,7 +130,7 @@ function OnMachineDeleteSingle(item) {
function OnMachineDelete() {
showConfirm(GetTextByKey("P_UM_DELETESELECTEDASSET", 'Are you sure you want to delete these selected assets?'), GetTextByKey("P_UM_ASSETASSIGNMENT", "Asset Assignment"), function () {
var ids = grid_dtsm.innerSource.filter(function (s) { return s.Values.selected; }).map(function (s) { return s.Values.ID; });
var ids = grid_dtsm.source.filter(function (s) { return s.selected; }).map(function (s) { return s.ID; });
var params = [
custrecordid,
JSON.stringify(ids)
@ -155,21 +141,17 @@ function OnMachineDelete() {
if (r !== 'OK') {
showAlert(r, GetTextByKey("P_UM_ASSETASSIGNMENT", "Asset Assignment"));
} else {
for (var i = grid_dtsm.innerSource.length - 1; i >= 0; i--) {
var s = grid_dtsm.innerSource[i].Values;
if (s.selected) {
grid_dtsm.innerSource.splice(i, 1);
}
}
if (grid_dtsm.source != null) {
for (var j = grid_dtsm.source.length - 1; j >= 0; j--) {
var l = grid_dtsm.source[j].Values;
var tmp = grid_dtsm.source;
if (tmp != null) {
for (var j = tmp.length - 1; j >= 0; j--) {
var l = tmp[j];
if (l.selected) {
grid_dtsm.source.splice(j, 1);
tmp.splice(j, 1);
}
}
}
grid_dtsm.reset();
grid_dtsm.setData(tmp);
grid_dtsm.reload(true);
}
});
});
@ -177,12 +159,7 @@ function OnMachineDelete() {
var grid_dtsm;
function InitGridSelectedMachines() {
grid_dtsm = new GridView('#selectedmachinelist');
grid_dtsm.lang = {
all: GetTextByKey("P_GRID_ALL", "(All)"),
ok: GetTextByKey("P_GRID_OK", "OK"),
reset: GetTextByKey("P_GRID_RESET", "Reset")
};
grid_dtsm = createGridView('#selectedmachinelist');
var list_columns = [
{ name: 'VIN', caption: GetTextByKey("P_UM_SN", "SN"), valueIndex: 'VIN', css: { 'width': 160, 'text-align': 'left' } },
{ name: 'Name', caption: GetTextByKey("P_UM_NAME", "Name"), valueIndex: 'Name', css: { 'width': 160, 'text-align': 'left' } },
@ -224,8 +201,9 @@ function InitGridSelectedMachines() {
width: 30,
align: 'center',
sortable: false,
isurl: true,
text: '\uf00d',
resizable: false,
type: GridView.ColumnTypes.Icon,
text: 'times',
events: {
onclick: function () {
OnMachineDeleteSingle(this);
@ -236,15 +214,9 @@ function InitGridSelectedMachines() {
},
attrs: { 'title': GetTextByKey("P_UM_DELETE", 'Delete') }
});
grid_dtsm.canMultiSelect = true;
grid_dtsm.multiSelect = true;
grid_dtsm.columns = columns;
grid_dtsm.init();
grid_dtsm.selectedrowchanged = function (rowindex) {
var rowdata = grid_dtsm.source[rowindex];
if (rowdata) {
}
}
}

View File

@ -54,13 +54,13 @@ function DoUploadAttachments(fid) {
uploadingindex = -1;
getAttachments();
if (fileupload_errors !== "")
showAlert(fileupload_errors, GetTextByKey("P_WO_XXXXX", 'Upload failed'));
showAlert(fileupload_errors, GetTextByKey("P_WO_UPLOADFAILED", 'Upload failed'));
showloading(false);
return;
}
var file = filesinuploading[uploadingindex];
if (file.name.length > 200) {
showUplpadingStatus(GetTextByKey("P_WO_XXX", "Attachment name length cannot be greater than 200."));
showUplpadingStatus(GetTextByKey("P_WO_ATTACHMENTNAMELENGTHCANNOTBEGREATERTHAN", "Attachment name length cannot be greater than 200."));
DoUploadAttachments(fid);
return;
}
@ -95,7 +95,7 @@ function DoUploadAttachments(fid) {
}
},
error: function (err) {
showUplpadingStatus(GetTextByKey("P_WO_XXXXX", 'Upload failed'));
showUplpadingStatus(GetTextByKey("P_WO_UPLOADFAILED", 'Upload failed'));
DoUploadAttachments(fid);
}
});

File diff suppressed because it is too large Load Diff

View File

@ -1,205 +1,207 @@

if (typeof manageassetsCtrl !== 'function') {
$manageassetsCtrl = function manageassetsCtrl() {
this.tmpobj = {
};
this.wizardCtrl = null;
this.vue = null;
};
function showAssignedAssetsList(data) {
(function () {
'use strict';
var dataGrid = window.DataGrid || window['g5-datagrid'];
$manageassetsCtrl.prototype.getData = function (/*dataObj, tmpdata*/) {
return this.vue.source;
};
$manageassetsCtrl.prototype.setData = function (assetData) {
if (assetData) {
for (var i = 0; i < assetData.length; i++) {
var a = assetData[i];
a.Selected = false;
if (a.Highlight == undefined)
a.Highlight = false;
}
}
this.vue.source = assetData ? assetData : [];
this.vue.$refs.grid.resize();
};
$manageassetsCtrl.prototype.reload = function () {
this.vue.$refs.grid.reload()
};
$manageassetsCtrl.prototype.Init = function (parent, newselected) {
var ethis = this;
//加载子页面模版
parent.load('../template/ManageAssetsCtrl.html?v=8', function () {
ethis.vue = new Vue({
el: parent.find('.ManageAssetsCtrl')[0],
components: {
'data-grid': dataGrid
},
data: {
wnd: window.parent,
editable: true,
columns: [],
source: []
},
computed: {
},
watch: {
source: function (val) {
}
},
methods: {
cellvaluechanged: function (item, key) {
},
rowdblclick: function (e) {
}
}
});
ethis.vue.columns = createGridColumn(newselected);
});
};
function createGridColumn(newselected) {
var editable = false;
var columns = [
{
key: 'Selected',
caption: '',
type: dataGrid.COLUMN_TYPE.checkbox,
width: 30,
align: 'center',
sortable: false,
orderable: false,
enabled: true,
resizable: false,
allcheck: false,
visible: !newselected
},
{
key: 'VIN',
caption: GetTextByKey("P_PM_SN", 'SN'),
type: dataGrid.COLUMN_TYPE.lable,
width: 140,
orderable: false,
resizable: true,
enabled: editable,
styleFilter: function (item) {
if (item.Highlight)
return { 'background-color': 'yellow' };
}
},
{
key: 'Name',
caption: GetTextByKey("P_PM_NAME", 'Name'),
type: dataGrid.COLUMN_TYPE.lable,
width: 140,
orderable: false,
resizable: true,
enabled: editable,
styleFilter: function (item) {
if (item.Highlight)
return { 'background-color': 'yellow' };
}
},
{
key: 'MakeName',
caption: GetTextByKey("P_PM_MAKE", 'Make'),
type: dataGrid.COLUMN_TYPE.lable,
width: 100,
orderable: false,
enabled: editable,
resizable: true,
visible: !newselected,
styleFilter: function (item) {
if (item.Highlight)
return { 'background-color': 'yellow' };
}
},
{
key: 'ModelName',
caption: GetTextByKey("P_PM_MODEL", 'Model'),
type: dataGrid.COLUMN_TYPE.lable,
width: 100,
orderable: false,
resizable: true,
enabled: editable,
visible: !newselected,
styleFilter: function (item) {
if (item.Highlight)
return { 'background-color': 'yellow' };
}
},
{
key: 'EngineHours',
caption: GetTextByKey("P_PM_CURRENTHOURS", 'Current Hours'),
type: dataGrid.COLUMN_TYPE.lable,
width: 100,
orderable: false,
resizable: true,
visible: (scheduletype === "HM" || scheduletype === "PM")
},
{
key: 'StartHours',
caption: GetTextByKey("P_PM_STARTINGHOURS", 'Starting Hours'),
type: dataGrid.COLUMN_TYPE.input,
width: 100,
orderable: false,
resizable: false,
enabled: 'Enabled',
visible: (scheduletype === "HM" || scheduletype === "PM")
},
{
key: 'Odometer',
caption: GetTextByKey("P_PM_CURRENTODOMETER", 'Current Odometer'),
type: dataGrid.COLUMN_TYPE.lable,
width: 120,
orderable: false,
resizable: true,
visible: (scheduletype === "RDM" || scheduletype === "ADM")
},
{
key: 'StartOdometer',
caption: GetTextByKey("P_PM_STARTODOMETER", 'Start Odometer'),
type: dataGrid.COLUMN_TYPE.input,
width: 100,
orderable: false,
resizable: false,
enabled: 'Enabled',
visible: (scheduletype === "RDM" || scheduletype === "ADM")
},
{
key: 'StartDateString',
caption: GetTextByKey("P_PM_PLANSTARTDATE", 'Plan Start Date'),
type: dataGrid.COLUMN_TYPE.datepicker,
width: 100,
orderable: false,
resizable: false,
enabled: 'Enabled',
visible: scheduletype === "TBM"
},
{
key: 'StartIntervalValue',
caption: GetTextByKey("P_PM_STARTINTERVAL", 'Start Interval'),
type: dataGrid.COLUMN_TYPE.dropdown,
source: 'TempIntervals',
width: 100,
orderable: false,
resizable: false,
enabled: 'Enabled',
visible: (scheduletype === "HM" || scheduletype === "RDM" || scheduletype === "TBM")
}
];
return columns;
grid_assignedassetdt.setData(data);
grid_assignedassetdt.reload();
}
var grid_assignedassetdt;
function InitAssignedAssetsGridData() {
grid_assignedassetdt = createGridView('#divScheduleAssets');
grid_assignedassetdt.isEditable = true;
var list_columns = [
{ name: 'Selected', caption: "", valueIndex: 'Selected', type: 3, css: { 'width': 45, 'text-align': 'center' } },
{ name: 'VIN', caption: GetTextByKey("P_PM_SN", 'SN'), valueIndex: 'VIN', css: { 'width': 140, 'text-align': 'left' } },
{ name: 'Name', caption: GetTextByKey("P_PM_NAME", 'Name'), valueIndex: 'Name', css: { 'width': 140, 'text-align': 'left' } },
{ name: 'MakeName', caption: GetTextByKey("P_PM_MAKE", 'Make'), valueIndex: 'MakeName', css: { 'width': 100, 'text-align': 'left' } },
{ name: 'ModelName', caption: GetTextByKey("P_PM_MODEL", 'Model'), valueIndex: 'ModelName', css: { 'width': 100, 'text-align': 'left' } },
{ name: 'EngineHours', caption: GetTextByKey("P_PM_CURRENTHOURS", 'Current Hours'), valueIndex: 'EngineHours', css: { 'width': 100, 'text-align': 'left' } },
{ name: 'StartHours', caption: GetTextByKey("P_PM_STARTINGHOURS", 'Starting Hours'), valueIndex: 'StartHours', css: { 'width': 100, 'text-align': 'left' } },
{ name: 'Odometer', caption: GetTextByKey("P_PM_CURRENTODOMETER", 'Current Odometer'), valueIndex: 'Odometer', css: { 'width': 100, 'text-align': 'left' } },
{ name: 'StartOdometer', caption: GetTextByKey("P_PM_STARTODOMETER", 'Start Odometer'), valueIndex: 'StartOdometer', css: { 'width': 100, 'text-align': 'left' } },
{ name: 'StartDateString', caption: GetTextByKey("P_PM_PLANSTARTDATE", 'Plan Start Date'), valueIndex: 'StartDateString', css: { 'width': 100, 'text-align': 'left' } },
{ name: 'StartIntervalValue', caption: GetTextByKey("P_PM_STARTINTERVAL", 'Start Interval'), valueIndex: 'StartIntervalValue', css: { 'width': 100, 'text-align': 'left' } }
];
var columns = [];
var DateColumn = window['lib-ui'].GridDateColumn;
// 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;
col.oldFilterValues = col.filterValues;
col.styleFilter = function (item) {
if (item.Highlight)
return { 'background-color': 'yellow' };
}
}());
if (list_columns[hd].type) {
col.type = list_columns[hd].type;
}
col.alwaysshow = list_columns[hd].alwaysshow;
if (col.name === "EngineHours" && ["HM", "PM"].indexOf(scheduletype) < 0) {
col.visible = false;
continue;
}
else if (col.name === "Odometer" && ["RDM", "ADM"].indexOf(scheduletype) < 0) {
col.visible = false;
continue;
}
else if (col.name === "StartHours") {
if (["HM", "PM"].indexOf(scheduletype) < 0) {
col.visible = false;
continue;
}
col.type = GridView.ColumnTypes.Input;
}
else if (col.name === "StartOdometer") {
if (["RDM", "ADM"].indexOf(scheduletype) < 0) {
col.visible = false;
continue;
}
col.type = GridView.ColumnTypes.Input;
}
else if (col.name === "StartDateString") {
if (["TBM"].indexOf(scheduletype) < 0) {
col.visible = false;
continue;
}
col.type = DateColumn;
col.onChanged = function (item, value) {
item.StartDate = item.StartDateString = DateColumn.formatDate(value);
};
}
else if (col.name === "StartIntervalValue") {
if (["HM", "RDM", "TBM"].indexOf(scheduletype) < 0) {
col.visible = false;
continue;
}
col.type = GridView.ColumnTypes.Dropdown;
col.sourceCache = false;
col.source = function (item) {
var source = [];
if (item.TempIntervals && item.TempIntervals.length > 0) {
for (var i = 0; i < item.TempIntervals.length; i++) {
var t = item.TempIntervals[i];
var kv = { value: '' + t, text: '' + t };
source.push(kv);
}
}
return source;
};
}
columns.push(col);
}
grid_assignedassetdt.multiSelect = true;
grid_assignedassetdt.columns = columns;
grid_assignedassetdt.init();
}
function showSelectedAssetsList(data) {
grid_selectedassetdt.setData(data);
grid_selectedassetdt.reload();
}
var grid_selectedassetdt;
function InitSelectedAssetsGridData() {
grid_selectedassetdt = createGridView('#selectedassets');
grid_selectedassetdt.isEditable = true;
var list_columns = [
{ name: 'VIN', caption: GetTextByKey("P_PM_SN", 'SN'), valueIndex: 'VIN', css: { 'width': 140, 'text-align': 'left' } },
{ name: 'Name', caption: GetTextByKey("P_PM_NAME", 'Name'), valueIndex: 'Name', css: { 'width': 140, 'text-align': 'left' } },
{ name: 'EngineHours', caption: GetTextByKey("P_PM_CURRENTHOURS", 'Current Hours'), valueIndex: 'EngineHours', css: { 'width': 100, 'text-align': 'left' } },
{ name: 'StartHours', caption: GetTextByKey("P_PM_STARTINGHOURS", 'Starting Hours'), valueIndex: 'StartHours', css: { 'width': 100, 'text-align': 'left' } },
{ name: 'Odometer', caption: GetTextByKey("P_PM_CURRENTODOMETER", 'Current Odometer'), valueIndex: 'Odometer', css: { 'width': 100, 'text-align': 'left' } },
{ name: 'StartOdometer', caption: GetTextByKey("P_PM_STARTODOMETER", 'Start Odometer'), valueIndex: 'StartOdometer', css: { 'width': 100, 'text-align': 'left' } },
{ name: 'StartDateString', caption: GetTextByKey("P_PM_PLANSTARTDATE", 'Plan Start Date'), valueIndex: 'StartDateString', css: { 'width': 100, 'text-align': 'left' } },
{ name: 'StartIntervalValue', caption: GetTextByKey("P_PM_STARTINTERVAL", 'Start Interval'), valueIndex: 'StartIntervalValue', css: { 'width': 100, 'text-align': 'left' } }
];
var columns = [];
var DateColumn = window['lib-ui'].GridDateColumn;
// 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;
col.oldFilterValues = col.filterValues;
col.styleFilter = function (item) {
if (item.Highlight)
return { 'background-color': 'yellow' };
}
if (list_columns[hd].type) {
col.type = list_columns[hd].type;
}
col.alwaysshow = list_columns[hd].alwaysshow;
if (col.name === "EngineHours" && ["HM", "PM"].indexOf(scheduletype) < 0) {
col.visible = false;
continue;
}
else if (col.name === "Odometer" && ["RDM", "ADM"].indexOf(scheduletype) < 0) {
col.visible = false;
continue;
}
else if (col.name === "StartHours") {
if (["HM", "PM"].indexOf(scheduletype) < 0) {
col.visible = false;
continue;
}
col.type = GridView.ColumnTypes.Input;
}
else if (col.name === "StartOdometer") {
if (["RDM", "ADM"].indexOf(scheduletype) < 0) {
col.visible = false;
continue;
}
col.type = GridView.ColumnTypes.Input;
}
else if (col.name === "StartDateString") {
if (["TBM"].indexOf(scheduletype) < 0) {
col.visible = false;
continue;
}
col.type = DateColumn;
col.onChanged = function (item, value) {
item.StartDate = item.StartDateString = DateColumn.formatDate(value);
};
}
else if (col.name === "StartIntervalValue") {
if (["HM", "RDM", "TBM"].indexOf(scheduletype) < 0) {
col.visible = false;
continue;
}
col.type = GridView.ColumnTypes.Dropdown;;
col.sourceCache = false;
col.source = function (item) {
var source = [];
if (item.TempIntervals && item.TempIntervals.length > 0) {
for (var i = 0; i < item.TempIntervals.length; i++) {
var t = item.TempIntervals[i];
var kv = { value: '' + t, text: '' + t };
source.push(kv);
}
}
return source
};
}
columns.push(col);
}
grid_selectedassetdt.multiSelect = true;
grid_selectedassetdt.columns = columns;
grid_selectedassetdt.init();
}
function getIntervalValues(currentValue) {
@ -237,7 +239,7 @@ function getIntervalValues(currentValue) {
function getMachineTypes() {
pmquery('GetMachineTypes', '', function (data) {
var types = [];
types.push($('<option value="-1">' + GetTextByKey("P_SELECT_ALL","All") + '</option>'));
types.push($('<option value="-1">' + GetTextByKey("P_SELECT_ALL", "All") + '</option>'));
if (data && data.length > 0) {
for (var i = 0; i < data.length; i++) {
types.push($('<option></option>').val(data[i].ID).text(data[i].Name));
@ -267,7 +269,7 @@ function GetSelectedMachines() {
}
function getMatchSelectedMachines() {
var typeid = $('#sel_machine_type').val();
var typeid = parseInt($('#sel_machine_type').val());
var machinefilter = $('#txt_machine_key').val().toLowerCase();
var showallassigned = $('#chk_showallassignedassets').prop('checked');
@ -311,10 +313,7 @@ function getMatchSelectedMachines() {
_showSelectedMachines.push(unMatched[i]);
}
if (assignedassetCtrl) {
assignedassetCtrl.setData(_showSelectedMachines);
//assignedassetCtrl.reload();
}
showAssignedAssetsList(_showSelectedMachines);
}
function OnSaveMachines() {
@ -326,7 +325,7 @@ function OnSaveMachines() {
asset.StartIntervalValue = machine.StartIntervalValue;
switch (scheduletype) {
case "TBM":
asset.StartDate = machine.StartDateString;
asset.StartDate = machine.StartDate;
if (asset.StartDate == "")
asset.StartDate = "1900-01-01";
break;
@ -351,15 +350,16 @@ function OnSaveMachines() {
'Assets': assets
};
var alerttitle = GetTextByKey("P_MA_SAVEASSETS", 'Save Assets');
pmquery('SaveMachines', JSON.stringify(item), function (data) {
if (!data || data.length == 0) {
// success
for (var i = 0; i < _ScheduleAssets.length; i++) {
_ScheduleAssets[i].unSaved = false;
}
showAlert(GetTextByKey("P_PM_SAVEASSETLISTSUCCESSFUL", 'Save asset list successful.'));
showAlert(GetTextByKey("P_PM_SAVEASSETLISTSUCCESSFUL", 'Save asset list successful.'), alerttitle);
} else {
showAlert(GetTextByKey("P_PM_FAILEDTOSAVEASSETLIST", 'Failed to save asset list.') + "\n" + data);
showAlert(GetTextByKey("P_PM_FAILEDTOSAVEASSETLIST", 'Failed to save asset list.') + "\n" + data, alerttitle);
}
});
}
@ -400,11 +400,10 @@ function convertOdometer(odometer, odounit) {
return Math.round(value);
}
var selectedassetsctrl = undefined;
function setNewSelectedAseets(assets) {
var newassets = [];
for (var i = 0; i < assets.length; i++) {
var a = assets[i].Values;
var a = assets[i];
if (!a.Selected) continue;
var item = {};
@ -414,12 +413,14 @@ function setNewSelectedAseets(assets) {
item.Name = a.Name;
item.MakeName = a.MakeName;
item.ModelName = a.ModelName;
item.TypeID = a.TypeID;
item.TypeName = a.TypeName;
item.EngineHours = a.EngineHours;
item.StartHours = a.EngineHours;
item.Odometer = convertOdometer(a.Odometer, a.OdometerUnits);
item.StartOdometer = item.Odometer;
item.OdometerUnits = a.OdometerUnits;
item.StartDateString = currentdate;
item.StartDate = item.StartDateString = currentdate;
item.StartIntervalValue = "";
item.Enabled = true;
if (scheduletype == "HM" || scheduletype == "RDM") {
@ -453,12 +454,13 @@ function setNewSelectedAseets(assets) {
'left': (document.documentElement.clientWidth - $('#dialog_machinegroup').width()) / 2
}).showDialog();
selectedassetsctrl.setData(newassets);
showSelectedAssetsList(newassets);
}
function OnSetAssetsDialogOK() {
for (var i = 0; i < selectedassetsctrl.vue.source.length; i++) {
var asset = selectedassetsctrl.vue.source[i];
var tempsource = grid_selectedassetdt.source;
for (var i = 0; i < tempsource.length; i++) {
var asset = tempsource[i];
asset.unSaved = true;
_ScheduleAssets.push(asset);
}
@ -500,14 +502,14 @@ function OnRemoveAssets() {
msg += assetwillalerts + ".<br/>";
msg += GetTextByKey("P_PM_DELTEALERTSYESORNOTIPS", "If you do not want those alerts deleted, select CANCEL and assign appropriate alerts to a maintenance record or work order in asset health prior to deletion/removal.");
}
showConfirm(msg, GetTextByKey("P_PM_REMOVEASSETS", 'Remove Assets'), function (e) {
var alerttitle = GetTextByKey("P_PM_REMOVEASSETS", 'Remove Assets');
showConfirmOKCancel(msg, alerttitle, function (e) {
pmquery('RemovePMAssets', JSON.stringify(item), function (data) {
if (!data || data.length == 0) {
showAlert(GetTextByKey("P_PM_ASSETSREMOVEDSUCCESSFULLY", 'Assets removed successfully.'));
showAlert(GetTextByKey("P_PM_ASSETSREMOVEDSUCCESSFULLY", 'Assets removed successfully.'), alerttitle);
GetSelectedMachines();
} else {
showAlert(GetTextByKey("P_PM_FAILEDTOREMOVEASSETS", 'Failed to remove assets.') + "\n" + data);
showAlert(GetTextByKey("P_PM_FAILEDTOREMOVEASSETS", 'Failed to remove assets.') + "\n" + data, alerttitle);
}
});
});

View File

@ -53,22 +53,51 @@ function addWorkOrderComment(comment) {
return;
}
var param = JSON.stringify([workorderid, comment]);
param = htmlencode(param);
$('#mask_over_bg').show();
worequest("AddWorkOrderComment", param, function (data) {
$('#mask_over_bg').hide();
if (data !== "") {
showAlert(data, GetTextByKey("P_WO_ERROR", 'Error'));
return;
var url = 'Maintenance/AddWorkOrder.aspx';
var method = 'SendInternalComments';
var data = new FormData();
data.append('MethodName', method);
data.append('WorkorderId', workorderid);
data.append('Comment', encodeURIComponent(comment));
//data.append('Emails', JSON.stringify(emailaddress));
//data.append('Phones', JSON.stringify(phonenumbers));
var file = internal?.file;
if (file != null) {
data.append('Attachment', file);
}
$.ajax({
url: _network.root + url,
type: 'POST',
dataType: 'json',
processData: false,
contentType: false,
cache: false,
data: data,
success: function (data) {
$('#mask_over_bg').hide();
if (data !== "") {
showAlert(data, GetTextByKey("P_WO_ERROR", 'Error'));
if (typeof internal !== 'undefined') {
internal.loading = false;
}
return;
}
if (typeof internal !== 'undefined') {
internal.text = '';
internal.file = null;
internal.loading = false;
}
$('#commentsinputcount').text("0/" + $('#dialog_comments').attr("maxlength"));
getComments();
},
error: function (request, textStatus, errorThrown) {
$('#mask_over_bg').hide();
if (typeof internal !== 'undefined') {
internal.loading = false;
}
}
if (typeof internal !== 'undefined') {
internal.text = '';
}
$('#commentsinputcount').text("0/" + $('#dialog_comments').attr("maxlength"));
getComments();
}, function (err) {
$('#mask_over_bg').hide();
});
}
@ -121,34 +150,70 @@ function getCommunications(reset) {
function addWorkOrderCommunication() {
var pmemails = customer?.contacts;
if (pmemails == null || pmemails.length === 0) {
if (typeof customer !== 'undefined')
customer.loading = false;
showAlert(GetTextByKey("P_WO_PLEASEINPUTTHEPHONENUMBEROREMAL", "Please input the phone number or email."), GetTextByKey("P_WO_ERROR", 'Error'));
return;
}
var comm = customer?.text;
if ($.trim(comm) == "") {
if (typeof customer !== 'undefined')
customer.loading = false;
showAlert(GetTextByKey("P_WO_PLEASEINPUTTHEMESSAGE", "Please input the message."), GetTextByKey("P_WO_ERROR", 'Error'));
return;
}
var includeStatusLink = customer?.statusLink;
var param = JSON.stringify([workorderid, JSON.stringify(pmemails), comm, (includeStatusLink ? "1" : "0")]);
param = htmlencode(param);
$('#mask_over_bg').show();
worequest("AddWorkOrderCommunication", param, function (data) {
$('#mask_over_bg').hide();
if (data !== "") {
showAlert(data, GetTextByKey("P_WO_ERROR", 'Error'));
return;
var url = 'Maintenance/AddWorkOrder.aspx';
var method = 'AddWorkOrderCommunication';
var data = new FormData();
data.append('MethodName', method);
data.append('WorkorderId', workorderid);
data.append('PMEmails', JSON.stringify(pmemails));
data.append('Comment', encodeURIComponent(comm));
data.append('IncludeStatusLink', includeStatusLink ? "1" : "0");
var file = customer?.file;
if (file != null) {
data.append('Attachment', file);
}
$.ajax({
url: _network.root + url,
type: 'POST',
dataType: 'json',
processData: false,
contentType: false,
cache: false,
data: data,
success: function (data) {
$('#mask_over_bg').hide();
if (typeof customer !== 'undefined')
customer.loading = false;
if (data !== "") {
showAlert(data, GetTextByKey("P_WO_ERROR", 'Error'));
return;
}
if (typeof customer !== 'undefined') {
customer.text = '';
customer.file = null;
}
$('#msginputcount').text("0/" + $('#dialog_communications').attr("maxlength"));
getCommunications();
},
error: function (request, textStatus, errorThrown) {
$('#mask_over_bg').hide();
if (typeof customer !== 'undefined') {
customer.loading = false;
}
if (request?.readyState == 0) {
console.log(request);
} else {
writelog_ironintel("onAddMessage", url + ".-1." + method + "." + JSON.stringify(param), JSON.stringify(request), textStatus + errorThrown);
}
}
if (typeof customer !== 'undefined') {
customer.text = '';
}
$('#msginputcount').text("0/" + $('#dialog_communications').attr("maxlength"));
getCommunications();
}, function (err) {
$('#mask_over_bg').hide();
});
}

View File

@ -1,5 +1,6 @@
$(function () {
InitContactGridData();
if ($("#contactlist").length > 0)//contactlist在AddWorkOrder中使用
InitContactGridData();
InitICContactGridData();
$('#sendworkorder_search').bind('input propertychange', function () {
@ -24,6 +25,9 @@
$('#sendicemailpopupdialog').dialog(function () {
showmaskbg(false);
if (typeof internal !== 'undefined') {
internal.loading = false;
}
});
});
@ -37,7 +41,8 @@ function getMachineContacts(assetid) {
return;
}
machineContacts = data;
showContactList(true);
if (grid_contactdt)//grid_contactdt在AddWorkOrder中使用
showContactList(true);
showICContactList(true);
}, function (err) {
});
@ -52,31 +57,30 @@ function showContactList(newopen) {
for (var i = 0; i < machineContacts.length; i++) {
var r = machineContacts[i];
var fr = { Values: r };
if (newopen) {
if (assignedto.toLowerCase() === r.IID.toLowerCase())
r.Email = true;
else
r.Email = false;
if (assignedto.toLowerCase() === r.IID.toLowerCase())
rows.splice(0, 0, fr);
rows.splice(0, 0, r);
else
rows.push(fr);
rows.push(r);
}
else {
if (!r.Text && !r.Email) {
if (r.DisplayName.toLowerCase().indexOf(filter) >= 0) {
if (assignedto.toLowerCase() === r.IID.toLowerCase())
rows.splice(0, 0, fr);
rows.splice(0, 0, r);
else
rows.push(fr);
rows.push(r);
}
}
else {
if (assignedto.toLowerCase() === r.IID.toLowerCase())
rows.splice(0, 0, fr);
rows.splice(0, 0, r);
else
rows.push(fr);
rows.push(r);
}
}
}
@ -88,12 +92,7 @@ function showContactList(newopen) {
var grid_contactdt;
function InitContactGridData() {
grid_contactdt = new GridView('#contactlist');
grid_contactdt.lang = {
all: GetTextByKey("P_GRID_ALL", "(All)"),
ok: GetTextByKey("P_GRID_OK", "OK"),
reset: GetTextByKey("P_GRID_RESET", "Reset")
};
grid_contactdt = createGridView('#contactlist');
var list_columns = [
{ name: 'DisplayName', caption: GetTextByKey("P_WO_CONTACTNAME", "Contact Name"), valueIndex: 'DisplayName', css: { 'width': 148, 'text-align': 'left' } },
{ name: 'ContactTypeName', caption: GetTextByKey("P_WO_CONTACTTYPE", "Contact Type"), valueIndex: 'ContactTypeName', css: { 'width': 148, 'text-align': 'left' } },
@ -126,15 +125,9 @@ function InitContactGridData() {
};
}
}
grid_contactdt.canMultiSelect = false;
grid_contactdt.multiSelect = false;
grid_contactdt.columns = columns;
grid_contactdt.init();
grid_contactdt.selectedrowchanged = function (rowindex) {
var rowdata = grid_contactdt.source[rowindex];
if (rowdata) {
}
}
}
function openSendEmail() {
@ -197,8 +190,9 @@ function onSendWorkOrder() {
}
}
for (var i = 0; i < grid_contactdt.source.length; i++) {
var ct = grid_contactdt.source[i].Values;
var tempsource = grid_contactdt.source;
for (var i = 0; i < tempsource.length; i++) {
var ct = tempsource[i];
if (ct.Email) {
emailaddress.push({ 'Key': ct.IID, 'Value': ct.ID });
}
@ -228,12 +222,7 @@ function onSendWorkOrder() {
var grid_iccontactdt;
function InitICContactGridData() {
grid_iccontactdt = new GridView('#iccontactlist');
grid_iccontactdt.lang = {
all: GetTextByKey("P_GRID_ALL", "(All)"),
ok: GetTextByKey("P_GRID_OK", "OK"),
reset: GetTextByKey("P_GRID_RESET", "Reset")
};
grid_iccontactdt = createGridView('#iccontactlist');
var list_columns = [
{ name: 'DisplayName', caption: GetTextByKey("P_WO_CONTACTNAME", "Contact Name"), valueIndex: 'DisplayName', css: { 'width': 148, 'text-align': 'left' } },
{ name: 'ContactTypeName', caption: GetTextByKey("P_WO_CONTACTTYPE", "Contact Type"), valueIndex: 'ContactTypeName', css: { 'width': 148, 'text-align': 'left' } },
@ -266,15 +255,9 @@ function InitICContactGridData() {
};
}
}
grid_iccontactdt.canMultiSelect = false;
grid_iccontactdt.multiSelect = false;
grid_iccontactdt.columns = columns;
grid_iccontactdt.init();
grid_iccontactdt.selectedrowchanged = function (rowindex) {
var rowdata = grid_iccontactdt.source[rowindex];
if (rowdata) {
}
}
}
function showICContactList(newopen) {
@ -286,15 +269,15 @@ function showICContactList(newopen) {
if (newopen) {
r.Text = false;
r.Email = false;
rows.push({ Values: r });
rows.push(r);
}
else {
if (!r.Text && !r.Email) {
if (r.DisplayName.toLowerCase().indexOf(filter) >= 0)
rows.push({ Values: r });
rows.push(r);
}
else
rows.push({ Values: r });
rows.push(r);
}
}
}
@ -340,12 +323,16 @@ function hideSendICEmailPopup() {
$('#sendicemailpopupdialog').hide();
}
var icsending = false;
function onSendInternalComments() {
var comment = internal?.text;
if ($.trim(comment) == "") {
hideSendICEmailPopup();
return;
}
if (icsending)
return;
icsending = true;
var alerttitle = GetTextByKey("P_WO_SENDINTERNALCOMMENTS", "Send Internal Comments");
var emailaddress = [];
var otheremailaddressstr = $('#sendic_otheremailaddress').val();
@ -375,34 +362,70 @@ function onSendInternalComments() {
}
}
for (var i = 0; i < grid_iccontactdt.source.length; i++) {
var ct = grid_iccontactdt.source[i].Values;
var tempsource = grid_iccontactdt.source;
for (var i = 0; i < tempsource.length; i++) {
var ct = tempsource[i];
if (ct.Email) {
emailaddress.push({ 'Key': ct.IID, 'Value': ct.ID });
emailaddress.push({ 'Key': ct.IID, 'Value': ct.ID, 'Tag1': ct.DisplayName });
}
if (ct.Text && (checkPhoneNumber(ct.Mobile) || CheckEmail(ct.Mobile))) {
phonenumbers.push({ 'Key': ct.IID, 'Value': ct.Mobile });
phonenumbers.push({ 'Key': ct.IID, 'Value': ct.Mobile, 'Tag1': ct.DisplayName });
}
}
var param = JSON.stringify([workorderid, comment, JSON.stringify(emailaddress), JSON.stringify(phonenumbers)]);
param = htmlencode(param);
worequest("SendInternalComments", param, function (data) {
if (data !== "") {
showAlert(data, GetTextByKey("P_WO_ERROR", 'Error'));
return;
var url = 'Maintenance/AddWorkOrder.aspx';
var method = 'SendInternalComments';
var data = new FormData();
data.append('MethodName', method);
data.append('WorkorderId', workorderid);
data.append('Comment', encodeURIComponent(comment));
data.append('Emails', JSON.stringify(emailaddress));
data.append('Phones', JSON.stringify(phonenumbers));
var file = internal?.file;
if (file != null) {
data.append('Attachment', file);
}
$.ajax({
url: _network.root + url,
type: 'POST',
dataType: 'json',
processData: false,
contentType: false,
cache: false,
data: data,
success: function (data) {
icsending = false;
$('#mask_over_bg').hide();
if (data !== "") {
showAlert(data, GetTextByKey("P_WO_ERROR", 'Error'));
if (typeof internal !== 'undefined') {
internal.loading = false;
}
return;
}
if (typeof internal !== 'undefined') {
internal.text = '';
internal.file = null;
internal.loading = false;
}
hideSendICEmailPopup();
if (typeof wowidgetobj != 'undefined')
wowidgetobj.reloaddata("InternalComments");
else
getComments();
},
error: function (request, textStatus, errorThrown) {
icsending = false;
hideSendICEmailPopup();
if (typeof internal !== 'undefined') {
internal.loading = false;
}
if (request?.readyState == 0) {
console.log(request);
} else {
writelog_ironintel("onSendInternalComments", url + ".-1." + method + "." + JSON.stringify(param), JSON.stringify(request), textStatus + errorThrown);
}
}
if (typeof internal !== 'undefined') {
internal.text = '';
}
hideSendICEmailPopup();
if (typeof wowidgetobj != 'undefined')
wowidgetobj.reloaddata("InternalComments");
else
getComments();
}, function (err) {
hideSendICEmailPopup();
});
}

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,6 @@
var $wowidgetselector = function (id) {
this.containerId = id;
this.title = GetTextByKey("P_XXX", 'Widgets');
this.title = GetTextByKey("P_WO_WIDGETS", 'Widgets');
this.companyId = null;;
this.forceSingle = false;
this.exceptShareAsset = false;
@ -15,12 +15,7 @@
var __proto = $wowidgetselector.prototype;
function initWidgetsGrid(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 grid = createGridView(parent);
var styleFilter = function (item) {
if (item.Suggested) {
return {
@ -40,26 +35,49 @@
if (item.Suggested)
return 'yellow';
};
var columns = [];
columns.push({
// checkbox
name: 'check',
key: 'Visible',
width: 45,
align: 'center',
sortable: false,
allcheck: true,
type: 3
},
grid.columns = [
{
// checkbox
name: 'check',
key: 'Visible',
width: 45,
align: 'center',
sortable: false,
allcheck: true,
type: 3
},
{
key: 'WidgetName',
caption: 'Name',
width: 300,
width: 290,
styleFilter: styleFilter,
bgFilter: bgFilter
});
//grid.canMultiSelect = true;
grid.columns = columns;
},
{
key: 'InBottom',
caption: 'Bottom',
//captionTooltip: 'Multiple widgets may be placed on the bottom',
type: 3,
width: 80,
enabled: 'Visible',
onChanged: function (item) {
item.InRight = !item.InBottom;
grid.refresh();
}
},
{
key: 'InRight',
caption: 'Right',
//captionTooltip: 'Only one widget may be placed on the right',
type: 3,
width: 70,
enabled: 'Visible',
onChanged: function (item) {
item.InBottom = !item.InRight;
grid.refresh();
}
}
];
grid.init();
this.gridWidgets = grid;
@ -75,9 +93,9 @@
var content = $('<div class="dialog-content"></div>').appendTo(dialog);
var labeldiv = $('<div style="margin: 4px 0 0 10px; line-height: 25px"></div>').appendTo(content);
$('<span></span>').text(GetTextByKey("P_XXX", 'Which Widgets Should be Displayed?')).appendTo(labeldiv);
$('<span></span>').text(GetTextByKey("P_WO_WHICHWIDGETSSHOULDBEDISPLAYED", 'Which Widgets Should be Displayed?')).appendTo(labeldiv);
this.widgetList = $('<div style="width: 520px; height: 320px; margin: 10px 0 4px"></div>').appendTo(content);
this.widgetList = $('<div style="width: 520px; height: 320px; margin: 10px 0 4px; position: relative"></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", 'unset');
@ -132,39 +150,48 @@
worequest("GetWorkOrderWidgets", "", function (data) {
if (typeof data === 'string') {
showAlert(GetTextByKey("P_XXX", 'Error'), title);
showAlert(GetTextByKey("P_WO_ERROR", 'Error'), title);
maskbg.hide();
return;
}
var items = [];
for (var i = 0; i < widgetdata.length; i++) {
var item = widgetdata[i].Values;
var item = widgetdata[i];
item.Visible = false;
for (var j = 0; j < data.length; j++) {
if (item.WidgetId == data[j].WidgetId) {
var wd = data[j];
if (item.WidgetId == wd.WidgetId) {
item.Visible = true;
item.InBottom = wd.Position != 1;
item.InRight = wd.Position == 1;
break;
}
}
items.push({ Values: item });
if (!item.InBottom && !item.InRight) {
item.InBottom = true;
}
items.push(item);
}
gridWidgets.setData(items);
maskbg.hide();
}, function () {
showAlert(GetTextByKey("P_XXXX", 'Failed to get the work order widget list.'), title);
showAlert(GetTextByKey("P_WO_FAILEDTOGETTHEWORKORDERWIDGETLIST", 'Failed to get the work order widget list.'), title);
maskbg.hide();
});
}
function onOKClick() {
var widgets = [];
for (var i = 0; i < this.gridWidgets.source.length; i++) {
widgets.push(this.gridWidgets.source[i].Values);
}
var _this = this;
var alerttitle = GetTextByKey("P_WO_XXX", "Save Widgets");
var param = JSON.stringify(widgets);
var alerttitle = GetTextByKey("P_WO_SAVEWIDGETS", "Save Widgets");
var param = JSON.stringify(this.gridWidgets.source.map(function (w) {
return {
WidgetId: w.WidgetId,
Category: w.Category,
Visible: w.Visible,
Position: w.InRight ? 1 : 0
};
}));
param = htmlencode(param);
worequest("SaveWorkOrderWidgets", param, function (data) {
if (data !== 'OK') {
@ -188,24 +215,46 @@ var WorkOrderWidget = function () {
var _this = this;
this.getWorkOrderWidgets = function () {
this.workorderwidgets = null;
var title = GetTextByKey("P_XXX", 'Widget');
var title = GetTextByKey("P_WO_WIDGETS", 'Widget');
worequest("GetWorkOrderWidgets", "", function (data) {
if (typeof data === 'string') {
showAlert(GetTextByKey("P_XXX", 'Error'), title);
showAlert(GetTextByKey("P_WO_ERROR", 'Error'), title);
return;
}
for (var w of data) {
w.InBottom = w.Position != 1;
w.InRight = w.Position == 1
}
_this.workorderwidgets = data;
var display = data?.length > 0 ? 'block' : 'none';
$('#workorderspliter').css('display', display);
$('#workorderdetail').css('display', display);
_this.showWorkOrderWidgets();
_this.getWorkOrderContacts(_this.workorderid);
setTimeout(function () {
$(window).resize();
document.querySelector('#workorderdetail').scrollTop = 0;
}, 0);
$(window).resize();
if (data?.length > 0) {
var displayBottom = data.find(function (w) { return w.InBottom }) != null ? '' : 'none';
var hasRight = data.find(function (w) { return w.InRight }) != null;
var displayRight = hasRight ? '' : 'none';
$('#workorderspliter').css('display', displayBottom);
$('#workorderdetail').css('display', spliterProps.collapsed ? 'none' : displayBottom);
$('#workorderspliter_right').css('display', displayRight);
var right = $('#workorderdetail_right');
right.css('display', spliterProps.collapsed_right ? 'none' : displayRight);
if (hasRight) {
ui.createTab(right[0]);
}
_this.showWorkOrderWidgets();
if (hasRight) {
right.find('.ui-tab-header>.ui-tab-title:first').click();
}
_this.getWorkOrderContacts(_this.workorderid);
setTimeout(function () {
document.querySelector('#workorderdetail').scrollTop = 0;
}, 0);
} else {
$('#workorderspliter').css('display', 'none');
$('#workorderdetail').css('display', 'none');
$('#workorderspliter_right').css('display', 'none');
$('#workorderdetail_right').css('display', 'none');
}
}, function () {
showAlert(GetTextByKey("P_XXXX", 'Failed to get the work order widget list.'), title);
showAlert(GetTextByKey("P_WO_FAILEDTOGETTHEWORKORDERWIDGETLIST", 'Failed to get the work order widget list.'), title);
});
}
@ -218,7 +267,7 @@ var WorkOrderWidget = function () {
} else {
for (let w of this.workorderwidgets) {
if (Object.prototype.hasOwnProperty.call(this.widgets, w.WidgetId)) {
this.widgets[w.WidgetId].changewo(this.workorderid, this.assetid, wo);
this.widgets[w.WidgetId]?.changewo(this.workorderid, this.assetid, wo);
}
}
this.getWorkOrderContacts(this.workorderid);
@ -229,8 +278,7 @@ var WorkOrderWidget = function () {
if (this.workorderwidgets != null) {
for (let w of this.workorderwidgets) {
this.popups[w.WidgetId]?.close(false);
if (this.widgets[w.WidgetId] && typeof this.widgets[w.WidgetId].close == 'function')
this.widgets[w.WidgetId].close();
this.widgets[w.WidgetId]?.close?.();
}
}
this.getWorkOrderWidgets();
@ -239,18 +287,21 @@ var WorkOrderWidget = function () {
this.onmsgreceived = function (data) {
if (this.workorderwidgets != null) {
if (data && this.workorderid == data.Message) {
var wid = this.workorderid;
if (data.Code == "501") {
for (let w of this.workorderwidgets) {
this.widgets[w.WidgetId].changewo(this.workorderid);
if (this.workorderwidgets && this.workorderwidgets.length > 0) {
for (let w of this.workorderwidgets) {
this.widgets[w.WidgetId]?.changewo(wid);
}
this.getWorkOrderContacts(this.workorderid);
}
this.getWorkOrderContacts(this.workorderid);
}
else if (data.Code == "503" || data.Code == "504" || data.Code == "507") {
this.widgets['CustomerCommunication']?.changewo(this.workorderid);
this.widgets['CustomerCommunication']?.changewo(wid);
this.getWorkOrderContacts(this.workorderid);
}
else if (data.Code == "505") {
this.widgets['InternalComments']?.changewo(this.workorderid);
this.widgets['InternalComments']?.changewo(wid);
}
else if (data.Code == "506") {
this.getWorkOrderContacts(this.workorderid);
@ -259,23 +310,43 @@ var WorkOrderWidget = function () {
{
for (let w of this.workorderwidgets) {
this.popups[w.WidgetId]?.close(false);
if (this.widgets[w.WidgetId] && typeof this.widgets[w.WidgetId].close == 'function')
this.widgets[w.WidgetId].close();
this.widgets[w.WidgetId]?.close?.();
}
this.workorderwidgets = null;
this.popups = [];
this.widgets = [];
this.popups = {};
this.widgets = {};
$('#workorderspliter').css('display', 'none');
$('#workorderdetail').css('display', 'none');
$(window).resize();
}
else if (data.Code == "508") {
this.widgets['Alerts']?.changewo(wid);
}
else if (data.Code == "509") {
this.widgets['Segments']?.changewo(wid);
}
else if (data.Code == "510") {
this.widgets['Attachments']?.changewo(wid);
}
else if (data.Code == "511") {
this.widgets['Inspections']?.changewo(wid);
this.widgets['Attachments']?.changewo(wid);
this.widgets['Alerts']?.changewo(wid);
}
else if (data.Code == "512") {
this.widgets['Estimates']?.changewo(wid);
}
else if (data.Code == "513") {
this.widgets['Invoices']?.changewo(wid);
}
}
}
};
this.reloaddata = function (widgetid) {
if (this.workorderwidgets != null) {
this.widgets[widgetid]?.changewo(this.workorderid);
var wid = this.workorderid;
this.widgets[widgetid]?.changewo(wid);
}
this.getWorkOrderContacts(this.workorderid);
};
@ -285,23 +356,28 @@ var WorkOrderWidget = function () {
this.defY = 0;
this.currentZIndex = 200 + this.workorderwidgets.length;
for (let w of this.workorderwidgets) {
this.createWidgetDialog(w);
if (w.InBottom) {
this.createWidgetDialog(w);
}
if (w.InRight) {
this.createWidgetDialog(w, true);
}
}
}
this.saveWorkOrderWidgets = function (widget, layout) {
widget.Layout = JSON.stringify(layout);
var title = GetTextByKey("P_XXX", 'Widget');
var title = GetTextByKey("P_WO_WIDGET", 'Widget');
worequest('SaveWorkOrderWidgetLayout', JSON.stringify(widget), function (data) {
if (data === 'OK') {
return;
}
showAlert(data, title);
}, function () {
showAlert(GetTextByKey("P_XXXX", 'Failed to save the work order widget layout.'), title);
showAlert(GetTextByKey("P_WO_FAILEDTOSAVETHEWORKORDERWIDGETLAYOUT", 'Failed to save the work order widget layout.'), title);
});
};
};
this.getWorkOrderContacts = function (woid) {
worequest('GetWorkOrderContacts', woid, function (data) {
@ -311,75 +387,90 @@ var WorkOrderWidget = function () {
}
if (_this.workorderwidgets != null) {
for (let w of _this.workorderwidgets) {
if (_this.widgets[w.WidgetId] && typeof _this.widgets[w.WidgetId].updatecontact == 'function')
_this.widgets[w.WidgetId].updatecontact(data);
_this.widgets[w.WidgetId]?.updatecontact?.(data);
}
}
}, function () {
});
};
this.createWidgetDialog = function (widget) {
this.createWidgetDialog = function (widget, right) {
const ui = window['lib-ui'];
let width = $(document.body).width();
let layout = widget.Layout;
if (!layout || layout === '') {
let x = this.defX;
let y = this.defY;
let left = 10 + 315 * x;
if (left + 300 > width) {
x = 0;
left = 10;
y++;
this.defY = y;
}
let top = 10 + 165 * y;
if (top >= widgetHeight) {
top = widgetHeight - 40;
}
x++;
this.defX = x;
layout = { left, top, width: 300, height: 400 };
} else {
layout = JSON.parse(widget.Layout);
if (layout.top >= widgetHeight) {
layout.top = widgetHeight - 40;
}
if (layout.left >= width) {
layout.left = width - 10;
}
}
let zIndex = this.currentZIndex--;
var container = ui.createElement('div', 'class-content');
var _this = this;
const popup = new ui.Popup({
title: widgetdata.find(function (v) { return v.Values.WidgetId == widget.WidgetId })?.Values?.WidgetName,
content: container,
mask: false,
// movable: false,
resizable: true,
collapsable: true,
zIndex,
changeZIndex: true,
minWidth: 210,
minHeight: 200,
buttons: [
//{
// text: 'Loading', trigger: p => {
// p.loading = true;
// setTimeout(() => p.loading = false, 1000);
// return false;
// }
//},
//{ text: 'OK' }
],
onMoveEnded: function () { _this.saveWorkOrderWidgets(widget, popup.rect) },
onResizeEnded: function () { _this.saveWorkOrderWidgets(widget, popup.rect) }
});
popup.show(document.querySelector('#workorderdetail'));
popup.rect = layout;
var opts;
let layout = widget.Layout;
if (right) {
opts = {
title: widgetdata.find(function (v) { return v.WidgetId == widget.WidgetId })?.WidgetName,
content: container,
mask: false,
closable: false,
movable: false,
resizable: false
};
} else {
let width = $(document.body).width();
if (!layout || layout === '') {
let x = this.defX;
let y = this.defY;
let left = 10 + 315 * x;
if (left + 300 > width) {
x = 0;
left = 10;
y++;
this.defY = y;
}
let top = 10 + 165 * y;
if (top >= spliterProps.widgetHeight) {
top = spliterProps.widgetHeight - 40;
}
x++;
this.defX = x;
layout = { left, top, width: 300, height: 400 };
} else {
layout = JSON.parse(widget.Layout);
if (layout.top >= spliterProps.widgetHeight) {
layout.top = spliterProps.widgetHeight - 40;
}
if (layout.left >= width) {
layout.left = width - 10;
}
}
let zIndex = this.currentZIndex--;
var _this = this;
opts = {
title: widgetdata.find(function (v) { return v.WidgetId == widget.WidgetId })?.WidgetName,
content: container,
mask: false,
// movable: false,
resizable: true,
collapsable: true,
zIndex,
changeZIndex: true,
minWidth: 210,
minHeight: 200,
onMoveEnded: function () { _this.saveWorkOrderWidgets(widget, popup.rect) },
onResizeEnded: function () { _this.saveWorkOrderWidgets(widget, popup.rect) }
};
}
const popup = new ui.Popup(opts);
if (right) {
var right = document.querySelector('#workorderdetail_right');
var header = right.querySelector('.ui-tab-header');
header.append(ui.createElement('span', function (span) {
span.className = 'ui-tab-title';
span.dataset.for = widget.WidgetId;
span.innerText = opts.title;
}));
popup.show(right);
popup.container.parentElement.classList.add('ui-tab-page');
popup.container.parentElement.dataset.page = widget.WidgetId;
} else {
popup.show(document.querySelector('#workorderdetail'));
popup.rect = layout;
}
this.popups[widget.WidgetId] = popup;
let options = {
@ -387,7 +478,8 @@ var WorkOrderWidget = function () {
canExport: canExport,
showloading: function (flag) {
popup.loading = flag;
}
},
inwidget: true
};
let content;
switch (widget.WidgetId) {
@ -401,11 +493,11 @@ var WorkOrderWidget = function () {
onchange: function () {
content.customer.statusLink = this.checked;
ui.setTooltip(checkLink, this.checked ?
GetTextByKey('P_WO_XXXXXX', 'Status Link Included') :
GetTextByKey('P_WO_XXXXXX', 'Status Link Excluded'));
GetTextByKey('P_WO_STATUSLINKINCLUDED', 'Status Link Included') :
GetTextByKey('P_WO_STATUSLINKEXCLUDED', 'Status Link Excluded'));
}
});
ui.setTooltip(checkLink, GetTextByKey('P_WO_XXXXXX', 'Status Link Excluded'));
ui.setTooltip(checkLink, GetTextByKey('P_WO_STATUSLINKEXCLUDED', 'Status Link Excluded'));
$(checkLink).insertAfter(options.parent.parents('.ui-popup-container').find('.ui-popup-header>.ui-popup-header-title'));
break;
case 'InternalComments': content = new $wointernal(options); break;
@ -415,6 +507,7 @@ var WorkOrderWidget = function () {
case 'Inspections': content = new $woinspection(options); break;
case 'Estimates': content = new $woestimate(options); break;
case 'Invoices': content = new $woinvoice(options); break;
case 'CustomerRecordComments': content = new $wocrcomment(options); break;
}
if (content != null) {
this.widgets[widget.WidgetId] = content;