Pu Zhibing
2025-04-02 d36376f732544c5ecfb59eff3eea8ab087d1a1f4
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
/**
 * 管理初始化
 */
var UserActivity = {
    id: "UserActivityTable",    //表格id
    seItem: null,        //选中的条目
    table: null,
    layerIndex: -1
};
 
/**
 * 初始化表格的列
 */
UserActivity.initColumn = function () {
    return [
        {field: 'selectItem', radio: true},
        {title: '', field: 'id', visible: false, align: 'center', valign: 'middle'},
        {title: '添加时间', field: 'insertTime', visible: true, align: 'center', valign: 'middle'},
        {title: '活动名称', field: 'name', visible: true, align: 'center', valign: 'middle'},
        {title: '开始时间', field: 'startTime', visible: true, align: 'center', valign: 'middle'},
        {title: '结束时间', field: 'endTime', visible: true, align: 'center', valign: 'middle'},
        {title: '参与人次', field: 'number', visible: true, align: 'center', valign: 'middle'},
        {title: '备注', field: 'remark', visible: true, align: 'center', valign: 'middle'},
        {
            title: '状态', field: 'status', visible: true, align: 'center', valign: 'middle',
            formatter: function (value, row) {
                if (value == 1) {
                    return "待审核";
                } else if (value == 2) {
                    return "已驳回";
                } else if (value == 3) {
                    // if(new Date()<new Date(row.startTime.replace(/-/g,"/"))){
                    //     return "未开始";
                    // }else if(new Date()>new Date(row.endTime.replace(/-/g,"/"))){
                    //     return "已结束";
                    // }else{
                    //     return "进行中";
                    // }
                } else if (value == 4) {
                    return "已暂停";
                } else if (value == 5) {
                    return "未开始";
                } else if (value == 6) {
                    return "进行中";
                } else if (value == 7) {
                    return "已结束";
                }
            }
        }
    ];
};
 
/**
 * 检查是否选中
 */
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 != 6 && selected[0].status != 7) {
            Feng.info("当前状态不能暂停/启动!");
            return false;
        } else if (type == 3 && selected[0].status == 6 && (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 && new Date() >= new Date(selected[0].startTime.replace(/-/g, "/"))) {
            Feng.info("当前状态不能编辑!");
            return false;
        }
        UserActivity.seItem = selected[0];
        return true;
    }
};
 
/**
 * 点击添加
 */
UserActivity.openAddUserActivity = function () {
    var index = layer.open({
        type: 2,
        title: '添加',
        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: '详情',
            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 index = layer.open({
            type: 2,
            title: '编辑',
            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.error("动/暂停失败!" + data.responseJSON.message + "!");
        });
        ajax.set("id", this.seItem.id);
        ajax.set("status", this.seItem.status == 6 ? 4 : 3);
        ajax.start();
    }
};
/**
 * 打开立即处理页面
 */
UserActivity.immediately = function () {
    if (this.check(1)) {
        var index = layer.open({
            type: 2,
            title: '审核',
            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: '领取记录',
            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("");
    DriverActivity.search();
};
$(function () {
    var defaultColunms = UserActivity.initColumn();
    var table = new BSTable(UserActivity.id, "/userActivity/list", defaultColunms);
    table.setPaginationType("server");
    UserActivity.table = table.init();
});