You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
290 lines
13 KiB
JavaScript
290 lines
13 KiB
JavaScript
/// <reference path="../Scripts/MicrosoftAjax.js" />
|
|
/// <reference path="../Scripts/jquery.min.js" />
|
|
/// <reference path="fancybox/jquery.fancybox-1.3.4.js" />
|
|
/// <reference path="jquery.easyui.min.js" />
|
|
|
|
Custom_Device = function () {
|
|
this.ApplicationPath = "../";
|
|
this.ControlID = "Window_Custom_Device";
|
|
this.ParentElement = null; //要加入的父容器
|
|
this.IsCheckPopedom = false; //是否需要检查权限
|
|
this.AppCode = ""; //是否需要检查权限
|
|
this.IDType = "DeviceNo"; //是否需要检查权限
|
|
var My = this;
|
|
|
|
var txtName = null;
|
|
var listLeftPerson = null;
|
|
var listRightPerson = null;
|
|
var listDeviceType = null;
|
|
var cmdPersonRightAll = null;
|
|
var cmdPersonLeftAll = null;
|
|
var cmdPersonRight = null;
|
|
var cmdPersonLeft = null;
|
|
var cmdSave = null;
|
|
var cmdGet = null;
|
|
|
|
var RightPerson = null;
|
|
|
|
var EventHandler = new Sys.EventHandlerList();
|
|
|
|
//#region 加载
|
|
this.Load = function () {
|
|
txtName = My.ControlID + "txtName";
|
|
listLeftPerson = My.ControlID + "listLeftPerson";
|
|
listRightPerson = My.ControlID + "listRightPerson";
|
|
listDeviceType = My.ControlID + "listDeviceType";
|
|
cmdPersonRightAll = My.ControlID + "cmdPersonRightAll";
|
|
cmdPersonLeftAll = My.ControlID + "cmdPersonLeftAll";
|
|
cmdPersonRight = My.ControlID + "cmdPersonRight";
|
|
cmdPersonLeft = My.ControlID + "cmdPersonLeft";
|
|
cmdSave = My.ControlID + "cmdSave";
|
|
cmdGet = My.ControlID + "cmdGet";
|
|
|
|
Init();
|
|
BindDeviceType();
|
|
|
|
$("#" + cmdPersonLeftAll, My.ParentElement).click(function () {
|
|
var options = $("#" + listRightPerson, My.ParentElement).find("option");
|
|
if (options.length == 0) { alert("没有可以移除的设备"); return; }
|
|
|
|
var html = new Sys.StringBuilder();
|
|
$(options).each(function () {
|
|
var PersonID = $(this).val();
|
|
var query = JSLINQ(RightPerson).Where(function (item) {
|
|
if (item.ID == PersonID) return item;
|
|
});
|
|
Array.remove(RightPerson, query.items[0]);
|
|
html.append("<option value='" + PersonID + "'>" + $(this).text() + "</option>");
|
|
});
|
|
$('#' + listLeftPerson, My.ParentElement).append(html.toString());
|
|
options.remove();
|
|
});
|
|
$("#" + cmdPersonRightAll, My.ParentElement).click(function () {
|
|
var options = $("#" + listLeftPerson, My.ParentElement).find("option");
|
|
if (options.length == 0) { alert("没有可以添加的设备"); return; }
|
|
var html = new Sys.StringBuilder();
|
|
$(options).each(function () {
|
|
var model = new Object();
|
|
model.ID = $(this).val();
|
|
model.Name = $(this).text();;
|
|
Array.add(RightPerson, model);
|
|
html.append("<option value='" + model.ID + "'>" + model.Name + "</option>");
|
|
});
|
|
$('#' + listRightPerson, My.ParentElement).append(html.toString());
|
|
options.remove();
|
|
});
|
|
$("#" + cmdPersonLeft, My.ParentElement).click(function () {
|
|
var options = $("#" + listRightPerson, My.ParentElement).find("option:selected");
|
|
if (options.length == 0) { alert("请选择要移除的设备"); return; }
|
|
var html = new Sys.StringBuilder();
|
|
$(options).each(function () {
|
|
var PersonID = $(this).val();
|
|
var query = JSLINQ(RightPerson).Where(function (item) {
|
|
if (item.ID == PersonID) return item;
|
|
});
|
|
Array.remove(RightPerson, query.items[0]);
|
|
html.append("<option value='" + PersonID + "'>" + $(this).text() + "</option>");
|
|
});
|
|
$('#' + listLeftPerson, My.ParentElement).append(html.toString());
|
|
options.remove();
|
|
});
|
|
$("#" + cmdPersonRight, My.ParentElement).click(function () {
|
|
var options = $("#" + listLeftPerson, My.ParentElement).find("option:selected");
|
|
if (options.length == 0) { alert("请选择要添加的设备"); return; }
|
|
var html = new Sys.StringBuilder();
|
|
$(options).each(function () {
|
|
var model = new Object();
|
|
model.ID = $(this).val();
|
|
model.Name = $(this).text();;
|
|
Array.add(RightPerson, model);
|
|
html.append("<option value='" + model.ID + "'>" + model.Name + "</option>");
|
|
});
|
|
$('#' + listRightPerson, My.ParentElement).append(html.toString());
|
|
options.remove();
|
|
});
|
|
|
|
$("#" + cmdSave, My.ParentElement).click(function () {
|
|
OnSave();
|
|
$.fancybox.close();
|
|
});
|
|
$("#" + cmdGet, My.ParentElement).click(function () {
|
|
RefshRightPerson();
|
|
});
|
|
$("#" + listDeviceType, My.ParentElement).change(function () {
|
|
RefshRightPerson();
|
|
});
|
|
|
|
$("#" + listLeftPerson, My.ParentElement).dblclick(function () {
|
|
var options = $("#" + listLeftPerson, My.ParentElement).find("option:selected");
|
|
if (options.length == 0) { return; }
|
|
var html = new Sys.StringBuilder();
|
|
$(options).each(function () {
|
|
var model = new Object();
|
|
model.ID = $(this).val();
|
|
model.Name = $(this).text();;
|
|
Array.add(RightPerson, model);
|
|
html.append("<option value='" + model.ID + "'>" + model.Name + "</option>");
|
|
});
|
|
$('#' + listRightPerson, My.ParentElement).append(html.toString());
|
|
options.remove();
|
|
});
|
|
|
|
$("#" + listRightPerson, My.ParentElement).dblclick(function () {
|
|
var options = $("#" + listRightPerson, My.ParentElement).find("option:selected");
|
|
if (options.length == 0) { return; }
|
|
var html = new Sys.StringBuilder();
|
|
$(options).each(function () {
|
|
var PersonID = $(this).val();
|
|
var query = JSLINQ(RightPerson).Where(function (item) {
|
|
if (item.ID == PersonID) return item;
|
|
});
|
|
Array.remove(RightPerson, query.items[0]);
|
|
html.append("<option value='" + query.items[0].ID + "'>" + $(this).text() + "</option>");
|
|
});
|
|
$('#' + listLeftPerson, My.ParentElement).append(html.toString());
|
|
options.remove();
|
|
});
|
|
|
|
}
|
|
//#endregion
|
|
//#region 初始化
|
|
function Init() {
|
|
if (My.ParentElement == null) My.ParentElement = $(document.body);
|
|
if ($("#" + My.ControlID, My.ParentElement).length > 0) return;
|
|
var htmlString = new Sys.StringBuilder();
|
|
htmlString.append("<div style='display: none;'>");
|
|
htmlString.append("<div id='" + My.ControlID + "' title='选择' style='width: 430px; height: auto;' >");
|
|
htmlString.append("<table class='tableAll' style='width:100%;'><tr><td>设备类型 <select id='" + listDeviceType + "' style='width: 133px;'></select>安装地点<input id='" + txtName + "' type='text' class='editTextbox' style='width: 100px;' /><input id='" + cmdGet + "' type='button' class='btnClass btnClassFind' value='查询' /></td></tr>");
|
|
htmlString.append("<tr><td><table border='0' cellpadding='0' cellspacing='0' >");
|
|
htmlString.append("<tr>");
|
|
htmlString.append("<td>未选择:</td>");
|
|
htmlString.append("<td></td>");
|
|
htmlString.append("<td>已选择:</td>");
|
|
htmlString.append("</tr>");
|
|
htmlString.append("<tr>");
|
|
htmlString.append(" <td><select id='" + listLeftPerson + "' multiple='multiple' style='width: 150px; height: 300px;'></select></td>");
|
|
htmlString.append("<td style='width:150px;' align='center' valign='middle' >");
|
|
htmlString.append("<a id='" + cmdPersonRight + "' href='#' class='easyui-linkbutton' iconcls='icon-next' plain='true'>右移</a>");
|
|
htmlString.append("<br /><br />");
|
|
htmlString.append("<a id='" + cmdPersonRightAll + "' href='#' class='easyui-linkbutton' iconcls='icon-next' plain='true'>全部右移</a>");
|
|
htmlString.append("<br /><br />");
|
|
htmlString.append("<a id='" + cmdPersonLeft + "' href='#' class='easyui-linkbutton' iconcls='icon-prev' plain='true'>左移</a>");
|
|
htmlString.append("<br /><br />");
|
|
htmlString.append("<a id='" + cmdPersonLeftAll + "' href='#' class='easyui-linkbutton' iconcls='icon-prev' plain='true'>全部左移</a>");
|
|
|
|
htmlString.append(" <td><select id='" + listRightPerson + "' multiple='multiple' style='width: 150px; height: 300px;'></select></td>");
|
|
htmlString.append("</tr></table></td></tr>");
|
|
//htmlString.append("<div style='height:10px;'></div>");
|
|
htmlString.append("<tr><td style='text-align: center'><input id='" + cmdSave + "' class='btnClass btnClassSave' type='button' value='确定' /></td></tr>");
|
|
htmlString.append("</div>");
|
|
My.ParentElement.append(htmlString.toString());
|
|
|
|
$("#" + My.ControlID, My.ParentElement).find("a").linkbutton();
|
|
|
|
|
|
}
|
|
//#endregion
|
|
//#region 显示
|
|
this.Show = function (ListModel) {
|
|
RightPerson = ListModel;
|
|
if (RightPerson == null) RightPerson = new Array();
|
|
//var html = new Sys.StringBuilder();
|
|
//html.append("<option value='1'>班级门口屏</option>");
|
|
//html.append("<option value='2'>办公室屏</option>");
|
|
//html.append("<option value='3'>电视机</option>");
|
|
//html.append("<option value='0'>其他</option>");
|
|
|
|
//$("#" + listDeviceType, My.ParentElement).html(html.toString());
|
|
RefshRightPerson();
|
|
$.fancybox({
|
|
'autoScale': false,
|
|
'transitionIn': 'elastic',
|
|
'transitionOut': 'elastic',
|
|
'href': '#' + My.ControlID,
|
|
'onStart': function () {
|
|
}
|
|
}, 0);
|
|
}
|
|
//#endregion
|
|
//#region 读取设备类型
|
|
function BindDeviceType() {
|
|
var param = new Object();
|
|
param.KeyName = "DeviceType";
|
|
$.ajax({
|
|
url: My.ApplicationPath + "UserService.asmx/GetListBaseCode",
|
|
data: Sys.Serialization.JavaScriptSerializer.serialize(param),
|
|
async: false,
|
|
success: function (data) {
|
|
var html = new Sys.StringBuilder();
|
|
//html.append("<option value='-1'>全部</option>");
|
|
$(data.d).each(function (i) {
|
|
html.append("<option value='" + this.ID + "'>" + this.Name + "</option>");
|
|
});
|
|
$('#' + listDeviceType).html(html.toString());
|
|
}
|
|
});
|
|
}
|
|
//#endregion
|
|
//#region 读取用户信息
|
|
function ReadUserInfo(Persons) {
|
|
var param = new Object();
|
|
param.DeviceType = $("#" + listDeviceType, My.ParentElement).val();
|
|
param.DeviceNos = Persons;
|
|
param.DeviceAddress = $("#" + txtName, My.ParentElement).val();
|
|
param.AppCode = My.AppCode;
|
|
var url = My.ApplicationPath + "UserService.asmx/GetListDevice";
|
|
if (My.IsCheckPopedom == true && My.IDType == "DeviceBo") {
|
|
url = My.ApplicationPath + "UserService.asmx/GetListUserDevice2";
|
|
//param.UserID = 0;
|
|
// param.TermID = 0;
|
|
}
|
|
else if (My.IsCheckPopedom == true && My.IDType == "DeviceId") {
|
|
url = My.ApplicationPath + "UserService.asmx/GetListUserDevice3";
|
|
//param.UserID = 0;
|
|
// param.TermID = 0;
|
|
}
|
|
$.ajax({
|
|
url: url,
|
|
data: Sys.Serialization.JavaScriptSerializer.serialize(param),
|
|
success: function (data) {
|
|
var html = new Sys.StringBuilder();
|
|
$(data.d).each(function (i) {
|
|
html.append("<option value='" + this.ID + "'>" + this.Name + "</option>");
|
|
});
|
|
$('#' + listLeftPerson, My.ParentElement).html(html.toString());
|
|
}
|
|
});
|
|
}
|
|
//#endregion
|
|
|
|
|
|
//#region 刷新已设置人员
|
|
function RefshRightPerson() {
|
|
var html = new Sys.StringBuilder();
|
|
var html2 = new Sys.StringBuilder();
|
|
$(RightPerson).each(function (i) {
|
|
html.append("<option value='" + this.ID + "'>" + this.Name + "</option>");
|
|
html2.append(this.ID + ",");
|
|
});
|
|
var Persons = html2.toString();
|
|
if (Persons != "") Persons = Persons.substr(0, Persons.length - 1);
|
|
$('#' + listRightPerson, My.ParentElement).html(html.toString());
|
|
ReadUserInfo(Persons);
|
|
}
|
|
//#endregion
|
|
|
|
|
|
//#region 点击确定时触发
|
|
this.Save = function (handler) {
|
|
EventHandler.addHandler('Save', handler);
|
|
}
|
|
//#endregion
|
|
//#region 点击确定时触发
|
|
function OnSave() {
|
|
var h = EventHandler.getHandler('Save');
|
|
if (h) h(RightPerson);
|
|
}
|
|
//#endregion
|
|
|
|
|
|
} |