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.
 
 
 
 

326 lines
8.5 KiB

  1. var img_type=[];
  2. $(document).ready(function() {
  3. bus_team_baseinfo();
  4. brand_list_baseinfo();
  5. bus_type_baseinfo();
  6. seat_number_baseinfo();
  7. // bus_status_baseinfo();
  8. bus_color_baseinfo();
  9. set_year();
  10. set_month();
  11. load_img_type();
  12. });
  13. //加载车队配置信息
  14. function bus_team_baseinfo() {
  15. $.ajax({
  16. url: base_api + 'carManager/index.php', //请求地址
  17. data: {
  18. tp: "carControl_orgList"
  19. },
  20. type: "post", //请求方式
  21. dataType: "json",
  22. success: function(data) {
  23. console.log(data);
  24. if(data.code == 0) {
  25. get_bus_team_baseinfo(data.data);
  26. } else {
  27. ZZAlertInfo(data.info);
  28. }
  29. }
  30. });
  31. }
  32. //替换车队加载配置信息
  33. function get_bus_team_baseinfo(data) {
  34. var temp = '<option value="0">请选择</option>';
  35. for(var i = 0, j = data.length; i < j; i++) {
  36. temp += '<option value="' + data[i].supplier_id + '">' + data[i].bus_team + '</option>';
  37. }
  38. $("#car_team").html(temp);
  39. }
  40. //加载品牌配置信息
  41. function brand_list_baseinfo() {
  42. $.ajax({
  43. url: base_api + 'carManager/index.php', //请求地址
  44. data: {
  45. tp: "carControl_brandList"
  46. },
  47. type: "post", //请求方式
  48. dataType: "json",
  49. success: function(data) {
  50. console.log(data);
  51. if(data.code == 0) {
  52. get_brand_list_baseinfo(data.data);
  53. } else {
  54. ZZAlertInfo(data.info);
  55. }
  56. }
  57. });
  58. }
  59. //替换品牌加载配置信息
  60. function get_brand_list_baseinfo(data) {
  61. var temp = '<option value="0">请选择</option>';
  62. for(var i = 0, j = data.length; i < j; i++) {
  63. temp += '<option value="' + data[i].res_id + '">' + data[i].res_name + '</option>';
  64. }
  65. $("#brand_select").html(temp);
  66. }
  67. //加载车辆类型配置信息
  68. function bus_type_baseinfo() {
  69. $.ajax({
  70. url: base_api + 'carManager/index.php', //请求地址
  71. data: {
  72. tp: "carControl_getSeatType"
  73. },
  74. type: "post", //请求方式
  75. dataType: "json",
  76. success: function(data) {
  77. console.log(data);
  78. if(data.code == 0) {
  79. get_bus_type_baseinfo(data.data);
  80. } else {
  81. ZZAlertInfo(data.info);
  82. }
  83. }
  84. });
  85. }
  86. //替换车辆类型配置信息
  87. function get_bus_type_baseinfo(data) {
  88. var temp = '';
  89. for(var i = 0, j = data.length; i < j; i++) {
  90. temp += '<option value="' + data[i].id + '">' + data[i].seat_type + '</option>';
  91. }
  92. $("#seat_type").html(temp);
  93. }
  94. //加载座位数量配置信息
  95. function seat_number_baseinfo() {
  96. $.ajax({
  97. url: base_api + 'carManager/index.php', //请求地址
  98. data: {
  99. tp: "carControl_getSeatNumber"
  100. },
  101. type: "post", //请求方式
  102. dataType: "json",
  103. success: function(data) {
  104. console.log(data);
  105. if(data.code == 0) {
  106. get_seat_number_baseinfo(data.data);
  107. } else {
  108. ZZAlertInfo(data.info);
  109. }
  110. }
  111. });
  112. }
  113. //替换座位数量配置信息
  114. function get_seat_number_baseinfo(data) {
  115. var temp = '<option value="0">请选择</option>';
  116. for(var i = 0, j = data.length; i < j; i++) {
  117. temp += '<option value="' + data[i].res_id + '">' + data[i].seat_number + '</option>';
  118. }
  119. $("#seat_number").html(temp);
  120. }
  121. //加载车辆状态配置信息 去掉状态
  122. //function bus_status_baseinfo() {
  123. // $.ajax({
  124. // url: base_api + 'carManager/index.php', //请求地址
  125. // data: {
  126. // tp: "carControl_getCarStatus"
  127. // },
  128. // type: "post", //请求方式
  129. // dataType: "json",
  130. // success: function(data) {
  131. // console.log(data);
  132. // if(data.code == 0) {
  133. // get_bus_status_baseinfo(data.data);
  134. // } else {
  135. // ZZAlertInfo(data.info);
  136. // }
  137. //
  138. // }
  139. // });
  140. //}
  141. //替换车辆状态配置信息 去掉状态
  142. //function get_bus_status_baseinfo(data) {
  143. // var temp = '<option value="0">请选择</option>';
  144. // for(var i = 0, j = data.length; i < j; i++) {
  145. // temp += '<option value="' + data[i].id + '">' + data[i].bus_status + '</option>';
  146. // }
  147. // $("#status_select").html(temp);
  148. //}
  149. //加载车辆颜色配置信息
  150. function bus_color_baseinfo() {
  151. $.ajax({
  152. url: base_api + 'carManager/index.php', //请求地址
  153. data: {
  154. tp: "carControl_getColorList"
  155. },
  156. type: "post", //请求方式
  157. dataType: "json",
  158. success: function(data) {
  159. console.log(data);
  160. if(data.code == 0) {
  161. get_bus_color_baseinfo(data.data);
  162. } else {
  163. ZZAlertInfo(data.info);
  164. }
  165. }
  166. });
  167. }
  168. //替换车辆颜色配置信息
  169. function get_bus_color_baseinfo(data) {
  170. var temp = '<option value="0">请选择</option>';
  171. for(var i = 0, j = data.length; i < j; i++) {
  172. temp += '<option value="' + data[i].res_id + '">' + data[i].color + '</option>';
  173. }
  174. $("#bus_color").html(temp);
  175. }
  176. function set_year() {
  177. var myDate = new Date();
  178. var year = myDate.getFullYear();
  179. var temp = '<option value="0">请选择</option>';
  180. for(var i = 20; i > 0; i--) {
  181. temp += '<option value="' + (year) + '">' + (year) + '年' + '</option>';
  182. year = year - 1;
  183. }
  184. $("#year_select").html(temp);
  185. }
  186. function set_month() {
  187. var temp = '<option value="0">请选择</option>';
  188. for(var i = 1; i < 13; i++) {
  189. var month=(Array(2).join(0)+i).slice(-2);
  190. temp += '<option value="' + month + '">' + i + '月' + '</option>';
  191. }
  192. $("#month_select").html(temp);
  193. }
  194. function all_save() {
  195. var bus_team = $("#car_team").val(); //所属车队
  196. var bus_brand = $("#brand_select").val(); //所属品牌
  197. var buy_year = $("#year_select").val(); //年
  198. var buy_month = $("#month_select").val(); //月
  199. var seat_type = $("#seat_type").val(); //客座
  200. var seat_number = $("#seat_number").val(); //座位数【并不是座位数,而是base_resource的id值】
  201. var bus_status = $("#status_select").val(); //状态
  202. var bus_color = $("#bus_color").val(); //颜色
  203. var car_number = $("#car_number").val(); //车牌号
  204. var bus_version = $("#bus_version").val(); //型号
  205. var driver = $("#driver").val(); //司机
  206. var guider = $("#guider").val(); //导游
  207. var auxiliary_seat = $("#auxiliary_seat").val(); //辅座
  208. var consumption = $("#consumption").val(); //油耗
  209. var day_cost = ""; //固定成本
  210. var bus_desc = $("#seat_type").find("option:selected").text() + $("#seat_number").find("option:selected").text();
  211. if(bus_team == 0 || bus_brand == 0 || buy_year == 0 || buy_month == 0 ||
  212. seat_type == 0 || seat_number == 0 || bus_status == 0 || car_number.length == 0) {
  213. if(car_number.length == 0) {
  214. ZZAlertInfo("请输入车牌号!");
  215. return;
  216. }
  217. if(bus_team == 0) {
  218. ZZAlertInfo("请输入所属车队!");
  219. return;
  220. }
  221. if(bus_brand == 0) {
  222. ZZAlertInfo("请输入品牌名!");
  223. return;
  224. }
  225. if(buy_year == 0) {
  226. ZZAlertInfo("请输入购车年份!");
  227. return;
  228. }
  229. if(buy_month == 0) {
  230. ZZAlertInfo("请输入购车月份!");
  231. return;
  232. }
  233. if(seat_type == 0) {
  234. ZZAlertInfo("请输入客座类型!");
  235. return;
  236. }
  237. if(seat_number == 0) {
  238. ZZAlertInfo("请输入客座数量!");
  239. return;
  240. }
  241. if(bus_status == 0) {
  242. ZZAlertInfo("请输入汽车状态!");
  243. return;
  244. }
  245. } else {
  246. var form = document.querySelector('form');
  247. var data = new FormData(form);
  248. data.append('tp', 'carControl_addCar');
  249. data.append('bus_number', car_number);
  250. data.append('bus_team', bus_team);
  251. data.append('bus_brand', bus_brand);
  252. data.append('bus_version', bus_version);
  253. data.append('buy_date', (buy_year + "-" + buy_month));
  254. data.append('seat_type', seat_type);
  255. data.append('seat_number', seat_number);
  256. data.append('driver', driver);
  257. data.append('guider', guider);
  258. data.append('auxiliary_seat', auxiliary_seat);
  259. data.append('consumption', consumption);
  260. data.append('day_cost', day_cost);
  261. data.append('status_select', bus_status);
  262. data.append('bus_color', bus_color);
  263. data.append('bus_desc', bus_desc);
  264. ZZLog(data);
  265. $.ajax({
  266. url: base_api + 'carManager/index.php', //请求地址
  267. data: data,
  268. type: "post",
  269. dataType: "json",
  270. processData: false,
  271. contentType: false,
  272. success: function (data) {
  273. if(data.code == "0") {
  274. ZZAlertInfo("添加成功!",function(){
  275. window.location.href = "carList.html";
  276. });
  277. } else {
  278. ZZLog(data)
  279. ZZAlertInfo(data.info);
  280. }
  281. }
  282. });
  283. }
  284. }
  285. //加载图片类型数组
  286. function load_img_type() {
  287. $.ajax({
  288. url: base_api + 'carManager/index.php', //请求地址
  289. data: {
  290. tp: "carControl_getImgType"
  291. },
  292. type: "post", //请求方式
  293. dataType: "json",
  294. success: function(data) {
  295. console.log(data);
  296. if(data.code == 0) {
  297. data = data.data;
  298. var temp = '<option value="0">请选择</option>';
  299. for(var i = 0, j = data.length; i < j; i++) {
  300. temp += '<option value="' + data[i].id + '">' + data[i].img_status + '</option>';
  301. }
  302. $(".bus_img_type").html(temp);
  303. } else {
  304. ZZAlertInfo(data.info);
  305. }
  306. }
  307. });
  308. }