share.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /**
  2. * Created with PyCharm.
  3. * User: Administrator
  4. * Date: 14-9-11
  5. * Time: 上午11:18
  6. * To change this template use File | Settings | File Templates.
  7. */
  8. /* 共用 js 模块 *
  9. /* 时间插件 使用 */
  10. (function($){
  11. $.setStartTime = function(){
  12. $('.startDate').datepicker({
  13. dateFormat: "yy/mm/dd",
  14. maxDate: "+d",
  15. onClose : function(dateText, inst) {
  16. $( "#endDate" ).datepicker( "show" );
  17. },
  18. onSelect:function(dateText, inst) {
  19. $( "#endDate" ).datepicker( "option","minDate",dateText );
  20. },
  21. });
  22. };
  23. $.setEndTime = function(){
  24. $(".endDate").datepicker({
  25. dateFormat: "yy/mm/dd",
  26. maxDate: "+d",
  27. defaultDate : new Date(),
  28. onClose : function(dateText, inst) {
  29. if (dateText < $("input[name=startDate]").val()){
  30. $( "#endDate" ).datepicker( "show" );
  31. alert("结束日期不能小于开始日期!");
  32. //$("#endDate").val(newdate)
  33. }
  34. }
  35. });
  36. };
  37. $.date = function(){
  38. $('.date').datepicker(
  39. $.extend({showMonthAfterYear:true}, $.datepicker.regional['zh-CN'],
  40. {'showAnim':'','dateFormat':'yy/mm/dd','changeMonth':'true','changeYear':'true',
  41. 'showButtonPanel':'true'}
  42. ));
  43. };
  44. $.datepickerjQ = function(){
  45. $(".ui-datepicker-time").on("click",function(){
  46. $(".ui-datepicker-css").css("display","block")
  47. });
  48. $(".ui-kydtype li").on("click",function(){
  49. $(".ui-kydtype li").removeClass("on").filter($(this)).addClass("on");
  50. // getAppCondtion();
  51. });
  52. $(".ui-datepicker-quick input").on("click",function(){
  53. var thisAlt = $(this).attr("alt");
  54. var dateList = timeConfig(thisAlt);
  55. $(".ui-datepicker-time").val(dateList);
  56. $(".ui-datepicker-css").css("display","none");
  57. $("#ui-datepicker-div").css("display","none")
  58. // getAppCondtion()
  59. });
  60. $(".ui-close-date").on("click",function(){
  61. $(".ui-datepicker-css").css("display","none")
  62. $("#ui-datepicker-div").css("display","none")
  63. //inst.dpDiv.css({"display":"none"})
  64. });
  65. $(".startDate").on("click",function(){
  66. $(".endDate").attr("disabled",false);
  67. });
  68. }
  69. })(jQuery);
  70. $(function(){
  71. $.setStartTime();
  72. $.setEndTime();
  73. $.datepickerjQ();
  74. // var nowDate = new Date();
  75. // timeStr = nowDate.getFullYear() + '/' + (nowDate.getMonth()+1) + '/' + nowDate.getDate();
  76. // nowDate.setDate(nowDate.getDate()+parseInt(-1));
  77. // var endDateStr = nowDate.getFullYear() + '/'+ (nowDate.getMonth()+1) + '/' + nowDate.getDate();
  78. // $(".ui-datepicker-time").attr("value",endDateStr +"一"+ timeStr)
  79. // $("#startDate").attr("value",endDateStr)
  80. // $("#endDate").attr("value",timeStr)
  81. });
  82. function timeConfig(time){
  83. //快捷菜单的控制
  84. var nowDate = new Date();
  85. timeStr = '一' + nowDate.getFullYear() + '/' + (nowDate.getMonth()+1) + '/' + nowDate.getDate();
  86. nowDate.setDate(nowDate.getDate()+parseInt(time));
  87. var endDateStr = nowDate.getFullYear() + '/'+ (nowDate.getMonth()+1) + '/' + nowDate.getDate();
  88. if(time == -1){
  89. endDateStr += '一' + endDateStr;
  90. }else{
  91. endDateStr += timeStr;
  92. }
  93. return endDateStr;
  94. }
  95. function datePickers(){
  96. //自定义菜单
  97. var startDate = $("#startDate").val();
  98. var endDate = $("#endDate").val();
  99. var dateList = startDate +'一'+ endDate;
  100. $(".ui-datepicker-time").val(dateList);
  101. $(".ui-datepicker-css").css("display","none");
  102. // getAppCondtion()
  103. }
  104. function cleanDate() {
  105. $(".ui-datepicker-time").val('');
  106. }
粤ICP备19079148号