/**
|
* 初始化加油站活动详情对话框
|
*/
|
var GasStationActivityInfoDlg = {
|
gasStationActivityInfoData : {}
|
};
|
|
/**
|
* 清除数据
|
*/
|
GasStationActivityInfoDlg.clearData = function() {
|
this.gasStationActivityInfoData = {};
|
}
|
|
/**
|
* 设置对话框中的数据
|
*
|
* @param key 数据的名称
|
* @param val 数据的具体值
|
*/
|
GasStationActivityInfoDlg.set = function(key, val) {
|
this.gasStationActivityInfoData[key] = (typeof val == "undefined") ? $("#" + key).val() : val;
|
return this;
|
}
|
|
/**
|
* 设置对话框中的数据
|
*
|
* @param key 数据的名称
|
* @param val 数据的具体值
|
*/
|
GasStationActivityInfoDlg.get = function(key) {
|
return $("#" + key).val();
|
}
|
|
/**
|
* 关闭此对话框
|
*/
|
GasStationActivityInfoDlg.close = function() {
|
parent.layer.close(window.parent.GasStationActivity.layerIndex);
|
}
|
|
/**
|
* 收集数据
|
*/
|
GasStationActivityInfoDlg.collectData = function() {
|
this
|
.set('id')
|
.set('code')
|
.set('name')
|
.set('state')
|
.set('createUserId')
|
.set('createTime')
|
.set('updateUserId')
|
.set('updateTime')
|
.set('startTime')
|
.set('endTime')
|
.set('priceShow');
|
}
|
|
/**
|
* 提交添加
|
*/
|
GasStationActivityInfoDlg.addSubmit = function(x) {
|
|
const activityId = $("#activityId").val();
|
const icon = $("#icon"+x+"").val();
|
const iconOld = $("#iconOld"+x+"").val();
|
if(null == icon || '' == icon){
|
Feng.error("icon图标不能为空");
|
return
|
}
|
var formData = new FormData() //创建一个forData
|
formData.append('file', $("#file"+x+"")[0].files[0]) //把file添加进去 name命名为img
|
formData.append("gasStationActivityId", activityId);
|
formData.append("icon", icon);
|
formData.append("iconOld", iconOld);
|
layer.load(); //上传loading
|
$.ajax({
|
url: Feng.ctxPath + "/gasStationIcon/add",
|
data: formData,
|
type: "POST",
|
async: true,
|
cache: false,
|
contentType: false,
|
processData: false,
|
success: function(res) {
|
layer.closeAll('loading'); //关闭loading
|
if(res.code == 200){
|
Feng.success("操作成功!");
|
location.reload();
|
window.parent.GasStation.table.refresh();
|
}else if(res.code == 800){
|
layer.alert(res.msg, {
|
icon: 5,
|
title: "提示"
|
});
|
}else{
|
Feng.error(res.msg);
|
}
|
}
|
})
|
}
|
|
//icon板块删除数据
|
GasStationActivityInfoDlg.deleteIcon = function(e,x){
|
var operation = function () {
|
const activityId = $("#activityId").val();
|
const iconOld = $("#iconOld"+x+"").val();
|
console.log(iconOld);
|
var formData = new FormData() //创建一个forData
|
formData.append("gasStationActivityId", activityId);
|
formData.append("icon", iconOld);
|
layer.load(); //上传loading
|
$.ajax({
|
url: Feng.ctxPath + "/gasStationIcon/delete",
|
data: formData,
|
type: "POST",
|
async: true,
|
cache: false,
|
contentType: false,
|
processData: false,
|
success: function (res) {
|
layer.closeAll('loading'); //关闭loading
|
if (res.code == 200) {
|
Feng.success("删除成功!");
|
$(e).parent().parent().parent().parent().remove();
|
location.reload();
|
window.parent.GasStation.table.refresh();
|
} else {
|
Feng.error(res.msg);
|
}
|
}
|
})
|
};
|
Feng.confirm("是否刪除该加油站图标数据?", operation);
|
|
}
|
//icon板块减少
|
GasStationActivityInfoDlg.subtractIcon = function(e){
|
$(e).parent().parent().parent().parent().remove();
|
}
|
|
//icon板块新增
|
GasStationActivityInfoDlg.addIcon = function(){
|
var x = 1;
|
$('.moduleDiv').each(function (e, i) {
|
x=x+1;
|
})
|
var moduleDiv='<div class="moduleDiv"><hr><div class="row">\n' +
|
' <div class="form-group">\n' +
|
' <label class="col-sm-3 control-label head-scu-label">加油站icon</label>\n' +
|
' <div class="col-sm-4">\n' +
|
' <div id="icon' + x + 'PreId">\n' +
|
' <div><img width="100px" height="100px" src="'+Feng.ctxPath+'/static/img/NoPIC.png"></div>\n' +
|
' </div>\n' +
|
' </div>\n' +
|
' <div class="col-sm-2">\n' +
|
' <div class="head-scu-btn upload-btn" id="icon' + x + 'BtnId">\n' +
|
' <i class="fa fa-upload"></i> 上传\n' +
|
' </div>\n' +
|
' </div>\n' +
|
' <input type="hidden" id="icon' + x + '" value=""/>\n' +
|
' <div class="col-sm-1" >\n' +
|
' <i class="fa fa-plus-square" style="font-size:24px" onclick="GasStationActivityInfoDlg.addIcon()"></i>\n' +
|
' <i class="fa fa-minus-square" style="font-size:24px" onclick="GasStationActivityInfoDlg.subtractIcon(this)"></i>\n' +
|
' </div>\n' +
|
' </div>\n' +
|
' <div class="form-group">\n' +
|
' <label class="col-sm-3 control-label head-scu-label"></label>\n' +
|
' <div class="col-sm-8">\n' +
|
' <div style="color: red;" id="size">推荐尺寸:64px * 90px(宽*高)<br/>推荐大小:不超过300K</div>\n' +
|
' </div>\n' +
|
' </div>\n' +
|
' <div class="form-group">\n' +
|
' <label class="col-sm-3 control-label"></label>\n' +
|
' <div class="col-sm-8">\n' +
|
' <input type="file" id="file'+x+'" accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel" style="display: none;">\n' +
|
' <button style="width: 150px;height: 40px;line-height: 30px;background-color: #0E6828;color: #ffffff;" id="chooseFile'+x+'">导入活动加油站</button>\n' +
|
' </div>\n' +
|
' </div>\n' +
|
' <div class="form-group">\n' +
|
' <label class="col-sm-3 control-label">excel</label>\n' +
|
' <div class="col-sm-8">\n' +
|
' <span id="excelName'+x+'"></span>\n' +
|
' </div>\n' +
|
' </div>\n' +
|
' </div>\n' +
|
' <div class="row btn-group-m-t">\n' +
|
' <div class="col-sm-10">\n' +
|
' <button type="button" class="btn btn-info " onclick="GasStationActivityInfoDlg.addSubmit('+x+')" id="ensure">\n' +
|
' <i class="fa fa-check"></i> 保存\n' +
|
' </button>\n' +
|
' </div>\n' +
|
' </div>'+
|
' </div>';
|
$(".moduleDiv").last().after(moduleDiv);
|
// 初始化icon上传
|
var iconUp = new $WebUpload("icon"+x);
|
iconUp.setUploadBarId("progressBar");
|
iconUp.init();
|
|
$("#chooseFile"+x+"").on('click', function () {
|
$("#file"+x+"").click();
|
$("#file"+x+"").on('change', function () {
|
const file = $("#file"+x+"")[0].files[0]
|
$("#excelName"+x+"").text(file.name);
|
})
|
})
|
}
|
|
$(function() {
|
// 初始化icon上传
|
var iconUp = new $WebUpload("icon0");
|
iconUp.setUploadBarId("progressBar");
|
iconUp.init();
|
|
$('#chooseFile0').on('click', function () {
|
$('#file0').click();
|
$('#file0').on('change', function () {
|
const file = $('#file0')[0].files[0]
|
$('#excelName0').text(file.name);
|
})
|
})
|
var iconSize = $("#iconSize").val();
|
for(var i = 1 ; i < iconSize+1 ; i++){
|
// 初始化icon上传
|
var iconUp = new $WebUpload("icon"+i);
|
iconUp.setUploadBarId("progressBar");
|
iconUp.init();
|
|
$("#chooseFile"+i).on('click', function () {
|
$(this).prev().click();
|
$(this).prev().on('change', function (e) {
|
const file = $(this)[0].files[0]
|
$(this).parent().parent().next().find("span").text(file.name);
|
})
|
})
|
}
|
});
|