/**
|
* 管理初始化
|
*/
|
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();
|
});
|