44323
2023-10-13 4433f665bf1eccaeee8de43b08095bf4e576fc5d
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
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
/**
 * 版本管理管理初始化
 */
var TVersionManagement = {
    id: "TVersionManagementTable",    //表格id
    seItem: null,        //选中的条目
    table: null,
    layerIndex: -1
};
var language = $("#language").val()
/**
 * 初始化表格的列
 */
TVersionManagement.initColumn = function () {
    return [
        {field: 'selectItem', radio: true},
        {title: '序号', field: 'id', visible: true, align: 'center', valign: 'middle',width:'5%'},
        {title: language==1?'添加时间':(language==2?'Add Time':'Tambahkan waktu'), field: 'insertTime', visible: true, align: 'center', valign: 'middle',width:'10%',
            formatter: function (value, row) {
                return currentTime(value);
            }
        },
        {title: language==1?'版本编号':(language==2?'Version number':'Nomor Versi'), field: 'version', visible: true, align: 'center', valign: 'middle',
            formatter: function (value, row) {
                var btn = "";
                if(row.version != '' && row.version != null) {
                    btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="' + row.version + '" onfocus="TUser.tooltip()">' + row.version + '</p>']
                }
                return btn;
            }
        },
        {title:language==1?'端口类型':(language==2?'Port type':'Tipe port'), field: 'type', visible: true, align: 'center', valign: 'middle',
            formatter: function (value, row) {
                var btn = "";
                if(row.type != '' && row.type != null) {
                    if(language==1){
                        if (row.type == 1){
                            btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="用户端" onfocus="TUser.tooltip()">用户端</p>']
                        } else if (row.type == 2){
                            btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="司机端" onfocus="TUser.tooltip()">司机端</p>']
                        } else if (row.type == 3){
                            btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="车载端" onfocus="TUser.tooltip()">车载端</p>']
                        }else if (row.type == 4){
                            btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="调度端" onfocus="TUser.tooltip()">调度端</p>']
                        }
                    }else if(language==2){
                        if (row.type == 1){
                            btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="User\'s end" onfocus="TUser.tooltip()">User\'s end</p>']
                        } else if (row.type == 2){
                            btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="Driver\'s end" onfocus="TUser.tooltip()">Driver\'s end</p>']
                        } else if (row.type == 3){
                            btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="Vehicle mounted terminal" onfocus="TUser.tooltip()">Vehicle mounted terminal</p>']
                        }else if (row.type == 4){
                            btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="The dispatching end" onfocus="TUser.tooltip()">The dispatching end</p>']
                        }
                    }else {
                        if (row.type == 1){
                            btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="Akhir pengguna" onfocus="TUser.tooltip()">Akhir pengguna</p>']
                        } else if (row.type == 2){
                            btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="Akhir pengemudi" onfocus="TUser.tooltip()">Akhir pengemudi</p>']
                        } else if (row.type == 3){
                            btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="Terminal terpasang kendaraan" onfocus="TUser.tooltip()">Terminal terpasang kendaraan</p>']
                        }else if (row.type == 4){
                            btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="Akhir pengiriman" onfocus="TUser.tooltip()">Akhir pengiriman</p>']
                        }
                    }
 
                }
                return btn;
            }
        },
        {title: language==1?'文件':(language==2?'file':'file'), field: 'url', visible: true, align: 'center', valign: 'middle',width:'40%',
            formatter: function (value, row) {
                var btn = "";
                if(language==1){
                    if(row.url != '' && row.url != null) {
                        btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="' + row.url + '" onfocus="AppUserInfo.tooltip()">' + row.url + '</p>' +
                        '<button class="btn" onclick="TVersionManagement.copy(\''+row.url+'\')"> 复制 </button>']
                    }
                }else if(language==2){
                    if(row.url != '' && row.url != null) {
                        btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="' + row.url + '" onfocus="AppUserInfo.tooltip()">' + row.url + '</p>' +
                        '<button class="btn" onclick="TVersionManagement.copy(\''+row.url+'\')"> copy </button>']
                    }
                }else {
                    if(row.url != '' && row.url != null) {
                        btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="' + row.url + '" onfocus="AppUserInfo.tooltip()">' + row.url + '</p>' +
                        '<button class="btn" onclick="TVersionManagement.copy(\''+row.url+'\')"> Salin </button>']
                    }
                }
 
                return btn;
            }
        },
        {title: language==1?'是否强制<br/>更新':(language==2?'Whether to force update':'Apakah akan memaksa pembaruan'), field: 'mandatory', visible: true, align: 'center', valign: 'middle',
            formatter: function (value, row) {
                var btn = "";
                if(row.mandatory != '' && row.mandatory != null) {
 
                    if(language==1){
                        if (row.mandatory == 1){
                            btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="是" onfocus="AppUserInfo.tooltip()">是</p>']
                        } else if (row.mandatory == 2){
                            btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="否" onfocus="AppUserInfo.tooltip()">否</p>']
                        }
                    }else if(language==2){
                        if (row.mandatory == 1){
                            btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="Yes" onfocus="AppUserInfo.tooltip()">Yes</p>']
                        } else if (row.mandatory == 2){
                            btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="No" onfocus="AppUserInfo.tooltip()">No</p>']
                        }
                    }else {
                        if (row.mandatory == 1){
                            btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="Ya" onfocus="AppUserInfo.tooltip()">Ya</p>']
                        } else if (row.mandatory == 2){
                            btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="Tidak" onfocus="AppUserInfo.tooltip()">Tidak</p>']
                        }
                    }
 
                }
                return btn;
            }
        },
        {title: language==1?'版本<br/>公告':(language==2?'Version announcement':'Pengumuman versi'), field: 'content', visible: true, align: 'center', valign: 'middle',
            formatter: function (value, row) {
                var btn = "";
                if(row.content != '' && row.content != null) {
                    var str = row.content;
                    if (str.length > 20){
                        if(language==1){
                            str = str.substring(0,20)+'...<br><button class="btn btn-outline btn-primary" onclick="TVersionManagement.buttonClick(' +  row.id+','+ 1+ ')">查看更多</button>';
                        }else if(language==2){
                            str = str.substring(0,20)+'...<br><button class="btn btn-outline btn-primary" onclick="TVersionManagement.buttonClick(' +  row.id+','+ 1+ ')">view more</button>';
                        }else {
                            str = str.substring(0,20)+'...<br><button class="btn btn-outline btn-primary" onclick="TVersionManagement.buttonClick(' +  row.id+','+ 1+ ')">lihat lebih</button>';
                        }
 
                    }
                    btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="' + row.content + '" onfocus="TUser.tooltip()">' + str + '</p>']
                }
                return btn;
            }
        }
    ];
};
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
}
/**
 * 查看更多按钮
 * @param con
 */
TVersionManagement.buttonClick = function (id,type) {
    var index = layer.open({
        type: 2,
         title: language==1?'查看详情':(language==2?'View details':'Melihat rincian'),
        area: ['800px', '420px'], //宽高
        fix: false, //不固定
        maxmin: true,
        content: Feng.ctxPath + '/tVersionManagement/lookDetail/'+id+"/"+type
    });
    this.layerIndex = index;
}
 
/**
 * 复制文本内容
 * @param value
 */
TVersionManagement.copy = function(value){
    var sss = document.getElementById("input");
    sss.value = value;
    if (document.execCommand("copy")) {
        sss.select();
        document.execCommand("copy");
    }
}
 
/**
 * 检查是否选中
 */
TVersionManagement.check = function () {
    var selected = $('#' + this.id).bootstrapTable('getSelections');
    if(selected.length == 0){
        Feng.info("请先选中表格中的某一记录!");
        return false;
    }else{
        TVersionManagement.seItem = selected[0];
        return true;
    }
};
 
/**
 * 点击添加版本管理
 */
TVersionManagement.openAddTVersionManagement = function () {
    var index = layer.open({
        type: 2,
        title: language==1?'添加':(language==2?'Add':'Tambahkan'),
        area: ['100%', '100%'], //宽高
        fix: false, //不固定
        maxmin: true,
        content: Feng.ctxPath + '/tVersionManagement/tVersionManagement_add'
    });
    this.layerIndex = index;
};
 
/**
 * 打开查看版本管理详情
 */
TVersionManagement.openTVersionManagementDetail = function () {
    if (this.check()) {
        var index = layer.open({
            type: 2,
            title: language==1?'详情':(language==2?'details':'details'),
            area: ['800px', '420px'], //宽高
            fix: false, //不固定
            maxmin: true,
            content: Feng.ctxPath + '/tVersionManagement/tVersionManagement_update/' + TVersionManagement.seItem.id
        });
        this.layerIndex = index;
    }
};
 
/**
 * 删除版本管理
 */
TVersionManagement.delete = function () {
    if (this.check()) {
        var nickname = TVersionManagement.seItem.version;
        if (nickname == "" || nickname == null || nickname == undefined) {
            if(language==1){
                nickname = "该版本";
            }else if(language==2){
                nickname = "This version";
            }else {
                nickname = "Versi ini";
            }
 
        } else {
            nickname = "【" + nickname + "】";
        }
        swal({
            title: language==1?"您是否确认删除" + nickname + "?":(language==2?"Are you sure to delete the" + nickname + "?":"Apakah Anda pasti akan menghapus" + nickname + "?"),
            text: language==1?"请谨慎操作!":(language==2?' Please operate with caution!':'Harap beroperasi dengan hati -hati!'),
            type: "warning",
            showCancelButton: true,
            confirmButtonColor: "#DD6B55",
            confirmButtonText: language==1?"删除":(language==2?'Delete':'Hapus'),
            closeOnConfirm: false
        }, function () {
            var ajax = new $ax(Feng.ctxPath + "/tVersionManagement/delete", function (data) {
                if(language==1){
                    swal("删除成功", "您已经删除了" + nickname + "。", "success");
                }else if(language==2){
                    swal("Success", "You have deleted it" + nickname + "。", "success");
                }else {
                    swal("Success", "Anda telah menghapusnya" + nickname + "。", "success");
                }
                TVersionManagement.table.refresh();
            }, function (data) {
                if(language==1){
                    swal("删除失败", data.responseJSON.message + "!", "warning");
                }else if(language==2){
                    swal("Failed to delete", data.responseJSON.message + "!", "warning");
                }else {
                    swal("Hapus Gagal", data.responseJSON.message + "!", "warning");
                }
            });
            ajax.set("tVersionManagementId",TVersionManagement.seItem.id);
            ajax.start();
        });
    }
};
 
/**
 * 查询版本管理列表
 */
TVersionManagement.search = function () {
    var queryData = {};
    queryData['insertTime'] = $("#insertTime").val();
    queryData['version'] = $("#version").val();
    TVersionManagement.table.refresh({query: queryData});
};
 
TVersionManagement.resetSearch = function () {
    $("#insertTime").val("");
    $("#version").val("");
    TVersionManagement.search();
};
 
 
$(function () {
    var defaultColunms = TVersionManagement.initColumn();
    var table = new BSTable(TVersionManagement.id, "/tVersionManagement/list", defaultColunms);
    table.setPaginationType("server");
    TVersionManagement.table = table.init();
});