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.
simple-yewu/frontend/web/js/common.js

242 lines
6.2 KiB

5 years ago
//删除
function del(id) {
if (confirm('是否确认删除?')) {
$.post('/business-order/delete', {id: id}, function (obj) {
alert(obj.msg);
if (obj.success) {
window.location.reload();
}
}, 'json');
}
}
//下载图片
function downloadImg() {
var isChoice = false,
id = 0;
$('#img-area > li ').each(function (i) {
if ($(this).hasClass('active-border')) {
isChoice = true;
id = $(this).find('i').data('fix-img')
}
})
if (!isChoice) {
alert('请先选择要下载的图片!');
return false;
}
if (id == 0) {
alert('下载失败!');
return false;
}
window.location.href = "/fix-car/download-img?id=" + id;
}
function maskInit() {
$('.mask-layer').height($(window).width());
$('.mask-layer').height($(document).width());
}
function show(id_str) {
var obj = $('#' + id_str);
var obj_title = $('#' + id_str + '_title');
obj.toggle();
if (obj_title.html() == '▼')
obj_title.html('▲');
else
obj_title.html('▼');
}
function maskOpen() {
parent.maskOpen();
$('.mask-layer').show();
$(document.body).css({
"overflow-x": "hidden",
"overflow-y": "hidden"
});
}
function maskClose() {
parent.maskClose();
$('.mask-layer').hide();
$('#img-box').hide();
$('#dialog').hide();
$(document.body).css({
"overflow-x": "auto",
"overflow-y": "auto"
});
}
function fixCarSave(status) {
//保存按钮
$(".js-update-btn").click(function () {
if (confirm('是否确认提交?')) {
var params = $("#theFrm").serialize();
params += '&status=' + status;
$.post('/business-order/fix-car-save', params, function (obj) {
alert(obj.msg);
if (obj.success) {
$('#id').val(obj.fix_id);
window.location.reload();
}
}, 'json');
}
});
}
function fixCarAdd(msg, status) {
$(".js-insert-btn").click(function () {
var id = $('#id').val();
var sys_remark = $('#sys_remark').val();
if (sys_remark == '') {
alert('请先输入' + msg);
return;
}
if (id > 0) {
if (confirm('是否确认提交?')) {
var params = $("#theFrm").serialize();
params = params + '&status=' + status;
$.post('/business-order/fix-car-save', params, function (obj) {
alert(obj.msg);
if (obj.success) {
$('#id').val(obj.fix_id);
$('#back-btn').click();
}
}, 'json');
}
} else {
alert('请先保存维修信息');
}
});
}
//图片点击加边框
$('#img-box > ul > li').on('mouseover', function () {
$(this).addClass('active-bg');
$(this).siblings().removeClass('active-bg');
});
//品牌
$('#brand_id').change(function () {
var brand_id = $(this).val();
$('#series_id').html('<option value="0">---请选择---</option>');
$('#displacement_id').html('<option value="0">---请选择---</option>');
if (brand_id > 0) {
$.get('/car/series', {brand_id: brand_id}, function (obj) {
if (obj.success) {
$('#series_id').html(obj.html);
}
}, 'json');
}
});
//车系
$('#series_id').change(function () {
var series_id = $(this).val();
$('#displacement_id').html('<option value="0">---请选择---</option>');
if (series_id > 0) {
$.get('/car/displacement', {series_id: series_id}, function (obj) {
if (obj.success) {
$('#displacement_id').html(obj.html);
}
}, 'json');
}
});
//排量
$('#displacement_id').change(function(){
var displacement_id = $(this).val();
if(displacement_id < 1) return false;
$.get('/car/year-price',{displacement_id:displacement_id},function(data){
if(data.success){
$('#year_id').html(data.html);
}
},'json');
});
//年份
$('#year_id').change(function(){
var yearID = $(this).val();
if(yearID < 1) return false;
$.get('/car/new-car-price',{year_id:yearID},function(data){
if(data.success){
$('#new_price').val(data.content);
}
},'json');
});
function refreshItemList(id,gid,report){
$.post('/business-order/refresh-item-list',{id:id,gid:gid,report:report},function(data){
if(data.success){
$('#divBox').html(data.content);
}
});
}
function openListDialog(){
layer.tab({
id:'my-ll',
area: ['600px', '300px'],
shade:0,
closeBtn:2,
offset:['100px','20%'],
tab: [{
title: '配件',
content: $('#parts').html()
}, {
title: '材料',
content: $('#material').html()
}, {
title: '辅料',
content: $('#trims').html()
}],
cancel:function(){
maskClose();
},
success:function(){
maskOpen();
}
});
}
function openImageUpload(type,id){
maskOpen();
layer.open({
id:'my-22',
type: 2,
shade:0,
title:'图片管理',
closeBtn:2,
skin: 'layui-layer-rim', //加上边框
area: ['1000px', '300px'], //宽高
offset:['100px','10%'],
content: '/image/image-upload?type=' + type + '&id=' + id,
cancel:function(){
maskClose();
},
success:function(){
}
});
}
function layerClose(){
layer.closeAll();
maskClose();
}
//图片弹窗
function openImgDialog(id,type) {
maskOpen();
layer.open({
id:'my-23',
type: 2,
shade:0,
title:'图片管理',
closeBtn:2,
skin: 'layui-layer-rim', //加上边框
area: ['1000px', '500px'], //宽高
offset:['20px','10%'],
fixed:false,
content: '/image/look-image?type=' + type + '&id=' + id,
cancel:function(){
maskClose();
},
success:function(){
}
});
}