script.blade.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <script>
  2. function changeSelect(_self, action) {
  3. if(action == 'exclude' || action == 'view_exclude')
  4. {
  5. var dom = $('#temp_exclude_spu');
  6. } else {
  7. var dom = $('#temp_selected_spu');
  8. }
  9. if ($(_self).hasClass('select')) {
  10. var btnVal = $(_self).data('id');
  11. var string = dom.val();
  12. var ids = string.split(',');
  13. var index = ids.indexOf(String(btnVal));
  14. if(!!~index)
  15. {
  16. ids.splice(index, 1);
  17. }
  18. var str = ids.join(',');
  19. $(_self).removeClass('select btn-info').addClass('btn-warning unselect').find('i').removeClass('fa-check').addClass('fa-times');
  20. dom.val(str);
  21. } else {
  22. var btnVal = $(_self).data('id');
  23. var str = dom.val() + ',' + btnVal;
  24. if (str.substr(0, 1) == ',') str = str.substr(1);
  25. $(_self).addClass('select btn-info').removeClass('btn-warning unselect').find('i').addClass('fa-check').removeClass('fa-times');
  26. dom.val(str);
  27. }
  28. paraDiscount.ids = str;
  29. console.log(paraDiscount.ids);
  30. }
  31. function sendIds(action) {
  32. if(action == 'exclude' || action == 'view_exclude')
  33. {
  34. var string = $('#temp_exclude_spu').val();
  35. $('#exclude_spu').val(string);
  36. } else {
  37. var string = $('#temp_selected_spu').val();
  38. $('#selected_spu').val(string);
  39. }
  40. if (string) {
  41. var count = string.split(',').length;
  42. } else {
  43. count = 0
  44. }
  45. if(action == 'exclude' || action == 'view_exclude')
  46. {
  47. $('.countExcludeSpu').html(count);
  48. } else {
  49. $('.countSpu').html(count);
  50. }
  51. $('#spu_modal').modal('hide');
  52. }
  53. </script>