无关风月
10 小时以前 28a60b0977d66b75fb9a2c3306840bc18ec271f6
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
243
244
245
246
247
248
249
250
251
/**
 * 车辆管理管理初始化
 */
var TCompetition = {
    id: "TCompetitionTable",    //表格id
    seItem: null,        //选中的条目
    table: null,
    layerIndex: -1
};
var language =1
var role =$("#role").val()
/**
 * 初始化表格的列
 */
TCompetition.initColumn = function () {
    return [
        {field: 'selectItem', radio: true},
        {title: '序号', field: 'id', visible: true, align: 'center', valign: 'middle'},
        {title: '订单编号', field: 'code', visible: true, align: 'center', valign: 'middle'},
        {title:  '用户姓名', field: 'appUserName', visible: true, align: 'center', valign: 'middle'},
        {title:  '联系电话', field: 'appUserPhone', visible: true, align: 'center', valign: 'middle'},
        {title: '会员卡名称', field: 'vipName', visible:  true, align: 'center', valign: 'middle'},
        {title: '时长', field: 'vipTime', visible:  true, align: 'center', valign: 'middle'},
        {title: '金额', field: 'amountValue', visible:  true, align: 'center', valign: 'middle'},
        {title: '下单时间', field: 'insertTime', visible:  true, align: 'center', valign: 'middle'},
        {title: '是否退费', field: 'isRefund', visible: true, align: 'center', valign: 'middle',
            formatter:function (data) {
                return {0:"否",1:"是"}[data]
            }
        },
        {title: '备注', field: 'remark', visible: true, align: 'center', valign: 'middle'},
        { title: '操作', field: 'remark', visible: true, align: 'center', valign: 'middle',
            formatter: function (data,row) {
                // row.redCode存储的设备二维码连接
                var temp = row.isRefund;
                var id = row.id;
                // 已退费不展示按钮
                if (temp==0){
                    var str = '<button class="btn btn-outline btn-primary" onclick="TCompetition.refund(\'' + id + '\')" >'+'会员退费'+'</button>'
                    btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="" onfocus="TUser.tooltip()">' + str + '</p>']
                    return btn;
                }else{
                    return '已退费';
                }
            }
        },
    ];
};
/**
 * 打开编辑
 */
TCompetition.refund = function (e) {
    console.log("退款记录id")
    console.log( e)
    const data1 = {
        id:null,
        vipEndTime:""
 
    };
        var index = layer.load(1,{
            type: 1
            , title: '会员退费'
            , area: ['800px', '600px']
            , offset: 'auto' //具体配置参考:http://www.layui.com/doc/modules/layer.html#offset
            , id: 'layerDemo' //防止重复弹出cge
            , content: '<div class="form-horizontal" style="padding-top: 20px;">' +
                '                    <div class="col-sm-11" >' +
                '                    <div class="col-sm-11">' +
                '                        <div class="form-group">\n' +
                '<label class="col-sm-3 control-label">*会员到期时间:</label>'+
    '<div class="col-sm-9">'+
        '<input style="width: 300px" class="form-control" id="vipEndTime" name="vipEndTime" type="date">'+
    '</div>'+
                '                        <div class="form-group refusal" >\n' +
                '                            <label class="col-sm-3 control-label">备注:</label>\n' +
                '                            <div class="col-sm-9">\n' +
                '                     <textarea id="refusal" class="form-control" style="width: 100%;height: 200px"></textarea>'+
                '                            </div>\n' +
                '                        </div>\n' +
                '                       </div>' +
                '                   </div>' +
                '</div>'
            , btn: ['保存', '关闭']
            , btnAlign: 'c' //按钮居中
            , shade:  0.5 //不显示遮罩
            ,load:1
            , yes: function () {
                var vipEndTime =  $("#vipEndTime").val();
                if(vipEndTime==null || vipEndTime==''){
                    Feng.error("请选择会员到期时间!");
                    return;
                }
                data1.id = e;
                data1.vipEndTime = $("#vipEndTime").val();
                $.ajax({
                    url: Feng.ctxPath + "/vipDetail/refund",
                    type: "POST",
                    contentType: "application/json", // 设置请求头的 Content-Type
                    data: JSON.stringify(data1), // 将数据转换为 JSON 字符串
                    success: function(response) {
                        Feng.success("操作成功!");
                        window.location.reload();
                        layer.closeAll();
                    },
                    error: function(xhr, status, error) {
                        var errorMessage = xhr.responseText ? xhr.responseText : "退费失败!";
                        Feng.error("退费失败!");
                    }
                });
            }
        });
        this.layerIndex = index;
 
};
 
 
/**
 * 查询车辆管理列表
 */
TCompetition.search = function () {
    var queryData = {};
    queryData['appUserName'] = $("#appUserName").val();
    queryData['vipName'] = $("#vipName").val();
    queryData['phone'] = $("#phone").val();
    queryData['isRefund'] = $("#isRefund").val();
    queryData['time'] = $("#time").val();
    TCompetition.table.refresh({query: queryData});
};
 
 
TCompetition.resetSearch = function () {
    $("#appUserName").val("");
    $("#vipName").val("");
    $("#phone").val("");
    $("#isRefund").val("");
    $("#time").val("");
    TCompetition.search();
};
 
 
$(function () {
    var defaultColunms = TCompetition.initColumn();
    var table = new BSTable(TCompetition.id, "/vipDetail/list", defaultColunms);
    table.setPaginationType("client");
    TCompetition.table = table.init();
    TCompetition.getAmount();
 
});
 
/**
 * 下载模板
 */
TCompetition.uploadCarModel = function () {
    window.location.href = Feng.ctxPath + "/TCompetition/uploadCarModel";
}
 
var agreement = function(){
    this.init = function(){
        //模拟上传excel  
        $("#uploadEventBtn").unbind("click").bind("click",function(){
            $("#uploadEventFile").click();
        });
    };
}
/**
 * 导入合同
 */
TCompetition.exporTCompetition = function () {
    var uploadEventFile = $("#uploadEventFile").val();
    if(uploadEventFile == ''){
        if(language==1){
            Feng.info("请选择Excel,再上传");
        }else if(language==2){
            Feng.info("Please select Excel and upload");
        }else {
            Feng.info("Silakan pilih Excel dan upload");
        }
    }else if(uploadEventFile.lastIndexOf(".xls")<0){//可判断以.xls和.xlsx结尾的excel  
        if(language==1){
            Feng.info("只能上传Excel文件");
        }else if(language==2){
            Feng.info("Only Excel files can be uploaded");
        }else {
            Feng.info("Hanya berkas Excel yang dapat diunggah");
        }
    }else{
        var url = Feng.ctxPath + '/TCompetition/exporTCompetition';
        var file = document.querySelector('input[name=file]').files[0];
        var reader = new FileReader();
        if (file) {
            var formData = new FormData();
            formData.append("myfile", file);
            this.sendAjaxRequest(url, 'POST', formData);
        }
    }
}
TCompetition.sendAjaxRequest = function(url,type,data){
    $.ajax({
        url : url,
        type : type,
        data : data,
        success : function(result) {
            if(result.code==500) {
                Feng.info(result.message);
            }else {
                if(language==1){
                    Feng.success("导入成功!");
                }else if(language==2){
                    Feng.success("SUCCESSFUL IMPORT!");
                }else {
                    Feng.success("Import berhasil!");
                }
            }
            TCompetition.table.refresh();
        },
        error : function() {
            if(language==1){
                Feng.error("excel上传失败!");
            }else if(language==2){
                Feng.error("Uploading excel Fails. Procedure!");
            }else {
                Feng.error("Gagal mengunggah excel!");
            }
        },
        cache : false,
        contentType : false,
        processData : false
    });
};
 
var agreement;
$(function(){
    agreement = new agreement();
    agreement.init();
});
 
/**
 * 导出车辆操作
 */
TCompetition.ouTCompetition = function () {
    var operation = function() {
        window.location.href = Feng.ctxPath + "/TCompetition/ouTCompetition";
    };
    if(language==1){
        Feng.confirm("是否确认导出车辆信息?", operation);
    }else if(language==2){
        Feng.confirm("Are you sure to export vehicle information?", operation);
    }else {
        Feng.confirm("Apakah Anda pasti akan mengekspor informasi kendaraan?", operation);
    }
}