No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 
 
 

570 líneas
17 KiB

  1. //author:fuhc
  2. //date:20161018
  3. //单一线路基本信息
  4. var trHTML = '';
  5. var trRowHTML='';
  6. var line_id = ''; //line_id if{没有就不能点击售卖票种}
  7. var line_type = '';
  8. var res_id = '';
  9. var res_name = '';
  10. var cstr_time = '<span class="arrive_time minutes" data-time="0" style="width: 55px;display: inline-block;text-align: center;">0</span>';
  11. window.onload = function() {
  12. // $('.select_line').comboSelect();
  13. line_id=getPar('line_id');
  14. if(line_id){
  15. $('.up_hide').hide();
  16. $('#top_type').hide();
  17. $('.up_info').text('基本信息');
  18. }
  19. //setBaseInfo();
  20. setHttpBaseInfo();
  21. $('.tr_row').show();
  22. trHTML = $('.tr_row').html();
  23. trRowHTM = $('#tbody').html();
  24. $('#tbody').html('');
  25. }
  26. //配置
  27. function setBaseInfo() {
  28. var obj1 = document.getElementById('hour');
  29. for(var i = 0; i <= 24; i++) {
  30. var hour = (Array(2).join(0) + i).slice(-2);
  31. var myOption = new Option(hour, hour);
  32. obj1.options[obj1.options.length] = myOption;
  33. }
  34. obj1.selectedIndex = 0;
  35. var obj2 = document.getElementById('ne_minutes');
  36. for(var i = 0; i <= 59; i++) {
  37. var minutes = (Array(2).join(0) + i).slice(-2);
  38. var myOption = new Option(minutes, minutes);
  39. obj2.options[obj2.options.length] = myOption;
  40. }
  41. obj2.selectedIndex = 0;
  42. }
  43. //设置页面配置信息
  44. function setHttpBaseInfo() {
  45. var param = {
  46. tp: "singleLine_getBaseManager"
  47. }
  48. ZZLog(base_api + 'lineManager/index.php' + JSON.stringify(param));
  49. $.ajax({
  50. type: "post",
  51. url: base_api + 'lineManager/index.php',
  52. data: param,
  53. dataType: "json",
  54. success: function(res_data) {
  55. ZZLog(res_data);
  56. if(res_data['code'] != "0") {
  57. ZZAlertInfo(res_data['info']);
  58. } else {
  59. //类目
  60. var bus_type = res_data['bus_type'];
  61. var obj = document.getElementById('bus_type');
  62. for(var i = 0, m = bus_type.length; i < m; i++) {
  63. var tempDict = bus_type[i];
  64. var myOption = new Option(tempDict['name'], tempDict['id']);
  65. obj.options[obj.options.length] = myOption;
  66. }
  67. //售卖截止
  68. // var time_type = res_data['time_type'];
  69. // var obj = document.getElementById('time_type');
  70. // for(var i = 0, m = time_type.length; i < m; i++) {
  71. // var tempDict = time_type[i];
  72. // var myOption = new Option(tempDict['type_name'], tempDict['id']);
  73. // obj.options[obj.options.length] = myOption;
  74. // }
  75. //运营公司
  76. var supply_list = res_data['supply_list'];
  77. var obj = document.getElementById('supply');
  78. for(var i = 0, m = supply_list.length; i < m; i++) {
  79. var tempDict = supply_list[i];
  80. var myOption = new Option(tempDict['supplier_name'], tempDict['supplier_id']);
  81. obj.options[obj.options.length] = myOption;
  82. }
  83. //判断是否是修改
  84. //设置默认选中项
  85. if(""!=line_id.trim()){
  86. setSelectBaseInfo();
  87. }
  88. }
  89. },
  90. error: function(error) {
  91. ZZLog(error);
  92. }
  93. });
  94. }
  95. //设置选中的值
  96. function setSelectBaseInfo(){
  97. var param={
  98. tp:"singleLine_getLineDetail",
  99. line_id:line_id
  100. }
  101. ZZLog(base_api+"lineManager/index.php"+JSON.stringify(param));
  102. $.ajax({
  103. type:"post",
  104. url:base_api+"lineManager/index.php",
  105. data:param,
  106. dataType:"json",
  107. success:function(res_data){
  108. ZZLog(res_data);
  109. if(res_data.code!="0"){
  110. ZZAlertInfo(res_data.info);
  111. }else{
  112. var line_info=res_data.line_info;
  113. $('#line_name').val(line_info['line_name']);
  114. $('#line_code').val(line_info['line_code']);
  115. $('#bus_type').val(line_info['line_type']);
  116. $('#time_type').val(line_info['sale_expired_type']);
  117. // $('#tailor_flag').val(line_info['tailor_flag']);
  118. $("input[name='tailor_flag'][value="+line_info['tailor_flag']+"]").attr("checked",true);
  119. $("input[name='allow_selected_seat'][value="+line_info['allow_select_seat']+"]").attr("checked",true);
  120. var time=line_info['sale_expired_time'];
  121. var hour=time.split(':')[0];
  122. var minutes=time.split(':')[1];
  123. $('#hour').val(hour);
  124. $('#ne_minutes').val(minutes);
  125. $('#supply').val(line_info['org_id']);
  126. setSelectStationHTML(res_data['station_info']);
  127. }
  128. },error:function(e){
  129. ZZLog(e);
  130. }
  131. });
  132. }
  133. //设置选中的站点信息
  134. function setSelectStationHTML(station_info){
  135. var HTML='';
  136. for (var j=0,m=station_info.length;j<m;j++) {
  137. var res_info=station_info[j];
  138. var tempHTML = trRowHTM;
  139. tempHTML = tempHTML.replace(cstr_time, '<input class="minutes" value="'+res_info['start_minutes']+'" type="text" style="width: 55px;"/>');
  140. //处理站点
  141. tempHTML = tempHTML.replace('[res-name]', res_info['res_name']);
  142. tempHTML = tempHTML.replace('[res-id]', res_info['res_id']);
  143. //处理POI
  144. var parent_area = res_info['parent_area'];
  145. var cstr1 = '<select class="select_line poi" style="width: 200px;display: inline-block;border: 0;">';
  146. for(var i = 0; i < parent_area.length; i++) {
  147. var dict = parent_area[i];
  148. var temp = '';
  149. if(dict['checked']=="1"){
  150. temp='<option selected="selected" value="' + dict['id'] + '">' + dict['name'] + '</option>';
  151. }else{
  152. temp='<option value="' + dict['id'] + '">' + dict['name'] + '</option>';
  153. }
  154. cstr1 += temp;
  155. if(i == parent_area.length) {
  156. cstr1 += '</select>';
  157. }
  158. }
  159. tempHTML = tempHTML.replace('[POI]', cstr1);
  160. var cstr5 = '<input class="distance" value="'+res_info.distance+'" type="text" style="width: 55px;"/>公里';
  161. tempHTML = tempHTML.replace('[距离]', cstr5);
  162. //处理上下
  163. var inout_type = res_info['inout_type'];
  164. var cstr2 = '<select class="inout_type" style="width: 55px;">';
  165. for(var i = 0; i < inout_type.length; i++) {
  166. var dict = inout_type[i];
  167. var temp = ' ';
  168. if(dict['checked']=="1"){
  169. temp='<option selected="selected" value="' + dict['id'] + '">' + dict['name'] + '</option>';
  170. }else{
  171. temp='<option value="' + dict['id'] + '">' + dict['name'] + '</option>';
  172. }
  173. cstr2 += temp;
  174. if(i == inout_type.length) {
  175. cstr2 += '</select>';
  176. }
  177. }
  178. tempHTML = tempHTML.replace('[上下]', cstr2);
  179. //处理检票口
  180. var check_port = res_info['check_port'];
  181. var cstr3 = '<select class="check_port" style="width: 55px;">';
  182. var cstr4 = '';
  183. for(var i = 0; i < check_port.length; i++) {
  184. var dict = check_port[i];
  185. var temp='';
  186. if(dict['id']!='0'){
  187. temp = '<option value="' + dict['id'] + '">' + dict['name'] + '</option>';
  188. }else{
  189. temp = '';
  190. }
  191. cstr3 += temp;
  192. cstr4 += temp;
  193. if(i == check_port.length) {
  194. cstr3 += '</select>';
  195. }
  196. }
  197. if(check_port.length <= 0 || cstr4 == '') {
  198. cstr3 = "-";
  199. }
  200. tempHTML = tempHTML.replace('[检票口]', cstr3);
  201. HTML+=tempHTML;
  202. // addtr.innerHTML = tempHTML;
  203. // $('.select_line').comboSelect();
  204. // //删除ROW
  205. // $('.delrow').on('click', function() {
  206. // $(this).closest('tr').remove();
  207. // sortTr();
  208. // })
  209. // sortTr();
  210. }
  211. $('#tbody').html(HTML);
  212. $('.select_line').comboSelect();
  213. //上下类型改变联动检票口
  214. var cstrCheck = '';
  215. $('.inout_type').on('change',function(){
  216. var typeid=$(this).val();
  217. var $check = $(this).closest('tr').children().eq(6);
  218. cstrCheck = $check.html();
  219. if(typeid!='110'){
  220. $check.html(cstrCheck);
  221. }else{
  222. $check.html('-');
  223. }
  224. })
  225. $('.delrow').on('click',function(){
  226. $(this).closest('tr').remove();
  227. sortTr();
  228. })
  229. sortTr();
  230. }
  231. $(document).ready(function() {
  232. // 添加站点
  233. $('#btn_add').on('click', function() {
  234. var _res_id = res_id;
  235. var param = {
  236. tp: "singleLine_getStationInfo",
  237. res_id: res_id
  238. }
  239. ZZLog(base_api + "lineManager/index.php" + JSON.stringify(param));
  240. $.ajax({
  241. type: "post",
  242. url: base_api + "lineManager/index.php",
  243. data: param,
  244. dataType: "json",
  245. success: function(res_data) {
  246. ZZLog(res_data);
  247. if(res_data['code'] != "0") {
  248. ZZAlertInfo(res_data['info']);
  249. } else {
  250. setTrRowHtml(res_data['res_info']);
  251. }
  252. },
  253. error: function() {
  254. ZZLog('error');
  255. }
  256. });
  257. function setTrRowHtml(res_info) {
  258. var addtr = document.createElement('tr');
  259. var tbody = document.getElementById('tbody');
  260. addtr.className = 'tr_row';
  261. tbody.appendChild(addtr);
  262. var tempHTML = trHTML;
  263. tempHTML = tempHTML.replace(cstr_time, '<input class="minutes" type="text" style="width: 55px;"/>');
  264. //处理站点
  265. tempHTML = tempHTML.replace('[res-name]', res_name);
  266. tempHTML = tempHTML.replace('[res-id]', res_id);
  267. //处理POI
  268. var parent_area = res_info['parent_area'];
  269. var cstr1 = '<select class="select_line poi" style="width: 200px;display: inline-block;border: 0;">';
  270. for(var i = 0; i < parent_area.length; i++) {
  271. var dict = parent_area[i];
  272. var temp = '<option value="' + dict['id'] + '">' + dict['name'] + '</option>';
  273. cstr1 += temp;
  274. if(i == parent_area.length) {
  275. cstr1 += '</select>';
  276. }
  277. }
  278. tempHTML = tempHTML.replace('[POI]', cstr1);
  279. var cstr5 = '<input class="distance" value="" type="text" style="width: 55px;"/>公里';
  280. tempHTML = tempHTML.replace('[距离]', cstr5);
  281. //处理上下
  282. var inout_type = res_info['inout_type'];
  283. var cstr2 = '<select class="inout_type" style="width: 55px;">';
  284. for(var i = 0; i < inout_type.length; i++) {
  285. var dict = inout_type[i];
  286. var temp = '<option value="' + dict['id'] + '">' + dict['name'] + '</option>';
  287. cstr2 += temp;
  288. if(i == inout_type.length) {
  289. cstr2 += '</select>';
  290. }
  291. }
  292. tempHTML = tempHTML.replace('[上下]', cstr2);
  293. //处理检票口
  294. var check_port = res_info['check_port'];
  295. var cstr3 = '<select class="check_port" style="width: 55px;">';
  296. var cstr4 = '';
  297. for(var i = 0; i < check_port.length; i++) {
  298. var dict = check_port[i];
  299. var temp='';
  300. if(dict['id']!='0'){
  301. temp = '<option value="' + dict['id'] + '">' + dict['name'] + '</option>';
  302. }else{
  303. temp = '';
  304. }
  305. cstr3 += temp;
  306. cstr4 += temp;
  307. if(i == check_port.length) {
  308. cstr3 += '</select>';
  309. }
  310. }
  311. if(check_port.length <= 0 || cstr4 == '') {
  312. cstr3 = "-";
  313. }
  314. tempHTML = tempHTML.replace('[检票口]', cstr3);
  315. addtr.innerHTML = tempHTML;
  316. $('.select_line').comboSelect();
  317. //上下类型改变联动检票口
  318. var cstrCheck = '';
  319. $('.inout_type').on('change',function(){
  320. var typeid=$(this).val();
  321. var $check = $(this).closest('tr').children().eq(6);
  322. cstrCheck = $check.html();
  323. if(typeid!='110'){
  324. $check.html(cstrCheck);
  325. }else{
  326. $check.html('-');
  327. }
  328. })
  329. //删除ROW
  330. $('.delrow').on('click', function() {
  331. $(this).closest('tr').remove();
  332. sortTr();
  333. })
  334. sortTr();
  335. }
  336. })
  337. //检索行驶路线
  338. $('#run_road').on('input', function() {
  339. var keyword = $(this).val();
  340. var param = {
  341. tp: "singleLine_getLineStation",
  342. res_name: keyword
  343. }
  344. ZZLog(base_api + "lineManager/index.php" + JSON.stringify(param));
  345. $.ajax({
  346. type: "post",
  347. url: base_api + "lineManager/index.php",
  348. data: param,
  349. dataType: "json",
  350. success: function(res_data) {
  351. ZZLog(res_data);
  352. if(res_data['code'] != "0") {
  353. ZZAlertInfo(res_data['info']);
  354. } else {
  355. var res_list = res_data['res_list'];
  356. var HTML = '';
  357. for(var i = 0, m = res_list.length; i < m; i++) {
  358. var dict = res_list[i];
  359. var cstr = '<div onclick="chooseRunRoad(' + dict['res_id'] + ',\'' + dict['res_name'] + '\')" class="content_xiala" onmouseover="getDark(this)" onmouseout="getLight(this)" style="cursor: pointer;">' + dict['res_name'] + '</div>';
  360. HTML += cstr;
  361. }
  362. if(HTML) {
  363. $('.select_content').html(HTML);
  364. $('.select_content').show();
  365. }
  366. }
  367. },
  368. error: function() {
  369. ZZLog('error');
  370. }
  371. });
  372. })
  373. //保存
  374. $('#base_info_save').on('click', function() {
  375. baseInfoSave();
  376. })
  377. })
  378. function getDark(obj){
  379. $(obj).addClass('get_dark');
  380. }
  381. function getLight(obj){
  382. $(obj).removeClass('get_dark');
  383. }
  384. //保存
  385. function baseInfoSave() {
  386. $('.errinfo').html('');
  387. // 参数非空验证
  388. var _line_name = $('#line_name').val(); //线路名称
  389. if("" == _line_name.trim()) {
  390. $('#line_name').focus();
  391. $('#line_name').parent().children().eq(1).html('请输入名称');
  392. return;
  393. }
  394. var _line_code = $('#line_code').val(); //线路代码
  395. if("" == _line_code) {
  396. $('#line_code').focus();
  397. $('#line_code').parent().children().eq(1).html('请输入编号');
  398. return;
  399. }
  400. var _line_type = $('#bus_type').val(); //线路类型1
  401. var _line_sub_type = "0"; ////线路类型2 目前固定
  402. var _time_type = $('#time_type').val(); //时间类型
  403. var _hour = $('#hour').val();
  404. var _ne_minutes = $('#ne_minutes').val();
  405. // var _time_info = _hour + ":" + _ne_minutes; //时间
  406. var _supply_id = $('#supply').val(); //供应商id
  407. var _time_type = 322; //时间类型
  408. var _time_info = '00:00'; //时间
  409. var _station_list = '';
  410. var bool_inout_type=false;
  411. // var _tailor_flag = $("#tailor_flag").val();
  412. var _tailor_flag = $("input[name='tailor_flag']:checked").val();
  413. var _allow_selected_seat = $("input[name='allow_selected_seat']:checked").val();
  414. var flag = 0;
  415. $('.tr_row').each(function(index, domEle) {
  416. var _inout_type = $(this).children().find('.inout_type').val();
  417. if(index==$('.tr_row').length-1 && _inout_type!='110'){
  418. bool_inout_type = true;
  419. }
  420. var _index = index + 1;
  421. var _arrive_time = '';
  422. if(index == 0) {
  423. _arrive_time = $(this).children().find('.minutes').text();
  424. } else {
  425. _arrive_time = $(this).children().find('.minutes').val();
  426. if("" == _arrive_time) {
  427. $(this).children().find('.minutes').focus();
  428. flag = 1;
  429. return false;
  430. }
  431. }
  432. var _distance = $(this).children().find('.distance').val();
  433. if("" == _distance) {
  434. $(this).children().find('.distance').focus();
  435. flag = 1;
  436. return false;
  437. }
  438. var _check_port = $(this).children().find('.check_port').val();
  439. _check_port=_check_port==undefined?"0":_check_port;
  440. var _res_id = $(this).children().eq(1).attr('data-res-id');
  441. var _area_id = $(this).children().find('.poi').val();
  442. //
  443. // var _json=$(this).children().eq(2).attr('data-json');
  444. // ZZLog(_json);
  445. // _json=_json.replace(/'/g,'\"');
  446. // ZZLog(_json);
  447. // var param=JSON.parse(_json);
  448. // ZZLog(_json);
  449. // ZZLog(param);
  450. if(_check_port == null)
  451. _check_port = 0;
  452. _station_list += "{" + _inout_type + "," + _index + "," + _arrive_time + ","+_distance+"," + _check_port + "," + _res_id + "," + _area_id + "}";
  453. })
  454. if(flag == 1) {
  455. return;
  456. }
  457. if(bool_inout_type){
  458. ZZAlertInfo('最后一个站点不能选择下车类型');
  459. return;
  460. }
  461. if("" == _station_list.trim()) {
  462. $('#run_road').focus();
  463. return;
  464. }
  465. var param = {}
  466. if(!line_id){
  467. param={
  468. tp: "singleLine_addLine",
  469. line_name: _line_name,
  470. line_code: _line_code,
  471. line_type: _line_type,
  472. line_sub_type: _line_sub_type,
  473. time_type: _time_type,
  474. time_info: _time_info,
  475. supply_id: _supply_id,
  476. station_list: _station_list,
  477. tailor_flag: _tailor_flag,
  478. allow_selected_seat: _allow_selected_seat,
  479. }
  480. }else{
  481. param={
  482. tp: "singleLine_lineUpdate",
  483. line_id:line_id,
  484. line_name: _line_name,
  485. line_code: _line_code,
  486. line_type: _line_type,
  487. line_sub_type: _line_sub_type,
  488. time_type: _time_type,
  489. time_info: _time_info,
  490. supply_id: _supply_id,
  491. station_list: _station_list,
  492. tailor_flag: _tailor_flag,
  493. allow_selected_seat: _allow_selected_seat,
  494. }
  495. }
  496. ZZLog(base_api + "lineManager/index.php" + JSON.stringify(param));
  497. $.ajax({
  498. type: "post",
  499. url: base_api + "lineManager/index.php",
  500. data: param,
  501. dataType: "json",
  502. success: function(res_data) {
  503. ZZLog(res_data);
  504. if(res_data['code'] != "0") {
  505. ZZAlertInfo(res_data['info']);
  506. } else {
  507. if(line_id){
  508. var lourl = "line_list.html";
  509. window.location.href = lourl;
  510. return;
  511. }
  512. line_id = res_data['line_id'];
  513. line_type = res_data['line_type'];
  514. var lochref="singline_sell_ticket_type.html?line_id=" + line_id + "&line_type=" + line_type;
  515. $.cookie("path_url",cookie_path+"web/lineManager/"+lochref,{domain:domain_path});
  516. window.open(system_path);
  517. }
  518. },
  519. error: function() {
  520. ZZLog('error');
  521. }
  522. });
  523. }
  524. //点击检索的
  525. function chooseRunRoad(re_id, re_name) {
  526. res_id = re_id;
  527. res_name = re_name;
  528. $('#run_road').val(res_name);
  529. $('.select_content').hide();
  530. }
  531. //重新排序
  532. function sortTr() {
  533. $('.tr_row').each(function(index, domEle) {
  534. if(index == 0) {
  535. var cstr = cstr_time + '<span style="margin-left: 10px;">分</span>';
  536. $(this).children().eq(3).html(cstr);
  537. }
  538. $(this).children().eq(0).text(index + 1);
  539. $(this).children().eq(0).attr('index', index + 1);
  540. })
  541. }
  542. //头部切换
  543. function click_type(op) {
  544. var lochref = '';
  545. if(op == "com_baseinfo") {
  546. lochref = "combination_line.html";
  547. } else if(op == "sing_ticket") {
  548. ZZLog(line_id);
  549. if(line_id == "") {
  550. ZZAlertInfo('请先填写保存线路基本信息');
  551. return;
  552. }
  553. // line_type = line_type;
  554. line_type = $('#bus_type').val();
  555. lochref = "singline_sell_ticket_type.html?line_id=" + line_id + "&line_type=" + line_type;
  556. }
  557. window.location.href = lochref;
  558. }