_transferCommon.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <script>
  2. $(document).ready(function() {
  3. var currType = "<?php echo isset($_GET['itemsType'])?$_GET['itemsType']:-1;?>";
  4. if(currType){
  5. var statusText = $(".pm_type>li[val='"+currType+"']").html();
  6. $('#itemsType').val(currType);
  7. $(".pm_type_txt").text(statusText);
  8. getItem(currType);
  9. }
  10. //初始化品目
  11. var currPmId = "<?php echo isset($_GET['itemId'])?$_GET['itemId']:'';?>";
  12. if(currPmId > 0){
  13. var pmNameText = $(".pm_name>li[val='"+currPmId+"']").html();
  14. $(".pm_name_txt").text(pmNameText);
  15. $("#itemId").val(currPmId);
  16. }
  17. var transType = "<?php echo isset($_GET['transferType'])?$_GET['transferType'] :0;?>";
  18. if(transType){
  19. var transferText = $(".pm_transfer>li[val='"+transType+"']").text();
  20. $('#transferType').val(transType);
  21. $(".pm_transfer_txt").text(transferText);
  22. }
  23. $('.create-allocation').click(function(){
  24. window.location.href='<?php echo $this->createUrl('imsStore/createtransfer')?>';
  25. });
  26. $('.select-type li').click(function () {
  27. var type = $(this).attr('val');
  28. if(type>=0){
  29. getItem(type);
  30. }else{
  31. $('.select-item .diy_select_txt').html("品目名称");
  32. $('#itemId').val(0);
  33. $('.select-item ul').html('<li val="0">品目名称</li>');
  34. }
  35. });
  36. function getItem(type){
  37. if(type>=0){
  38. $.ajax({
  39. type: 'POST',
  40. url: "<?php echo $this->createUrl('imsStore/ajaxGetItem');?>",
  41. data: {type:type},
  42. async: false,
  43. dataType: 'json',
  44. success: function (result) {
  45. var liStr = '';
  46. if (result.status == 1) {
  47. var data = result.data;
  48. for(var i in data){
  49. liStr += '<li val="'+data[i].itemId+'" >'+data[i].itemName+'</li>'
  50. }
  51. $('.pm_name_txt').html('品目名称');
  52. } else {
  53. $('.pm_name_txt').html('品目名称');
  54. }
  55. $('.select-item ul').html(liStr);
  56. var currPmId = "<?php echo isset($_GET['itemId'])?$_GET['itemId']:'';?>";
  57. var pmNameText = $(".pm_name>li[val='"+currPmId+"']").html();
  58. $('#itemId').val(0);
  59. $(".select-item .diy_select_txt").text(pmNameText);
  60. },
  61. error: function (jqXHR, textStatus, errorThrown) {
  62. /*错误信息处理*/
  63. flag = true;
  64. layer.msg('提交失败');
  65. }
  66. });
  67. }
  68. }
  69. });
  70. </script>