/**
|
* 初始化加油站活动详情对话框
|
*/
|
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() {
|
|
const startTime = $('#startTime').val();
|
if(null == startTime || '' == startTime){
|
Feng.error("开始生效时间不能为空");
|
return
|
}
|
var formData = new FormData() //创建一个forData
|
formData.append('file', $('#file')[0].files[0]) //把file添加进去 name命名为img
|
formData.append("startTime", startTime);
|
layer.load(); //上传loading
|
$.ajax({
|
url: Feng.ctxPath + "/gasStationActivity/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("添加成功!");
|
window.parent.GasStationActivity.table.refresh();
|
GasStationActivityInfoDlg.close();
|
}else{
|
Feng.error(res.msg);
|
}
|
}
|
})
|
}
|
|
/**
|
* 提交修改
|
*/
|
GasStationActivityInfoDlg.editSubmit = function() {
|
|
const id = $('#id').val();
|
const startTime = $('#startTime').val();
|
if(null == startTime || '' == startTime){
|
Feng.error("开始生效时间不能为空");
|
return
|
}
|
var formData = new FormData() //创建一个forData
|
formData.append('file', $('#file')[0].files[0]) //把file添加进去 name命名为img
|
formData.append("startTime", startTime);
|
formData.append("id", id);
|
layer.load(); //上传loading
|
$.ajax({
|
url: Feng.ctxPath + "/gasStationActivity/update",
|
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("添加成功!");
|
window.parent.GasStationActivity.table.refresh();
|
GasStationActivityInfoDlg.close();
|
}else{
|
Feng.error(res.msg);
|
}
|
}
|
})
|
}
|
|
$(function() {
|
$('#chooseFile').on('click', function () {
|
$('#file').val('');
|
$('#file').click();
|
$('#file').on('change', function () {
|
const file = $('#file')[0].files[0]
|
$('#excelName').text(file.name);
|
})
|
})
|
});
|