wwservice/web/Views/Home/Index.cshtml

293 lines
11 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

@using model;
@{
ViewBag.Title = "我的企业微信";
Layout = "~/Views/Shared/_content.cshtml";
}
<div class="layui-container" style="padding-left:0px;padding-top:10px;">
<table class="layui-hide" id="tab_kefuzhuangtaiyi1" lay-filter="wochao"></table>
</div>
<!--确定宽度-->
<style type="text/css">
.layui-table-body .layui-table-cell {
height: auto;
line-height: 100px;
}
.HeadImg {
float: left;
}
.leftDiv {
float: left;
width: 500px;
}
.MyUL {
float: left;
padding-left: 20px;
}
.MyUL li {
line-height: 30px;
}
.MyUL2 {
float: right;
padding-left: 10px;
}
.MyUL2 li {
line-height: 30px;
width: 90px;
text-align: right;
}
.leftDiv a:hover {
color: #FF5722;
text-decoration: underline;
}
</style>
<script>
var table;
$(function () {
//var tempwidth = 1410;
//var tempheight = 1115;
//var width = $(window).width();
//var height = Math.ceil(width * (tempheight / tempwidth));
//$("body").height($(window).height() + 150);
//$(window).resize(function () {//自动适应大小
// console.log("resize");
// table.resize('tab_kefuzhuangtaiyi1');
//});
});
</script>
<script>
var needBind ="@Html.Raw(ViewBag.needBind)";
layui.use('laydate', function () {
var laydate = layui.laydate;
//执行一个laydate实例
laydate.render({
elem: '#start' //指定元素
});
//执行一个laydate实例
laydate.render({
elem: '#end' //指定元素
});
});
var selectRow = {};
var winindex;
var layer;
var rowid;
//注意:选项卡 依赖 element 模块,否则无法进行功能性操作
layui.use('element', function () {
var element = layui.element;
element.on('tab(tonghuajiankong)', function (n) {
$(".bodytable").addClass("hidden");
$("#kefuzhuangtai" + (n.index + 1)).removeClass("hidden");
});
element.on('tab(maintab)', function (n) {
if (n.index == 0)
$("#bottomcard").removeClass("hidden");
else
$("#bottomcard").addClass("hidden");
});
});
var machineid='@ViewBag.Machineid';
layui.use(['laypage', 'layer', 'table', 'laydate'], function () {
var laydate = layui.laydate;
layer = layui.layer;
table = layui.table;
table.render({
id: 'listReload'//列表别名ID
,toolbar: '#toolbarDemo' //开启头部工具栏,并为其绑定左侧模板
,defaultToolbar:[]
, elem: '#tab_kefuzhuangtaiyi1'
, url: '/Home/GetWeWorktHtmlList?machineid=@ViewBag.Machineid'
, method: 'POST'
, page: true
, limit: 30
, height: "full-160"
,width:700
,skin: 'line' //行边框风格
,even: true //开启隔行背景
//, size:"sm"
, cols: [[
, { field: 'exinfo',width:690, title: '我的企业微信列表',height:300,templet:function(d){
var html="";
html+="<div class='leftDiv'><a title='进入我的客户,进行筛选!' href=\"CSelectionTag?machineid="+d.machineid+"&userid="+d.userid+"&corpid="+d.corpid+"\"><img src='"+(d.thumb_avatar)+"'width='90' height='90' class='HeadImg'/><ul class='MyUL'>";
html+="<li>企业号:"+d.corpname+"</li>";
html+="<li>昵称:"+d.name+"</li>";
html+="<li>号码:"+d.mobile+"</li>";
html+="</ul></a></div>";
html+="<ul class='MyUL2'>";
html+='<li>&nbsp;</li>';
html+="<li>&nbsp;</li>";
if(d.isdefault==1){
html+= "<li><span style='color:green;'>默认</span>";
}else{
html+="<li><a href='javascript:SetDefault(\""+d.userid+"\",\""+d.corpid+"\");' style='color:#1E9FFF;'>设为默认</a>";
}
html+="&nbsp;&nbsp;<a href='javascript:DisBind(\""+d.userid+"\",\""+d.corpid+"\");' style='color:red;'>删除</a></li>";
html+="</ul>";
return html ;
}
}
]], where: $("#myform").serializeFormJSON()
});
//监听行单击事件单击事件为rowDouble
//table.on('row(wochao)', function (obj) {
// var data = obj.data;
// //console.log(data);
// //标注选中样式
// obj.tr.addClass('self-table-click').siblings().removeClass('self-table-click');
// selectRow = data;
//});
var active = {
add: function () {
winindex = layer.open({
type: 2,
content: 'Bind?machineid=' + machineid,
title: '绑定企业微信',
area: ['500px', '400px']
});
}
, delete: function () {
if (selectRow.userid == "undefined" || selectRow.userid == null) {
layer.msg("请先选中一条记录!", { icon: 7 });
return;
}
layer.confirm('确定解绑吗?', {icon: 3, title:'提示'}, function(index){
var loading = layer.load(0, { shade: true});
$.ajax({
type: "POST",
url: "DisBind",
data:{machineid:machineid,userid:selectRow.userid,corpid:selectRow.corpid} ,
dataType: "json",
success: function (da) {
if (da.result == true) {
layer.msg('操作成功!', { icon: 1 });
TableReload();
} else {
layer.msg(da.retmsg, { icon: 2 });
}
},
error: function () {
layer.msg('操作失败!', { icon: 2 });
}
});
layer.close(loading);
});
},set:function(){
if (selectRow.userid == "undefined" || selectRow.userid == null) {
layer.msg("请先选中一条记录!", { icon: 7 });
return;
}
layer.confirm('确定设为默认吗?', {icon: 3, title:'提示'}, function(index){
var loading = layer.load(0, { shade: true});
$.ajax({
type: "POST",
url: "SetDefault",
data:{machineid:machineid,userid:selectRow.userid,corpid:selectRow.corpid} ,
dataType: "json",
success: function (da) {
if (da.result == true) {
layer.msg('操作成功!', { icon: 1 });
TableReload();
} else {
layer.msg(da.retmsg, { icon: 2 });
}
},
error: function () {
layer.msg('操作失败!', { icon: 2 });
}
});
layer.close(loading);
});
}, search: function () {
var param = $("#myform").serializeFormJSON();
table.reload('listReload', {
page: {
curr: 1 //重新从第 1 页开始
},
where: param
});
}
};
$('.layui-btn').on('click', function () {
var othis = $(this), method = othis.data('method');
console.log(method);
active[method] ? active[method].call(this, othis) : '';
});
if(needBind=="1"){
winindex = layer.open({
type: 2,
content: 'Bind?machineid=' + machineid,
title: '绑定企业微信',
area: ['500px', '400px']
});
}
});
function DisBind(userid,corpid){
layer.confirm('确定解绑吗?', {icon: 3, title:'提示'}, function(index){
var loading = layer.load(0, { shade: true});
$.ajax({
type: "POST",
url: "DisBind",
data:{machineid:machineid,userid:userid,corpid:corpid} ,
dataType: "json",
success: function (da) {
if (da.result == true) {
layer.msg('操作成功!', { icon: 1 });
TableReload();
} else {
layer.msg(da.retmsg, { icon: 2 });
}
},
error: function () {
layer.msg('操作失败!', { icon: 2 });
}
});
layer.close(loading);
});
}
function SetDefault(userid,corpid){
var loading = layer.load(0, { shade: true});
$.ajax({
type: "POST",
url: "SetDefault",
data:{ machineid:machineid,userid:userid,corpid:corpid} ,
dataType: "json",
success: function (da) {
if (da.result == true) {
layer.msg('操作成功!', { icon: 1 });
TableReload();
} else {
layer.msg(da.retmsg, { icon: 2 });
}
},
error: function () {
layer.msg('操作失败!', { icon: 2 });
}
});
layer.close(loading);
}
function Closed() {
layer.close(winindex);
}
function TableReload() {
table.reload('listReload', {
});
}
</script>
<script type="text/html" id="toolbarDemo">
<div class="layui-btn-container">
<input class="layui-btn layui-btn-primary layui-border-blue" data-method="add" type="button" value="+绑定" />
</div>
</script>