/**
|
* 角色管理的单例
|
*/
|
var GasStationOilPrice = {
|
id: "GasStationOilPriceTable", //表格id
|
seItem: null, //选中的条目
|
table: null,
|
layerIndex: -1
|
};
|
|
/**
|
* 初始化表格的列
|
*/
|
GasStationOilPrice.initColumn = function () {
|
var columns = [
|
{field: 'select_item', radio: true},
|
{title: 'id', field: 'id', visible: false, align: 'center', valign: 'middle'},
|
{title: '序号', field: '', visible: true, align: 'center', valign: 'middle', width: '50px',
|
formatter: function (value, row, index) {
|
return index + 1;
|
}
|
},
|
{title: '油站编码', field: 'code', align: 'center', valign: 'middle', width: '100px'},
|
{title: '油站名称', field: 'name', align: 'center', valign: 'middle'},
|
{title: '-10#柴油<br>(直降)', field: 'dieselOil10Price', align: 'center', valign: 'middle', width: '80px'},
|
{title: '0#柴油<br>(直降)', field: 'dieselOil0Price', align: 'center', valign: 'middle', width: '80px'},
|
{title: '92#汽油<br>(直降)', field: 'gasoline92Price', align: 'center', valign: 'middle', width: '80px'},
|
{title: '95#汽油<br>(直降)', field: 'gasoline95Price', align: 'center', valign: 'middle', width: '80px'},
|
{title: '98#汽油<br>(直降)', field: 'gasoline98Price', align: 'center', valign: 'middle', width: '80px'},
|
{title: '周期', field: 'effectivePeriod', align: 'center', valign: 'middle',
|
formatter: function (value) {
|
let str = '';
|
if(typeof value != "undefined"){
|
var arr = value.split(";");
|
for(var i in arr){
|
switch (arr[i]) {
|
case '1':
|
str += '周一;';
|
break
|
case '2':
|
str += '周二;';
|
break
|
case '3':
|
str += '周三;';
|
break
|
case '4':
|
str += '周四;';
|
break
|
case '5':
|
str += '周五;';
|
break
|
case '6':
|
str += '周六;';
|
break
|
case '7':
|
str += '周日;';
|
break
|
}
|
}
|
}
|
if(str.length > 0){
|
str = str.substring(0, str.length - 1);
|
}
|
return str;
|
}
|
},
|
{title: '标签1文案', field: 'labelOne', align: 'center', valign: 'middle'},
|
{title: '标签2文案', field: 'labelTwo', align: 'center', valign: 'middle'},
|
{title: '加油站图标', field: 'stationIcon', align: 'center', valign: 'middle', width: '150px',
|
formatter: function (value) {
|
if(value == null || value == "" || value == undefined){
|
|
}else {
|
return '<img src="' + value + '" width="100%" onclick="showImg(this)"/>'
|
}
|
}
|
},
|
]
|
return columns;
|
};
|
|
|
/**
|
* 检查是否选中
|
*/
|
GasStationOilPrice.check = function () {
|
var selected = $('#' + this.id).bootstrapTable('getSelections');
|
if (selected.length == 0) {
|
Feng.info("请先选中表格中的某一记录!");
|
return false;
|
} else {
|
GasStationOilPrice.seItem = selected[0];
|
return true;
|
}
|
};
|
|
/**
|
* 点击修改
|
*/
|
GasStationOilPrice.openChangeGasStationOilPrice = function () {
|
if (this.check()) {
|
var index = layer.open({
|
type: 2,
|
title: '加油站促销数据编辑',
|
area: ['80%', '90%'], //宽高
|
fix: false, //不固定
|
maxmin: true,
|
content: Feng.ctxPath + '/salesPromotion/openChangeGasStationOilPrice?id=' + this.seItem.id
|
});
|
this.layerIndex = index;
|
}
|
};
|
|
/**
|
* 删除
|
*/
|
GasStationOilPrice.delGasStationOilPrice = function () {
|
if (this.check()) {
|
var operation = function () {
|
var ajax = new $ax(Feng.ctxPath + "/salesPromotion/delGasStationOilPrice", function (data) {
|
if(data.code == 200 ){
|
Feng.success("删除成功!");
|
GasStationOilPrice.table.refresh();
|
}else{
|
Feng.error(data.msg);
|
}
|
}, function (data) {
|
Feng.error("删除失败!" + data.responseJSON.message + "!");
|
});
|
ajax.set("id", GasStationOilPrice.seItem.id);
|
ajax.start();
|
};
|
|
Feng.confirm("是否刪除该加油站?", operation);
|
}
|
};
|
|
/**
|
* 图标设置
|
*/
|
GasStationOilPrice.iconSet = function (){
|
let salesPromotionId = $('#id').val();
|
var index = layer.open({
|
type: 2,
|
title: '加油站图标设置',
|
area: ['90%', '90%'], //宽高
|
fix: false, //不固定
|
maxmin: true,
|
content: Feng.ctxPath + '/salesPromotion/gasStationOilPrice_iconSet?salesPromotionId='+salesPromotionId
|
});
|
this.layerIndex = index;
|
}
|
//选择油价是否显示,并保存数据
|
GasStationOilPrice.hoiceType = function (e){
|
var formData = new FormData() //创建一个forData
|
let salesPromotionId = $('#id').val();
|
let priceShow = $(e).val();
|
formData.append('salesPromotionId',salesPromotionId)
|
formData.append('priceShow', priceShow)
|
$.ajax({
|
url: Feng.ctxPath + '/salesPromotion/updatePriceShow',
|
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("油价是否显示设置成功");
|
} else {
|
Feng.error(res.msg);
|
}
|
}
|
});
|
}
|
|
$(function () {
|
var defaultColunms = GasStationOilPrice.initColumn();
|
var table = new BSTable(GasStationOilPrice.id, "/salesPromotion/queryGasStationOilPriceList", defaultColunms);
|
table.setPaginationType("server");
|
table.setQueryParams({
|
id: $('#id').val()
|
})
|
GasStationOilPrice.table = table.init();
|
|
});
|