xfrontend/web/srczip/logic/userlabel.js
2022-05-19 16:07:40 +08:00

79 lines
3.1 KiB
JavaScript

(function(){
X.pageLogic['userlabel'] = {
init : function(parms){
var me = this;
me.userlabellist();
$(document).off('click','.lable-dingyi').on('click','.lable-dingyi',function(){
X.gourl('userlabel_dy','conetnt');
});
$(document).off('click','.addlabeldata').on('click','.addlabeldata',function(){
X.DATA.userlabelid = "";
X.gourl('userlabel_dy','conetnt');
});
$(document).off('click','.lable-del').on('click','.lable-del',function(){
var _id = X.DATA.userlabelid;
layer.confirm('确认删除选中的标签吗?该操作不可恢复', {
btn: ['取消','删除 '] //按钮
}, function(){
//取消
layer.close(layer.index);
}, function(){
//删除
X.api("user_label/del",'post',{label_id: _id},function(d){
layer.msg('删除成功');
layer.close(layer.index);
me.userlabellist();
})
});
});
// 标签详情
$(document).off('click','.label-info-box').on('click','.label-info-box',function(){
X.gourl('userlabelinfo','conetnt');
});
// 监听单行事件
layui.table.on('row(userlabeltest)',function(obj){
var data = obj.data
//
X.DATA.userlabelid = data._id;
X.api("user_label/cluster_user_count","post",{cluster_name:data.cluster_name},function(d){
data['num'] = d.num;
// console.log(d);
X.laytpldata('#userlabel-right-box-dot',data,'.userlabel-right-box');
})
});
},
userlabellist : function(){
X.laytabledata("#userlabel-table","user_label/list",[[
{field:'cluster_name', title: '标签名', sort: true}
,{field:'display_name', title: '显示名'}
,{field:'act_name', title: '最后操作人'}
,{field:'cluster_type', title: '创建方式',templet:function(d){
if(d.cluster_type == "user_custom"){
return '自定义条件'
}else{
return '其他条件'
}
}}
// ,{fixed: 'right', title:'操作', toolbar: '#eventattradminbarDemo', width:80}
]],"",'auto',function(res, curr, count){
// console.log(res);
if(res.data.length > 0){
X.DATA.userlabelid = res.data[0]._id;
X.api("user_label/cluster_user_count","post",{cluster_name:res.data[0].cluster_name},function(d){
res.data[0]['num'] = d.num;
X.laytpldata('#userlabel-right-box-dot',res.data[0],'.userlabel-right-box');
})
}
});
}
};
})();