puzhibing
2024-02-05 640ff18d2d7f4be02ddb7f8f75e899f05545eb98
cloud-server-management/src/main/webapp/static/modular/system/tDiscount/tDiscount_info.js
New file
@@ -0,0 +1,322 @@
/**
 * 初始化车辆管理详情对话框
 */
var language=1;
var TCarInfoDlg = {
    tCarInfoData : {},
    validateFields: {
    }
};
/**
 * 验证数据是否为空
 */
TCarInfoDlg.validate = function () {
    $('#carInfoForm').data("bootstrapValidator").resetForm();
    $('#carInfoForm').bootstrapValidator('validate');
    return $("#carInfoForm").data('bootstrapValidator').isValid();
};
/**
 * 清除数据
 */
TCarInfoDlg.clearData = function() {
    this.tCarInfoData = {};
}
/**
 * 设置对话框中的数据
 *
 * @param key 数据的名称
 * @param val 数据的具体值
 */
TCarInfoDlg.set = function(key, val) {
    this.tCarInfoData[key] = (typeof val == "undefined") ? $("#" + key).val() : val;
    return this;
}
/**
 * 设置对话框中的数据
 *
 * @param key 数据的名称
 * @param val 数据的具体值
 */
TCarInfoDlg.get = function(key) {
    return $("#" + key).val();
}
/**
 * 关闭此对话框
 */
TCarInfoDlg.close = function() {
    parent.layer.close(window.parent.TCompetition.layerIndex);
}
/**
 * 收集数据
 */
TCarInfoDlg.collectData = function() {
    this
    .set('id')
    .set('isPlatCar')
    .set('companyId')
    .set('franchiseeId')
    .set('carColor')
    .set('carModelId')
    .set('carBrandId')
    .set('carLicensePlate')
    .set('carPhoto')
    .set('drivingLicenseNumber')
    .set('drivingLicensePhoto')
    .set('annualInspectionTime')
    .set('commercialInsuranceTime')
    .set('createTime')
    .set('state')
    .set('addType')
    .set('addObjectId')
    .set('plateColor')
    .set('vehicleType')
    .set('ownerName')
    .set('engineId')
    .set('VIN')
    .set('certifyDateA')
    .set('fuelType')
    .set('engineDisplace')
    .set('certificate')
    .set('transAgency')
    .set('transArea')
    .set('transDateStart')
    .set('transDateStop')
    .set('certifyDateB')
    .set('fixState')
    .set('nextFixDate')
    .set('checkState')
    .set('feePrintId')
    .set('GPSBrand')
    .set('GPSModel')
    .set('GPSIMEI')
    .set('GPSInstallDate')
    .set('registerDate')
    .set('commercialType');
}
TCarInfoDlg.audit = function() {
}
/**
 * 提交添加
 */
TCarInfoDlg.addSubmit = function() {
    this.clearData();
    this.collectData();
    if(!this.validate()){
        return ;
    }
    let pCode = $("#pCode").val()
    let cCode = $("#cCode").val()
    let name = $("#name").val()
    let phone = $("#phone").val()
    if(pCode==''){
        Feng.info("请选择省")
        return;
    }
    if(cCode==''){
        Feng.info("请选择市")
        return;
    }
    if(name==''){
        Feng.info("管理员姓名不能为空")
        return;
    }
    if(phone==''){
        Feng.info("管理员手机号不能为空")
        return;
    }
    //提交信息
    var ajax = new $ax(Feng.ctxPath + "/tCity/add", function(data){
        if(data=="5001"){
            Feng.error("改账号已经存在");
        }else
        if(data.code == 200){
            if(language==1){
                Feng.success("添加成功!");
            }else if(language==2){
                Feng.success("Successfully added!");
            }else {
                Feng.success("Sangat berhasil ditambah!");
            }
            window.parent.TCompetition.table.refresh();
            TCarInfoDlg.close();
        }else{
            Feng.error(data.msg);
        }
    },function(data){
        Feng.error("添加失败!" + data.responseJSON.message + "!");
    });
    ajax.set(this.tCarInfoData);
    ajax.set("provinceCode",pCode);
    ajax.set("cityCode",cCode);
    ajax.set("name",name);
    ajax.set("phone",phone);
    ajax.start();
}
/**
 * 提交修改
 */
TCarInfoDlg.editSubmit = function() {
    this.clearData();
    this.collectData();
    if(!this.validate()){
        return ;
    }
    let pCode = $("#pCode").val()
    let cCode = $("#cCode").val()
    let name = $("#name").val()
    let phone = $("#phone").val()
    if(pCode==''){
        Feng.info("请选择省")
        return;
    }
    if(cCode==''){
        Feng.info("请选择市")
        return;
    }
    if(name==''){
        Feng.info("管理员姓名不能为空")
        return;
    }
    if(phone==''){
        Feng.info("管理员手机号不能为空")
        return;
    }
    //提交信息
    var ajax = new $ax(Feng.ctxPath + "/tCity/update", function(data){
        if(data=="5001"){
            Feng.error("改账号已经存在");
        }else
        if(data.code == 200){
            if(language==1){
                Feng.success("修改成功!");
            }else if(language==2){
                Feng.success("Modify successfully!");
            }else {
                Feng.success("Mengubah dengan sukses!");
            }
            window.parent.TCompetition.table.refresh();
            TCarInfoDlg.close();
        }else{
            Feng.error(data.msg);
        }
    },function(data){
        Feng.error("修改失败!" + data.responseJSON.message + "!");
    });
    ajax.set("provinceCode",pCode);
    ajax.set("cityCode",cCode);
    ajax.set("name",name);
    ajax.set("phone",phone);
    ajax.set("id",$("#id").val());
    ajax.start();
}
$(function() {
    Feng.initValidator("carInfoForm", TCarInfoDlg.validateFields);
    // 初始化图片上传
    var carPhoto = new $WebUpload("carPhoto");
    carPhoto.setUploadBarId("progressBar");
    carPhoto.init();
    var drivingLicensePhoto = new $WebUpload("drivingLicensePhoto");
    drivingLicensePhoto.setUploadBarId("progressBar");
    drivingLicensePhoto.init();
});
/**
 * 选择分公司后执行
 */
TCarInfoDlg.oneChange = function (e) {
    var oneId=$(e).val();
    var ajax = new $ax(Feng.ctxPath + "/tCity/onChange", function(data){
        if(data!=null){
            if(language==1){
                var content='<option value="">选择市</option>';
            }else if(language==2){
                var content='<option value="">Choose your franchisee</option>';
            }else {
                var content='<option value="">Pilih franchisee Anda</option>';
            }
            $.each(data, function(k,v) {
                content += "<option value='"+v.code+"'>"+v.name+"</option>";
            });
            $("#cCode").empty().append(content);
        }
    });
    ajax.set("oneId",oneId);
    ajax.start();
}
/**
 * 类型改变执行
 * @param e
 */
TCarInfoDlg.companyTypeClick = function (e) {
    if (1 == e){
        $(".companyDiv").hide();
    } else if (2 == e){
        $(".companyDiv").show();
    }
}
/**
 * 车辆品牌改变时执行
 */
TCarInfoDlg.brandChange = function (e) {
    var carBrandId=$(e).val();
    var ajax = new $ax(Feng.ctxPath + "/tCar/brandChange", function(data){
        if(data!=null){
            if(language==1){
                var content='<option value="">选择车辆类型</option>';
            }else if(language==2){
                var content='<option value="">Please select the vehicle type</option>';
            }else {
                var content='<option value="">Pilih Jenis Kendaraan</option>';
            }
            $.each(data, function(k,v) {
                content += "<option value='"+v.id+"'>"+v.name+"</option>";
            });
            $("#carModelId").empty().append(content);
        }
    });
    ajax.set("carBrandId",carBrandId);
    ajax.start();
}
/**
 * 专车服务被点击
 */
TCarInfoDlg.zcServerClick = function () {
    var serverBox1 = $('#serverBox1').prop('checked');
    if (serverBox1){
        $("#zcModelDiv").show();
    } else {
        $("#zcModelDiv").hide();
    }
}
/**
 * 跨城服务被点击
 */
TCarInfoDlg.kcServerClick = function () {
    var serverBox3 = $('#serverBox3').prop('checked');
    if (serverBox3){
        $("#kcModelDiv").show();
    } else {
        $("#kcModelDiv").hide();
    }
}