|
- $(document).ready(function() {
- //firfox会初始化图片历史路径到bus_img_path
- $(".bus_img_div input").val('');
- bus_team_baseinfo();
- brand_list_baseinfo();
- load_img_type();
- bus_type_baseinfo();
- seat_number_baseinfo();
- // bus_status_baseinfo();
- bus_color_baseinfo();
- set_year();
- set_month();
- get_bus_detail_info();
- });
- //加载车队配置信息
- function bus_team_baseinfo() {
- $.ajax({
- url: base_api + 'carManager/index.php', //请求地址
- data: {
- tp: "carControl_orgList"
- },
- type: "post", //请求方式
- async: false,
- 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", //请求方式
- async: false,
- 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"
- },
- async: false,
- 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", //请求方式
- async: false,
- 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"
- // },
- // async: false,
- // 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", //请求方式
- async: false,
- 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++) {
- temp += '<option value="' + i + '">' + i + '月' + '</option>';
- }
- $("#month_select").html(temp);
- }
-
- function get_bus_detail_info() {
- var bus_id = getPar("bus_id");
- if(bus_id != 0) {
- $.ajax({
- url: base_api + 'carManager/index.php', //请求地址
- data: {
- tp: "carControl_getBusInfo",
- bus_id: bus_id,
- },
- type: "post",
- dataType: "json",
- success: function(data) {
- ZZLog(data);
- if(data.code == "0") {
- $('#car_number').val(data.data[0].bus_no);
- $('#bus_color').val(data.data[0]["bus_color"]);
- $('#car_team').val(data.data[0]["org_id"]);
- $('#brand_select').val(data.data[0]["brand_id"]);
- $('#bus_version').val(data.data[0]["bus_license"]);
- $('#seat_type').val(data.data[0]["seat_type"]);
- $('#seat_number').val(data.data[0]["bus_type_res_id"]);
- $('#consumption').val(data.data[0]["mpg"]);
- $('#day_cost').val(data.data[0]["cost"]);
- $('#status_select').val(data.data[0]["bus_state"]);
- $('#driver').val(data.data[0]["driver_count"]);
- $('#guider').val(data.data[0]["tour_count"]);
- $('#auxiliary_seat').val(data.data[0]["extra_count"]);
- $('#year_select').val(data.data[0]["buy_year"]);
- $('#month_select').val(data.data[0]["buy_month"]);
- $('#bus_img_allpath_old').val(data.data[0]["bus_img_path"]);
-
- //车辆图片信息,数据库原格式 "../upload/car/****.jpg,../upload/car/***.png"
- var path = data.data[0]["bus_img_path"];
- path = path.split(',');
- var type = data.data[0]["bus_img_type"];
- type = type.split(',');
- if(path.length > 0){
- $.each(path, function(k, e){
- if(e != ''){
- var img_div = $(".bus_img_div:last").clone();
- $(img_div).find('.bus_image').html('-');
- $(img_div).find('.bus_image').addClass('bus_img_remove');
- $(".bus_img_group").prepend(img_div);
- $(".bus_image:first").css('background-image', 'url(' + e + ')');
- $(".bus_img_path_old:first").val(e);
- $(".bus_img_type_old:first").val(type[k]);
- $(".bus_img_type:first").val(type[k]);
-
- }
- })
- }
-
- } else {
- ZZLog(data)
- ZZAlertInfo(data.info);
- }
- }
- });
- } else {
- ZZAlertInfo("传入参数错误");
- }
- }
-
- function update_save() {
- var bus_id = getPar("bus_id");
- 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(); //座位数
- 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_img_allpath_old = $("#bus_img_allpath_old").val(); //原始图片全路径
- var bus_img_alltype_old = $("#bus_img_alltype_old").val(); //原始图片全类型
- 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_reviseCar');
- data.append('bus_id', bus_id);
- 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);
- data.append('bus_img_allpath_old', bus_img_allpath_old);
- data.append('bus_img_alltype_old', bus_img_alltype_old);
-
- $.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);
- }
-
- },
- error: function (msg) {
-
- }
- });
-
- }
-
- }
-
- $("div.bus_img_group").on('change', 'select', function (e) {
- var img = $(this).closest('.bus_img_div').find('.bus_image');
- // $(img).closest('.bus_img_div').find('.bus_img_path_old').val('');
- $(img).closest('.bus_img_div').find('.bus_img_type_old').val($(this).val());
-
- })
|