/// <reference path="_references.js" />
(function (window, undefined) {
var controlHooks = window.controlHooks || (window.controlHooks = {});
$.extend(controlHooks, {
//多选列表控件
selectList: {
get: function (elem) {
return $(elem).selectList("getValue");
},
set: function (elem, value) {
$(elem).selectList("setValue", value);
}
},
//条件组合
combination: {
get: function (elem) {
if (elem.getValue) {
return elem.getValue();
}
},
set: function (elem, value) {
if (elem.setValue) {
elem.setValue(value);
}
},
valid: function (elem) {
if (elem.valid) {
return elem.valid();
}
}
},
F4F5AirlineLiecseCheckReult: {
get: function (elem) {
if (elem.getValue) {
return elem.getValue();
}
},
set: function (elem, value) {
if (elem.setValue) {
elem.setValue(value);
}
}
},
F4F5AirlineLicEvaluation: {
get: function (elem) {
if (elem.getValue) {
return elem.getValue();
}
},
set: function (elem, value) {
if (elem.setValue) {
elem.setValue(value);
}
}
},
//注册控件方法
register: function (name, methods) {
if (!this[name]) {
this[name] = methods;
}
else {
var control = this[name];
for (var m in methods) {
if (!control[m]) {
control[m] = methods[m];
}
}
}
}
});
$.fn.extend({
//将form转换为具有状态显示的ajax表单
//服务器必须返回FeedbackModel
submitForm: function (url, onSuccess, validate, dataFunc) {
var _submitForm = function (event) {
//这句话里判断event不是原始事件(因为有的浏览器会拦不住原始事件),
//且没有被阻止过(有的浏览器事件被阻止了还是会触发后边的事件)
//&& event.originalEvent
if ($(this).valid() && !event.isDefaultPrevented()) {
if (validate && !validate()) {
event.preventDefault();
return false;
};
var submitStatus = $.pnotify({ text: '正在进行' });
submitStatus.success = false;
$.ajax({
url: url || $(this).attr("action"),
type: "POST",
data: dataFunc ? $(this).serialize() + "&" + dataFunc() : $(this).serialize(),
success: function (data, textStatus, jqXHR) {
if (data.Result) {
submitStatus.pnotify({ text: "操作成功!", type: "success" });
submitStatus.success = true;
if (onSuccess) {
onSuccess(data);
}
}
else {
submitStatus.pnotify({ text: "操作失败" || textStatus, type: 'error' });
}
},
error: function () {
submitStatus.pnotify_remove();
},
complete: function () {
setTimeout(function () {
if (submitStatus.success) {
submitStatus.pnotify_remove();
}
}, 1000);
}
});
}
event.preventDefault();
return false;
};
$(this).unbind("submit");
$(this).unbind("submit", $(this).data("handler"));
$(this).bind("submit", _submitForm);
$(this).data("handler", _submitForm);
},
//将表单JSON序列化提交
submitJson: function (url, onSuccess, validate, dataFunc) {
var _submitJson = function (event) {
var $form = $(this);
//这句话里判断event不是原始事件(因为有的浏览器会拦不住原始事件),
//且没有被阻止过(有的浏览器事件被阻止了还是会触发后边的事件)
//&& event.originalEvent
//$form.valid() 原始验证方法
if ($form.formValid() && !event.isDefaultPrevented()) {
if (validate && !validate()) {
event.preventDefault();
return false;
};
var submitStatus = $.pnotify({ text: '正在进行' });
submitStatus.success = false;
var json = $.extend(true, $form.data("formdata"),
$form.serializeObject(),
dataFunc && dataFunc());
$.ajax({
url: url || $form.attr("action"),
type: "POST",
data: { data: JSON.stringify(json) },
success: function (data, textStatus, jqXHR) {
if (data.Result) {
submitStatus.pnotify({ text: "操作成功!", type: "success" });
submitStatus.success = true;
if (onSuccess) {
onSuccess(data);
}
}
else {
submitStatus.pnotify({ text: "操作失败" || textStatus, type: 'error' });
}
},
error: function () {
submitStatus.pnotify_remove();
},
complete: function () {
setTimeout(function () {
if (submitStatus.success) {
submitStatus.pnotify_remove();
}
}, 1000);
}
});
}
event.preventDefault();
return false;
};
$(this).unbind("submit");
$(this).unbind("submit", $(this).data("handler"));
$(this).bind("submit", _submitJson);
$(this).data("handler", _submitJson);
},
//序列化表单为数组
_serializeArray: function () {
var rCRLF = /\r?\n/g,
rinput = /^(?:color|date|datetime|datetime-local|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,
rselectTextarea = /^(?:select|textarea)/i;
return this.map(function () {
return this.elements ? $.makeArray(this.elements) : this;
})
.filter(function () {
return this.name && !this.disabled &&
(this.checked || rselectTextarea.test(this.nodeName) || rinput.test(this.type));
})
.not(function () {
return $(this).parentsUntil(this.form, "[controlname]").length > 0;
})
.add("[controlname]", this)
.map(function (i, elem) {
var val = $(this).value();
return val == null ? null : {
name: elem.name || elem.id,
operator: $(this).attr("operator") ||
(elem.type == "select-one" && "eq") ||
(elem.type == "select-multiple" && "containedin") ||
"substringof",
value: !$.isArray(val) ?
val.replace(rCRLF, "\r\n") :
$.map(val, function (v, i) {
if (typeof v === "string") {
return v.replace(rCRLF, "\r\n");
}
return v;
})
};
}).get();
},
//序列化表单为JSON
serializeObject: function () {
var obj = {};
$.each(this._serializeArray(), function (i, item) {
var keys = item['name'].split('.');
var o = obj;
$.each(keys, function (_i, key) {
if (_i == keys.length - 1) {
if (o[key] == undefined) {
o[key] = item['value'] || '';
}
else {
if (!$.isArray(o[key])) {
o[key] = [o[key]];
}
o[key].push(item['value'] || '');
}
}
else if (o[key] == undefined) {
o[key] = {};
}
o = o[key];
});
});
return obj;
},
//绑定搜索表单
searchForm: function (grid) {
var $form = this;
if (!grid) {
grid = $form.attr("for");
}
$form.unbind().bind("submit", function (event) {
var formData = $form._serializeArray();
if (typeof grid == "string" || grid.nodeType) {
$.extend($(grid).datagrid("options").queryParams, {
RuleString: JSON.stringify(formData)
});
$(grid).datagrid("reload");
}
event.preventDefault();
return false;
});
},
//重置验证
resetValid: function () {
var $form = this.closest('form');
//reset jQuery Validate's internals
$form.validate().resetForm();
//reset unobtrusive validation summary, if it exists
$form.find("[data-valmsg-summary=true]")
.removeClass("validation-summary-errors")
.addClass("validation-summary-valid")
.find("ul").empty();
//reset unobtrusive field level, if it exists
$form.find("[data-valmsg-replace]")
.removeClass("field-validation-error")
.addClass("field-validation-valid")
.empty();
return $form;
},
//表单验证
formValid: function () {
var $form = this;
if ($form.valid()) {
var hooks, result = true;
$form.find("[controlname]").each(function () {
hooks = controlHooks[$(this).attr("controlname")];
if (hooks && "valid" in hooks) {
hooks.valid(this) || (result = false);
}
});
return result;
}
return false;
},
//重置表单
formReset: function (valid) {
var $form = this.closest('form');
$form[0].reset();
if (valid == undefined || valid) {
$form.resetValid();
}
return $form;
},
//表单数据载入
formLoad: function (data, callback) {
var $form = this;
var form = this[0]; //form element,可能需要找出有效表单元素
var _checkField = function (name, val) {
var rr = $form.find(':radio[name="' + name + '"], :checkbox[name="' + name + '"]');
rr.prop('checked', false);
rr.each(function () {
var f = $(this);
if (f.val() == String(val) || $.inArray(f.val(), $.isArray(val) ? val : [val]) >= 0) {
f.prop('checked', true);
}
});
return rr;
}
var _loadCombo = function (name, val) {
var cc = ['combobox', 'combotree', 'combogrid', 'datetimebox', 'datebox', 'combo'];
var c = $form.find('[comboName="' + name + '"]');
if (c.length) {
for (var i = 0; i < cc.length; i++) {
var type = cc[i];
if (c.hasClass(type + '-f')) {
if (c[type]('options').multiple) {
c[type]('setValues', val);
} else {
c[type]('setValue', val);
}
return;
}
}
}
}
var _load = function (_data) {
if (!$.isArray(_data)) {
$form.data("formdata", _data); //缓存form数据
}
for (var n in _data) {
var val = _data[n];
var $control = _checkField(n, val);
if (!$control.length) {
$control = $("[name=" + n + "],:not(label)[id=" + n + "]", form);
$control.length ? $control.value(val)
: $("label[id=" + n + "]").text(val);
}
_loadCombo(n, val); //for easyui
}
if (callback && $.isFunction(callback)) {
callback.call(this, _data);
}
};
if (typeof data == 'string') {
$.ajax({
url: data,
type: "POST",
dataType: "json",
success: function (d) {
_load(d);
}
});
}
else {
_load(data);
}
},
//绑定下拉框
bindSelect: function (data, addEmpty) {
var self = $(this).empty();
self.append($.map(data, function (v) {
return "<option value='" + v["Value"] + "' "
+ (v["Selected"] ? "selected" : "") + " >" + v["Text"] + "</option>";
}).join(''));
if (addEmpty) {
self.prepend("<option value=''>-请选择-</option>");
}
},
//自定义jquery赋值取值方法
value: function (value) {
var hooks, isFunction, elem = this[0];
if (!arguments.length) {
if (elem) {
hooks = controlHooks[this.attr("controlname")];
if (hooks && "get" in hooks) {
return hooks.get(elem, "value");
}
return this.val();
}
}
isFunction = jQuery.isFunction(value);
return this.each(function (i) {
var val,
_self = jQuery(this);
if (isFunction) {
val = value.call(this, i, _self.value());
} else {
val = value;
}
if (val == null) {
val = "";
} else if (typeof val === "number") {
val += "";
} else if (jQuery.isArray(val)) {
val = jQuery.map(val, function (value) {
return value == null ? "" : value + "";
});
}
hooks = controlHooks[_self.attr("controlname")];
if (hooks && "set" in hooks) {
hooks.set(this, val, "value")
}
else {
_self.val(val);
}
});
}
});
/**
* jquery中各个事件执行顺序如下:
* ajaxStart(全局事件)
* beforeSend(局部事件)
* ajaxSend(全局事件)
* success(局部事件)
* ajaxSuccess(全局事件)
* error(局部事件)
* ajaxError (全局事件)
* complete(局部事件)
* ajaxComplete(全局事件)
* ajaxStop(全局事件)
*/
//#region 注册全局ajax函数,若要屏蔽
//将局部参数global设置为false即可
$.ajaxSetup({
async: true,
global: true,
type: "POST"
});
var gloabStatus = null;
//ajax请求发送前
$(document).ajaxStart(function () {
/*$.pnotify({
type: 'notice',
text: '正在进行...'
});*/
});
//ajax请求成功
$(document).ajaxSuccess(function (event, xhr, options) {
});
//ajax出错显示
$(document).ajaxError(function (event, jqXHR, ajaxSettings, thrownError) {
switch (jqXHR.status) {
case 403:
{
break;
$.pnotify({
title: "登录超时!",
type: "error",
text: "登录超时,请重新登录!"
});
}
default:
{
//xmp直接输出html代码
$.pnotify({
title: "请求出错了!!!",
type: "error",
width: "800px",
text: "请求地址:<font color='blue'>" + ajaxSettings.url + "</font>\n\r" +
"事件类型:<font color='blue'>" + event.type + "</font>\n\r" +
"错误信息:<font color='blue'>" + thrownError + "</font>\n\r" +
"错误详情:" + (function () {
var $div = $("<div></div>")
.text(jqXHR.responseText)
.css({
"max-height": "400px",
"overflow-y": "auto",
"overflow-x": "hidden",
"color": "blue"
});
var html = $div[0].outerHTML;
$div.remove();
$div = null;
return html;
})()
});
break;
}
}
});
//#endregion
$(document).ready(function () {
if ($.inArray($("#pageParams input[name=action]").val(), ["edit", "init"]) > -1) {
$.each(document.forms, function (i, form) {
var $form = $(form);
// if (!$form.attr("isAutoLoad")) {
if ($form.attr("behaviorname")) {
var url = func.bulidBehaviorUrl("../GHPQ/Load",
$form.attr("behaviorname"),
$form.attr('behaviorparams'));
$form.formLoad(url);
}
// }
})
}
});
//form表单验证移除提示信息
$("form").find("input, select, textarea")
.not(":submit, :reset, :image, [disabled]")
.on({
"mouseover": function () {
$(this).siblings(".field-validation-error").show();
},
"mouseout": function () {
$(this).siblings(".field-validation-error").hide();
}
});
})(window);
//上传文件处理
$(function () {
if ($('.inputfileupload').size() > 0) {
$('.inputfileupload').fileupload({
url: '../Upload/UploadHandler.ashx?type=save',
dataType: 'json',
done: function (e, data) {
var target = this;
var htmltr = '';
var multiple = $(target).prev().attr("ifmultiple");
$.each(data.result, function (index, file) {
if (multiple == "true") {
$(target).next().val($(target).next().val() + file.name + '$' + file.newNames + ',');
htmltr = "<tr><td><a href='.." + file.url + "'>" + file.name + "</a></td><td>" + (file.size / 1024).toFixed(2) + "KB</td><td><a data-url=" + file.delete_url + "&type=delete href='javascript:void(0)' onclick='deletefileupload(this)'>删除</a></td></tr>";
} else {
$(target).next().val(file.name + '$' + file.newNames);
htmltr = "<tr><td><a href='.." + file.url + "'>" + file.name + "</a></td><td>" + (file.size / 1024).toFixed(2) + "KB</td><td><a data-url=" + file.delete_url + "&type=delete href='javascript:void(0)' onclick='deletefileupload(this)'>删除</a></td></tr>";
}
});
if (multiple != "true") {
$(target).parent().parent().children().find("table").empty();
}
$(target).parent().parent().children().find("table").append(htmltr).show();
},
progressall: function (e, data) {
var progress = parseInt(data.loaded / data.total * 100, 10);
$(this).parent().parent().children().filter(".progress").children().css(
'width',
progress + '%'
);
}
}).prop('disabled', !$.support.fileInput).parent().addClass($.support.fileInput ? undefined : 'disabled');
}
//加载检查单列表数据
$("table[url]").each(function () {
var ithis = this;
$.ajax({
type: "Post",
url: $(this).attr("url"),
dataType: "json",
success: function (data) {
if (data != null) {
var json = eval(data);
var html = "";
var hrCount = $(ithis).find("th[controlType]").size();
var titleposition = "";
if (typeof ($(ithis).attr("titleposition")) != "undefined") {
titleposition = $(ithis).attr("titleposition");
} else {
titleposition = "left";
}
//类型显示在左边
if (titleposition == "left") {
for (var i = 0; i < json.length; i++) {
html += "<tr>";
if (i == 0) {
if (typeof (json[i]["FREMARK"]) != "undefined" && json[i]["FREMARK"] != "" && json[i]["FREMARK"].length > 0) {
html += "<td>" + json[i][$(ithis).find("th[bindcol]").eq(0).attr("bindcol")] + "</td>";
html += "<td style='text-align:left;padding-left:5px;' colSpan='" + (hrCount - 1) + "'> " + json[i]["FREMARK"] + "</td>";
} else {
html += showTableTh(ithis, json, i);
}
} else if (typeof (json[i]["FNAME"]) != "undefined" && json[i]["FNAME"] != json[i - 1]["FNAME"]) { //显示说明
//if (json[i]["FREMARK"] != "" && json[i]["FREMARK"].length > 0) {
// html += "<td>" + json[i][$(ithis).find("th[bindcol]").eq(0).attr("bindcol")] + "</td>";
// html += "<td style='text-align:left;padding-left:5px;' colSpan=" + (hrCount - 1) + ">" + json[i]["FREMARK"] + "</td>";
//} else {
html += showTableTh(ithis, json, i);
//}
} else {
html += showTableTh(ithis, json, i);
}
html += "</tr>";
}
$(ithis).append(html);
if (typeof ($(ithis).attr("combinecol")) != "undefined") {
uniteTable(ithis, $(ithis).attr("combinecol"));
}
} else if (titleposition == "top") { //类型显示在上面
for (var i = 0; i < json.length; i++) {
if (i == 0) {
if (json[i]["FNAME"] != "" && json[i]["FNAME"].length > 0) {
html += "<tr>";
html += "<td style='font-weight:bold;'>" + json[i]["FNAME"] + "</td>";
html += "<td style='text-align:left;padding-left:5px;' colSpan='" + (hrCount - 1) + "'> " + json[i]["FREMARK"] + "</td></tr>";
html += "<tr class='classF4SF5AirLicCheckR'>";
html += showTableThtop(ithis, json, i);
} else {
html += "<tr class='classF4SF5AirLicCheckR'>";
html += showTableThtop(ithis, json, i);
}
} else if (json[i]["FNAME"] != json[i - 1]["FNAME"]) { //显示说明
//if (json[i]["FREMARK"] != "" && json[i]["FREMARK"].length > 0) {
html += "<tr>";
html += "<td style='font-weight:bold;'>" + json[i]["FNAME"] + "</td>";
html += "<td style='text-align:left;padding-left:5px;' colSpan=" + (hrCount - 1) + "> " + json[i]["FREMARK"] + "</td></tr>";
//} else {
html += "<tr class='classF4SF5AirLicCheckR'>";
html += showTableThtop(ithis, json, i);
//}
} else {
html += "<tr class='classF4SF5AirLicCheckR'>";
html += showTableThtop(ithis, json, i);
}
html += "</tr>";
}
$(ithis).append(html);
}
}
},
error: function (err) {
alert("数据加载错误");
}
});
});
//--加载检查单列表数据结束
});
//正常TABEL加载数据
function showTableTh(ithis, json, i) {
var html = "";
$(ithis).find("th[bindcol]").each(function () {
if (typeof ($(this).attr("bindcol")) != "undefined" && typeof ($(this).attr("controlType")) == "undefined") {
html += "<td>" + json[i][$(this).attr("bindcol")] + "</td>";
}
});
$(ithis).find("th[controlType]").each(function () {
if (typeof ($(this).attr("controlType")) != "undefined") {
html += "<td><input name='" + json[i]["id"] + "' type ='" + $(this).attr("controlType") + "' /></td>";
}
});
return html;
}
//正常TABEL加载数据
function showTableThtop(ithis, json, i) {
var html = "";
$(ithis).find("tr").eq(0).children().each(function () {
if (typeof ($(this).attr("bindcol")) != "undefined" && typeof ($(this).attr("controlType")) == "undefined") { //过滤控件
if ($(this).attr("bindcol") == "FREMARK") {
html += "<td> </td>";
} else {
html += "<td>" + json[i][$(this).attr("bindcol")] + "</td>";
}
} else if (typeof ($(this).attr("controlType")) != "undefined") {
if ($(this).attr("controlType") == "textbox") {
html += "<td><input type='hidden' name='id' value='" + json[i]["id"] + "'/><input style='width:350px;' name='" + $(this).attr("bindcol") + "' type ='" + $(this).attr("controlType") + "' /></td>";
} else if ($(this).attr("controlType") == "hidden") {
html += "<td style='display:none;'><input name='" + $(this).attr("bindcol") + "' type ='" + $(this).attr("controlType") + "' value='" + json[i][$(this).attr("bindcol")] + "' /></td>";
} else {
html += "<td><input name='" + $(this).attr("bindcol") + "' type ='" + $(this).attr("controlType") + "' /></td>";
}
} else if (typeof ($(this).attr("colSpan")) != "undefined") {
var icount = parseInt($(this).attr("colSpan"));
var pthis = this;
var pcont = 0;
// $(pthis).parent().find("th[colSpan]").each(function () {
// if (this == pthis) {
// return false;
// }
// pcont += parseInt($(this).attr("colSpan"));
// });
$(this).parent().next().children().each(function (n) {
if (n >= pcont && n < (icount + pcont)) {
if (typeof ($(this).attr("bindcol")) != "undefined" && typeof ($(this).attr("controlType")) == "undefined") {
html += "<td>" + json[i][$(this).attr("bindcol")] + "</td>";
} else if (typeof ($(this).attr("controlType")) != "undefined") {
if ($(this).attr("controlType") == "radio") {
html += "<td><input name='" + $(this).attr("bindcol") + "_" + json[i]["id"] + "' value='" + $(this).attr("value") + "' type ='" + $(this).attr("controlType") + "' /></td>";
} else if ($(this).attr("controlType") == "hidden") {
html += "<td style='display:none;'><input name='" + $(this).attr("bindcol") + "' type ='" + $(this).attr("controlType") + "' value='" + json[i][$(this).attr("bindcol")] + "' /></td>";
} else {
html += "<td><input name='" + $(this).attr("bindcol") + "' type ='" + $(this).attr("controlType") + "' /></td>";
}
}
}
});
}
});
return html;
}
//删除方法
function deletefileupload(ithis) {
$.ajax({
url: ".." + $(ithis).attr("data-url"),
async: true,
type: "POST",
cache: false,
success: function (responseData) {
if (responseData) {
$(ithis).parent().parent().remove();
}
else {
alert('数据不能被删除!');
}
}
});
}
///////////////////////////////////////////////
// 功能:合并表格
// 参数:tb--需要合并的表格ID
// 参数:colLength--需要对前几列进行合并,比如,
// 想合并前两列,后面的数据列忽略合并,colLength应为2
// 缺省表示对全部列合并
///////////////////////////////////////////////
function uniteTable(tb, colLength) {
// 检查表格是否规整
//if (!checkTable(tb)) return;
var i = 0;
var j = 0;
var rowCount = tb.rows.length; // 行数
var colCount = tb.rows[0].cells.length; // 列数
var obj1 = null;
var obj2 = null;
//为每个单元格命名
for (i = 0; i < rowCount; i++) {
for (j = 0; j < tb.rows[i].cells.length; j++) {
tb.rows[i].cells[j].id = "tb__" + i.toString() + "_" + j.toString();
}
}
//合并行
for (i = 0; i < colCount; i++) {
if (i == colLength) break;
obj1 = document.getElementById("tb__0_" + i.toString())
for (j = 1; j < rowCount; j++) {
obj2 = document.getElementById("tb__" + j.toString() + "_" + i.toString());
if (obj1.innerHTML == obj2.innerHTML) {
obj1.rowSpan++;
obj2.parentNode.removeChild(obj2);
} else {
obj1 = document.getElementById("tb__" + j.toString() + "_" + i.toString());
}
}
}
//合并列
// for (i = 0; i < rowCount; i++) {
// colCount = tb.rows[i].cells.length;
// obj1 = document.getElementById(tb.rows[i].cells[0].id);
// for (j = 1; j < colCount; j++) {
// if (j >= colLength) break;
// if (obj1.colSpan >= colLength) break;
// obj2 = document.getElementById(tb.rows[i].cells[j].id);
// if (obj1.innerText == obj2.innerText) {
// obj1.colSpan++;
// obj2.parentNode.removeChild(obj2);
// j = j - 1;
// }
// else {
// obj1 = obj2;
// j = j + obj1.rowSpan;
// }
// }
// }
}
///////////////////////////////////////////////
// 想合并前两列,后面的数据列忽略合并,colLength应为2,startRowIndex 从第几行开始 (孙超)
///////////////////////////////////////////////
function uniteTable2(tb, colLength, startRowIndex) {
var rowCount = tb.rows.length; // 行数
var colCount = tb.rows[startRowIndex].cells.length; // 列数
var obj1 = null;
var obj2 = null;
//为每个单元格命名
for (var i = startRowIndex; i < rowCount; i++) {
for (var j = 0; j < colCount; j++) {
tb.rows[i].cells[j].id = "tb__" + i.toString() + "_" + j.toString();
}
}
//合并行
for (var i = 0; i < colCount; i++) {
if (i == colLength) break;
obj1 = document.getElementById("tb__" + startRowIndex + "_" + i.toString());
for (var j = startRowIndex + 1; j < rowCount; j++) {
obj2 = document.getElementById("tb__" + j.toString() + "_" + i.toString());
if (obj1.innerHTML == obj2.innerHTML) {
obj1.rowSpan++;
obj2.parentNode.removeChild(obj2);
} else {
obj1 = document.getElementById("tb__" + j.toString() + "_" + i.toString());
}
}
}
}
/////////////////////////////////////////
// 功能:检查表格是否规整
// 参数:tb--需要检查的表格ID
/////////////////////////////////////////
function checkTable(tb) {
if (tb.rows.length == 0) return false;
if (tb.rows[0].cells.length == 0) return false;
for (var i = 0; i < tb.rows.length; i++) {
if (tb.rows[0].cells.length != tb.rows[i].cells.length) return false;
}
return true;
}
//加载报表
function BindChart(data, ChartRenderID, ChartType, chartWidth, chartHeight) {
var ChartGuid = NewGuid();
//var ChartHeight = $("#" + ChartRenderID + "").parent().prev("div").height();
var myChart = new FusionCharts("../Chart/" + ChartType + ".swf", ChartGuid, chartWidth, chartHeight, "0", "1");
myChart.setDataXML(data);
myChart.render(ChartRenderID);
}
function NewGuid() {
var guid = "";
for (var i = 1; i <= 32; i++) {
var n = Math.floor(Math.random() * 16.0).toString(16);
guid += n;
if ((i == 8) || (i == 12) || (i == 16) || (i == 20))
guid += "-";
}
return guid;
}
//设置TABLE返回值的通用方法
function setTableRelList(id) {
var elem = document.getElementById(id);
elem["getValue"] = function () {
var arrays = [];
var n = $(elem).find("tr").size();
$(elem).find("tr").each(function (i) {
if ($(this).hasClass("classF4SF5AirLicCheckR")) {
var radioName = "";
var ithis = this;
var obj = {};
$(this).find("input").each(function () {
if ($(this).attr("type") == "radio") {
var strs = new Array();
strs = $(this).attr("name").split("_"); //字符分割
if (radioName != strs[0]) {
var chooseobject = $(ithis).find("input:radio[name^='" + strs[0] + "']:checked").val();
if (typeof (chooseobject) != "undefined") {
obj[strs[0]] = chooseobject;
} else {
obj[strs[0]] = "";
}
}
radioName = strs[0];
} else if ($(this).attr("type") == "checkbox") {
if ($(this)[0].checked) {
obj[$(this).attr("name")] = "1";
} else {
obj[$(this).attr("name")] = "0";
}
} else {
obj[$(this).attr("name")] = $(this).val();
}
});
arrays.push(obj);
}
});
return arrays;
};
elem["setValue"] = function (val) {
alert("");
};
}
//小数转百分比方法
Number.prototype.toPercent = function (n) {
n = n || 0;
if (isNaN(this)) {
return "-";
}
var flag = (Math.round(this * Math.pow(10, n + 2)) / Math.pow(10, n)).toFixed(n);
if (flag == "Infinity") {
return "-";
}
return flag + '%';
}
//扩展数组方法
/*
Array.prototype.in_array = function (e) {
for (i = 0; i < this.length; i++) {
if (this[i] == e)
return true;
}
return false;
}
*/
//显示单条飞行时间--格式00:00
function ChangeFlightTimeShow(flightTime) {
var currentHour = Math.floor(flightTime / 60);
var currentMinite = flightTime - currentHour * 60;
return currentHour + ":" + currentMinite;
}
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请
点击举报。