lists.html 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  1. {extend name="base"/}
  2. {block name="resources"}
  3. <link rel="stylesheet" href="ADMIN_CSS/order_list.css"/>
  4. {/block}
  5. {block name="main"}
  6. <div class="ns-screen layui-collapse">
  7. <div class="layui-colla-item">
  8. <h2 class="layui-colla-title">筛选</h2>
  9. <form class="layui-colla-content layui-form layui-show" lay-filter="order_list">
  10. <div class="layui-form-item">
  11. <div class="layui-inline">
  12. <label class="layui-form-label">商品名称:</label>
  13. <div class="layui-input-inline">
  14. <input type="text" class="layui-input" name="sku_name" autocomplete="off">
  15. </div>
  16. </div>
  17. </div>
  18. <div class="layui-form-item">
  19. <div class="layui-inline">
  20. <label class="layui-form-label">申请时间:</label>
  21. <div class="layui-input-inline">
  22. <input type="text" class="layui-input" name="start_time" id="start_time" placeholder="开始时间" autocomplete="off" readonly>
  23. <i class="ns-calendar"></i>
  24. </div>
  25. <div class="layui-form-mid">-</div>
  26. <div class="layui-input-inline">
  27. <input type="text" class="layui-input" name="end_time" id="end_time" placeholder="结束时间" autocomplete="off" readonly>
  28. <i class="ns-calendar"></i>
  29. </div>
  30. <button class="layui-btn layui-btn-primary date-picker-btn" onclick="datePick(7, this);return false;">近7天</button>
  31. <button class="layui-btn layui-btn-primary date-picker-btn" onclick="datePick(30, this);return false;">近30天</button>
  32. </div>
  33. </div>
  34. <div class="layui-form-item">
  35. <div class="layui-inline">
  36. <label class="layui-form-label">退款状态:</label>
  37. <div class="layui-input-inline">
  38. <select name="complain_status" lay-filter="complain_status">
  39. <option value="">全部</option>
  40. {foreach $complain_status_list as $k => $status_val}
  41. <option value="{$status_val.status}">{$status_val.name}</option>
  42. {/foreach}
  43. </select>
  44. </div>
  45. </div>
  46. <div class="layui-inline">
  47. <label class="layui-form-label">订单编号:</label>
  48. <div class="layui-input-inline">
  49. <input type="text" class="layui-input" name="order_no" autocomplete="off">
  50. </div>
  51. </div>
  52. </div>
  53. <div class="ns-form-row">
  54. <button class="layui-btn ns-bg-color" lay-submit lay-filter="btn_search">筛选</button>
  55. <button type="reset" class="layui-btn layui-btn-primary">重置</button>
  56. </div>
  57. <input type="hidden" name="status" val=""/>
  58. <input type="hidden" name="page" val=""/>
  59. </form>
  60. </div>
  61. </div>
  62. <div class="layui-tab ns-table-tab" lay-filter="order_tab">
  63. <ul class="layui-tab-title">
  64. <li class="layui-this" lay-id="">全部订单</li>
  65. {foreach $complain_status_list as $k => $status_val}
  66. {if $status_val.status!=0}
  67. <li lay-id="{$status_val.status}">{$status_val.name}</li>
  68. {/if}
  69. {/foreach}
  70. </ul>
  71. <div class="layui-tab-content">
  72. <!-- 列表 -->
  73. <div id="order_list"></div>
  74. </div>
  75. </div>
  76. <div id="order_page"></div>
  77. <div id="order_operation"></div>
  78. {/block}
  79. {block name="script"}
  80. <script src="ADMIN_JS/complain_list.js"></script>
  81. <script>
  82. var laypage,element, form, hash_url;
  83. /**
  84. *通过hash获取页数
  85. */
  86. function getHashPage(){
  87. var page = 1;
  88. var hash = location.hash;
  89. var hash_arr = hash.split("&");
  90. $.each(hash_arr,function(index, itemobj){
  91. var item_arr = itemobj.split("=");
  92. if(item_arr.length == 2){
  93. if(item_arr[0].indexOf("page") != "-1"){
  94. page = item_arr[1];
  95. }
  96. }
  97. });
  98. return page;
  99. }
  100. //从hash中获取数据
  101. function getHashData(){
  102. var hash = ns.urlReplace(location.hash);
  103. var data= [];
  104. var hash_arr = hash.split("&");
  105. var form_json = {
  106. "end_time" : "",
  107. "sku_name" : "",
  108. "order_no" : "",
  109. "complain_status" : "",
  110. "start_time" : "",
  111. "page" : ""
  112. };
  113. if(hash_arr.length > 0){
  114. // page = hash_arr[0].replace('#!page=', '');
  115. $.each(hash_arr,function(index, itemobj){
  116. var item_arr = itemobj.split("=");
  117. if(item_arr.length == 2){
  118. $.each(form_json,function(key, form_val){
  119. if(item_arr[0].indexOf(key) != "-1"){
  120. form_json[key] = item_arr[1];
  121. }
  122. })
  123. }
  124. })
  125. }
  126. form.val("order_list", form_json);
  127. setStatusTab(form_json.complain_status);
  128. return form_json;
  129. }
  130. layui.use(['laypage','laydate','form', 'element'], function(){
  131. form = layui.form;
  132. laypage = layui.laypage;
  133. element = layui.element;
  134. form.render();
  135. var laydate = layui.laydate;
  136. //渲染时间
  137. laydate.render({
  138. elem: '#start_time'
  139. ,type: 'datetime'
  140. ,change: function(value, date, endDate){
  141. $(".date-picker-btn").removeClass("selected");
  142. }
  143. });
  144. laydate.render({
  145. elem: '#end_time'
  146. ,type: 'datetime'
  147. ,change: function(value, date, endDate){
  148. $(".date-picker-btn").removeClass("selected");
  149. }
  150. });
  151. //监听筛选事件
  152. form.on('submit(btn_search)', function(data){
  153. data.field.page = 1;
  154. setHashOrderList(data.field);
  155. setStatusTab(data.field.complain_status);
  156. return false;
  157. });
  158. //批量导出
  159. form.on('submit(batch_export)', function(data){
  160. location.href = ns.url("admin/complain/exportRefundOrder",data.field);
  161. return false;
  162. });
  163. //监听Tab切换,以改变地址hash值
  164. element.on('tab(order_tab)', function(){
  165. var status = this.getAttribute('lay-id');
  166. form.val("order_list", {"complain_status":status});
  167. var hash_data = getHashList();
  168. hash_data.complain_status = status;
  169. hash_data.page = 1;
  170. setHashOrderList(hash_data);
  171. });
  172. getOrderList();//筛选
  173. getHashData();
  174. });
  175. //哈希值 订单数据
  176. function setHashOrderList(data){
  177. var hash = "";
  178. $.each(data,function(index, itemobj){
  179. if(itemobj != ""){
  180. if(hash == ""){
  181. hash += "#!"+index +"="+itemobj;
  182. }else{
  183. hash += "&"+index +"="+itemobj;
  184. }
  185. }
  186. });
  187. // window.location.href = hash;
  188. hash_url = hash;
  189. location.hash = hash;
  190. getOrderList();
  191. }
  192. function getHashList(){
  193. var hash = ns.urlReplace(location.hash);
  194. var data= [];
  195. var hash_arr = hash.split("&");
  196. var form_json = {
  197. "end_time" : "",
  198. "sku_name" : "",
  199. "order_no" : "",
  200. "complain_status" : "",
  201. "start_time" : "",
  202. "page" : ""
  203. };
  204. if(hash_arr.length > 0){
  205. // page = hash_arr[0].replace('#!page=', '');
  206. $.each(hash_arr,function(index, itemobj){
  207. var item_arr = itemobj.split("=");
  208. if(item_arr.length == 2){
  209. $.each(form_json,function(key, form_val){
  210. if(item_arr[0].indexOf(key) != "-1"){
  211. form_json[key] = item_arr[1];
  212. }
  213. })
  214. }
  215. })
  216. }
  217. return form_json;
  218. }
  219. function setStatusTab(complain_status){
  220. $(".layui-tab-title li").removeClass("layui-this");
  221. $(".layui-tab-title li").each(function(){
  222. var status = $(this).attr("lay-id");
  223. if(status == complain_status){
  224. $(this).addClass("layui-this")
  225. }
  226. });
  227. }
  228. var order = new Order();
  229. function getOrderList(){
  230. var url = ns.url("admin/complain/lists", ns.urlReplace(location.hash.replace('#!', '')));
  231. $.ajax({
  232. type : 'get',
  233. dataType: 'json',
  234. url :url,
  235. success : function(res){
  236. if(res.code == 0){
  237. order.setData(res.data);
  238. $("#order_list").html(order.fetch());
  239. //执行一个laypage实例
  240. laypage.render({
  241. elem: 'order_page',
  242. count: res.data.count,
  243. curr: getHashPage(),
  244. layout: ['count','prev', 'page', 'next'],
  245. // hash: 'page',
  246. jump: function(obj, first){
  247. //首次不执行
  248. if(!first){
  249. var hash_data = getHashData();
  250. hash_data.page = obj.curr;
  251. setHashOrderList(hash_data);
  252. // $("#btn_search").click();//筛选
  253. }
  254. }
  255. });
  256. }else{
  257. layer.msg(res.message);
  258. }
  259. }
  260. });
  261. }
  262. /**
  263. * 七天时间
  264. */
  265. function datePick(date_num,event_obj){
  266. $(".date-picker-btn").removeClass("selected");
  267. $(event_obj).addClass('selected');
  268. // alert(new Date().format("yyyy-MM-dd hh:mm"));
  269. var now_date = new Date();
  270. Date.prototype.Format = function (fmt,date_num) { //author: meizz
  271. this.setDate(this.getDate()-date_num);
  272. var o = {
  273. "M+": this.getMonth() + 1, //月份
  274. "d+": this.getDate(), //日
  275. "H+": this.getHours(), //小时
  276. "m+": this.getMinutes(), //分
  277. "s+": this.getSeconds(), //秒
  278. "q+": Math.floor((this.getMonth() + 3) / 3), //季度
  279. "S": this.getMilliseconds() //毫秒
  280. };
  281. if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
  282. for (var k in o)
  283. if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
  284. return fmt;
  285. };
  286. // var now_time = new Date().Format("yyyy-MM-dd HH:mm:ss",0);//当前日期
  287. var now_time = new Date().Format("yyyy-MM-dd 23:59:59",0);//当前日期
  288. var before_time = new Date().Format("yyyy-MM-dd 00:00:00",date_num-1);//前几天日期
  289. $("input[name=start_time]").val(before_time,0);
  290. $("input[name=end_time]").val(now_time,date_num-1);
  291. }
  292. </script>
  293. {/block}