File: /web/data/www.tbbprovision.com/static/manage/js/purchase.js
/**
* author : liaoyaping
* createTime : 2017/5/22 9:48
* description :
*/
var purchaseobj = {
list : function(){
window.$bootstrapTable = $('#table2').bootstrapTable({
url:'/admin/purchase/list_json/',
method:'post',
striped:true,
search:false,
height:'530',
toolbar:'#toolbar',
sortOrder:'desc',
showColumns:true,
showRefresh:true,
idField:'rid',
showToggle:false,
sidePagination:'server',
selectItemName:'id',
clickToSelect:true,
totalRows:5,
columns: [{
field: 'rid',
title: 'ID',
checkbox:true,
formatter: function(value,row){
row['post_id'] = value;
}
},{
title: '序号',
width:'5%',
align:'center',
formatter:function(value,row,index,data){
return ++index ;
}
},{
field: 'email',
title: '邮箱',
width: '14%',
formatter:function(value){
return value;
}
},{
field: 'phone',
title: '电话',
width: '5%',
formatter:function(value){
return value;
}
},{
field: 'from_source',
title: '提交位置',
formatter:function(value){
return (value==0?"未统计":(value==1?"首页表单":(value==2?"询价单页":(value==3?"悬浮询价":"产品详情表单"))));
}
},{
field: 'acc_time',
title: '时间'
},{
field: 'brief_time',
title: '处理时间'
},{
field: 'ip',
title: 'IP地址',
formatter: function(value,row){
return value + "<br />["+row['ip_area']+']';
}
},{
field: 'brief',
title: '是否已处理',
formatter: function(value,row){
return (value?'':'<font class="label label-danger">未处理</font>');
}
},{
field: '',
title: '操作',
width: '8%',
formatter: function(value,row,index){
return "<a href='/admin/purchase/edit/?rid="+row.post_id+"' class='item-edit-btn btn btn-info btn-list' title='编辑' data-id='"+row.post_id+"'><span class='fa fa-pencil'></span></a>";
}
}]
});
//删除
$('#remove').click(function(){
//询问框
layer.confirm('确定删除此记录?', {
'title':'提示',
btn: ['删除','关闭'] //按钮
}, function(){
jQuery.ajax({
method:'post',
url:'/admin/purchase/del/',
data:global.get_selected_str('input[name="id"]:checked','id'),
dataType:'json',
timeout:5000,
beforeSend: function(){layer.msg('数据处理中',{icon:16,time:0,shade:[0.8,'#000']});},
success:function($d){
$bootstrapTable.bootstrapTable('refresh');
layer.msg($d.response_content, {icon: 1,time:1000});
},
error:function(xhrData){
layer.msg(errorMessage(xhrData.responseText),{time:2000,icon:7});
}
});
});
});
},
edit : function(){
$('#defaultForm').bootstrapValidator({
message: '这是个无效值',
feedbackIcons: {/*input状态样式图片*/
//valid: 'glyphicon glyphicon-ok',
invalid: 'glyphicon glyphicon-remove',
validating: 'glyphicon glyphicon-refresh'
},
fields: {/*验证:规则*/
brief: {//验证input项:验证规则
validators: {
notEmpty: { message: '备注信息不能为空'}
}
}
}
})
.on('success.form.bv', function(e) {//点击提交之后
e.preventDefault();
var $form = $(e.target);
var bv = $form.data('bootstrapValidator');
$.ajax({
type: "post",
url: $('#defaultForm').attr('action'),
dataType: 'json',
timeout:5000,
data: $('body').find('form').serialize(),//表单数据
beforeSend:function(){
$('#validateBtn').button('loading');
layer.msg('数据处理中',{icon:16,time:0,shade:[0.8,'#000']});
},
success: function (d) {
window.location = '/admin/purchase/list/';
},
error:function(xhrData){
layer.msg(errorMessage(xhrData.responseText),{time:2000,icon:7});
$('#validateBtn').button('reset');
}
});
});
$('#validateBtn').click(function(){
$('#defaultForm').bootstrapValidator('validate');
});
$('.detail-btn').click(function(){
var $this = $(this);
if($this.hasClass('defined')){
return false;
}
$.ajax({
type: 'post',
url: '/admin/purchase/get_email_detail/',
dataType: 'json',
timeout: 5000,
data: 'rid='+$this.attr('data-id'),
beforeSend: function(){},
success: function(xhrData){
$this.addClass('defined');
$this.addClass('hide');
$('.email').html(xhrData.response_content);
},
error: function(xhrData){
$('.error-tip').html(errorMessage(xhrData.responseText));
}
});
});
$('.detail-phone-btn').click(function(){
var $this = $(this);
if($this.hasClass('defined')){
return false;
}
$.ajax({
type: 'post',
url: '/admin/purchase/get_phone_detail/',
dataType: 'json',
timeout: 5000,
data: 'rid='+$this.attr('data-id'),
beforeSend: function(){},
success: function(xhrData){
$this.addClass('defined');
$this.addClass('hide');
$('.phone').html(xhrData.response_content);
},
error: function(xhrData){
$('.phone-error-tip').html(errorMessage(xhrData.responseText));
}
});
});
}
}