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.

line_list.js 16 KiB

3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493
  1. //取权限缓存
  2. var user_type = getStorage("user_type");
  3. //一个页面的线路条数
  4. var pagesize = 10;
  5. //当前页数
  6. var currpage = 1;
  7. //根据线路编号和名称检索
  8. var line_code = $("#line_text").val();
  9. //运营公司
  10. var supply_id = "-1";
  11. //产品线
  12. var product_line = "-1";
  13. //线路状态
  14. var line_status = "-1";
  15. //线路类型
  16. var line_type = "255";
  17. //线路类型为 256 时 增加判断 705
  18. var tailor_type = 0;
  19. //总页数
  20. var totalpage = "";
  21. var sing_listHTML = '';
  22. var com_listHTML = '';
  23. $(document).ready(function () {
  24. if (user_type == "0") {
  25. $("#line1").show();
  26. $("#line2").show();
  27. $("#line3").show();
  28. $("#line4").show();
  29. line_type = "255";
  30. } else if (user_type == "1") {
  31. $("#line1").show();
  32. $("#line2").hide();
  33. $("#line3").hide();
  34. $("#line4").hide();
  35. line_type = "255";
  36. } else if (user_type == "2") {
  37. $("#line1").hide();
  38. $("#line2").show();
  39. $("#line3").hide();
  40. $("#line2").removeClass("com_line btn-primary");
  41. $("#line2").addClass("sole_line");
  42. line_type = "256";
  43. } else if (user_type == "3") {
  44. $("#line1").hide();
  45. $("#line2").hide();
  46. $("#line3").show();
  47. $("#line3").removeClass("com_line btn-primary");
  48. $("#line3").addClass("sole_line");
  49. $("#sample-table-1").hide();
  50. $("#sample-table-2").show();
  51. line_type = "316";
  52. } else if (user_type == "4") {
  53. $("#line1").show();
  54. $("#line2").show();
  55. $("#line3").hide();
  56. line_type = "255";
  57. } else if (user_type == "5") {
  58. $("#line1").show();
  59. $("#line2").hide();
  60. $("#line3").show();
  61. line_type = "255";
  62. } else if (user_type == "6") {
  63. $("#line1").hide();
  64. $("#line2").show();
  65. $("#line3").show();
  66. line_type = "256";
  67. $("#line2").removeClass("com_line btn-primary");
  68. $("#line2").addClass("sole_line");
  69. }
  70. $("#line3").hide();
  71. sing_listHTML = $('#sing_list').html();
  72. com_listHTML = $('#com_list').html();
  73. line_list_baseinfo();
  74. selectOnePage(1);
  75. });
  76. //头部切换
  77. function cut_car_type(index) {
  78. $(".top").children().addClass("com_line btn-primary");
  79. $(index).addClass("sole_line");
  80. $(index).removeClass("com_line btn-primary");
  81. $("#line_text").val("");
  82. $("#yunying_company").val("-1");
  83. $("#state").val("-1");
  84. $("#product_type").val("-1");
  85. line_type = $(index).attr("line_type");
  86. if (line_type == 705) {
  87. line_type = 256;
  88. tailor_type = 705;
  89. } else {
  90. line_type = line_type;
  91. tailor_type = 0;
  92. }
  93. if (line_type == "316") {
  94. $("#product_line").show();
  95. $("#sample-table-2").show();
  96. $("#sample-table-1").hide();
  97. } else {
  98. $("#product_line").hide();
  99. $("#sample-table-1").show();
  100. $("#sample-table-2").hide();
  101. }
  102. supply_id = $("#yunying_company").val();
  103. line_code = $("#line_text").val();
  104. line_status = $("#state").val();
  105. selectOnePage(1);
  106. }
  107. //加载配置信息
  108. function line_list_baseinfo() {
  109. $.ajax({
  110. url: base_api + 'lineManager/index.php',//请求地址
  111. data: {tp: "singleLine_getLineListBase"},
  112. type: "post", //请求方式
  113. dataType: "json",
  114. success: function (data) {
  115. console.log(data);
  116. if (data.code == 0) {
  117. get_baseinfo(data.supply_list, data.product_list);
  118. } else {
  119. ZZAlertInfo(data.info);
  120. }
  121. }
  122. });
  123. }
  124. //替换线路加载配置信息
  125. function get_baseinfo(data1, data2) {
  126. var temp1 = '<option value="-1">请选择</option>';
  127. var temp2 = '<option value="-1">请选择</option>';
  128. for (var i = 0, j = data1.length; i < j; i++) {
  129. temp1 += '<option value="' + data1[i].supplier_id + '">' + data1[i].supplier_name + '</option>';
  130. }
  131. for (var i = 0, j = data2.length; i < j; i++) {
  132. temp2 += '<option value="' + data2[i].id + '">' + data2[i].type_name + '</option>';
  133. }
  134. $("#yunying_company").html(temp1);
  135. $("#product_type").html(temp2);
  136. }
  137. //加载线路列表
  138. function selectOnePage(page) {
  139. if (line_type != "316") {
  140. $('.yunying_company').hide();
  141. $('#yunying_company').hide();
  142. } else {
  143. $('.yunying_company').show();
  144. $('#yunying_company').show();
  145. }
  146. supply_id = $("#yunying_company").val();
  147. line_code = $("#line_text").val();
  148. line_status = $("#state").val();
  149. product_line = $("#product_type").val();
  150. if (line_type == "316") {
  151. $.ajax({
  152. url: base_api + 'lineManager/index.php', //请求地址
  153. data: {
  154. tp: "groupLine_getLineList",
  155. page_size: pagesize,
  156. current_page: page,
  157. line_code: line_code,
  158. supply_id: supply_id,
  159. line_status: line_status,
  160. product_type: product_line,
  161. line_type: line_type
  162. },
  163. type: "post", //请求方式
  164. dataType: "json",
  165. async: false,
  166. success: function (data) {
  167. if (data.code == 0) {
  168. console.log(data);
  169. totalpage = data.page.total_page;
  170. comReloadData(data.line_list);
  171. if (totalpage == 0) {
  172. $('.pageDiv').hide();
  173. } else {
  174. createPage(currpage, totalpage);
  175. $('.pageDiv').show();
  176. }
  177. } else {
  178. ZZAlertInfo(data.info);
  179. }
  180. }
  181. });
  182. } else {
  183. $.ajax({
  184. url: base_api + 'lineManager/index.php', //请求地址
  185. data: {
  186. tp: "singleLine_getLineList",
  187. page_size: pagesize,
  188. current_page: page,
  189. line_code: line_code,
  190. supply_id: supply_id,
  191. line_status: line_status,
  192. line_type: line_type,
  193. tailor_type: tailor_type,
  194. },
  195. type: "post", //请求方式
  196. dataType: "json",
  197. async: false,
  198. success: function (data) {
  199. if (data.code == 0) {
  200. console.log(data);
  201. totalpage = data.page.total_page;
  202. singReloadData(data.line_list);
  203. if (totalpage == 0) {
  204. $('.pageDiv').hide();
  205. } else {
  206. createPage(currpage, totalpage);
  207. $('.pageDiv').show();
  208. }
  209. } else {
  210. ZZAlertInfo(data.info);
  211. }
  212. }
  213. });
  214. }
  215. }
  216. //替换加载列表
  217. function get_linelist(data) {
  218. var temp = '';
  219. for (var i = 0, j = data.length; i < j; i++) {
  220. temp += '<option value="' + data[i].supplier_id + '">' + data[i].supplier_name + '</option>';
  221. }
  222. $("#yunying_company").html(temp);
  223. }
  224. //加载单一线路列表数据
  225. function singReloadData(data) {
  226. var list = data;
  227. var newHTML = '';
  228. for (var i = 0; i < list.length; i++) {
  229. var tempHTML = sing_listHTML;
  230. tempHTML = tempHTML.replace('[sing线路编号]', list[i].line_code);
  231. tempHTML = tempHTML.replace('[sing线路名称]', list[i].line_name);
  232. // tempHTML=tempHTML.replace('[类目]',list[i].line_sub_type);
  233. tempHTML = tempHTML.replace('[sing票种数量]', list[i].cnt);
  234. tempHTML = tempHTML.replace('[sing运营公司]', list[i].org_name);
  235. tempHTML = tempHTML.replace('[sing状态]', list[i].disabled_status);
  236. tempHTML = tempHTML.replace('[sing_userid_style]', 'userid_style' + list[i].line_id);
  237. tempHTML = tempHTML.replace('[singOneCheckName]', list[i].line_id);
  238. var str = '<a style="margin-right: 10px;" target="view_window" onclick="open_new_path(this)" go_path="web/lineManager/singline_sell_ticket_type.html?line_type=' + line_type + '&line_id=' + list[i].line_id + '">票种管理</a><a target="view_window" onclick="open_new_path(this)" go_path="web/lineManager/singline_baseinfo.html?line_id=' + list[i].line_id + '">修改</a>';
  239. tempHTML = tempHTML.replace('[sing操作]', str);
  240. newHTML += tempHTML;
  241. }
  242. $('#sing_list').html(newHTML);
  243. $('#sing_list').show();
  244. }
  245. //加载组合线路列表数据
  246. function comReloadData(data) {
  247. var list = data;
  248. var newHTML = '';
  249. for (var i = 0; i < list.length; i++) {
  250. var tempHTML = com_listHTML;
  251. tempHTML = tempHTML.replace('[com线路编号]', list[i].line_code);
  252. tempHTML = tempHTML.replace('[com线路名称]', list[i].line_name);
  253. tempHTML = tempHTML.replace('[com产品线]', list[i].product_type_name);
  254. tempHTML = tempHTML.replace('[com票种数量]', list[i].cnt);
  255. tempHTML = tempHTML.replace('[com运营公司]', list[i].org_name);
  256. tempHTML = tempHTML.replace('[com状态]', list[i].disabled_status);
  257. tempHTML = tempHTML.replace('[com_userid_style]', 'userid_style' + list[i].line_id);
  258. tempHTML = tempHTML.replace('[comOneCheckName]', list[i].line_id);
  259. var str = '<a target="view_window" style="margin-right: 10px;" onclick="open_new_path(this)" go_path="web/lineManager/comsell_ticket_type.html?line_id=' + list[i].line_id + '">票种管理</a><a target="view_window" onclick="open_new_path(this)" go_path="web/lineManager/amend_com_line.html?line_id=' + list[i].line_id + '">修改</a>';
  260. tempHTML = tempHTML.replace('[com操作]', str);
  261. newHTML += tempHTML;
  262. }
  263. $('#com_list').html(newHTML);
  264. }
  265. //创建分页控件
  266. function createPage(currpage, totalpage) {
  267. $(".pageDiv").createPage({
  268. pageCount: totalpage,//总页数
  269. current: currpage,//当前页
  270. turndown: 'true',//是否显示跳转框,显示为true,不现实为false,一定记得加上引号...
  271. backFn: function (p) {
  272. if (line_type == "316") {
  273. $.ajax({
  274. url: base_api + 'lineManager/index.php', //请求地址
  275. data: {
  276. tp: "groupLine_getLineList",
  277. page_size: pagesize,
  278. current_page: p,
  279. line_code: line_code,
  280. supply_id: supply_id,
  281. line_status: line_status,
  282. product_type: product_line,
  283. line_type: line_type,
  284. },
  285. type: "post", //请求方式
  286. dataType: "json",
  287. async: false,
  288. success: function (data) {
  289. if (data.code == 0) {
  290. console.log(data);
  291. totalpage = data.page.total_page;
  292. comReloadData(data.line_list);
  293. } else {
  294. ZZAlertInfo(data.info);
  295. }
  296. }
  297. });
  298. } else {
  299. $.ajax({
  300. url: base_api + 'lineManager/index.php', //请求地址
  301. data: {
  302. tp: "singleLine_getLineList",
  303. page_size: pagesize,
  304. current_page: p,
  305. line_code: line_code,
  306. supply_id: supply_id,
  307. line_status: line_status,
  308. line_type: line_type,
  309. tailor_type: tailor_type,
  310. },
  311. type: "post",
  312. dataType: "json",
  313. async: false,
  314. success: function (data) {
  315. if (data.code == "0") {
  316. console.log(data);
  317. totalpage = data.page.total_page;
  318. singReloadData(data.line_list);
  319. } else {
  320. ZZAlertInfo(data.info);
  321. }
  322. }
  323. });
  324. }
  325. }
  326. });
  327. }
  328. //查询
  329. function searchInfo() {
  330. selectOnePage(1);
  331. }
  332. //复选框判断
  333. function select_checked(index) {
  334. //index=0最上面的全选 index=1表示的是下面所有的
  335. var cur_check = $('.ace_check')[0];
  336. var checkList = $('.ace_check');
  337. var checkCount = checkList.length - 1;
  338. var true_count = 0;
  339. for (var i = 1; i < checkList.length; i++) {
  340. if (index == '0') {
  341. checkList[i].checked = cur_check.checked;
  342. } else {
  343. if (checkList[i].checked == false) {
  344. cur_check.checked = false
  345. } else {
  346. true_count = true_count + 1;
  347. }
  348. }
  349. }
  350. //判断下面是否选中完
  351. if (checkCount == true_count) {
  352. cur_check.checked = true;
  353. }
  354. }
  355. //得到url上的参数
  356. function getPar(par) {
  357. var local_url = document.location.href;
  358. local_url = decodeURI(local_url);
  359. var get = local_url.indexOf(par + "=");
  360. if (get == -1) {
  361. return false;
  362. }
  363. var get_par = local_url.slice(par.length + get + 1);
  364. var nextPar = get_par.indexOf("&");
  365. if (nextPar != -1) {
  366. get_par = get_par.slice(0, nextPar);
  367. }
  368. return get_par;
  369. }
  370. //停用选中项
  371. function stopSelect() {
  372. var ary = new Array();
  373. $('.ace_check').each(function (index, item) {
  374. if (this.checked && index != 0 && isNaN($(this).attr('name')) == false) {
  375. ary.push($(this).attr('name'));
  376. }
  377. });
  378. if (ary.length <= 0) {
  379. ZZAlertInfo('请勾选!!!');
  380. return;
  381. }
  382. var pro_str = ary.join(',');
  383. var data = {
  384. tp: "singleLine_lineStop",
  385. line_id: pro_str
  386. }
  387. $.ajax({
  388. url: base_api + 'lineManager/index.php', //请求地址
  389. type: "post", //请求方式
  390. data: data,
  391. async: false,
  392. dataType: "json",
  393. success: function (data) {
  394. console.log(data);
  395. if (data.code == 0) {
  396. $('.ace_check').each(function (index, item) {
  397. if (this.checked && index != 0) {
  398. var stopid = $(this).attr('name');
  399. $('#userid_style' + stopid).text('停用');
  400. }
  401. });
  402. ZZAlertInfo('停用成功!');
  403. }
  404. }
  405. });
  406. }
  407. //启用选中项
  408. function startSelect() {
  409. var ary = new Array();
  410. $('.ace_check').each(function (index, item) {
  411. if (this.checked && index != 0 && isNaN($(this).attr('name')) == false) {
  412. ary.push($(this).attr('name'));
  413. }
  414. });
  415. if (ary.length <= 0) {
  416. ZZAlertInfo('请勾选!!!');
  417. return;
  418. }
  419. var pro_str = ary.join(',');
  420. var data = {
  421. tp: "singleLine_lineStart",
  422. line_id: pro_str
  423. }
  424. $.ajax({
  425. url: base_api + 'lineManager/index.php', //请求地址
  426. type: "post", //请求方式
  427. data: data,
  428. dataType: "json",
  429. success: function (data) {
  430. console.log(data);
  431. if (data.code == 0) {
  432. $('.ace_check').each(function (index, item) {
  433. if (this.checked && index != 0) {
  434. var stopid = $(this).attr('name');
  435. $('#userid_style' + stopid).text('启用');
  436. }
  437. });
  438. ZZAlertInfo('启用成功!');
  439. }
  440. }
  441. });
  442. }
  443. function addline() {
  444. if (line_type == "316") {
  445. window.location.href = "combination_line.html";
  446. } else {
  447. window.location.href = "singline_baseinfo.html";
  448. }
  449. }