/**
|
* 初始化车辆管理详情对话框
|
*/
|
var SellingCarInfo = {
|
tCarInfoData : {},
|
validateFields: {
|
title: {
|
validators: {
|
notEmpty: {
|
message: '标题不能为空'
|
}
|
}
|
},
|
carIdentificationCode: {
|
validators: {
|
notEmpty: {
|
message: '车辆识别码不能为空'
|
}
|
}
|
},
|
carLicensePlate: {
|
validators: {
|
notEmpty: {
|
message: '车牌号不能为空'
|
}
|
}
|
},
|
brandId: {
|
validators: {
|
notEmpty: {
|
message: '品牌不能为空'
|
}
|
}
|
},
|
carColor: {
|
validators: {
|
notEmpty: {
|
message: '车辆颜色不能为空'
|
}
|
}
|
},
|
licensingTime: {
|
validators: {
|
notEmpty: {
|
message: '首次上牌时间不能为空'
|
}
|
}
|
},
|
mileage: {
|
validators: {
|
notEmpty: {
|
message: '行驶里程不能为空'
|
}
|
}
|
},
|
locationOfLicensePlate: {
|
validators: {
|
notEmpty: {
|
message: '牌照所在地不能为空'
|
}
|
}
|
},
|
transferTimes: {
|
validators: {
|
notEmpty: {
|
message: '过户次数不能为空'
|
}
|
}
|
},
|
displacement: {
|
validators: {
|
notEmpty: {
|
message: '排量不能为空'
|
}
|
}
|
},
|
transmissionCase: {
|
validators: {
|
notEmpty: {
|
message: '变速箱不能为空'
|
}
|
}
|
},
|
level: {
|
validators: {
|
notEmpty: {
|
message: '级别不能为空'
|
}
|
}
|
},
|
transferPrice: {
|
validators: {
|
notEmpty: {
|
message: '车辆售价不能为空'
|
},
|
regexp: {
|
regexp: /^[1-9]\d*(\.\d{1,2})?$|^0+(\.\d{1,2})?$/,
|
message: '请输入有效的数值'
|
}
|
}
|
},
|
newCarPrice: {
|
validators: {
|
// notEmpty: {
|
// message: '车辆新车价不能为空'
|
// }
|
},
|
regexp: {
|
regexp: /^[1-9]\d*(\.\d{1,2})?$|^0+(\.\d{1,2})?$/,
|
message: '请输入有效的数值'
|
}
|
},
|
dueTimeOfCompulsoryInsurance: {
|
validators: {
|
notEmpty: {
|
message: '交强险到期时间不能为空'
|
}
|
}
|
},
|
expirationTimeOfAnnualInspection: {
|
validators: {
|
notEmpty: {
|
message: '年检到期时间不能为空'
|
}
|
}
|
},
|
maturityTimeOfCommercialInsurance: {
|
validators: {
|
notEmpty: {
|
message: '商业险到期时间不能为空'
|
}
|
}
|
},
|
contactsPhone: {
|
validators: {
|
notEmpty: {
|
message: '联系人手机号不能为空'
|
}
|
}
|
},
|
contactsName: {
|
validators: {
|
notEmpty: {
|
message: '联系人名称不能为空'
|
}
|
}
|
},
|
addres: {
|
validators: {
|
notEmpty: {
|
message: '详细地址不能为空'
|
}
|
}
|
}
|
}
|
};
|
|
/**
|
* 验证数据是否为空
|
*/
|
SellingCarInfo.validate = function () {
|
$('#carInfoForm').data("bootstrapValidator").resetForm();
|
$('#carInfoForm').bootstrapValidator('validate');
|
return $("#carInfoForm").data('bootstrapValidator').isValid();
|
};
|
|
/**
|
* 清除数据
|
*/
|
SellingCarInfo.clearData = function() {
|
this.tCarInfoData = {};
|
}
|
|
/**
|
* 设置对话框中的数据
|
*
|
* @param key 数据的名称
|
* @param val 数据的具体值
|
*/
|
SellingCarInfo.set = function(key, val) {
|
var v = $("#" + key).val();
|
if('' != v){
|
this.tCarInfoData[key] = (typeof val == "undefined") ? v : val;
|
}
|
return this;
|
}
|
|
/**
|
* 设置对话框中的数据
|
*
|
* @param key 数据的名称
|
* @param val 数据的具体值
|
*/
|
SellingCarInfo.get = function(key) {
|
return $("#" + key).val();
|
}
|
|
/**
|
* 关闭此对话框
|
*/
|
SellingCarInfo.close = function() {
|
parent.layer.close(window.parent.SellingCar.layerIndex);
|
}
|
|
/**
|
* 收集数据
|
*/
|
SellingCarInfo.collectData = function() {
|
this
|
.set('id')
|
.set('title')
|
.set('carIdentificationCode')
|
.set('carLicensePlate')
|
.set('brandId')
|
.set('carColor')
|
.set('licensingTime')
|
.set('mileage')
|
.set('locationOfLicensePlate')
|
.set('transferTimes')
|
.set('displacement')
|
.set('transmissionCase')
|
.set('level')
|
.set('transferPrice')
|
.set('newCarPrice')
|
.set('describe')
|
.set('dueTimeOfCompulsoryInsurance')
|
.set('expirationTimeOfAnnualInspection')
|
.set('maturityTimeOfCommercialInsurance')
|
.set('contactsPhone')
|
.set('contactsName')
|
.set('provinceCode')
|
.set('cityCode')
|
.set('addres');
|
}
|
|
/**
|
* 提交添加
|
*/
|
SellingCarInfo.addSubmit = function(status) {
|
this.clearData();
|
this.collectData();
|
if(!this.validate()){
|
return ;
|
}
|
let category = $('#category label[class="category"]').attr('tag');
|
this.tCarInfoData.category = category;
|
if(category == 2){
|
let remainingOperationTime = $('#remainingOperationTime').val();
|
if(null == remainingOperationTime || '' == remainingOperationTime){
|
Feng.error("剩余营运时间不能为空");
|
return
|
}
|
let operationUpdateTime = $('#operationUpdateTime').val();
|
if(null == operationUpdateTime || '' == operationUpdateTime){
|
Feng.error("营运车辆更新时间不能为空");
|
return
|
}
|
this.tCarInfoData.remainingOperationTime = remainingOperationTime;
|
this.tCarInfoData.operationUpdateTime = operationUpdateTime;
|
}
|
|
let includingTransferFee = $('#includingTransferFee label[class="labelCheacked"]').attr('tag');
|
let mortgage = $('#mortgage label[class="labelCheacked"]').attr('tag');
|
this.tCarInfoData.includingTransferFee = includingTransferFee;
|
this.tCarInfoData.mortgage = mortgage;
|
|
let imgUrls = $('#imgUrl img[class="imgUrl"]');
|
if(imgUrls.length == 0){
|
Feng.error("请上传车辆图片");
|
return
|
}
|
let videoUrl = $('#videoUrl video[class="videoUrl"]');
|
if(videoUrl.length == 0){
|
Feng.error("请上传车辆视频");
|
return
|
}
|
let describeImgUrl = $('#describeImgUrl img[class="describeImgUrl"]');
|
let imgs = [];
|
imgUrls.each(function (i, e) {
|
imgs.push($(e).attr('src'));
|
})
|
let videos = [];
|
videoUrl.each(function (i, e) {
|
videos.push($(e).attr('src'));
|
})
|
let describeImgUrls = [];
|
describeImgUrl.each(function (i, e) {
|
describeImgUrls.push($(e).attr('src'));
|
})
|
let installationConfiguration = [];
|
$('#installationConfiguration input[type="checkbox"]').each(function (i, e) {
|
if($(e).is(':checked')){
|
installationConfiguration.push($(e).val());
|
}
|
})
|
|
//提交信息
|
var ajax = new $ax(Feng.ctxPath + "/sellingCar/addSellingCar", function(res){
|
if(res.code == 200){
|
Feng.success("添加成功!");
|
window.parent.SellingCar.table.refresh();
|
SellingCarInfo.close();
|
}else{
|
Feng.error(res.msg);
|
}
|
},function(data){
|
Feng.error("添加失败!" + data.responseJSON.message + "!");
|
});
|
ajax.set(this.tCarInfoData);
|
ajax.set('imgUrl', imgs.toString());
|
ajax.set('videoUrl', videos.toString());
|
ajax.set('describeImgUrl', describeImgUrls.toString());
|
ajax.set('installationConfiguration', installationConfiguration.toString());
|
ajax.set('status', status);
|
ajax.start();
|
}
|
|
/**
|
* 提交修改
|
*/
|
SellingCarInfo.editSubmit = function(status) {
|
this.clearData();
|
this.collectData();
|
if(!this.validate()){
|
return ;
|
}
|
let category = $('#category label[class="category"]').attr('tag');
|
this.tCarInfoData.category = category;
|
if(category == 2){
|
let remainingOperationTime = $('#remainingOperationTime').val();
|
if(null == remainingOperationTime || '' == remainingOperationTime){
|
Feng.error("剩余营运时间不能为空");
|
return
|
}
|
let operationUpdateTime = $('#operationUpdateTime').val();
|
if(null == operationUpdateTime || '' == operationUpdateTime){
|
Feng.error("营运车辆更新时间不能为空");
|
return
|
}
|
this.tCarInfoData.remainingOperationTime = remainingOperationTime;
|
this.tCarInfoData.operationUpdateTime = operationUpdateTime;
|
}
|
let transferPrice = $('#transferPrice').val();
|
if(null == transferPrice || '' == transferPrice){
|
Feng.info("车辆售价不能为空");
|
return
|
}
|
this.tCarInfoData.transferPrice = transferPrice;
|
let newCarPrice = $('#newCarPrice').val();
|
if(null == newCarPrice || '' == newCarPrice){
|
Feng.info("车辆新车价不能为空");
|
return
|
}
|
this.tCarInfoData.newCarPrice = newCarPrice;
|
let includingTransferFee = $('#includingTransferFee label[class="labelCheacked"]').attr('tag');
|
let mortgage = $('#mortgage label[class="labelCheacked"]').attr('tag');
|
this.tCarInfoData.includingTransferFee = includingTransferFee;
|
this.tCarInfoData.mortgage = mortgage;
|
|
let imgUrls = $('#imgUrl img[class="imgUrl"]');
|
if(imgUrls.length == 0){
|
Feng.error("请上传车辆图片");
|
return
|
}
|
let videoUrl = $('#videoUrl video[class="videoUrl"]');
|
if(videoUrl.length == 0){
|
Feng.error("请上传车辆视频");
|
return
|
}
|
let describeImgUrl = $('#describeImgUrl img[class="describeImgUrl"]');
|
let imgs = [];
|
imgUrls.each(function (i, e) {
|
imgs.push($(e).attr('src'));
|
})
|
let videos = [];
|
videoUrl.each(function (i, e) {
|
videos.push($(e).attr('src'));
|
})
|
let describeImgUrls = [];
|
describeImgUrl.each(function (i, e) {
|
describeImgUrls.push($(e).attr('src'));
|
})
|
let installationConfiguration = [];
|
$('#installationConfiguration input[type="checkbox"]').each(function (i, e) {
|
if($(e).is(':checked')){
|
installationConfiguration.push($(e).val());
|
}
|
})
|
|
//提交信息
|
var ajax = new $ax(Feng.ctxPath + "/sellingCar/updateSellingCar", function(res){
|
if(res.code == 200){
|
Feng.success("修改成功!");
|
window.parent.SellingCar.table.refresh();
|
SellingCarInfo.close();
|
}else{
|
Feng.error(res.msg);
|
}
|
},function(data){
|
Feng.error("修改失败!" + data.responseJSON.message + "!");
|
});
|
ajax.set(this.tCarInfoData);
|
ajax.set('imgUrl', imgs.toString());
|
ajax.set('videoUrl', videos.toString());
|
ajax.set('describeImgUrl', describeImgUrls.toString());
|
ajax.set('installationConfiguration', installationConfiguration.toString());
|
ajax.set('status', status);
|
ajax.start();
|
}
|
|
let fileId = "";
|
function uploadImg(idName){
|
if(idName == 'imgUrl'){
|
let files = $('#' + idName).find('img');
|
if(files.length >= 15){
|
Feng.info("只能上传15张图片");
|
return
|
}
|
}else{
|
let files = $('#' + idName).find('video');
|
if(files.length >= 1){
|
Feng.info("只能上传1个视频");
|
return
|
}
|
}
|
fileId = idName;
|
$('#file').click();
|
}
|
|
|
function checkedLable(e){
|
$(e).attr('class', 'labelCheacked');
|
$(e).siblings().removeAttr('class');
|
}
|
|
|
function checkedCategory(e, t){
|
$(e).attr('class', 'category');
|
$(e).siblings().removeAttr('class');
|
if(t == 1){
|
$('.operation').hide();
|
}else{
|
$('.operation').show();
|
}
|
}
|
|
|
|
function delImg(ev, fileId, t){
|
$(ev).parent().remove();
|
if(t == 1){//图片
|
let files = $('#' + fileId).find('img');
|
$($('#' + fileId).parent('div')).siblings('label').text('*车辆图片(' + files.length + '/15):');
|
}
|
if(2 == t){//视频
|
let files = $('#' + fileId).find('video');
|
$($('#' + fileId).parent('div')).siblings('label').text('*车辆视频(' + files.length + '/1):');
|
}
|
}
|
|
|
function initImgSize(){
|
if('' != $('#id').val()){
|
let files = $('#imgUrl').find('img');
|
$($('#imgUrl').parent('div')).siblings('label').text('*车辆图片(' + files.length + '/15):');
|
|
files = $('#videoUrl').find('video');
|
$($('#videoUrl').parent('div')).siblings('label').text('*车辆视频(' + files.length + '/1):');
|
}
|
}
|
|
|
$(function() {
|
Feng.initValidator("carInfoForm", SellingCarInfo.validateFields);
|
|
initImgSize();
|
|
$('#provinceCode').on('change', function () {
|
let provinceCode = $('#provinceCode').val();
|
var ajax = new $ax(Feng.ctxPath + "/recruit/getRegion", function(res){
|
if(res.code == 200){
|
let data = res.data;
|
let str='';
|
for(let i in data){
|
str += '<option value="' + data[i].code + '">' + data[i].name + '</option>';
|
}
|
$("#cityCode").html(str);
|
}else{
|
Feng.error(res.msg);
|
}
|
});
|
ajax.set("code", provinceCode);
|
ajax.start();
|
})
|
|
$('#file').on('change', function () {
|
console.log(111222)
|
let formData = new FormData() //创建一个forData
|
formData.append('file', $('#file')[0].files[0]) //把file添加进去 name命名为img
|
layer.load(); //上传loading
|
$.ajax({
|
url: Feng.ctxPath + '/upload/image1',
|
data: formData,
|
type: "POST",
|
async: true,
|
cache: false,
|
contentType: false,
|
processData: false,
|
success: function(res) {
|
layer.closeAll('loading'); //关闭loading
|
$('#file').val('');
|
if(fileId == 'imgUrl'){
|
$('#' + fileId).append('<div><img src="' + res + '" width="100px" class="imgUrl"><i class="fa fa-close" onclick="delImg(this, \'imgUrl\', 1)" style="color: red;color: red;font-size: 18px;position: absolute;left: 108px;top: -8px;"></i></div> ');
|
let files = $('#' + fileId).find('img');
|
$($('#' + fileId).parent('div')).siblings('label').text('*车辆图片(' + files.length + '/15):');
|
}
|
if(fileId == 'videoUrl'){
|
$('#' + fileId).append('<div><video src="' + res + '" controls style="width: 200px !important;" class="videoUrl"></video><i class="fa fa-close" onclick="delImg(this, \'videoUrl\', 2)" style="color: red;color: red;font-size: 18px;position: absolute;left: 108px;top: -8px;"></i></div> ');
|
let files = $('#' + fileId).find('video');
|
$($('#' + fileId).parent('div')).siblings('label').text('*车辆视频(' + files.length + '/1):');
|
}
|
if(fileId == 'describeImgUrl'){
|
$('#' + fileId).append('<div><img src="' + res + '" width="100px" class="describeImgUrl"/><i class="fa fa-close" onclick="delImg(this, \'describeImgUrl\')" style="color: red;color: red;font-size: 18px;position: absolute;left: 108px;top: -8px;"></i></div> ');
|
}
|
}
|
})
|
})
|
});
|