goods_selector_op.html 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <div class="modal-dialog" id="goods-selector-opmodal-{$goods['id']}">
  2. <div class="modal-content">
  3. <div class="modal-header">
  4. <button data-dismiss="modal" class="close hasoption-close" type="button">×</button>
  5. <h4 class="modal-title">商品设置选项</h4>
  6. </div>
  7. <div class="modal-body">
  8. <div class="alert alert-danger hide" id="ophtml"></div>
  9. <table class="table" style="width:100%;margin-top: 10px">
  10. <thead>
  11. <tr>
  12. <th style=""><?php if( empty($options)){ ?>商品<?php }else{ ?>规格<?php } ?>名称</th>
  13. <th style="width:100px;">原价</th>
  14. <th style="width:100px;">库存</th>
  15. <?php foreach($column as $colk => $col){ ?>
  16. <th style="width:100px;">
  17. {$col['title']}
  18. </th>
  19. <?php } ?>
  20. <?php if( !empty($options)){ ?>
  21. <th style="width:100px;">
  22. 全选 <input type="checkbox">
  23. </th>
  24. <?php } ?>
  25. </tr>
  26. </thead>
  27. <tbody id="param-items" class="ui-sortable">
  28. <!--没有规格-->
  29. <?php if( empty($options)){ ?>
  30. <tr class="multi-product-item goods-item">
  31. <td>{$goods['title']}</td>
  32. <td>&yen;{$goods['marketprice']}</td>
  33. <td>{$goods['total']}</td>
  34. <?php foreach( $column as $colk => $col){ ?>
  35. <td>
  36. <input name="{$col['name']}" type="{$col['type']}" class="form-control" value="{$col['default']}" max="{$col['max']}" min="{$col['min']}">
  37. </td>
  38. <?php } ?>
  39. </tr>
  40. <?php }else{ ?>
  41. <!--有规格-->
  42. <?php foreach($options as $ok => $option){ ?>
  43. <tr class="multi-product-item goods-item">
  44. <td>{$option['title']}</td>
  45. <td>&yen;{$option['marketprice']}</td>
  46. <td>{$option['stock']}</td>
  47. <?php foreach($column as $colk => $col){ ?>
  48. <td>
  49. <input name="{$col['name']}" type="{$col['type']}" class="form-control" value="{$col['default']}" max="{$col['max']}" min="{$col['min']}">
  50. </td>
  51. <?php } ?>
  52. <td>
  53. <input type="checkbox" class="form-control option-item" value="{$option['id']}" data-price="{$option['marketprice']}">
  54. </td>
  55. </tr>
  56. <?php } ?>
  57. <?php } ?>
  58. </tbody>
  59. </table>
  60. </div>
  61. <div class="modal-footer">
  62. <button class="btn btn-primary goods-selector-op-<?php if( empty($options)){ ?>goods<?php }else{ ?>option<?php } ?>" type="button" id="option_submit" data-id="{$id}" data-dismiss="modal">确认</button>
  63. <button data-dismiss="modal" class="btn btn-default" type="button">取消</button>
  64. </div>
  65. </div>
  66. </div>
  67. <script>
  68. //规格选项状态渲染
  69. $(function () {
  70. var goodsid = {$goods['id']};
  71. var goods = model.selectedPool[goodsid];
  72. var htm = $(model.ele).find('.op-html').html();
  73. if (htm){
  74. $('#ophtml').html(htm);
  75. $('#ophtml').removeClass('hide');
  76. }
  77. // 如果有规格
  78. if (goods.options != undefined && model.option_switch == 1){
  79. $.each(goods.options,function (i, v) {
  80. var id = v.id;
  81. //渲染勾选
  82. var p = $('.option-item[value="'+id+'"]').attr('checked',true);
  83. //渲染字段
  84. var column = v.column;
  85. if (column != undefined)
  86. $.each(column,function (colname,colvalue) {
  87. $('.option-item[value="'+id+'"]').parent().parent().find('input[name="'+colname+'"]').val(colvalue);
  88. });
  89. });
  90. }else{
  91. // 没有规格
  92. var column = goods.column;
  93. if (column != undefined)
  94. $.each(column,function (colname,colvalue) {
  95. $('#goods-selector-opmodal-'+goodsid).find('input[name="'+colname+'"]').val(colvalue);
  96. });
  97. }
  98. model.selectedPool = undefined;
  99. model.ele = undefined;
  100. });
  101. </script>