mitao
2024-04-30 ab4ea7b8f10c9b66aed9c2ea161a08b25c3851a7
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
/**
 * 示例功能管理初始化
 */
var AaaTest = {
    id: "AaaTestTable",    //表格id
    seItem: null,        //选中的条目
    table: null,
    layerIndex: -1
};
 
/**
 * 初始化表格的列
 */
AaaTest.initColumn = function () {
    return [
        {field: 'selectItem', checkbox: true},
        {title: 'ID', field: 'id', visible: true, align: 'center', valign: 'middle'},
        {title: '手机', field: 'phone', visible: true, align: 'center', valign: 'middle'},
        {title: '是否锁定“is”前缀', field: 'isLock', visible: true, align: 'center', valign: 'middle',
            formatter: function (value, row) {
              return Feng.getIsObjFormat(value);
            }
        },
        {title: '复选框示例', field: 'checkBoxEq', visible: true, align: 'center', valign: 'middle'},
        {title: '复选下拉框示例', field: 'selectMultiEq', visible: true, align: 'center', valign: 'middle'},
        {title: '是否删除(下拉框)', field: 'isDelete', visible: true, align: 'center', valign: 'middle',
            formatter: function (value, row) {
              return Feng.getIsObjFormat(value);
            }
        },
        {title: '日期到天“date”前缀', field: 'dateVip', visible: true, align: 'center', valign: 'middle',
            formatter: function (value, row) {
              return Feng.dateFormat(value);
            }
        },
        {title: '文字缩略“rext”前缀', field: 'textMark', visible: true, align: 'center', valign: 'middle',
            formatter: function (value, row) {
              return Feng.textFormat(value, 10);
            }
        },
        {title: '图片展示“image”前缀', field: 'imageCover', visible: true, align: 'center', valign: 'middle',
            formatter: function (value, row) {
              return Feng.getImageDom(value);
            }
        },
        {title: '创建时间', field: 'createTime', visible: true, align: 'center', valign: 'middle'},
        {title: '操作', field: 'opts', visible: true, align: 'center', valign: 'middle',
            formatter: function (value, row) {
                var opts = Feng.Opts();
                if ($("#updateAuth").val() == 'true') {
                    opts.add("AaaTest.openAaaTestUpdate('"+row.id+"');", "编辑");
                }
                if ($("#deleteAuth").val() == 'true') {
                    opts.add("AaaTest.delete('"+row.id+"');", "删除");
                }
                if ($("#updateStateAuth").val() == 'true') {
                    if(row.isLock == 0) {
                        opts.add("AaaTest.updateState('"+row.id+"','1');", "锁定");
                    } else {
                        opts.add("AaaTest.updateState('"+row.id+"','0');", "解锁");
                    }
                }
                return opts.getOpts();
            }
        }
    ];
};
 
/**
 * 检查是否选中
 */
AaaTest.check = function () {
    var selected = $('#' + this.id).bootstrapTable('getSelections');
    if(selected.length == 0){
        Feng.info("请先选中表格中的某一记录!");
        return false;
    }else{
        AaaTest.seItem = selected[0];
        return true;
    }
};
 
/**
 * 点击添加示例功能
 */
AaaTest.openAaaTestAdd = function () {
    var index = layer.open({
        type: 2,
        title: '添加示例功能',
        area: ['99%', '99%'], //宽高
        fix: false, //不固定
        maxmin: true,
        content: Feng.ctxPath + '/aaaTest/aaaTest_add'
    });
    this.layerIndex = index;
};
 
/**
 * 点击编辑示例功能
 */
AaaTest.openAaaTestUpdate = function (id) {
    var index = layer.open({
        type: 2,
        title: '编辑示例功能',
        area: ['99%', '99%'], //宽高
        fix: false, //不固定
        maxmin: true,
        content: Feng.ctxPath + '/aaaTest/aaaTest_update/' + id
    });
    this.layerIndex = index;
};
 
/**
 * 打开查看示例功能详情
 */
AaaTest.openAaaTestDetail = function (id) {
    var index = layer.open({
        type: 2,
        title: '示例功能详情',
        area: ['80%', '80%'], //宽高
        fix: false, //不固定
        maxmin: true,
        content: Feng.ctxPath + '/aaaTest/detail/' + id
    });
    this.layerIndex = index;
};
 
/**
 * 删除/批量删除示例功能
 */
AaaTest.delete = function(id){
    var ids = id;
    if(id == 0) {
      // 如果id为0,则为批量删除
      ids = Feng.checkBoxIds(AaaTest.id);
    }
    if (ids.length != 0) {
        var operation = function() {
            // 加载动画层,0代表加载的风格,支持0-2
            var index = parent.layer.load(0, {shade: false});
            var ajax = new $ax(Feng.ctxPath + "/aaaTest/delete", function (data) {
                // 关闭加载动画层
                parent.layer.close(index);
                Feng.success("删除成功!");
                AaaTest.table.refresh();
            }, function (data) {
                Feng.error("删除失败!" + data.responseJSON.message + "!");
            });
            ajax.set("ids", ids);
            ajax.start();
        };
        Feng.confirm("是否删除所选中的数据?", operation);
    }
};
 
/**
 * 编辑示例功能状态
 */
AaaTest.updateState = function (id, state) {
    var ajax = new $ax(Feng.ctxPath + "/aaaTest/updateState", function (data) {
        if(data.code == 200){
            Feng.success("操作成功!");
            AaaTest.table.refresh();
        } else {
            Feng.error("操作失败!" + data.message);
        }
    }, function () {
        Feng.error("操作失败!");
    });
    ajax.set("aaaTestId", id);
    ajax.set("state", state);
    ajax.start();
};
 
/**
 * 导出记录
 */
AaaTest.export = function () {
    var phone = $("#phone").val();
    window.location.href = Feng.ctxPath + "/aaaTest/export" +
        "?phone=" + phone;
};
 
/**
 * 跳转导入数据页面
 */
AaaTest.import = function() {
    var index = layer.open({
        type: 2,
        title: '导入数据',
        area: ['50%', '25%'], //宽高
        fix: false, //不固定
        maxmin: true,
        content: Feng.ctxPath + '/aaaTest/import'
    });
    this.layerIndex = index;
};
 
 
/**
 * 查询示例功能列表
 */
AaaTest.search = function () {
    var queryData = {};
    queryData['phone'] = $("#phone").val();
    queryData['isLock'] = $("#isLock").val();
    queryData['beginTime'] = $("#beginTime").val();
    queryData['endTime'] = $("#endTime").val();
    AaaTest.table.refresh({query: queryData});
};
/**
 * 重置查询条件
 */
AaaTest.resetSearch = function () {
    $("#phone").val("");
    $("#isLock").val("");
    $("#beginTime").val("");
    $("#endTime").val("");
    AaaTest.search();
};
$(function () {
    var defaultColunms = AaaTest.initColumn();
    var table = new BSTable(AaaTest.id, "/aaaTest/list", defaultColunms);
    // 设置物理分页server(逻辑分页client)
    table.setPaginationType("server");
    // 表单提交参数
    var queryData = {};
    queryData['phone'] = $("#phone").val();
    queryData['isLock'] = $("#isLock").val();
    queryData['beginTime'] = $("#beginTime").val();
    queryData['endTime'] = $("#endTime").val();
    table.setQueryParams(queryData);
    AaaTest.table = table.init();
});