无关风月
2025-03-20 2ad97245d64b65132507cab36ad89d968edb7705
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
/**
 * 角色管理的单例
 */
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);
                }
 
            }
        })
    })
});