|
- var img_type=[];
- $(document).ready(function() {
- bus_team_baseinfo();
- brand_list_baseinfo();
- bus_type_baseinfo();
- seat_number_baseinfo();
- // bus_status_baseinfo();
- bus_color_baseinfo();
- set_year();
- set_month();
- load_img_type();
- });
- //加载车队配置信息
- function bus_team_baseinfo() {
- $.ajax({
- url: base_api + 'carManager/index.php', //请求地址
- data: {
- tp: "carControl_orgList"
- },
- type: "post", //请求方式
- dataType: "json",
- success: function(data) {
- console.log(data);
- if(data.code == 0) {
- get_bus_team_baseinfo(data.data);
- } else {
- ZZAlertInfo(data.info);
- }
-
- }
- });
- }
- //替换车队加载配置信息
- function get_bus_team_baseinfo(data) {
- var temp = '<option value="0">请选择</option>';
- for(var i = 0, j = data.length; i < j; i++) {
- temp += '<option value="' + data[i].supplier_id + '">' + data[i].bus_team + '</option>';
- }
- $("#car_team").html(temp);
- }
- //加载品牌配置信息
- function brand_list_baseinfo() {
- $.ajax({
- url: base_api + 'carManager/index.php', //请求地址
- data: {
- tp: "carControl_brandList"
- },
- type: "post", //请求方式
- dataType: "json",
- success: function(data) {
- console.log(data);
- if(data.code == 0) {
- get_brand_list_baseinfo(data.data);
- } else {
- ZZAlertInfo(data.info);
- }
-
- }
- });
- }
- //替换品牌加载配置信息
- function get_brand_list_baseinfo(data) {
- var temp = '<option value="0">请选择</option>';
- for(var i = 0, j = data.length; i < j; i++) {
- temp += '<option value="' + data[i].res_id + '">' + data[i].res_name + '</option>';
- }
- $("#brand_select").html(temp);
- }
- //加载车辆类型配置信息
- function bus_type_baseinfo() {
- $.ajax({
- url: base_api + 'carManager/index.php', //请求地址
- data: {
- tp: "carControl_getSeatType"
- },
- type: "post", //请求方式
- dataType: "json",
- success: function(data) {
- console.log(data);
- if(data.code == 0) {
- get_bus_type_baseinfo(data.data);
- } else {
- ZZAlertInfo(data.info);
- }
-
- }
- });
- }
- //替换车辆类型配置信息
- function get_bus_type_baseinfo(data) {
- var temp = '';
- for(var i = 0, j = data.length; i < j; i++) {
- temp += '<option value="' + data[i].id + '">' + data[i].seat_type + '</option>';
- }
- $("#seat_type").html(temp);
- }
-
- //加载座位数量配置信息
- function seat_number_baseinfo() {
- $.ajax({
- url: base_api + 'carManager/index.php', //请求地址
- data: {
- tp: "carControl_getSeatNumber"
- },
- type: "post", //请求方式
- dataType: "json",
- success: function(data) {
- console.log(data);
- if(data.code == 0) {
- get_seat_number_baseinfo(data.data);
- } else {
- ZZAlertInfo(data.info);
- }
-
- }
- });
- }
- //替换座位数量配置信息
- function get_seat_number_baseinfo(data) {
- var temp = '<option value="0">请选择</option>';
- for(var i = 0, j = data.length; i < j; i++) {
- temp += '<option value="' + data[i].res_id + '">' + data[i].seat_number + '</option>';
- }
- $("#seat_number").html(temp);
- }
- //加载车辆状态配置信息 去掉状态
- //function bus_status_baseinfo() {
- // $.ajax({
- // url: base_api + 'carManager/index.php', //请求地址
- // data: {
- // tp: "carControl_getCarStatus"
- // },
- // type: "post", //请求方式
- // dataType: "json",
- // success: function(data) {
- // console.log(data);
- // if(data.code == 0) {
- // get_bus_status_baseinfo(data.data);
- // } else {
- // ZZAlertInfo(data.info);
- // }
- //
- // }
- // });
- //}
-
- //替换车辆状态配置信息 去掉状态
- //function get_bus_status_baseinfo(data) {
- // var temp = '<option value="0">请选择</option>';
- // for(var i = 0, j = data.length; i < j; i++) {
- // temp += '<option value="' + data[i].id + '">' + data[i].bus_status + '</option>';
- // }
- // $("#status_select").html(temp);
- //}
- //加载车辆颜色配置信息
- function bus_color_baseinfo() {
- $.ajax({
- url: base_api + 'carManager/index.php', //请求地址
- data: {
- tp: "carControl_getColorList"
- },
- type: "post", //请求方式
- dataType: "json",
- success: function(data) {
- console.log(data);
- if(data.code == 0) {
- get_bus_color_baseinfo(data.data);
- } else {
- ZZAlertInfo(data.info);
- }
-
- }
- });
- }
- //替换车辆颜色配置信息
- function get_bus_color_baseinfo(data) {
- var temp = '<option value="0">请选择</option>';
- for(var i = 0, j = data.length; i < j; i++) {
- temp += '<option value="' + data[i].res_id + '">' + data[i].color + '</option>';
- }
- $("#bus_color").html(temp);
- }
-
- function set_year() {
- var myDate = new Date();
- var year = myDate.getFullYear();
- var temp = '<option value="0">请选择</option>';
- for(var i = 20; i > 0; i--) {
- temp += '<option value="' + (year) + '">' + (year) + '年' + '</option>';
- year = year - 1;
- }
- $("#year_select").html(temp);
- }
-
- function set_month() {
- var temp = '<option value="0">请选择</option>';
- for(var i = 1; i < 13; i++) {
- var month=(Array(2).join(0)+i).slice(-2);
- temp += '<option value="' + month + '">' + i + '月' + '</option>';
- }
- $("#month_select").html(temp);
- }
-
- function all_save() {
- var bus_team = $("#car_team").val(); //所属车队
- var bus_brand = $("#brand_select").val(); //所属品牌
- var buy_year = $("#year_select").val(); //年
- var buy_month = $("#month_select").val(); //月
- var seat_type = $("#seat_type").val(); //客座
- var seat_number = $("#seat_number").val(); //座位数【并不是座位数,而是base_resource的id值】
- var bus_status = $("#status_select").val(); //状态
- var bus_color = $("#bus_color").val(); //颜色
- var car_number = $("#car_number").val(); //车牌号
- var bus_version = $("#bus_version").val(); //型号
- var driver = $("#driver").val(); //司机
- var guider = $("#guider").val(); //导游
- var auxiliary_seat = $("#auxiliary_seat").val(); //辅座
- var consumption = $("#consumption").val(); //油耗
- var day_cost = ""; //固定成本
- var bus_desc = $("#seat_type").find("option:selected").text() + $("#seat_number").find("option:selected").text();
- if(bus_team == 0 || bus_brand == 0 || buy_year == 0 || buy_month == 0 ||
- seat_type == 0 || seat_number == 0 || bus_status == 0 || car_number.length == 0) {
- if(car_number.length == 0) {
- ZZAlertInfo("请输入车牌号!");
- return;
- }
- if(bus_team == 0) {
- ZZAlertInfo("请输入所属车队!");
- return;
- }
- if(bus_brand == 0) {
- ZZAlertInfo("请输入品牌名!");
- return;
- }
- if(buy_year == 0) {
- ZZAlertInfo("请输入购车年份!");
- return;
- }
- if(buy_month == 0) {
- ZZAlertInfo("请输入购车月份!");
- return;
- }
- if(seat_type == 0) {
- ZZAlertInfo("请输入客座类型!");
- return;
- }
- if(seat_number == 0) {
- ZZAlertInfo("请输入客座数量!");
- return;
- }
- if(bus_status == 0) {
- ZZAlertInfo("请输入汽车状态!");
- return;
- }
-
- } else {
- var form = document.querySelector('form');
- var data = new FormData(form);
- data.append('tp', 'carControl_addCar');
- data.append('bus_number', car_number);
- data.append('bus_team', bus_team);
- data.append('bus_brand', bus_brand);
- data.append('bus_version', bus_version);
- data.append('buy_date', (buy_year + "-" + buy_month));
- data.append('seat_type', seat_type);
- data.append('seat_number', seat_number);
- data.append('driver', driver);
- data.append('guider', guider);
- data.append('auxiliary_seat', auxiliary_seat);
- data.append('consumption', consumption);
- data.append('day_cost', day_cost);
- data.append('status_select', bus_status);
- data.append('bus_color', bus_color);
- data.append('bus_desc', bus_desc);
- ZZLog(data);
- $.ajax({
- url: base_api + 'carManager/index.php', //请求地址
- data: data,
- type: "post",
- dataType: "json",
- processData: false,
- contentType: false,
- success: function (data) {
-
- if(data.code == "0") {
- ZZAlertInfo("添加成功!",function(){
- window.location.href = "carList.html";
- });
-
- } else {
- ZZLog(data)
- ZZAlertInfo(data.info);
- }
-
- }
- });
-
- }
-
- }
- //加载图片类型数组
- function load_img_type() {
- $.ajax({
- url: base_api + 'carManager/index.php', //请求地址
- data: {
- tp: "carControl_getImgType"
- },
- type: "post", //请求方式
- dataType: "json",
- success: function(data) {
- console.log(data);
- if(data.code == 0) {
- data = data.data;
- var temp = '<option value="0">请选择</option>';
- for(var i = 0, j = data.length; i < j; i++) {
- temp += '<option value="' + data[i].id + '">' + data[i].img_status + '</option>';
- }
- $(".bus_img_type").html(temp);
- } else {
- ZZAlertInfo(data.info);
- }
-
- }
- });
- }
|