weight.html 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. {Template header}
  2. <body>
  3. <div class="warp">
  4. <div class="fixed">
  5. <ul class="search">
  6. <li>类目:<select name="category" class="select">
  7. <option value="">请选择</option>{loop typeclass(16) as $val}
  8. <option value="{$val['id']}">{$val['title']}</option>{/loop}</select></li>
  9. <!--<li>重量:<select name="weight" class="select">
  10. <option value="">请选择</option>{loop $weight as $val}
  11. <option value="{$val['id']}">{$val['title']}</option>{/loop}</select></li>-->
  12. <input type="hidden" name="arg_array" value="{$arg_array}" />
  13. <li>名称:<input value="" name="title" type="text" style="width:280px;"></li>
  14. <li>SKU:<input value="" name="sku" type="text" style="width:280px;"></li>
  15. <li><span>确 定</span></li>
  16. </ul>
  17. <div class="control">
  18. <select name="lm" class="dcmb">
  19. <option value="">请选择</option>
  20. {loop typeclass(16) as $val}
  21. <option value="{$val['id']}">{$val['title']}</option>
  22. {/loop}
  23. </select>
  24. <a href="/weight/mb?excel=1">模板下载</a>
  25. <a href="javascript:void(0);" class="drweightexcel">导入数据</a>
  26. <a href="javascript:void(0);" class="check">删 除</a>
  27. <a href="javascript:void(0);" class="weightdcsj">导出数据</a>
  28. </div>
  29. <table class="datatitle data" border="0" style="border-collapse:collapse;">
  30. <tr>
  31. <td><label onClick="swapCheck()"><input name="checkbox" type="checkbox" class="regular-checkbox"></label></td>
  32. <td>产品名称</td>
  33. <td>标签SKU</td>
  34. <td>重量</td>
  35. </tr>
  36. </table>
  37. </div>
  38. <table class="datatext data" border="0" style="border-collapse:collapse;">
  39. </table>
  40. <div class="bomf"></div>
  41. </div>
  42. <div style="display:none;">
  43. <input id="upload-file" name="files" accept="image/xls,image/xlsx" type="file">
  44. </div>
  45. <script>
  46. var dataurl = "/weight";
  47. var editurl = "/weight/edit/";
  48. var editdj = 1;
  49. var editt = "产品配置 - 修改";
  50. var customon = 1;
  51. function custom(){
  52. $(".data tr").each(function() {
  53. $(this).find('td:eq(0)').css("width","1%");
  54. });}
  55. $(".weightdcsj").click(function() {
  56. var f = "";
  57. $(".select").each(function() {
  58. f = f + $(this).attr("name") + "=" + $(this).children("option:selected").val() + "&";
  59. });
  60. $("input:text").each(function() {
  61. f = f + $(this).attr("name") + "=" + $(this).val() + "&";
  62. });
  63. window.location.href = "/weight/excel?excel=1&"+f;
  64. });
  65. $(".drweightexcel").click(function() {
  66. var xz = $("select[name='lm']").children("option:selected").val();
  67. if(xz == '')
  68. {
  69. layx.alert('错误',"没有选择需要导入的类型!",function(id,button){
  70. },{dialogIcon:'error'});
  71. return false;
  72. }
  73. var features = $(".control select[name='lm']").children("option:selected").val();
  74. var title = $(".control select[name='lm']").children("option:selected").html();
  75. var dr = $(this);
  76. $("#upload-file").click();
  77. $("#upload-file").unbind("change");
  78. $("#upload-file").bind("change",function(){
  79. weight(dr,title,features);
  80. layx.load('loadId','导入中,请稍后',{shadable:0.6});
  81. });
  82. });
  83. function weight(dr,title,features){
  84. var file = document.getElementById("upload-file").files[0];
  85. var data = new FormData();
  86. data.append("userfile",file);
  87. $.ajax({
  88. data : data,
  89. type : "POST",
  90. url : dataurl+"/drexcel/"+features+'/'+title,
  91. cache : false,
  92. contentType : false,
  93. processData : false,
  94. dataType:"json",
  95. success: function(a) {
  96. layx.destroy('loadId');
  97. if (a && a.success) {
  98. if(a.error == 1)
  99. {
  100. errora(a);
  101. }
  102. else
  103. {
  104. errorb(a);
  105. }
  106. } else {
  107. errorc(a);
  108. }
  109. }
  110. });
  111. }
  112. </script>
  113. {Template footer}