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.
 
 
 
 

385 lines
11 KiB

  1. $(document).ready(function() {
  2. //firfox会初始化图片历史路径到bus_img_path
  3. $(".bus_img_div input").val('');
  4. bus_team_baseinfo();
  5. brand_list_baseinfo();
  6. load_img_type();
  7. bus_type_baseinfo();
  8. seat_number_baseinfo();
  9. // bus_status_baseinfo();
  10. bus_color_baseinfo();
  11. set_year();
  12. set_month();
  13. get_bus_detail_info();
  14. });
  15. //加载车队配置信息
  16. function bus_team_baseinfo() {
  17. $.ajax({
  18. url: base_api + 'carManager/index.php', //请求地址
  19. data: {
  20. tp: "carControl_orgList"
  21. },
  22. type: "post", //请求方式
  23. async: false,
  24. dataType: "json",
  25. success: function(data) {
  26. console.log(data);
  27. if(data.code == 0) {
  28. get_bus_team_baseinfo(data.data);
  29. } else {
  30. ZZAlertInfo(data.info);
  31. }
  32. }
  33. });
  34. }
  35. //替换车队加载配置信息
  36. function get_bus_team_baseinfo(data) {
  37. var temp = '<option value="0">请选择</option>';
  38. for(var i = 0, j = data.length; i < j; i++) {
  39. temp += '<option value="' + data[i].supplier_id + '">' + data[i].bus_team + '</option>';
  40. }
  41. $("#car_team").html(temp);
  42. }
  43. //加载品牌配置信息
  44. function brand_list_baseinfo() {
  45. $.ajax({
  46. url: base_api + 'carManager/index.php', //请求地址
  47. data: {
  48. tp: "carControl_brandList"
  49. },
  50. type: "post", //请求方式
  51. async: false,
  52. dataType: "json",
  53. success: function(data) {
  54. console.log(data);
  55. if(data.code == 0) {
  56. get_brand_list_baseinfo(data.data);
  57. } else {
  58. ZZAlertInfo(data.info);
  59. }
  60. }
  61. });
  62. }
  63. //替换品牌加载配置信息
  64. function get_brand_list_baseinfo(data) {
  65. var temp = '<option value="0">请选择</option>';
  66. for(var i = 0, j = data.length; i < j; i++) {
  67. temp += '<option value="' + data[i].res_id + '">' + data[i].res_name + '</option>';
  68. }
  69. $("#brand_select").html(temp);
  70. }
  71. //加载车辆类型配置信息
  72. function bus_type_baseinfo() {
  73. $.ajax({
  74. url: base_api + 'carManager/index.php', //请求地址
  75. data: {
  76. tp: "carControl_getSeatType"
  77. },
  78. async: false,
  79. type: "post", //请求方式
  80. dataType: "json",
  81. success: function(data) {
  82. console.log(data);
  83. if(data.code == 0) {
  84. get_bus_type_baseinfo(data.data);
  85. } else {
  86. ZZAlertInfo(data.info);
  87. }
  88. }
  89. });
  90. }
  91. //替换车辆类型配置信息
  92. function get_bus_type_baseinfo(data) {
  93. var temp = '';
  94. for(var i = 0, j = data.length; i < j; i++) {
  95. temp += '<option value="' + data[i].id + '">' + data[i].seat_type + '</option>';
  96. }
  97. $("#seat_type").html(temp);
  98. }
  99. //加载座位数量配置信息
  100. function seat_number_baseinfo() {
  101. $.ajax({
  102. url: base_api + 'carManager/index.php', //请求地址
  103. data: {
  104. tp: "carControl_getSeatNumber"
  105. },
  106. type: "post", //请求方式
  107. async: false,
  108. dataType: "json",
  109. success: function(data) {
  110. console.log(data);
  111. if(data.code == 0) {
  112. get_seat_number_baseinfo(data.data);
  113. } else {
  114. ZZAlertInfo(data.info);
  115. }
  116. }
  117. });
  118. }
  119. //替换座位数量配置信息
  120. function get_seat_number_baseinfo(data) {
  121. var temp = '<option value="0">请选择</option>';
  122. for(var i = 0, j = data.length; i < j; i++) {
  123. temp += '<option value="' + data[i].res_id + '">' + data[i].seat_number + '</option>';
  124. }
  125. $("#seat_number").html(temp);
  126. }
  127. //加载车辆状态配置信息
  128. //function bus_status_baseinfo() {
  129. // $.ajax({
  130. // url: base_api + 'carManager/index.php', //请求地址
  131. // data: {
  132. // tp: "carControl_getCarStatus"
  133. // },
  134. // async: false,
  135. // type: "post", //请求方式
  136. // dataType: "json",
  137. // success: function(data) {
  138. // console.log(data);
  139. // if(data.code == 0) {
  140. // get_bus_status_baseinfo(data.data);
  141. // } else {
  142. // ZZAlertInfo(data.info);
  143. // }
  144. //
  145. // }
  146. // });
  147. //}
  148. //替换车辆状态配置信息
  149. //function get_bus_status_baseinfo(data) {
  150. // var temp = '<option value="0">请选择</option>';
  151. // for(var i = 0, j = data.length; i < j; i++) {
  152. // temp += '<option value="' + data[i].id + '">' + data[i].bus_status + '</option>';
  153. // }
  154. // $("#status_select").html(temp);
  155. //}
  156. //加载车辆颜色配置信息
  157. function bus_color_baseinfo() {
  158. $.ajax({
  159. url: base_api + 'carManager/index.php', //请求地址
  160. data: {
  161. tp: "carControl_getColorList"
  162. },
  163. type: "post", //请求方式
  164. async: false,
  165. dataType: "json",
  166. success: function(data) {
  167. console.log(data);
  168. if(data.code == 0) {
  169. get_bus_color_baseinfo(data.data);
  170. } else {
  171. ZZAlertInfo(data.info);
  172. }
  173. }
  174. });
  175. }
  176. //替换车辆颜色配置信息
  177. function get_bus_color_baseinfo(data) {
  178. var temp = '<option value="0">请选择</option>';
  179. for(var i = 0, j = data.length; i < j; i++) {
  180. temp += '<option value="' + data[i].res_id + '">' + data[i].color + '</option>';
  181. }
  182. $("#bus_color").html(temp);
  183. }
  184. function set_year() {
  185. var myDate = new Date();
  186. var year = myDate.getFullYear();
  187. var temp = '<option value="0">请选择</option>';
  188. for(var i = 20; i > 0; i--) {
  189. temp += '<option value="' + (year) + '">' + (year) + '年' + '</option>';
  190. year = year - 1;
  191. }
  192. $("#year_select").html(temp);
  193. }
  194. function set_month() {
  195. var temp = '<option value="0">请选择</option>';
  196. for(var i = 1; i < 13; i++) {
  197. temp += '<option value="' + i + '">' + i + '月' + '</option>';
  198. }
  199. $("#month_select").html(temp);
  200. }
  201. function get_bus_detail_info() {
  202. var bus_id = getPar("bus_id");
  203. if(bus_id != 0) {
  204. $.ajax({
  205. url: base_api + 'carManager/index.php', //请求地址
  206. data: {
  207. tp: "carControl_getBusInfo",
  208. bus_id: bus_id,
  209. },
  210. type: "post",
  211. dataType: "json",
  212. success: function(data) {
  213. ZZLog(data);
  214. if(data.code == "0") {
  215. $('#car_number').val(data.data[0].bus_no);
  216. $('#bus_color').val(data.data[0]["bus_color"]);
  217. $('#car_team').val(data.data[0]["org_id"]);
  218. $('#brand_select').val(data.data[0]["brand_id"]);
  219. $('#bus_version').val(data.data[0]["bus_license"]);
  220. $('#seat_type').val(data.data[0]["seat_type"]);
  221. $('#seat_number').val(data.data[0]["bus_type_res_id"]);
  222. $('#consumption').val(data.data[0]["mpg"]);
  223. $('#day_cost').val(data.data[0]["cost"]);
  224. $('#status_select').val(data.data[0]["bus_state"]);
  225. $('#driver').val(data.data[0]["driver_count"]);
  226. $('#guider').val(data.data[0]["tour_count"]);
  227. $('#auxiliary_seat').val(data.data[0]["extra_count"]);
  228. $('#year_select').val(data.data[0]["buy_year"]);
  229. $('#month_select').val(data.data[0]["buy_month"]);
  230. $('#bus_img_allpath_old').val(data.data[0]["bus_img_path"]);
  231. //车辆图片信息,数据库原格式 "../upload/car/****.jpg,../upload/car/***.png"
  232. var path = data.data[0]["bus_img_path"];
  233. path = path.split(',');
  234. var type = data.data[0]["bus_img_type"];
  235. type = type.split(',');
  236. if(path.length > 0){
  237. $.each(path, function(k, e){
  238. if(e != ''){
  239. var img_div = $(".bus_img_div:last").clone();
  240. $(img_div).find('.bus_image').html('-');
  241. $(img_div).find('.bus_image').addClass('bus_img_remove');
  242. $(".bus_img_group").prepend(img_div);
  243. $(".bus_image:first").css('background-image', 'url(' + e + ')');
  244. $(".bus_img_path_old:first").val(e);
  245. $(".bus_img_type_old:first").val(type[k]);
  246. $(".bus_img_type:first").val(type[k]);
  247. }
  248. })
  249. }
  250. } else {
  251. ZZLog(data)
  252. ZZAlertInfo(data.info);
  253. }
  254. }
  255. });
  256. } else {
  257. ZZAlertInfo("传入参数错误");
  258. }
  259. }
  260. function update_save() {
  261. var bus_id = getPar("bus_id");
  262. var bus_team = $("#car_team").val(); //所属车队
  263. var bus_brand = $("#brand_select").val(); //所属品牌
  264. var buy_year = $("#year_select").val(); //年
  265. var buy_month = $("#month_select").val(); //月
  266. var seat_type = $("#seat_type").val(); //客座
  267. var seat_number = $("#seat_number").val(); //座位数
  268. var bus_status = $("#status_select").val(); //状态
  269. var bus_color = $("#bus_color").val(); //颜色
  270. var car_number = $("#car_number").val(); //车牌号
  271. var bus_version = $("#bus_version").val(); //型号
  272. var driver = $("#driver").val(); //司机
  273. var guider = $("#guider").val(); //导游
  274. var auxiliary_seat = $("#auxiliary_seat").val(); //辅座
  275. var consumption = $("#consumption").val(); //油耗
  276. var day_cost = ""; //固定成本
  277. var bus_img_allpath_old = $("#bus_img_allpath_old").val(); //原始图片全路径
  278. var bus_img_alltype_old = $("#bus_img_alltype_old").val(); //原始图片全类型
  279. var bus_desc = $("#seat_type").find("option:selected").text() + $("#seat_number").find("option:selected").text();
  280. if(bus_team == 0 || bus_brand == 0 || buy_year == 0 || buy_month == 0 ||
  281. seat_type == 0 || seat_number == 0 || bus_status == 0 || car_number.length == 0) {
  282. if(car_number.length == 0) {
  283. ZZAlertInfo("请输入车牌号!");
  284. return;
  285. }
  286. if(bus_team == 0) {
  287. ZZAlertInfo("请输入所属车队!");
  288. return;
  289. }
  290. if(bus_brand == 0) {
  291. ZZAlertInfo("请输入品牌名!");
  292. return;
  293. }
  294. if(buy_year == 0) {
  295. ZZAlertInfo("请输入购车年份!");
  296. return;
  297. }
  298. if(buy_month == 0) {
  299. ZZAlertInfo("请输入购车月份!");
  300. return;
  301. }
  302. if(seat_type == 0) {
  303. ZZAlertInfo("请输入客座类型!");
  304. return;
  305. }
  306. if(seat_number == 0) {
  307. ZZAlertInfo("请输入客座数量!");
  308. return;
  309. }
  310. if(bus_status == 0) {
  311. ZZAlertInfo("请输入汽车状态!");
  312. return;
  313. }
  314. } else {
  315. var form = document.querySelector('form');
  316. var data = new FormData(form);
  317. data.append('tp', 'carControl_reviseCar');
  318. data.append('bus_id', bus_id);
  319. data.append('bus_number', car_number);
  320. data.append('bus_team', bus_team);
  321. data.append('bus_brand', bus_brand);
  322. data.append('bus_version', bus_version);
  323. data.append('buy_date', (buy_year + "-" + buy_month));
  324. data.append('seat_type', seat_type);
  325. data.append('seat_number', seat_number);
  326. data.append('driver', driver);
  327. data.append('guider', guider);
  328. data.append('auxiliary_seat', auxiliary_seat);
  329. data.append('consumption', consumption);
  330. data.append('day_cost', day_cost);
  331. data.append('status_select', bus_status);
  332. data.append('bus_color', bus_color);
  333. data.append('bus_desc', bus_desc);
  334. data.append('bus_img_allpath_old', bus_img_allpath_old);
  335. data.append('bus_img_alltype_old', bus_img_alltype_old);
  336. $.ajax({
  337. url: base_api + 'carManager/index.php', //请求地址
  338. data: data,
  339. type: "post",
  340. dataType: "json",
  341. processData: false,
  342. contentType: false,
  343. success: function(data) {
  344. if(data.code == "0") {
  345. ZZAlertInfo("修改成功!",function(){
  346. window.location.href = "carList.html";
  347. });
  348. } else {
  349. ZZLog(data)
  350. ZZAlertInfo(data.info);
  351. }
  352. },
  353. error: function (msg) {
  354. }
  355. });
  356. }
  357. }
  358. $("div.bus_img_group").on('change', 'select', function (e) {
  359. var img = $(this).closest('.bus_img_div').find('.bus_image');
  360. // $(img).closest('.bus_img_div').find('.bus_img_path_old').val('');
  361. $(img).closest('.bus_img_div').find('.bus_img_type_old').val($(this).val());
  362. })