无关风月
2025-05-08 9486766c806fe1d9e082b2fd02ea1cc558f1b443
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
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
/**
 * 管理初始化
 */
var UserActivity = {
    id: "UserActivityTable",    //表格id
    seItem: null,        //选中的条目
    table: null,
    layerIndex: -1
};
 
var language =$("#language").val()
/**
 * 初始化表格的列
 */
UserActivity.initColumn = function () {
    return [
        {field: 'selectItem', radio: true},
        {title: '序号', field: 'id', visible: true, align: 'center', valign: 'middle'},
        {title: language==1?'添加时间':(language==2?'Add Time':'Tambahkan waktu'), field: 'insertTime', visible: true, align: 'center', valign: 'middle',formatter:function (data) {
                return currentTime(data);
            }},
        {title: language==1?'活动名称':(language==2?'Activity name':'Nama aktivitas'), field: 'name', visible: true, align: 'center', valign: 'middle'},
        {title:  language==1?'开始时间':(language==2?'Start time':'Waktu awal'), field: 'startTime', visible: true, align: 'center', valign: 'middle',formatter:function (data) {
                return currentTime(data);
            }},
        {title: language==1?'结束时间':(language==2?'End time':'Waktu akhir'), field: 'endTime', visible: true, align: 'center', valign: 'middle',formatter:function (data) {
                return currentTime(data);
            }},
        {title:language==1?'领取人次':(language==2?'Number of pickups':'Jumlah penjemputan') , field: 'number', visible: true, align: 'center', valign: 'middle'},
        {title:language == 1 ? '备注' : ( language == 2 ? 'remark' : 'Catatan'), field: 'remark', visible: true, align: 'center', valign: 'middle'},
        {title:language==1?'状态':(language==2?'State':'Status'), field: 'status', visible: true, align: 'center', valign: 'middle',
            formatter: function (value, row) {
            if(language==1){
                if(value==1){
                    return "待审核";
                }else if(value==2){
                    return "已驳回";
                }else if(value==3){
                    if(new Date()<new Date(row.startTime)){
                        return "未开始";
                    }else if(new Date()>new Date(row.endTime)){
                        return "已结束";
                    }else{
                        return "进行中";
                    }
                }else if(value==4){
                    return "已暂停";
                }
            }else if(language==2){
                if(value==1){
                    return "Pending review";
                }else if(value==2){
                    return "Has been rejected";
                }else if(value==3){
                    if(new Date()<new Date(row.startTime)){
                        return "Not started";
                    }else if(new Date()>new Date(row.endTime)){
                        return "Has ended";
                    }else{
                        return "On going";
                    }
                }else if(value==4){
                    return "Has been paused";
                }
            }else {
                if(value==1){
                    return "Tinjauan tertunda";
                }else if(value==2){
                    return "Telah ditolak";
                }else if(value==3){
                    if(new Date()<new Date(row.startTime)){
                        return "Belum mulai";
                    }else if(new Date()>new Date(row.endTime)){
                        return "Telah berakhir";
                    }else{
                        return "Sedang berlangsung";
                    }
                }else if(value==4){
                    return "Telah dijeda";
                }
            }
 
            }
        }
    ];
};
function currentTime(timestamp){
    var time = timestamp + '';
    if(time.length != 13){
        timestamp = timestamp * 1000;
    }
    var date = new Date(timestamp);;
    var Y = date.getFullYear() + '-';
    var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
    var D = (date.getDate() < 10 ? '0' + (date.getDate()) : date.getDate()) + ' ';
 
    var h = (date.getHours() < 10 ? '0' + (date.getHours()) : date.getHours()) + ':';
    var m = (date.getMinutes() < 10 ? '0' + (date.getMinutes()) : date.getMinutes()) + ':';
    var s = (date.getSeconds() < 10 ? '0' + (date.getSeconds()) : date.getSeconds());
    var strDate = Y + M + D + h + m + s;
    return strDate
}
/**
 * 检查是否选中
 */
UserActivity.check = function (type) {
    var selected = $('#' + this.id).bootstrapTable('getSelections');
    if(selected.length == 0){
        Feng.info("请先选中表格中的某一记录!");
        return false;
    }else{
 
        //验证类型null删除,1=审核,2=编辑,3=启动/暂停
        if(type==null){
            UserActivity.seItem = selected[0];
            return true;
        }else if(type==3 && selected[0].status!=3 && selected[0].status!=4){
            Feng.info("当前状态不能暂停/启动!");
 
            return false;
        }else if(type==3 && selected[0].status==3 && (selected[0].startTime>new Date() || new Date()>selected[0].endTime)){
            Feng.info("当前状态不能暂停/启动!");
            return false;
        }else if(type==1 && selected[0].status!=1){
            Feng.info("当前状态不能审核!");
 
            return false;
        }else if(type==2 && selected[0].status!=2){
             Feng.info("当前状态不能编辑!");
 
            return false;
        }
        UserActivity.seItem = selected[0];
        return true;
    }
};
 
/**
 * 点击添加
 */
UserActivity.openAddUserActivity = function () {
    var index = layer.open({
        type: 2,
        title: language==1?'添加':(language==2?'Add':'Tambahkan'),
        area: ['100%', '100%'], //宽高
        fix: false, //不固定
        maxmin: true,
        content: Feng.ctxPath + '/userActivity/userActivity_add'
    });
    this.layerIndex = index;
};
 
/**
 * 打开查看详情
 */
UserActivity.openUserActivityDetail = function () {
    if (this.check()) {
        var index = layer.open({
            type: 2,
            title: language==1?'详情':(language==2?'details':'details'),
            area: ['100%', '100%'], //宽高
            fix: false, //不固定
            maxmin: true,
            content: Feng.ctxPath + '/userActivity/userActivity_detail/' + UserActivity.seItem.id
        });
        this.layerIndex = index;
    }
};
/**
 * 打开编辑
 */
UserActivity.openUpdateUserActivity = function () {
    if (this.check(2)) {
        var companyId = UserActivity.seItem.companyId
        var id = $("#id").val()
        if(companyId!=id){
            if(language==1){
                Feng.info("不可编辑!")
            }else if(language==2){
                Feng.info("not editable!")
            }else {
                Feng.info("tidak dapat diedit!")
            }
 
        }
        var index = layer.open({
            type: 2,
            title: language==1?'编辑':(language==2?'Edit':'Edit'),
            area: ['100%', '100%'], //宽高
            fix: false, //不固定
            maxmin: true,
            content: Feng.ctxPath + '/userActivity/userActivity_update/' + UserActivity.seItem.id
        });
        this.layerIndex = index;
    }
};
/**
 * 删除
 */
UserActivity.delete = function () {
    if (this.check()) {
        var ajax = new $ax(Feng.ctxPath + "/userActivity/delete", function (data) {
             Feng.success("删除成功!");
            UserActivity.table.refresh();
        }, function (data) {
            Feng.error("删除失败!" + data.responseJSON.message + "!");
        });
        ajax.set("userActivityId",this.seItem.id);
        ajax.start();
    }
};
/**
 * 启动/暂停
 */
UserActivity.updateStatus = function () {
    if (this.check(3)) {
        var ajax = new $ax(Feng.ctxPath + "/userActivity/updateStatus", function (data) {
            Feng.success("启动/暂停成功!");
 
            UserActivity.table.refresh();
        }, function (data) {
           Feng.success("启动/暂停失败!");
 
        });
        ajax.set("id",this.seItem.id);
        ajax.set("status",this.seItem.status==3?4:3);
        ajax.start();
    }
};
/**
 * 打开立即处理页面
 */
UserActivity.immediately = function () {
    if (this.check(1)) {
        var index = layer.open({
            type: 2,
            title: language==1?'审核':(language==2?'Audit':'Audit'),
            area: ['800px', '420px'], //宽高
            fix: false, //不固定
            maxmin: true,
            content: Feng.ctxPath + '/userActivity/userActivity_immediately/' +  this.seItem.id
        });
        this.layerIndex = index;
    }
};
/**
 * 领取记录
 */
UserActivity.receiveRecord= function () {
    if (this.check()) {
        var index = layer.open({
            type: 2,
            title: language==1?'领取记录':(language==2?'Collect records':'Mengumpulkan catatan'),
            area: ['100%', '100%'], //宽高
            fix: false, //不固定
            maxmin: true,
            content: Feng.ctxPath + '/userActivity/receiveRecord?activityId='+ UserActivity.seItem.id
        });
        this.layerIndex = index;
    }
};
/**
 * 查询列表
 */
UserActivity.search = function () {
    var queryData = {};
    queryData['createTime'] = $("#createTime").val();
    queryData['name'] = $("#name").val();
    queryData['status'] = $("#status").val();
    UserActivity.table.refresh({query: queryData});
};
UserActivity.resetSearch = function () {
    $("#createTime").val("");
    $("#name").val("");
    $("#status").val("");
    UserActivity.search();
};
$(function () {
    var defaultColunms = UserActivity.initColumn();
    var table = new BSTable(UserActivity.id, "/userActivity/list", defaultColunms);
    table.setPaginationType("server");
    UserActivity.table = table.init();
});