puzhibing
2024-02-05 640ff18d2d7f4be02ddb7f8f75e899f05545eb98
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
/**
 * 管理初始化
 */
var THotAddress = {
    id: "THotAddressTable",    //表格id
    seItem: null,        //选中的条目
    table: null,
    layerIndex: -1
};
 
var language =$("#language").val()
/**
 * 初始化表格的列
 */
THotAddress.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: 'createTime', visible: true, align: 'center', valign: 'middle',
                formatter:function (data){
                    return currentTime(data)
                }
            },
            {title: language==1?'省':(language==2?'Province':'Propinsi'), field: 'pname', visible: true, align: 'center', valign: 'middle'},
            {title: language==1?'搜索地址':(language==2?'Search address':'Alamat pencarian'), field: 'address', visible: true, align: 'center', valign: 'middle',
            },
            {title:language==1?'状态':(language==2?'State':'Status'), field: 'hide', visible: true, align: 'center', valign: 'middle',
                formatter:function (data){
                    if(language==1){
                        if(data==0){
                            return  '<span style="color:red;">显示</span> '
                        }
                        if(data==1){
                            return "隐藏"
                        }
                    }else if(language==2){
                        if(data==0){
                            return  '<span style="color:red;">display</span> '
                        }
                        if(data==1){
                            return "hide"
                        }
                    }else {
                        if(data==0){
                            return  '<span style="color:red;">menampilkan</span> '
                        }
                        if(data==1){
                            return "Sembunyikan"
                        }
                    }
 
                }
            }
    ];
};
 
 
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
}
/**
 * 检查是否选中
 */
THotAddress.check = function () {
    var selected = $('#' + this.id).bootstrapTable('getSelections');
    if(selected.length == 0){
        Feng.info("请先选中表格中的某一记录!");
        return false;
    }else{
        THotAddress.seItem = selected[0];
        return true;
    }
};
THotAddress.reset = function () {
    $("#time").val('');
    $("#name").val('');
    THotAddress.search();
};
 
/**
 * 点击添加
 */
THotAddress.openAddTHotAddress = function () {
    var index = layer.open({
        type: 2,
        title: language==1?'添加':(language==2?'Add':'Tambahkan'),
        area: ['80%', '80%'], //宽高
        fix: false, //不固定
        maxmin: true,
        content: Feng.ctxPath + '/THotAddress/tbHotAddress_add'
    });
    this.layerIndex = index;
};
 
/**
 * 打开查看详情
 */
THotAddress.openTHotAddressDetail = function () {
    if (this.check()) {
        var index = layer.open({
            type: 2,
            title: language==1?'详情':(language==2?'details':'details'),
            area: ['80%', '80%'], //宽高
            fix: false, //不固定
            maxmin: true,
            content: Feng.ctxPath + '/THotAddress/tbHotAddress_update/' + THotAddress.seItem.id
        });
        this.layerIndex = index;
    }
};
 
/**
 * 删除
 */
THotAddress.delete = function () {
    if (this.check()) {
        let a =  this.seItem.id
        var operation = function () {
            var ajax = new $ax(Feng.ctxPath + "/THotAddress/delete", function (data) {
                if(language==1){
                    Feng.success("删除成功!");
                }else if(language==2){
                    Feng.success("Delete succeeded!");
                }else {
                    Feng.success("Hapus berhasil!");
                }
                THotAddress.table.refresh();
            }, function (data) {
                if(language==1){
                    Feng.error("删除失败!" + data.responseJSON.message + "!");
                }else if(language==2){
                    Feng.error("Delete failed!" + data.responseJSON.message + "!");
                }else {
                    Feng.error("Hapus gagal!" + data.responseJSON.message + "!");
                }
            });
            ajax.set("THotAddressId", a);
            ajax.start();
        }
 
        if(language==1){
            Feng.confirm("确定要删除该地址?", operation);
        }else if(language==2){
            Feng.confirm("Make sure you want to delete the address?", operation);
        }else {
            Feng.confirm("Pastikan Anda ingin menghapus alamat?", operation);
        }
 
    }
};
 
/**
 * 查询列表
 */
THotAddress.search = function () {
    var queryData = {};
    queryData['time'] = $("#time").val();
    queryData['name'] = $("#name").val();
    THotAddress.table.refresh({query: queryData});
};
 
$(function () {
    var defaultColunms = THotAddress.initColumn();
    var table = new BSTable(THotAddress.id, "/THotAddress/list", defaultColunms);
    table.setPaginationType("client");
    THotAddress.table = table.init();
});