Sin descripción
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.

users_collection_index.js 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. // 管理相关
  2. var relatedContent = $('.related-content');
  3. var managementButton = $('#management-button');
  4. function handleClick() {
  5. if (relatedContent.is(':hidden')) {
  6. relatedContent.show();
  7. managementButton.text('完成');
  8. } else {
  9. relatedContent.hide();
  10. managementButton.text('管理');
  11. }
  12. }
  13. managementButton.on('click', handleClick);
  14. $(function() {
  15. $('input[name*=ids]').click(function() {
  16. if ($('input[name*=ids]').length == $('input[name*=ids]:checked').length) {
  17. $('#checkboxAll').prop('checked', true);
  18. } else {
  19. $('#checkboxAll').prop('checked', false);
  20. }
  21. });
  22. $('#checkboxAll').click(function() {
  23. $('input[type=checkbox]').prop('checked', this.checked);
  24. });
  25. });
  26. // 批量删除文档
  27. function batchDelCollection(obj) {
  28. var ids = [];
  29. $('input[name*=ids]').each(function(i, o) {
  30. if ($(o).is(':checked')) ids.push($(o).val());
  31. });
  32. if (0 === parseInt(ids.length)) {
  33. showLayerMsg('请选择需要删除的收藏');
  34. return false;
  35. }
  36. showConfirmBox('确认删除选中收藏?', null, function() {
  37. showLayerLoad();
  38. $.ajax({
  39. url : $(obj).attr('data-url'),
  40. data: {del_id: ids},
  41. type: "POST",
  42. dataType: 'json',
  43. success: function (res) {
  44. layer.closeAll();
  45. if (1 === parseInt(res.code)) {
  46. for (var i = 0; i < ids.length; i++) {
  47. $('#collection_' + ids[i]).remove();
  48. }
  49. showLayerMsg(res.msg, 2, function() {
  50. window.location.reload();
  51. });
  52. } else {
  53. showLayerAlert(res.msg);
  54. }
  55. },
  56. error: function(e) {
  57. layer.closeAll();
  58. showLayerAlert(e.responseText);
  59. }
  60. });
  61. });
  62. }