var CMSFunction = {
ComboGrid: {
SetValue: function (source, text, value) {
var opts = $.data(source[0], "combogridX").options;
if (text == "") {
$(source).find('.combo-text').val(opts.emptyText);
} else {
$(source).find('.combo-text').val(text);
}
$(source).find('.combogridX-value').val(value);
$(source).attr("loaded", "true");
if ("undefined" != typeof EasyUIValidate) {
if (EasyUIValidate.Events.ComboGridXOnChange) {
EasyUIValidate.Events.ComboGridXOnChange.call(this);
}
}
if (opts.onChange) opts.onChange.call(source);
},
OnLoadSuccessFunction: function (source, tableData, callBack) {
var opts = $.data(source[0], "combogridX").options;
var callbackCalled = false;
var text = source.find(".combo-text").val();
if (text == '' || text == null) {
source.find('.combogridX-value').val("");
}
if (opts.value != '' && opts.value != -1 && $(source).attr("loaded") != "true") {
callbackCalled = true;
var dataGrid = source.find('.easyui-cmsXDataTable');
var formData;
if (opts.formData) {
formData = $.unpackFormParams(opts.formData.QueryParamsDatas);
} else {
formData = new Object();
}
formData.Attribute = "{ \"ID\":\"00000000-0000-0000-0000-000000000000\",\"Value\":\"" + opts.valueField
+ "\",\"ControlType\":\"TextBox\"}";
formData.Condition = "=";
formData[opts.valueField + "_QueryTextBox"] = opts.value;
var jsonString = "({'QueryParamsDatas':'" + $.packFormParams(formData) + "',page: 0,rows: 10 })";
// var jsonString = "({'QueryParamsDatas':'Attribute|*|{\"ID\":\"00000000-0000-0000-0000-000000000000\",\"Value\":\"" + opts.valueField
// + "\",\"ControlType\":\"TextBox\"}|@|Condition|*|=|@|ConditionValue|*|" + opts.value
// + "|@|" + opts.valueField + "_QueryTextBox|*|" + opts.value + "|@|',page: 0,rows: 10 })";
try {
var dataGridOptions = dataGrid.cmsXDataTable("options");
var url = dataGridOptions.url;
$.post(url, eval(jsonString), function (data) {
if (data.rows.length > 0) {
CMSFunction.ComboGrid.SetValue(source, data.rows[0][opts.textField], opts.value);
if (callBack) {
callBack.call(source, tableData);
}
}
});
}
catch (err) { }
}
var nowVal = source.find('.combogridX-value').val();
if (!(nowVal && nowVal != "") && opts.selectedIndex != null && $(source).attr("loaded") != "true") {
if (tableData.rows.length > opts.selectedIndex) {
CMSFunction.ComboGrid.SetValue(source, tableData.rows[opts.selectedIndex][opts.textField], tableData.rows[opts.selectedIndex][opts.valueField]);
}
}
//source.find(".combogridX-expander").width(source.find("table").width() + 16);
source.find('tr.row>td').css("cursor", "pointer");
source.find('tr.row').click(function () {
var comboGrid = $(this).parents('.easyui-combogridX:first');
var grid = $(this).parents('.easyui-cmsXDataTable:first');
var opts = $.data(comboGrid[0], "combogridX").options;
var gridOpts = $.data(grid[0], "cmsXDataTable").options;
var gridData = gridOpts.data;
var rowIndex = parseInt($(this).attr("xRowIndex"));
var rowData = gridData.rows[rowIndex];
CMSFunction.ComboGrid.SetValue(comboGrid, rowData[opts.textField], rowData[opts.valueField]);
if (opts.onSelect) opts.onSelect.call(this, rowData);
comboGrid.find(".combogridX-expander").css("display", "none");
});
var expander = source.find(".combogridX-expander");
// expander.css("width", "");
source.combogridX("setExpanderPosition", {
expander: expander, dropdown: source, arrow: source.find('.combo-arrow')
});
if (callBack && !callbackCalled) {
callBack.call(source, tableData);
}
}
},
Tree: {
setParentsChecked: function (jq, node, ischeck) {
var parent = jq.tree('getParent', node.target);
if (parent) {
if (parent.checked != ischeck) {
if (!parent.attributes) parent.attributes = new Object();
parent.attributes.isRecursionParent = true;
jq.tree('update',{ target: parent.target, attributes: parent.attributes });
if (ischeck) {
jq.tree('check', parent.target);
} else {
jq.tree('uncheck', parent.target);
}
}
//CMSFunction.Tree.setParentsChecked(jq, parent, ischeck);
}
},
setChildrenChecked: function (jq, node, checked) {
var childNodes = jq.tree('getChildren', node.target);
for (var i = 0; i < childNodes.length; i++) {
if (childNodes[i].checked != checked) {
if (!childNodes[i].attributes) childNodes[i].attributes = new Object();
childNodes[i].attributes.isRecursionChild = true;
jq.tree('update',{ target: childNodes[i].target, attributes: childNodes[i].attributes });
if (checked) jq.tree('check', childNodes[i].target);
else jq.tree('uncheck', childNodes[i].target);
}
}
},
OnBeforeCheck: function (node, checked) {
var treeView = $(this);
var opts = treeView.tree('options');
if (!node.attributes) node.attributes = new Object();
if (!opts.cascadeCheck) {
if (checked == node.checked) { return true; }
if (checked) {
if (!node.attributes.isRecursionChild) {
CMSFunction.Tree.setParentsChecked(treeView, node, checked);
}
}
if (!node.attributes.isRecursionParent) {
CMSFunction.Tree.setChildrenChecked(treeView, node, checked);
}
node.attributes.isRecursionParent = false;
node.attributes.isRecursionChild = false;
treeView.tree('update',{ target: node.target, attributes: node.attributes });
// else {
// //opts.cascadeCheck = false;
// var childNodes = treeView.tree('getChildren', node.target);
// for (var i = 0; i < childNodes.length; i++) {
// if (checked) treeView.tree('check', childNodes[i].target);
// else treeView.tree('uncheck', childNodes[i].target);
// }
// }
}
},
CheckBranch: function () {
var parentid = event.srcElement.id;
var myCheck = $(event.srcElement).attr("checked");
$(event.srcElement).find("input[id^='" + parentid + "']").each(function () {
if (!myCheck)
{ $(this).removeAttr("checked"); }
else
{ $(this).attr("checked", myCheck); }
});
},
OnClick: function (node) {
var tree = $(node.target).parents('.easyui-tree');
if (tree.tree('getChildren', node.target).length > 0) {
tree.tree('toggle', node.target);
}
}
},
DataTable: {
TriggerIndex: null,
TriggerData: null,
///
/// 本对象专门用于操作jQueryEasyUI框架的DataGrid
///
OnLoadSuccessFunction: function (data, callBack) {
var target = $(this);
var comboGrid = $(this).parents('.easyui-combogridX:first');
if (comboGrid.length > 0) {
CMSFunction.ComboGrid.OnLoadSuccessFunction(comboGrid, data, callBack);
} else {
if (callBack) {
callBack.call(this, data);
}
}
},
CorssRowsStylerFunction: function (value, row, index) {
if (index % 2 != 0) { //偶数行
return 'background-color:#DAEEE1;';
} else { //奇数行
}
},
ColumnFormatterFunction: function (value, row, index, formatType, formatString, customFormatFun, overflowlength) {
if (formatType == FormatType.None) {
if (!value && value != 0) {
value = "";
}
} else if (formatType == FormatType.DateTime) {
if (!value && value != 0) {
value = "";
}
else {
try{
value = value.toDateString(formatString);
}
catch(error){}
}
}
if (overflowlength > 3) {
value = value.toString().length <= overflowlength ? value : value.toString().substring(0, overflowlength - 3) + '...';
}
if (customFormatFun) {
return customFormatFun.call(this, index, row, value);
}
return value;
},
OperaterColumnFormatterFunction: function (value, row, index, buttonArrayString) {
var htmlString = " ";
buttonArrayString = buttonArrayString.replace(/\^\^/g, "\"");
var buttonArray = $.parseJSON(buttonArrayString);
for (var i = 0; i < buttonArray.length; i++) {
htmlString += buttonArray[i][i] + " ";
}
return htmlString;
},
LinkButtonColumnFormatterFunction: function (value, row, index, text, handleScript, formatType, formatString, overflowlength, emptyText) {
var content = (text ? text : (!value && value != 0 ? "" : value));
if(emptyText == undefined){
emptyText = "";
}
if (content.length == 0 && emptyText.length > 0) {
content = emptyText;
}
if (overflowlength > 3) {
content = content.length < overflowlength ? content : content.substring(0, overflowlength - 3) + '...';
}
var html = "" + content + " ";
return html;
},
GetRowData: function (table) {
///
/// 获取table中所有被选中的数据(最后返回的是数据是JSON格式的String类型数据)
/// jQuery对象,不传则默认为当前选项卡中的第一个DataGrid
///
var $table = null;
if (table == undefined || table == null) {
var $tabs = $('#index_center').tabs();
$table = $tabs.tabs('getSelected').find("div.easyui-cmsXDataTable").eq(0);
} else {
$table = $(table);
}
if ($table == null || $table == undefined) {
return ""
}
;
var rowsData = $table.cmsXDataTable('getSelections');
if (rowsData.length > 0) {
for (var i = 0; i < rowsData.length; i++) {
var data = rowsData[i];
data = BowinFunction.Untility.ConvertObjectDateFormat(data);
}
}
// return rowsData == null ? "" : rowsData.length > 1 ? JSON.stringify(rowsData) : "[" + JSON.stringify(rowsData) + "]";
return rowsData == null ? "" : JSON.stringify(rowsData);
},
GetCurrentRowData: function (obj) {
///
/// 获取ojb对象所在行的数据(最后返回的是数据是JSON格式的String类型数据)
///
var rowIndex = $(obj).closest('tr').attr("xRowIndex");
var rowDatas = $(obj).closest('.easyui-cmsXDataTable').cmsXDataTable("getRows");
var data = BowinFunction.Untility.ConvertObjectDateFormat(rowDatas[rowIndex]);
return "[" + JSON.stringify(data) + "]";
}
},
DataTableFormatter: {
TwoDigit: function (index, row, value) {
if (!value || isNaN(value)) {
if(value === 0)//判断是否为0
{
return value.toFixed(2).toString();
}
return "";
}
return value.toFixed(2).toString();
}
},
DragDrop: {
dragX: 0,
dragY: 0,
offsetX: 0,
offsetY: 0,
isInnerDrag: false,
curPopupContainerItem: null,
DropContainerItemClick: function (e) {
var x = e.x || e.layerX || 0;
var y = e.y || e.layerY || 0;
var containerID = $(e.srcElement).parent().parent().attr("id");
var menuID = containerID + "_menu";
CMSFunction.DragDrop.curPopupContainerItem = $(e.srcElement).parent();
$("#" + menuID).menu("show", { left: x, top: y });
},
DropFunc: function (e, source) {
if (CMSFunction.DragDrop.isInnerDrag != true) {
var newObj = $(source).clone();
var myLeft = e.currentTarget.clientLeft;
var myTop = e.currentTarget.clientTop;
var myWidth = e.currentTarget.clientWidth;
var myHeight = e.currentTarget.clientHeight;
var myObj = e.currentTarget;
var opts = $.data(this, "droppableContainer").options;
newObj.css('top', CMSFunction.DragDrop.dragY - CMSFunction.DragDrop.offsetY)
.css('position', 'absolute')
.css('left', CMSFunction.DragDrop.dragX - CMSFunction.DragDrop.offsetX);
newObj.find(".draggableTitle").css("color", opts.foreColor)
newObj.appendTo($(this));
newObj.draggable({
handle: '.draggableTitle',
onDrag: function (e) {
CMSFunction.DragDrop.dragX = e.clientX;
CMSFunction.DragDrop.dragY = e.clientY;
},
onBeforeDrag: function (e) {
CMSFunction.DragDrop.offsetX = e.offsetX + e.srcElement.offsetLeft;
CMSFunction.DragDrop.offsetY = e.offsetY + e.srcElement.offsetTop;
CMSFunction.DragDrop.isInnerDrag = true;
},
onStopDrag: function (e) {
if (e.clientX < myLeft || e.clientX > myLeft + myWidth || e.clientY < myTop || e.clientY > myTop + myHeight) {
$(e.srcElement).offsetParent().remove();
}
}
});
}
var hidden = $(e.currentTarget.nextSibling);
hidden.val('');
$.each($(e.currentTarget).find('.easyui-draggable'), function () {
var valStr = '';
if (hidden.val() != '') valStr = ',';
var titleDiv = $(this).find('.draggableTitle');
valStr += titleDiv.attr('value') + '|' + titleDiv.html() + '|' + $(this).css('left').replace("px", "") + '|' + $(this).css('top').replace("px", "");
hidden.val(hidden.val() + valStr);
});
}
}
};
//2013-05-31 begin added by pengbb 新增部门选择控件,由项目易系统开发提供
var departmentSelector = function (dataUrl, multipleChoice, handlers) {
var win;
var tree;
var pitchOnDataGrid;
var rightTopQuey;
var hasEasyUI = function (elementTypeName) {
if ($(elementTypeName).length > 0) {
return true;
} else {
return false;
}
}
//private 创建Html元素
var createElement = function (elementTypeName, elements, parentElments) {
$(elementTypeName).removeClass();
if (typeof parentElments != "undefined" && typeof elements == "string") {
var elementsObject = $(elements);
parentElments.append(elementsObject);
return elementsObject;
}
else {
if (typeof elements == "string")
return $(elements);
}
};
var createLinkButton = function (elements) {
var links = elements.find("a");
for (var i = 0; i < links.length; i++) {
$(links[i]).linkbutton();
}
};
var createTableString = function (name) {
var table = "
");
};
var registEvent = function (target, eventType, handler) {
target.unbind(eventType, handler);
target.bind(eventType, handler);
}
//private 选择部门
var selectWaitOrg = function (node) {
var selectUser;
if (multipleChoice) {
selectUser = tree.tree('getChecked');
} else {
var selectUser = new Array();
selectUser.push(node);
}
if (selectUser.length > 0) {
if (!multipleChoice && selectUser.length > 1) {
window.top.$.messager.alert("系统消息", "一次只能选择一个部门!");
}
else {
var dataSource = "{\"total\":".concat(selectUser.length, ",", "\"rows\":[");
for (var i = 0; i < selectUser.length; i++) {
dataSource = dataSource.concat('{"OrgID":', "\"", selectUser[i].id, "\",", '"DepartmentName":',
"\"", selectUser[i].text, "\"},"
);
}
dataSource = dataSource.substring(0, dataSource.length - 1);
dataSource = dataSource.concat("]}");
pitchOnDataGrid.datagrid("loadData", $.parseJSON(dataSource));
}
} else if (multipleChoice == false) {
window.top.$.messager.alert("系统消息", "未选择任何用户!");
}
};
var InitGridFile = function (dataGrid, pagination, url) {
return dataGrid.datagrid({
url: pagination ? url : "",
queryParams: pagination ? {
departmentID: DepartmentID,
userName: rightTopQuey.find("input[name='txtUserName']").val()
} : "",
pagination: pagination,
pageSize: 1,
pageList: [5, 10],
loadMsg: "请稍等....",
columns: [[
{ field: 'id', title: '', checkbox: true },
{ field: 'DepartmentName', title: '部门机构' }
]]
});
}
var loadDepartmentTree = function () {
var inputDepartment = leftQuery.find("input[name='txtDepartmentName']").val();
$.cmsPost("/Common/GetSelectUserControlDepartmentTree",
{ departmentID: "", departmentName: inputDepartment },
function (data) {
$(tree).tree('loadData', data);
});
}
var deleteSelectUser = function () {
var deleteSource = pitchOnDataGrid.datagrid("getChecked");
if (deleteSource.length > 0) {
for (var i = 0; i < deleteSource.length; i++) {
var rowIndex = pitchOnDataGrid.datagrid("getRowIndex", deleteSource[i]);
pitchOnDataGrid.datagrid("deleteRow", rowIndex);
if (multipleChoice) {
var node = tree.tree("find", deleteSource[i].OrgID);
tree.tree('uncheck', node.target);
}
}
} else {
window.top.$.messager.alert("系统消息", "未选中任何行!");
}
};
var close = function () {
var btnSelectOk = $((rightTopQuey.find("a"))[1]);
btnSelectOk.unbind();
btnSelectOk.bind("click", function () {
var selectUser = pitchOnDataGrid.datagrid("getData");
if (handlers instanceof Array) {
for (var i = 0; i < handlers.length; i++) {
handlers[i](selectUser);
}
} else if (typeof handlers != "undefined") {
handlers(selectUser);
}
if (typeof (pitchOnDataGrid.data("SelectedUser")) != "undefined") {
var catchData = pitchOnDataGrid.data("SelectedUser");
pitchOnDataGrid.removeData("SelectedUser");
}
win.window("close");
});
};
this.show = function () {
if (true) {
$("div[name='winOrgWarp']").remove();
var warpElement = "
";
//var warp = createElement(".selectOrg_warp", warpElement, win);
var warp = window.top.$(warpElement).appendTo(window.top.document.body);
win = warp.window({
width: 780,
height: 530,
modal: true,
maximizable: false,
title: '部门信息选择'
});
var elementLeft = createElement(".selectOrg_left",
"
", warp);
var elementRight = createElement(".selectOrg_right",
"
", warp);
var leftQueryTable = "");
leftQuery = createElement(".query", leftQueryTable, elementLeft);
createLinkButton(leftQuery);
var left_panel_warp = createElement("div[panel_postion='org_left']", "", elementLeft);
left_panel_warp.panel({
width: 350,
height: 450,
title: '部门信息',
closable: false,
collapsible: true,
minimizable: false,
maximizable: false
});
tree = $(left_panel_warp.find("ul[name='departmentTree']")[0]).tree({
url: dataUrl + "?departmentName=",
lines: true,
checkbox: multipleChoice,
onBeforeLoad: function (node, param) {
if (node == null) {
return true;
} else {
var children = $(this).tree("getChildren", node.target);
if (children == "") {
return true;
} else {
return false;
}
}
},
onClick: function (node) {
selectWaitOrg(node);
},
onCheck: function (node) {
selectWaitOrg();
}
});
var rightQuery = '删除 ';
rightQuery = rightQuery.concat(" 确定
");
rightTopQuey = createElement("p[pPostion='org_right_top']", rightQuery, elementRight);
createLinkButton(rightTopQuey);
var left_panel_warp = createElement("div[panel_postion='right_selectOrg']", "
", elementRight);
var pitchOnPanel = left_panel_warp.panel({
width: 380,
height: 450,
title: '已选部门',
closable: false,
collapsible: true,
minimizable: false,
maximizable: false
});
var pitchOnTable = createElement("table[name='pitchOnOrgDataGrid']", createTableString("pitchOnOrgDataGrid"), pitchOnPanel);
pitchOnDataGrid = (InitGridFile(pitchOnTable, false));
//查询部门树
registEvent(leftQuery.find("a:first"), "click", loadDepartmentTree);
//删除
registEvent($(rightTopQuey.find("a")[0]), "click", deleteSelectUser);
//确认
close(handlers);
} else {
$("div[name='winOrgWarp']").window('open');
}
}
};
//2013-05-31 end added by pengbb 新增部门选择控件,由项目易系统开发提供
//
var brandSelector = function (dataUrl, multipleChoice, triggerboxTarget, handlers) {
var win;
var tree;
var pitchOnDataGrid;
var rightTopQuey;
var hasEasyUI = function (elementTypeName) {
if ($(elementTypeName).length > 0) {
return true;
} else {
return false;
}
}
//private 创建Html元素
var createElement = function (elementTypeName, elements, parentElments) {
$(elementTypeName).removeClass();
if (typeof parentElments != "undefined" && typeof elements == "string") {
var elementsObject = $(elements);
parentElments.append(elementsObject);
return elementsObject;
}
else {
if (typeof elements == "string")
return $(elements);
}
};
var createLinkButton = function (elements) {
var links = elements.find("a");
for (var i = 0; i < links.length; i++) {
$(links[i]).linkbutton();
}
};
var createTableString = function (name) {
var table = "");
};
var registEvent = function (target, eventType, handler) {
target.unbind(eventType, handler);
target.bind(eventType, handler);
}
//private 选择品牌
var selectWaitOrg = function (node) {
var selectUser;
if (multipleChoice) {
selectUser = tree.tree('getChecked');
} else {
var selectUser = new Array();
selectUser.push(node);
}
var removeArray = new Array();
for (var i = 0; i < selectUser.length; i++) {
if (!selectUser[i].attributes.parentDepartmentID) {//查找根节点
removeArray.push(selectUser[i]);
}
else {
for (var x = 0; x < selectUser.length; x++) {
if (selectUser[i].attributes.parentDepartmentID == selectUser[x].id) {//查找父节点
removeArray.push(selectUser[x]);
}
}
}
}
for (var i = 0; i < removeArray.length; i++) { //移除选中项
for (var x = 0; x < selectUser.length; x++) {
if (removeArray[i].id == selectUser[x].id) {
selectUser.splice(x, 1);
break;
}
}
}
$(tree).data("Selections", selectUser);
};
this.show = function () {
if (true) {
$("div[name='winOrgWarp']").remove();
var warpElement = "
";
var warp = window.top.$(warpElement).appendTo(window.top.document.body);
var elementLeft = createElement(".selectOrg_left",
"
", warp);
var elementRight = createElement(".selectOrg_right",
"
", warp);
var left_panel_warp = createElement("div[panel_postion='org_left']", "", elementLeft);
tree = $(left_panel_warp.find("ul[name='departmentTree']")[0]).tree({
url: dataUrl + "?departmentName=",
lines: true,
checkbox: multipleChoice,
onBeforeLoad: function (node, param) {
if (node == null) {
return true;
} else {
var children = $(this).tree("getChildren", node.target);
if (children == "") {
return true;
} else {
return false;
}
}
},
onLoadSuccess: function (node, data) {
var checkedData = $(triggerboxTarget).triggerbox("getValue");
if (checkedData != "") {
var checkedArray = checkedData.split(';');
for (var i = 0; i < checkedArray.length; i++) {
var checkedNode = tree.tree("find", checkedArray[i]);
tree.tree("check", checkedNode.target);
}
}
},
onClick: function (node) {
selectWaitOrg(node);
},
onCheck: function (node) {
selectWaitOrg();
}
});
win = warp.dialog({
width: 400,
height: 600,
modal: true,
maximizable: false,
title: '品牌信息选择',
buttons:
[{
text: '确定',
handler: function () {
var result = $(tree).data("Selections") || new Array();
if (handlers instanceof Array) {
for (var i = 0; i < result.length; i++) {
handlers[i](result);
}
} else if (typeof handlers != "undefined") {
handlers(result);
}
warp.dialog("close");
}
},
{
text: '取消',
handler: function () {
warp.dialog("close");
}
}]
});
} else {
$("div[name='winOrgWarp']").dialog('open');
}
}
};
var brandSelectorHandlers = function (targe, node) {
var datas = [];
$.each(node, function () {
datas.push([{ 'text': this.text, 'value': this.id }][0]);
});
$(targe).triggerbox('setValue', datas);
};
//
//2013-05-29 begin added by pengbb 新增系统菜单控件
/*用法:定义一个div,指定class 为 easyui-cmsTree
data-options参数如下:
url:'/Common/GetCurrentUserMenuList'
onMenuClick:function(node){}
*/
(function ($) {
$.parser.plugins.push("cmsTree");
function _toggleChildMenu(currMenu) {
//$(currMenu).next('div').toggle();
if ($(currMenu).next('div').css("display") == "none") {
$(currMenu).siblings("div").slideUp("normal");
$(currMenu).next('div').slideDown("normal");
} else {
$(currMenu).next('div').slideUp("normal");
}
}
function _hideAllChildMenu(jq) {
$(jq).find('a+div').hide();
}
function _init(jq) {
var opts = $.data(jq, "cmsTree").options;
$(jq).addClass("menu_panel");
//$(jq).height(opts.height);
var defaultOpenMenu = null;
var newUrl = opts.url;
if (opts.loadingMessage) {
$(jq).html($("
").html(opts.loadingMessage));
}
$.post(newUrl, {}, function (responseJson) {
var rootPanel = jq;
var i = 0;
$.each(responseJson, function () {
var level1Menu = $("");
var level1MenuOption = this;
level1Menu.appendTo(rootPanel);
level1Menu.find("span").text(level1MenuOption.text);
level1Menu.find("span").addClass("menu_item_level1_title");
if (level1MenuOption.text != "系统首页" && level1MenuOption.text != "系统注销" && i == 0) {
i = 1;
defaultOpenMenu = level1Menu;
}
if (level1MenuOption.iconUrl) {
level1MenuOption.iconUrl = "url(" + level1MenuOption.iconUrl + ")";
level1Menu.find(">span").css({ backgroundPosition: "10px 6px", backgroundImage: level1MenuOption.iconUrl });
}
level1Menu.attr("title", level1MenuOption.text);
level1Menu.data("menuOption", level1MenuOption);
if (level1MenuOption.children.length > 0) {
var level2Panel = $("").appendTo(rootPanel);
$.each(level1MenuOption.children, function () {
var level2Menu = $("");
var level2MenuOption = this;
level2Menu.appendTo(level2Panel);
level2Menu.find("span").text(level2MenuOption.text);
level2Menu.find("span").addClass("menu_item_level2_title");
level2Menu.attr("title", level2MenuOption.text);
level2Menu.data("menuOption", level2MenuOption);
if (level2MenuOption.children.length > 0) {
//menu_item_level2_icon_opened
//menu_item_level2_icon_closed
level2Menu.addClass("menu_item_collapsable")
.find("span").css({ paddingLeft: "20px" }).addClass("menu_item_level2_icon_closed");
var levelLeafPanel = $("").appendTo(level2Panel);
$.each(level2MenuOption.children, function () {
var levelLeafMenu = $("");
var levelLeafMenuOption = this;
levelLeafMenu.appendTo(levelLeafPanel);
levelLeafMenu.find("span").text(levelLeafMenuOption.text);
levelLeafMenu.find("span").addClass("menu_item_leaf_title");
levelLeafMenu.find("span").addClass("menu_item_leaf_icon");
levelLeafMenu.find("span").css({ backgroundImage: levelLeafMenuOption.iconUrl });
levelLeafMenu.attr("title", levelLeafMenuOption.text);
levelLeafMenu.data("menuOption", levelLeafMenuOption);
});
}
});
}
_hideAllChildMenu(jq);
});
if (defaultOpenMenu) {
_toggleChildMenu(defaultOpenMenu);
}
// $(rootPanel).find("div.menu_item_panel").tinyscrollbar();
}, "json");
return { cmsTree: jq };
}
$.fn.cmsTree = function (_7be, _7bf) {
if (typeof _7be == "string") {
var _7c0 = $.fn.cmsTree.methods[_7be];
if (_7c0) {
return _7c0(this, _7bf);
} else {
return this.cmsTree(_7be, _7bf);
}
}
_7be = _7be || {};
return this.each(function () {
var _this = this;
var _jqThis = $(_this);
var cacheData = $.data(_this, "cmsTree");
if (cacheData) {
$.extend(cacheData.options, _7be);
} else {
cacheData = $.data(_this, "cmsTree", { options: $.extend({}, $.fn.cmsTree.defaults, $.fn.cmsTree.parseOptions(this), _7be) });
var initCacheData = _init(_this);
initCacheData.clickCallbacks = $.Callbacks();
cacheData = $.data(_this, "cmsTree", $.extend({}, cacheData, initCacheData));
_jqThis.find("a.menu_item").live("click", function (event) {
//alert($(this).attr("title"));
//alert(JSON.stringify($(this).data("menuOption")));
//menu_item_level2_icon_opened
//menu_item_level2_icon_closed
if ($(this).hasClass("menu_item_collapsable")) {
var span = $(this).find(">span");
if (span.hasClass("menu_item_level2_icon_closed")) {
span.removeClass("menu_item_level2_icon_closed");
span.addClass("menu_item_level2_icon_opened");
} else {
span.removeClass("menu_item_level2_icon_opened");
span.addClass("menu_item_level2_icon_closed");
}
$(this).siblings(".menu_item_collapsable").find(">span").removeClass("menu_item_level2_icon_opened").addClass("menu_item_level2_icon_closed");
}
var opts = _jqThis.data("cmsTree").options;
_toggleChildMenu(this);
var menuOption = $(this).data("menuOption");
if (opts.onMenuClick) {
opts.onMenuClick.call(_this, menuOption);
}
return false;
});
//_jqThis.find("div.menu_item_panel").tinyscrollbar({ axis: 'x', size: 20});
}
});
};
$.fn.cmsTree.methods = {
options: function (jq) {
var opts = $.data(jq[0], "cmsTree").options;
return opts;
}
};
$.fn.cmsTree.parseOptions = function (_7c7) {
var t = $(_7c7);
return $.extend({}, $.fn.cmsTree.defaults, $.parser.parseOptions(_7c7, []));
};
$.fn.cmsTree.defaults = {
url: '',
loadingMessage: '菜单正在加载中...',
onMenuClick: function () { } //,
//height: 700
};
})(jQuery);
//2013-05-29 end added by pengbb 新增系统菜单控件
//2013-05-21 begin added by pengbb 附件上传控件
/*用法:定义一个div,指定class 为 easyui-AttachmentUploader
data-options参数如下:
title: "附件列表",
canUpload: true, //是否可以上传
formData: {
ReferenceID: '',
ReferenceKeyName: 'CMS'
},
multi: true, //是否启用批量上传
fileSizeLimit: 0, // The maximum size of an uploadable file in KB (Accepts units B KB MB GB if string, 0 for no limit)
fileTypeDesc : 'Image Files', // The description for file types in the browse dialog
fileTypeExts : '*.gif; *.jpg; *.png', // Allowed extensions in the browse dialog (server-side validation should also be used)
buttonText: '上传附件',
buttonClass: '',
swf: '/Scripts/Plugins/Uploadify/uploadify.swf',
uploader: '/UploadFile.axd',
uploadSuccess: function (file, data, response) { },
uploadFailure: function (file, data, response) { }
*/
(function ($) {
$.parser.plugins.push("AttachmentUploader");
function s4() {
return Math.floor((1 + Math.random()) * 0x10000)
.toString(16)
.substring(1);
}
function guid() {
return s4() + s4() + '-' + s4() + '-' + s4() + '-' +
s4() + '-' + s4() + s4() + s4();
}
function _init(jq) {
var opts = $.data(jq, "AttachmentUploader").options;
var plAttachment = jq;
var jqThis = $(jq);
var dgAttachment = jqThis.find("div.upload_filelist>div");
var btnUpload = jqThis.find("div.upload_tool>input");
dgAttachment.cmsXDataTable();
return { AttachmentUploader: jq, btnUpload: btnUpload, dgAttachment: dgAttachment };
}
function _deleteAttachment(jq, id) {
var dgAttachment = $.data(jq, "AttachmentUploader").dgAttachment;
$.messager.confirm('系统提示', '确定要删除该附件吗?', function (r) {
if (r) {
var ops = {
URL: ("/" + CMS_SystemConfig.VirtualDirectoryPath + '/Common/RemoveAttachment/').replaceDoubleSlashesToSingle() + id,
Before: function (rows) {
},
CallBack: function (result) {
$.messager.alert('系统提示', '删除成功!', 'info', function () {
setTimeout(function () { dgAttachment.cmsXDataTable('load') }, 100);
});
}
}
BowinFunction.Request.AJAX(ops);
}
})
}
$.fn.AttachmentUploader = function (_7be, _7bf) {
if (typeof _7be == "string") {
var _7c0 = $.fn.AttachmentUploader.methods[_7be];
if (_7c0) {
return _7c0(this, _7bf);
} else {
return this.AttachmentUploader(_7be, _7bf);
}
}
_7be = _7be || {};
return this.each(function () {
var _this = this;
var cacheData = $.data(_this, "AttachmentUploader");
if (cacheData) {
$.extend(cacheData.options, _7be);
} else {
cacheData = $.data(_this, "AttachmentUploader", { options: $.extend({}, $.fn.AttachmentUploader.defaults, $.fn.AttachmentUploader.parseOptions(this), _7be) });
cacheData.options = $.extend({}, cacheData.options, {
onUploadSuccess: function (file, data, response) {
setTimeout(function () { dgAttachment.cmsXDataTable("load"); }, 100);
if (opts.uploadSuccess) {
opts.uploadSuccess.call(this, file, data, response);
}
},
onAllComplete: function (event, data) {
opts.onAllComplete.call(this, event, data);
},
onUploadError: function (file, data, response) {
if (opts.uploadFailure) {
opts.uploadFailure.call(this, file, data, response);
}
}
});
var initCacheData = _init(this);
cacheData = $.data(this, "AttachmentUploader", $.extend({}, cacheData, initCacheData));
}
var opts = cacheData.options;
var btnUpload = cacheData.btnUpload;
var dgAttachment = cacheData.dgAttachment;
if (opts.canUpload) {
btnUpload.show();
try {
btnUpload.uploadify("destroy");
} catch (ignore) { }
btnUpload.uploadify(opts);
} else {
btnUpload.hide();
}
});
};
$.fn.AttachmentUploader.deleteColumnFormatFun = function (index, row, value) {
if (row["IsOwn"]) {
return "删除 ";
} else {
return " ";
}
};
$.fn.AttachmentUploader.methods = {
options: function (jq) {
var opts = $.data(jq[0], "AttachmentUploader").options;
return opts;
},
getDatagrid: function (jq) {
var dgAttachment = $.data(jq[0], "AttachmentUploader").dgAttachment;
return dgAttachment;
},
deleteAttachment: function (jq, id) {
return _deleteAttachment(jq[0], id);
},
destroy: function (jq) {
var btnUpload = $.data(jq[0], "AttachmentUploader").btnUpload;
btnUpload.uploadify("destroy");
}
};
$.fn.AttachmentUploader.parseOptions = function (_7c7) {
var t = $(_7c7);
return $.extend({}, $.fn.AttachmentUploader.defaults, $.parser.parseOptions(_7c7, []));
};
$.fn.AttachmentUploader.defaults = {
title: "附件列表",
canUpload: true,
formData: {
ReferenceID: '',
ReferenceKeyName: 'CMS'
},
width: 70, // The width of the browse button
height: 26, // The height of the browse button
createUserID: "",
canDelete: true,
multi: true,
fileSizeLimit: 0, // The maximum size of an uploadable file in KB (Accepts units B KB MB GB if string, 0 for no limit)
fileTypeDesc: '所有文件', // The description for file types in the browse dialog
fileTypeExts: '*.*', // Allowed extensions in the browse dialog (server-side validation should also be used)
buttonText: '上传附件',
buttonClass: '',
swf: ('/' + CMS_SystemConfig.VirtualDirectoryPath + '/Scripts/Plugins/Uploadify/uploadify.swf').replaceDoubleSlashesToSingle(),
uploader: ('/' + CMS_SystemConfig.VirtualDirectoryPath + '/UploadFile.axd').replaceDoubleSlashesToSingle(),
uploadSuccess: function (file, data, response) {
},
uploadFailure: function (file, data, response) { },
onAllComplete: function (event, data) {
//$('.easyui-window').window('close');
}
};
})(jQuery);
//2013-05-21 end added by pengbb 附件上传控件
//2013-08-01 begin added by pengbb 新增弹窗上传控件
(function ($) {
$.parser.plugins.push("FileUploaderWindow");
function s4() {
return Math.floor((1 + Math.random()) * 0x10000)
.toString(16)
.substring(1);
}
function guid() {
return s4() + s4() + '-' + s4() + '-' + s4() + '-' +
s4() + '-' + s4() + s4() + s4();
}
function _init(jq) {
var opts = $.data(jq, "FileUploaderWindow").options;
var plAttachment = jq;
var jqThis = $(jq);
var win = jqThis.find(".FileUploaderWindowPanel");
var fileUploader = win.find(".easyui-AttachmentUploader");
//win.window();
return { FileUploaderWindow: jq, FileUploader: fileUploader, Window: win };
}
$.fn.FileUploaderWindow = function (_7be, _7bf) {
if (typeof _7be == "string") {
var _7c0 = $.fn.FileUploaderWindow.methods[_7be];
if (_7c0) {
return _7c0(this, _7bf);
} else {
return this.FileUploaderWindow(_7be, _7bf);
}
}
_7be = _7be || {};
return this.each(function () {
var _this = this;
var cacheData = $.data(_this, "FileUploaderWindow");
if (cacheData) {
$.extend(cacheData.options, _7be);
} else {
cacheData = $.data(_this, "FileUploaderWindow", { options: $.extend({}, $.fn.FileUploaderWindow.defaults, $.fn.FileUploaderWindow.parseOptions(this), _7be) });
var initCacheData = _init(this);
cacheData = $.data(this, "FileUploaderWindow", $.extend({}, cacheData, initCacheData));
}
});
};
$.fn.FileUploaderWindow.methods = {
options: function (jq) {
var opts = $.data(jq[0], "FileUploaderWindow").options;
return opts;
},
open: function (jq) {
var data = $.data(jq[0], "FileUploaderWindow");
var opts = data.options;
var win = data.Window;
var fileUploader = data.FileUploader;
fileUploader.AttachmentUploader(opts);
win.window().show().window("open");
},
close: function (jq) {
var data = $.data(jq[0], "FileUploaderWindow");
var opts = data.options;
var win = data.Window;
var fileUploader = data.FileUploader;
fileUploader.AttachmentUploader("destroy");
win.window("close");
}
};
$.fn.FileUploaderWindow.parseOptions = function (_7c7) {
var t = $(_7c7);
return $.extend({}, $.fn.FileUploaderWindow.defaults, $.parser.parseOptions(_7c7, []));
};
$.fn.FileUploaderWindow.defaults = $.extend({}, $.fn.AttachmentUploader.defaults, {
formData: {
ReferenceID: '',
ReferenceKeyName: 'TempFile'
}
});
})(jQuery);
//2013-08-01 end added by pengbb 新增弹窗上传控件
//2013-04-28 begin added by pengbb 新增triggerbox控件,用于用户选择和部门选择,号码规则选择
(function ($) {
$.parser.plugins.push("triggerbox");
function _init(jq) {
var widthCss = $(jq).width();
$(jq).addClass("triggerbox-f").hide();
var span = $(" ").insertAfter(jq);
var span_text = $(" ").appendTo(span);
var span_delete = $(" ").appendTo(span);
var span_search = $(" ").appendTo(span);
$(" ").appendTo(span);
var name = $(jq).attr("name");
if (name) {
span.find("input.triggerbox-value").attr("name", name);
$(jq).removeAttr("name").attr("triggerboxName", name);
}
span_text.attr("autocomplete", "off");
//span.css("width", widthCss);
span_text.width(widthCss - span_search.width() - span_delete.width() - 10);
//span_text.width(span.width() - span_search.width() - span_delete.width());
return { triggerbox: span };
}
function _setValue(jq, newData, isValidate) {
var opts = $.data(jq, "triggerbox").options;
var data = $.data(jq, "triggerbox").data;
var span = $.data(jq, "triggerbox").triggerbox;
data = newData;
var ss = [];
for (var i = 0; i < newData.length; i++) {
var s = newData[i][opts.valueField];
if (opts.formatter) {
s = opts.formatter.call(jq, newData[i]);
}
ss.push(s);
}
var oldTriggerboxValue = span.find("input.triggerbox-value").val();
span.find("input.triggerbox-text").val(ss.join(opts.separator));
span.find("input.triggerbox-value").val(JSON.stringify(newData));
var reg = "/" + opts.separator + "/g";
span.find("input.triggerbox-text").attr("title", ss.join(opts.separator).replace(eval(reg), "\r\n"));
if (opts.required && isValidate) {
//try{
var _769 = span.find("input.triggerbox-text");
_769.validatebox("validate");
// }catch(ignore){}
}
// if (ss.join(opts.separator).length > 0 && vv.join(opts.separator).length > 0) {
// span.find(".triggerbox-delete").css("visibility", "visible");
// } else {
// span.find(".triggerbox-delete").css("visibility", "hidden");
// }
$.data(jq, "triggerbox", { options: opts, data: data, triggerbox: span });
if (oldTriggerboxValue != span.find("input.triggerbox-value").val()) {
var changeFn = opts.change || function () { };
if (typeof (changeFn) == "function") {
changeFn.call(jq);
}
}
}
function _initValidate(_768, doit) {
var opts = $.data(_768, "triggerbox").options;
var _769 = $.data(_768, "triggerbox").triggerbox.find("input.triggerbox-text");
_769.validatebox(opts);
$(_768).removeClass("easyui-validatebox validatebox-text");
if (doit) {
_769.validatebox("validate");
}
};
$.fn.triggerbox = function (_7be, _7bf) {
if (typeof _7be == "string") {
var _7c0 = $.fn.triggerbox.methods[_7be];
if (_7c0) {
return _7c0(this, _7bf);
} else {
return this.triggerbox(_7be, _7bf);
}
}
_7be = _7be || {};
return this.each(function () {
var _this = this;
var triggerboxData = $.data(this, "triggerbox");
if (triggerboxData) {
$.extend(triggerboxData.options, _7be);
} else {
triggerboxData = $.data(this, "triggerbox", { options: $.extend({}, $.fn.triggerbox.defaults, $.fn.triggerbox.parseOptions(this), _7be) });
var initTriggerboxData = _init(this);
triggerboxData = $.data(this, "triggerbox", $.extend({}, triggerboxData, initTriggerboxData));
}
if (triggerboxData.options.data) {
_setValue(this, triggerboxData.options.data, false);
}
triggerboxData.triggerbox.find(".triggerbox-search").unbind(".triggerbox");
triggerboxData.triggerbox.find(".triggerbox-delete").unbind(".triggerbox");
//注册事件
triggerboxData.triggerbox.find(".triggerbox-search").bind("mouseenter.triggerbox", function () {
$(this).addClass("triggerbox-search-hover");
}).bind("mouseleave.triggerbox", function () {
$(this).removeClass("triggerbox-search-hover");
}).bind("mousedown.triggerbox", function () {
if (triggerboxData.options.editable) {
//查询点击事件
if (triggerboxData.options.onSearch) {
triggerboxData.options.onSearch.call(_this);
}
}
});
triggerboxData.triggerbox.find(".triggerbox-search").bind("mouseenter.triggerbox", function () {
$(this).addClass("triggerbox-search-hover");
}).bind("mouseleave.triggerbox", function () {
$(this).removeClass("triggerbox-search-hover");
}).bind("mousedown.triggerbox", function () {
if (triggerboxData.options.editable) {
//查询点击事件
if (triggerboxData.options.onSearchClick) {
triggerboxData.options.onSearchClick.call(_this);
}
}
});
triggerboxData.triggerbox.find(".triggerbox-delete").bind("mouseenter.triggerbox", function () {
$(this).addClass("triggerbox-delete-hover");
}).bind("mouseleave.triggerbox", function () {
$(this).removeClass("triggerbox-delete-hover");
}).bind("mousedown.triggerbox", function () {
if (triggerboxData.options.editable) {
$.fn.triggerbox.methods["clear"]($(_this));
//$(this).css("visibility", "hidden");
}
});
_initValidate(_this, true);
});
};
$.fn.triggerbox.methods = {
options: function (jq) {
var opts = $.data(jq[0], "triggerbox").options;
return opts;
},
getData: function (jq) {
return $.data(jq[0], "triggerbox").data;
},
setValue: function (jq, newData) {
jq.each(function () {
_setValue(this, newData, true);
});
},
getValue: function (jq) {
return eval($.data(jq[0], "triggerbox").triggerbox.find("input.triggerbox-value").val());
},
clear: function (jq) {
jq.each(function () {
var opts = $(this).triggerbox("options");
opts.data = [];
$(this).triggerbox("setValue", opts.data);
});
}
};
$.fn.triggerbox.parseOptions = function (_7c7) {
var t = $(_7c7);
return $.extend({}, $.extend({}, $.fn.triggerbox.defaults, $.parser.parseOptions(_7c7, ["valueField", "textField"])), $.fn.validatebox.parseOptions(_7c7));
};
$.fn.triggerbox.defaults = $.extend({},
$.fn.validatebox.defaults, {
valueField: "value",
textField: "text",
separator: ",",
editable: true,
postData: {},
change: function () { },
formatter: function (row) {
var opts = $(this).triggerbox("options");
return row[opts.textField];
}
}
);
})(jQuery);
//2013-04-28 end added by pengbb 新增triggerbox控件,用于用户选择和部门选择,号码规则选择
//2013-05-03 begin added by pengbb 新增号码规则选择控件
function TelNumberRuleSelector(config) {
var defaultConfig = { onSelect: null, width: 600, height: 400, postData: {} };
config = $.extend({}, defaultConfig, config);
var newUrl = "/Common/GetTelNumberRuleListForSelector";
newUrl = ("/" + CMS_SystemConfig.VirtualDirectoryPath + newUrl).replaceDoubleSlashesToSingle();
var jqPanel = $("
").appendTo(document.body);
var jqPanelLayout = $('').appendTo(jqPanel);
var jqPanelLayoutCenter = jqPanelLayout.find("div.layout-panel-center>div.layout-body");
var jqPanelLayoutCenterContent = $('
').appendTo(jqPanelLayoutCenter);
var jqPanelLayoutSouth = jqPanelLayout.find("div.layout-panel-south>div.layout-body");
var btnYes = $("确定 ").appendTo(jqPanelLayoutSouth);
var btnNo = $("取消 ").appendTo(jqPanelLayoutSouth);
if (config.width) {
jqPanel.width(config.width);
}
if (config.height) {
jqPanel.height(config.height);
}
jqPanel.window();
btnYes.linkbutton();
btnNo.linkbutton();
var isIE6 = false;
if ($.browser.msie) {
if ($.browser.version < 7) {
isIE6 = true;
}
}
var centerContentConfig = {
url: newUrl,
postData: config.postData,
onLoaded: function () {
jqPanelLayoutCenterContent.find("div.cmspanel>div.panel-header>div.panel-tool>a.cmspanel-tool-collapse").click(function () {
var _this = $(this);
if (_this.hasClass("panel-tool-expand")) {
_this.removeClass("panel-tool-expand");
if (isIE6) {
_this.closest("div.cmspanel").find("div.panel-body").show();
} else {
_this.closest("div.cmspanel").find("div.panel-body").slideDown();
}
} else {
_this.addClass("panel-tool-expand");
if (isIE6) {
_this.closest("div.cmspanel").find("div.panel-body").hide();
} else {
_this.closest("div.cmspanel").find("div.panel-body").slideUp();
}
}
});
}
};
jqPanelLayoutCenterContent.cmsLoadHtml(centerContentConfig);
var eventManager = { onSelect: [] };
var _select = function (fn) {
eventManager["onSelect"].push(fn);
}
if (config.onSelect) {
eventManager["onSelect"].push(config.onSelect);
}
btnYes.unbind(".SelectTelNumberRule");
btnNo.unbind(".SelectTelNumberRule");
btnYes.bind("click.SelectTelNumberRule", function () {
var selectDatas = [];
$(jqPanel).find("input[type=checkbox]:checked").each(function () {
selectDatas.push({ text: $(this).attr("text"), value: $(this).val() });
});
_postEvent(selectDatas);
_hide();
});
btnNo.bind("click.SelectTelNumberRule", function () {
_hide();
});
var _show = function () {
jqPanel.window('open');
};
var _hide = function () {
jqPanel.window('close');
};
var _postEvent = function (p) {
$.each(eventManager["onSelect"], function () {
this.call(_this, p);
});
}
var _this = { jq: jqPanel, show: _show, hide: _hide, select: _select };
return _this;
}
//2013-05-03 end added by pengbb新增号码规则选择控件
var SelectUserContorl = function (departmentID, multipleChoice, handlers) {
var groups = {};
var DepartmentID = departmentID;
var MultipleChoice = multipleChoice;
var waitDataGrid;
var pitchOnDataGrid;
var rightTopQuey;
var tree;
var win;
var leftQuery;
//private 创建Html元素
var createElement = function (elementTypeName, elements, parentElments) {
$(elementTypeName).removeClass();
if (typeof parentElments != "undefined" && typeof elements == "string") {
var elementsObject = $(elements);
parentElments.append(elementsObject);
return elementsObject;
} else {
if (typeof elements == "string")
return $(elements);
}
};
var createTableString = function (name) {
var table = "");
};
var InitGridFile = function (dataGrid, pagination, url) {
return dataGrid.datagrid({
url: pagination ? url : "",
queryParams: pagination ? {
departmentID: DepartmentID,
userName: rightTopQuey.find("input[name='txtUserName']").val()
} : "",
pagination: pagination,
pageSize: 1,
pageList: [5, 10],
loadMsg: "请稍等....",
columns: [[
{ field: 'UserID', title: 'UserID', checkbox: true },
{ field: 'DepartmentName', title: '部门机构' },
{ field: 'LoginName', title: '登录名' },
{ field: 'UserName', title: '用户名' }
]]
});
}
//private 选择用户
var selectWaitUser = function () {
var selectUser = waitDataGrid.datagrid("getChecked");
if (selectUser.length > 0) {
if (!multipleChoice && selectUser.length > 1) {
$.messager.alert("系统消息", "一次只能选择一个用户!");
} else {
var dataSource = "{\"total\":".concat(selectUser.length, ",", "\"rows\":[");
for (var i = 0; i < selectUser.length; i++) {
dataSource = dataSource.concat('{"UserID":', "\"", selectUser[i].UserID, "\",", '"DepartmentName":',
"\"", selectUser[i].DepartmentName, "\",\"LoginID\":\"", selectUser[i].LoginName, "\",\"UserName\":\"",
selectUser[i].UserName, "\"},"
);
}
dataSource = dataSource.substring(0, dataSource.length - 1);
dataSource = dataSource.concat("]}");
var currentData = $.parseJSON(dataSource);
currentData.rows = currentData.rows.sort(function (a, b) {
return a > b;
});
if (typeof (pitchOnDataGrid.data("SelectedUser")) != "undefined") {
//先拿缓存数据
var cachData = pitchOnDataGrid.data("SelectedUser");
for (var i = 0; i < cachData.rows.length; i++) {
for (var j = 0; j < currentData.rows.length; j++) {
if (cachData.rows[i].UserID == currentData.rows[j].UserID) {
currentData.rows.splice(j, 1);
}
}
}
cachData.rows = $.merge(currentData.rows, cachData.rows);
pitchOnDataGrid.data("SelectedUser", cachData);
} else {
pitchOnDataGrid.data("SelectedUser", currentData);
}
pitchOnDataGrid.datagrid("loadData", pitchOnDataGrid.data("SelectedUser"));
}
} else {
$.messager.alert("系统消息", "未选择任何用户!");
}
};
var registEvent = function (target, eventType, handler) {
target.unbind(eventType, handler);
target.bind(eventType, handler);
}
var close = function () {
var btnSelectOk = $((rightTopQuey.find("a"))[1]);
btnSelectOk.unbind();
btnSelectOk.bind("click", function () {
var selectUser = pitchOnDataGrid.datagrid("getData");
if (handlers instanceof Array) {
for (var i = 0; i < handlers.length; i++) {
handlers[i](selectUser);
}
} else if (typeof handlers != "undefined") {
handlers(selectUser);
}
win.window("close");
});
};
var hasEasyUI = function (elementTypeName) {
if ($(elementTypeName).length > 0) {
return true;
} else {
return false;
}
}
var createLinkButton = function (elements) {
var links = elements.find("a");
for (var i = 0; i < links.length; i++) {
$(links[i]).linkbutton();
}
};
var getUserInfo = function () {
waitDataGrid.datagrid('load', {
departmentID: DepartmentID,
userName: rightTopQuey.find("input[name='txtUserName']").val()
}
);
}
var deleteSelectUser = function () {
var deleteSource = pitchOnDataGrid.datagrid("getChecked");
if (deleteSource.length > 0) {
for (var i = 0; i < deleteSource.length; i++) {
var rowIndex = pitchOnDataGrid.datagrid("getRowIndex", deleteSource[i]);
pitchOnDataGrid.datagrid("deleteRow", rowIndex);
}
}
//else {
// $.messager.alert("系统消息", "未选中任何行!");
// }
};
var loadDepartmentTree = function () {
var inputDepartment = leftQuery.find("input[name='txtDepartmentName']").val();
$.cmsPost("/Common/GetSelectUserControlDepartmentTree",
{ departmentID: "", departmentName: inputDepartment },
function (data) {
$(tree).tree('loadData', data);
});
}
var show = function () {
if (!hasEasyUI("div[name='winWarp']")) {
var warpElement = "
";
var warp = createElement(".selectUser_warp", warpElement, win);
win = warp.window({
width: 760,
height: 500,
modal: true,
maximizable: false,
title: '用户信息选择'
});
var elementLeft = createElement(".selectUser_left",
"
", warp);
var elementRight = createElement(".selectUser_right",
"
", warp);
var leftQueryTable = "");
leftQuery = createElement(".query", leftQueryTable, elementLeft);
createLinkButton(leftQuery);
var left_panel_warp = createElement("div[panel_postion='left']", "", elementLeft);
left_panel_warp.panel({
width: 350,
height: 450,
title: '部门信息',
closable: false,
collapsible: true,
minimizable: false,
maximizable: false
});
var departmentName = leftQuery.find("input[name='txtDepartmentName']").val();
tree = $(left_panel_warp.find("ul[name='departmentTree']")[0]).tree({
url: ("/" + CMS_SystemConfig.VirtualDirectoryPath + ("/Common/GetSelectUserControlDepartmentTree?departmentName=" + departmentName).replace(CMS_SystemConfig.VirtualDirectoryPath, "")).replaceDoubleSlashesToSingle(),
lines: true,
onBeforeLoad: function (node, param) {
if (node == null) {
return true;
} else {
var children = $(this).tree("getChildren", node.target);
if (children == "") {
return true;
} else {
return false;
}
}
},
onClick: function (node) {
DepartmentID = eval(node).id;
getUserInfo();
}
});
var rightQuery = '帐号/用户名: 查询 ';
rightQuery = rightQuery.concat(" 确定
");
rightTopQuey = createElement("p[pPostion='right_top']", rightQuery, elementRight);
createLinkButton(rightTopQuey);
var rightWaitChoise_paneDiv = createElement("div[panel_postion='right_middel']", "
", elementRight);
var waitChoisePanel = rightWaitChoise_paneDiv.panel({
width: 380,
title: '待选用户',
closable: false,
collapsible: true,
minimizable: false,
maximizable: false
});
var selectAndDeteButtonStr = "选择 删除
";
var selectAndDeteButton = createElement("p[pPostion='right_bottom']", selectAndDeteButtonStr, elementRight);
createLinkButton(selectAndDeteButton);
var left_panel_warp = createElement("div[panel_postion='right_selectUser']", "
", elementRight);
var pitchOnPanel = left_panel_warp.panel({
width: 380,
height: 150,
title: '已选用户',
closable: false,
collapsible: true,
minimizable: false,
maximizable: false
});
var waitTable = createElement("table[name='waitDataGrid']", createTableString("waitDataGrid"), waitChoisePanel);
var pitchOnTable = createElement("table[name='pitchOnDataGrid']", createTableString("pitchOnDataGrid"), pitchOnPanel);
waitDataGrid = InitGridFile(waitTable, true, ("/" + CMS_SystemConfig.VirtualDirectoryPath + ("/Common/GetSelectUserContorlViewPageList").replace(CMS_SystemConfig.VirtualDirectoryPath, "")).replaceDoubleSlashesToSingle());
pitchOnDataGrid = (InitGridFile(pitchOnTable, false));
//查询部门树
registEvent(leftQuery.find("a:first"), "click", loadDepartmentTree);
//选择用户
registEvent(selectAndDeteButton.find("a:first"), "click", selectWaitUser);
//删除用户
registEvent($(selectAndDeteButton.find("a")[1]), "click", deleteSelectUser);
//关闭
registEvent(rightTopQuey.find("a:first"), "click", getUserInfo);
close(handlers);
} else {
$("div[name='winWarp']").window('open');
}
};
return { "show": show };
};
$.extend($.fn.validatebox.defaults.rules, {
baseRequired: {
validator: function (value, param) {
return value && value != "";
},
message: '必填'
},
dropdownListRequired: {
validator: function (value, param) {
return value != "" && value != "-1" && value != "全部" && value != "请选择";
},
message: '必选'
},
mobile: {
validator: function (value, param) {
return (/^1\d{10}$/gi).test(value);
},
message: '手机号码格式不对'
},
telnumber: {
validator: function (value, param) {
return (/((\d{11})|^((\d{7,8})|(\d{4}|\d{3})-(\d{7,8})|(\d{4}|\d{3})-(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1})|(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1}))$)/gi).test(value);
},
message: '号码格式不对'
},
IDCard: {
validator: function (value, param) {
var idcard = value; //身份证号码
var Errors = new Array(
"验证通过!OK",
"身份证号码位数不对!",
"身份证号码出生日期超出范围或含有非法字符!",
"身份证号码校验错误!",
"身份证地区非法!"
);
var area = { 11: "北京", 12: "天津", 13: "河北", 14: "山西", 15: "内蒙古", 21: "辽宁", 22: "吉林", 23: "黑龙江", 31: "上海", 32: "江苏", 33: "浙江", 34: "安徽", 35: "福建", 36: "江西", 37: "山东", 41: "河南", 42: "湖北", 43: "湖南", 44: "广东", 45: "广西", 46: "海南", 50: "重庆", 51: "四川", 52: "贵州", 53: "云南", 54: "西藏", 61: "陕西", 62: "甘肃", 63: "青海", 64: "宁夏", 65: "新疆", 71: "台湾", 81: "香港", 82: "澳门", 91: "国外" };
var idcard, Y, JYM;
var S, M;
var idcard_array = new Array();
idcard_array = idcard.split("");
//地区检验
if (area[parseInt(idcard.substr(0, 2))] == null) {
this.message = Errors[4];
return false;
}
//身份号码位数及格式检验
switch (idcard.length) {
case 15:
if ((parseInt(idcard.substr(6, 2)) + 1900) % 4 == 0 || ((parseInt(idcard.substr(6, 2)) + 1900) % 100 == 0 && (parseInt(idcard.substr(6, 2)) + 1900) % 4 == 0)) {
ereg = /^[1-9][0-9]{5}[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|[1-2][0-9]))[0-9]{3}$/; //测试出生日期的合法性
} else {
ereg = /^[1-9][0-9]{5}[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|1[0-9]|2[0-8]))[0-9]{3}$/; //测试出生日期的合法性
}
if (ereg.test(idcard)) return true;
else {
this.message = Errors[2];
return false;
}
break;
case 18:
//18位身份号码检测
//出生日期的合法性检查
//闰年月日:((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|[1-2][0-9]))
//平年月日:((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|1[0-9]|2[0-8]))
if (parseInt(idcard.substr(6, 4)) % 4 == 0 || (parseInt(idcard.substr(6, 4)) % 100 == 0 && parseInt(idcard.substr(6, 4)) % 4 == 0)) {
ereg = /^[1-9][0-9]{5}(19|20)[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|[1-2][0-9]))[0-9]{3}[0-9Xx]$/; //闰年出生日期的合法性正则表达式
} else {
ereg = /^[1-9][0-9]{5}(19|20)[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|1[0-9]|2[0-8]))[0-9]{3}[0-9Xx]$/; //平年出生日期的合法性正则表达式
}
if (ereg.test(idcard)) {//测试出生日期的合法性
//计算校验位
S = (parseInt(idcard_array[0]) + parseInt(idcard_array[10])) * 7
+ (parseInt(idcard_array[1]) + parseInt(idcard_array[11])) * 9
+ (parseInt(idcard_array[2]) + parseInt(idcard_array[12])) * 10
+ (parseInt(idcard_array[3]) + parseInt(idcard_array[13])) * 5
+ (parseInt(idcard_array[4]) + parseInt(idcard_array[14])) * 8
+ (parseInt(idcard_array[5]) + parseInt(idcard_array[15])) * 4
+ (parseInt(idcard_array[6]) + parseInt(idcard_array[16])) * 2
+ parseInt(idcard_array[7]) * 1
+ parseInt(idcard_array[8]) * 6
+ parseInt(idcard_array[9]) * 3;
Y = S % 11;
M = "F";
JYM = "10X98765432";
M = JYM.substr(Y, 1); //判断校验位
if (M == idcard_array[17]) return true; //检测ID的校验位
else {
this.message = Errors[3];
return false;
};
}
else {
this.message = Errors[2];
return false;
};
break;
default:
this.message = Errors[1];
return false;
break;
}
},
message: '证件号码格式不对'
},
filterWord: {
validator: function (value, param) {
var returnValue = true;
$(param[0]).each(function (i, item) {
if (item == value) {
returnValue = false;
return false;
}
});
return returnValue;
},
message: '敏感字过滤'
},
onlyNumber: {
validator: function (value, param) {
return (/^[0-9]\d*$/gi).test(value);
},
message: '仅允许输入数字'
},
onlyDiscount: {
validator: function (value, param) {
//^0\.[0-9]{1,2}$
return (/^(?:0(?:\.(?!00)[0-9]{1,2})?|1)$/gi).test(value);
// return (/^[1-9]([.]{1}[1-9])?$/gi).test(value);
},
message: '仅允许输入带二位小数的有效数字'
},
onlyChar: {
validator: function (value, param) {
return (/^[A-Za-z0-9]+$/gi).test(value);
},
message: '仅允许输入英文及数字'
},
onlyMoney: {
validator: function (value, param) {
return (/^-?\d+(\.\d{1,2})?$/gi).test(value);
},
message: '仅允许输入保留二位有效数字'
}
});
$.extend($.fn.validatebox.methods, {
remove: function (jq, newposition) {
return jq.each(function () {
$(this).removeClass("validatebox-text validatebox-invalid").unbind('focus.validatebox').unbind('blur.validatebox');
});
},
reduce: function (jq, newposition) {
return jq.each(function () {
var opt = $(this).data().validatebox.options;
$(this).addClass("validatebox-text").validatebox(opt);
});
}
});
$.extend($.fn.validatebox.methods, {
removeForCombobox: function (jq, newposition) {
return jq.each(function () {
var comboxText = $(this).next().find("input").first();
comboxText.removeClass("validatebox-text validatebox-invalid").unbind('focus.validatebox').unbind('blur.validatebox');
});
},
reduceForCombobox: function (jq, newposition) {
return jq.each(function () {
var comboxText = $(this).next().find("input").first();
var opt = comboxText.data().validatebox.options;
comboxText.addClass("validatebox-text").validatebox(opt);
});
}
});
//2013-12-05 begin added by pengbb 新增ajax加载html内容控件
/*用法:定义一个div,指定class 为 easyui-cmsLoadHtml
data-options参数如下:
url:'/Common/GetHtmlContent',
loadingMessage:'正在加载中...',
postData : {}
*/
(function ($) {
$.parser.plugins.push("cmsLoadHtml");
function _init(jq) {
var opts = $.data(jq, "cmsLoadHtml").options;
return { cmsLoadHtml: jq };
}
function _load(jq) {
var opts = $.data(jq, "cmsLoadHtml").options;
if (opts.url && opts.url != "") {
if (opts.loadingMessage) {
//loadPanel.prependTo(jq);
var loadPanel = $("
").prependTo(jq);
$("
").appendTo(jq);
$("
").appendTo(loadPanel);
var msg = $("
").html(opts.loadingMessage).appendTo(loadPanel);
msg.css("marginLeft", -msg.outerWidth() / 2);
}
setTimeout(function () {
$.ajax({
url: opts.url,
data: $.extend({}, {}, opts.postData),
cache: false,
dataType: "html",
success: function (data) {
$(jq).html(opts.extractor.call(jq, data));
if (typeof (opts.onLoaded) == "function") {
opts.onLoaded.call(jq);
}
}
});
}, opts.delay);
}
};
$.fn.cmsLoadHtml = function (_7be, _7bf) {
if (typeof _7be == "string") {
var _7c0 = $.fn.cmsLoadHtml.methods[_7be];
if (_7c0) {
return _7c0(this, _7bf);
} else {
return this.cmsLoadHtml(_7be, _7bf);
}
}
_7be = _7be || {};
return this.each(function () {
var _this = this;
var _jqThis = $(_this);
var cacheData = $.data(_this, "cmsLoadHtml");
if (cacheData) {
$.extend(cacheData.options, _7be);
} else {
cacheData = $.data(_this, "cmsLoadHtml", { options: $.extend({}, $.fn.cmsLoadHtml.defaults, $.fn.cmsLoadHtml.parseOptions(this), _7be) });
var initCacheData = _init(_this);
cacheData = $.data(_this, "cmsLoadHtml", $.extend({}, cacheData, initCacheData));
}
_load(_this);
});
};
$.fn.cmsLoadHtml.methods = {
options: function (jq) {
var opts = $.data(jq[0], "cmsLoadHtml").options;
return opts;
},
reload: function (jq) {
_load(jq[0]);
}
};
$.fn.cmsLoadHtml.parseOptions = function (_7c7) {
var t = $(_7c7);
return $.extend({}, $.fn.cmsLoadHtml.defaults, $.parser.parseOptions(_7c7, []));
};
$.fn.cmsLoadHtml.defaults = {
url: '',
delay: 0,
loadingMessage: '正在加载中...',
postData: {},
onLoaded: function () { },
extractor: function (data) {
var _1ef = /]*>((.|[\n\r])*)<\/body>/im;
var _1f0 = _1ef.exec(data);
if (_1f0) {
return _1f0[1];
} else {
return data;
}
}
};
})(jQuery);
//2013-12-05 end added by pengbb 新增ajax加载html内容控件
//2013-12-10 begin added by pengbb 新增下一步审批人控件
/*用法:定义一个div,指定class 为 easyui-cmsNextApproverSelector
data-options参数如下:
url:'/Common/GetHtmlContent',
loadingMessage:'正在加载中...',
postData : {}
*/
(function ($) {
$.parser.plugins.push("cmsNextApproverSelector");
function _init(jq) {
var opts = $.data(jq, "cmsNextApproverSelector").options;
var approverCombobox = $(" ").attr("name", opts.name).appendTo(jq);
var workPositionLabel = $(" ").appendTo(jq);
return { cmsNextApproverSelector: jq, approverCombobox: approverCombobox, workPositionLabel: workPositionLabel };
}
function _load(jq) {
var opts = $.data(jq, "cmsNextApproverSelector").options;
var approverCombobox = $.data(jq, "cmsNextApproverSelector").approverCombobox;
var workPositionLabel = $.data(jq, "cmsNextApproverSelector").workPositionLabel;
var loadingMessage = opts.loadingMessage || "系统正在加载下一步审批人中,请稍候...";
var approverComboboxDefaultOptions = {
multiple: false,
panelHeight: 'auto',
onSelect: function (record) {
workPositionLabel.text(record.data[0].label);
if (typeof (opts.onSelect) == "function") {
opts.onSelect.call(jq);
}
},
onLoadSuccess: function () {
if (opts.showProgress) {
//$.messager.progress('close');
$.cmsLoading.hide();
}
if (approverCombobox.combobox("options").firstLoad) return;
var getData = approverCombobox.combobox("getData");
if (getData.length > 0) {
if (getData[0].data[0].label == "结束") {
approverCombobox.combobox("select", getData[0].id);
workPositionLabel.text(getData[0].data[0].label);
approverCombobox.combobox('disable');
} else {
approverCombobox.combobox('setValues', ['请选择']);
}
}
if (typeof (opts.onLoadSuccess) == "function") {
opts.onLoadSuccess.call(jq);
}
},
onLoadError: function () {
if (opts.showProgress) {
//$.messager.progress('close');
$.cmsLoading.hide();
}
//if (approverCombobox.combobox("options").firstLoad) return;
if (typeof (opts.onLoadError) == "function") {
opts.onLoadError.call(jq);
}
},
//firstLoad: true,
onBeforeLoad: function (param) {
//alert(approverCombobox.combobox("options").firstLoad);
//if (approverCombobox.combobox("options").firstLoad) {
// approverCombobox.combobox("options").firstLoad = false;
// return false;
//}
if (opts.showProgress) {
//$.messager.progress({ msg: loadingMessage, autoClose: true, interval: 600 });
$.cmsLoading.show(loadingMessage);
}
approverCombobox.combobox('enable');
workPositionLabel.text("");
$.extend(param, opts.postData);
}
};
approverCombobox.combobox($.extend({}, opts, approverComboboxDefaultOptions));
}
$.fn.cmsNextApproverSelector = function (_7be, _7bf) {
if (typeof _7be == "string") {
var _7c0 = $.fn.cmsNextApproverSelector.methods[_7be];
if (_7c0) {
return _7c0(this, _7bf);
} else {
return this.cmsNextApproverSelector(_7be, _7bf);
}
}
_7be = _7be || {};
return this.each(function () {
var _this = this;
var _jqThis = $(_this);
var cacheData = $.data(_this, "cmsNextApproverSelector");
if (cacheData) {
$.extend(cacheData.options, _7be);
} else {
cacheData = $.data(_this, "cmsNextApproverSelector", { options: $.extend({}, $.fn.cmsNextApproverSelector.defaults, $.fn.cmsNextApproverSelector.parseOptions(this), _7be) });
var initCacheData = _init(_this);
cacheData = $.data(_this, "cmsNextApproverSelector", $.extend({}, cacheData, initCacheData));
}
//cacheData.approverCombobox.combobox("reload");
_load(_this);
});
};
$.fn.cmsNextApproverSelector.methods = {
options: function (jq) {
var opts = $.data(jq[0], "cmsNextApproverSelector").options;
return opts;
},
reload: function (jq) {
var approverCombobox = $.data(jq[0], "cmsNextApproverSelector").approverCombobox;
approverCombobox.combobox("reload");
},
getData: function (jq) {
var approverCombobox = $.data(jq[0], "cmsNextApproverSelector").approverCombobox;
return approverCombobox.combobox("getData");
},
setValue: function (jq, val) {
var approverCombobox = $.data(jq[0], "cmsNextApproverSelector").approverCombobox;
approverCombobox.combobox("setValue", val);
},
setValues: function (jq, vals) {
var approverCombobox = $.data(jq[0], "cmsNextApproverSelector").approverCombobox;
approverCombobox.combobox("setValues", vals);
},
getValue: function (jq, vals) {
var approverCombobox = $.data(jq[0], "cmsNextApproverSelector").approverCombobox;
return approverCombobox.combobox("getValue");
},
getValues: function (jq, vals) {
var approverCombobox = $.data(jq[0], "cmsNextApproverSelector").approverCombobox;
return approverCombobox.combobox("getValues");
},
isValid: function (jq) {
var t = $(jq);
t.find(".validatebox-text:not(:disabled)").validatebox("validate");
var _3dd = t.find(".validatebox-invalid");
_3dd.filter(":not(:disabled):first").focus();
return _3dd.length == 0;
},
validate: function (jq) {
var approverCombobox = $.data(jq[0], "cmsNextApproverSelector").approverCombobox;
return approverCombobox.combobox("validate");
}
};
$.fn.cmsNextApproverSelector.parseOptions = function (_7c7) {
var t = $(_7c7);
return $.extend({}, $.extend({}, $.fn.cmsNextApproverSelector.defaults, $.parser.parseOptions(_7c7, ["valueField", "textField"])), $.fn.validatebox.parseOptions(_7c7));
//return $.extend({}, $.fn.cmsNextApproverSelector.defaults, $.parser.parseOptions(_7c7, []));
};
$.fn.cmsNextApproverSelector.defaults = {
valueField: 'id',
textField: 'text',
url: '',
loadingMessage: '',
name: '',
postData: {},
showProgress: true,
onSelect: function () { },
onLoadSuccess: function () { },
onLoadError: function () { }
};
})(jQuery);
//2013-12-05 end added by pengbb 新增下一步审批人控件
//2014-01-19 begin added by pengbb 新增下拉控件
(function ($) {
$.parser.plugins.push("cmsCombobox");
function _getSelectedRecord(jq, selectedValue) {
var opts = $.data(jq, "cmsCombobox").options;
var reVal = null;
$.each(opts.data, function () {
if (this[opts.valueField] == selectedValue) {
reVal = this;
return false;
}
});
return reVal;
}
function _init(jq) {
var opts = $.data(jq, "cmsCombobox").options;
var jqThis = $(jq);
if (!opts.url) {
opts.value = jq.value;
opts.data = new Array();
jqThis.find("option").each(function () {
var rowRecord = new Object();
rowRecord[opts.valueField] = this.value;
rowRecord[opts.textField] = this.text;
opts.data.push(rowRecord);
});
}
$(jq).change(function () {
opts.value = $(this).val();
opts.onSelect.call(jq, _getSelectedRecord(jq, opts.value));
});
return { cmsCombobox: jq };
}
function _loadData(jq, data) {
var opts = $.data(jq, "cmsCombobox").options;
opts.data = data || [];
var optionList = new Array();
$.each(opts.data, function () {
optionList.push("" + opts.formatter.call(jq, this) + " ");
});
$(jq).html(optionList.join(""));
opts.onLoadSuccess.apply(this);
}
function _load(jq) {
var opts = $.data(jq, "cmsCombobox").options;
if (opts.url) {
var params = {};
opts.onBeforeLoad.call(this, params);
opts.loader.call(jq, params,
function (responseJson) {
_loadData(jq, responseJson);
}, function () {
opts.onLoadError.call(this, arguments);
});
} else {
//opts.onLoadSuccess.call(this);
}
}
function _setValue(jq, val) {
//var opts = $.data(jq, "cmsCombobox").options;
jq.value = val;
}
$.fn.cmsCombobox = function (_7be, _7bf) {
if (typeof _7be == "string") {
var _7c0 = $.fn.cmsCombobox.methods[_7be];
if (_7c0) {
return _7c0(this, _7bf);
} else {
return this.cmsCombobox(_7be, _7bf);
}
}
_7be = _7be || {};
return this.each(function () {
var _this = this;
var _jqThis = $(_this);
var cacheData = $.data(_this, "cmsCombobox");
if (cacheData) {
$.extend(cacheData.options, _7be);
} else {
cacheData = $.data(_this, "cmsCombobox", { options: $.extend({}, $.fn.cmsCombobox.defaults, $.fn.cmsCombobox.parseOptions(this), _7be) });
var initCacheData = _init(_this);
cacheData = $.data(_this, "cmsCombobox", $.extend({}, cacheData, initCacheData));
}
_load(_this);
});
};
$.fn.cmsCombobox.methods = {
options: function (jq) {
var opts = $.data(jq[0], "cmsCombobox").options;
return opts;
},
reload: function (jq) {
},
getValue: function (jq) {
return jq.val();
},
setValue: function (jq, val) {
jq.each(function () {
_setValue(this, val);
});
},
disable: function (jq) {
jq.disable();
},
enable: function (jq) {
jq.enable();
}
};
$.fn.cmsCombobox.parseOptions = function (_7c7) {
var t = $(_7c7);
return $.extend({}, $.fn.combo.parseOptions(_7c7), $.parser.parseOptions(_7c7, ["valueField", "textField", "mode", "method", "url"]));
};
$.fn.cmsCombobox.defaults = $.extend({}, $.fn.combo.defaults, {
autoLoad: false,
valueField: "value", textField: "text", mode: "local", method: "post", url: null, data: null,
filter: function (q, row) {
var opts = $(this).cmsCombobox("options");
return row[opts.textField].indexOf(q) == 0;
}, formatter: function (row) {
var opts = $(this).cmsCombobox("options");
return row[opts.textField];
}, loader: function (_7c9, _7ca, _7cb) {
var opts = $(this).cmsCombobox("options");
if (!opts.url) {
return false;
}
$.ajax({
type: opts.method, url: opts.url, data: _7c9, dataType: "json", success: function (data) {
_7ca(data);
}, error: function () {
_7cb.call(this, arguments);
}
});
}, onBeforeLoad: function (_7cc) {
}, onLoadSuccess: function () {
}, onLoadError: function () {
}, onSelect: function (_7cd) {
}, onUnselect: function (_7ce) {
}
});
})(jQuery);
//2014-01-19 end added by pengbb 新增下拉控件
//2013-12-05 begin added by pengbb 新增时间选择控件
/*用法:指定class 为 easyui-cmsDatebox
*/
(function ($) {
$.parser.plugins.push("cmsDateTimeBox");
function _init(jq) {
var opts = $.data(jq, "cmsDateTimeBox").options;
var jqThis = $(jq);
var jqTxtValue = jqThis.find("input.cmsDateTimeBox-text");
var jqBtnSelect = jqThis.find("span.cmsDateTimeBox-select");
var wdatePickerOptions = $.extend({}, opts, {
el: jqTxtValue[0],
onpicking: function () {
}, onpicked: function () {
opts.onSelect.call(jq);
return true;
}, onclearing: function () {
}, oncleared: function () {
}
});
jqBtnSelect.bind("mouseenter.cmsDateTimeBox", function () {
$(this).addClass("cmsDateTimeBox-select-hover");
}).bind("mouseleave.cmsDatebox", function () {
$(this).removeClass("cmsDateTimeBox-select-hover");
}).bind("mousedown.cmsDatebox", function () {
WdatePicker(wdatePickerOptions);
});
jqTxtValue.click(function () {
WdatePicker(wdatePickerOptions);
});
return { cmsDateTimeBox: jq, txtValue: jqTxtValue, btnSelect: jqBtnSelect };
}
$.fn.cmsDateTimeBox = function (_7be, _7bf) {
if (typeof _7be == "string") {
var _7c0 = $.fn.cmsDateTimeBox.methods[_7be];
if (_7c0) {
return _7c0(this, _7bf);
} else {
return this.cmsDateTimeBox(_7be, _7bf);
}
}
_7be = _7be || {};
return this.each(function () {
var _this = this;
var _jqThis = $(_this);
var cacheData = $.data(_this, "cmsDateTimeBox");
if (cacheData) {
$.extend(cacheData.options, _7be);
} else {
cacheData = $.data(_this, "cmsDateTimeBox", { options: $.extend({}, $.fn.cmsDateTimeBox.defaults, $.fn.cmsDateTimeBox.parseOptions(this), _7be) });
var initCacheData = _init(_this);
cacheData = $.data(_this, "cmsDateTimeBox", $.extend({}, cacheData, initCacheData));
}
});
};
$.fn.cmsDateTimeBox.methods = {
options: function (jq) {
var opts = $.data(jq[0], "cmsDateTimeBox").options;
return opts;
},
getValue: function (jq) {
var txtValue = $.data(jq[0], "cmsDateTimeBox").txtValue;
return txtValue.val();
},
setValue: function (jq, val) {
jq.each(function () {
var txtValue = $.data(jq[0], "cmsDateTimeBox").txtValue;
return txtValue.val(val);
});
}
};
$.fn.cmsDateTimeBox.parseOptions = function (_7c7) {
var t = $(_7c7);
return $.extend({}, $.parser.parseOptions(_7c7, []));
};
$.fn.cmsDateTimeBox.defaults = $.extend({}, {}, {
dateFmt: 'yyyy-MM-dd',
lang: 'zh-cn',
onSelect: function () {
}
});
})(jQuery);
//2014-01-20 end added by pengbb 新增时间选择控件
//2014-01-21 begin added by pengbb 新增页面操作loading效果
$.cmsLoading = (function () {
var defaultSetting = {
panelElement: document.body,
defaultMessage: "正在努力处理中..."
};
var isInit = false;
var loadingPanel = null;
var f_getLoadingPanel = function () {
return loadingPanel;
};
var f_show = function (msg) {
if (!isInit) {
this.setting.panelElement = this.setting.panelElement || document.body;
loadingPanel = $('').appendTo(this.setting.panelElement);
isInit = true;
} else {
loadingPanel.show();
}
loadingPanel.find("div.loading-mask-msg").html(msg || this.setting.defaultMessage);
};
var f_hide = function () {
if (loadingPanel) {
loadingPanel.hide();
}
};
return { getLoadingPanel: f_getLoadingPanel, show: f_show, hide: f_hide, setting: defaultSetting };
})();
//2014-01-21 end added by pengbb 新增页面操作loading效果
//2014-01-23 begin added by pengbb 新增下一步审批人控件,审批页面使用
/*用法:定义一个div,指定class 为 easyui-cmsLocalNextApproverSelector
xxx xxx xxx
data-options参数如下:
url:'/Common/GetHtmlContent',
loadingMessage:'正在加载中...',
postData : {}
*/
(function ($) {
$.parser.plugins.push("cmsLocalNextApproverSelector");
function _init(jq) {
var opts = $.data(jq, "cmsLocalNextApproverSelector").options;
var jqThis = $(jq);
var approverCombobox = jqThis.find(">select");
var workPositionLabel = jqThis.find(">label");
approverCombobox.validatebox(opts);
approverCombobox.unbind("cmsLocalNextApproverSelector");
approverCombobox.bind("change.cmsLocalNextApproverSelector", function () {
var selectedData = _getSelectedData(jq);
if (selectedData && selectedData.ApprovalPower.length > 0) {
workPositionLabel.text(selectedData.ApprovalPower[0].NodeName);
} else {
workPositionLabel.text("");
}
});
//2014-02-20 end added by pengbb 修改IE8下 下一步审批人为"结束"时验证不通过
if ($.browser.msie && $.browser.version > 6 && !approverCombobox.attr("disabled")) {
approverCombobox.validatebox("validate");
}
return { cmsNextApproverSelector: jq, approverCombobox: approverCombobox, workPositionLabel: workPositionLabel };
}
function _getSelectedData(jq) {
var opts = $.data(jq, "cmsLocalNextApproverSelector").options;
var approverCombobox = $.data(jq, "cmsLocalNextApproverSelector").approverCombobox;
var selectedValue = approverCombobox.val();
var selectedData = null;
$.each(opts.data, function () {
if (this[opts.valueField] == selectedValue) {
selectedData = this;
return false;
}
});
return selectedData;
}
function _loadData(jq, data) {
var opts = $.data(jq, "cmsLocalNextApproverSelector").options;
var approverCombobox = $.data(jq, "cmsLocalNextApproverSelector").approverCombobox;
approverCombobox.enable();
opts.data = data || [];
var optionList = new Array();
optionList.push("请选择 ");
$.each(opts.data, function () {
if (this[opts.textField] == "结束") {
optionList.length = 0;
$(approverCombobox).attr("disabled", "disabled");
}
optionList.push("" + opts.formatter.call(jq, this) + " ");
});
approverCombobox.html(optionList.join(""));
opts.onLoadSuccess.apply(this);
}
function _reload(jq, url, postData) {
var opts = $.data(jq, "cmsLocalNextApproverSelector").options;
var approverCombobox = $.data(jq, "cmsLocalNextApproverSelector").approverCombobox;
var workPositionLabel = $.data(jq, "cmsLocalNextApproverSelector").workPositionLabel;
approverCombobox.disable();
workPositionLabel.text("正在加载下一步审批人,请稍等...");
$.ajax({
type: "post", url: url, data: postData, dataType: "json", success: function (data) {
workPositionLabel.text("");
_loadData(jq, data);
//解决点击下一步审批人下拉框缩回去的Bug
if ($.browser.msie && $.browser.version > 6 && !approverCombobox.attr("disabled")) {
approverCombobox.validatebox("validate");
}
}, error: function () {
workPositionLabel.text("下一步审批人加载失败,请尝试重新打开,若多次出现这种请联系系统管理员");
opts.onLoadError.apply(this, arguments);
}
});
}
$.fn.cmsLocalNextApproverSelector = function (_7be, _7bf) {
if (typeof _7be == "string") {
var _7c0 = $.fn.cmsLocalNextApproverSelector.methods[_7be];
if (_7c0) {
return _7c0(this, _7bf);
} else {
return this.cmsLocalNextApproverSelector(_7be, _7bf);
}
}
_7be = _7be || {};
return this.each(function () {
var _this = this;
var _jqThis = $(_this);
var cacheData = $.data(_this, "cmsLocalNextApproverSelector");
if (cacheData) {
$.extend(cacheData.options, _7be);
} else {
cacheData = $.data(_this, "cmsLocalNextApproverSelector", { options: $.extend({}, $.fn.cmsLocalNextApproverSelector.defaults, $.fn.cmsLocalNextApproverSelector.parseOptions(this), _7be) });
var initCacheData = _init(_this);
cacheData = $.data(_this, "cmsLocalNextApproverSelector", $.extend({}, cacheData, initCacheData));
}
var opts = cacheData.options;
if (opts.url && (!opts.data || opts.data.length == 0)) {
_reload(_this, opts.url, opts.postData);
}
});
};
$.fn.cmsLocalNextApproverSelector.methods = {
options: function (jq) {
var opts = $.data(jq[0], "cmsLocalNextApproverSelector").options;
return opts;
},
reload: function (jq, p) {
jq.each(function () {
_reload(this, p.url, p.postData);
});
},
getValue: function (jq) {
var approverCombobox = $.data(jq[0], "cmsLocalNextApproverSelector").approverCombobox;
return approverCombobox.val();
},
isValid: function (jq) {
var t = $(jq);
t.find("select:not(:disabled)").validatebox("validate");
var _3dd = t.find(".validatebox-invalid");
_3dd.filter(":not(:disabled):first").focus();
return _3dd.length == 0;
},
validate: function (jq) {
var approverCombobox = $.data(jq[0], "cmsLocalNextApproverSelector").approverCombobox;
return approverCombobox.cmsCombobox("validate");
}
};
$.fn.cmsLocalNextApproverSelector.parseOptions = function (_7c7) {
var t = $(_7c7);
return $.extend({}, $.extend({}, $.fn.cmsLocalNextApproverSelector.defaults, $.parser.parseOptions(_7c7, ["valueField", "textField"])), $.fn.validatebox.parseOptions(_7c7));
//return $.extend({}, $.fn.cmsNextApproverSelector.defaults, $.parser.parseOptions(_7c7, []));
};
$.fn.cmsLocalNextApproverSelector.defaults = {
valueField: 'UserID',
textField: 'UserName',
url: '',
loadingMessage: '',
name: '',
postData: {},
data: [],
showProgress: true,
onSelect: function () { },
onLoadSuccess: function () { },
onLoadError: function () { },
formatter: function (row) {
var opts = $(this).cmsLocalNextApproverSelector("options");
return row[opts.textField];
}
};
})(jQuery);
//2014-01-23 end added by pengbb 新增下一步审批人控件,审批页面使用
//2014-02-21 begin added by pengbb 新增平铺品牌选择控件 cmsXBrandItemSelector
(function ($) {
$.parser.plugins.push("cmsXBrandItemSelector");
function _init(jq) {
var opts = $.data(jq, "cmsXBrandItemSelector").options;
var _jqThis = $(jq);
var brandPanel = _jqThis.find(".brandpanel");
var brandItemPanel = _jqThis.find(".branditempanel");
//品牌
var brandXOptionItemList = brandPanel.find(".xoption2 table.xTabOption_item");
brandXOptionItemList.unbind(".cmsXBrandItemSelector");
brandXOptionItemList.bind("mouseenter.cmsXBrandItemSelector",
function () {
var _this = $(this);
_this.addClass("xTabOption_item_hover");
}
);
brandXOptionItemList.bind("mouseleave.cmsXBrandItemSelector",
function () {
var _this = $(this);
_this.removeClass("xTabOption_item_hover");
}
);
brandXOptionItemList.bind('click.cmsXBrandItemSelector', function () {
var _this = $(this);
if (!_this.hasClass("xTabOption_item_selected")) {
brandPanel.find(".xTabOption_item_selected").each(function () {
$(this).removeClass("xTabOption_item_selected");
});
_this.addClass("xTabOption_item_selected");
brandPanel.trigger("selectChanged");
}
});
brandPanel.unbind(".cmsXBrandItemSelector");
brandPanel.bind("selectChanged.cmsXBrandItemSelector", function () {
var selectValue = brandPanel.find("table.xTabOption_item_selected:first").attr("xoptionValue");
if (selectValue != "-1") {
brandItemPanel.show();
} else {
brandItemPanel.hide();
}
var brandItemPanelContent = brandItemPanel.find(".branditempanel_content");
brandItemPanelContent.find("li.xoption").remove();
$.each(opts.brandList, function () {
if (this.BrandID == selectValue) {
$.each(this.BrandItemList, function () {
var newBrandItemLi = $(' ').appendTo(brandItemPanelContent);
newBrandItemLi.find("table").attr("xoptionValue", this.BrandItemID);
newBrandItemLi.find("table td.xoption_item_bg_center").text(this.BrandItemName);
});
}
});
opts.selectChanged.call(jq);
});
//品牌物品
var brandItemXOptionItemList = brandItemPanel.find("li.xoption table.xoption_item");
brandItemXOptionItemList.die(".cmsXBrandItemSelector");
brandItemXOptionItemList.live("mouseenter.cmsXBrandItemSelector",
function () {
var _this = $(this);
_this.addClass("xoption_item_hover");
}
);
brandItemXOptionItemList.live("mouseleave.cmsXBrandItemSelector",
function () {
var _this = $(this);
_this.removeClass("xoption_item_hover");
}
);
brandItemXOptionItemList.live("click.cmsXBrandItemSelector", function () {
var _this = $(this);
if (_this.hasClass("xoption_item_selected")) {
_this.removeClass("xoption_item_selected");
_this.find("td.xoption_item_bg_right>i").remove();
} else {
_this.addClass("xoption_item_selected");
$(' ').appendTo(_this.find("td.xoption_item_bg_right"));
}
brandItemPanel.trigger("selectChanged");
});
brandItemPanel.unbind(".cmsXBrandItemSelector");
brandItemPanel.bind("selectChanged.cmsXBrandItemSelector", function () {
opts.selectChanged.call(jq);
});
//清除所选按扭
// brandItemPanel.find("li.branditempanel_tools .xbutton").unbind(".cmsXBrandItemSelector");
// brandItemPanel.find("li.branditempanel_tools .xbutton").bind("click.cmsXBrandItemSelector", function () {
// if (brandItemPanel.find("li.xoption_selected a").length > 0) {
// brandItemPanel.find("li.xoption_selected a").each(function () {
// var li = $(this).closest("li");
// li.removeClass("xoption_selected");
// li.find("i").remove();
// });
// brandItemPanel.trigger("selectChanged");
// }
// });
return { cmsXBrandItemSelector: jq, brandPanel: brandPanel, brandItemPanel: brandItemPanel };
}
$.fn.cmsXBrandItemSelector = function (_7be, _7bf) {
if (typeof _7be == "string") {
var _7c0 = $.fn.cmsXBrandItemSelector.methods[_7be];
if (_7c0) {
return _7c0(this, _7bf);
} else {
return this.cmsXBrandItemSelector(_7be, _7bf);
}
}
_7be = _7be || {};
return this.each(function () {
var _this = this;
var cacheData = $.data(_this, "cmsXBrandItemSelector");
if (cacheData) {
$.extend(cacheData.options, _7be);
} else {
cacheData = $.data(_this, "cmsXBrandItemSelector", { options: $.extend({}, $.fn.cmsXBrandItemSelector.defaults, $.fn.cmsXBrandItemSelector.parseOptions(this), _7be) });
var initCacheData = _init(_this);
cacheData = $.data(_this, "cmsXBrandItemSelector", $.extend({}, cacheData, initCacheData));
}
});
};
function _getValue(jq) {
var opts = $.data(jq, "cmsXBrandItemSelector").options;
var brandPanel = $.data(jq, "cmsXBrandItemSelector").brandPanel;
var brandItemPanel = $.data(jq, "cmsXBrandItemSelector").brandItemPanel;
var brandPayType = { BrandPayTypeID: "-1", BrandPayTypeName: "全部" };
var brand = { BrandID: "-1", BrandName: "全部" };
var brandItemList = [];
brandPanel.find("table.xTabOption_item_selected:first").each(function () {
var selectedBrand = $(this);
brand = { BrandID: selectedBrand.attr("xoptionValue"), BrandName: selectedBrand.find("td.xTabOption_item_bg_center").text() };
});
brandItemPanel.find("table.xoption_item_selected").each(function () {
var selectedBrandItem = $(this);
brandItemList.push({
BrandItemID: selectedBrandItem.attr("xoptionValue"),
BrandItemName: selectedBrandItem.find("td.xoption_item_bg_center").text()
});
});
return {
BrandPayType: brandPayType,
Brand: brand,
BrandItemList: brandItemList
};
}
function _clearBrandSelections(jq) {
var brandPanel = $.data(jq, "cmsXBrandItemSelector").brandPanel;
var brandItemPanel = $.data(jq, "cmsXBrandItemSelector").brandItemPanel;
brandPanel.find("table.xTabOption_item_selected").removeClass("xTabOption_item_selected");
var btnSelectAll = brandPanel.find("table.xTabOption_item[xoptionValue='-1']");
btnSelectAll.addClass("xTabOption_item_selected");
brandItemPanel.find("table.xoption_item").remove();
brandItemPanel.hide();
}
function _clearBrandItemSelections(jq) {
var brandItemPanel = $.data(jq, "cmsXBrandItemSelector").brandItemPanel;
//brandItemPanel.find("table.xoption_item").remove();
brandItemPanel.find("table.xoption_item_selected").removeClass("xoption_item_selected");
//brandItemPanel.hide();
}
$.fn.cmsXBrandItemSelector.methods = {
options: function (jq) {
var opts = $.data(jq[0], "cmsXBrandItemSelector").options;
return opts;
},
getValue: function (jq) {
return _getValue(jq[0]);
},
clearBrandSelections: function (jq) {
jq.each(function () {
_clearBrandSelections(this);
});
},
clearBrandItemSelections: function (jq) {
jq.each(function () {
_clearBrandItemSelections(this);
});
}
};
$.fn.cmsXBrandItemSelector.parseOptions = function (_7c7) {
var t = $(_7c7);
return $.extend({}, $.fn.cmsXBrandItemSelector.defaults, $.parser.parseOptions(_7c7, ["valueField", "textField"]));
};
$.fn.cmsXBrandItemSelector.defaults = {
selectChanged: function () {
var val = $(this).cmsXBrandItemSelector("getValue");
//alert(val.Brand.BrandName);
//if (val.BrandItemList.length > 0) {
// var ss = [];
// $.each(val.BrandItemList, function () {
// ss.push(this.BrandItemName);
// });
// alert(ss.join(","));
//}
},
brandList: []
};
})(jQuery);
//2014-02-21 end added by pengbb 新增平铺品牌选择控件
//2014-02-24 begin added by pengbb 新增平铺选择控件 cmsXTileSelector
(function ($) {
$.parser.plugins.push("cmsXTileSelector");
function _init(jq) {
var opts = $.data(jq, "cmsXTileSelector").options;
var _jqThis = $(jq);
//var btnSelectAll = _jqThis.find(".col2 .selectall .xoption a");
var tileItemPanel = _jqThis.find(".tileItemPanel,.tileItemPanel_more");
if (tileItemPanel.find(".tileItemPanel_tools").length > 0) {
var tileItemPanelMore = _jqThis.find(".tileItemPanel_more");
var btnShowMore = tileItemPanel.find(".tileItemPanel_tools table.xbutton");
btnShowMore.unbind(".cmsXTileSelector");
btnShowMore.bind("click.cmsXTileSelector", function () {
var btn = $(this);
if (btn.hasClass("tileItemPanel_more_hide")) {
btn.find("td.xbutton_bg_center").text("更多");
btn.removeClass("tileItemPanel_more_hide");
tileItemPanelMore.hide();
} else {
btn.addClass("tileItemPanel_more_hide");
tileItemPanelMore.show();
btn.find("td.xbutton_bg_center").text("收起");
}
});
}
//选项
var optionItemList = tileItemPanel.find(".xoption table.xoption_item");
var btnAllOptionItem = tileItemPanel.find(".xoption table.xoption_item[xoptionValue='-1']");
optionItemList.unbind(".cmsXTileSelector");
optionItemList.bind("mouseenter.cmsXTileSelector",
function () {
var _this = $(this);
_this.addClass("xoption_item_hover");
}
);
optionItemList.bind("mouseleave.cmsXTileSelector",
function () {
var _this = $(this);
_this.removeClass("xoption_item_hover");
}
);
optionItemList.bind('click.cmsXTileSelector', function () {
var _this = $(this);
var _thisValue = _this.attr("xoptionvalue");
var isBtnAll = _thisValue == "-1";
var isSelected = _this.hasClass("xoption_item_selected");
if (opts.multiple) {
if (isSelected && isBtnAll) return;
if (_this.hasClass("xoption_item_selected")) {
_this.removeClass("xoption_item_selected");
_this.find("td.xoption_item_bg_right>i").remove();
} else {
_this.addClass("xoption_item_selected");
$(' ').appendTo(_this.find("td.xoption_item_bg_right"));
}
if (!isBtnAll) {
if (tileItemPanel.find(".xoption table.xoption_item_selected").length > 0) {
btnAllOptionItem.removeClass("xoption_item_selected");
btnAllOptionItem.find("td.xoption_item_bg_right>i").remove();
} else {
btnAllOptionItem.addClass("xoption_item_selected");
$(' ').appendTo(btnAllOptionItem.find("td.xoption_item_bg_right"));
}
} else {
var btnOtherOptionItemList = tileItemPanel.find(".xoption table.xoption_item[xoptionValue!='-1']");
btnOtherOptionItemList.removeClass("xoption_item_selected");
btnOtherOptionItemList.find("td.xoption_item_bg_right>i").remove();
}
} else {
if (_this.hasClass("xoption_item_selected")) {
return;
} else {
optionItemList.removeClass("xoption_item_selected");
optionItemList.find("td.xoption_item_bg_right>i").remove();
_this.addClass("xoption_item_selected");
$(' ').appendTo(_this.find("td.xoption_item_bg_right"));
}
}
opts.selectChanged.call(jq);
});
return { cmsXTileSelector: jq, tileItemPanel: tileItemPanel };
}
$.fn.cmsXTileSelector = function (_7be, _7bf) {
if (typeof _7be == "string") {
var _7c0 = $.fn.cmsXTileSelector.methods[_7be];
if (_7c0) {
return _7c0(this, _7bf);
} else {
return this.cmsXTileSelector(_7be, _7bf);
}
}
_7be = _7be || {};
return this.each(function () {
var _this = this;
var cacheData = $.data(_this, "cmsXTileSelector");
if (cacheData) {
$.extend(cacheData.options, _7be);
} else {
cacheData = $.data(_this, "cmsXTileSelector", { options: $.extend({}, $.fn.cmsXTileSelector.defaults, $.fn.cmsXTileSelector.parseOptions(this), _7be) });
var initCacheData = _init(_this);
cacheData = $.data(_this, "cmsXTileSelector", $.extend({}, cacheData, initCacheData));
}
});
};
function _getValue(jq) {
var opts = $.data(jq, "cmsXTileSelector").options;
var tileItemPanel = $.data(jq, "cmsXTileSelector").tileItemPanel;
var selectedValueList = [];
tileItemPanel.find("li.xoption table.xoption_item_selected").each(function () {
var selectedItem = $(this);
var selectedValue = new Object();
selectedValue[opts.valueField] = selectedItem.attr("xoptionValue");
selectedValue[opts.textField] = selectedItem.find("td.xoption_item_bg_center").text();
selectedValueList.push(selectedValue);
});
return selectedValueList;
}
function _clearSelections(jq) {
var tileItemPanel = $.data(jq, "cmsXTileSelector").tileItemPanel;
tileItemPanel.find("li.xoption table.xoption_item_selected td.xoption_item_bg_right i").remove();
tileItemPanel.find("li.xoption table.xoption_item_selected").removeClass("xoption_item_selected");
var btnAllOptionItem = tileItemPanel.find("li.xoption table.xoption_item[xoptionValue='-1']");
btnAllOptionItem.addClass("xoption_item_selected");
$(' ').appendTo(btnAllOptionItem.find("td.xoption_item_bg_right"));
}
$.fn.cmsXTileSelector.methods = {
options: function (jq) {
var opts = $.data(jq[0], "cmsXTileSelector").options;
return opts;
},
getValue: function (jq) {
return _getValue(jq[0]);
},
clearSelections: function (jq) {
jq.each(function () {
_clearSelections(this);
});
}
};
$.fn.cmsXTileSelector.parseOptions = function (_7c7) {
var t = $(_7c7);
return $.extend({}, $.fn.cmsXTileSelector.defaults, $.parser.parseOptions(_7c7, ["valueField", "textField"]));
};
$.fn.cmsXTileSelector.defaults = {
valueField: "Value",
textField: "Text",
selectChanged: function () {
},
multiple: true
};
})(jQuery);
//2014-02-24 end added by pengbb 新增平铺品牌选择控件
//2014-02-24 begin added by pengbb 新增平铺号码规则选择控件 cmsXTelnumberRuleSelector
(function ($) {
$.parser.plugins.push("cmsXTelnumberRuleSelector");
function _init(jq) {
var opts = $.data(jq, "cmsXTelnumberRuleSelector").options;
var _jqThis = $(jq);
var telnumberRuleTypePanel = _jqThis.find(".telnumberRuleTypePanel");
var telnumberRulePanel = _jqThis.find(".telnumberRulePanel");
//规则分类
var telNumberRuleTypeOptionItemList = telnumberRuleTypePanel.find("li.telnumberRuleTypeItem table.xoption_item");
telNumberRuleTypeOptionItemList.die(".cmsXTelnumberRuleSelector");
telNumberRuleTypeOptionItemList.live("mouseenter.cmsXTelnumberRuleSelector",
function () {
var _this = $(this);
_this.addClass("xoption_item_hover");
}
);
telNumberRuleTypeOptionItemList.live("mouseleave.cmsXTelnumberRuleSelector",
function () {
var _this = $(this);
_this.removeClass("xoption_item_hover");
}
);
telNumberRuleTypeOptionItemList.live("click.cmsXTelnumberRuleSelector", function () {
var _this = $(this);
if (!_this.hasClass("xoption_item_selected")) {
var oldSelectedTelNumberRuleTypeOptionItemList = telnumberRuleTypePanel.find("li.telnumberRuleTypeItem table.xoption_item_selected");
oldSelectedTelNumberRuleTypeOptionItemList.removeClass("xoption_item_selected");
oldSelectedTelNumberRuleTypeOptionItemList.find("td.xoption_item_bg_right>i").remove();
_this.addClass("xoption_item_selected");
$(' ').appendTo(_this.find("td.xoption_item_bg_right"));
telnumberRuleTypePanel.trigger("selectChanged");
}
});
telnumberRuleTypePanel.unbind(".cmsXTelnumberRuleSelector");
telnumberRuleTypePanel.bind("selectChanged.cmsXTelnumberRuleSelector", function () {
telnumberRulePanel.find(".xoption").remove();
var selectedTelNumberRuleTypeID = telnumberRuleTypePanel.find("li.telnumberRuleTypeItem table.xoption_item_selected:first").attr("xoptionValue");
if (selectedTelNumberRuleTypeID == -1) {
telnumberRulePanel.hide();
//$.each(opts.telNumberRuleList, function () {
// $.each(this.TelNumberRuleList, function () {
// var newTelNumberRuleLi = $(' ').appendTo(telnumberRulePanel);
// newTelNumberRuleLi.find("a>span").attr("xoptionValue", this.TelNumberRuleID);
// newTelNumberRuleLi.find("a>span").text(this.TelNumberRuleName);
// });
//});
} else {
telnumberRulePanel.show();
$.each(opts.telNumberRuleList, function () {
if (this.TelNumberRuleTypeID == selectedTelNumberRuleTypeID) {
$.each(this.TelNumberRuleList, function () {
var newTelNumberRuleLi = $(' ').appendTo(telnumberRulePanel);
newTelNumberRuleLi.find("table").attr("xoptionValue", this.TelNumberRuleID);
newTelNumberRuleLi.find("table td.xoption_item_bg_center").text(this.TelNumberRuleName);
});
}
});
}
opts.selectChanged.call(jq);
});
//规则
var telnumberRuleOptionItemList = telnumberRulePanel.find(".xoption table.xoption_item");
telnumberRuleOptionItemList.die(".cmsXTelnumberRuleSelector");
telnumberRuleOptionItemList.live("mouseenter.cmsXTelnumberRuleSelector",
function () {
var _this = $(this);
_this.addClass("xoption_item_hover");
}
);
telnumberRuleOptionItemList.live("mouseleave.cmsXTelnumberRuleSelector",
function () {
var _this = $(this);
_this.removeClass("xoption_item_hover");
}
);
telnumberRuleOptionItemList.live('click.cmsXTelnumberRuleSelector', function () {
var _this = $(this);
if (_this.hasClass("xoption_item_selected")) {
_this.removeClass("xoption_item_selected");
_this.find("td.xoption_item_bg_right>i").remove();
} else {
_this.addClass("xoption_item_selected");
$(' ').appendTo(_this.find("td.xoption_item_bg_right"));
}
telnumberRulePanel.trigger("selectChanged");
});
telnumberRulePanel.unbind(".cmsXTelnumberRuleSelector");
telnumberRulePanel.bind("selectChanged.cmsXTelnumberRuleSelector", function () {
opts.selectChanged.call(jq);
});
telnumberRulePanel.find(".telnumberRulePanelTool table.xbutton").die(".cmsXTelnumberRuleSelector");
telnumberRulePanel.find(".telnumberRulePanelTool table.xbutton").live("click.cmsXTelnumberRuleSelector", function () {
telnumberRulePanel.find(".xoption table.xoption_item").each(function () {
var _this = $(this);
if (!_this.hasClass("xoption_item_selected")) {
_this.addClass("xoption_item_selected");
$(' ').appendTo(_this.find("td.xoption_item_bg_right"));
}
});
telnumberRulePanel.trigger("selectChanged");
});
return { cmsXTelnumberRuleSelector: jq, telnumberRuleTypePanel: telnumberRuleTypePanel, telnumberRulePanel: telnumberRulePanel };
}
$.fn.cmsXTelnumberRuleSelector = function (_7be, _7bf) {
if (typeof _7be == "string") {
var _7c0 = $.fn.cmsXTelnumberRuleSelector.methods[_7be];
if (_7c0) {
return _7c0(this, _7bf);
} else {
return this.cmsXTelnumberRuleSelector(_7be, _7bf);
}
}
_7be = _7be || {};
return this.each(function () {
var _this = this;
var cacheData = $.data(_this, "cmsXTelnumberRuleSelector");
if (cacheData) {
$.extend(cacheData.options, _7be);
} else {
cacheData = $.data(_this, "cmsXTelnumberRuleSelector", { options: $.extend({}, $.fn.cmsXTelnumberRuleSelector.defaults, $.fn.cmsXTelnumberRuleSelector.parseOptions(this), _7be) });
var initCacheData = _init(_this);
cacheData = $.data(_this, "cmsXTelnumberRuleSelector", $.extend({}, cacheData, initCacheData));
}
});
};
function _getValue(jq) {
var opts = $.data(jq, "cmsXTelnumberRuleSelector").options;
var telnumberRuleTypePanel = $.data(jq, "cmsXTelnumberRuleSelector").telnumberRuleTypePanel;
var telnumberRulePanel = $.data(jq, "cmsXTelnumberRuleSelector").telnumberRulePanel;
var selectedValueList = [];
var selectedTelNumberRuleType = {};
telnumberRuleTypePanel.find("li.telnumberRuleTypeItem table.xoption_item_selected:first").each(function () {
selectedTelNumberRuleType["TelNumberRuleTypeID"] = $(this).attr("xoptionValue");
selectedTelNumberRuleType["TelNumberRuleTypeName"] = $(this).find("td.xoption_item_bg_center").text();
});
telnumberRulePanel.find("table.xoption_item_selected").each(function () {
var _this = $(this);
selectedValueList.push({
TelNumberRuleName: _this.find("td.xoption_item_bg_center").text(),
TelNumberRuleID: _this.attr("xoptionValue")
});
});
return { TelNumberRuleType: selectedTelNumberRuleType, TelNumberRuleList: selectedValueList };
}
function _clearSelections(jq) {
var telnumberRuleTypePanel = $.data(jq, "cmsXTelnumberRuleSelector").telnumberRuleTypePanel;
var telnumberRulePanel = $.data(jq, "cmsXTelnumberRuleSelector").telnumberRulePanel;
var selectedTelnumberRuleTypeOptionItemList = telnumberRuleTypePanel.find("li.telnumberRuleTypeItem table.xoption_item_selected");
selectedTelnumberRuleTypeOptionItemList.removeClass("xoption_item_selected");
selectedTelnumberRuleTypeOptionItemList.find("td.xoption_item_bg_right>i").remove();
var telnumberRuleTypePanelSelectAll = telnumberRuleTypePanel.find("li.telnumberRuleTypeItem table.xoption_item[xoptionValue='-1']");
telnumberRuleTypePanelSelectAll.addClass("xoption_item_selected");
$(' ').appendTo(telnumberRuleTypePanelSelectAll.find("td.xoption_item_bg_right"));
telnumberRulePanel.find("li.xoption table.xoption_item_selected td.xoption_item_bg_right i").remove();
telnumberRulePanel.find("li.xoption table.xoption_item_selected").removeClass("xoption_item_selected");
telnumberRulePanel.hide();
}
function _load(jq, param) {
var opts = $.data(jq, "cmsXTelnumberRuleSelector").options;
param = $.extend({}, { url: '', postData: {} }, param);
if (param.url) {
$.ajax({
type: "post", url: param.url, data: param.postData, dataType: "json", success: function (data) {
_loadData(jq, data);
}, error: function () {
if (typeof (opts.onLoadError) == "function") {
opts.onLoadError.call(jq);
}
}
});
}
}
function _loadData(jq, data) {
var opts = $.data(jq, "cmsXTelnumberRuleSelector").options;
var telnumberRuleTypePanel = $.data(jq, "cmsXTelnumberRuleSelector").telnumberRuleTypePanel;
var telnumberRulePanel = $.data(jq, "cmsXTelnumberRuleSelector").telnumberRulePanel;
opts.telNumberRuleList = data || [];
telnumberRuleTypePanel.find("li.telnumberRuleTypeItem").remove();
telnumberRulePanel.find("li.xoption").remove();
telnumberRulePanel.hide();
$(' ').appendTo(telnumberRuleTypePanel);
$.each(opts.telNumberRuleList, function () {
var newTelNumberRuleTypeLi = $(' ').appendTo(telnumberRuleTypePanel);
newTelNumberRuleTypeLi.find("table").attr("xoptionValue", this.TelNumberRuleTypeID);
newTelNumberRuleTypeLi.find("table td.xoption_item_bg_center").text(this.TelNumberRuleTypeName);
//$.each(this.TelNumberRuleList,function() {
// var newTelNumberRuleLi = $(' ').appendTo(telnumberRulePanel);
// newTelNumberRuleLi.find("a>span").attr("xoptionValue", this.TelNumberRuleID);
// newTelNumberRuleLi.find("a>span").text(this.TelNumberRuleName);
//});
});
if (typeof (opts.onLoadSuccess) == "function") {
opts.onLoadSuccess.call(jq);
}
}
$.fn.cmsXTelnumberRuleSelector.methods = {
options: function (jq) {
var opts = $.data(jq[0], "cmsXTelnumberRuleSelector").options;
return opts;
},
getTelNumberRuleList: function (jq) {
var opts = $.data(jq[0], "cmsXTelnumberRuleSelector").options;
return opts.telNumberRuleList;
},
getValue: function (jq) {
return _getValue(jq[0]);
},
clearSelections: function (jq) {
jq.each(function () {
_clearSelections(this);
});
},
//param:{url:'',postData:{}}
load: function (jq, param) {
jq.each(function () {
_load(this, param);
});
}
};
$.fn.cmsXTelnumberRuleSelector.parseOptions = function (_7c7) {
var t = $(_7c7);
return $.extend({}, $.fn.cmsXTelnumberRuleSelector.defaults, $.parser.parseOptions(_7c7, []));
};
$.fn.cmsXTelnumberRuleSelector.defaults = {
selectChanged: function () {
//alert(JSON.stringify($(this).cmsXTelnumberRuleSelector("getValue")));
//alert(0);
},
multiple: true,
telNumberRuleList: [],
onLoadSuccess: function (data) {
},
onLoadError: function () {
}
};
})(jQuery);
//2014-02-24 end added by pengbb 新增平铺号码规则选择控件
//2014-02-25 begin added by pengbb 新增号码精确查询输入控件 cmsXExactTelNumberInput
(function ($) {
$.parser.plugins.push("cmsXExactTelNumberInput");
function _init(jq) {
var opts = $.data(jq, "cmsXExactTelNumberInput").options;
var _jqThis = $(jq);
var numberInputList = _jqThis.find("li.numbercolumn span.numberinput>input");
var btnOK = _jqThis.find("li.toolcolumn .xbutton");
numberInputList.unbind(".cmsXExactTelNumberInput");
numberInputList.bind("keydown.cmsXExactTelNumberInput", function (event) {
//48-57,96-105,退格:8,左:37,右:39
var keyCode = event.keyCode;
if (!((48 <= keyCode && keyCode <= 57) || (96 <= keyCode && keyCode <= 105) || keyCode == 8)) {
return false;
}
this.value = "";
});
numberInputList.bind("keyup.cmsXExactTelNumberInput", function (event) {
var keyCode = event.keyCode;
if (keyCode == 37) {
$(this).closest("li").prev("li").find("span.numberinput>input").focus();
} else if (keyCode == 39) {
$(this).closest("li").next("li").find("span.numberinput>input").focus();
} else {
if (this.value != "") {
$(this).closest("li").next("li").find("span.numberinput>input").focus();
} else {
if (keyCode == 8) {
$(this).closest("li").prev("li").find("span.numberinput>input").focus().val("");
}
}
}
});
btnOK.unbind(".cmsXExactTelNumberInput");
btnOK.bind("click.cmsXExactTelNumberInput", function () {
opts.inputCompleted.call(jq, _getValue(jq));
});
return { cmsXExactTelNumberInput: jq, numberInputList: numberInputList, btnOK: btnOK };
}
$.fn.cmsXExactTelNumberInput = function (_7be, _7bf) {
if (typeof _7be == "string") {
var _7c0 = $.fn.cmsXExactTelNumberInput.methods[_7be];
if (_7c0) {
return _7c0(this, _7bf);
} else {
return this.cmsXExactTelNumberInput(_7be, _7bf);
}
}
_7be = _7be || {};
return this.each(function () {
var _this = this;
var cacheData = $.data(_this, "cmsXExactTelNumberInput");
if (cacheData) {
$.extend(cacheData.options, _7be);
} else {
cacheData = $.data(_this, "cmsXExactTelNumberInput", { options: $.extend({}, $.fn.cmsXExactTelNumberInput.defaults, $.fn.cmsXExactTelNumberInput.parseOptions(this), _7be) });
var initCacheData = _init(_this);
cacheData = $.data(_this, "cmsXExactTelNumberInput", $.extend({}, cacheData, initCacheData));
}
});
};
function _getValue(jq) {
var opts = $.data(jq, "cmsXExactTelNumberInput").options;
var numberInputList = $.data(jq, "cmsXExactTelNumberInput").numberInputList;
var valueList = [];
numberInputList.each(function () {
if (this.value == "") {
valueList.push("_");
} else {
valueList.push(this.value);
}
});
return valueList.join("");
}
function _reset(jq) {
var numberInputList = $.data(jq, "cmsXExactTelNumberInput").numberInputList;
numberInputList.each(function () {
this.value = "";
});
};
$.fn.cmsXExactTelNumberInput.methods = {
options: function (jq) {
var opts = $.data(jq[0], "cmsXExactTelNumberInput").options;
return opts;
},
getValue: function (jq) {
return _getValue(jq[0]);
},
reset: function (jq) {
jq.each(function () {
_reset(this);
});
}
};
$.fn.cmsXExactTelNumberInput.parseOptions = function (_7c7) {
var t = $(_7c7);
return $.extend({}, $.fn.cmsXExactTelNumberInput.defaults, $.parser.parseOptions(_7c7, ["valueField", "textField"]));
};
$.fn.cmsXExactTelNumberInput.defaults = {
inputCompleted: function (val) {
//alert("value:" + $(this).cmsXExactTelNumberInput("getValue"));
}
};
})(jQuery);
//2014-02-25 end added by pengbb 新增号码精确查询输入控件
//2014-02-25 begin added by pengbb 新增已选条件控件 cmsXSelectedCondition
(function ($) {
$.parser.plugins.push("cmsXSelectedCondition");
function _init(jq) {
var opts = $.data(jq, "cmsXSelectedCondition").options;
var _jqThis = $(jq);
var selectedConditionPanel = _jqThis.find(".selectedConditionPanel");
var conditionTool = selectedConditionPanel.find("li.conditionTool");
var conditionItemPanel = selectedConditionPanel;
var btnReset = conditionTool.find("table.xbutton_reset");
var btnQuery = conditionTool.find("table.xbutton_query");
btnReset.unbind(".cmsXSelectedCondition");
btnReset.bind("click.cmsXSelectedCondition", function () {
conditionItemPanel.find(">li.conditionItem").remove();
conditionItemPanel.trigger("onItemChanged");
opts.onReset.call(jq);
});
btnQuery.unbind(".cmsXSelectedCondition");
btnQuery.bind("click.cmsXSelectedCondition", function () {
var formDataJson = _getConditionJson(jq);
opts.onQuery.call(jq, formDataJson);
});
conditionItemPanel.find(">li.conditionItem i").die(".cmsXSelectedCondition");
conditionItemPanel.find(">li.conditionItem i").live("click.cmsXSelectedCondition", function () {
var li = $(this).closest("li");
li.remove();
var d = new Object();
d.name = li.attr("conditionName");
d.value = li.attr("conditionValue");
opts.onConditionRemoved.call(jq, d);
conditionItemPanel.trigger("onItemChanged");
});
conditionItemPanel.unbind("onItemChanged.cmsXSelectedCondition");
conditionItemPanel.bind("onItemChanged.cmsXSelectedCondition", function () {
var formDataJson = _getConditionJson(jq);
opts.onConditionChanged.call(jq, formDataJson);
});
//$('百万号段:全部 ').appendTo(conditionItemPanel);
return { cmsXSelectedCondition: jq, selectedConditionPanel: selectedConditionPanel, conditionItemPanel: conditionItemPanel, conditionTool: conditionTool, btnQuery: btnQuery, btnReset: btnReset };
}
$.fn.cmsXSelectedCondition = function (_7be, _7bf) {
if (typeof _7be == "string") {
var _7c0 = $.fn.cmsXSelectedCondition.methods[_7be];
if (_7c0) {
return _7c0(this, _7bf);
} else {
return this.cmsXSelectedCondition(_7be, _7bf);
}
}
_7be = _7be || {};
return this.each(function () {
var _this = this;
var cacheData = $.data(_this, "cmsXSelectedCondition");
if (cacheData) {
$.extend(cacheData.options, _7be);
} else {
cacheData = $.data(_this, "cmsXSelectedCondition", { options: $.extend({}, $.fn.cmsXSelectedCondition.defaults, $.fn.cmsXSelectedCondition.parseOptions(this), _7be) });
var initCacheData = _init(_this);
cacheData = $.data(_this, "cmsXSelectedCondition", $.extend({}, cacheData, initCacheData));
}
});
};
function _getConditionJson(jq) {
var opts = $.data(jq, "cmsXSelectedCondition").options;
var conditionItemPanel = $.data(jq, "cmsXSelectedCondition").conditionItemPanel;
var formDataJson = new Object();
conditionItemPanel.find("li.conditionItem").each(function () {
var jqItem = $(this);
var d = new Object();
d.name = jqItem.attr("conditionName");
d.value = jqItem.attr("conditionValue");
if (d.name) {
if (formDataJson[d.name]) {
formDataJson[d.name] += "," + d.value;
} else {
formDataJson[d.name] = d.value;
}
}
});
return formDataJson;
}
//condition:{name:'',value:'',text:''}
function _addCondition(jq, condition) {
var opts = $.data(jq, "cmsXSelectedCondition").options;
var conditionItemPanel = $.data(jq, "cmsXSelectedCondition").conditionItemPanel;
if (condition && condition.name && condition.text) {
var newConditionLi = conditionItemPanel.find("li.conditionItem[conditionName='" + condition.name + "']");
if (newConditionLi.length == 0) {
newConditionLi = $('
').appendTo(conditionItemPanel);
}
newConditionLi.attr("conditionName", condition.name);
newConditionLi.attr("conditionValue", condition.value);
newConditionLi.find(">span>p").html(condition.text);
conditionItemPanel.trigger("onItemChanged");
}
}
function _removeCondition(jq, conditionName) {
var opts = $.data(jq, "cmsXSelectedCondition").options;
var conditionItemPanel = $.data(jq, "cmsXSelectedCondition").conditionItemPanel;
var a = conditionItemPanel.find("li.conditionItem[conditionName='" + conditionName + "']");
if (a.length > 0) {
a.remove();
conditionItemPanel.trigger("onItemChanged");
}
}
$.fn.cmsXSelectedCondition.methods = {
options: function (jq) {
var opts = $.data(jq[0], "cmsXSelectedCondition").options;
return opts;
},
getConditionJson: function (jq) {
return _getConditionJson(jq[0]);
},
//condition:{name:'',value:'',text:''}
addCondition: function (jq, condition) {
jq.each(function () {
_addCondition(this, condition);
});
},
removeCondition: function (jq, conditionName) {
jq.each(function () {
_removeCondition(this, conditionName);
});
}
};
$.fn.cmsXSelectedCondition.parseOptions = function (_7c7) {
var t = $(_7c7);
return $.extend({}, $.fn.cmsXSelectedCondition.defaults, $.parser.parseOptions(_7c7, ["valueField", "textField"]));
};
$.fn.cmsXSelectedCondition.defaults = {
onConditionChanged: function (formDataJson) {
//alert("onConditionChanged:" + JSON.stringify(formDataJson));
},
onQuery: function (formDataJson) {
//alert("onQuery:" + JSON.stringify(formDataJson));
},
onConditionRemoved: function (removedCondition) {
},
onReset: function () {
}
};
})(jQuery);
//2014-02-25 end added by pengbb 新增已选条件控件
//2014-02-28 begin added by pengbb 新增cmsXDataTable
(function ($) {
$.parser.plugins.push("cmsXDataTable");
function _init(jq) {
var opts = $.data(jq, "cmsXDataTable").options;
var _jqThis = $(jq);
var header = _jqThis.find(">div.xDataTable_bodyPanel .xDataTableHeader");
var table = _jqThis.find(">div.xDataTable_bodyPanel .xDataTable");
var parentCtrl = _jqThis.parent();
var totalWidth = 0;
var columnList = new Array();
var contentContainer = table.parent();
// var container = _jqThis.find(".xDataTable_container");
// container.scroll(function () {
// table.find("tr.header").css("top", container.scrollTop());
// });
//初始化列属性
var columnIndex = 0;
header.find("tr.header>th").each(function () {
var jqThColumn = $(this);
var newColumn = $.extend({}, $.fn.cmsXDataTable.column.defaults, $.parser.parseOptions(jqThColumn, []));
// newColumn.columnType = $(this).attr("columnType");
// if(newColumn.columnType)
// newColumn.columnType = newColumn.columnType.replace(/[\']*/g, "");
if (newColumn.validateOption) {
if (newColumn.validateOption.required == "true") {
newColumn.validateOption.required = true;
}
else {
newColumn.validateOption.required = false;
}
}
newColumn.columnIndex = (columnIndex++);
newColumn.element = this;
if (newColumn.columnType == "checkbox") {
jqThColumn.find("input[type='checkbox']").unbind(".cmsXDataTable");
jqThColumn.find("input[type='checkbox']").bind("click.cmsXDataTable", function () {
var isChecked = !!$(this).attr("checked");
var allRow = table.find("tr.row>td[columnIndex='" + newColumn.columnIndex + "'] input[type='checkbox']");
allRow.attr("checked", isChecked);
if (isChecked) {
allRow.closest("tr").addClass("row_selected");
} else {
allRow.closest("tr").removeClass("row_selected");
}
});
table.find("tr.row>td[columnIndex='" + newColumn.columnIndex + "'] input[type='checkbox']").die(".cmsXDataTable");
table.find("tr.row>td[columnIndex='" + newColumn.columnIndex + "'] input[type='checkbox']").live("click.cmsXDataTable", function () {
var isChecked = !!$(this).attr("checked");
if (isChecked) {
$(this).closest("tr").addClass("row_selected");
} else {
$(this).closest("tr").removeClass("row_selected");
}
});
newColumn.width = 24;
}
else {
if (newColumn.width) {
if (newColumn.width < 1) {
newColumn.width = parentCtrl.width() * newColumn.width;
}
} else if (header.find("tr.header>th").length > 0){
newColumn.width = parseInt(parentCtrl.width() / header.find("tr.header>th").length);
}
}
if (newColumn.hidden) {
jqThColumn[0].style.display = "none";
}
jqThColumn.attr('align', newColumn.align);
jqThColumn.css("width", newColumn.width + "px");
totalWidth += newColumn.width;
columnList.push(newColumn);
});
var comboGrid = header.parents('.easyui-combogridX:first');
if (comboGrid.length > 0) {
if ((totalWidth + 24) > 150) {
comboGrid.find('.combogridX-expander').width(totalWidth + 24);
} else {
comboGrid.find('.combogridX-expander').width(150);
}
}
_calMaxSize(jq);
var pagerPanel = _jqThis.find(".xDataTablePanel_pager");
if (opts.pagerType == 0 && opts.pagination) {
pagerPanel.find("input.xDataTablePanel_pager-page-list").unbind("cmsXDataTable");
pagerPanel.find("input.xDataTablePanel_pager-page-list").bind("blur.cmsXDataTable", function () {
opts.pageNumber = 1;
opts.pageSize = $(this).val();
_load(jq, opts.queryParams, false);
});
pagerPanel.find("input.xDataTablePanel_pager-page-list").bind("keydown.cmsXDataTable", function () {
var keyCode = event.keyCode;
if (!((48 <= keyCode && keyCode <= 57) || (96 <= keyCode && keyCode <= 105) || keyCode == 8 || keyCode == 13)) {
return false;
}
});
pagerPanel.find("input.xDataTablePanel_pager-page-list").bind("keyup.cmsXDataTable", function () {
var keyCode = event.keyCode;
if (!((48 <= keyCode && keyCode <= 57) || (96 <= keyCode && keyCode <= 105) || keyCode == 8 || keyCode == 13)) {
return false;
}
if ($(this).val() >= 500) $(this).val(500);
//enter
if (keyCode == 13) {
$(this).blur();
opts.pageNumber = 1;
opts.pageSize = $(this).val();
_load(jq, opts.queryParams, false);
}
});
pagerPanel.find("input.xDataTablePanel_pager-num").unbind("cmsXDataTable");
pagerPanel.find("input.xDataTablePanel_pager-num").bind("keydown.cmsXDataTable", function () {
var keyCode = event.keyCode;
if (!((48 <= keyCode && keyCode <= 57) || (96 <= keyCode && keyCode <= 105) || keyCode == 8 || keyCode == 13)) {
return false;
}
});
pagerPanel.find("input.xDataTablePanel_pager-num").bind("keyup.cmsXDataTable", function () {
var keyCode = event.keyCode;
if (!((48 <= keyCode && keyCode <= 57) || (96 <= keyCode && keyCode <= 105) || keyCode == 8 || keyCode == 13)) {
return false;
}
//enter
if (keyCode == 13) {
$(this).blur();
var newPageNumber = $.trim($(this).val());
if (newPageNumber != "") {
opts.pageNumber = parseInt(newPageNumber);
_load(jq, opts.queryParams, false);
}
}
});
var btnPagerFirst = pagerPanel.find("a.pager-first");
btnPagerFirst.unbind("cmsXDataTable");
btnPagerFirst.bind("click.cmsXDataTable", function () {
if ($(this).hasClass("l-btn-disabled")) {
return false;
}
opts.pageNumber = 1;
_load(jq, opts.queryParams, false);
});
var btnPagerPrev = pagerPanel.find("a.pager-prev");
btnPagerPrev.unbind("cmsXDataTable");
btnPagerPrev.bind("click.cmsXDataTable", function () {
if ($(this).hasClass("l-btn-disabled")) {
return false;
}
opts.pageNumber = opts.pageNumber - 1;
_load(jq, opts.queryParams, false);
});
var btnPagerNext = pagerPanel.find("a.pager-next");
btnPagerNext.unbind("cmsXDataTable");
btnPagerNext.bind("click.cmsXDataTable", function () {
if ($(this).hasClass("l-btn-disabled")) {
return false;
}
opts.pageNumber = opts.pageNumber + 1;
_load(jq, opts.queryParams, false);
});
var btnPagerLast = pagerPanel.find("a.pager-last");
btnPagerLast.unbind("cmsXDataTable");
btnPagerLast.bind("click.cmsXDataTable", function () {
if ($(this).hasClass("l-btn-disabled")) {
return false;
}
opts.pageNumber = opts.totalPage;
_load(jq, opts.queryParams, false);
});
} else {
var btnPagerNext = pagerPanel.find(".xDataTablePanel_pager_Simp");
btnPagerNext.unbind("cmsXDataTable");
btnPagerNext.bind("click.cmsXDataTable", function () {
if ($(this).hasClass("l-btn-disabled")) {
return false;
}
opts.pageNumber = opts.pageNumber + 1;
_load(jq, opts.queryParams, false);
});
}
contentContainer.scroll(function() {
var headerContainer = header.parent();
headerContainer.scrollLeft($(this).scrollLeft());
});
return { cmsXDataTable: jq, table: table, totalWidth: totalWidth, header: header, columnList: columnList, pagerPanel: pagerPanel, btnPagerFirst: btnPagerFirst, btnPagerPrev: btnPagerPrev, btnPagerNext: btnPagerNext, btnPagerLast: btnPagerLast };
}
var _loadAll = function (jq, formData) {
var table = $.data(jq, "cmsXDataTable").table;
var opts = $.data(jq, "cmsXDataTable").options;
table.find("tr.row").remove();
opts.data = { total: 0, rows: [] };
_load(jq, formData, true);
};
var _calMaxSize = function (jq) {
var opts = $.data(jq, "cmsXDataTable").options;
if (opts.pagerType == 0) {
var tablePanel = $(jq).find(".xDataTable").parent();
if (opts.maxHeight) {
tablePanel.css("maxHeight", opts.maxHeight + "px");
} else {
var documentHeight = $(document).height();
// var bodyHeigh = $("body").height();
// var bodyTop = $('body').offset().top;
// var tablePanelHeight = tablePanel.height();
var maxHeight = documentHeight - 4 - tablePanel.offset().top - $(jq).find(".xDataTablePanel_pager").height();
//教务系统的特殊情况start
if ($("#BatchModifydiv").length > 0) {
if ($("#BatchModifydiv").css("display") != "none") {
maxHeight += $("#BatchModifydiv").height();
}
}
//教务系统的特殊情况end
// if ((bodyHeigh - tablePanelHeight + maxHeight) > (documentHeight - bodyTop - 30))
// {
// maxHeight = maxHeight - ((bodyHeigh - tablePanelHeight + maxHeight) - (documentHeight - bodyTop - 30));
// }
tablePanel.css("maxHeight", maxHeight + "px");
}
}
};
var _load = function (jq, formData, isLoadAll, orderby, isAsc) {
var opts = $.data(jq, "cmsXDataTable").options;
var table = $.data(jq, "cmsXDataTable").table;
var parent = table.closest(".xDataTable_bodyPanel");
if (!table.css("height") || table.css("height") == "") {
parent.css("height", "100%;");
}
if (typeof (opts.onBeforeLoad) == "function" && opts.onBeforeLoad.call(jq, formData) == false) {
return;
}
//loading msg
if (opts.loadMsg) {
$("
").appendTo(jq).height($(jq).outerHeight());
var msg = $("
").html(opts.loadMsg).appendTo(jq);
msg.css("marginLeft", -msg.outerWidth() / 2);
}
opts.queryParams = formData || opts.queryParams;
if (opts.pagination) {
formData = $.extend({}, opts.queryParams, { page: opts.pageNumber - 1, rows: opts.pageSize });
if (orderby) {
formData = $.extend({}, formData, { OrderBy: orderby, IsAsc: isAsc });
}
} else if (orderby) {
formData = $.extend({}, opts.queryParams, { OrderBy: orderby, IsAsc: isAsc });
}
if (!orderby) {
_clearOrderByAsc(jq);
}
$.ajax({
type: "post", url: opts.url, data: formData, dataType: "json", success: function (data) {
data = $.extend({}, { total: 0, rows: [] }, data);
$(jq).find(".datagrid-mask,.datagrid-mask-msg").remove();
_loadData(jq, data, isLoadAll);
}, error: function (e) {
$(jq).find(".datagrid-mask,.datagrid-mask-msg").remove();
if (typeof (opts.onLoadError) == "function") {
opts.onLoadError.call(jq);
}
}
});
};
var _getHighlightProp = function (jq, rowIndex) {
var opts = $.data(jq, "cmsXDataTable").options;
var row = opts.data.rows[rowIndex];
var result = "";
if (opts.rowHighlightColor) {
if (opts.rowHighlightFun) {
if (opts.rowHighlightFun.call(this, rowIndex, row)) {
result = " style=\"background-color: " + opts.rowHighlightColor + "\"";
}
}
}
return result;
}
var _loadData = function (jq, data, isLoadAll) {
var opts = $.data(jq, "cmsXDataTable").options;
var header = $.data(jq, "cmsXDataTable").header;
var table = $.data(jq, "cmsXDataTable").table;
var totalWidth = $.data(jq, "cmsXDataTable").totalWidth;
var columnList = $.data(jq, "cmsXDataTable").columnList;
var pagerPanel = $.data(jq, "cmsXDataTable").pagerPanel;
var btnPagerFirst = $.data(jq, "cmsXDataTable").btnPagerFirst;
var btnPagerPrev = $.data(jq, "cmsXDataTable").btnPagerPrev;
var btnPagerNext = $.data(jq, "cmsXDataTable").btnPagerNext;
var btnPagerLast = $.data(jq, "cmsXDataTable").btnPagerLast;
var tableid = table.closest(".easyui-cmsXDataTable").attr("id");
var tableDataHidden = $("#" + tableid + "_datajson");
var treeColumn;
$.each(columnList, function () {
if (this.columnType == 'tree') {
treeColumn = this;
return false;
}
});
if (treeColumn) {
var tmpRows = new Array();
_orderDataForTree(data.rows, treeColumn.field, treeColumn.parentIDField, treeColumn.orderByField, tmpRows);
data.rows = tmpRows;
}
if (opts.pagerType == 0 || !opts.data || isLoadAll) {
//这两句的顺序可不能错,remove的时候原来会触发textbox的propertychange事件,
//因为暂时没办法阻止这个触发,只好让它触发够了再重新赋值……
table.find("tr.row").remove();
opts.data = data;
} else {
for (var i = 0; i < data.rows.length; i++) {
opts.data.rows.push(data.rows[i]);
}
}
if (opts.isPostBack)
tableDataHidden.val(JSON.stringify(opts.data));
var deep = 0;
$.each(data.rows, function (rowIndex) {
var rowData = this;
var tdHtmlList = [];
var realRowIndex = rowIndex;
if (opts.pagerType == 1 && opts.pagination) {
realRowIndex += (opts.pageNumber - 1) * opts.pageSize;
}
//add by heyw,增加扩展行开始
//正常行增加一列,并带有展开按钮
if (opts.hasSubRow == true) {
if (opts.expandOnLoad == true) {
tdHtmlList.push("".concat('
'));
}
else {
tdHtmlList.push("".concat('
'));
}
}
//add by heyw,增加扩展行结束
$.each(columnList, function () {
var columnOpts = this;
var tdStyle = "width:" + parseInt(columnOpts.width) + "px;";
if (opts.hasSubRow == true && columnOpts.field == "") { return; }
if (columnOpts.hidden) {
tdStyle = "display:none;";
}
if (columnOpts.columnType == "checkbox") {
tdHtmlList.push("".concat(' '));
var selectAll = $(header.find('.header th').get(columnOpts.columnIndex)).find('input[type="checkbox"]');
selectAll.removeAttr("checked");
} else if (columnOpts.columnType == "radiobox") {
var controlName = columnOpts.field;
if (columnOpts.customName && columnOpts.customName != "") {
controlName = columnOpts.customName;
}
tdHtmlList.push("".concat(' '));
} else if (columnOpts.columnType == "checkbutton") {
tdHtmlList.push("".concat(' '));
} else if (columnOpts.columnType == "imagebutton") {
tdHtmlList.push("".concat(' '));
tdHtmlList.push("".concat(' '));
} else if (columnOpts.columnType == "textbox" || columnOpts.columnType == "triggerbox") {
var formatterValue = columnOpts.formatter.call(jq, eval("rowData." + columnOpts.field), rowData, rowIndex, columnOpts.overflowlength);
if (formatterValue != 0) {
formatterValue = formatterValue || "";
}
if (!columnOpts.isMultiline) {
tdHtmlList.push("".concat(' '));
} else {
tdHtmlList.push("".concat(' '));
}
} else if (columnOpts.columnType == "dropdownlist" || columnOpts.columnType == "dictionary") {
tdHtmlList.push("".concat(''));
tdHtmlList.push("".concat(' '));
tdHtmlList.push("".concat(' '));
} else if (columnOpts.columnType == "autocomplete") {
tdHtmlList.push("".concat(''));
tdHtmlList.push("".concat(' '));
tdHtmlList.push("".concat(' '));
tdHtmlList.push("".concat(' '));
} else if (columnOpts.columnType == "tree") {
var fullID = _getFullID(data.rows, rowData, columnOpts.parentIDField, columnOpts.field);
deep = fullID.split('.').length - 1;
tdHtmlList.push("".concat('', _treeFormatter(columnOpts, rowData, data.rows[rowIndex + 1], deep), ' '));
} else {
var formatterValue = columnOpts.formatter.call(jq, eval("rowData." + columnOpts.field), rowData, rowIndex, columnOpts.overflowlength, columnOpts.emptyText);
if (formatterValue != 0) {
formatterValue = formatterValue || columnOpts.defaultValue;
}
var titleValue;
if (!columnOpts.columnType) {
titleValue = eval("rowData." + columnOpts.field) == null ? '' : columnOpts.formatter.call(jq, eval("rowData." + columnOpts.field), rowData, rowIndex, 0, columnOpts.emptyText);
if (titleValue != 0) {
titleValue = titleValue || columnOpts.defaultValue;
}
} else {
titleValue = eval("rowData." + columnOpts.field) == null ? '' : eval("rowData." + columnOpts.field);
}
if (titleValue.toString().indexOf('<') >= 0) {
titleValue = eval("rowData." + columnOpts.field) == null ? '' : eval("rowData." + columnOpts.field);
}
tdHtmlList.push("".concat('', formatterValue, ' '));
}
});
var rowStyle = opts.rowStyle.call(jq, realRowIndex, rowData);
var highlightProp = _getHighlightProp(jq, rowIndex);
if (realRowIndex % 2 == 0) {
$(''.concat('', tdHtmlList.join(""), ' ')).appendTo(table);
} else {
$(''.concat('', tdHtmlList.join(""), ' ')).appendTo(table);
}
//add by heyw,增加扩展行开始
//填写扩展行内容
if (opts.hasSubRow == true) {
var subRowHtml = opts.subRowFomatter(rowData, rowIndex);
if (opts.expandOnLoad == true) {
$(''.concat('', subRowHtml, ' ')).appendTo(table);
}
else {
$(''.concat('', subRowHtml, ' ')).appendTo(table);
}
}
//add by heyw,增加扩展行结束
});
//add by heyw,增加扩展行开始
//绑定展开按钮事件
table.find("tr.row>td>div.subrow-expander").each(function () {
this.onclick = function () {
var subRow = table.find("tr.row[rowIndex=" + $(this).attr("rowIndex") + "]");
var oldDisplay = subRow.css("display");
if (oldDisplay == "none") {
subRow.css("display", "");
$(this).attr("class", "tree-expanded");
}
else {
subRow.css("display", "none");
$(this).attr("class", "tree-collapsed");
}
}
});
if (opts.isMouseOverHighlight) {
table.find("tr.row").mouseover(function() {
$(this).css("background-color", opts.rowHighlightColor);
$(this).find("td").css("background-color", opts.rowHighlightColor);
$(this).bind("mouseout.hightlight", function() {
$(this).css("background-color", "");
$(this).find("td").css("background-color", "");
$(this).unbind("mouseout.hightlight");
});
});
}
if (opts.checkOnSelect) {
var checkboxColumnIndexList = $.map(
$.grep(columnList, function (x){ return x.columnType == "checkbox"; }),
function(x) { return x.columnIndex; });
table.find('tr.row').click(function() {
if (event.srcElement.type == "checkbox") return;
for (var i = 0; i < checkboxColumnIndexList.length; i ++) {
var checkboxList = $(this).find('td[columnIndex=' + checkboxColumnIndexList[i] + '] input[type="checkbox"]');
for (var j = 0; j < checkboxList.length; j ++) {
checkbox = $(checkboxList[j]);
var isChecked = !checkbox.attr("checked");
checkbox.attr("checked", isChecked);
if (isChecked) {
$(this).addClass("row_selected");
} else {
$(this).removeClass("row_selected");
}
}
}
});
}
if (opts.onClickRow) {
table.find('tr.row').css("cursor", "pointer").click(function () {
var grid = $(this).parents('.easyui-cmsXDataTable:first');
var gridOpts = $.data(grid[0], "cmsXDataTable").options;
var gridData = gridOpts.data;
var rowIndex = parseInt($(this).attr("xRowIndex"));
var rowData = gridData.rows[rowIndex];
opts.onClickRow.call(grid, rowIndex, rowData);
});
}
if (opts.onDblClickRow) {
table.find('tr.row').css("cursor", "pointer").dblclick(function () {
var grid = $(this).parents('.easyui-cmsXDataTable:first');
var gridOpts = $.data(grid[0], "cmsXDataTable").options;
var gridData = gridOpts.data;
var rowIndex = parseInt($(this).attr("xRowIndex"));
var rowData = gridData.rows[rowIndex];
opts.onDblClickRow.call(grid, rowIndex, rowData);
});
}
//add by heyw,增加扩展行结束
//add by heyw,创建自定义控件开始
_createTableControls(jq);
//add by heyw,创建自定义控件结束
opts.totalPage = Math.ceil(opts.data.total / opts.pageSize);
if (opts.pagerType == 0 && opts.pagination) {
btnPagerFirst.removeClass("l-btn-disabled");
btnPagerPrev.removeClass("l-btn-disabled");
btnPagerNext.removeClass("l-btn-disabled");
btnPagerLast.removeClass("l-btn-disabled");
if (opts.pageNumber == 1) {
btnPagerFirst.addClass("l-btn-disabled");
btnPagerPrev.addClass("l-btn-disabled");
}
if (opts.pageNumber >= opts.totalPage) {
btnPagerNext.addClass("l-btn-disabled");
btnPagerLast.addClass("l-btn-disabled");
}
pagerPanel.find("input.xDataTablePanel_pager-num").val(opts.pageNumber);
pagerPanel.find(".xDataTablePanel_pager-totalInfo").html("共" + opts.totalPage + "页");
pagerPanel.find(".xDataTablePanel_pager_info").html("显示" + ((opts.pageNumber - 1) * opts.pageSize + 1) + "到" + ((opts.pageNumber - 1) * opts.pageSize + data.rows.length) + ",共" + data.total + "条记录");
} else {
pagerPanel.find(".xDataTablePanel_pager_Simp").removeClass("l-btn-disabled");
if (opts.pageNumber >= opts.totalPage) {
pagerPanel.find(".xDataTablePanel_pager_Simp").addClass("l-btn-disabled");
}
}
if (typeof (opts.onLoadSuccess) == "function") {
opts.onLoadSuccess.call(jq, data);
}
if (opts.isAutoHeight) {
if (table.parent().height() < table.height()) {
table.parent().height(table.height());
}
if (table[0].offsetWidth > table.parent()[0].offsetWidth) {
table.parent().height(table.height() + 16);
}
}
var firstRow = table.find("tr");
if (firstRow.length > 0) { //一行都没有一般就不会错位
header.find("tr.header>th").each(function(i, v) {
var width = $($(firstRow[0]).find("td")[i]).width();
$(this).width(width);
});
}
};
var _getFullID = function (dataRows, rowData, parentField, idField) {
var id = rowData[idField];
if (!rowData[parentField]) return id;
var parentData = $.grep(dataRows, function (v) { return v[idField] == rowData[parentField]; })[0];
return id + "." + _getFullID(dataRows, parentData, parentField, idField);
};
var _generalComparer = function (a, b) {
if (a == null && b == null) {
return 0;
}
else if (a == null) {
return -1;
}
else if (b == null) {
return 1;
}
else if (a == b) {
return 0;
}
else if (a > b) {
return 1;
}
else {
return -1;
}
};
var _orderDataForTree = function (dataRows, idField, parentField, orderField, result) {
var topRows = $.grep(dataRows, function (v) { return v[parentField] == null; })
.sort(function (a, b) { return _generalComparer(a[orderField], b[orderField]); });
$.each(topRows, function (i, v) {
result.push(v);
_pushChild(dataRows, v, idField, parentField, orderField, result);
})
};
var _pushChild = function (dataRows, value, idField, parentField, orderField, result) {
var childRows = $.grep(dataRows, function (v) { return v[parentField] == value[idField]; })
.sort(function (a, b) { return _generalComparer(a[orderField], b[orderField]); });
$.each(childRows, function (i, v) {
result.push(v);
_pushChild(dataRows, v, idField, parentField, orderField, result);
});
};
var _treeFormatter = function (columnOpts, rowData, nextRowData, deep) {
var html = new Array();
var i;
for (i = 0; i < deep; i++) {
html.push(' ');
}
//有无子集
if (nextRowData && eval("nextRowData." + columnOpts.parentIDField) == eval("rowData." + columnOpts.field)) {
html.push(' ');
}
else {
html.push(' ');
}
html.push(' ');
html.push('' + rowData[columnOpts.textField] + ' ');
return html.join('');
};
var _getRealRowIndex = function (opts, rowIndex) {
var realRowIndex = rowIndex;
if (opts.pagerType == 1 && opts.pagination) {
realRowIndex += (opts.pageNumber - 1) * opts.pageSize;
}
return realRowIndex;
}
var _createTableControls = function (jq) {
var opts = $.data(jq, "cmsXDataTable").options;
var table = $.data(jq, "cmsXDataTable").table;
var columnList = $.data(jq, "cmsXDataTable").columnList;
$.each(columnList, function () {
var columnOpts = this;
var columnIndex = columnOpts.columnIndex;
var isEditableColumn = true;
if (columnOpts.columnType == "autocomplete") {
_createAutoCompleteControl(columnOpts, table);
}
else if (columnOpts.columnType == "textbox" && !columnOpts.isMultiline) {
_createTextBoxControl(columnOpts, table);
}
else if (columnOpts.columnType == "textbox" && columnOpts.isMultiline) {
_createMultilineControl(columnOpts, table);
}
else if (columnOpts.columnType == "triggerbox") {
_createTriggerBoxControl(columnOpts, table);
}
else if (columnOpts.columnType == "radiobox") {
_createRadioBoxControl(columnOpts, table);
}
else if (columnOpts.columnType == "checkbutton") {
_createCheckButtonControl(columnOpts, table);
}
else if (columnOpts.columnType == "dropdownlist") {
_createDropdownControl(columnOpts, table);
}
else if (columnOpts.columnType == "dictionary") {
_createDictionaryControl(columnOpts, table);
}
else if (columnOpts.columnType == "tree") {
isEditableColumn = false;
_createTreeControl(columnOpts, table);
}
else if (columnOpts.columnType == "linkbutton" || columnOpts.columnType == "imagebutton") {
var enableFieldName = columnOpts.enableFieldName;
if (enableFieldName && enableFieldName != "") {
$.each(opts.data.rows, function (index, rowData) {
var realRowIndex = _getRealRowIndex(opts, index);
var tableRow = table.find("tr.row[xRowIndex=" + realRowIndex.toString() + "]");
if (!eval("rowData." + enableFieldName)) {
//$(tableRow.find("td")[columnIndex]).html($(tableRow.find("td")[columnIndex]).text());
$(tableRow.find("td")[columnIndex]).find('*').attr("disabled", "disabled");
$(tableRow.find("td")[columnIndex]).find('*').addClass("disabledLink");
}
});
}
var visibleFieldName = columnOpts.visibleFieldName;
if (visibleFieldName && visibleFieldName != "") {
$.each(opts.data.rows, function (index, rowData) {
var realRowIndex = _getRealRowIndex(opts, index);
var tableRow = table.find("tr.row[xRowIndex=" + realRowIndex.toString() + "]");
if (!eval("rowData." + visibleFieldName)) {
$(tableRow.find("td")[columnIndex]).html(" ");
}
});
}
isEditableColumn = false;
}
else {
isEditableColumn = false;
}
if (isEditableColumn) {
var enableFieldName = columnOpts.enableFieldName;
if (enableFieldName && enableFieldName != "") {
$.each(opts.data.rows, function (index, rowData) {
var realRowIndex = _getRealRowIndex(opts, index);
var tableRow = table.find("tr.row[xRowIndex=" + realRowIndex.toString() + "]");
if (eval("!rowData." + enableFieldName)) {
$(tableRow.find("td")[columnIndex]).children().attr("disabled", "disabled");
}
});
}
var visibleFieldName = columnOpts.visibleFieldName;
if (visibleFieldName && visibleFieldName != "") {
$.each(opts.data.rows, function (index, rowData) {
var realRowIndex = _getRealRowIndex(opts, index);
var tableRow = table.find("tr.row[xRowIndex=" + realRowIndex.toString() + "]");
if (eval("!rowData." + visibleFieldName)) {
$(tableRow.find("td")[columnIndex]).children().css("display", "none");
}
});
}
}
});
};
var _createTreeControl = function (columnOpts, table) {
$(table).find(".tree-hit").each(function () {
$(this).mouseover(function (e) {
if ($(e.target).hasClass("tree-expanded"))
$(e.target).addClass("tree-expanded-hover");
else
$(e.target).addClass("tree-collapsed-hover");
});
$(this).mouseout(function (e) {
if ($(e.target).hasClass("tree-expanded-hover"))
$(e.target).removeClass("tree-expanded-hover");
else
$(e.target).removeClass("tree-collapsed-hover");
});
$(this).click(function (e) {
if ($(e.target).hasClass("tree-expanded-hover")) {
$(e.target).removeClass("tree-expanded");
$(e.target).removeClass("tree-expanded-hover");
$(e.target).addClass("tree-collapsed");
$(e.target).addClass("tree-collapsed-hover");
}
else {
$(e.target).removeClass("tree-collapsed");
$(e.target).removeClass("tree-collapsed-hover");
$(e.target).addClass("tree-expanded");
$(e.target).addClass("tree-expanded-hover");
}
var childRows = $(table).find("td[fullTreeID$='" + $(e.target).parent().attr("fullTreeID") + "']");
childRows = $.grep(childRows, function (v) {
return $(v).attr("fullTreeID") != $(e.target).parent().attr("fullTreeID");
});
$.each(childRows, function () {
if ($(this).parent().css("display") == "none") {
$(this).parent().css("display", "");
} else {
$(this).parent().css("display", "none");
}
});
});
});
};
var _createTextBoxControl = function (columnOpts, table) {
$(table).find("tr").each(function () {
if ($(this).find("th").length > 0) return true;
var rowIndex = $(this).attr("xRowIndex");
var textControl = $($(this).find("td")[columnOpts.columnIndex]).find('input');
textControl.on('input propertychange', function (e) {
var textValue;
if (!columnOpts.validateOption) {
textValue = $(this).val();
} else {
switch (columnOpts.validateOption.validType) {
case "onlyMoney" :
case "onlyDiscount" :
case "onlyNumber" :
if (isNaN($(this).val())) {
textValue = null;
} else {
textValue = parseFloat($(this).val());
}
break;
default :
textValue = $(this).val();
break;
}
}
_changeDataJson(table, rowIndex, columnOpts.field, textValue, columnOpts);
});
if (columnOpts.validateOption) {
textControl.validatebox(columnOpts.validateOption);
}
});
};
var _createMultilineControl = function (columnOpts, table) {
$(table).find("tr").each(function () {
if ($(this).find("th").length > 0) return true;
var rowIndex = $(this).attr("xRowIndex");
var textControl = $($(this).find("td")[columnOpts.columnIndex]).find('textarea');
textControl.on('textarea propertychange', function (e) {
var textValue;
if (!columnOpts.validateOption) {
textValue = $(this).val();
} else {
switch (columnOpts.validateOption.validType) {
case "onlyMoney" :
case "onlyDiscount" :
case "onlyNumber" :
if (isNaN($(this).val())) {
textValue = null;
} else {
textValue = parseFloat($(this).val());
}
break;
default :
textValue = $(this).val();
break;
}
}
_changeDataJson(table, rowIndex, columnOpts.field, textValue, columnOpts);
});
if (columnOpts.validateOption) {
textControl.validatebox(columnOpts.validateOption);
}
});
};
var _createTriggerBoxControl = function (columnOpts, table) {
$(table).find("tr").each(function () {
if ($(this).find("th").length > 0) return true;
var rowIndex = $(this).attr("xRowIndex");
var textControl = $($(this).find("td")[columnOpts.columnIndex]).find('input');
var jq = table.closest(".easyui-cmsXDataTable")[0];
var opts = $.data(jq, "cmsXDataTable").options;
textControl.triggerbox({
valueField: columnOpts.targetField,
textField: columnOpts.targetTextField,
separator: ",",
editable: true,
postData: {},
change: function () {
var selectedData = $(this).triggerbox("getData");
if (selectedData.length > 0) {
var value;
if (Object.prototype.toString.call(opts.data.rows[rowIndex][columnOpts.field]) === "[object Array]") {
value = selectedData;
} else {
value = $.map(selectedData, function(x) { return x[columnOpts.targetField];}).join(',');
}
var text = $.map(selectedData, function(x) { return x[columnOpts.targetTextField];}).join(',');
_changeDataJson(table, rowIndex, columnOpts.field, value, columnOpts);
_changeDataJson(table, rowIndex, columnOpts.textfield, text, columnOpts);
} else {
if (Object.prototype.toString.call(opts.data.rows[rowIndex][columnOpts.field]) === "[object Array]") {
_changeDataJson(table, rowIndex, columnOpts.field, [], columnOpts);
} else {
_changeDataJson(table, rowIndex, columnOpts.field, null, columnOpts);
}
_changeDataJson(table, rowIndex, columnOpts.textfield, null, columnOpts);
}
},
onSearch: columnOpts.triggerHandle
});
var newArray = new Array();
var newObj = new Object();
if (Object.prototype.toString.call(opts.data.rows[rowIndex][columnOpts.field]) === "[object Array]") {
newArray = opts.data.rows[rowIndex][columnOpts.field];
} else {
newObj[columnOpts.targetField] = opts.data.rows[rowIndex][columnOpts.field];
newObj[columnOpts.targetTextField] = opts.data.rows[rowIndex][columnOpts.textfield];
newArray.push(newObj);
}
textControl.triggerbox('setValue', newArray);
});
}
var _createRadioBoxControl = function (columnOpts, table) {
$(table).find("tr").each(function () {
if ($(this).find("th").length > 0) return true;
var rowIndex = $(this).attr("xRowIndex");
var radioControl = $($(this).find("td")[columnOpts.columnIndex]).find('input');
radioControl.click(function () {
_changeDataJson(table, rowIndex, columnOpts.field, $(this).val(), columnOpts);
});
});
};
var _createCheckButtonControl = function (columnOpts, table) {
$(table).find("tr").each(function () {
if ($(this).find("th").length > 0) return true;
var rowIndex = $(this).attr("xRowIndex");
var checkButtonControl = $($(this).find("td")[columnOpts.columnIndex]).find('input');
checkButtonControl.click(function () {
_changeDataJson(table, rowIndex, columnOpts.field, $(this).prop("checked"), columnOpts);
});
});
};
var _createDropdownControl = function (columnOpts, table) {
var jq = table.closest(".easyui-cmsXDataTable")[0];
var opts = $.data(jq, "cmsXDataTable").options;
$.ajax({
// try to leverage ajaxQueue plugin to abort previous requests
mode: "abort",
// limit abortion to this input
dataType: "json",
url: columnOpts.url,
data: $.extend({
bindType: 0
}, {}),
success: function (data) {
if (data && data.length) {
$(table).find("tr").each(function () {
if ($(this).find("th").length > 0) return true;
var rowIndex = $(this).attr("xRowIndex");
var selectControl = $($(this).find("td")[columnOpts.columnIndex]).find('select');
selectControl.empty();
$("---请选择--- ").appendTo(selectControl);
$.each(data, function () {
if (this[columnOpts.valueField] == eval("opts.data.rows[rowIndex]." + columnOpts.fieldname)) {
$("" + this[columnOpts.textField] + " ").appendTo(selectControl);
} else {
$("" + this[columnOpts.textField] + " ").appendTo(selectControl);
}
});
$(selectControl).bind("click", function () {
var selectedValue = $(this).val();
if (selectedValue == "-1") selectedValue = null;
_changeDataJson(table, rowIndex, columnOpts.fieldname, selectedValue, columnOpts);
});
if (columnOpts.validateOption) {
$(selectControl).validatebox(columnOpts.validateOption);
}
});
}
}
});
};
var _createDictionaryControl = function (columnOpts, table) {
var jq = table.closest(".easyui-cmsXDataTable")[0];
var opts = $.data(jq, "cmsXDataTable").options;
var dictionaryCode = columnOpts.dictionaryCode;
if (dictionaryCode && dictionaryCode != "") {
$.post(CMS_SystemConfig.VirtualDirectoryPath + '/Common/DictionaryDropDown', { bindType: 0, dictionaryCode: dictionaryCode }, function (dictionaryData) {
$(table).find("tr").each(function () {
if ($(this).find("th").length > 0) return true; //跳过标题行
var rowIndex = $(this).attr("xRowIndex");
var selectControl = $($(this).find("td")[columnOpts.columnIndex]).find('select');
selectControl.empty();
$.each(dictionaryData, function () {
if (this.Value == opts.data.rows[rowIndex][columnOpts.fieldname]) {
$("" + this.Text + " ").appendTo(selectControl);
} else {
$("" + this.Text + " ").appendTo(selectControl);
}
});
$(selectControl).bind("click", function () {
var selectedValue = $(this).val();
if (selectedValue == "-1") selectedValue = null;
_changeDataJson(table, rowIndex, columnOpts.fieldname, selectedValue, columnOpts);
});
if (columnOpts.validateOption) {
$(selectControl).validatebox(columnOpts.validateOption);
}
});
});
}
};
var _createAutoCompleteControl = function (columnOpts, table) {
var top = 10;
//这里开始要修改成一次过读出数据……
$.ajax({
// try to leverage ajaxQueue plugin to abort previous requests
mode: "abort",
// limit abortion to this input
dataType: "json",
url: columnOpts.url,
data: $.extend({
q: "",
limit: 99999
}, {}),
success: function (data) {
if (data && data.length) {
$(table).find("tr").each(function () {
if ($(this).find("th").length > 0) return true;
var rowIndex = $(this).attr("xRowIndex");
var textControl = $($(this).find("td")[columnOpts.columnIndex]).find('input[type="text"]');
var valueBox = $($(this).find("td")[columnOpts.columnIndex]).find('input[type="hidden"]');
$.each(data, function () {
if (this[columnOpts.valueField].toString() == $(valueBox).val()) {
$(textControl).val(this[columnOpts.textField]);
}
});
$(textControl).autocomplete(data, {
max: top,
minChars: 1,
width: columnOpts.width,
scrollHeight: columnOpts.scrollHeight,
matchContains: columnOpts.matchContains,
mustMatch: columnOpts.mustMatch,
cacheLength: 99999, //1- 无缓存
autoFill: columnOpts.autoFill,
dataType: 'json',
parse: function (data) {
var parsed = [];
for (var i = 0; i < data.length; i++) {
parsed[parsed.length] = {
data: data[i],
value: data[i][columnOpts.valueField].toString(),
result: data[i][columnOpts.textField]
};
}
return parsed;
},
formatItem: columnOpts.formatter,
formatMatch: function (row, i, max) {
return row[columnOpts.textField];
},
formatResult: function (row) {
$(valueBox).val(row[columnOpts.valueField]);
_changeDataJson(table, rowIndex, columnOpts.fieldname, row[columnOpts.valueField], columnOpts);
return row[columnOpts.textField];
}
});
if (columnOpts.validateOption) {
$(textControl).validatebox(columnOpts.validateOption);
}
});
}
}
});
}
var _changeDataJson = function (table, rowIndex, fieldName, value, columnOpts) {
var jq = table.closest(".easyui-cmsXDataTable")[0];
var config = $.data(jq, "cmsXDataTable");
var opts = config.options;
if (opts.data.rows.length <= rowIndex) return;
eval("opts.data.rows[rowIndex]." + fieldName + " = value");
//$.data(jq, "cmsXDataTable", config);
if (!opts.isPostBack) return;
var tableid = table.closest(".easyui-cmsXDataTable").attr("id");
var tableDataHidden = $("#" + tableid + "_datajson");
var data = JSON.parse($(tableDataHidden).val());
eval("data.rows[rowIndex]." + fieldName + " = value");
$(tableDataHidden).val(JSON.stringify(data));
if (columnOpts) {
if (columnOpts.onChanged) columnOpts.onChanged.call(columnOpts, rowIndex, data.rows[rowIndex]);
}
};
var _getRowDataByObj = function (jq, obj) {
var rowIndex = parseInt($(obj).closest("tr").attr("xRowIndex"));
var opts = $.data(jq, "cmsXDataTable").options;
var data = opts.data;
return data.rows[rowIndex];
};
var _getRows = function (jq) {
var opts = $.data(jq, "cmsXDataTable").options;
if (!opts.isPostBack)
return opts.data.rows;
else {
var tableid = $(jq).attr("id");
var tableDataHidden = $("#" + tableid + "_datajson");
if (tableDataHidden.val() != "") {
return JSON.parse(tableDataHidden.val()).rows;
} else {
return [];
}
}
};
var _getTotal = function (jq) {
var opts = $.data(jq, "cmsXDataTable").options;
return opts.data.total;
};
var _getSelections = function (jq) {
var opts = $.data(jq, "cmsXDataTable").options;
var table = $.data(jq, "cmsXDataTable").table;
var selectionsList = new Array();
table.find("tr.row_selected").each(function () {
selectionsList.push(opts.data.rows[$(this).attr("xRowIndex")]);
});
return selectionsList;
};
var _clearSelections = function (jq) {
var opts = $.data(jq, "cmsXDataTable").options;
var table = $.data(jq, "cmsXDataTable").table;
var columnList = $.data(jq, "cmsXDataTable").columnList;
var checkboxIndex = 0;
$.each(columnList, function () {
if (this.columnType == "checkbox") {
checkboxIndex = this.columnIndex;
return false;
}
});
table.find("tr.row_selected").removeClass("row_selected").each(function () {
$(this).find(">td[columnIndex='" + checkboxIndex + "']>input[type='checkbox']").attr("checked", false);
});
};
var _deleteSubRowItem = function (jq, delData) {
var tableSettings = $.data(jq, "cmsXDataTable");
var table = $.data(jq, "cmsXDataTable").table;
var opts = tableSettings.options;
var data = opts.data;
var rowIndex = delData.rowIndex;
var delValue = delData.value;
var listElement = delData.listElement;
var valueElement = delData.valueElement;
//debugger;
if (opts.onSubRowItemDelete) {
var deleted = $.grep(data.rows[rowIndex][listElement], function (v, i) {
var elementTree = valueElement.split('.');
var firstElement = elementTree[0];
elementTree.splice(0, 1);
var lastElement = elementTree.join('.');
var expression = 'new Object(v["' + firstElement + '"])';
if (lastElement != "") {
expression += '.' + lastElement;
}
return eval(expression) == delValue;
});
opts.onSubRowItemDelete(deleted[0]);
}
var afterDel = $.grep(data.rows[rowIndex][listElement], function (v, i) {
var elementTree = valueElement.split('.');
var firstElement = elementTree[0];
elementTree.splice(0, 1);
var lastElement = elementTree.join('.');
var expression = 'new Object(v["' + firstElement + '"])';
if (lastElement != "") {
expression += '.' + lastElement;
}
return eval(expression) != delValue;
});
data.rows[rowIndex][listElement] = afterDel;
tableSettings.options.data = data;
$.data(jq, "cmsXDataTable", tableSettings);
if (opts.isPostBack) {
var tableid = table.closest(".easyui-cmsXDataTable").attr("id");
var tableDataHidden = $("#" + tableid + "_datajson");
$(tableDataHidden).val(JSON.stringify(data));
}
tableSettings.table.find("tr.row[rowIndex=" + rowIndex + "]>td").html(opts.subRowFomatter(data.rows[rowIndex], rowIndex));
}
var _clearOrderByAsc = function (jq) {
var headerTable = $(jq).find('.xDataTableHeader');
$.each(headerTable.find('th div a'), function (i, v) {
$(v).attr('asc', '1');
});
}
$.fn.cmsXDataTable = function (_7be, _7bf) {
if (typeof _7be == "string") {
var _7c0 = $.fn.cmsXDataTable.methods[_7be];
if (_7c0) {
return _7c0(this, _7bf);
} else {
return this.cmsXDataTable(_7be, _7bf);
}
}
_7be = _7be || {};
return this.each(function () {
var _this = this;
var cacheData = $.data(_this, "cmsXDataTable");
if (cacheData) {
$.extend(cacheData.options, _7be);
} else {
cacheData = $.data(_this, "cmsXDataTable", { options: $.extend({}, $.fn.cmsXDataTable.defaults, $.fn.cmsXDataTable.parseOptions(this), _7be) });
var initCacheData = _init(_this);
cacheData = $.data(_this, "cmsXDataTable", $.extend({}, cacheData, initCacheData));
}
if (cacheData.options.autoLoad) {
if (cacheData.data && cacheData.data.length > 0) {
_loadData(this, cacheData.data, false);
} else {
var conditionControls = $.grep($("[data-condition='" + this.id + "']"), function(x) {
var opts = $.parser.parseOptions(x, []);
return !$(x).closest("ul").attr("dynamicWhere") && opts.value && opts.value != "" && opts.value != "-1";
});
var isReady = true;
$.each(conditionControls, function (i, x) {
var isCombobox = $(x).hasClass('easyui-combobox');
var isComboGrid = $(x).hasClass('easyui-combogridX');
var comboboxData = $.data(x, 'combobox');
var combogridData = $.data(x, 'combogridX');
if (!isCombobox && !isComboGrid) {
return true;
}
if (isCombobox && !comboboxData) {
isReady = false;
return false;
}
if (isComboGrid && !combogridData) {
isReady = false;
return false;
}
if (comboboxData) {
if (comboboxData.options.value && comboboxData.options.value != ''
&& comboboxData.options.value != '-1' && $(x).next().find(".combo-value").val() == "") {
isReady = false;
return false;
} else {
return true;
}
} else {
if (combogridData.options.value && combogridData.options.value != '' && combogridData.options.value != -1
&& combogridData.options.text != '' && $(x).attr("loaded") != "true") {
isReady = false;
return false;
} else {
return true;
}
}
});
if (isReady && $(this).length > 0 && $.data(this, "cmsXDataTable")) {
var opts = $.data(this, "cmsXDataTable").options;
opts.pageNumber = 1;
_load(this, $.getDataGridParams(this.id), false);
}
}
}
});
};
$.fn.cmsXDataTable.methods = {
options: function (jq) {
var opts = $.data(jq[0], "cmsXDataTable").options;
return opts;
},
load: function (jq, formData) {
jq.each(function () {
var conditionControls = $.grep($("[data-condition='" + this.id + "']"), function(x) {
var opts = $.parser.parseOptions(x, []);
return !$(x).closest("ul").attr("dynamicWhere") && opts.value && opts.value != "" && opts.value != "-1";
});
var isReady = true;
$.each(conditionControls, function (i, x) {
var isCombobox = $(x).hasClass('easyui-combobox');
var isComboGrid = $(x).hasClass('easyui-combogridX');
var comboboxData = $.data(x, 'combobox');
var combogridData = $.data(x, 'combogridX');
if (!isCombobox && !isComboGrid) {
return true;
}
if (isCombobox && !comboboxData) {
isReady = false;
return false;
}
if (isComboGrid && !combogridData) {
isReady = false;
return false;
}
if (comboboxData) {
if (comboboxData.options.value && comboboxData.options.value != ''
&& comboboxData.options.value != '-1' && $(x).next().find(".combo-value").val() == "") {
isReady = false;
return false;
} else {
return true;
}
} else {
if (combogridData.options.value && combogridData.options.value != '' && combogridData.options.value != -1
&& combogridData.options.text != '' && $(x).attr("loaded") != "true") {
isReady = false;
return false;
} else {
return true;
}
}
});
if (isReady && $(this).length > 0 && $.data(this, "cmsXDataTable")) {
var opts = $.data(this, "cmsXDataTable").options;
opts.pageNumber = 1;
_load(this, formData, false);
}
});
},
clearOrderByAsc: function (jq) {
jq.each(function () {
_clearOrderByAsc(this);
});
},
loadNextPage: function (jq) {
jq.each(function () {
var opts = $.data(this, "cmsXDataTable").options;
if (opts.data) {
if (opts.pagerType == 0) {
if ((opts.pageNumber - 1) * opts.pageSize + opts.data.rows.length < opts.data.total) {
opts.pageNumber += 1;
_load(this, opts.queryParams, false);
}
} else if (opts.pagerType == 1) {
if (opts.data.rows.length < opts.data.total) {
opts.pageNumber += 1;
_load(this, opts.queryParams, false);
}
}
}
});
},
loadAll: function (jq, formData) {
jq.each(function () {
var opts = $.data(this, "cmsXDataTable").options;
opts.pageNumber = 1;
_load(this, formData, true);
});
},
reload: function (jq) {
jq.each(function () {
var opts = $.data(this, "cmsXDataTable").options;
opts.pageNumber = 1;
_load(this, null, true);
});
},
orderLoad: function (jq, orderby) {
jq.each(function () {
var opts = $.data(this, "cmsXDataTable").options;
opts.pageNumber = 1;
_load(this, null, true, orderby.field, orderby.isAsc);
});
},
loadData: function (jq, data) {
jq.each(function () {
var opts = $.data(this, "cmsXDataTable").options;
opts.pageNumber = 1;
_loadData(this, data, true);
});
},
getRowDataByObj: function (jq, obj) {
return _getRowDataByObj(jq[0], obj);
},
getRows: function (jq) {
return _getRows(jq[0]);
},
getTotal: function (jq) {
return _getTotal(jq[0]);
},
getSelections: function (jq) {
return _getSelections(jq[0]);
},
clearSelections: function (jq) {
jq.each(function () {
_clearSelections(this);
});
},
deleteSubRowItem: function (jq, delData) {
jq.each(function () {
_deleteSubRowItem(this, delData);
}
);
},
setDataValueByIndex: function (jq, parameters) {
var rowIndex = parameters.rowIndex;
var columnName = parameters.columnName;
var newValue = parameters.newValue;
jq.each(function () {
var opts = $.data(this, "cmsXDataTable").options;
var table = $.data(this, "cmsXDataTable").table;
var columnList = $.data(this, "cmsXDataTable").columnList;
var columnOptsList = $.grep(columnList, function (x) { return x.field == columnName; });
var columnOpts = null;
if (columnOptsList.length > 0) {
columnOpts = $.grep(columnList, function (x) { return x.field == columnName; })[0];
}
_changeDataJson(table, rowIndex, columnName, newValue, columnOpts);
});
},
calMaxSize: function (jq) {
jq.each(function() {
_calMaxSize(this);
});
}
};
$.fn.cmsXDataTable.parseOptions = function (_7c7) {
var t = $(_7c7);
return $.extend({}, $.fn.cmsXDataTable.defaults, $.parser.parseOptions(_7c7, []));
};
$.fn.cmsXDataTable.column = {
defaults: {
defaultValue: ' ',
field: '',
formatter: function (value, row, index) {
return value;
}
}
};
$.fn.cmsXDataTable.defaults = {
pageNumber: 1,
pageSize: 10,
loadMsg: "努力加载中...",
emptyMsg: "",
pagination: true,
autoLoad: true,
rowHighlightColor: null,
isMouseOverHighlight: false,
RowHighlightFun: "true",
isAutoHeight: true,
onSubRowItemDelete: null,
checkOnSelect: true,
rowStyle: function (index, row) {
},
onLoadSuccess: function (data) {
},
onLoadError: function () {
},
onBeforeLoad: function (param) {
},
//暂未实现
onClickRow: function (rowIndex, rowData) {
},
//暂未实现
onDblClickRow: function (rowIndex, rowData) {
},
//暂未实现
onClickCell: function (rowIndex, field, value) {
},
//暂未实现
onDblClickCell: function (rowIndex, field, value) {
}
};
$(window).resize(function () {
$(".cmsXDataTable").cmsXDataTable("calMaxSize");
});
})(jQuery);
//2014-02-28 end added by pengbb 新增cmsXDataTable
//2014-03-25 begin added by pengbb 新增cmsPanel控件
(function ($) {
$.parser.plugins.push("cmsPanel");
function _init(jq) {
var opts = $.data(jq, "cmsPanel").options;
var _jqThis = $(jq);
var isIE6 = false;
if ($.browser.msie) {
if ($.browser.version < 7) {
isIE6 = true;
}
}
var btnCollapsable = _jqThis.find(">div.panel-header>div.panel-tool>a.cmspanel-tool-collapse");
btnCollapsable.unbind(".cmsPanel");
btnCollapsable.bind("click.cmsPanel", function () {
var _this = $(this);
if (_this.hasClass("panel-tool-expand")) {
_this.removeClass("panel-tool-expand");
if (isIE6) {
_jqThis.find("div.panel-body").show();
} else {
_jqThis.find("div.panel-body").slideDown();
}
if (typeof (opts.onExpanded) == "function") {
opts.onExpanded.call(jq);
}
} else {
_this.addClass("panel-tool-expand");
if (isIE6) {
_jqThis.find("div.panel-body").hide();
} else {
_jqThis.find("div.panel-body").slideUp();
}
if (typeof (opts.onExpanded) == "function") {
opts.onCollapsed.call(jq);
}
}
});
return { cmsPanel: jq };
}
$.fn.cmsPanel = function (_7be, _7bf) {
if (typeof _7be == "string") {
var _7c0 = $.fn.cmsPanel.methods[_7be];
if (_7c0) {
return _7c0(this, _7bf);
} else {
return this.cmsPanel(_7be, _7bf);
}
}
_7be = _7be || {};
return this.each(function () {
var _this = this;
var cacheData = $.data(_this, "cmsPanel");
if (cacheData) {
$.extend(cacheData.options, _7be);
} else {
cacheData = $.data(_this, "cmsPanel", { options: $.extend({}, $.fn.cmsPanel.defaults, $.fn.cmsPanel.parseOptions(this), _7be) });
var initCacheData = _init(_this);
cacheData = $.data(_this, "cmsPanel", $.extend({}, cacheData, initCacheData));
}
});
};
$.fn.cmsPanel.methods = {
options: function (jq) {
var opts = $.data(jq[0], "cmsPanel").options;
return opts;
}
};
$.fn.cmsPanel.parseOptions = function (_7c7) {
var t = $(_7c7);
return $.extend({}, $.fn.cmsPanel.defaults, $.parser.parseOptions(_7c7, []));
};
$.fn.cmsPanel.defaults = {
onExpanded: function () {
},
onCollapsed: function () {
}
};
})(jQuery);
//2014-03-25 end added by pengbb 新增cmspanel控件
//2014-03-25 begin added by pengbb 新增cmsMenu控件
(function ($) {
$.parser.plugins.push("cmsMenu");
var isIE6 = false;
if ($.browser.msie) {
if ($.browser.version < 7) {
isIE6 = true;
}
}
function _onMenuClick(jq, clickMenu) {
var opts = $.data(jq, "cmsMenu").options;
var _this = $(clickMenu);
var node = { text: _this.attr("menuTitle"), url: _this.attr("menuUrl"), mnuNo: _this.attr("menuNo") };
if (typeof (opts.onMenuClick) == "function") {
opts.onMenuClick.call(jq, node);
}
}
function _toggleChildMenu(currMenu) {
var menuItemPanel = $(currMenu);
if (!menuItemPanel.hasClass('nav_left_menuitem_expand')) {
menuItemPanel.closest("li").siblings("li").removeClass('gradient');
menuItemPanel.closest("li").siblings("li").find('div.nav_left_menuitem_expand').find(".nav_left_menuitem_right>div").removeClass('down_arrow');
menuItemPanel.closest("li").siblings("li").find('div.nav_left_menuitem_expand').removeClass('nav_left_menuitem_expand');
menuItemPanel.closest("li").siblings("li").find('>div.nav_left_menuitem_childpanel').slideUp("normal");
menuItemPanel.next().next('div.nav_left_menuitem_childpanel').slideDown("normal");
menuItemPanel.closest("li").addClass('gradient');
menuItemPanel.addClass('nav_left_menuitem_expand');
menuItemPanel.find(".nav_left_menuitem_right>div").addClass('down_arrow');
} else {
menuItemPanel.closest("li").removeClass('gradient');
menuItemPanel.next().next('div.nav_left_menuitem_childpanel').slideUp("normal");
menuItemPanel.removeClass('nav_left_menuitem_expand');
menuItemPanel.find(".nav_left_menuitem_right>div").removeClass('down_arrow');
}
}
function _toggleSecondChildMenu(currMenu) {
var menuItemPanel = $(currMenu);
if (!menuItemPanel.hasClass('nav_left_menuitem_second_expand')) {
menuItemPanel.closest("li").siblings("li").find('div.nav_left_menuitem_second_expand').find(".node_plus").removeClass('node_minus');
menuItemPanel.closest("li").siblings("li").find('div.nav_left_menuitem_second_expand').next().next('div.nav_left_menuitem_childpanel').slideUp("normal");
menuItemPanel.closest("li").siblings("li").find('div.nav_left_menuitem_second_expand').removeClass('nav_left_menuitem_second_expand');
menuItemPanel.next().next('div.nav_left_menuitem_childpanel').slideDown("normal");
menuItemPanel.addClass('nav_left_menuitem_second_expand');
menuItemPanel.find(".node_plus").addClass('node_minus');
} else {
menuItemPanel.removeClass('nav_left_menuitem_second_expand');
menuItemPanel.find(".node_plus").removeClass('node_minus');
menuItemPanel.next().next('div.nav_left_menuitem_childpanel').slideUp("normal");
}
}
function _toggleThirdChildMenu(currMenu) {
// var menuItemPanel = $(currMenu);
// if (!menuItemPanel.hasClass('nav_left_menuitem_third_expand')) {
//
// //menuItemPanel.closest("li").siblings("li").find('div.nav_left_menuitem_third_expand').find(".node_plus").removeClass('node_minus');
// menuItemPanel.closest("li").siblings("li").find('div.nav_left_menuitem_third_expand').removeClass('nav_left_menuitem_second_expand');
// menuItemPanel.closest("li").siblings("li").find('div.nav_left_menuitem_third_expand').slideUp("normal");
// menuItemPanel.next().next('div.nav_left_menuitem_childpanel').slideDown("normal");
// menuItemPanel.addClass('nav_left_menuitem_third_expand');
// //menuItemPanel.find(".node_plus").addClass('node_minus');
// } else {
//
// menuItemPanel.removeClass('nav_left_menuitem_third_expand');
// //menuItemPanel.find(".node_plus").removeClass('node_minus');
// menuItemPanel.next().next('div.nav_left_menuitem_childpanel').slideUp("normal");
// }
}
function _init(jq) {
var opts = $.data(jq, "cmsMenu").options;
var _jqThis = $(jq);
//一级菜单
_jqThis.find(".nav_left_menuitem").unbind(".cmsMenu");
_jqThis.find(".nav_left_menuitem").bind("click.cmsMenu",
function (event) {
_toggleChildMenu(this);
_onMenuClick(jq, $(this).find(".nav_left_menuitem_link"));
return false;
}
);
//二级菜单
_jqThis.find(".nav_left_menuitem_second").unbind(".cmsMenu");
_jqThis.find(".nav_left_menuitem_second").bind("click.cmsMenu",
function (event) {
_toggleSecondChildMenu(this);
_onMenuClick(jq, $(this).find(".nav_left_menuitem_link"));
return false;
}
);
//二级菜单hover效果
_jqThis.find(".nav_left_menuitem_second").bind("mouseenter.cmsMenu", function () {
if (!$(this).hasClass("nav_left_menuitem_second_hover")) {
$(this).addClass("nav_left_menuitem_second_hover");
}
});
_jqThis.find(".nav_left_menuitem_second").bind("mouseleave.cmsMenu", function () {
if ($(this).hasClass("nav_left_menuitem_second_hover")) {
$(this).removeClass("nav_left_menuitem_second_hover");
}
});
//三级菜单
_jqThis.find(".nav_left_menuitem_third").unbind(".cmsMenu");
_jqThis.find(".nav_left_menuitem_third").bind("click.cmsMenu",
function (event) {
_toggleThirdChildMenu(this);
_onMenuClick(jq, $(this).find(".nav_left_menuitem_link"));
return false;
}
);
//三级菜单hover效果
_jqThis.find(".nav_left_menuitem_third").bind("mouseenter.cmsMenu", function () {
if (!$(this).hasClass("nav_left_menuitem_third_hover")) {
$(this).addClass("nav_left_menuitem_third_hover");
}
});
_jqThis.find(".nav_left_menuitem_third").bind("mouseleave.cmsMenu", function () {
if ($(this).hasClass("nav_left_menuitem_third_hover")) {
$(this).removeClass("nav_left_menuitem_third_hover");
}
});
return { cmsMenu: jq };
}
$.fn.cmsMenu = function (_7be, _7bf) {
if (typeof _7be == "string") {
var _7c0 = $.fn.cmsMenu.methods[_7be];
if (_7c0) {
return _7c0(this, _7bf);
} else {
return this.cmsMenu(_7be, _7bf);
}
}
_7be = _7be || {};
return this.each(function () {
var _this = this;
var cacheData = $.data(_this, "cmsMenu");
if (cacheData) {
$.extend(cacheData.options, _7be);
} else {
cacheData = $.data(_this, "cmsMenu", { options: $.extend({}, $.fn.cmsMenu.defaults, $.fn.cmsMenu.parseOptions(this), _7be) });
var initCacheData = _init(_this);
cacheData = $.data(_this, "cmsMenu", $.extend({}, cacheData, initCacheData));
}
});
};
$.fn.cmsMenu.methods = {
options: function (jq) {
var opts = $.data(jq[0], "cmsMenu").options;
return opts;
}
};
$.fn.cmsMenu.parseOptions = function (_7c7) {
var t = $(_7c7);
return $.extend({}, $.fn.cmsPanel.defaults, $.parser.parseOptions(_7c7, []));
};
$.fn.cmsMenu.defaults = {
onMenuClick: function (node) { }
};
})(jQuery);
//2014-04-21 end added by pengbb 新增cmsMenu控件
//2014-06-26 begin added by heyw 新增autoComplete控件
(function ($) {
$.parser.plugins.push("autoComplete");
function _init(jq) {
var opts = $.data(jq, "autoComplete").options;
var top = 10;
var _jqThis = $(jq);
var isIE6 = false;
if ($.browser.msie) {
if ($.browser.version < 7) {
isIE6 = true;
}
}
var mainBox = _jqThis;
var valueBox = $("#" + _jqThis.attr("id") + "_value");
$(mainBox).autocomplete(opts.url, {
max: top,
minChars: 1,
width: opts.width,
scrollHeight: opts.scrollHeight,
matchContains: opts.matchContains,
mustMatch: opts.mustMatch,
cacheLength: 50, //1- 无缓存
autoFill: opts.autoFill,
dataType: 'json',
parse: function (data) {
var parsed = [];
for (var i = 0; i < data.length; i++) {
parsed[parsed.length] = {
data: data[i],
value: data[i][opts.valueField].toString(),
result: data[i][opts.textField]
};
}
return parsed;
},
formatItem: opts.formatter,
formatMatch: function (row, i, max) {
return row[opts.textField];
},
formatResult: function (row) {
$(valueBox).val(row[opts.valueField]);
return row[opts.textField];
}
});
if ($(valueBox).val())
mainBox[0].setDefaultValue($(valueBox).val(), opts.textField, opts.valueField);
return { autoComplete: jq };
}
$.fn.autoComplete = function (_7be, _7bf) {
if (typeof _7be == "string") {
var _7c0 = $.fn.autoComplete.methods[_7be];
if (_7c0) {
return _7c0(this, _7bf);
} else {
return this.autoComplete(_7be, _7bf);
}
}
_7be = _7be || {};
return this.each(function () {
var _this = this;
var cacheData = $.data(_this, "autoComplete");
if (cacheData) {
$.extend(cacheData.options, _7be);
} else {
cacheData = $.data(_this, "autoComplete", { options: $.extend({}, $.fn.autoComplete.defaults, $.fn.autoComplete.parseOptions(this), _7be) });
var initCacheData = _init(_this);
cacheData = $.data(_this, "autoComplete", $.extend({}, cacheData, initCacheData));
}
});
};
$.fn.autoComplete.methods = {
options: function (jq) {
var opts = $.data(jq[0], "autoComplete").options;
return opts;
},
setDefaultValue: function (jq, value) {
}
};
$.fn.autoComplete.parseOptions = function (_7c7) {
var t = $(_7c7);
return $.extend({}, $.fn.autoComplete.defaults, $.parser.parseOptions(_7c7, []));
};
$.fn.autoComplete.defaults = {
width: 600,
scrollHeight: 380,
matchContains: true,
mustMatch: true,
autoFill: false,
url: "",
textField: "",
valueField: "",
defaltValue: "",
formatter: function (row, i, max) {
return i;
}
};
})(jQuery);
//2014-06-26 begin added by heyw 新增autoComplete控件
//2014-08-13 begin added by heyw 新增draggableList控件
(function ($) {
$.parser.plugins.push("draggableList");
function _init(jq) {
var opts = $.data(jq, "draggableList").options;
var listID = jq.id;
var div = $("
").appendTo(jq);
$.ajax({
type: "post", url: opts.url, success: function (data) {
var length = 0;
$.each(data, function () {
var htmlList = new Array();
var className = listID + "_" + this[opts.valueField];
htmlList.push("");
if (opts.iconField && opts.iconField != "") {
htmlList.push("
");
}
htmlList.push("
" + this[opts.titleField] + "
");
htmlList.push("
");
var itemElement = $(htmlList.join(""));
itemElement.appendTo(div);
length += itemElement.width();
$("." + className).draggable({
handle: ".draggableTitle",
proxy: "clone",
revert: true,
onDrag: function (e) {
CMSFunction.DragDrop.dragX = e.clientX;
CMSFunction.DragDrop.dragY = e.clientY;
},
onBeforeDrag: function (e) {
CMSFunction.DragDrop.isInnerDrag = false;
CMSFunction.DragDrop.offsetX = e.offsetX + e.srcElement.offsetLeft - e.srcElement.parentElement.offsetLeft;
CMSFunction.DragDrop.offsetY = e.offsetY + e.srcElement.offsetTop - e.srcElement.parentElement.offsetTop;
}
});
});
div.width(length);
//$(jq).height(opts.itemHeight + 16);
}
});
return { draggableList: jq };
}
$.fn.draggableList = function (_7be, _7bf) {
if (typeof _7be == "string") {
var _7c0 = $.fn.draggableList.methods[_7be];
if (_7c0) {
return _7c0(this, _7bf);
} else {
return this.draggableList(_7be, _7bf);
}
}
_7be = _7be || {};
return this.each(function () {
var _this = this;
var cacheData = $.data(_this, "draggableList");
if (cacheData) {
$.extend(cacheData.options, _7be);
} else {
cacheData = $.data(_this, "draggableList", { options: $.extend({}, $.fn.draggableList.defaults, $.fn.draggableList.parseOptions(this), _7be) });
var initCacheData = _init(_this);
cacheData = $.data(_this, "draggableList", $.extend({}, cacheData, initCacheData));
}
});
};
$.fn.draggableList.methods = {
options: function (jq) {
var opts = $.data(jq[0], "draggableList").options;
return opts;
},
setDefaultValue: function (jq, value) {
}
};
$.fn.draggableList.parseOptions = function (_7c7) {
var t = $(_7c7);
return $.extend({}, $.fn.draggableList.defaults, $.parser.parseOptions(_7c7, []));
};
$.fn.draggableList.defaults = {
url: "",
titleField: "",
valueField: "",
iconField: "",
itemHeight: 0,
foreColor: "#000000"
};
})(jQuery);
//2014-08-13 begin added by heyw 新增draggableList控件
//2014-08-18 begin added by heyw 新增droppableContainer控件
(function ($) {
$.parser.plugins.push("droppableContainer");
function _init(jq) {
var opts = $.data(jq, "droppableContainer").options;
var listID = jq.id;
var myLeft = jq.clientLeft;
var myTop = jq.clientTop;
var myWidth = jq.clientWidth;
var myHeight = jq.clientHeight;
document.body.oncontextmenu = function (e) {
e = e || window.event;
var target = e.target || e.srcElement;
if (($(target).hasClass("easyui-draggable") && $(target).parent().hasClass("easyui-droppableContainer"))
|| ($(target).parent().hasClass("easyui-draggable") && $(target).parent().parent().hasClass("easyui-droppableContainer"))) {
CMSFunction.DragDrop.DropContainerItemClick(e);
return false;
}
}
if (opts.url && opts.url != "") {
$.ajax({
type: "post", url: opts.url, success: function (data) {
$.each(data, function () {
var htmlList = new Array();
var className = listID + "_" + this[opts.valueField];
htmlList.push("");
if (opts.iconField && opts.iconField != "") {
htmlList.push("
");
}
htmlList.push("
" + this[opts.titleField] + "
");
htmlList.push("
");
$(htmlList.join("")).appendTo(jq);
$("." + className).draggable({
handle: ".draggableTitle",
onDrag: function (e) {
CMSFunction.DragDrop.dragX = e.clientX;
CMSFunction.DragDrop.dragY = e.clientY;
},
onBeforeDrag: function (e) {
CMSFunction.DragDrop.isInnerDrag = true;
CMSFunction.DragDrop.offsetX = e.offsetX;
CMSFunction.DragDrop.offsetY = e.offsetY;
},
onStopDrag: function (e) {
if (e.clientX < myLeft || e.clientX > myLeft + myWidth || e.clientY < myTop || e.clientY > myTop + myHeight) {
$(e.srcElement).offsetParent().remove();
}
}
});
});
}
});
}
else if (opts.items && opts.items.length > 0) {
$.each(opts.items, function () {
var htmlList = new Array();
var className = listID + "_" + this.value;
htmlList.push("");
if (this.icon && this.icon != "") {
htmlList.push("
");
}
htmlList.push("
" + this.title + "
");
htmlList.push("
");
$(htmlList.join("")).appendTo(jq);
$("." + className).draggable({
handle: ".draggableTitle",
onDrag: function (e) {
CMSFunction.DragDrop.dragX = e.clientX;
CMSFunction.DragDrop.dragY = e.clientY;
},
onBeforeDrag: function (e) {
CMSFunction.DragDrop.isInnerDrag = true;
CMSFunction.DragDrop.offsetX = e.offsetX;
CMSFunction.DragDrop.offsetY = e.offsetY;
},
onStopDrag: function (e) {
if (e.clientX < myLeft || e.clientX > myLeft + myWidth || e.clientY < myTop || e.clientY > myTop + myHeight) {
$(e.srcElement).offsetParent().remove();
}
}
});
});
}
$(jq).droppable({});
var hidden = $(jq).next();
hidden.val('');
$.each($(jq).find('.easyui-draggable'), function () {
var valStr = '';
if (hidden.val() != '') valStr = ',';
var titleDiv = $(this).find('.draggableTitle');
valStr += titleDiv.attr('value') + '|' + titleDiv.html() + '|' + $(this).css('left').replace("px", "") + '|' + $(this).css('top').replace("px", "");
hidden.val(hidden.val() + valStr);
});
return { droppableContainer: jq };
}
$.fn.droppableContainer = function (_7be, _7bf) {
if (typeof _7be == "string") {
var _7c0 = $.fn.droppableContainer.methods[_7be];
if (_7c0) {
return _7c0(this, _7bf);
} else {
return this.droppableContainer(_7be, _7bf);
}
}
_7be = _7be || {};
return this.each(function () {
var _this = this;
var cacheData = $.data(_this, "droppableContainer");
if (cacheData) {
$.extend(cacheData.options, _7be);
} else {
cacheData = $.data(_this, "droppableContainer", { options: $.extend({}, $.fn.droppableContainer.defaults, $.fn.droppableContainer.parseOptions(this), _7be) });
var initCacheData = _init(_this);
cacheData = $.data(_this, "droppableContainer", $.extend({}, cacheData, initCacheData));
}
});
};
$.fn.droppableContainer.methods = {
options: function (jq) {
var opts = $.data(jq[0], "droppableContainer").options;
return opts;
},
getContainerItems: function (jq) {
var hidden = jq.next();
var valStr = hidden.val();
var items = valStr.split(',');
var result = new Array();
$.each(items, function () {
var colVals = this.split('|');
result.push({
Icon: null,
Value: colVals[0],
Title: colVals[1],
Left: parseInt(colVals[2]),
Top: parseInt(colVals[3])
});
});
return result;
}
};
$.fn.droppableContainer.parseOptions = function (_7c7) {
var t = $(_7c7);
return $.extend({}, $.fn.droppableContainer.defaults, $.parser.parseOptions(_7c7, []));
};
$.fn.droppableContainer.defaults = {
title: "",
value: "",
icon: "",
height: 0,
foreColor: "#000000"
};
})(jQuery);
//2014-08-18 begin added by heyw 新增droppableContainer控件
//2015-12-08 begin added by heyw 新增combogridX控件
(function ($) {
$.parser.plugins.push("combogridX");
function _init(jq) {
var opts = $.data(jq, "combogridX").options;
var bubbleKeyup = true;
var oldValue;
var lastScoreHeight = 0;
var expander = $(jq).find(".combogridX-expander");
if (opts.panelWidth) {
$(expander).width(opts.panelWidth);
}
$(document).click(function () {
if ($(event.srcElement).parents(".easyui-combogridX").length == 0) {
$('.combogridX-expander').css("display", "none");
}
});
var gridTable = $(jq).find('.easyui-cmsXDataTable');
var beforeScrollTop = $(gridTable).scrollTop();
$(expander).scroll(function (event) {
event = event || window.event;
var afterScrollTop = $(gridTable).scrollTop;
delta = afterScrollTop - beforeScrollTop;
beforeScrollTop = afterScrollTop;
var scrollTop = $(this).scrollTop();
var scrollHeight = $(gridTable).height();
var windowHeight = $(this).height();
if (scrollTop + windowHeight >= (scrollHeight - 10) && lastScoreHeight != scrollHeight) { //滚动到底部执行事件
lastScoreHeight = scrollHeight;
gridTable.cmsXDataTable("loadNextPage");
return;
}
});
$(jq).find(".combo-arrow").mouseover(function () {
$(this).addClass("combogridX-arrow-hover");
});
$(jq).find(".combo-arrow").mouseout(function () {
$(this).removeClass("combogridX-arrow-hover");
});
$(jq).find(".combo-clear").mouseover(function () {
$(this).addClass("combo-clear-hover");
});
$(jq).find(".combo-clear").mouseout(function () {
$(this).removeClass("combo-clear-hover");
});
var comboText = $(jq).find(".combo-text");
var controlWidth = comboText.width() + 4;
if ($(jq).attr("width")) {
controlWidth = parseInt($(jq).attr("width"));
}
comboText.width(controlWidth - 36 - 3);
$(jq).width(controlWidth);
$(jq).find(".combo-arrow").offset({
top: $(jq).find(".combo-arrow").offset().top,
left: $(jq).find(".combo-arrow").offset().left + 18
});
if (comboText.attr("placeholder") && $(jq).attr("placeholder") != "") {
comboText.placeholder();
}
//设置相应事件
if (opts.enabled == true) {
$(jq).find(".combo-arrow").click(function () {
var dropdown = $(this).parents('.easyui-combogridX:first');
var expander = dropdown.find(".combogridX-expander");
var display = expander.css("display");
$('.combogridX-expander').css("display", "none");
if (display == "none") {
_showExpander(expander, dropdown, $(this));
}
else expander.css("display", "none");
});
$(jq).find(".combo-clear").click(function () {
var dropdown = $(this).parents('.easyui-combogridX:first');
var comboText = dropdown.find(".combo-text");
CMSFunction.ComboGrid.SetValue(dropdown, "", "-1");
if (opts.isAutoComplete) {
_autoComplete(comboText, true, oldValue, { keyCode: 8 });
}
$('.combogridX-expander').css("display", "none");
if (opts.onSelect) opts.onSelect.call(this, null);
});
}
if (opts.value != '' && opts.value != -1 && opts.text != '') {
CMSFunction.ComboGrid.SetValue($(jq), opts.text, opts.value);
}
if (opts.isAutoComplete) {
$(jq).find(".combo-text")
// .keyup(function (ev) {
// _autoComplete($(this), bubbleKeyup, oldValue, ev);
// })
.keydown(function (ev) {
// oldValue = $(this).val();
// if (ev.keyCode == 229) {
// bubbleKeyup = false;
// } else {
// bubbleKeyup = true;
// }
var selfControl = $(this);
clearTimeout(selfControl.timeoutFunc);
$(this).timeoutFunc = setTimeout(function() {
_autoComplete(selfControl, bubbleKeyup, null, ev);
}, 300);
});
}
return { combogridX: jq };
}
function _autoComplete(comboText, bubbleKeyup, oldValue, ev) {
// if (!bubbleKeyup && ev.keyCode != 32 && ev.keyCode != 13
// && (oldValue.indexOf(comboText.val()) >= 0
// || (ev.keyCode == 229 && comboText.val().indexOf(oldValue) >= 0)
// )) {
// bubbleKeyup = false;
// return;
// }
var dropdown = comboText.parents('.easyui-combogridX:first');
var grid = dropdown.find('.easyui-cmsXDataTable');
var opts = $.data(dropdown[0], "combogridX").options;
var formData = opts.formData;
if (comboText.val().length >= opts.minReloadCharactor) {
var expander = dropdown.find(".combogridX-expander");
var arrow = dropdown.find(".combo-arrow");
var display = expander.css("display");
if (display == "none") {
_showExpander(expander, dropdown, arrow);
}
var queryParamString = "";
if (formData) {
queryParamString = formData.QueryParamsDatas;
}
var queryText = comboText.val();
if (queryText == opts.emptyText) {
queryText = "";
}
var jsonString = "({'QueryParamsDatas':'Attribute|*|{\"ID\":\"00000000-0000-0000-0000-000000000000\",\"Value\":\"" + opts.textField
+ "\",\"ControlType\":\"TextBox\"}|@|Condition|*|中|@|ConditionValue|*|" + comboText.val()
+ "|@|" + opts.textField + "_QueryTextBox|*|" + queryText + "|@|" + queryParamString + "'})";
try {
grid.cmsXDataTable("loadAll", eval(jsonString));
}
catch (err) { }
}
}
function _showExpander(expander, dropdown, arrow) {
expander.css("display", "block");
_setExpanderPosition(expander, dropdown, arrow);
}
function _setExpanderPosition(expander, dropdown, arrow) {
var panelLeft = expander.position().left;
var panelWidth = expander.width();
var panelHeight = expander.height();
var dropdownLeft = dropdown.position().left;
var dropdownTop = dropdown.offset().top;
var dropdownHeight = dropdown.height();
var panelTop = (dropdownTop + dropdownHeight);
var arrowLeft = arrow.position().left;
var documentWidth = $(window).width();
var documentHeight = $(window).height() - 5;
var newTop = 0;
var newLeft = 0;
if (panelTop + panelHeight >= documentHeight) {
if (panelHeight < dropdownTop) {
newTop = dropdownTop - panelHeight;
} else if (dropdownTop >= (documentHeight - panelTop)) { //当下拉控件位置偏下……
newTop = 0;
expander.height(documentHeight - panelTop);
} else { //当下拉控件位置偏上……
newTop = panelTop;
expander.height(documentHeight - panelTop);
}
} else {
newTop = panelTop;
}
if (dropdownLeft + panelWidth > documentWidth - 16) {
newLeft = arrowLeft + arrow.width() - panelWidth;
if (newLeft < 2) newLeft = 2;
}
else {
newLeft = dropdownLeft;
}
//设置高度如果用offset的话,第一次点击时,如果窗口被滚动过,会忽略滚动条来设置高度,第二次又不会了,不知道为什么……
expander.position({
top: newTop
});
expander.offset({
left: newLeft
});
}
function _setValue(jq, val, callback) {
if (!val) {
CMSFunction.ComboGrid.SetValue($(jq), "", "");
return;
} else if (val == "" || val == "-1") {
CMSFunction.ComboGrid.SetValue($(jq), "", val);
return;
}
var opts = $.data(jq, "combogridX").options;
var grid = $(jq).find('.easyui-cmsXDataTable:first');
var jsonString = "({'QueryParamsDatas':'Attribute|*|{\"ID\":\"00000000-0000-0000-0000-000000000000\",\"Value\":\"" + opts.valueField
+ "\",\"ControlType\":\"TextBox\"}|@|Condition|*|=|@|ConditionValue|*|" + opts.value
+ "|@|" + opts.valueField + "_QueryTextBox|*|" + val + "|@|',page: 0,rows: 10 })";
try {
var gridOptions = grid.cmsXDataTable("options");
var url = gridOptions.url;
$.post(url, eval(jsonString), function (data) {
if (data.rows.length > 0) {
CMSFunction.ComboGrid.SetValue($(jq), data.rows[0][opts.textField], val);
if (callback) {
callback.call($(jq));
}
}
});
}
catch (err) { }
// var gridOpts = $.data(grid[0], "cmsXDataTable").options;
// var gridData = gridOpts.data;
// CMSFunction.ComboGrid.SetValue($(jq), "", "-1");
// if (gridData) {
// $.each(gridData.rows, function (i, v) {
// if (v[opts.valueField] == val) {
// CMSFunction.ComboGrid.SetValue($(jq), v[opts.textField], v[opts.valueField]);
// return false;
// }
// });
// }
}
function _getValue(jq) {
return $(jq).find('.combogridX-value').val();
}
function _getSelectedRow(jq) {
var value = _getValue(jq);
var opts = $.data(jq, "combogridX").options;
var grid = $(jq).find('.easyui-cmsXDataTable:first');
var gridOpts = $.data(grid[0], "cmsXDataTable").options;
var gridData = gridOpts.data;
var selectedRow = null;
if (gridData) {
$.each(gridData.rows, function (i, v) {
if (v[opts.valueField] == value) {
selectedRow = v;
return false;
}
});
}
return selectedRow;
}
function _getText(jq) {
return $(jq).find('.combo-text').val();
}
function _loadData(jq, data) {
jq.each(function () {
var grid = $(jq).parent().find('.easyui-cmsXDataTable:first');
if (!$.data(grid[0], "cmsXDataTable")) return;
grid.cmsXDataTable("loadData", data);
});
}
function _reload(jq, formData) {
jq.each(function () {
var grid = $(jq).parent().find('.easyui-cmsXDataTable:first');
if (!$.data(grid[0], "cmsXDataTable")) return;
var opts = $.data(grid[0], "cmsXDataTable").options;
opts.pageNumber = 1;
if (typeof formData == "string") {
opts.url = formData;
grid.cmsXDataTable("loadAll", '');
}
else {
$.data(this, "combogridX").options.formData = formData;
grid.cmsXDataTable("loadAll", formData);
}
});
}
function _select(jq, index) {
var grid = $(jq).parent().find('.easyui-cmsXDataTable:first');
var opts = $.data(jq, "combogridX").options;
if (!$.data(grid[0], "cmsXDataTable")) return;
var data = grid.cmsXDataTable("getRows");
if (data[index]) {
var selectedText = eval("data[index]." + opts.textField);
var selectedValue = eval("data[index]." + opts.valueField);
CMSFunction.ComboGrid.SetValue($(jq), selectedText, selectedValue);
}
}
$.fn.combogridX = function (_7be, _7bf, _7bg) {
if (typeof _7be == "string") {
var _7c0 = $.fn.combogridX.methods[_7be];
if (_7c0) {
return _7c0(this, _7bf, _7bg);
} else {
return this.combogridX(_7be, _7bf, _7bg);
}
}
_7be = _7be || {};
return this.each(function () {
var _this = this;
var cacheData = $.data(_this, "combogridX");
if (cacheData) {
$.extend(cacheData.options, _7be);
} else {
cacheData = $.data(_this, "combogridX", { options: $.extend({}, $.fn.combogridX.defaults, $.fn.combogridX.parseOptions(this), _7be) });
var initCacheData = _init(_this);
cacheData = $.data(_this, "combogridX", $.extend({}, cacheData, initCacheData));
}
});
};
$.fn.combogridX.methods = {
options: function (jq) {
var opts = $.data(jq[0], "combogridX").options;
return opts;
},
getValue: function (jq) {
return _getValue(jq[0]);
},
getSelectedRow: function (jq) {
return _getSelectedRow(jq[0]);
},
setValue: function (jq, val, callback) {
_setValue(jq[0], val, callback);
},
select: function (jq, index) {
_select(jq[0], index);
},
getText: function (jq) {
return _getText(jq[0]);
},
reload: function (jq, formData) {
_reload(jq, formData);
},
loadData: function (jq, data) {
_loadData(jq, data);
},
setExpanderPosition: function (jq, opts) {
_setExpanderPosition(opts.expander, opts.dropdown, opts.arrow);
}
};
$.fn.combogridX.parseOptions = function (_7c7) {
var t = $(_7c7);
return $.extend({}, $.fn.combogridX.defaults, $.parser.parseOptions(_7c7, []));
};
$.fn.combogridX.defaults = {
textField: "",
valueField: "",
isAutoComplete: true,
minReloadCharactor: 0,
onSelect: function (value) { },
onChange: function () { },
panelHeight: 300,
formData: null,
value: "",
enabled: true,
};
})(jQuery);
//2014-08-18 begin added by heyw 新增droppableContainer控件
$(function () {
$.parser.parseEasyUI(["autoComplete"]);
$.parser.parseEasyUI(["combogridX"]);
$.parser.parseEasyUI(["draggableList"]);
$.parser.parseEasyUI(["droppableContainer"]);
$.parser.parseEasyUI(["checkList"]);
$.parser.parseEasyUI(["richtext"]);
//$(".popupWindowContent").width(window.);
});
$.extend({
packFormParams: function (obj) {
var result = [];
for (var p in obj) {
result.push(p.toString() + "|*|" + obj[p] + "|@|");
}
return result.join('');
},
unpackFormParams: function (str) {
var json = [];
var props = str.split('|@|');
json.push("({");
for (var i = 0; i < props.length; i++) {
if (props[i] == "") continue;
var kv = props[i].split('|*|');
if (i != 0) { json.push(","); }
json.push('"' + kv[0] + '":"' + kv[1] + '"');
}
json.push("})");
return eval(json.join(""));
},
popupTopWindow: function (title, url, width, height, func, data) {
var containerTop = top.$('#sysWindow').parent();
var windowID = "sysWindow" + Math.floor(Math.random() * 100000 + 1);
$("
").appendTo(containerTop);
var loU = url.split("?");
var newUrl = url;
if (loU.length > 1) {
newUrl += "&WindowID=" + windowID;
} else {
newUrl += "?WindowID=" + windowID;
}
if (data) {
top.$('#' + windowID).data("inputData", data);
}
var windowHeight = $(top.document).height();
if (windowHeight < height) {
height = windowHeight;
}
top.$('#' + windowID).dialog({
title: title,
width: width,
height: height,
content: '',
modal: true,
onClose: function () {
if (func)
func.call(this, top.$('#' + windowID).data("resultData"));
},
onOpen: function () {
$(this).find("iframe").attr("src", newUrl);
}
});
return top.$('#' + windowID);
},
popupTopWindowOutsite: function (title, url, width, height, func, data) {
var containerTop = top.$('#sysWindow').parent();
var windowID = "sysWindow" + Math.floor(Math.random() * 100000 + 1);
$("
").appendTo(containerTop);
if (data) {
top.$('#' + windowID).data("inputData", data);
}
var windowHeight = $(top.document).height();
if (windowHeight < height) {
height = windowHeight;
}
top.$('#' + windowID).dialog({
title: title,
width: width,
height: height,
content: '',
modal: true,
onClose: function () {
if (func)
func.call(this, top.$('#' + windowID).data("resultData"));
},
onOpen: function () {
$(this).find("iframe").attr("src", url);
}
});
return top.$('#' + windowID);
},
closeCurPopupTopWindow: function () {
var windowID = $.SystemGeneral.getUrlParam("WindowID");
top.$("#" + windowID).dialog("close");
},
getPopupTopWindowInputData: function () {
var windowID = $.SystemGeneral.getUrlParam("WindowID");
return top.$('#' + windowID).data("inputData");
}
});
//2016-02-25 begin added by heyw 新增checkList控件
(function ($) {
$.parser.plugins.push("checkList");
function _init(jq) {
var opts = $.data(jq, "checkList").options;
if (opts.url && opts.url != "") {
$.ajax({
type: "post", url: opts.url, success: function (data) {
opts.data = data;
opts.values = $.map($.grep(data, function (x) { return x.IsSelected; }), function (x) { return x[opts.valueField]; });
_getInitValuesAndLoad(jq, opts);
}
});
}
else {
_getInitValuesAndLoad(jq, opts);
}
return { checkList: jq };
}
var _getInitValuesAndLoad = function (jq, opts) {
if (opts.valueUrl && opts.valueUrl != "") {
$.ajax({
type: "post", url: opts.valueUrl, success: function (valueData) {
opts.values = valueData;
_bind(jq);
}
});
}
else {
_bind(jq);
}
};
var _bind = function (jq) {
var opts = $.data(jq, "checkList").options;
var listID = jq.id;
var html = new Array();
var textField = opts.textField;
var valueField = opts.valueField;
if (!(textField && textField != "")) {
textField = "Text";
}
if (!(valueField && valueField != "")) {
valueField = "Value";
}
var styleHtml = new Array();
if (!opts.isShow) styleHtml.push('display: none;');
var pages = Math.ceil(opts.data.length / opts.columnCount);
html.push('');
var div = $(''.concat("", html.join(''), "
")).appendTo(jq);
if (opts.onclick) {
$(jq).find('input[name="' + opts.checkName + '"]').click(opts.onclick);
}
if (opts.onLoadSuccess) {
opts.onLoadSuccess.call(jq, opts.data);
}
};
$.fn.checkList = function (_7be, _7bf) {
if (typeof _7be == "string") {
var _7c0 = $.fn.checkList.methods[_7be];
if (_7c0) {
return _7c0(this, _7bf);
} else {
return this.checkList(_7be, _7bf);
}
}
_7be = _7be || {};
return this.each(function () {
var _this = this;
var cacheData = $.data(_this, "checkList");
if (cacheData) {
$.extend(cacheData.options, _7be);
} else {
cacheData = $.data(_this, "checkList", { options: $.extend({}, $.fn.checkList.defaults, $.fn.checkList.parseOptions(this), _7be) });
var initCacheData = _init(_this);
cacheData = $.data(_this, "checkList", $.extend({}, cacheData, initCacheData));
}
});
};
$.fn.checkList.methods = {
options: function (jq) {
var opts = $.data(jq[0], "checkList").options;
return opts;
}
};
$.fn.checkList.parseOptions = function (_7c7) {
var t = $(_7c7);
return $.extend({}, $.fn.checkList.defaults, $.parser.parseOptions(_7c7, []));
};
$.fn.checkList.defaults = {
url: "",
valueUrl: "",
textField: "",
valueField: "",
columnCount: 1,
data: [],
values: [],
onLoadSuccess: function (data) { },
isEnabled: true,
isShow: true
};
})(jQuery);
//2016-02-25 begin added by heyw 新增richtext控件
//2021-05-10 modify by heyw 实际控件从ueditor改为kindeditor
(function ($) {
$.parser.plugins.push("richtext");
var ueList = new Object();
function _init(jq) {
var id = $(jq).attr("id");
var name = $(jq).attr("name");
// var ue = new baidu.editor.ui.Editor();
// ue.render(id);
var ke;
KindEditor.ready(function(K) {
ke = K.create('#'+id, {
uploadJson: K.options.basePath + 'asp.net/upload_json.ashx',
fileManagerJson: K.options.basePath + 'asp.net/file_manager_json.ashx'
});
if (!ueList["richtext_" + id]) {
//ueList["richtext_" + id] = { name: name, editor: ue };
ueList["richtext_" + id] = { name: name, editor: ke };
}
});
$(jq).closest('form').submit(function () {
$(".easyui-richtext").richtext("sync");
});
return { richtext: jq };
}
function _getValue(jq) {
var id = $(jq).attr("id");
//var ue = ueList["richtext_" + id].editor;
//return ue.getContent();
var ke = ueList["richtext_" + id].editor;
ke.sync();
return editor.html();
}
function _setValue(jq, value) {
var id = $(jq).attr("id");
// var ue = ueList["richtext_" + id].editor;
// return ue.setContent(value);
var ke = ueList["richtext_" + id].editor;
return editor.html(value);
}
function _sync(jq) {
var id = $(jq).attr("id");
var opts = ueList["richtext_" + id]
// var ue = opts.editor;
//
// ue.sync();
// var content = ue.getContent();
// content = UE.utils.unhtml(content);
// content = content.replace(/'/g,'');
var ke = opts.editor;
var content = ke.html();
content = KindEditor.escape(content);
$('[name="' + opts.name + '"]').val(content);
}
$.fn.richtext = function (_7be, _7bf) {
if (typeof _7be == "string") {
var _7c0 = $.fn.richtext.methods[_7be];
if (_7c0) {
return _7c0(this, _7bf);
} else {
return this.richtext(_7be, _7bf);
}
}
_7be = _7be || {};
return this.each(function () {
var _this = this;
var cacheData = $.data(_this, "richtext");
if (cacheData) {
$.extend(cacheData.options, _7be);
} else {
cacheData = $.data(_this, "richtext", { options: $.extend({}, $.fn.richtext.defaults, $.fn.richtext.parseOptions(this), _7be) });
var initCacheData = _init(_this);
cacheData = $.data(_this, "richtext", $.extend({}, cacheData, initCacheData));
}
});
};
$.fn.richtext.methods = {
options: function (jq) {
var opts = $.data(jq[0], "richtext").options;
return opts;
},
getValue: function (jq) {
return _getValue(jq[0]);
},
setValue: function (jq, val) {
$.each(jq, function (i, v) {
_setValue(jq[i], val);
});
},
sync: function (jq) {
$.each(jq, function (i, v) {
_sync(jq[i]);
});
}
};
$.fn.richtext.parseOptions = function (_7c7) {
var t = $(_7c7);
return $.extend({}, $.fn.richtext.defaults, $.parser.parseOptions(_7c7, []));
};
$.fn.richtext.defaults = {
isEnabled: true,
isShow: true
};
})(jQuery);
//2016-02-25 begin added by heyw 新增checkList控件
(function ($) {
$.parser.plugins.push("qqList");
function _init(jq) {
var opts = $.data(jq, "qqList").options;
if (opts.url && opts.url != "") {
$.ajax({
type: "post", url: opts.url, success: function (data) {
opts.data = data;
_bind(jq);
}
});
}
else {
_bind(jq);
}
return { qqList: jq };
}
var _bind = function (jq) {
var opts = $.data(jq, "qqList").options;
var listID = jq.id;
var html = new Array();
var textField = opts.textField;
var valueField = opts.valueField;
if (!(textField && textField != "")) {
textField = "Text";
}
if (!(valueField && valueField != "")) {
valueField = "Value";
}
var styleHtml = new Array();
var pages = Math.ceil(opts.data.length / opts.columnCount);
html.push(' 0) html.push(' style="' + styleHtml.join('') + '"');
html.push('>');
for (var i = 0; i < pages; i++) {
html.push('');
for (var j = 0; j < opts.columnCount; j++) {
var curIndex = (i * opts.columnCount + j);
if (opts.data.length > curIndex) {
var enabledString = "";
var qqNo = opts.data[curIndex][valueField];
if (!opts.isEnabled) enabledString = " disabled";
html.push('');
html.push('')
html.push('');
html.push(''.concat('
', opts.data[curIndex][textField], ' '));
html.push('
');
}
else {
html.push(' ');
}
}
html.push(' ');
}
html.push('
');
var div = $(''.concat("", html.join(''), "
")).appendTo(jq);
if (opts.onclick) {
$(jq).find('a[name="' + opts.itemName + '"]').click(opts.onclick);
}
if (opts.onLoadSuccess) {
opts.onLoadSuccess.call(jq, opts.data);
}
};
$.fn.qqList = function (_7be, _7bf) {
if (typeof _7be == "string") {
var _7c0 = $.fn.qqList.methods[_7be];
if (_7c0) {
return _7c0(this, _7bf);
} else {
return this.qqList(_7be, _7bf);
}
}
_7be = _7be || {};
return this.each(function () {
var _this = this;
var cacheData = $.data(_this, "qqList");
if (cacheData) {
$.extend(cacheData.options, _7be);
} else {
cacheData = $.data(_this, "qqList", { options: $.extend({}, $.fn.qqList.defaults, $.fn.qqList.parseOptions(this), _7be) });
var initCacheData = _init(_this);
cacheData = $.data(_this, "qqList", $.extend({}, cacheData, initCacheData));
}
});
};
$.fn.qqList.methods = {
options: function (jq) {
var opts = $.data(jq[0], "qqList").options;
return opts;
}
};
$.fn.qqList.parseOptions = function (_7c7) {
var t = $(_7c7);
return $.extend({}, $.fn.qqList.defaults, $.parser.parseOptions(_7c7, []));
};
$.fn.qqList.defaults = {
url: "",
textField: "",
columnCount: 1,
data: [],
onLoadSuccess: function (data) { },
isEnabled: true,
isShow: true
};
})(jQuery);