var FormatType = {
None: 0,
DateTime: 1
};
var EditerModel = {
Disabled: 0,
Enabled: 1,
Forthwith: 2
};
var TableModel = {
Normal: 0,
OverLoad: 1//超载模式
};
var HandleResult = {
Failure: 0,
Succeed: 1,
Defects: 2
};
var BowinFunction = {
///
/// CMS框架内置顶级对象,所有内置函数或对象的祖先对象
/// Add : by 劳炳辉 (忘记时间了-_-)
///
Untility: {
ConvertObjectDateFormat: function (obj) {
for (var itemName in obj) {
var val = obj[itemName];
if (typeof (val) == "string") {
if (val.indexOf("/Date(") != -1) {
obj[itemName] = val.toDateString("yyyy-MM-dd HH:mm:ss.S");
}
}
else if (typeof (val) == "object") {
BowinFunction.Untility.ConvertObjectDateFormat(val);
}
}
return obj;
}
},
UpdateClockFun: function (controlID) {
///
/// 系统时钟定时器方法
///
var control = controlID.indexOf("#") == -1 ? ("#" + controlID) : controlID;
var timeStr = $(control).find('span').eq(0).html().replace('年', '-').replace('月', '-').replace('日', '-').replace(" ", '').replace(/\:/g, '-');
var timeStrArray = timeStr.split("-");
var yyyy = parseInt(timeStrArray[0]);
var MM = parseInt((timeStrArray[1].indexOf("0") == 0 && timeStrArray[1].length > 1 ? timeStrArray[1].substr(1) : timeStrArray[1])) - 1;
var dd = parseInt((timeStrArray[2].indexOf("0") == 0 && timeStrArray[2].length > 1 ? timeStrArray[2].substr(1) : timeStrArray[2]));
var HH = parseInt((timeStrArray[3].indexOf("0") == 0 && timeStrArray[3].length > 1 ? timeStrArray[3].substr(1) : timeStrArray[3]));
var mm = parseInt((timeStrArray[4].indexOf("0") == 0 && timeStrArray[4].length > 1 ? timeStrArray[4].substr(1) : timeStrArray[4]));
var ss = parseInt((timeStrArray[5].indexOf("0") == 0 && timeStrArray[5].length > 1 ? timeStrArray[5].substr(1) : timeStrArray[5]));
var oldTime = new Date(yyyy, MM, dd, HH, mm, ss);
if (oldTime.getSeconds() == 59 && oldTime.getMinutes() == 59 && oldTime.getHours() == 23) {//更新星期X
switch ($(control).find('span').eq(1).html()) {
case '星期一':
$(control).find('span').eq(1).html('星期二');
break;
case '星期二':
$(control).find('span').eq(1).html('星期三');
break;
case '星期三':
$(control).find('span').eq(1).html('星期四');
break;
case '星期四':
$(control).find('span').eq(1).html('星期五');
break;
case '星期五':
$(control).find('span').eq(1).html('星期六');
break;
case '星期六':
$(control).find('span').eq(1).html('星期日');
break;
case '星期日':
$(control).find('span').eq(1).html('星期一');
break;
}
}
var newTime = new Date(oldTime.setSeconds(oldTime.getSeconds() + 1)); //秒数+1
var Str = newTime.format("yyyy年MM月dd日 HH:mm:ss"); //时间
$(control).find('span').eq(0).html(Str);
},
Combobox: {
OnSelect: function (record, callBack) {
var target = $(this);
if (target.attr("isOnload") == 1) {
target.attr("isOnload", 0);
return;
}
var options = target.combobox("options");
var defaultValue = options.value;
if (options.multiple) {
var o = false;
for (var i = 0; i < options.data.length; i++) {
if (options.data[i].Value == defaultValue) {
o = true;
break;
}
}
if (defaultValue && o) {
if (record.Value == defaultValue) {
target.combobox("setValue", defaultValue);
target.siblings("span.combo").find("span").find("span.combo-arrow").click();
}
else {
var values = target.combobox("getValues");
for (var i = 0; i < values.length; i++) {
if (values[i] == defaultValue) {
target.combobox("unselect", defaultValue);
break;
}
}
}
}
}
if (callBack) {
callBack.call(this, record);
}
},
OnUnselect: function (record, callBack) {
var target = $(this);
var options = target.combobox("options");
var defaultValue = options.value;
if (options.multiple) {
var o = false;
for (var i = 0; i < options.data.length; i++) {
if (options.data[i].Value == defaultValue) {
o = true;
break;
}
}
if (defaultValue && o) {
var values = target.combobox("getValues");
if (values.length == 0) {
target.combobox("setValue", defaultValue);
target.siblings("span.combo").find("span").find("span.combo-arrow").click();
}
}
}
if (callBack) {
callBack.call(this, record);
}
},
OnChange: function (newValue, oldValue, callBack) {
if ("undefined" != typeof EasyUIValidate) {
if (EasyUIValidate.Events.ComboboxOnChange) {
EasyUIValidate.Events.ComboboxOnChange.call(this, newValue, oldValue);
}
}
if (callBack) {
callBack.call(this, newValue, oldValue);
}
},
OnLoadSuccess: function (callBack) {
var target = $(this);
var data = target.combobox('getData');
var options = target.combobox('options');
if (data.length > 0) {
target.attr("isOnload", 1);
if (!(options.value && options.value != "-1")) {
if ($.grep(data, function (x) { return x[options.valueField] == "-1"; }).length > 0) {
target.combobox('select', "-1");
} else {
target.combobox('select', data[0][options.valueField]);
}
} else if ($.grep(data, function (x) { return x[options.valueField] == options.value; }).length == 0) {
target.combobox('select', data[0][options.valueField]);
} else {
target.attr("isOnload", 0);
// target.combobox('select', options.value);
}
var datavalList = $.data(this, "combobox-dataval");
if (datavalList) {
if (datavalList.length > 0) {
$.each(datavalList, function (i, x) {
$('[name=' + target.attr("comboname") + ']').attr(x.name, x.value);
target.removeAttr(x.name);
});
target.removeAttr("data-val");
}
}
if ($.grep(data, function (x) {
return x[options.textField] == "<";
}).length > 0) {
$(".combobox-item[value='<']").html('<');
}
}
// if (options.data.length == 1 && options.data[0][options.valueField] == -1) {
// target.parent().find('select').append("");
// }
if (callBack) {
callBack.call(this, data);
}
},
ChangeHidden: function (record) {
$('[name="' + $(this).attr("id") + '"]').val(record.Value);
}
},
DataGrid: {
///
/// 本对象专门用于操作jQueryEasyUI框架的DataGrid
///
OnLoadSuccessFunction: function (data, callBack) {
var target = $(this);
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) {
if (formatType == FormatType.None) {
if (!value && value != 0) {
value = "";
}
}
else if (formatType == FormatType.DateTime) {
if (!value) {
value = "";
}
else {
value = value.toDateString(formatString);
}
}
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) {
var html = "" + (text ? text : (!value && value != 0 ? "" : value)) + "";
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("table.easyui-datagrid").eq(0);
}
else {
$table = $(table);
}
if ($table == null || $table == undefined) { return "" };
var rowsData = $table.datagrid('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 $table = $(obj).closest('.datagrid-view').find('table.easyui-datagrid').eq(0);
var RowsData = $table.datagrid("getRows");
var rowIndex = $(obj).closest('tr').attr("datagrid-row-index");
var data = BowinFunction.Untility.ConvertObjectDateFormat(RowsData[rowIndex]);
return "[" + JSON.stringify(data) + "]";
},
OrderColumn: function (src, field) {
var table = $(src).closest('.easyui-cmsXDataTable');
var opts = $.data(table[0], "cmsXDataTable").options;
if (opts.pagerType == 0) {
var ascStr = $(src).attr("asc");
table.cmsXDataTable("clearOrderByAsc");
if (!ascStr) {
$(src).attr("asc", "1");
} else if (ascStr == "1") {
$(src).attr("asc", "0");
} else {
$(src).attr("asc", "1");
}
var isAsc = ascStr == "1";
table.cmsXDataTable("orderLoad", { field: field, isAsc: isAsc });
}
}
},
EditerTable: {
Editer: {
ComboBox: {
OptionOverride: function (tbTarget, comboBoxTarget, rowIndex, itemSourceField, itemData, rowField, editerModel, editerHandleUrl) {
var columnOption = $(tbTarget).datagrid("getColumnOption", rowField);
var rowData = $(tbTarget).datagrid("getRows")[rowIndex];
var options = $(comboBoxTarget).combobox("options");
options.width = columnOption.width;
options.panelWidth = columnOption.width;
options.onSelect = function (record) { BowinFunction.EditerTable.Editer.ComboBox.OnSelectEvents.call(this, tbTarget, rowIndex, itemSourceField, itemData, record, editerModel, editerHandleUrl) };
if (itemSourceField) {
options.data = rowData[itemSourceField];
}
else {
options.data = $.parseJSON(itemData.replace(/\'/g, "\""));
}
options.panelHeight = "auto";
options.valueField = "Value";
options.textField = "Text";
var rowFieldArray = rowField.split('.');
var objValue;
if (rowFieldArray.length > 1) {
objValue = new Object(rowData[rowFieldArray[0]]);
for (var i = 1; i < rowFieldArray.length; i++) {
var objName = rowFieldArray[i];
objValue = new Object(objValue)[objName];
}
options.value = objValue;
}
else {
options.value = rowData[rowField];
}
$(comboBoxTarget).combobox(options);
},
OnSelectEvents: function (tbTarget, rowIndex, itemSourceField, itemData, record, editerModel, editerHandleUrl) {
var originalKey = ($(tbTarget).datagrid("options").pageNumber * rowIndex) + (($(tbTarget).datagrid("options").pageNumber - 1) * $(tbTarget).datagrid("options").pageSize);
var originalValue = $(tbTarget).datagrid("getRows")[rowIndex];
var superData = $(tbTarget).data("superData");
if (!superData) {
superData = {};
}
if (!superData.editerData) {
superData.editerData = {};
}
if (!superData.originalData) {
superData.originalData = {};
}
if (!superData.originalData[originalKey]) {
superData.originalData[originalKey] = {};
$.extend(superData.originalData[originalKey], originalValue);
}
var editors = $(tbTarget).datagrid("endEdit", rowIndex).datagrid("beginEdit", rowIndex).datagrid("getEditors", rowIndex);
var editerKey = ($(tbTarget).datagrid("options").pageNumber * rowIndex) + (($(tbTarget).datagrid("options").pageNumber - 1) * $(tbTarget).datagrid("options").pageSize);
var editerValue = $(tbTarget).datagrid("getRows")[rowIndex];
superData.editerData[editerKey] = editerValue;
$(tbTarget).data("superData", superData);
var s1 = $(tbTarget).datagrid("getModifyData");
var s2 = $(tbTarget).datagrid("getModifyData", rowIndex);
if (editerModel == EditerModel.Forthwith) {
var ops = {
URL: editerHandleUrl,
Data: { source: "[" + JSON.stringify(editerValue) + "]" },
CallBack: function (result) {
if (result.HandleResult == HandleResult.Failure) {
$.exceptionThrow(result, null);
}
else {
$.messager.show({
title: '设置成功',
msg: '数据更新成功',
timeout: 3000,
showType: 'slide'
});
}
}
};
BowinFunction.Request.AJAX(ops);
}
for (var i = 0; i < editors.length; i++) {
if (editors[i].type == "combobox") {//下拉菜单类编辑器
BowinFunction.EditerTable.Editer.ComboBox.OptionOverride(tbTarget, editors[i].target, rowIndex, itemSourceField, itemData, editors[i].field, editerModel, editerHandleUrl);
}
}
},
FormatterFunction: function (value, row, index, formatType, formatString, itemSourceField, itemData) {
value = BowinFunction.DataGrid.ColumnFormatterFunction(value, row, index, formatType, formatString);
var itemSource;
if (itemSourceField) {
itemSource = new Object(row[itemSourceField]);
}
else {
itemSource = $.parseJSON(itemData.replace(/\'/g, "\""));
}
for (var i = 0; i < itemSource.length; i++) {
if (itemSource[i].Value == value) {
return itemSource[i].Text;
}
}
}
}
},
Rows: {
OnDoubleClickEvents: function (rowIndex, rowData, itemSourceField, itemData, editerModel, editerHandleUrl) {
var tbTarget = this;
var editors = $(tbTarget).datagrid("getEditors", rowIndex); //获取行内所有编辑器
if (editors.length > 0) {//已经进入编辑模式
$(tbTarget).datagrid("cancelEdit", rowIndex); //撤销编辑
var superData = $(tbTarget).data("superData");
var originalData = null;
if (superData && superData.originalData) {//获取原始数据
var keyNumber = ($(tbTarget).datagrid("options").pageNumber * rowIndex) + (($(tbTarget).datagrid("options").pageNumber - 1) * $(tbTarget).datagrid("options").pageSize);
originalData = superData.originalData[keyNumber];
if (originalData) {
$(tbTarget).datagrid("updateRow", { index: rowIndex, row: originalData });
if (editerModel == EditerModel.Forthwith) {//回滚用户提交的更改
var ops = {
URL: editerHandleUrl,
Data: { source: "[" + JSON.stringify(originalData) + "]" },
CallBack: function (result) {
if (result.HandleResult == HandleResult.Failure) {
$.exceptionThrow(result, null);
}
else {
$(tbTarget).data("superData").originalData[keyNumber] = null;
$(tbTarget).data("superData").editerData[keyNumber] = null;
$.messager.show({
title: '撤销成功',
msg: '数据回滚至编辑器启动前状态',
timeout: 3000,
showType: 'slide'
});
}
}
};
BowinFunction.Request.AJAX(ops);
}
}
}
}
else {
$(this).datagrid("beginEdit", rowIndex); //启动编辑
editors = $(tbTarget).datagrid("getEditors", rowIndex); //获取行内所有编辑器
for (var i = 0; i < editors.length; i++) {
if (editors[i].type == "combobox") {//下拉菜单类编辑器
BowinFunction.EditerTable.Editer.ComboBox.OptionOverride(tbTarget, editors[i].target, rowIndex, itemSourceField, itemData, editors[i].field, editerModel, editerHandleUrl);
}
}
}
}
}
},
Request: {
Settings: {
url: "",
data: {},
datatype: "",
showProgress: true,
progressTitle: "等待服务器返回处理结果",
beforeSend: function () {
///
/// ajax请求发送前执行的函数
/// 例: function BowinBeforeFun(rowData)
/// 默认内置函数$BowinFunction.AjaxBefore,使用自定义函数请勿重名
/// 内置函数作用:弹出Loading条
/// rowData==当前行数据(JSON格式)
///
var title = this.progressTitle;
if (this.showProgress) {
//$.messager.progress({ msg: title, autoClose: true, interval: 600 });
$.cmsLoading.show(title);
}
},
complete: function (XHR, TS) {
//if (this.showProgress) {
// var progressbar = $.messager.progress('bar');
// if (progressbar.progressbar('getValue') < 100) {
// progressbar.progressbar('setValue', 100);
// }
//}
$.cmsLoading.hide();
},
success: function (result) {
///
/// 后台返回处理结果后执行的函数
/// 例: function BowinCallBackFun(result)
/// 默认内置函数$BowinFunction.AjaxCallBack,使用自定义函数请勿重名
/// 内置函数处理逻辑:result==""?alert("处理成功"):alert(result)
///
if (result.HandleResult == HandleResult.Failure) {
$.exceptionThrow(result, null);
}
else if (result.HandleResult == HandleResult.Defects) {
var detailError = "";
for (var i = 0; i < result.DetailError.length; i++) {
detailError += (result.DetailError[i][0] + "
");
}
$.messager.alert("部分数据处理失败", detailError, function () { });
}
else if (result.HandleResult == HandleResult.Succeed) {
$.messager.show({
title: '成功',
msg: '处理成功',
timeout: 5000,
showType: 'slide'
});
}
},
error: function (response) {
///
/// ajax请求发送失败时执行的函数
/// 例: function BowinErrorFun(response)
/// 默认内置函数$BowinFunction.AjaxError,使用自定义函数请勿重名
///
if (this.showProgress) {
//$.messager.CloseProgress();
$.cmsLoading.hide();
}
// $.messager.alert('请求失败 状态码:' + errorMsg.status, '错误信息:
' + errorMsg.statusText, 'error');
var errorObj = $.parseJSON($(response.responseText)[1].innerHTML);
$.exceptionThrow(errorObj, null);
}
},
AJAX: function (settings) {
var ajaxOptions = {};
$.extend(ajaxOptions, this.Settings);
if (settings.ProgressTitle != null && settings.ProgressTitle != undefined) {
ajaxOptions.progressTitle = settings.ProgressTitle;
}
if (settings.ShowProgress != null && settings.ShowProgress != undefined) {
ajaxOptions.showProgress = settings.ShowProgress;
}
if (settings.URL == null || settings.URL == "" || settings.URL == undefined) {
$.messager.alert('请求失败', 'Action地址不能为空', 'error');
return false;
}
else
ajaxOptions.url = ("/" + CMS_SystemConfig.VirtualDirectoryPath + settings.URL.replace(CMS_SystemConfig.VirtualDirectoryPath, "")).replaceDoubleSlashesToSingle();
if (settings.CallBack) {
ajaxOptions.success = function (result) {
settings.CallBack(result);
}
}
if (settings.Error != null && settings.Error != undefined) { ajaxOptions.error = settings.Error; }
if (settings.Data != null && settings.Data != undefined) { ajaxOptions.data = settings.Data; }
if (settings.Before != null && settings.Before != undefined) {
ajaxOptions.beforeSend = function () {
if (ajaxOptions.showProgress) {
//$.messager.progress({ msg: ajaxOptions.progressTitle, autoClose: true, interval: 600 });
$.cmsLoading.show(ajaxOptions.progressTitle);
}
return settings.Before(ajaxOptions.data);
}
}
$.ajax(ajaxOptions);
}
},
Submit: function (obj) {
var includedDataArray = ($(obj).attr('bowin-includeddata') == null || $(obj).attr('bowin-includeddata') == "" || $(obj).attr('bowin-includeddata') == undefined) ? null : ($(obj).attr('bowin-includeddata')).split(',');
var includedDataFun = includedDataArray != null ? includedDataArray[0] : null;
var $includedDataParm = (includedDataArray != null && includedDataArray[1] != undefined) ? $(includedDataArray[1]) : null;
if (includedDataFun != null && includedDataFun.indexOf('GetCurrentRowData') > -1) {
$includedDataParm = obj;
}
var dataFun = includedDataFun == null ? null : new Function('obj', "return " + includedDataFun + "(obj)");
var ops = {
URL: $(obj).attr("bowin-action"),
Before: $(obj).attr("bowin-beforefun") ? new Function('obj', "return " + $(obj).attr("bowin-beforefun") + "(obj)") : null,
CallBack: $(obj).attr("bowin-callbackfun") ? new Function('obj', "return " + $(obj).attr("bowin-callbackfun") + "(obj)") : null,
Error: $(obj).attr("bowin-errorfun") ? new Function('obj', "return " + $(obj).attr("bowin-errorfun") + "(obj)") : null
}
if (dataFun != null) {
ops.Data = {
"BowinJsonData": dataFun($includedDataParm)
}
}
if ($(obj).attr("customdata")) {
$(obj).attr("customdata");
}
BowinFunction.Request.AJAX(ops);
}
};
$(function () {
$(':checkbox[controltype="bowin"]').live("click", function () {
if ($(this).attr("checked") == undefined) {
$(this).attr("value", "false");
}
else {
$(this).attr("value", "true");
}
});
top.$("div[data-tab]:visible").hide();
$('.easyui-combobox').combo({
onShowPanel: function () {
var panelLeft = $(this).combo('panel').offset().left;
var panelHeight = $(this).combo('panel').height();
var textboxTop = $(this).combo('textbox').offset().top;
var textboxHeight = $(this).combo('textbox').height();
var panelTop = textboxTop + textboxHeight;
var documentHeight = $(window).height() - 5;
if (panelTop + panelHeight > documentHeight) {
if (panelHeight < textboxTop) {
$(this).combo('panel').parent().position({
top: textboxTop - panelHeight
});
$(this).combo('panel').parent().offset({
left: panelLeft
});
} else if (textboxTop > (documentHeight - panelTop)) {
$(this).combo('panel').height(textboxTop - 5);
$(this).combo('panel').parent().position({
top: 5,
});
$(this).combo('panel').parent().offset({
left: panelLeft
});
} else {
$(this).combo('panel').height(documentHeight - panelTop);
}
}
}
});
MVC_EasyUI_ValidateEntity();
});
$.extend($.fn.datagrid.methods, {
getModifyData: function (tbTarget, rowIndex) {
var editerData = $(tbTarget).data("superData").editerData;
if (rowIndex) {
var index = ($(tbTarget).datagrid("options").pageNumber * rowIndex) + (($(tbTarget).datagrid("options").pageNumber - 1) * $(tbTarget).datagrid("options").pageSize);
return editerData[index];
}
else {
var arr = [];
for (var item in editerData) {
arr.push(editerData[item]);
}
return arr;
}
},
clearSuperData: function (tbTarget) {
$(tbTarget).removeData("superData");
}
});
function MVC_EasyUI_ValidateEntity() {
if (location.href.indexOf("/Account/") <= 0) {
//判断不能为空
$("form [data-val-required]:visible,form [data-val-required][comboname]:hidden").each(function (i, n) {
var jn = $(n);
if (n.type != "checkbox") {
var $td = jn.parent();
if (!$td.is("td")) {
$td = $td.parent();
}
if (jn.parent().find("span.ValidateEntityrequired").length == 0) {
$td.append("*");
}
}
});
$('form .easyui-datebox[validtype="daterequired"],form .easyui-datetimebox[validtype="daterequired"]').each(function (i, n) {
var jn = $(n);
var $td = jn.parent();
if (!$td.is("td")) {
$td = $td.parent();
}
if (jn.parent().find("span.ValidateEntityrequired").length == 0) {
$td.append("*");
}
});
}
move_dataVal();
}
function move_dataVal() {
$("[comboname]").each(function (i) {
var $this = $(this);
var $easyUI = $("[name='" + $this.attr("comboname") + "']");
if ($this.attr("data-val")) {
var datavalList = new Array();
for (var j = this.attributes.length - 1; j >= 0; j--) {
if (this.attributes[j].name.indexOf("data-val") >= 0) {
if (this.attributes[j].name == "data-val-required") {
if ($this.hasClass("easyui-combobox") || $this.hasClass("easyui-combogridX")) {
datavalList.push({ name: "data-val-dropdownlistrequired", value: this.attributes[j].value });
$easyUI.attr("data-val-dropdownlistrequired", this.attributes[j].value);
}
// else if ($this.hasClass("easyui-datebox")) {
// $easyUI.parent().find(".combo-text").attr("data-val-daterequired", this.attributes[j].value);
// }
else {
datavalList.push({ name: "data-val-required", value: this.attributes[j].value });
$easyUI.attr("data-val-required", this.attributes[j].value);
}
}
else {
// if ($this.hasClass("easyui-datebox")) {
// $easyUI.parent().find(".combo-text").attr(this.attributes[j].name, this.attributes[j].value);
// } else {
// $easyUI.attr(this.attributes[j].name, this.attributes[j].value);
// }
datavalList.push({ name: this.attributes[j].name, value: this.attributes[j].value });
$easyUI.attr(this.attributes[j].name, this.attributes[j].value);
}
$this.removeAttr(this.attributes[j].name);
}
}
$.data(this, "combobox-dataval", datavalList);
$this.removeAttr("data-val");
}
});
}
//start uploader
function uploader_winName(name) {
return "uploader_" + name;
}
function uploader_showFileDialog(name) {
// var upname = uploader_winName(name);
// if (!window[upname]) {
// var j_uploader = $("fieldset[name='" + name + "']");
// //var dialogdiv=$("
");
// var dialogdiv = $("");
// dialogdiv.appendTo("body");
// dialogdiv.window({ width: 600, height: 350, title: "附件上传", collapsible: false, minimizable: false, maximizable: false, modal: true });
// dialogdiv.append("");
// window[upname] = dialogdiv;
// }
// else {
// window[upname].window("open");
// }
var j_uploader = $("fieldset[name='" + name + "']");
var uploader_url = j_uploader.attr("data-rooturl") + "Common/Uploader?n=" + name + "&t=" + j_uploader.attr("data-type") + "&v=" + j_uploader.attr("data-value");
if (j_uploader.attr("maxFileSize")) {
uploader_url += "&m=" + j_uploader.attr("maxFileSize");
}
$.popupTopWindow("附件上传", uploader_url, 480, 380, null, window);
}
function uploader_delTableRow(own, name) {
$.messager.confirm("选择提示", "是否要删除当前文件?", function (r) {
if (r) {
var a_li = $(own).parent();
var j_uploader = $("fieldset[name='" + name + "']");
var formID = j_uploader.attr("data-value");
$.post(j_uploader.attr("data-rooturl") + "Common/UploaderDel/" + formID + "?fileid=" + $(own).val(), function (msg) {
if (msg.length == 0) {
$.messager.alert("删除结果", "删除成功!", "", function () {
a_li.remove();
});
}
else {
$.messager.alert("删除结果", msg);
}
});
}
});
}
function uploader_addli(name, tb_file) {
var j_uploader = $("fieldset[name='" + name + "']");
var isDisabled = j_uploader.find("[name='uploader_btn_add']").attr("disabled") == "disabled";
var rooturl = j_uploader.attr("data-rooturl");
var uploader_ul = j_uploader.find("[name='uploader_ul']");
var uploader_li = "" +
"" + tb_file.FileName + "";
if (!isDisabled) {
uploader_li += "";
}
uploader_li += "";
uploader_ul.append(uploader_li);
}
function uploader_init() {
var j_uploader = $("fieldset[data-uploader]");
var up_load;
for (var i = 0; i < j_uploader.length; i++) {
up_load = j_uploader.eq(i);
$.getJSON(up_load.attr("data-rooturl") + "Common/UploaderInit/" + up_load.attr("data-value") + "?n=" + up_load.attr("name"), function (json) {
$.each(json, function (j, n) {
uploader_addli(j_uploader.attr("name"), n);
});
});
}
}
$(function () {
uploader_init();
});
//end uploader