123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854 |
- 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 = {
- /// <summary>
- /// <para>CMS框架内置顶级对象,所有内置函数或对象的祖先对象</para>
- /// <para>Add : by 劳炳辉 (忘记时间了-_-)</para>
- /// </summary>
- 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) {
- /// <summary>
- /// <para>系统时钟定时器方法</para>
- /// </summary>
- 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("<option value='" + options.data[0][options.valueField] + "'>" + options.data[0][options.textField] + "</option>");
- // }
- if (callBack) {
- callBack.call(this, data);
- }
- },
- ChangeHidden: function (record) {
- $('[name="' + $(this).attr("id") + '"]').val(record.Value);
- }
- },
- DataGrid: {
- /// <summary>
- /// <para>本对象专门用于操作jQueryEasyUI框架的DataGrid</para>
- /// </summary>
- 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 = "<a title=\"" + (text ? text : (!value && value != 0 ? "" : value)) + "\" href=\"javascript:void(0);\" class=\"easyui-linkbutton\" onclick=\"return " + handleScript + "(" + index + ",$(this).closest('div.datagrid-view').find('table.easyui-datagrid').datagrid('getRows')[" + index + "]);\" >" + (text ? text : (!value && value != 0 ? "" : value)) + "</a>";
- return html;
- },
- GetRowData: function (table) {
- /// <summary>
- /// <para>获取table中所有被选中的数据(最后返回的是数据是JSON格式的String类型数据)</para>
- /// <param name="table">jQuery对象,不传则默认为当前选项卡中的第一个DataGrid</param>
- /// </summary>
- 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) {
- /// <summary>
- /// <para>获取ojb对象所在行的数据(最后返回的是数据是JSON格式的String类型数据)</para>
- /// </summary>
- 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 () {
- /// <summary>
- /// <para>ajax请求发送前执行的函数</para>
- /// <para>例: function BowinBeforeFun(rowData)</para>
- /// <para>默认内置函数$BowinFunction.AjaxBefore,使用自定义函数请勿重名</para>
- /// <para>内置函数作用:弹出Loading条</para>
- /// <para>rowData==当前行数据(JSON格式)</para>
- /// </summary>
- 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) {
- /// <summary>
- /// <para>后台返回处理结果后执行的函数</para>
- /// <para>例: function BowinCallBackFun(result)</para>
- /// <para>默认内置函数$BowinFunction.AjaxCallBack,使用自定义函数请勿重名</para>
- /// <para>内置函数处理逻辑:result==""?alert("处理成功"):alert(result)</para>
- /// </summary>
- 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] + "<br />");
- }
- $.messager.alert("部分数据处理失败", detailError, function () { });
- }
- else if (result.HandleResult == HandleResult.Succeed) {
- $.messager.show({
- title: '成功',
- msg: '处理成功',
- timeout: 5000,
- showType: 'slide'
- });
- }
- },
- error: function (response) {
- /// <summary>
- /// <para>ajax请求发送失败时执行的函数</para>
- /// <para>例: function BowinErrorFun(response)</para>
- /// <para>默认内置函数$BowinFunction.AjaxError,使用自定义函数请勿重名</para>
- /// </summary>
- if (this.showProgress) {
- //$.messager.CloseProgress();
- $.cmsLoading.hide();
- }
- // $.messager.alert('请求失败 状态码:' + errorMsg.status, '错误信息:<br />' + 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("<span class='ValidateEntityrequired'>*</span>");
- }
- }
- });
- $('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("<span class='ValidateEntityrequired'>*</span>");
- }
- });
- }
- 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=$("<div><iframe src='" + j_uploader.attr("data-rooturl") + "Common/Uploader?n=" + name + "&v=" + j_uploader.attr("data-value") + "' frameborder=\"0\" style=\"border:0;width:100%;height:99%;\"></iframe></div>");
- // var dialogdiv = $("<div></div>");
- // dialogdiv.appendTo("body");
- // dialogdiv.window({ width: 600, height: 350, title: "附件上传", collapsible: false, minimizable: false, maximizable: false, modal: true });
- // dialogdiv.append("<iframe src='" + j_uploader.attr("data-rooturl") + "Common/Uploader?n=" + name + "&t=" + j_uploader.attr("data-type") + "&v=" + j_uploader.attr("data-value") + "' frameborder=\"0\" style=\"border:0;width:100%;height:99%;\"></iframe>");
- // 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 = "<li>" +
- "<a href='" + tb_file.FileUrl.replace('~/', rooturl) + "' target=\"_blank\">" + tb_file.FileName + "</a>";
- if (!isDisabled) {
- uploader_li += "<input style=\"border: 0;\" onclick=\"uploader_delTableRow(this,'" + name + "');return false;\" type=\"image\" src='" + rooturl + "Scripts/Bowin.Control.Core/Plugins/uploadifyFile/delfile.gif' value='" + tb_file.FileID + "' />";
- }
- uploader_li += "</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
|