add site
This commit is contained in:
165
Site/Inspection/js/modules/templates/linksection.js
Normal file
165
Site/Inspection/js/modules/templates/linksection.js
Normal file
@ -0,0 +1,165 @@
|
||||
define(['common'], function (Common) {
|
||||
|
||||
var dialogSection = null;
|
||||
var ls = function () {
|
||||
};
|
||||
|
||||
ls.prototype.getDialogSection = function () {
|
||||
if (!dialogSection)
|
||||
dialogSection = new $sectionselector();
|
||||
return dialogSection;
|
||||
}
|
||||
|
||||
var $sectionselector = function () {
|
||||
this.title = GetTextByKey("P_IPT_SELECTSECTION", 'Select Section');
|
||||
this.companyId = null;
|
||||
this.exceptSource = null;
|
||||
this.onOK = null;
|
||||
this.onDialogClosed = null;
|
||||
};
|
||||
|
||||
(function () {
|
||||
var __proto = $sectionselector.prototype;
|
||||
|
||||
function initGrid(parent) {
|
||||
var grid = new GridView(parent);
|
||||
var columns = [];
|
||||
columns.push({
|
||||
// checkbox
|
||||
name: 'check',
|
||||
key: 'Selected',
|
||||
width: 30,
|
||||
align: 'center',
|
||||
sortable: false,
|
||||
allcheck: true,
|
||||
type: 3
|
||||
});
|
||||
columns.push({
|
||||
key: 'Name',
|
||||
caption: GetTextByKey("P_IPT_NAME", 'Name'),
|
||||
width: 200
|
||||
},
|
||||
{
|
||||
key: 'DisplayText',
|
||||
caption: GetTextByKey("P_IPT_DISPLAYTEXT", 'DisplayText'),
|
||||
width: 320
|
||||
});
|
||||
//grid.canMultiSelect = true;
|
||||
grid.columns = columns;
|
||||
grid.init();
|
||||
|
||||
this.gridctrl = grid;
|
||||
}
|
||||
|
||||
function createDialog() {
|
||||
var dialog = $('<div class="dialog" style="display: none; width: 602px; height: 380px">');
|
||||
|
||||
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);
|
||||
|
||||
this.listdiv = $('<div style="width: 580px; height: 290px;margin-bottom:5px;"></div>').appendTo(content);
|
||||
|
||||
var dialogFunction = $('<div class="dialog-func"></div>').appendTo(dialog);
|
||||
$('<input type="button" value="' + GetTextByKey("P_IPT_CANCEL", "Cancel") + '" class="dialog-close" />').appendTo(dialogFunction);
|
||||
$('<input type="button" value="' + GetTextByKey("P_IPT_COPY", "Copy") + '" />').click(onCopyClick.bind(this)).appendTo(dialogFunction);
|
||||
$('<input type="button" value="' + GetTextByKey("P_IPT_ADDASLINK", "Add as Link") + '" />').click(onLinkClick.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
|
||||
initGrid.call(this, this.listdiv);
|
||||
$(document.body).append(dialog);
|
||||
var mask = $('<div class="maskbg"></div>');
|
||||
dialog.data('mask', mask);
|
||||
dialog.before(mask);
|
||||
|
||||
var _this = this;
|
||||
dialog.dialog(function () {
|
||||
if (_this.onDialogClosed)
|
||||
_this.onDialogClosed();
|
||||
if (dialog.data('mask'))
|
||||
dialog.data('mask').hide();
|
||||
});
|
||||
return dialog;
|
||||
}
|
||||
|
||||
__proto.showSelector = function () {
|
||||
if (!this.dialog) {
|
||||
this.dialog = createDialog.call(this);
|
||||
}
|
||||
|
||||
if (this.dialog.data('mask'))
|
||||
this.dialog.data('mask').show();
|
||||
this.dialog.showDialog(false);
|
||||
this.gridctrl.setData([]);
|
||||
onSearch.call(this);
|
||||
};
|
||||
|
||||
function onKeyPress(e) {
|
||||
if (e.keyCode === 13) {
|
||||
onSearch.call(this);
|
||||
}
|
||||
};
|
||||
|
||||
function excepted(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 excepts = this.exceptSource;
|
||||
var gridctrl = this.gridctrl;
|
||||
var title = this.title;
|
||||
var companyId = this.companyId || '';
|
||||
|
||||
inspectionrequest("GetGlobalSections", teamintelligence, function (data) {
|
||||
if (typeof data === 'string') {
|
||||
showAlert(GetTextByKey("P_IPT_FAILEDTOGETTHESECTIONS", 'Failed to get the sections: ') + data, title);
|
||||
maskbg.hide();
|
||||
return;
|
||||
}
|
||||
var items = [];
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
var it = data[i];
|
||||
if (excepts == null || !excepted(it.Id, excepts)) {
|
||||
items.push({ Values: it });
|
||||
}
|
||||
}
|
||||
gridctrl.setData(items);
|
||||
maskbg.hide();
|
||||
}, function (err) {
|
||||
showAlert(GetTextByKey("P_IPT_FAILEDTOGETTHESECTIONS1",'Failed to get the sections.'), title);
|
||||
maskbg.hide();
|
||||
});
|
||||
}
|
||||
|
||||
function onCopyClick() {
|
||||
//var index = this.gridctrl.selectedIndex;
|
||||
this.onOK && this.onOK(this.gridctrl.source, true);
|
||||
if (this.dialog.data('mask'))
|
||||
this.dialog.data('mask').hide();
|
||||
this.dialog.hideDialog();
|
||||
}
|
||||
|
||||
function onLinkClick() {
|
||||
//var index = this.gridctrl.selectedIndex;
|
||||
this.onOK && this.onOK(this.gridctrl.source, false);
|
||||
if (this.dialog.data('mask'))
|
||||
this.dialog.data('mask').hide();
|
||||
this.dialog.hideDialog();
|
||||
}
|
||||
})();
|
||||
|
||||
return ls;
|
||||
});
|
Reference in New Issue
Block a user