/**
|
* 用户管理管理初始化
|
*/
|
|
var language=$("#language").val();
|
var TUser = {
|
id: "TUserTable", //表格id
|
seItem: null, //选中的条目
|
table: null,
|
layerIndex: -1
|
};
|
|
/**
|
* 鼠标悬停提示框 class .toolTip 为无效样式,作用于个别选择器使用
|
*/
|
TUser.tooltip = function(){
|
$(".toolTip").tooltip();
|
};
|
|
/**
|
* 初始化表格的列
|
*/
|
TUser.initColumn = function () {
|
return [
|
{field: 'selectItem', radio: true},
|
{title: '序号', field: 'id', visible: true, align: 'center', valign: 'middle'},
|
{title: language == 1 ? '注册时间' : ( language == 2 ? 'Registration time' : 'Waktu pendaftaran'), field: 'insertTime', visible: true, align: 'center', valign: 'middle',width:'10%',
|
formatter:function (data) {
|
return currentTime(data);
|
}
|
},
|
{title: language == 1 ? '用户ID' : ( language == 2 ? 'User id' : 'Identitas pengguna'), field: 'id', visible: true, align: 'center', valign: 'middle',width:'8%'},
|
{title: language == 1 ? '注册地所<br/>属分公司ID' : ( language == 2 ? 'Registered address of branch id' : 'Alamat Terdaftar Cabang id'), field: 'companyId', visible: false, align: 'center', valign: 'middle',width:'8%'},
|
{title: language == 1 ? '注册地所<br/>属分公司' : ( language == 2 ? 'Registered address of branch' : 'Alamat Terdaftar Cabang'), field: 'companyName', visible: true, align: 'center', valign: 'middle',width:'8%',
|
formatter: function (value, row) {
|
var btn = "";
|
if(row.companyName != '' && row.companyName != null) {
|
btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="' + row.companyName + '" onfocus="TUser.tooltip()">' + row.companyName + '</p>']
|
}
|
return btn;
|
}
|
},
|
{title: language == 1 ? '昵称' : ( language == 2 ? 'nick name' : 'nama panggilan'), field: 'nickName', visible: true, align: 'center', valign: 'middle',width:'10%',
|
formatter: function (value, row) {
|
var btn = "";
|
if(row.nickName != '' && row.nickName != null) {
|
btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="' + row.nickName + '" onfocus="TUser.tooltip()">' + row.nickName + '</p>']
|
}
|
return btn;
|
}
|
},
|
{title: language == 1 ? '手机号' : ( language == 2 ? 'phone' : 'nomor ponsel'), field: 'phone', visible: true, align: 'center', valign: 'middle',width:'8%',
|
formatter: function (value, row) {
|
var btn = "";
|
if(row.phone != '' && row.phone != null) {
|
btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="' + row.phone + '" onfocus="TUser.tooltip()">' + row.phone + '</p>']
|
}
|
return btn;
|
}
|
},
|
{title: language == 1 ? '紧急联系人<br/>姓名' : ( language == 2 ? 'Emergency contact name' : 'Nama kontak darurat'), field: 'emergencyContact', visible: true, align: 'center', valign: 'middle',width:'8%',
|
formatter: function (value, row) {
|
var btn = "";
|
if(row.emergencyContact != '' && row.emergencyContact != null) {
|
btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="' + row.emergencyContact + '" onfocus="TUser.tooltip()">' + row.emergencyContact + '</p>']
|
}
|
return btn;
|
}
|
},
|
{title: language == 1 ? '紧急联系人<br/>电话' : ( language == 2 ? 'Emergency contact telephone number' : 'Nomor telepon kontak darurat'), field: 'emergencyContactNumber', visible: true, align: 'center', valign: 'middle',width:'8%',
|
formatter: function (value, row) {
|
var btn = "";
|
if(row.emergencyContactNumber != '' && row.emergencyContactNumber != null) {
|
btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="' + row.emergencyContactNumber + '" onfocus="TUser.tooltip()">' + row.emergencyContactNumber + '</p>']
|
}
|
return btn;
|
}
|
},
|
{title: language == 1 ? '是否实<br/>名认证' : ( language == 2 ? 'Whether to carry out the real name authentication' : 'Apakah akan melakukan otentikasi nama asli'), field: 'isAuth', visible: true, align: 'center', valign: 'middle',width:'5%',
|
formatter: function (value, row) {
|
var btn = "";
|
if(row.isAuth != '' && row.isAuth != null) {
|
if (row.isAuth == 1){
|
if(language==1){
|
btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="否" onfocus="TUser.tooltip()">否</p>']
|
}else if(language==2){
|
btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="No" onfocus="TUser.tooltip()">No</p>']
|
}else {
|
btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="否" onfocus="TUser.tooltip()">Tidak</p>']
|
}
|
|
} else if (row.isAuth == 2){
|
if(language==1){
|
btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="是" onfocus="TUser.tooltip()">是</p>']
|
}else if(language==2){
|
btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="Yes" onfocus="TUser.tooltip()">Yes</p>']
|
}else {
|
btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="是" onfocus="TUser.tooltip()">Ya</p>']
|
}
|
}
|
}
|
return btn;
|
}
|
},
|
{title: language == 1 ? '历史出<br/>行次数' : ( language == 2 ? 'Historical number of trips' : 'Riwayat jumlah perjalanan'), field: 'orderNum', visible: true, align: 'center', valign: 'middle',width:'5%',
|
formatter: function (value, row) {
|
var btn = "";
|
if(row.historyNum != '' && row.historyNum != null) {
|
btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="' + row.historyNum + '" onfocus="TUser.tooltip()">' + row.historyNum + '</p>']
|
}else {
|
btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="0" onfocus="TUser.tooltip()">0</p>']
|
}
|
return btn;
|
}
|
},
|
{title: language == 1 ? '历史消费' : ( language == 2 ? 'Historical consumption' : 'Riwayat konsumsi'), field: 'consumption', visible: true, align: 'center', valign: 'middle',width:'5%',
|
},
|
{title: language == 1 ? '积分' : ( language == 2 ? 'integral' : 'integral'), field: 'integral', visible: true, align: 'center', valign: 'middle',width:'5%',
|
formatter: function (value, row) {
|
var btn = "";
|
if(row.integral != '' && row.integral != null) {
|
btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="' + row.integral + '" onfocus="TUser.tooltip()">' + row.integral + '</p>']
|
}else {
|
btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="0" onfocus="TUser.tooltip()">0</p>']
|
}
|
return btn;
|
}
|
},
|
{title: language == 1 ? '用户等级' : ( language == 2 ? 'User level' : 'Tingkat Pengguna'), field: 'level', visible: true, align: 'center', valign: 'middle',width:'8%',
|
},
|
{title: language == 1 ? '推广码' : ( language == 2 ? 'Invitation code' : 'Kode undangan'), field: 'code', visible: true, align: 'center', valign: 'middle',width:'8%',
|
},
|
{title: language == 1 ? '备注' : ( language == 2 ? 'remark' : 'Catatan'), field: 'remark', visible: true, align: 'center', valign: 'middle',width:'10%',
|
formatter: function (value, row) {
|
var btn = "";
|
if(row.remark != '' && row.remark != null){
|
var str = row.remark;
|
if (row.remark.length > 10){
|
str = row.remark.substring(0,10)+"...";
|
}
|
btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="' + row.remark + '" onfocus="TUser.tooltip()">' + str + '</p>']
|
}
|
return btn;
|
}
|
},
|
{title: language == 1 ? '状态' : ( language == 2 ? 'state' : 'Status'), field: 'state', visible: true, align: 'center', valign: 'middle',width:'5%',
|
formatter: function (value, row) {
|
var btn = "";
|
if(row.state != '' && row.state != null) {
|
if (row.state == 1){
|
if(language==1){
|
btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;color: #0d8ddb;" title="正常" onfocus="TUser.tooltip()">正常</p>']
|
}else if(language==2){
|
btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;color: #0d8ddb;" title="normal" onfocus="TUser.tooltip()">normal</p>']
|
}else {
|
btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;color: #0d8ddb;" title="normal" onfocus="TUser.tooltip()">正常</p>']
|
}
|
|
} else if (row.state == 2){
|
if(language==1){
|
btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;color: red;" title="冻结" onfocus="TUser.tooltip()">冻结</p>']
|
}else if(language==2){
|
btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;color: red;" title="freeze" onfocus="TUser.tooltip()">freeze</p>']
|
}else {
|
btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;color: red;" title="Membekukan" onfocus="TUser.tooltip()">冻结</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
|
}
|
/**
|
* 检查是否选中
|
*/
|
TUser.check = function () {
|
var selected = $('#' + this.id).bootstrapTable('getSelections');
|
if(selected.length == 0){
|
if(language==1){
|
Feng.info("请先选中表格中的某一记录!");
|
}else if(language==2){
|
Feng.info("Please select 条记录 in the table!");
|
}else {
|
Feng.info("Pilih catatan di tabel terlebih dahulu!");
|
}
|
return false;
|
}else{
|
TUser.seItem = selected[0];
|
return true;
|
}
|
};
|
|
/**
|
* 修改余额
|
*/
|
TUser.updateBalance = function () {
|
if (this.check()) {
|
var index = layer.open({
|
type: 2,
|
title: language==1?'修改余额':(language==2?'Modify balance':'Ubah Saldo'),
|
area: ['800px', '420px'], //宽高
|
fix: false, //不固定
|
maxmin: true,
|
content: Feng.ctxPath + '/tUser/tUser_updateBalance/'+ TUser.seItem.id
|
});
|
this.layerIndex = index;
|
}
|
};
|
/**
|
* d导出
|
*/
|
TUser.export = function () {
|
console.log(111)
|
};
|
|
|
TUser.getCode = function () {
|
layer.open({
|
type: 1
|
, title: language==1?'推广码设置':(language==2?'Promotion code setting':'Pengaturan kode promosi')
|
, area: ['50%', '50%']
|
, offset: 'auto' //具体配置参考:http://www.layui.com/doc/modules/layer.html#offset
|
, id: 'layerDemo' //防止重复弹出cge
|
, content: '<div class="form-horizontal">' +
|
' <div class="col-sm-11" style="margin-top: 30px">' +
|
' <div class="col-sm-11">' +
|
' <div class="form-group">\n' +
|
' <label class="col-sm-3 control-label">Number:</label>\n' +
|
' <div class="col-sm-9">\n' +
|
' <input class="form-control" id="num" type="number" min="1"> '+
|
' </div>\n' +
|
' </div>\n' +
|
' <div class="form-group">\n' +
|
' <label class="col-sm-3 control-label">ExpireTime:</label>\n' +
|
' <div class="col-sm-9">\n' +
|
' <input class="form-control" id="likeNum" name="likeNum" autocomplete="off" >\n' +
|
' </div>\n' +
|
' </div>\n' +
|
' </div>' +
|
' </div>' +
|
'</div>'
|
|
, btn: ['Export', 'Cancel']
|
, btnAlign: 'c' //按钮居中
|
, shade: 0.5 //不显示遮罩
|
, yes: function () {
|
let num = $('#num').val();
|
let likeNum = $('#likeNum').val();
|
if(num==''||likeNum==''){
|
if(language==1){
|
Feng.info("输入框不能为空")
|
}else if(language==2){
|
Feng.info("The input field cannot be empty")
|
}else {
|
Feng.info("Catatan eksport informasi pengguna")
|
}
|
|
}else {
|
window.location.href=Feng.ctxPath + "/tUser/getCode?num="+num
|
+"&time="+likeNum
|
;
|
layer.closeAll();
|
}
|
|
},
|
});
|
|
laydate.render({
|
elem: '#likeNum'
|
,range: false
|
,lang:"en",
|
min: new Date().toLocaleString()
|
});
|
|
function minDate(){
|
var now = new Date();
|
return now.getFullYear()+"-" + (now.getMonth()+1) + "-" + now.getDate();
|
}
|
};
|
/**
|
* 修改密码
|
*/
|
TUser.updatePassword = function () {
|
if (this.check()) {
|
var index = layer.open({
|
type: 2,
|
title: language==1?'修改密码':(language==2?'Change password':'Ubah Sandi'),
|
area: ['800px', '420px'], //宽高
|
fix: false, //不固定
|
maxmin: true,
|
content: Feng.ctxPath + '/tUser/tUser_updatePassword/'+ TUser.seItem.id
|
});
|
this.layerIndex = index;
|
}
|
};
|
|
/**
|
* 打开查看用户管理详情
|
*/
|
TUser.userDetail = function () {
|
if (this.check()) {
|
var index = layer.open({
|
type: 2,
|
title: language==1?'用户详情':(language==2?'User details':'Detail Pengguna'),
|
area: ['100%', '100%'], //宽高
|
fix: false, //不固定
|
maxmin: true,
|
content: Feng.ctxPath + '/tUser/tUser_userDetail/' + TUser.seItem.id
|
});
|
this.layerIndex = index;
|
}
|
};
|
|
/**
|
* 冻结用户
|
*/
|
TUser.freezeUser = function () {
|
if (this.check()) {
|
var nickname = TUser.seItem.nickName;
|
if (nickname == "" || nickname == null || nickname == undefined) {
|
if(language==1){
|
nickname = "该用户";
|
}else if(language==2){
|
nickname = "this user";
|
}else {
|
nickname = "Pengguna ini";
|
}
|
|
} else {
|
nickname = "【" + nickname + "】";
|
}
|
if (TUser.seItem.state != 1) {
|
if(language==1){
|
swal("冻结失败", "【正常】状态下才能执行此操作", "warning");
|
}else if(language==2){
|
swal("Fail","This operation can only be performed in unfreezing failed [normal] status", "warning");
|
}else {
|
swal("Gagal", "Operasi ini hanya dapat dilakukan dalam status unfreezing gagal [normal].", "warning");
|
}
|
|
return;
|
} else {
|
var index = layer.open({
|
type: 2,
|
title: language==1?'冻结用户':(language==2?'Freeze User':'Membeku Pengguna'),
|
area: ['800px', '420px'], //宽高
|
fix: false, //不固定
|
maxmin: true,
|
content: Feng.ctxPath + '/tUser/tUser_optUser/' + TUser.seItem.id +"/"+1
|
});
|
this.layerIndex = index;
|
}
|
}
|
};
|
/**
|
* 解冻用户
|
*/
|
TUser.trawUser = function () {
|
if (this.check()) {
|
var nickname = TUser.seItem.nickName;
|
if (nickname == "" || nickname == null || nickname == undefined) {
|
if(language==1){
|
nickname = "该用户";
|
}else if(language==2){
|
nickname = "this user";
|
}else {
|
nickname = "Pengguna ini";
|
}
|
} else {
|
nickname = "【" + nickname + "】";
|
}
|
if (TUser.seItem.state != 2) {
|
if(language==1){
|
swal("启用失败", "【冻结】状态下才能执行此操作", "warning");
|
}else if(language==2){
|
swal("Fail","This operation can be performed only when the function is frozen", "warning");
|
}else {
|
swal("Gagal", "Operasi ini hanya dapat dilakukan dalam status kegagalan [beku] yang tidak bebas.", "warning");
|
}
|
|
return;
|
} else {
|
var index = layer.open({
|
type: 2,
|
title: language==1?'解冻用户':(language==2?'Unfreeze user':'Batalkan pembekuan Akun'),
|
area: ['800px', '420px'], //宽高
|
fix: false, //不固定
|
maxmin: true,
|
content: Feng.ctxPath + '/tUser/tUser_optUser/' + TUser.seItem.id +"/"+2
|
});
|
this.layerIndex = index;
|
}
|
}
|
};
|
|
/**
|
* 查询用户管理列表
|
*/
|
TUser.search = function () {
|
var queryData = {};
|
queryData['insertTime'] = $("#insertTime").val();
|
queryData['id'] = $("#id").val();
|
queryData['nickName'] = $("#nickName").val();
|
queryData['phone'] = $("#phone").val();
|
queryData['isAuth'] = $("#isAuth").val();
|
queryData['state'] = $("#state").val();
|
queryData['code'] = $("#code").val();
|
TUser.table.refresh({query: queryData});
|
};
|
TUser.resetSearch = function () {
|
$("#insertTime").val("");
|
$("#id").val("");
|
$("#nickName").val("");
|
$("#phone").val("");
|
$("#isAuth").val("");
|
$("#state").val("");
|
$("#code").val("");
|
TUser.search();
|
};
|
|
$(function () {
|
var defaultColunms = TUser.initColumn();
|
var table = new BSTable(TUser.id, "/tUser/list", defaultColunms);
|
// 设置物理分页server(逻辑分页client)
|
table.setPaginationType("server");
|
TUser.table = table.init();
|
});
|
|
/**
|
* 下载模板
|
*/
|
TUser.uploadUserModel = function () {
|
window.location.href = Feng.ctxPath + "/tUser/uploadUserModel";
|
}
|
|
var agreement = function(){
|
this.init = function(){
|
//模拟上传excel
|
$("#uploadEventBtn").unbind("click").bind("click",function(){
|
$("#uploadEventFile").click();
|
});
|
};
|
}
|
/**
|
* 导入合同
|
*/
|
TUser.exportUser = function () {
|
var uploadEventFile = $("#uploadEventFile").val();
|
if(uploadEventFile == ''){
|
if(language==1){
|
Feng.info("请选择Excel,再上传");
|
}else if(language==2){
|
Feng.info("Please select Excel and upload");
|
}else {
|
Feng.info("Silakan pilih Excel dan upload");
|
}
|
|
}else if(uploadEventFile.lastIndexOf(".xls")<0){//可判断以.xls和.xlsx结尾的excel
|
if(language==1){
|
Feng.info("只能上传Excel文件");
|
}else if(language==2){
|
Feng.info("Only Excel files can be uploaded");
|
}else {
|
Feng.info("Hanya berkas Excel yang dapat diunggah");
|
}
|
|
}else{
|
var url = Feng.ctxPath + '/tUser/exportUser';
|
var file = document.querySelector('input[name=file]').files[0];
|
var reader = new FileReader();
|
if (file) {
|
var formData = new FormData();
|
formData.append("myfile", file);
|
this.sendAjaxRequest(url, 'POST', formData);
|
}
|
}
|
}
|
TUser.sendAjaxRequest = function(url,type,data){
|
$.ajax({
|
url : url,
|
type : type,
|
data : data,
|
success : function(result) {
|
if(result.code==500) {
|
Feng.info(result.message);
|
}else {
|
if(language==1){
|
Feng.success("导入成功!");
|
}else if(language==2){
|
Feng.success("SUCCESSFUL IMPORT!");
|
}else {
|
Feng.success("Import berhasil!");
|
}
|
|
}
|
TUser.table.refresh();
|
},
|
|
error : function() {
|
if(language==1){
|
Feng.error("excel上传失败!");
|
}else if(language==2){
|
Feng.error("Uploading excel Fails. Procedure!");
|
}else {
|
Feng.error("Gagal mengunggah excel!");
|
}
|
},
|
cache : false,
|
contentType : false,
|
processData : false
|
});
|
};
|
|
var agreement;
|
$(function(){
|
agreement = new agreement();
|
agreement.init();
|
});
|
|
/**
|
* 导出车辆操作
|
*/
|
TUser.outUser = function () {
|
var insertTime = $("#insertTime").val();
|
var id = $("#id").val();
|
var nickName= $("#nickName").val();
|
var phone = $("#phone").val();
|
var isAuth= $("#isAuth").val();
|
var state = $("#state").val();
|
var code= $("#code").val();
|
var operation = function() {
|
window.location.href = Feng.ctxPath + "/tUser/outUser?insertTime="+insertTime+"&id="+id+"&nickName="+nickName+"&phone="+phone+"&isAuth="+isAuth+"&state="+state+"&code="+code;
|
};
|
if(language==1){
|
Feng.confirm("是否确认导出用户信息?", operation);
|
}else if(language==2){
|
Feng.confirm("Whether to export user information?", operation);
|
}else {
|
Feng.confirm("Konfirmasi untuk mengeksport informasi pengguna?", operation);
|
}
|
|
}
|