304 lines
11 KiB
Plaintext
304 lines
11 KiB
Plaintext
@model WX.CRM.Model.Entity.TemplateListModel
|
|
@{ ViewBag.Title = "Edit";
|
|
Layout = "~/Views/Shared/_form.cshtml";
|
|
}
|
|
@{
|
|
string isok = ViewBag.isOk == null ? "1" : Convert.ToString(ViewBag.isOk);
|
|
}
|
|
<script>
|
|
var isOk = "@Html.Raw(isok)";
|
|
</script>
|
|
<div class="layui-form-item" style="margin-top:20px;">
|
|
<label class="layui-form-label">
|
|
业务线
|
|
</label>
|
|
<div class="layui-input-block my_form_iterm">
|
|
<select name="DeptId" id="DeptId" lay-verify="required" lay-filter="deptid" style="height: 35px; width: 80%">
|
|
@foreach (var item in ViewBag.deptList as List<SelectListItem>)
|
|
{
|
|
<option value="@item.Value">@item.Text</option>
|
|
}
|
|
</select>
|
|
</div>
|
|
</div>
|
|
<div class="layui-form-item" style="margin-top:20px;">
|
|
<label class="layui-form-label">
|
|
选择人员
|
|
</label>
|
|
<div class="layui-input-block my_form_iterm">
|
|
<div id="Participant" style="width: 100%; display: flex;">
|
|
<input onclick="importEmployee()" type="button" class="layui-btn layui-btn-sm layui-border-blue" value="一键导入" style="line-height: 36px; height: 36px;margin-left:1%;width:15%">
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
<div class="layui-form-item" style="margin-top:20px;">
|
|
<label class="layui-form-label">
|
|
模板
|
|
</label>
|
|
<div class="layui-input-block my_form_iterm" >
|
|
<div style="width: 100%; display: flex;">
|
|
<select name="templateId" id="templateId" lay-filter="templateId" onchange="changeTemplate">
|
|
</select>
|
|
<input onclick="EditTemplate()" type="button" class="layui-btn layui-btn-sm layui-border-blue" value="预警模板管理" style="line-height: 36px; height: 36px; margin-left: 1%; width: 15%">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="layui-form-item" style="margin-top:20px;" id="MaxText">
|
|
<label class="layui-form-label">
|
|
最大资源量
|
|
</label>
|
|
<div class="layui-input-block my_form_iterm">
|
|
<input disabled type="text" name="MaxNum" id="MaxNum" lay-verify="number" autocomplete="off" class="layui-input layui-disabled" />
|
|
</div>
|
|
</div>
|
|
<div class="layui-form-item">
|
|
<div class="layui-input-block my_form_iterm">
|
|
<button class="layui-btn layui-btn-ok" lay-submit lay-filter="formDemo">保存</button>
|
|
</div>
|
|
</div>
|
|
@if (isok == "0")
|
|
{
|
|
<div class="layui-form-item">
|
|
<label class="layui-form-label erro_msg">错误提示:</label>
|
|
<div class="layui-input-block my_form_iterm erro_msg">
|
|
@Html.Raw(ViewBag.Msg)
|
|
</div>
|
|
</div>
|
|
}
|
|
<script src="~/Scripts/layui_ext/xm-select/xm-select.js"></script>
|
|
<script>
|
|
var winindex;
|
|
var participantTree;
|
|
var form;
|
|
var participantIds = [];
|
|
layui.config({
|
|
base: '../Scripts/layui_ext/',
|
|
}).extend({
|
|
selectInput: 'selectInput/selectInput'
|
|
}).use(['table', 'laydate', 'upload', 'flow', 'element', 'form', 'selectInput'], function () {
|
|
var $ = layui.jquery
|
|
, upload = layui.upload
|
|
, element = layui.element
|
|
, layer = layui.layer
|
|
, form = layui.form
|
|
, selectInput = layui.selectInput;
|
|
element = layui.element;
|
|
var laydate = layui.laydate;
|
|
|
|
laydate.render({
|
|
elem: '#BeginTime'
|
|
, type: 'datetime'
|
|
, format: 'yyyy-MM-dd HH:mm',
|
|
});
|
|
init(@Html.Raw(ViewBag.deptid));
|
|
})
|
|
layui.use('form', function () {
|
|
form = layui.form;
|
|
form.verify({
|
|
number: function (value) { }
|
|
});
|
|
$("#MaxText").hide();
|
|
var layer = layui.layer;
|
|
var type = "@Html.Raw(ViewBag.type)";
|
|
//监听提交
|
|
form.on('submit(formDemo)', function (data) {
|
|
var eid = '@ViewBag.eid';
|
|
var postData = {
|
|
Participant: data.field.Participant,
|
|
templateId: data.field.templateId,
|
|
MaxNum: data.field.MaxNum,
|
|
DeptId: data.field.DeptId,
|
|
}
|
|
if (isOk == "1") {
|
|
$.ajax({
|
|
type: "POST",
|
|
url: "EditWarnSetting",
|
|
data: JSON.stringify(data.field),
|
|
dataType: "json",
|
|
contentType: "application/json",
|
|
success: function (da) {
|
|
if (da.result == true) {
|
|
layer.msg("操作成功", { icon: 1 });
|
|
parent.frameReturnByClose();
|
|
parent.frameReturnByReload();
|
|
//init(data.field.DeptId);
|
|
} else {
|
|
layer.msg(da.retmsg, { icon: 2 });
|
|
}
|
|
},
|
|
error: function () {
|
|
layer.msg('操作失败!', { icon: 2 });
|
|
}
|
|
});
|
|
return false;
|
|
} else {
|
|
layer.msg('系统错误!请关闭编辑页重试!', { icon: 2 });
|
|
return false;
|
|
}
|
|
});
|
|
//各种基于事件的操作,下面会有进一步介绍
|
|
|
|
form.on('select(deptid)', function (data) {
|
|
init(data.value);
|
|
});
|
|
|
|
form.on('select(templateId)', function (data) {
|
|
console.log(data.value);
|
|
$.ajax({
|
|
type: "GET",
|
|
url: '/WxResourceReport/GetTemplateJson?id=' + data.value,
|
|
success: function (da) {
|
|
$("#MaxNum").val(da.data.Maxnum);
|
|
}
|
|
});
|
|
if (data.value == '') {
|
|
$("#MaxNum").val('');
|
|
form.verify({
|
|
number: function (value) { }
|
|
});
|
|
$("#MaxText").hide();
|
|
} else {
|
|
form.verify({
|
|
number: function (e) { if (!e || isNaN(e)) return "只能填写数字" }
|
|
});
|
|
$("#MaxText").show();
|
|
}
|
|
})
|
|
});
|
|
function addEid(addEid) {
|
|
if (addEid != null && addEid != undefined) {
|
|
var result = addEid.split(",");
|
|
var addids = participantIds;
|
|
for (var i = 0; i < result.length; i++) {
|
|
if (participantIds.indexOf(result[i]) == -1) {
|
|
addids.push(result[i]);
|
|
}
|
|
}
|
|
}
|
|
Closed();
|
|
renderSelectParticipant(participantTree, addids);
|
|
changePeople();
|
|
}
|
|
function Closed() {
|
|
layer.close(winindex);
|
|
}
|
|
function init(deptid) {
|
|
$.ajax({
|
|
type: "GET",
|
|
url: '@Html.Raw(ViewBag.webapi + "Api/Warnning/GetWarnSetting?deptid=")' + deptid,
|
|
success: function (da) {
|
|
//document.getElementById("Id").value = da.data.id;
|
|
$.ajax({
|
|
type: "GET",
|
|
url: '/Inneruser/GetInneruserTree',
|
|
success: function (da1) {
|
|
participantTree = $.extend(true, [], da1);
|
|
da.data.participantIds = [];
|
|
renderSelectParticipant(participantTree, []);
|
|
$("#templateId").empty();
|
|
$('#templateId').append(new Option("无", ""));// 下拉菜单里添加元素
|
|
$.each(da.data.template, function (index, value) {
|
|
// console.log(value.department_id);
|
|
$('#templateId').append(new Option(value.templateName, value.id, value.selected));// 下拉菜单里添加元素
|
|
});
|
|
layui.form.render("select");//重新渲染 固定写法
|
|
//renderSelectChannel(da.data.channelList);
|
|
}
|
|
});
|
|
}
|
|
});
|
|
}
|
|
function renderSelectParticipant(participantTree, check) {
|
|
var optionsParticipant = {
|
|
el: '#Participant',
|
|
name: 'Participant',//表单的name属性
|
|
//clickClose: true, //单选完关闭下拉框
|
|
filterable: true, //搜索
|
|
direction: 'down', // 展开方向 下
|
|
//radio: false, //单选
|
|
height: '400px',
|
|
tree: {
|
|
show: true,
|
|
showFolderIcon: true,
|
|
showLine: true,
|
|
expandedKeys: true
|
|
},
|
|
toolbar: {//工具条,全选,清空,反选,自定义
|
|
show: true,
|
|
list: [
|
|
'CLEAR'
|
|
]
|
|
},
|
|
on: function (data) {
|
|
var addids = [];
|
|
for (var i = 0; i < data.arr.length; i++) {
|
|
addids.push(data.arr[i].value);
|
|
}
|
|
participantIds = addids;
|
|
changePeople();
|
|
},
|
|
data: participantTree,
|
|
initValue: check
|
|
};
|
|
var selectParticipant = xmSelect.render(optionsParticipant);
|
|
return selectParticipant;
|
|
}
|
|
function importEmployee() {
|
|
winindex = layer.open({
|
|
title: '一键导入客服',
|
|
type: 2,
|
|
content: '/WxResourceReport/ImportEmployee',
|
|
area: ['650px', '550px']
|
|
});
|
|
}
|
|
function EditTemplate() {
|
|
winindex = layer.open({
|
|
title: '模板管理',
|
|
type: 2,
|
|
content: '/WxResourceReport/TemplateList',
|
|
area: ['1000px', '750px']
|
|
, cancel: function () {
|
|
changePeople();
|
|
}
|
|
});
|
|
}
|
|
|
|
function changePeople() {
|
|
var deptId = $("#DeptId").val();
|
|
var eidList = "";
|
|
for (var i = 0; i < participantIds.length; i++) {
|
|
eidList += participantIds[i]+","
|
|
}
|
|
eidList = eidList.substr(0, eidList.length - 1)
|
|
$.ajax({
|
|
type: "GET",
|
|
url: '@Html.Raw(ViewBag.webapi + "Api/Warnning/GetWarnSetting?EidList=")' + eidList +'&deptId=' +deptId,
|
|
success: function (da) {
|
|
$("#templateId").empty();
|
|
$('#templateId').append(new Option("无", ""));
|
|
$.each(da.data.template, function (index, value) {
|
|
// console.log(value.department_id);
|
|
$('#templateId').append(new Option(value.templateName, value.id, selected = value.selected));// 下拉菜单里添加元素
|
|
if (value.selected) {
|
|
document.getElementById("templateId").value = value.id;
|
|
}
|
|
});
|
|
if ($("#templateId").val() == '') {
|
|
$("#MaxNum").val('');
|
|
form.verify({
|
|
number: function (value) { }
|
|
});
|
|
$("#MaxText").hide();
|
|
} else {
|
|
$("#MaxNum").val(da.data.maxNum);
|
|
$("#MaxText").show();
|
|
}
|
|
layui.form.render("select");//重新渲染 固定写法
|
|
}
|
|
});
|
|
}
|
|
</script>
|
|
|
|
|