/**
|
* 角色管理的单例
|
*/
|
var GasStation = {
|
id: "GasStationTable", //表格id
|
seItem: null, //选中的条目
|
table: null,
|
layerIndex: -1
|
};
|
|
/**
|
* 初始化表格的列
|
*/
|
GasStation.initColumn = function () {
|
var columns = [
|
{field: 'select_item', radio: true},
|
{title: 'id', field: 'id', visible: false, align: 'center', valign: 'middle'},
|
{title: '序号', field: '', align: 'center', valign: 'middle', width: '100px',
|
formatter: function (value, row, index) {
|
return index + 1;
|
}
|
},
|
{title: '油站编码', field: 'code', align: 'center', valign: 'middle', width: '100px'},
|
{title: '油站名称', field: 'name', align: 'center', valign: 'middle', width: '100px'},
|
{title: '所属大区', field: 'largeAreaOne', align: 'center', valign: 'middle', width: '100px'},
|
{title: '所属区域', field: 'largeAreaTwo', align: 'center', valign: 'middle', width: '100px'},
|
{title: '是否售卖-10#柴油', field: 'dieselOil10', align: 'center', valign: 'middle', width: '150px',
|
formatter: function (value, row) {
|
return value == 1 ? '是' : '否';
|
}
|
},
|
{title: '是否售卖0#柴油', field: 'dieselOil0', align: 'center', valign: 'middle', width: '150px',
|
formatter: function (value, row) {
|
return value == 1 ? '是' : '否';
|
}
|
},
|
{title: '是否售卖92#汽油', field: 'gasoline92', align: 'center', valign: 'middle', width: '150px',
|
formatter: function (value, row) {
|
return value == 1 ? '是' : '否';
|
}
|
},
|
{title: '是否售卖95#汽油', field: 'gasoline95', align: 'center', valign: 'middle', width: '150px',
|
formatter: function (value, row) {
|
return value == 1 ? '是' : '否';
|
}
|
},
|
{title: '是否售卖98#汽油', field: 'gasoline98', align: 'center', valign: 'middle', width: '150px',
|
formatter: function (value, row) {
|
return value == 1 ? '是' : '否';
|
}
|
},
|
{title: '经度', field: 'lonLat', align: 'center', valign: 'middle', width: '100px',
|
formatter: function (value) {
|
if(typeof value != "undefined" && '' != value){
|
return value.split(',')[0];
|
}
|
}
|
},
|
{title: '纬度', field: 'lonLat', align: 'center', valign: 'middle', width: '100px',
|
formatter: function (value) {
|
if(typeof value != "undefined" && '' != value){
|
return value.split(',')[1];
|
}
|
}
|
},
|
{title: '地址', field: 'address', align: 'center', valign: 'middle', width: '150px',
|
formatter: function (value) {
|
return '<span title="' + value + '">' + value + '</span>'
|
}
|
}
|
]
|
return columns;
|
};
|
|
|
/**
|
* 检查是否选中
|
*/
|
GasStation.check = function () {
|
var selected = $('#' + this.id).bootstrapTable('getSelections');
|
if (selected.length == 0) {
|
Feng.info("请先选中表格中的某一记录!");
|
return false;
|
} else {
|
GasStation.seItem = selected[0];
|
return true;
|
}
|
};
|
|
/**
|
* 点击导入
|
*/
|
GasStation.uploadGasStation = function () {
|
$('#file').click();
|
};
|
|
|
GasStation.delGasStation = function(){
|
if(this.check()){
|
var operation = function () {
|
var ajax = new $ax(Feng.ctxPath + "/gasStation/delGasStation", function (data) {
|
if(data.code == 200 ){
|
Feng.success("删除成功!");
|
GasStation.table.refresh();
|
}else{
|
Feng.error(data.msg);
|
}
|
}, function (data) {
|
Feng.error("删除失败!" + data.responseJSON.message + "!");
|
});
|
ajax.set("id", GasStation.seItem.id);
|
ajax.start();
|
};
|
Feng.confirm("是否刪除该加油站?", operation);
|
}
|
}
|
|
|
|
/**
|
* 导出
|
*/
|
GasStation.downloadGasStation = function(){
|
const code = $("#code").val();
|
const name = $("#name").val();
|
const largeAreaOneId = $("#largeAreaOne").val();
|
const largeAreaTwoId = $("#largeAreaTwo").val();
|
const dieselOil10 = $("#dieselOil10").val();
|
const dieselOil0 = $("#dieselOil0").val();
|
const gasoline92 = $("#gasoline92").val();
|
const gasoline95 = $("#gasoline95").val();
|
const gasoline98 = $("#gasoline98").val();
|
window.location.href = Feng.ctxPath + "/gasStation/downloadGasStation?code=" + code + "&name=" + name + "&largeAreaOneId=" + largeAreaOneId +
|
"&largeAreaTwoId=" + largeAreaTwoId + "&dieselOil10=" + dieselOil10 + "&dieselOil0=" + dieselOil0 + "&gasoline92=" + gasoline92 +
|
"&gasoline95=" + gasoline95 + "&gasoline98=" + gasoline98;
|
}
|
|
|
GasStation.getLargeArea = function(level, pid){
|
//提交信息
|
var ajax = new $ax(Feng.ctxPath + "/gasStation/queryLargeArea", function (data) {
|
if(data.code == 200){
|
let str = '<option value="">全部</option>';
|
for(var i in data.data){
|
str += '<option value="' + data.data[i].id + '">' + data.data[i].name + '</option>';
|
}
|
if(level == 1){
|
$('#largeAreaOne').html(str);
|
}
|
if(level == 2){
|
$('#largeAreaTwo').html(str);
|
}
|
}else{
|
Feng.error(data.msg);
|
}
|
}, function (data) {
|
Feng.error("获取失败!" + data.responseJSON.message + "!");
|
});
|
ajax.set({
|
pid: pid
|
});
|
ajax.start();
|
}
|
|
|
|
|
/**
|
* 搜索
|
*/
|
GasStation.search = function () {
|
var queryData = {};
|
queryData['code'] = $("#code").val();
|
queryData['name'] = $("#name").val();
|
queryData['largeAreaOneId'] = $("#largeAreaOne").val();
|
queryData['largeAreaTwoId'] = $("#largeAreaTwo").val();
|
queryData['dieselOil10'] = $("#dieselOil10").val();
|
queryData['dieselOil0'] = $("#dieselOil0").val();
|
queryData['gasoline92'] = $("#gasoline92").val();
|
queryData['gasoline95'] = $("#gasoline95").val();
|
queryData['gasoline98'] = $("#gasoline98").val();
|
GasStation.table.setQueryParams({});
|
GasStation.table.refresh({query: queryData});
|
}
|
|
/**
|
* 重置
|
*/
|
GasStation.resetSearch = function(){
|
var queryData = {};
|
$("#code").val('');
|
$("#name").val('');
|
$("#largeAreaOne").val('');
|
$("#largeAreaTwo").val('');
|
$("#dieselOil10").val('');
|
$("#dieselOil0").val('');
|
$("#gasoline92").val('');
|
$("#gasoline95").val('');
|
$("#gasoline98").val('');
|
GasStation.table.setQueryParams({});
|
GasStation.table.refresh({query: queryData});
|
}
|
|
|
$(function () {
|
var defaultColunms = GasStation.initColumn();
|
var table = new BSTable(GasStation.id, "/gasStation/queryGasStationList", defaultColunms);
|
table.setPaginationType("server");
|
GasStation.table = table.init();
|
|
GasStation.getLargeArea(1, 0);
|
|
$('#largeAreaOne').on('change', function () {
|
GasStation.getLargeArea(2, $(this).val());
|
});
|
|
$('#file').on('change', function () {
|
var formData = new FormData() //创建一个forData
|
formData.append('file', $('#file')[0].files[0]) //把file添加进去 name命名为img
|
layer.load(); //上传loading
|
$.ajax({
|
url: Feng.ctxPath + '/gasStation/uploadGasStation',
|
data: formData,
|
type: "POST",
|
async: true,
|
cache: false,
|
contentType: false,
|
processData: false,
|
success: function(res) {
|
layer.closeAll('loading'); //关闭loading
|
$('#file').val('');
|
if(res.code == 200){
|
Feng.success("导入成功");
|
GasStation.search();
|
}else{
|
Feng.error(res.msg);
|
}
|
|
}
|
})
|
})
|
});
|