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.
 
 
 
 

271 rivejä
7.0 KiB

  1. //增加线路html
  2. var travel_line_html = "";
  3. var start_line = "";
  4. var end_line = "";
  5. var line_id = "";
  6. $(document).ready(function(){
  7. //加载时间
  8. upload_time();
  9. line_list_baseinfo();
  10. });
  11. //根据天数安排行程
  12. function day_number(){
  13. var dayno = $("#day_no").val();
  14. var travel_html = "";
  15. for(var i=0;i<dayno;i++){
  16. j=i+1;
  17. travel_html += '<div class="travel_day travel_day'+j+'" style="margin-top: 30px;">'
  18. + '<div sub_day="'+j+'" style="margin-bottom: 15px;">'
  19. + '<span>第 '+j+' 天</span>'
  20. + '<img class="mouse_hand" onclick="add_travel_number(this)" style="width: 20px;margin-left: 10px;" src="images/add.png"/>'
  21. + '</div>'
  22. + travel_line_html
  23. + '</div>'
  24. }
  25. $(".com_trave").html(travel_html);
  26. $('.select_line').comboSelect();
  27. }
  28. //增加每天的行程条数
  29. function add_travel_number(index){
  30. $(index).closest('.travel_day').append(travel_line_html);
  31. $('.select_line').comboSelect();
  32. }
  33. function delete_travel_number(index){
  34. $(index).closest('.travel_line').remove();
  35. }
  36. //加载时间小时和秒
  37. function upload_time(){
  38. var hour_html = '';
  39. var minute_html = '';
  40. for(var i=0;i<24;i++){
  41. if(i<10){
  42. hour_html += '<option value="'+i+'">0'+i+'</option>';
  43. }else{
  44. hour_html += '<option value="'+i+'">'+i+'</option>';
  45. }
  46. }
  47. for(var i=0;i<60;i++){
  48. if(i<10){
  49. minute_html += '<option value="'+i+'">0'+i+'</option>';
  50. }else{
  51. minute_html += '<option value="'+i+'">'+i+'</option>';
  52. }
  53. }
  54. $(".load_hour").html(hour_html);
  55. $(".load_minute").html(minute_html);
  56. }
  57. //头部切换
  58. function sell_ticket(){
  59. if(line_id==""){
  60. ZZAlertInfo("请先填写保存线路基本信息!");
  61. }else{
  62. window.location.href="comsell_ticket_type.html?line_id="+line_id;
  63. }
  64. }
  65. function selset_line(index){
  66. var line_id = $(index).val();
  67. start_line = $(index).parent().next();
  68. $.ajax({
  69. url:base_api+'lineManager/index.php', //请求地址
  70. data:{
  71. tp:"groupLine_getStartByLine",
  72. line_id:line_id
  73. },
  74. type: "post", //请求方式
  75. dataType: "json",
  76. // async:false,
  77. success: function (data) {
  78. console.log(data);
  79. if(data.code == 0){
  80. get_start_station(data.station);
  81. }else{
  82. ZZAlertInfo(data.info);
  83. }
  84. }
  85. });
  86. }
  87. //配置信息
  88. function line_list_baseinfo(){
  89. $.ajax({
  90. url:base_api+'lineManager/index.php', //请求地址
  91. data:{tp:"groupLine_getProduct"},
  92. type: "post", //请求方式
  93. dataType: "json",
  94. // async:false,
  95. success: function (data) {
  96. console.log(data);
  97. if(data.code == 0){
  98. get_baseinfo(data.res_line,data.product,data.company);
  99. }else{
  100. ZZAlertInfo(data.info);
  101. }
  102. }
  103. });
  104. }
  105. //替换加载配置信息
  106. function get_baseinfo(data,index,obj){
  107. var line_temp = '<option value="-1">请选择</option>';
  108. var product_temp = "";
  109. var company = "";
  110. for(var i=0,j=index.length;i<j;i++){
  111. product_temp += '<option value="'+index[i].id+'">'+index[i].type_name+'</option>';
  112. }
  113. for(var i=0,j=obj.length;i<j;i++){
  114. company += '<option value="'+obj[i].supplier_id+'">'+obj[i].supplier_name+'</option>';
  115. }
  116. for(var i=0,j=data.length;i<j;i++){
  117. line_temp += '<option value="'+data[i].line_id+'">'+data[i].line_name+'</option>';
  118. }
  119. $(".select_line").html(line_temp);
  120. $("#product_line").html(product_temp);
  121. $("#yunying_company").html(company);
  122. travel_line_html = $(".travel_line").prop("outerHTML");
  123. $('.select_line').comboSelect();
  124. }
  125. //根据线路得到出发站
  126. function get_start_station(index){
  127. var temp = '<option value="-1">选择出发地</option>';
  128. for(var i=0,j=index.length;i<j;i++){
  129. temp += '<option value="'+index[i].res_id+'">'+index[i].res_name+'</option>';
  130. }
  131. start_line.html(temp);
  132. }
  133. //根据选择的出发地掉目的地接口
  134. function choose_startline(index){
  135. var line_id = $(index).prev().children().eq(0).val();
  136. var start_res_id = $(index).val();
  137. end_line = $(index).next().next();
  138. $.ajax({
  139. url:base_api+'lineManager/index.php', //请求地址
  140. data:{
  141. tp:"groupLine_getEndStation",
  142. res_id:start_res_id,
  143. line_id:line_id
  144. },
  145. type: "post", //请求方式
  146. dataType: "json",
  147. // async:false,
  148. success: function (data) {
  149. console.log(data);
  150. if(data.code == 0){
  151. get_end_station(data.station);
  152. }else{
  153. ZZAlertInfo(data.info);
  154. }
  155. }
  156. });
  157. }
  158. //根据出发站得到目的地
  159. function get_end_station(index){
  160. var temp = '<option value="-1">选择目的地</option>';
  161. for(var i=0,j=index.length;i<j;i++){
  162. temp += '<option value="'+index[i].res_id+'">'+index[i].res_name+'</option>';
  163. }
  164. end_line.html(temp);
  165. }
  166. //保存基本信息
  167. function submit_line(){
  168. var submit_product_arr = [];
  169. var sub_mit = $(".travel_day").length;
  170. for(var i=0;i<sub_mit;i++){
  171. var z=i+1;
  172. $('.travel_day'+z+' .travel_line').each(function(index,dom){
  173. var sub_line_id = $(this).children().eq(0).children().eq(0).val();
  174. var in_turn = index+1;
  175. var sub_start_id = $(this).children().eq(1).val();
  176. var sub_end_id = $(this).children().eq(3).val();
  177. var sub_time = parseInt($(this).children().eq(5).val())*60+parseInt($(this).children().eq(7).val());
  178. var sub_day = $(this).parent().children().eq(0).attr("sub_day");
  179. var submit_product = "{"+sub_day+","+in_turn+","+sub_line_id+","+sub_start_id+","+sub_end_id+","+sub_time+"}"
  180. submit_product_arr.push(submit_product);
  181. })
  182. }
  183. // $('.travel_line').each(function(index,dom){
  184. // var sub_line_id = $(this).children().eq(0).children().eq(0).val();
  185. // var sub_start_id = $(this).children().eq(1).val();
  186. // var sub_end_id = $(this).children().eq(3).val();
  187. // var sub_time = parseInt($(this).children().eq(5).val())*60+parseInt($(this).children().eq(7).val());
  188. // var sub_day = $(this).parent().children().eq(0).attr("sub_day");
  189. // var submit_product = "{"+sub_day+","+sub_line_id+","+sub_start_id+","+sub_end_id+","+sub_time+"}"
  190. //
  191. // submit_product_arr.push(submit_product);
  192. //
  193. //
  194. // })
  195. var submit_product_str = submit_product_arr.toString();
  196. console.log(submit_product_str);
  197. var sub_line_name = $("#line_name").val();
  198. var sub_line_no = $("#line_no").val();
  199. var sub_product_line = $("#product_line").val();
  200. var sub_sell_end = $("#sell_end").val();
  201. var sub_sell_time = $("#sell_hour").val()+":"+$("#sell_minute").val();
  202. var sub_yunying_company = $("#yunying_company").val();
  203. $.ajax({
  204. url:base_api+'lineManager/index.php', //请求地址
  205. data:{
  206. tp:"groupLine_addGroupLine",
  207. line_name:sub_line_name,
  208. line_code:sub_line_no,
  209. product_type:sub_product_line,
  210. expired_type:sub_sell_end,
  211. expired_time:sub_sell_time,
  212. org_id:sub_yunying_company,
  213. station_list:submit_product_str
  214. },
  215. type: "post", //请求方式
  216. dataType: "json",
  217. // async:false,
  218. success: function (data) {
  219. console.log(data);
  220. if(data.code == 0){
  221. ZZAlertInfo("保存成功");
  222. // line_id = "387714";
  223. line_id = data.line_id;
  224. }else{
  225. ZZAlertInfo(data.info);
  226. line_id = "";
  227. }
  228. }
  229. });
  230. }
  231. function singline(){
  232. window.location.href="singline_baseinfo.html"
  233. }