旭捷内部项目管理系统
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

311 lines
8.0 KiB

10 months ago
  1. /*页面加载完成事件绑定二级li的点击事件*/
  2. $(function(){
  3. var window_width = $(window).width();
  4. $(".main-show").css({
  5. "width": window_width-5,
  6. "left": 2,
  7. });
  8. //给只有二级菜单的li绑定事件负责背景颜色
  9. $("li.second-li").bind("click", function(){
  10. $(this).parents("ul.custom-style").find("li").removeClass("active");
  11. $(this).addClass("active");
  12. });
  13. $("ul").on("hide.bs.dropdown", function(){
  14. return false;
  15. });
  16. //失去open后的事件
  17. $("li.first-li").bind("click", function(){
  18. $(this).siblings("li.open").find("li").removeClass("active");
  19. if($(this).hasClass('open')){
  20. $(this).removeClass("open");
  21. }else{
  22. $(this).addClass("open");
  23. }
  24. });
  25. //负责有三级菜单的二级li的图标控制和ul的伸展和塑回
  26. $("li.dropdown-submenu").bind("click", function(){
  27. if($(this).hasClass('open')){
  28. $(this).removeClass("open");
  29. $(this).removeClass("active");
  30. $(this).find("ul.second-menu").removeAttr("display");
  31. }else{
  32. $(this).addClass("open");
  33. $(this).find("ul.second-menu").attr("display", "block");
  34. }
  35. });
  36. //数据展示
  37. $("a.header-show").bind("click", function(){
  38. var url = $(this).attr("href");
  39. $.ajax({
  40. url: url,
  41. type:"GET",
  42. data:{},// 你的formid
  43. dataType:"Html",
  44. success: function (data) {
  45. $(".main-show").html(data);
  46. },
  47. error: function(data) {
  48. var responseText = data.responseText;
  49. var json_str = JSON.parse(responseText);
  50. var status = json_str.status;
  51. var message = json_str.message;
  52. //判断是否是session超时
  53. if(403==status){
  54. layer.alert(message,function(){
  55. window.location.href="/login";
  56. });
  57. }
  58. layer.closeAll('loading');
  59. }
  60. })
  61. return false;
  62. });
  63. });
  64. /* 停止隐藏ul */
  65. function stop(){
  66. event.stopPropagation();
  67. }
  68. //展示修改密码模态框
  69. function editPasswordPage(){
  70. $("#first_password").val("");
  71. $("#confirm_password").val("");
  72. $("#user_password").modal();
  73. }
  74. //密码修改验证
  75. $("input.checkedPassword").bind("blur",function(){
  76. var first_password = $.trim($("#first_password").val());
  77. var confirm_password = $.trim($("#confirm_password").val());
  78. if(first_password==""){
  79. layer.msg("密码不能为空!");
  80. return false;
  81. }
  82. if(confirm_password==""){
  83. layer.msg("确认密码不能为空!");
  84. return false;
  85. }
  86. if(confirm_password!=first_password){
  87. layer.msg("确认密码和密码必须相同!");
  88. return false;
  89. }
  90. });
  91. //提交使用
  92. function checkedPassword(){
  93. var first_password = $.trim($("#first_password").val());
  94. var confirm_password = $.trim($("#confirm_password").val());
  95. if(first_password==""){
  96. layer.msg("密码不能为空!");
  97. return false;
  98. }
  99. if(confirm_password==""){
  100. layer.msg("确认密码不能为空!");
  101. return false;
  102. }
  103. if(confirm_password!=first_password){
  104. layer.msg("确认密码和密码必须相同!");
  105. return false;
  106. }
  107. }
  108. //修改密码
  109. function passwordSave(){
  110. checkedPassword();
  111. var first_password = $.trim($("#first_password").val());
  112. var confirm_password = $.trim($("#confirm_password").val());
  113. $.ajax({
  114. url: "/user/passwordSave",
  115. type:"POST",
  116. data:{"id": $("#current_id").val(),
  117. "password": first_password,
  118. "confirm_password": confirm_password
  119. },// 你的formid
  120. dataType:"JSON",
  121. success: function (data) {
  122. if (data.success) {
  123. layer.msg(data.msg);
  124. $("#password_cancel").click();
  125. window.location.href="/login";
  126. }else{
  127. layer.msg(data.msg);
  128. }
  129. },
  130. error: function(data) {
  131. var responseText = data.responseText;
  132. var json_str = JSON.parse(responseText);
  133. var status = json_str.status;
  134. var message = json_str.message;
  135. //判断是否是session超时
  136. if(403==status){
  137. layer.alert(message,function(){
  138. window.location.href="/login";
  139. });
  140. }
  141. layer.closeAll('loading');
  142. }
  143. });
  144. }
  145. //清除输入内容
  146. function clear(){
  147. //初始化信息
  148. $("#username").val("");
  149. $("#display").val("");
  150. $("#password").val("");
  151. $("#user_des").val("");
  152. $("#id").val("0");
  153. $("#user_status").val("0");
  154. }
  155. //修改用户页面
  156. function editUserPage(){
  157. clear();
  158. var id = $("#current_id").val();
  159. var username = $("#current_username").val();
  160. var display = $("#current_display").val();
  161. $("#operate_username").val(username);
  162. $("#operate_display").val(display);
  163. $("#operate_id").val(id);
  164. //显示隐藏的数据
  165. $("#operate_user_modal").modal();
  166. }
  167. //用户的更新和新增
  168. function operateUserSave(){
  169. var username = $.trim($("#operate_username").val());
  170. var display = $.trim($("#operate_display").val());
  171. if (username=="") {
  172. layer.msg("请输入用户账号!");
  173. return false;
  174. }
  175. if (display=="") {
  176. layer.msg("请输入用户名称!");
  177. return false;
  178. }
  179. layer.load(2);
  180. /**
  181. * 保存数据
  182. */
  183. $.ajax({
  184. url: "/user/operateUserSave",
  185. type:"POST",
  186. data:$('#operate_user_form').serialize(),// 你的formid
  187. dataType:"JSON",
  188. success: function (data) {
  189. layer.closeAll('loading');
  190. if (data.success) {
  191. layer.msg(data.msg);
  192. clear();
  193. $("#operate_user_cancel").click();
  194. }else{
  195. layer.msg(data.msg);
  196. }
  197. },
  198. error: function(data) {
  199. var responseText = data.responseText;
  200. var json_str = JSON.parse(responseText);
  201. var status = json_str.status;
  202. var message = json_str.message;
  203. //判断是否是session超时
  204. if(403==status){
  205. layer.alert(message,function(){
  206. window.location.href="/login";
  207. });
  208. }
  209. layer.closeAll('loading');
  210. }
  211. })
  212. }
  213. //获取当天日期时间
  214. function getNowFormatDate() {
  215. var date = new Date();
  216. var seperator1 = "-";
  217. var seperator2 = ":";
  218. var month = date.getMonth() + 1;
  219. var strDate = date.getDate();
  220. if (month >= 1 && month <= 9) {
  221. month = "0" + month;
  222. }
  223. if (strDate >= 0 && strDate <= 9) {
  224. strDate = "0" + strDate;
  225. }
  226. var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate
  227. + " " + date.getHours() + seperator2 + date.getMinutes()
  228. + seperator2 + date.getSeconds();
  229. return currentdate;
  230. }
  231. //获取当天日期时间
  232. function getNowFormatYMDHm() {
  233. var date = new Date();
  234. var seperator1 = "-";
  235. var seperator2 = ":";
  236. var month = date.getMonth() + 1;
  237. var strDate = date.getDate();
  238. var hour = date.getHours();
  239. var minutes = date.getMinutes();
  240. if (month >= 1 && month <= 9) {
  241. month = "0" + month;
  242. }
  243. if (strDate >= 0 && strDate <= 9) {
  244. strDate = "0" + strDate;
  245. }
  246. if (hour >= 0 && hour <= 9){
  247. hour = "0" + hour;
  248. }
  249. if (minutes >= 0 && minutes <= 9){
  250. minutes = "0" + minutes;
  251. }
  252. var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate
  253. + " " + hour + seperator2 + minutes;
  254. return currentdate;
  255. }
  256. //获取当天日期时间
  257. function getNowDate() {
  258. var nowDate = new Date();
  259. var year = nowDate.getFullYear();
  260. var month = nowDate.getMonth() + 1 < 10 ? "0" + (nowDate.getMonth() + 1)
  261. : nowDate.getMonth() + 1;
  262. var day = nowDate.getDate() < 10 ? "0" + nowDate.getDate() : nowDate
  263. .getDate();
  264. var dateStr = year + "-" + month + "-" + day;
  265. return dateStr;
  266. }
  267. axspost=function(url, data, successfn) {
  268. $.ajax({
  269. type: "post",
  270. contentType: 'application/json',
  271. data: JSON.stringify(data),
  272. url: url,
  273. dataType: "JSON",
  274. beforeSend: function(request) {
  275. request.setRequestHeader("token", $.cookie('token'));
  276. },
  277. success: function (d) {
  278. successfn(d);
  279. },
  280. error: function (data) {
  281. var responseText = data.responseText;
  282. var json_str = JSON.parse(responseText);
  283. var status = json_str.status;
  284. var message = json_str.message;
  285. //判断是否是session超时
  286. if (403 == status) {
  287. layer.alert(message, function () {
  288. window.location.href = "/login";
  289. });
  290. }
  291. layer.closeAll('loading');
  292. }
  293. })
  294. }