44323
2024-02-22 aa8ff2d61669d0779fdacdba76e26388587b435d
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
/**
 * 角色管理的单例
 */
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();
 
});