function thisDate() { var now = new Date() var year = now.getFullYear() var month = now.getMonth() var date = now.getDate() if (month < 1) month = 1 else month = month + 1 return year + "-" + (month < 10 ? "0" + month : month) + "-" + (date < 10 ? "0" + date : date) + " " } function CurentTime() { var now = new Date() var hh = now.getHours() var mm = now.getMinutes() var ss = now.getTime() % 60000 ss = (ss - (ss % 1000)) / 1000 var clock = hh + ":" if (mm < 10) clock += "0" clock += mm + ":" if (ss < 10) clock += "0" clock += ss return clock } function thisWeek() { var todayDate = new Date() if (todayDate.getDay() == 1) return "星期一" else if (todayDate.getDay() == 2) return "星期二" else if (todayDate.getDay() == 3) return "星期三" else if (todayDate.getDay() == 4) return "星期四" else if (todayDate.getDay() == 5) return "星期五" else if (todayDate.getDay() == 6) return "星期六" else if (todayDate.getDay() == 0) return "星期日" } $.fn.extend({ resizeDataGrid: function (heightMargin, widthMargin, minHeight, minWidth, iswidth) { var height = document.documentElement.clientHeight - heightMargin var width = $(document.body).width() - widthMargin height = height < minHeight ? minHeight : height width = width < minWidth ? minWidth : width if (iswidth) { $(this).datagrid("resize", { height: height, width: width, }) } else { $(this).datagrid("resize", { height: height, }) } }, }) function ResizeDG(dgId, height, width) { $("#" + dgId).resizeDataGrid(height, width, 0, 0, true) $(window).resize(function () { $("#" + dgId).resizeDataGrid(height, width, 0, 0, true) }) } function ResizeHeghtDG(dgId, height) { $("#" + dgId).resizeDataGrid(height, 0, 0, 0, false) $(window).resize(function () { $("#" + dgId).resizeDataGrid(height, 0, 0, 0, false) }) } //判断是否全是中文 function isAllChinese(str) { var re = /^[\u4E00-\u9FA5]+$/ if (!re.test(str)) { return false } return true } // 将JeasyUI datetimebox控件获取的字符串转换为整型字符串 function datetimeStrToNum(str) { if (str && str.length == 19) { var day = str.substring(0, 10) var time = str.substring(11, 19) var arr = day.split("-") var str = arr[0] + arr[1] + arr[2] arr = time.split(":") str += arr[0] + arr[1] + arr[2] } return str } /** * 全选或全不选checkbox * @param myName 主控制checkbox的name属性 * @param otherName 受控制checkbox的name属性 */ function changeAllCheckBox(myName, otherName) { var val = $(":checkbox[name='" + myName + "']").attr("checked") if (val) { $(":checkbox[name='" + otherName + "']").attr("checked", "true") } else { $(":checkbox[name='" + otherName + "']").removeAttr("checked") } } /** * 获取所有checkbox选中的值 * @param name checkbox的name属性 * @returns {Array} */ function getCheckBoxValue(name) { var val = new Array() $(":checkbox[name='" + name + "'][checked='checked']").each(function (i) { val[i] = $(this).val() }) return val } function getCheckBoxTitle(name) { var val = new Array() $(":checkbox[name='" + name + "'][checked='checked']").each(function (i) { val[i] = $(this).attr("title") }) return val } /** * 获取select选中的值 * @param name select的name属性 * @returns select的value值 */ function getSelectValue(name) { return $("select[name='" + name + "']").val() } /** * 让指定的select选中指定值 * @param name select的name属性 * @param value select的value值 */ function selectOption(name, value) { $("select[name='" + name + "']") .find("option[value='" + value + "']") .attr("selected", true) } /** * 让指定的radio选中指定值 * @param name radio的name属性 * @param value 选中值 */ function selectRadio(name, value) { $(":radio[name='" + name + "'][value='" + value + "']").attr("checked", true) } /** * 获取radio选中的值 * @param name radio的name属性 */ function getRadioValue(name) { return $(":radio[name='" + name + "'][checked='checked']").val() } function getRadioTitle(name) { return $(":radio[name='" + name + "'][checked='checked']").attr("title") } /** * 获取上传的文件后缀名 * @param id file的id属性 * @returns 文件后缀名 */ function getFileExtName(id) { var path = $("#" + id).val() var extName = null if (path) { var index = path.lastIndexOf(".") + 1 extName = path.substring(index).toLowerCase() } return extName } /** * 删除左右两端的空格 */ function trim(str) { return str.replace(/(^\s*)(\s*$)/g, "") } /** * 删除左边的空格 */ function ltrim(str) { return str.replace(/(^\s*)/g, "") } /** * 删除右边的空格 */ function rtrim(str) { return str.replace(/(\s*$)/g, "") } /** * 对数据进行补0处理 * @param num 待补0的原生数据 * @param n 数据位数 * @returns */ function padNum(num, n) { var len = num.toString().length while (len < n) { num = "0" + num len++ } return num }