TG.WXCRM.V4/WEB/Views/MsgToolTask/Index.cshtml

493 lines
22 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 WX.CRM.WebHelper;
@{
ViewBag.Title = "Index";
Layout = "~/Views/Shared/_content.cshtml";
}
<script src="/Scripts/jquery.easyui.min.js" type="text/javascript"></script>
<link href="/Content/themes/blue/easyui.css" rel="stylesheet" />
<link href="/Content/Site.css" rel="stylesheet" />
<script src="/Scripts/common.js"></script>
<link href="/Content/data_grid_list.css" rel="stylesheet" />
<script src="/Scripts/op/jquery.rewrite.js"></script>
<style type="text/css">
.xm-option {
line-height: 30px;
}
.layui-card {
padding-top: 0px !important;
}
</style>
<!--确定宽度-->
<style>
.layui-form-label {
width: 150px
}
.layui-input-block {
margin-left: 0;
}
.dialogName {
width: 31%;
display: inline-block;
text-align: center;
}
.layui-table-cell {
height: auto !important;
line-height: 28px !important;
}
.myimage {
width: 100px;
padding: 3px 0px;
}
.mydiv {
/*width:250px;*/
}
</style>
<div class="layui-fluid" style="padding-left:0px;padding-top:10px;">
<div class="layui-card" id="topcard" style="width:100%;padding-top:10px;">
<div class="layui-card-header layui-self-header">
<div style="float:left;position:relative;">
群发任务列表
</div>
<div style="float:right;position:relative;">
@*@if (ViewBag.IndexType == 2)
{
<input class="layui-btn layui-btn-sm layui-btn-normal" data-method="other5" type="button" value="详情">
}*@
@Html.Action("ToolBarNew", "Control", new
{
tool = ViewBag.ToolBar as ToolBar,
otherToolBars = new ToolBarNew[] {
new ToolBarNew(){ btnColor="", btnName="复制群发任务" },
new ToolBarNew(){ btnColor="", btnName="转发任务" },
new ToolBarNew(){ btnColor="", btnName="取消任务" },
new ToolBarNew(){ btnColor="", btnName="立即执行" }
}
})
</div>
<div class="hrclass" style="position:relative;float: left;"></div>
</div>
<div class="layui-card-body " id="contentBody">
<form class="layui-form selftopwhere" id="myform">
<div class="layui-form-item">
<div class="layui-inline" style="width:460px;">
@Html.Action("UserSSOComBox", "Control", new { currentRight = WX.CRM.WebHelper.InitRights.CONST_群发任务列表, isSelf = true })
</div>
任务名称:
<div class="layui-inline">
<input type="text" name="PLANNAME" required lay-verify="required" autocomplete="off" class="layui-input">
</div>
创建者:
<div class="layui-inline">
<input type="text" name="CREATOR" required lay-verify="required" autocomplete="off" class="layui-input">
<input type="text" name="IndexType" required lay-verify="required" autocomplete="off" class="layui-input" value="@ViewBag.IndexType" style="display:none">
</div>
创建时间:
<div class="layui-inline">
<input class="layui-input" placeholder="开始日" name="xstime" id="start" style="width:120px;" autocomplete="off">
</div>
<div class="layui-inline">
<input class="layui-input" placeholder="截止日" name="xetime" id="end" style="width:120px;" autocomplete="off">
</div>
@if (ViewBag.IndexType == 1)
{
<label>发送类型</label>
<div class="layui-inline">
<select name="SENDTYPE">
<option value="">全部</option>
<option value="now">立即发布</option>
<option value="tim">定时发布</option>
</select>
</div>
}
发送状态:
<div class="layui-inline">
<select name="STATUS">
<option value="">全部</option>
<option value="0">未执行</option>
<option value="200">进行中</option>
<option value="70">已取消</option>
<option value="220">已完成</option>
<option value="500">执行错误</option>
</select>
</div>
<div class="layui-inline">
<input class="layui-btn layui-btn-sm layui-btn-ok" data-method="search" type="button" value="查询" /><input class="layui-btn layui-btn-sm layui-btn-reset" type="reset" value="清空" />
</div>
</div>
</form>
<table class="layui-hide" id="tab_kefuzhuangtaiyi1" lay-filter="wochao"></table>
</div>
</div>
</div>
<!--确定宽度-->
<script>
//企业号的数据
var table;
$(function () {
});
</script>
<script>
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");
});
});
function OpenExecute(pkid, type) {
winindex = layer.open({
type: 2,
content: '/MsgToolTask/Execute?taskid=' + pkid +'&taskType='+type,
area: ['1048px', '600px']
});
}
function Closed() {
layer.close(winindex);
}
function TableReload() {
table.reload('listReload', {
});
}
function GetIframeHtml(src) {
return "<iframe width='100%' height='98%' scrolling='no' frameborder='0'' src='" + src + "'></iframe>";
}
//替换表情
function replaceFace(cotent) {
if (!cotent)
return cotent;
var face = '@Html.Raw(ViewBag.faceListJson)';
var facelist = face.split(',');
for (var i = 0; i < facelist.length; i++) {
while (cotent.indexOf(facelist[i]) > -1) {
var src = facelist[i].replace("[", "").replace("]", "") + ".png";
cotent = cotent.replace(facelist[i], '<img class="faceClass" src="/Content/Images/icon/msgtool/face/' + src + '" alt="' + facelist[i].replace("[", "").replace("]", "") +'"/>');
}
}
return cotent;
}
function onLoadSucced() {
if (!table) {
layui.use(['laypage', 'layer', 'table', 'laydate', 'form'], function () {
var form = layui.form;
var laydate = layui.laydate;
layer = layui.layer;
table = layui.table;
if (@ViewBag.IndexType == 1) {
table.render({
id: 'listReload'//列表别名ID
, elem: '#tab_kefuzhuangtaiyi1'
, url: 'GetHtmlList'
, method: 'POST'
, cellMinWidth: 80 //全局定义常规单元格的最小宽度layui 2.2.1 新增
, page: true
, limit: 30
, height: "full-160"
, size: "sm"
, cols: [[
{ field: 'PKID', title: '任务id', width: 120 }
, { field: 'Creator', title: '任务发起人', width: 120 }
, { field: 'Receiver', title: '任务接收人', width: 120 }
, { field: 'PlanName', title: '任务名称', width: 120 }
//, { field: 'JsonData', title: '发送内容' }
, {
field: 'JsonData', title: '发送内容', width: 250, templet: function (d) {
var mydata = JSON.parse(d.JsonData);
var html = "";
$(mydata).each(function (aa, bb) {
if (bb.msgtype == "img") {
html += "<div class='mydiv'>" + (aa + 1) + "、<img class='myimage' src='" + bb.content + "'/></div>";
} else if (bb.msgtype == 'file') {
var file = bb.content;
var filename = file.substring(file.lastIndexOf("/") + 1, file.length);
var filename = decodeURI(filename);
html += "<div class='mydiv'>" + (aa + 1) + "、<a href='" + bb.content + "' target='_blank' title='点击查看附件'>" + filename + "</a></div>";
} else {
bb.content = replaceFace(bb.content);
html += "<div class='mydiv'>" + (aa + 1) + "、" + bb.content + "</div>";
}
});
/*return d.JSONDATA*/
return html;
}
}
, { field: 'GroupName', title: '群发对象', width: 150 }
, { field: 'SendTypeName', title: '发送类型', width: 100 }
, { field: 'Count', title: '群发数量', width: 80 }
, { field: 'SuccessCount', title: '成功数', width: 80 }
, { field: 'FailCount', title: '失败数', width: 80 }
, { field: 'StatusName', title: '状态', width: 100, templet: '#statusTpl' }
, { field: 'Remark', title: '备注', width: 120 }
, { field: 'planexetime', title: '预计开始时间', width: 150 }
, { field: 'DUEDATE', title: '截止时间', width: 150 }
, { field: 'ExecTime', title: '执行时间', width: 150 }
, { field: 'ExitTime', title: '执行完成时间', width: 150 }
]], where: $("#myform").serializeFormJSON()
,
done: function (res, curr, count) {
$("#isExe").val("");
$("#fiterUser").val("");
}
});
} else {
table.render({
id: 'listReload'//列表别名ID
, elem: '#tab_kefuzhuangtaiyi1'
, url: 'GetHtmlList'
, method: 'POST'
, cellMinWidth: 80 //全局定义常规单元格的最小宽度layui 2.2.1 新增
, page: true
, limit: 30
, height: "full-160"
, size: "sm"
, cols: [[
{ field: 'PKID', title: '任务id', width: 120 }
, { field: 'Creator', title: '任务发起人', width: 120 }
, { field: 'Receiver', title: '任务接收人', width: 120 }
, { field: 'PlanName', title: '任务名称', width: 120 }
, {
field: 'JsonData', title: '发送内容', width: 250, templet: function (d) {
var mydata = JSON.parse(d.JsonData);
var html = "";
$(mydata).each(function (aa, bb) {
if (bb.msgtype == "img") {
html += "<div class='mydiv'>" + (aa + 1) + "、<img class='myimage' src='" + bb.content + "'/></div>";
} else if (bb.msgtype == 'file') {
var file = bb.content;
var filename = file.substring(file.lastIndexOf("/") + 1, file.length);
var filename = decodeURI(filename);
html += "<div class='mydiv'>" + (aa + 1) + "、<a href='" + bb.content + "' target='_blank' title='点击查看附件'>" + filename + "</a></div>";
} else {
bb.content = replaceFace(bb.content);
html += "<div class='mydiv'>" + (aa + 1) + "、" + bb.content + "</div>";
}
});
return html;
}
}
, { field: 'GroupName', title: '群发对象', width: 120 }
, { field: 'SendTypeName', title: '模式', width: 120 }
, { field: 'Cycle', title: '周期', width: 80 }
, { field: 'CycleNum', title: '循环次数', width: 120 }
, { field: 'Count', title: '群发客户数量', width: 120 }
, { field: 'SuccessCount', title: '成功数', width: 120 }
, { field: 'FailCount', title: '失败', width: 120 }
, { field: 'StatusName', title: '状态', width: 120, templet: '#statusTpl' }
, { field: 'Remark', title: '备注', width: 120 }
, { field: 'planexetime', title: '预计开始时间', width: 150 }
, { field: 'ExecTime', title: '执行时间', width: 150 }
, { field: 'DUEDATE', title: '截止时间', width: 150 }
]], where: $("#myform").serializeFormJSON()
,
done: function (res, curr, count) {
}
});
}
//监听行单击事件单击事件为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;
});
form.on('select(corp_deptid)', function (data) {
console.log(data);
let mydeptid = "";
$(mydata.filter(m => m.corpid == data.value)).each(function (is, sw) {
mydeptid = sw.deptid;
});
$("#deptid").val(mydeptid);
});
function GetWindowInfo() {
var width = $(window).width() * 0.95 ;
var height = $(window).height() * 0.95;
if (width < 1048)
width= 1048;
if (height < 700)
height = 700;
return [width+"px", height+"px"]
}
var active = {
add: function () {
winindex = layer.open({
type: 2,
content:'/MsgToolTask/Add',
area: GetWindowInfo()
});
},
update: function () {
if (selectRow.PKID == "undefined" || selectRow.PKID == null) {
layer.msg("请先选中一条记录!", { icon: 7 });
return;
}
if (selectRow.ReceiverEid != @ViewBag.Eid) {
layer.msg("不能编辑非本人任务!", { icon: 7 });
return;
}
winindex = layer.open({
type: 2,
content: '/MsgToolTask/Add?id=' + selectRow.PKID,
area: GetWindowInfo()
});
},
other1: function () {
if (selectRow.PKID == "undefined" || selectRow.PKID == null) {
layer.msg("请先选中一条记录!", { icon: 7 });
return;
}
winindex = layer.open({
type: 2,
content: '/MsgToolTask/CopyPlan?id=' + selectRow.PKID,
area: GetWindowInfo()
});
},
other2: function () {
if (selectRow.PKID == "undefined" || selectRow.PKID == null) {
layer.msg("请先选中一条记录!", { icon: 7 });
return;
}
layer.msg('todo');
}, other3: function () {
if (selectRow.PKID == "undefined" || selectRow.PKID == null) {
layer.msg("请先选中一条记录!", { icon: 7 });
return;
}
$.ajax({
type: "POST",
url: "CancelTask",
data: { planId: selectRow.PKID },
dataType: "json",
success: function (da) {
if (da.result == true) {
layer.msg(da.retmsg, { icon: 1 });
TableReload();
} else {
layer.msg(da.retmsg, { icon: 2 });
}
},
error: function () {
layer.msg('操作失败!', { icon: 2 });
}
});
},
// 立即执行
other4: function () {
if (selectRow.ReceiverEid != @ViewBag.Eid) {
layer.msg("不能执行非本人任务!", { icon: 7 });
return;
}
if (selectRow.PKID == "undefined" || selectRow.PKID == null) {
layer.msg("请先选中一条记录!", { icon: 7 });
return;
}
$.ajax({
type: "POST",
url: "CreateTask",
data: { planId: selectRow.PKID },
dataType: "json",
success: function (da) {
debugger
if (da.result == true) {
winindex = layer.open({
type: 2,
content: '/MsgToolTask/Execute?taskid=' + selectRow.PKID + '&taskType=' + 1,
area: ['1048px', '600px']
});
} else {
if (da.retmsg != "" && da.retmsg != null) {
layer.msg(da.retmsg, { icon: 2 });
} else {
winindex = layer.open({
type: 2,
content: '/MsgToolTask/Execute?taskid=' + selectRow.PKID,
area: ['1048px', '600px']
});
}
}
},
error: function () {
layer.msg('操作失败!', { icon: 2 });
}
});
}, search: function () {
var param = $("#myform").serializeFormJSON();
table.reload('listReload', {
where: param,
page: {
curr: 1
}
});
}
};
$('.layui-btn').on('click', function () {
var othis = $(this), method = othis.data('method');
console.log(method);
active[method] ? active[method].call(this, othis) : '';
});
});
} else {
var param = $("#myform").serializeFormJSON();
table.reload('listReload', {
where: param,
page: {
curr: 1
}
});
}
}
</script>
<script type="text/html" id="statusTpl">
{{# if(d.StatusName == '执行错误'){ }}
<span style="color: red; font-weight: 900;"> {{ d.StatusName }}</span>
{{# } else if(d.StatusName == '已完成') { }}
<span style="color: green;font-weight:900;"> {{ d.StatusName }}</span>
{{# } else if(d.StatusName == '进行中') { }}
<span style="color:orange;font-weight:900; "> {{ d.StatusName }}</span>
{{# } else if(d.StatusName == '未执行') { }}
<span style="font-weight:900;"> {{ d.StatusName }}</span>
{{# } else { }}
<span style="font-weight:900;"> {{ d.StatusName }}</span>
{{# } }}
</script>