export_form.html 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. </head>
  6. <body>
  7. <style>
  8. .move_item{width:18%;}
  9. </style>
  10. <form action="{:U('order/index')}" method="post" id="export_form" class="form-horizontal form-search " role="form">
  11. <input type="hidden" name="controller" value="order/order" />
  12. <?php
  13. foreach($post_data as $key => $val){
  14. ?>
  15. <input type="hidden" name="{$key}" value="{$val}" />
  16. <?php } ?>
  17. <input type="hidden" name="c" value="order" />
  18. <input type="hidden" name="a" value="index" />
  19. <div class="layui-fluid">
  20. <div class="layui-row layui-col-space15">
  21. <div class="layui-col-md12">
  22. <div class="layui-card">
  23. <div class="layui-card-header">拖动排序</div>
  24. <div class="layui-card-body multi-img-details">
  25. <?php foreach( $columns as $key => $val ){ ?>
  26. <label class="move_item">
  27. <input type="checkbox" lay-skin="primary" name="order_index" value="{$val['field']}" class="item_input" <?php if( $val['is_check'] ==1 ){ ?>checked<?php } ?> /><?php echo $val['title']; ?>
  28. </label>
  29. <?php } ?>
  30. </div>
  31. </div>
  32. </div>
  33. <div class='layui-row'>
  34. <div class="layui-col-sm-12">
  35. <div class="modal-footer" style="text-align: left">
  36. <button type="submit" class="btn " id="sub_orderexport" name="cancelsend" value="yes">确认导出</button>
  37. <input type="hidden" name="modify_explode_arr" id="modify_explode_arr" value="" />
  38. </div>
  39. </div>
  40. </div>
  41. </div>
  42. </div>
  43. </form>
  44. <script type="text/javascript" src="/static/js/jquery-migrate-1.1.1.js"></script>
  45. <script src="/static/js/jquery-ui.min.js"></script>
  46. <script>
  47. $(function(){
  48. $('#sub_orderexport').click(function(){
  49. var load_arr = [];
  50. $('.item_input').each(function(){
  51. console.log( $(this).val() );
  52. if( $(this).is(':checked') ) {
  53. // do something
  54. load_arr.push( $(this).val() );
  55. }
  56. })
  57. if( load_arr.length <= 0 )
  58. {
  59. alert('请选择导出项');
  60. return false;
  61. }
  62. var load_arr_str = load_arr.join(',');
  63. $('#modify_explode_arr').val(load_arr_str);
  64. layer.closeAll();
  65. $('#export_form').submit();
  66. return false;
  67. })
  68. })
  69. </script>
  70. <script>
  71. $(function () {
  72. // 拖拽时开始滚动的间距
  73. var scrollingSensitivity = 20
  74. // 拖拽时滚动速度
  75. let scrollingSpeed = 20
  76. // 拖拽前的父级节点
  77. let dragBeforeParentNode = null
  78. // 初始化拖拽函数
  79. $('.multi-img-details').sortable({
  80. // 自适应placeholder的大小
  81. forceHelperSize: true,
  82. // 拖拽时的鼠标形状
  83. cursor: '-webkit-grabbing',
  84. // 拖拽的父级节点(该节点一定要注意,配置错误会导致当前屏幕外的元素没法自动滚动拖拽,两列之间拖拽的滚动也会出问题)
  85. appendTo: '.layui-form-item',
  86. // 拖拽时的倾斜度
  87. rotate: '5deg',
  88. // 延迟时间(毫秒),避免和click同时操作时出现的冲突
  89. delay: 0,
  90. // 拖拽到边框出现滚动的间距,
  91. scrollSensitivity: scrollingSensitivity,
  92. // 应用于拖拽空白区域的样式
  93. placeholder: 'portlet-placeholder ui-state-highlight',
  94. // 允许拖拽预留空白区域
  95. forcePlaceholderSize: false,
  96. // 多个列表之间的拖拽的dom元素
  97. connectWith: '.multi-img-details',
  98. // 鼠标到区域则填充
  99. tolerance: "pointer",
  100. // 可以拖拽的项
  101. items: '.move_item',
  102. // 填充动画
  103. revert: 0,
  104. // 拖拽结束函数
  105. stop: (e, ui) => {
  106. // 当前拽入的元素
  107. let item = $(ui.item)
  108. // 当前拽入元素的下标
  109. let index = item.index()
  110. let kid = ''
  111. // xxxx 这里面可以操作数据更新
  112. },
  113. // 开始拖拽时的函数
  114. start: (e, ui) => {
  115. // 拖拽前的父级节点
  116. dragBeforeParentNode = ui.item[0].parentNode
  117. // 让placeholder和源高度一致
  118. ui.helper.addClass('item').width(110)
  119. // xxxx 这里可以记录一些拖拽前的元素属性
  120. },
  121. // 处理两列滚动条问题
  122. sort: function (event, ui) {
  123. var scrollContainer = ui.placeholder[0].parentNode
  124. // 设置拽入的列表的滚动位置
  125. var overflowOffset = $(scrollContainer).offset()
  126. if ((overflowOffset.top + scrollContainer.offsetHeight) - event.pageY <
  127. scrollingSensitivity) {
  128. scrollContainer.scrollTop = scrollContainer.scrollTop + scrollingSpeed
  129. } else if (event.pageY - overflowOffset.top < scrollingSensitivity) {
  130. scrollContainer.scrollTop = scrollContainer.scrollTop - scrollingSpeed
  131. }
  132. }
  133. }).disableSelection()
  134. })
  135. </script>