You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

des_order_list.js 14 KiB

3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489
  1. var httpData;
  2. var pagesize = 10;
  3. var tttHTML = '';
  4. window.onload = function() {
  5. tttHTML = document.getElementById("tableOrder").innerHTML;
  6. var cur = "";
  7. var currpage = getPar('currpage');
  8. var timelimit = '';
  9. var starttime = '';
  10. var endtime = '';
  11. var ordersource = '';
  12. var moresearch = '';
  13. var typelimit = '';
  14. var ordersource_text = '';
  15. if(!currpage) {
  16. cur = 1;
  17. $('#starttime').val(getDateTime(12));
  18. $('#endtime').val(getDateTime(13));
  19. }else{
  20. cur = currpage;
  21. timelimit = getPar('timelimit');
  22. $('#timelimit').val(timelimit);
  23. starttime = getPar('starttime');
  24. $('#starttime').val(starttime);
  25. endtime = getPar('endtime');
  26. $('#endtime').val(endtime);
  27. ordersource = getPar('ordersource');
  28. $('#ordersource').attr('changeid',ordersource);
  29. ordersource_text = getPar('ordersource_text');
  30. $('#ordersource').val(ordersource_text);
  31. moresearch = getPar('moresearch');
  32. $('#moresearch').val(moresearch);
  33. typelimit = getPar('typelimit');
  34. $('#typelimit').val(typelimit);
  35. }
  36. searchBtnClicked(cur,timelimit,starttime,endtime,ordersource,moresearch,typelimit,ordersource_text);
  37. }
  38. function ordersourceSearch(value,self_id){
  39. var ordersource = $("#ordersource").val();
  40. $.ajax({
  41. url:'./st-xm/control.php',
  42. type: "post",
  43. data: {
  44. ordersource:ordersource,
  45. type:"des_ordersource"
  46. },
  47. dataType: "json",
  48. success: function (data) {
  49. if(data.code == 0){
  50. console.log(data);
  51. createHtml(data.list,self_id)
  52. }
  53. },
  54. fail: function (data) {
  55. // 此处放失败后执行的代码
  56. }
  57. });
  58. }
  59. $(document).ready(function(){
  60. $("#ordersource").click(function(e){
  61. e.stopPropagation();
  62. $("#select_ordersource").removeClass("hide1");
  63. });
  64. })
  65. $(document).click(function(){
  66. if(!$(".select_ordersource").hasClass("hide1")){
  67. $(".select_ordersource").addClass("hide1");
  68. }
  69. })
  70. //筛选列表
  71. function createHtml(data,select_id){
  72. var temp ='<div class="content" id="suoypuqudao" onmouseover="getDark(this.id)" onmouseout="getLight(this.id)" org_id="-1">所有渠道</div>';
  73. for (var i = 0; i < data.length; i++) {
  74. temp +='<div class="content" id="'+select_id+''+data[i].org_id+'" onmouseover="getDark(this.id)" onmouseout="getLight(this.id)" org_id="'+data[i].org_id+'">'+data[i].org_name+'</div>'
  75. }
  76. $(".select_ordersource").html(temp);
  77. $(".content").click(function(){
  78. var line = $(this).text();
  79. var value = $(this).attr('org_id');
  80. $("#"+select_id).val(line);
  81. $("#"+select_id).attr('changeid',value);
  82. })
  83. }
  84. function getDark(value){
  85. $('#'+value).addClass("get_dark");
  86. }
  87. function getLight(value){
  88. $('#'+value).removeClass("get_dark");
  89. }
  90. //查询按钮
  91. function searchBtnClicked(cur,timelimit,starttime,endtime,ordersource,moresearch,typelimit,ordersource_text){
  92. if(!cur){
  93. cur = 1;
  94. }
  95. if(!timelimit||!starttime||!endtime||!ordersource||!moresearch||!typelimit){
  96. timelimit = $('#timelimit').val();
  97. starttime = $('#starttime').val();
  98. endtime = $('#endtime').val();
  99. ordersource = $('#ordersource').attr('changeid');
  100. ordersource_text = $('#ordersource').val();
  101. if(!ordersource){
  102. ordersource = -1;
  103. }
  104. moresearch = $('#moresearch').val();
  105. if(!moresearch){
  106. moresearch = "";
  107. }
  108. typelimit = $('#typelimit').val();
  109. }
  110. $.ajax({
  111. url:'./st-xm/control.php', //请求地址
  112. type: "post", //请求方式
  113. //data: data, //请求参数
  114. data:{
  115. type:"des_orderlist",
  116. timelimit:timelimit,
  117. starttime:starttime,
  118. endtime:endtime,
  119. ordersource:ordersource,
  120. moresearch:moresearch,
  121. typelimit:typelimit,
  122. currpage:cur,
  123. pagesize:pagesize
  124. },
  125. async:false,
  126. dataType: "json",
  127. success: function (data) {
  128. console.log(data);
  129. if(data.code == 0){
  130. var sum = data.totalTickets;
  131. var tag = "page";
  132. var sendurl = './des_order_list.html?timelimit='+timelimit+'&starttime='+starttime+'&endtime='+endtime+'&ordersource='+ordersource+'&moresearch='+moresearch+'&typelimit='+typelimit+'&ordersource_text='+ordersource_text;
  133. getPager(sendurl, sum, cur, pagesize,tag,'currpage');
  134. $('#sum').html('共'+data.list_count+'条记录');
  135. if(data.orderList.length > 0){
  136. var temp = '';
  137. $("#tableOrder").html('');
  138. for (var i = 0; i < data.orderList.length; i++){
  139. var ifzhouzhuang = data.orderList[i].ifzhouzhuang;
  140. var str ="";
  141. if (ifzhouzhuang == 0) {
  142. str='-';
  143. }else if(ifzhouzhuang == 1){
  144. str = '<a onclick = "refundTicket('+data.orderList[i].order_id+')">退票</a>';
  145. }
  146. temp += '<tr class="list_info" id="list_info'+i+'">'
  147. + '<td class="list_middle">'+data.orderList[i].order_id+'</td>'
  148. + '<td class="list_middle">'+data.orderList[i].create_time+'</td>'
  149. + '<td class="list_middle">'+data.orderList[i].org_name+'</td>'
  150. + '<td class="list_middle">'+data.orderList[i].outside_order_no+'</td>'
  151. + '<td class="list_middle">'+data.orderList[i].product_info+'</td>'
  152. + '<td class="list_middle">'+data.orderList[i].run_time+'</td>'
  153. + '<td class="list_middle">'+data.orderList[i].customer_info+'</td>'
  154. + '<td class="list_middle">'+data.orderList[i].order_status+'</td>'
  155. + '<td class="list_middle">'+data.orderList[i].customer_memo+'</td>'
  156. + '<td class="list_middle" id="caozuo'+data.orderList[i].order_id+'">'+str+'</td>'
  157. + '</tr>'
  158. }
  159. }else{
  160. }
  161. $("#tableOrder").html(temp);
  162. }else{
  163. $("#tableOrder").html('');
  164. $('#sum').html('共'+data.list_count+'条记录');
  165. var sum = 0;
  166. var tag = "page";
  167. var sendurl = './des_order_list.html?timelimit='+timelimit+'&starttime='+starttime+'&endtime='+endtime+'&ordersource='+ordersource+'&moresearch='+moresearch+'&typelimit='+typelimit+'&ordersource_text='+ordersource_text;
  168. getPager(sendurl, sum, cur, pagesize,tag,'currpage');
  169. }
  170. },
  171. fail: function (data) {
  172. }
  173. });
  174. if(cur!=1){
  175. var cur = cur;
  176. timelimit = getPar('timelimit');
  177. $('#timelimit').val(timelimit);
  178. var starttime = getPar('starttime');
  179. $('#starttime').val(starttime);
  180. var endtime = getPar('endtime');
  181. $('#endtime').val(endtime);
  182. var ordersource = getPar('ordersource');
  183. $('#ordersource').attr('changeid',ordersource);
  184. var ordersource_text = getPar('ordersource_text');
  185. $('#ordersource').val(ordersource_text);
  186. var moresearch = getPar('moresearch');
  187. $('#moresearch').val(moresearch);
  188. var typelimit = getPar('typelimit');
  189. $('#typelimit').val(typelimit);
  190. }
  191. }
  192. function refundTicket(order_id){
  193. alert(order_id);
  194. var result =confirm("是否决定退票?");
  195. if(result ==true)
  196. {
  197. $.ajax({
  198. url:'./zz-fx/Model/cancelzhoutickets.php', //请求地址
  199. type: "post", //请求方式
  200. data:{
  201. order_id:order_id,
  202. method:1
  203. },
  204. async:true,
  205. dataType: "json",
  206. success: function (data) {
  207. console.log(data);
  208. if(data.code == 0){
  209. alert('退票成功!');
  210. $('#caozuo'+order_id).html('-');
  211. }else{
  212. alert(data.info);
  213. }
  214. }
  215. });
  216. }
  217. else
  218. {
  219. return;
  220. }
  221. }
  222. function getDateTime(nTypeFlag) {
  223. var tNowTime = new Date();
  224. var myYear = ';' + tNowTime.getFullYear() + ';';
  225. var myMonth = ';' + (tNowTime.getMonth() + 1 - 0) + ';';
  226. var myDay = ';' + tNowTime.getDate() + ';';
  227. var myHour = ';' + tNowTime.getHours() + ';';
  228. var myMinu = ';' + tNowTime.getMinutes() + ';';
  229. var mySecond = ';' + tNowTime.getSeconds() + ';';
  230. if(myMonth.length < 4) myMonth = '0' + myMonth;
  231. if(myDay.length < 4) myDay = '0' + myDay;
  232. if(myHour.length < 4) myHour = '0' + myHour;
  233. if(myMinu.length < 4) myMinu = '0' + myMinu;
  234. if(mySecond.length < 4) mySecond = '0' + mySecond;
  235. var cNewTimeStr;
  236. //alert(tNowTime);
  237. switch(nTypeFlag + 1 - 1) {
  238. case 0:
  239. cNewTimeStr = myYear + '-' + myMonth + '-' + myDay;
  240. break;
  241. case 1:
  242. cNewTimeStr = myYear + myMonth + myDay;
  243. break;
  244. case 2:
  245. cNewTimeStr = myHour + ':' + myMinu + ':' + mySecond;
  246. break;
  247. case 3:
  248. cNewTimeStr = myHour + myMinu + mySecond;
  249. break;
  250. case 4:
  251. cNewTimeStr = myYear + myMonth + myDay + myHour + myMinu + mySecond;
  252. break;
  253. case 5:
  254. cNewTimeStr = myYear + '年' + myMonth + '月' + myDay + '日';
  255. break;
  256. case 6:
  257. cNewTimeStr = myYear;
  258. break;
  259. case 7:
  260. cNewTimeStr = myYear + '-' + myMonth;
  261. break;
  262. case 8: //得到上一个月的今天
  263. var date = getDateTime(0);
  264. var arr = date.split('-');
  265. var year = arr[0]; //获取当前日期的年份
  266. var month = arr[1]; //获取当前日期的月份
  267. var day = arr[2]; //获取当前日期的日
  268. var days = new Date(year, month, 0);
  269. days = days.getDate(); //获取当前日期中月的天数
  270. var year2 = year;
  271. var month2 = parseInt(month) - 1;
  272. if(month2 == 0) {
  273. year2 = parseInt(year2) - 1;
  274. month2 = 12;
  275. }
  276. var day2 = day;
  277. var days2 = new Date(year2, month2, 0);
  278. days2 = days2.getDate();
  279. if(day2 > days2) {
  280. day2 = days2;
  281. }
  282. if(month2 < 10) {
  283. month2 = '0' + month2;
  284. }
  285. cNewTimeStr = year2 + '-' + month2 + '-' + day2;
  286. break;
  287. case 9: //得到下一个月的今天
  288. var date = getDateTime(0);
  289. var arr = date.split('-');
  290. var year = arr[0]; //获取当前日期的年份
  291. var month = arr[1]; //获取当前日期的月份
  292. var day = arr[2]; //获取当前日期的日
  293. var days = new Date(year, month, 0);
  294. days = days.getDate(); //获取当前日期中的月的天数
  295. var year2 = year;
  296. var month2 = parseInt(month) + 1;
  297. if(month2 == 13) {
  298. year2 = parseInt(year2) + 1;
  299. month2 = 1;
  300. }
  301. var day2 = day;
  302. var days2 = new Date(year2, month2, 0);
  303. days2 = days2.getDate();
  304. if(day2 > days2) {
  305. day2 = days2;
  306. }
  307. if(month2 < 10) {
  308. month2 = '0' + month2;
  309. }
  310. var t2 = year2 + '-' + month2 + '-' + day2;
  311. return t2;
  312. break;
  313. default:
  314. cNewTimeStr = myYear + '-' + myMonth + '-' + myDay + ' ' + myHour + ':' + myMinu + ':' + mySecond;
  315. break;
  316. case 12: //本周起始日期
  317. return getWeekStartDate()
  318. function getWeekStartDate() {
  319. var now = new Date(); //当前日期
  320. var nowDayOfWeek = now.getDay(); //今天本周的第几天
  321. var nowDay = now.getDate(); //当前日
  322. var nowMonth = now.getMonth(); //当前月
  323. var nowYear = now.getYear(); //当前年
  324. nowYear += (nowYear < 2000) ? 1900 : 0; //
  325. var lastMonthDate = new Date(); //上月日期
  326. lastMonthDate.setDate(1);
  327. lastMonthDate.setMonth(lastMonthDate.getMonth() - 1);
  328. var lastYear = lastMonthDate.getYear();
  329. var lastMonth = lastMonthDate.getMonth();
  330. var weekStartDate = new Date(nowYear, nowMonth, nowDay - nowDayOfWeek);
  331. return formatDate(weekStartDate);
  332. }
  333. break;
  334. case 13: //本周结束日期
  335. return getWeekEndDate()
  336. function getWeekEndDate() {
  337. var now = new Date(); //当前日期
  338. var nowDayOfWeek = now.getDay(); //今天本周的第几天
  339. var nowDay = now.getDate(); //当前日
  340. var nowMonth = now.getMonth(); //当前月
  341. var nowYear = now.getYear(); //当前年
  342. nowYear += (nowYear < 2000) ? 1900 : 0; //
  343. var lastMonthDate = new Date(); //上月日期
  344. lastMonthDate.setDate(1);
  345. lastMonthDate.setMonth(lastMonthDate.getMonth() - 1);
  346. var lastYear = lastMonthDate.getYear();
  347. var lastMonth = lastMonthDate.getMonth();
  348. var weekEndDate = new Date(nowYear, nowMonth, nowDay + (6 - nowDayOfWeek));
  349. return formatDate(weekEndDate);
  350. }
  351. break;
  352. case 14: //本月开始日期
  353. return getMonthStartDate()
  354. function getMonthStartDate() {
  355. var now = new Date(); //当前日期
  356. var nowDayOfWeek = now.getDay(); //今天本周的第几天
  357. var nowDay = now.getDate(); //当前日
  358. var nowMonth = now.getMonth(); //当前月
  359. var nowYear = now.getYear(); //当前年
  360. nowYear += (nowYear < 2000) ? 1900 : 0; //
  361. var lastMonthDate = new Date(); //上月日期
  362. lastMonthDate.setDate(1);
  363. lastMonthDate.setMonth(lastMonthDate.getMonth() - 1);
  364. var lastYear = lastMonthDate.getYear();
  365. var lastMonth = lastMonthDate.getMonth();
  366. var monthStartDate = new Date(nowYear, nowMonth, 1);
  367. return formatDate(monthStartDate);
  368. }
  369. break;
  370. }
  371. cNewTimeStr = cNewTimeStr.replace(/;/g, "");
  372. return cNewTimeStr;
  373. }
  374. function getPar(par) {
  375. //获取当前URL
  376. var local_url = document.location.href;
  377. local_url = decodeURI(local_url);
  378. //获取要取得的get参数位置
  379. var get = local_url.indexOf(par + "=");
  380. if(get == -1) {
  381. return "";
  382. }
  383. //截取字符串
  384. var get_par = local_url.slice(par.length + get + 1);
  385. //判断截取后的字符串是否还有其他get参数
  386. var nextPar = get_par.indexOf("&");
  387. if(nextPar != -1) {
  388. get_par = get_par.slice(0, nextPar);
  389. }
  390. return get_par;
  391. }
  392. //获取当前时间
  393. function CurrentTime() {
  394. var now = new Date();
  395. var year = now.getFullYear(); //年
  396. var month = now.getMonth() + 1; //月
  397. var day = now.getDate(); //日
  398. var hh = now.getHours(); //时
  399. var mm = now.getMinutes(); //分
  400. var ss = now.getSeconds(); //秒
  401. var clock = year + "-";
  402. if (month < 10)
  403. clock += "0";
  404. clock += month + "-";
  405. if (day < 10)
  406. clock += "0";
  407. clock += day + " ";
  408. if (hh < 10)
  409. clock += "0";
  410. clock += hh + ":";
  411. if (mm < 10) clock += '0';
  412. clock += mm + ":";
  413. if (ss < 10) clock += '0';
  414. clock += ss;
  415. return (clock);
  416. }