2021-11-08 20:28:13 +08:00
<!doctype html>
< html xmlns:th = "http://www.thymeleaf.org" xmlns = "http://www.w3.org/1999/html" >
< head >
< base th:href = "${#request.getContextPath() + '/'}" >
< meta charset = "utf-8" >
< meta name = "renderer" content = "webkit" >
< meta http-equiv = "X-UA-Compatible" content = "IE=edge,chrome=1" >
< meta name = "viewport" content = "width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0" >
< link rel = "stylesheet" href = "assets/fonts/font-awesome/css/font-awesome.css" / >
< link rel = "stylesheet" href = "assets/layuiadmin/layui/css/layui.css" media = "all" >
< link rel = "stylesheet" href = "assets/layuiadmin/style/admin.css" media = "all" >
< link rel = "stylesheet" type = "text/css" href = "assets/js/vendor/viewer/viewer.min.css" >
< / head >
< body >
< div class = "layui-fluid layui-anim layui-anim-fadein" >
< div class = "layui-card" >
< div class = "layui-card-header" >
< span class = "layui-breadcrumb" lay-filter = "breadcrumb" style = "visibility: visible;" >
< a class = "close" href = "javascript:void(0);" > 上级列表< / a > < span lay-separator = "" > /< / span >
< a href = "javascript:void(0);" > < cite > 新增内容< / cite > < / a >
< / span >
< / div >
< div class = "layui-card-body" style = "padding: 15px;" >
< form class = "layui-form layui-form-pane" lay-filter = "dataForm" >
< div class = "layui-form-item" >
< label class = "layui-form-label" > 名称< / label >
< div class = "layui-input-block" >
< input type = "text" id = "distributeTitle" name = "distributeTitle" class = "layui-input" value = "" placeholder = "请输入名称" maxlength = "255" >
< / div >
< / div >
< div class = "layui-form-item layui-form-text" >
< label class = "layui-form-label" > 描述< / label >
< div class = "layui-input-block" >
< textarea id = "distributeSummary" name = "distributeSummary" class = "layui-textarea" placeholder = "请输入描述" > < / textarea >
< / div >
< / div >
< div class = "layui-form-item" pane >
< label class = "layui-form-label" > 下派类型< / label >
< div class = "layui-input-block" >
< input type = "radio" name = "distributeType" lay-filter = "distributeType" value = "自动下派" title = "自动下派" checked >
< input type = "radio" name = "distributeType" lay-filter = "distributeType" value = "手动下派" title = "手动下派" >
< input type = "radio" name = "distributeType" lay-filter = "distributeType" value = "立即下派" title = "立即下派" >
< / div >
< / div >
< div class = "layui-form-item" id = "distributeTimeDiv" >
< label class = "layui-form-label" > 下派时间< / label >
< div class = "layui-input-block" >
< input type = "text" id = "distributeTime" name = "distributeTime" class = "layui-input" value = "" placeholder = "请输入下派时间" maxlength = "20" readonly >
< / div >
< / div >
< div class = "layui-form-item layui-row" >
< div class = "layui-col-lg6" >
< label class = "layui-form-label" style = "width: 146px;" > 即将超时天数限制< / label >
< div class = "layui-input-block" style = "margin-left: 146px;" >
< input type = "number" id = "days" name = "days" class = "layui-input" value = "" placeholder = "请输入即将超时天数限制(正整数)" lay-verify = "required|integer" >
< / div >
< / div >
< div class = "layui-col-lg6" >
< label class = "layui-form-label" style = "width: 146px;" > 即将超时小时限制< / label >
< div class = "layui-input-block" style = "margin-left: 146px;" >
< input type = "number" id = "hours" name = "hours" class = "layui-input" value = "" placeholder = "请输入即将超时小时限制(正整数)" lay-verify = "required|integer" >
< / div >
< / div >
< / div >
< div class = "layui-form-item" >
< label class = "layui-form-label" > 下派模板< / label >
< div class = "layui-input-block" >
< input type = "text" id = "taskTemplate" name = "taskTemplate" class = "layui-input" value = "" placeholder = "请输入下派模板" readonly maxlength = "36" >
< / div >
< div id = "templateTableDiv" >
< table class = "layui-hide" id = "templateTable" lay-data = "{height: 'full-200', cellMinWidth: 80, page: false'}" lay-filter = "templateTable" > < / table >
< script type = "text/html" id = "barDemo" >
< a class = "layui-btn layui-btn-xs layui-btn-danger" lay-event = "delete" > 删除< / a >
< / script >
< / div >
< / div >
< div class = "layui-form-item" id = "randomCountDiv" style = "display: none;" >
< label class = "layui-form-label" > 单随机数量< / label >
< div class = "layui-col-md4" >
< input type = "number" id = "randomCount" name = "randomCount" style = "width: 122%;" class = "layui-input" value = "0" placeholder = "请输入单随机数量" >
< / div >
< div class = "layui-col-md4" style = "margin-left: 7.5%;width: 42.3%;" >
< select name = "randomType" id = "randomType" lay-filter = "randomType" style = "width: 100%;" >
< option value = "" > 请选择随机类型< / option >
< option value = "0" > 巡查事项< / option >
< option value = "1" > 任务接收人< / option >
< / select >
< / div >
< div class = "layui-col-md2" style = "margin-left: -15%;" >
< button type = "button" style = "margin-left: 91%;" class = "layui-btn" id = "startRandom" lay-filter = "startRandom" > 开始随机< / button >
< / div >
< / div >
< div class = "layui-form-item" style = "display: none;" id = "randomBusinessDataDiv" >
< fieldset class = "layui-elem-field" style = "border:1px solid red;" >
< legend > 单随机-巡查事项< / legend >
< div class = "layui-field-box" id = "randomBusinessLegendDiv" >
< / div >
< / fieldset >
< / div >
< div class = "layui-form-item" style = "display: none;" id = "randomBusinessUserDataDiv" >
< fieldset class = "layui-elem-field" style = "border:1px solid red;" >
< legend > 单随机-任务接收人< / legend >
< div class = "layui-field-box" id = "randomBusinessUserLegendDiv" >
< / div >
< / fieldset >
< / div >
< span style = "color: red;font-size: 14px;margin-left: 9%;" > *选择下派模板,判断模板中任务频率,若为单次,截止日期为一条,若为多次,截止日期为多条< / span >
< div class = "layui-form-item" >
< label class = "layui-form-label" > 截止时间< / label >
< div class = "layui-input-block" >
< input type = "text" id = "distributeDeadline" name = "distributeDeadline" class = "layui-input" value = "" placeholder = "请输入截至时间" maxlength = "20" readonly >
< / div >
< div id = "deadlineDiv" >
< table class = "layui-hide" id = "deadlineTable" lay-data = "{height: 'full-200', cellMinWidth: 80, page: false'}" lay-filter = "deadlineTable" > < / table >
< script type = "text/html" id = "deadline" >
< a class = "layui-btn layui-btn-xs layui-btn-danger" lay-event = "delete" > 删除< / a >
< / script >
< / div >
< / div >
< div class = "layui-form-item" id = "businessDiv" style = "display: none;" >
< label class = "layui-form-label" > 巡查事项< / label >
< div class = "layui-input-block layui-form" id = "businessSelectTemplateBox" lay-filter = "businessSelectTemplateBox" > < / div >
< script id = "businessSelectTemplate" type = "text/html" >
2021-11-17 15:23:27 +08:00
< select id = "business" name = "business" lay-filter = "business" >
2021-11-08 20:28:13 +08:00
< option value = "" > 请选择巡查事项< / option >
{{# for(var i = 0, item; item = d[i++];) { }}
< option value = "{{item.businessId}},{{item.businessSummary}}" > {{item.businessName}}< / option >
{{# } }}
< / select >
< / script >
< / div >
< div class = "layui-form-item" id = "businessDataDivDiv" style = "display: none;" >
< label class = "layui-form-label" > 事项列表< / label >
< div class = "layui-input-block" >
< input type = "text" id = "businessData" name = "businessData" class = "layui-input" value = "" placeholder = "点击选择事项列表" maxlength = "20" readonly >
< / div >
< div id = "businessDataDiv" >
< table class = "layui-hide" id = "businessDataTable" lay-data = "{height: 'full-200', cellMinWidth: 80, page: false'}" lay-filter = "businessDataTable" > < / table >
< script type = "text/html" id = "businessDataDel" >
< a class = "layui-btn layui-btn-xs layui-btn-danger" lay-event = "delete" > 删除< / a >
< / script >
< / div >
< / div >
< div class = "layui-form-item" id = "receiverUserDivDiv" style = "display: none;" >
< label class = "layui-form-label" > 接收人< / label >
< div class = "layui-input-block" >
< input type = "text" id = "receiverUser" name = "receiverUser" class = "layui-input" value = "" placeholder = "点击选择任务接收人" maxlength = "20" readonly >
< / div >
< div id = "receiverUserDiv" >
< table class = "layui-hide" id = "receiverUserTable" lay-data = "{height: 'full-200', cellMinWidth: 80, page: false'}" lay-filter = "receiverUserTable" > < / table >
< script type = "text/html" id = "receiver" >
< a class = "layui-btn layui-btn-xs layui-btn-danger" lay-event = "delete" > 删除< / a >
< / script >
< / div >
< / div >
< div class = "layui-form-item" >
< label class = "layui-form-label" > 紧急等级< / label >
< div class = "layui-input-block layui-form" id = "urgentLevelSelectTemplateBox" lay-filter = "urgentLevelSelectTemplateBox" > < / div >
< script id = "urgentLevelSelectTemplate" type = "text/html" >
< select id = "urgentLevel" name = "urgentLevel" lay-filter = "urgentLevel" lay-verify = "required" >
< option value = "" > 请选择紧急等级< / option >
{{# for(var i = 0, item; item = d[i++];) { }}
< option value = "{{item.dataId}}" > {{item.dataName}}< / option >
{{# } }}
< / select >
< / script >
< / div >
< div class = "layui-form-item" >
< label class = "layui-form-label" > 上报次数< / label >
< div class = "layui-input-block" >
< input type = "number" id = "reportCount" name = "reportCount" class = "layui-input" value = "0" placeholder = "请输入上报次数" lay-verify = "required" >
< / div >
< / div >
<!-- 一级区域 -->
< div class = "layui-form-item" id = "area1Div" >
< label class = "layui-form-label" style = "width: 150px;" > 任务一级地区名称< / label >
< input type = "hidden" id = "taskArea1Id" name = "taskArea1Id" class = "layui-input" value = "" placeholder = "请输入任务一级地区ID" maxlength = "36" >
< input type = "hidden" id = "taskArea1Code" name = "taskArea1Code" class = "layui-input" value = "" placeholder = "请输入任务一级地区编码" maxlength = "255" >
< input type = "hidden" id = "taskArea1Name" name = "taskArea1Name" class = "layui-input" value = "" placeholder = "请输入任务一级地区名称" maxlength = "255" >
< div class = "layui-input-block layui-form" id = "taskArea1NameSelectTemplateBox" lay-filter = "taskArea1NameSelectTemplateBox" style = "margin-left: 150px;" > < / div >
< script id = "taskArea1NameSelectTemplate" type = "text/html" >
< select id = "taskArea1" name = "taskArea1" lay-filter = "taskArea1Name" >
< option value = "" > 请选择一级地区名称< / option >
{{# for(var i = 0, item; item = d[i++];) { }}
< option value = "{{item.areaId}},{{item.areaCode}},{{item.areaLng}},{{item.areaLat}},{{item.areaName}}" > {{item.areaName}}< / option >
{{# } }}
< / select >
< / script >
< / div >
<!-- 二级区域 -->
< div class = "layui-form-item" id = "area2Div" >
< label class = "layui-form-label" style = "width: 150px;" > 任务二级地区名称< / label >
< input type = "hidden" id = "taskArea2Id" name = "taskArea2Id" class = "layui-input" value = "" placeholder = "请输入任务二级地区ID" maxlength = "36" >
< input type = "hidden" id = "taskArea2Code" name = "taskArea2Code" class = "layui-input" value = "" placeholder = "请输入任务二级地区编码" maxlength = "255" >
< input type = "hidden" id = "taskArea2Name" name = "taskArea2Name" class = "layui-input" value = "" placeholder = "请输入任务二级地区名称" maxlength = "255" >
< div class = "layui-input-block layui-form" id = "taskArea2NameSelectTemplateBox" lay-filter = "taskArea2NameSelectTemplateBox" style = "margin-left: 150px;" > < / div >
< script id = "taskArea2NameSelectTemplate" type = "text/html" >
< select id = "taskArea2" name = "taskArea2" lay-filter = "taskArea2Name" >
< option value = "" > 请选择二级地区名称< / option >
{{# for(var i = 0, item; item = d[i++];) { }}
< option value = "{{item.areaId}},{{item.areaCode}},{{item.areaLng}},{{item.areaLat}},{{item.areaName}}" > {{item.areaName}}< / option >
{{# } }}
< / select >
< / script >
< / div >
<!-- 三级区域 -->
< div class = "layui-form-item" id = "area3Div" >
< label class = "layui-form-label" style = "width: 150px;" > 任务三级地区名称< / label >
< input type = "hidden" id = "taskArea3Id" name = "taskArea3Id" class = "layui-input" value = "" placeholder = "请输入任务三级地区ID" maxlength = "36" >
< input type = "hidden" id = "taskArea3Code" name = "taskArea3Code" class = "layui-input" value = "" placeholder = "请输入任务三级地区编码" maxlength = "255" >
< input type = "hidden" id = "taskArea3Name" name = "taskArea3Name" class = "layui-input" value = "" placeholder = "请输入任务三级地区名称" maxlength = "255" >
< div class = "layui-input-block layui-form" id = "taskArea3NameSelectTemplateBox" lay-filter = "taskArea3NameSelectTemplateBox" style = "margin-left: 150px;" > < / div >
< script id = "taskArea3NameSelectTemplate" type = "text/html" >
< select id = "taskArea3" name = "taskArea3" lay-filter = "taskArea3Name" >
< option value = "" > 请选择三级地区名称< / option >
{{# for(var i = 0, item; item = d[i++];) { }}
< option value = "{{item.areaId}},{{item.areaCode}},{{item.areaLng}},{{item.areaLat}},{{item.areaName}}" > {{item.areaName}}< / option >
{{# } }}
< / select >
< / script >
< / div >
<!-- 四级区域 -->
< div class = "layui-form-item" id = "area4Div" >
< label class = "layui-form-label" style = "width: 150px;" > 任务四级地区名称< / label >
< input type = "hidden" id = "taskArea4Id" name = "taskArea4Id" class = "layui-input" value = "" placeholder = "请输入任务四级地区编码" maxlength = "255" >
< input type = "hidden" id = "taskArea4Code" name = "taskArea4Code" class = "layui-input" value = "" placeholder = "请输入任务四级地区编码" maxlength = "255" >
< input type = "hidden" id = "taskArea4Name" name = "taskArea4Name" class = "layui-input" value = "" placeholder = "请输入任务四级地区名称" maxlength = "255" >
< div class = "layui-input-block layui-form" id = "taskArea4NameSelectTemplateBox" lay-filter = "taskArea4NameSelectTemplateBox" style = "margin-left: 150px;" > < / div >
< script id = "taskArea4NameSelectTemplate" type = "text/html" >
< select id = "taskArea4" name = "taskArea4" lay-filter = "taskArea4Name" >
< option value = "" > 请选择四级地区名称< / option >
{{# for(var i = 0, item; item = d[i++];) { }}
< option value = "{{item.areaId}},{{item.areaCode}},{{item.areaLng}},{{item.areaLat}},{{item.areaName}}" > {{item.areaName}}< / option >
{{# } }}
< / select >
< / script >
< / div >
<!-- 五级区域 -->
2021-11-30 17:40:20 +08:00
<!-- <div class="layui - form - item" id="area5Div">
2021-11-08 20:28:13 +08:00
< label class = "layui-form-label" style = "width: 150px;" > 任务五级地区名称< / label >
< input type = "hidden" id = "taskArea5Id" name = "taskArea5Id" class = "layui-input" value = "" placeholder = "请输入任务五级地区ID" maxlength = "36" >
< input type = "hidden" id = "taskArea5Code" name = "taskArea5Code" class = "layui-input" value = "" placeholder = "请输入任务五级地区编码" maxlength = "255" >
< input type = "hidden" id = "taskArea5Name" name = "taskArea5Name" class = "layui-input" value = "" placeholder = "请输入任务五级地区名称" maxlength = "255" >
< div class = "layui-input-block layui-form" id = "taskArea5NameSelectTemplateBox" lay-filter = "taskArea5NameSelectTemplateBox" style = "margin-left: 150px;" > < / div >
< script id = "taskArea5NameSelectTemplate" type = "text/html" >
< select id = "taskArea5" name = "taskArea5" lay-filter = "taskArea5Name" >
< option value = "" > 请选择五级地区名称< / option >
{{# for(var i = 0, item; item = d[i++];) { }}
< option value = "{{item.areaId}},{{item.areaCode}},{{item.areaLng}},{{item.areaLat}},{{item.areaName}}" > {{item.areaName}}< / option >
{{# } }}
< / select >
< / script >
2021-11-30 17:40:20 +08:00
< / div > -->
2021-11-08 20:28:13 +08:00
< div class = "layui-form-item" >
< label class = "layui-form-label" > 任务地点< / label >
< div class = "layui-input-block" >
< input type = "text" id = "missionLocation" name = "missionLocation" class = "layui-input" value = "" placeholder = "请输入任务地点" maxlength = "500" >
< / div >
< / div >
< div class = "layui-form-item" >
< label class = "layui-form-label" style = "width: 120px;" > 任务地点经度< / label >
< div class = "layui-input-block" style = "margin-left: 120px;" >
< input type = "text" id = "missionLocationLng" name = "missionLocationLng" class = "layui-input" value = "" placeholder = "请输入任务地点精度" maxlength = "255" >
< / div >
< / div >
< div class = "layui-form-item" >
2021-11-17 15:26:22 +08:00
< label class = "layui-form-label" style = "width: 120px;" > 任务地点纬度< / label >
2021-11-08 20:28:13 +08:00
< div class = "layui-input-block" style = "margin-left: 120px;" >
< input type = "text" id = "missionLocationLat" name = "missionLocationLat" class = "layui-input" value = "" placeholder = "请输入任务地点维度" maxlength = "255" >
< / div >
< / div >
< div class = "layui-row" id = "mapDiv" style = "display: none;" >
< div class = "layui-col-md12 layui-col-sm12" style = "padding: 0 0px;" >
< div id = "mapContainer" style = "width: 100%;height: 350px;" > < / div >
< / div >
< / div >
< div class = "layui-form-item layui-layout-admin" >
< div class = "layui-input-block" >
< div class = "layui-footer" style = "left: 0;" >
< button type = "button" class = "layui-btn" lay-submit lay-filter = "submitForm" > 提交新增< / button >
< button type = "button" class = "layui-btn layui-btn-primary close" > 返回上级< / button >
< / div >
< / div >
< / div >
< / form >
< / div >
< / div >
< / div >
< script type = "text/javascript" src = "http://api.map.baidu.com/api?v=3.0&ak=oWU9RD4ihDHAafexgI6XOrTK8lDatRju" > < / script >
< script src = "assets/js/vendor/wangEditor/wangEditor.min.js" > < / script >
< script src = "assets/js/vendor/ckplayer/ckplayer/ckplayer.js" > < / script >
< script src = "assets/js/vendor/viewer/viewer.min.js" > < / script >
< script src = "assets/layuiadmin/layui/layui.js" > < / script >
< script >
layui.config({
base: 'assets/layuiadmin/' //静态资源所在路径
}).extend({
index: 'lib/index' //主入口模块
}).use(['index', 'form', 'table', 'laydate', 'laytpl'], function(){
var $ = layui.$;
var form = layui.form;
var laytpl = layui.laytpl;
var laydate = layui.laydate;
var table = layui.table;
var templateObj = {};
// 任务清单列表
var listList = [];
// 任务频率类型
var taskRate = '';
// 模板类型(固定任务、单随机任务、双随机任务)
var templateType = '';
// 任务模板中任务上报次数
var reportCount = '';
// 截止日期列表
// 选择下派模板,判断模板中任务频率,若为单次,截止日期为一条,若为多次,截止日期为多条
// 未选择下派模板:截止日期仅一条
var deadlineList = [];
// 任务接收人列表
var receiverUserList = [];
// 巡查事项集合
var businessDataList = [];
// 事项集合
var matterList = [];
// 随机事件数据集合
var randomList = [];
2021-11-10 18:03:51 +08:00
// 记录随机数量
var randomCountCount = 0;
2021-11-08 20:28:13 +08:00
form.verify({
integer: [
/^[0-9]\d*$/
, '只能输入正整数'
]
});
/**
* 任务创建表单中,有个影响任务的选择,任务模板(下派模板)
* 选择下派模板:任务清单以模板为主
*/
// 巡查事项change事件
form.on('select(business)', function(data){
if(!data.value) {
}else {
var valueArr = data.value.split(',');
if(2 == valueArr.length) {
$('#receiverUserDivDiv').show();
$('#businessDataDivDiv').show();
}else {
$('#receiverUserDivDiv').hide();
$('#businessDataDivDiv').hide();
}
}
form.render("select");
});
// 通过巡查事项所配置的信息(业务描述)来进行业务分拨处理
function getDataList(summary) {
top.dialog.open({
title: '选择巡查数据',
url: top.restAjax.path('route/business/' + summary, []),
width: '1040px',
height: '98%',
onClose: function () {
if(top.dialog.dialogData.selectedDataArray.length > 0) {
matterList = top.dialog.dialogData.selectedDataArray;
}
$.unique(matterList);
if(matterList.length > 0) {
$('#businessDataDiv').show();
initMatterTable(matterList);
}
}
})
}
function initMatterTable(row) {
table.render({
elem: '#businessDataTable'
,cols: [
[
,{field: 'matterId', title: 'matterId', hide: true}
,{field: 'name', title: '事项名称', width: 300}
,{field: 'man', title: '负责人', width: 200}
,{field: 'phone', title: '联系方式', width: 200}
,{field: 'time', title: '时间', width: 200}
,{fixed: '', title:'操作', width: 119, align:'center', toolbar: '#receiver'}
]
]
,data: row
});
reloadMatterTable();
}
function reloadMatterTable() {
table.reload('businessDataTable', {});
}
//监听行工具事件
table.on('tool(businessDataTable)', function(obj){
var data = obj.data
,layEvent = obj.event;
if(layEvent === 'delete'){
layer.confirm('真的删除行么', function(index){
obj.del();
layer.close(index);
var i = 0;
for (;i < matterList.length ; i + + ) {
if (data.userId == matterList[i].userId) {
break;
}
}
matterList.splice(i, 1);
if(0 == matterList.length) {
$('#businessDataDiv').hide();
}
});
}
});
// 通过巡查事项ID来查找对应的人员列表
function initBusinessUser(businessId) {
top.dialog.open({
title: '选择人员',
url: top.restAjax.path('route/business/list-user?businessId={businessId}', [businessId]),
width: '1040px',
height: '98%',
onClose: function () {
if(top.dialog.dialogData.selectedUserArray.length > 0) {
receiverUserList = top.dialog.dialogData.selectedUserArray;
}
$.unique(receiverUserList);
if(receiverUserList.length > 0) {
$('#receiverUserDiv').show();
initReceiverUserTable(receiverUserList);
}
}
})
}
// 初始化巡查事项下拉选择
function initBusinessSelect() {
top.restAjax.get(top.restAjax.path('api/business/list', []), {}, null, function(code, data, args) {
laytpl(document.getElementById('businessSelectTemplate').innerHTML).render(data, function(html) {
document.getElementById('businessSelectTemplateBox').innerHTML = html;
});
form.render('select', 'businessSelectTemplateBox');
}, function(code, data) {
top.dialog.msg(data.msg);
});
}
// 初始化任务紧急程度下拉选择
function initUrgentLevelSelect() {
2021-11-30 17:40:20 +08:00
top.restAjax.get(top.restAjax.path('api/mongo/data/list-all/parent-id/{dataParentId}', ['203f7283-74a6-4f05-9d5f-c6675b3a69fc']), {}, null, function(code, data, args) {
2021-11-08 20:28:13 +08:00
laytpl(document.getElementById('urgentLevelSelectTemplate').innerHTML).render(data, function(html) {
document.getElementById('urgentLevelSelectTemplateBox').innerHTML = html;
});
form.render('select', 'urgentLevelSelectTemplateBox');
}, function(code, data) {
top.dialog.msg(data.msg);
});
}
form.on('radio(distributeType)', function(data){
if('手动下派' == data.value) {
$('#distributeTimeDiv').hide();
}else {
$('#distributeTimeDiv').show();
}
})
// 选择负责人
$(document).on('click', '#departmentMasterName', function() {
top.dialog.dialogData.selectedUserIds = $('#departmentMaster').val();
top.dialog.open({
url: top.restAjax.path('route/department/user/select-user', []),
title: '选择用户',
width: '500px',
height: '500px',
onClose: function() {
var selectedUsers = top.dialog.dialogData.selectedDepartmentUsers;
if(selectedUsers != null & & selectedUsers.length > 0) {
if(selectedUsers.length > 1) {
top.dialog.msg('负责人只能选择一人');
return;
}
$('#departmentMaster').val(selectedUsers[0].userId);
$('#departmentMasterName').val(selectedUsers[0].userName);
} else {
$('#departmentMaster').val('');
$('#departmentMasterName').val('');
}
}
});
})
// 巡查数据点击事件
$(document).on('click', '#businessData', function() {
/*if(receiverUserList.length > 0) {
var userIds = '';
for(var i=0, item; item = receiverUserList[i++];) {
if(i > 1) {
userIds += '_';
}
userIds += item['userId'];
}
top.dialog.dialogData.selectedUserIds = userIds;
}*/
// 获取巡查事项的选中值
var valueArr = $("#business option:selected").val().split(',');
getDataList(valueArr[1]);
});
// 任务接收人点击事件
$(document).on('click', '#receiverUser', function() {
if(receiverUserList.length > 0) {
var userIds = '';
for(var i=0, item; item = receiverUserList[i++];) {
if(i > 1) {
userIds += '_';
}
userIds += item['userId'];
}
top.dialog.dialogData.selectedUserIds = userIds;
}
// 获取巡查事项的选中值
var valueArr = $("#business option:selected").val().split(',');
initBusinessUser(valueArr[0]);
});
function initReceiverUserTable(row) {
table.render({
elem: '#receiverUserTable'
,cols: [
[
,{field: 'userId', title: 'userId', hide: true}
,{field: 'userName', title: '接收人姓名', width: 1114}
,{fixed: '', title:'操作', width: 119, align:'center', toolbar: '#receiver'}
]
]
,data: row
});
reloadReceiverUserTable();
}
function reloadReceiverUserTable() {
table.reload('receiverUserTable', {});
}
//监听行工具事件
table.on('tool(receiverUserTable)', function(obj){
var data = obj.data
,layEvent = obj.event;
if(layEvent === 'delete'){
layer.confirm('真的删除行么', function(index){
obj.del();
layer.close(index);
var i = 0;
for (;i < receiverUserList.length ; i + + ) {
if (data.userId == receiverUserList[i].userId) {
break;
}
}
receiverUserList.splice(i, 1);
if(0 == receiverUserList.length) {
$('#receiverUserDiv').hide();
}
});
}
});
// 下派模板点击事件
$(document).on('click', '#taskTemplate', function() {
top.dialog.dialogData.templateObj = {};
top.dialog.open({
url: top.restAjax.path('route/distribute/list-sel', []),
title: '任务模板',
width: '1040px',
height: '98%',
onClose: function(data) {
2021-11-10 18:03:51 +08:00
if(!$.isEmptyObject(top.dialog.dialogData.templateObj)) {
templateObj = top.dialog.dialogData.templateObj;
}
2021-11-08 20:28:13 +08:00
if(!$.isEmptyObject(templateObj)) {
templateType = templateObj.templateType;
// 通过模板类型控制页面
getDataByTemType(templateType);
getTaskRateMsg(templateObj.taskRateId);
$('#templateTableDiv').show();
initTable(templateObj);
}
}
});
});
function initTable(row) {
var templateList = [];
templateList.push(row);
table.render({
elem: '#templateTable'
,cols: [
[
,{field: 'templateId', title: 'templateId', hide: true}
,{field: 'templateTitle', title: '模板名称', width: 225}
,{field: 'templateSummary', title: '模板简介', width: 225}
,{field: 'templateType', title: '模板类型', width: 225}
,{field: 'taskTypeName', title: '任务类型', width: 225}
,{field: 'taskRateName', title: '任务频率', width: 225}
,{fixed: '', title:'操作', width: 107, align:'center', toolbar: '#barDemo'}
]
]
,data: templateList
});
reloadTable();
}
function reloadTable() {
table.reload('templateTable', {});
}
//监听行工具事件
table.on('tool(templateTable)', function(obj){
var data = obj.data
,layEvent = obj.event;
if(layEvent === 'delete'){
layer.confirm('真的删除行么', function(index){
obj.del();
layer.close(index);
if(data.templateId == templateObj.templateId) {
templateObj = {};
templateType = '';
taskRate = '';
reportCount = '';
$('#reportCount').val('');
$('#reportCount').removeAttr('readonly');
$('#templateTableDiv').hide();
$('#businessDiv').hide();
$('#receiverUserDivDiv').hide();
$('#businessDataDivDiv').hide();
$('#randomCountDiv').hide();
}
});
}
});
// 单随机任务按钮点击事件
$(document).on('click', '#startRandom', function() {
2021-11-10 18:03:51 +08:00
businessUnbind();
// 先移除所有方法
2021-11-08 20:28:13 +08:00
var randomCount = $('#randomCount').val();
if('' == randomCount) {
top.dialog.msg('随机数量不能为空');
return false;
}else if(randomCount < = 0) {
top.dialog.msg('随机数量必须大于0');
return false;
}else {
var reg = /^[1-9]\d*$/;
if(!reg.test(randomCount)) {
top.dialog.msg('随机数量必须为正整数');
return false;
}
}
var randomType = $("#randomType option:selected").val();
if('' == randomType) {
top.dialog.msg('请先选择随机类型');
return false;
}
randomData(randomCount, randomType);
});
// 获取随机数据
function randomData(randomCount, randomType) {
var url;
if(0 == randomType) {
url = 'api/business/random-list-business?randomCount={randomCount}';
}else {
url = 'api/business/random-list-user?randomCount={randomCount}';
}
var loadLayerIndex;
top.restAjax.get(top.restAjax.path(url, [randomCount]), {}, null, function(code, data) {
2021-11-10 18:03:51 +08:00
randomCountCount = randomCount;
2021-11-08 20:28:13 +08:00
if(0 == randomType) {
2021-11-10 18:03:51 +08:00
$('#randomBusinessUserDataDiv').hide();
2021-11-08 20:28:13 +08:00
businessDataList = data;
businessFun();
}else {
2021-11-10 18:03:51 +08:00
$('#randomBusinessDataDiv').hide();
$('#randomBusinessLegendDiv').empty();
2021-11-08 20:28:13 +08:00
receiverUserList = data;
businessUserFun();
}
2021-11-17 15:23:27 +08:00
// taskRate = data.rateType;
2021-11-08 20:28:13 +08:00
}, function(code, data) {
top.dialog.msg(data.msg);
}, function() {
loadLayerIndex = top.dialog.msg(top.dataMessage.loading, {icon: 16, time: 0, shade: 0.3});
}, function() {
top.dialog.close(loadLayerIndex);
});
}
// 页面显示巡查事项数据
function businessFun() {
2021-11-10 18:03:51 +08:00
randomList = [];
receiverUserList = [];
$('#randomBusinessUserLegendDiv').empty();
2021-11-08 20:28:13 +08:00
// 先清空原有数据
$('#randomBusinessLegendDiv').empty();
// randomBusinessDataDiv
$('#randomBusinessDataDiv').show();
for(var index=0;index< businessDataList.length ; index + + ) {
var html =
'< div class = "layui-form-item" id = "businessDiv" > \n' +
'< label class = "layui-form-label" > 巡查事项< / label > \n' +
'< div class = "layui-input-block" > \n' +
'< input type = "text" id = "business_' + index + '" name = "business_' + index + '" class = "layui-input" value = "'+businessDataList[index].businessName+'" readonly > \n' +
'< / div > \n' +
'< / div > \n' +
'< div class = "layui-form-item" id = "businessDataDivDiv" > \n' +
'< label class = "layui-form-label" > 事项列表< / label > \n' +
'< div class = "layui-input-block" > \n' +
'< input type = "text" id = "businessData_' + index + '" name = "businessData_' + index + '" class = "layui-input" value = "" placeholder = "点击选择事项列表" maxlength = "20" readonly > \n' +
'< input type = "hidden" id = "businessHideData_' + index + '" name = "businessHideData_' + index + '" value = "'+businessDataList[index].businessSummary+'" > \n' +
'< input type = "hidden" id = "businessIndexData_' + index + '" name = "businessIndexData_' + index + '" value = "'+index+'" > \n' +
'< / div > \n' +
'< div id = "businessDataDiv_'+index+'" > \n' +
'< input type = "hidden" id = "matterIndexTable_' + index + '" name = "matterIndexTable_' + index + '" value = "'+index+'" > \n' +
'< table class = "layui-hide" id = "businessDataTable_' + index + '" lay-data = "{height: \'full-200\', cellMinWidth: 80, page: false\'}" lay-filter = "businessDataTable_'+index+'" > < / table > \n' +
'< sc ' + ' ript type = "text/html" id = "businessDataDel_' + index + '" > \n' +
'< a class = "layui-btn layui-btn-xs layui-btn-danger" lay-event = "delete" > 删除< / a > \n' +
'< /sc' + 'ript>\n' +
'< / div > \n'+
'< / div > \n' +
'< div class = "layui-form-item" id = "receiverUserDivDiv_' + index + '" > \n' +
'< label class = "layui-form-label" > 接收人< / label > \n' +
'< div class = "layui-input-block" > \n' +
'< input type = "text" id = "receiverUser_' + index + '" name = "receiverUser_' + index + '" class = "layui-input" value = "" placeholder = "点击选择任务接收人" maxlength = "20" readonly > \n' +
'< input type = "hidden" id = "receiverHideUser_' + index + '" name = "receiverHideUser_' + index + '" value = "'+businessDataList[index].businessId+'" > \n' +
'< input type = "hidden" id = "receiverIndexUser_' + index + '" name = "receiverIndexUser_' + index + '" value = "'+index+'" > \n' +
'< / div > \n' +
'< div id = "receiverUserDiv_' + index + '" > \n' +
'< input type = "hidden" id = "receiverUserIndexTable_' + index + '" name = "receiverUserIndexTable_' + index + '" value = "'+index+'" > \n' +
'< table class = "layui-hide" id = "receiverUserTable_' + index + '" lay-data = "{height: \'full-200\', cellMinWidth: 80, page: false\'}" lay-filter = "receiverUserTable_' + index + '" > < / table > \n' +
'< sc ' + ' ript type = "text/html" id = "receiver_' + index + '" > \n' +
'< a class = "layui-btn layui-btn-xs layui-btn-danger" lay-event = "delete" > 删除< / a > \n' +
'< /sc' + 'ript>\n' +
'< / div > \n'+
'< / div > ';
$('#randomBusinessLegendDiv').append(html);
2021-11-10 18:03:51 +08:00
2021-11-08 20:28:13 +08:00
businessForEachData(index);
}
}
2021-11-10 18:03:51 +08:00
function businessUnbind() {
$("div#randomBusinessLegendDiv input,select").each(function(){
console.log($(this).attr('id'))
$(document).off('click', '#'+$(this).attr('id'));
})
$("div#randomBusinessUserLegendDiv input,select").each(function(){
console.log($(this).attr('id'))
$(document).off('click', '#'+$(this).attr('id'));
})
}
2021-11-08 20:28:13 +08:00
// 循环时创建每组数据对应的方法(当随机选择为巡查事项)
function businessForEachData(index) {
$(document).on('click', '#businessData_' + index, function() {
/*if(receiverUserList.length > 0) {
var userIds = '';
for(var i=0, item; item = receiverUserList[i++];) {
if(i > 1) {
userIds += '_';
}
userIds += item['userId'];
}
top.dialog.dialogData.selectedUserIds = userIds;
}*/
var businessSummary = $(this).next().val();
getDataListFor(businessSummary);
});
function getDataListFor(summary) {
2021-11-10 18:03:51 +08:00
var flag = true;
2021-11-08 20:28:13 +08:00
top.dialog.dialogData.selectedDataArray = [];
2021-11-10 18:03:51 +08:00
if(flag) {
flag = false;
top.dialog.open({
title: '选择巡查数据',
url: top.restAjax.path('route/business/' + summary, []),
width: '1040px',
height: '98%',
id: 'id' + summary + Math.random() * 1000,
onClose: function () {
flag = true;
var matterListFor = [];
if (top.dialog.dialogData.selectedDataArray.length > 0) {
matterListFor = top.dialog.dialogData.selectedDataArray;
for (var matterIdx = 0; matterIdx < matterListFor.length ; matterIdx + + ) {
matterListFor[matterIdx].matterIdx = index;
}
if (0 == randomList.length || randomList.length < businessDataList.length ) {
randomList.push({
business: businessDataList[index].businessId,
matterList: matterListFor,
receiveUserList: []
})
} else {
var businessId = businessDataList[index].businessId;
var k = 0;
for (; k < randomList.length ; k + + ) {
if (businessId == randomList[k].business) {
break;
}
2021-11-08 20:28:13 +08:00
}
2021-11-10 18:03:51 +08:00
randomList[k].matterList = matterListFor;
2021-11-08 20:28:13 +08:00
}
2021-11-10 18:03:51 +08:00
$.unique(randomList);
2021-11-08 20:28:13 +08:00
}
2021-11-10 18:03:51 +08:00
$.unique(matterListFor);
if (matterListFor.length > 0) {
$('#businessDataDiv_' + index).show();
initReceiverMatterTable(matterListFor);
}
},
cancel: function () {
flag = true;
2021-11-08 20:28:13 +08:00
}
2021-11-10 18:03:51 +08:00
})
}
2021-11-08 20:28:13 +08:00
}
function initReceiverMatterTable(row) {
table.render({
elem: '#businessDataTable_' + index
,cols: [
[
,{field: 'matterId', title: 'matterId', hide: true}
,{field: 'name', title: '事项名称', width: 300}
,{field: 'man', title: '负责人', width: 200}
,{field: 'phone', title: '联系方式', width: 200}
,{field: 'time', title: '时间', width: 200}
,{fixed: '', title:'操作', width: 119, align:'center', toolbar: '#businessDataDel_' + index}
]
]
,data: row
});
reloadReceiverMatterTable(row);
}
function reloadReceiverMatterTable(matterListFor) {
table.reload('businessDataTable_' + index, {});
matterDel(matterListFor);
}
function matterDel(matterListFor) {
//监听行工具事件
table.on('tool(businessDataTable_' + index + ')', function(obj){
var data = obj.data
,layEvent = obj.event;
if(layEvent === 'delete'){
layer.confirm('真的删除行么', function(delIndex){
obj.del();
layer.close(delIndex);
var j = 0;
for (;j < matterListFor.length ; j + + ) {
if (data.matterId == matterListFor[j].matterId) {
break;
}
}
matterListFor.splice(j, 1);
var businessId = businessDataList[index].businessId;
var k = 0;
for(;k < randomList.length ; k + + ) {
if(businessId == randomList[k].business) {
break;
}
}
randomList[k].matterList = matterListFor;
console.log(randomList)
if(0 == matterListFor.length) {
$('#businessDataDiv_' + index).hide();
}
});
}
});
}
// 任务接收人点击事件
$(document).on('click', '#receiverUser_' + index, function() {
if(receiverUserList.length > 0) {
var userIds = '';
for(var j=0, item; item = receiverUserList[j++];) {
if(j > 1) {
userIds += '_';
}
userIds += item['userId'];
}
top.dialog.dialogData.selectedUserIds = userIds;
2021-11-10 18:03:51 +08:00
}else {
top.dialog.dialogData.selectedUserIds = [];
2021-11-08 20:28:13 +08:00
}
var businessId = $(this).next().val();
initBusinessUserFor(businessId);
});
function initBusinessUserFor(businessId) {
top.dialog.dialogData.selectedUserArray = [];
top.dialog.open({
title: '选择人员',
url: top.restAjax.path('route/business/list-user?businessId={businessId}', [businessId]),
width: '1040px',
height: '98%',
onClose: function () {
var receiverUserListFor = [];
if(top.dialog.dialogData.selectedUserArray.length > 0) {
receiverUserListFor = top.dialog.dialogData.selectedUserArray;
2021-11-10 18:03:51 +08:00
for(var userIdx=0;userIdx< receiverUserListFor.length ; userIdx + + ) {
receiverUserListFor[userIdx].userIdx = index;
2021-11-08 20:28:13 +08:00
}
var businessId = businessDataList[index].businessId;
var k = 0;
for(;k < randomList.length ; k + + ) {
if(businessId == randomList[k].business) {
break;
}
}
randomList[k].receiveUserList = receiverUserListFor;
}
$.unique(receiverUserListFor);
if(receiverUserListFor.length > 0) {
$('#receiverUserDiv_' + index).show();
initReceiverUserTableFor(receiverUserListFor);
}
}
})
}
function initReceiverUserTableFor(row) {
table.render({
elem: '#receiverUserTable_' + index
,cols: [
[
,{field: 'userId', title: 'userId', hide: true}
,{field: 'userName', title: '接收人姓名', width: 1114}
,{fixed: '', title:'操作', width: 119, align:'center', toolbar: '#receiver_' + index}
]
]
,data: row
});
reloadReceiverUserTableFor(row);
}
function reloadReceiverUserTableFor(receiverUserListFor) {
table.reload('receiverUserTable_' + index, {});
receiveUserDel(receiverUserListFor);
}
function receiveUserDel(receiverUserListFor) {
//监听行工具事件
table.on('tool(receiverUserTable_' + index + ')', function (obj) {
var data = obj.data
, layEvent = obj.event;
if (layEvent === 'delete') {
layer.confirm('真的删除行么', function (delIndex) {
obj.del();
layer.close(delIndex);
var j = 0;
for (; j < receiverUserListFor.length ; j + + ) {
if (data.userId == receiverUserListFor[j].userId) {
break;
}
}
receiverUserListFor.splice(j, 1);
var businessId = businessDataList[index].businessId;
var k = 0;
for(;k < randomList.length ; k + + ) {
if(businessId == randomList[k].business) {
break;
}
}
randomList[k].receiveUserList = receiverUserListFor;
if (0 == receiverUserListFor.length) {
$('#receiverUserDiv_' + index).hide();
}
});
}
});
}
}
// 页面显示任务接收人数据
function businessUserFun() {
2021-11-10 18:03:51 +08:00
randomList = [];
$('#randomBusinessLegendDiv').empty();
2021-11-08 20:28:13 +08:00
// randomBusinessUserDataDiv
// randomBusinessUserLegendDiv
// 先清空原有数据
$('#randomBusinessUserLegendDiv').empty();
// randomBusinessDataDiv
$('#randomBusinessUserDataDiv').show();
for (var index = 0; index < receiverUserList.length ; index + + ) {
var html =
2021-11-10 18:03:51 +08:00
'< div class = "layui-form-item" id = "receiveUserUserDiv" > \n' +
2021-11-08 20:28:13 +08:00
'< label class = "layui-form-label" > 任务接收人< / label > \n' +
'< div class = "layui-input-block" > \n' +
2021-11-10 18:03:51 +08:00
'< input type = "text" id = "receiveUserUser_' + index + '" name = "receiveUserUser_' + index + '" class = "layui-input" value = "' + receiverUserList[index].userName + '" readonly > \n' +
2021-11-08 20:28:13 +08:00
'< / div > \n' +
'< / div > \n' +
2021-11-10 18:03:51 +08:00
'< div class = "layui-form-item" id = "businessUserDiv_'+index+'" style = "display: none;" > \n' +
2021-11-08 20:28:13 +08:00
'< label class = "layui-form-label" > 巡查事项< / label > \n' +
2021-11-10 18:03:51 +08:00
'< div class = "layui-input-block layui-form" id = "businessUserSelectTemplateBox_'+index+'" lay-filter = "businessUserSelectTemplateBox_'+index+'" > < / div > \n' +
'< sc ' + ' ript id = "businessUserSelectTemplate_'+index+'" type = "text/html" > \n' +
'< select id = "businessUser_'+index+'" name = "businessUser_'+index+'" lay-filter = "businessUser_'+index+'" lay-verify = "required" > \n' +
2021-11-08 20:28:13 +08:00
'< option value = "" > 请选择巡查事项< / option > \n' +
'{{# for(var i = 0, item; item = d[i++];) { }}\n' +
'< option value = "{{item.businessId}},{{item.businessSummary}}" > {{item.businessName}}< / option > \n' +
'{{# } }}\n' +
'< / select > \n' +
'< /sc' + 'ript>\n' +
'< / div > \n' +
2021-11-10 18:03:51 +08:00
'< div class = "layui-form-item" style = "display: none;" id = "businessUserDataDivDiv_'+index+'" > \n' +
2021-11-08 20:28:13 +08:00
'< label class = "layui-form-label" > 事项列表< / label > \n' +
'< div class = "layui-input-block" > \n' +
2021-11-10 18:03:51 +08:00
'< input type = "text" id = "businessUserData_' + index + '" name = "businessUserData_' + index + '" class = "layui-input" value = "" placeholder = "点击选择事项列表" maxlength = "20" readonly > \n' +
2021-11-08 20:28:13 +08:00
'< / div > \n' +
2021-11-10 18:03:51 +08:00
'< div id = "businessUserDataDiv_' + index + '" > \n' +
'< table class = "layui-hide" id = "businessUserDataTable_' + index + '" lay-data = "{height: \'full-200\', cellMinWidth: 80, page: false\'}" lay-filter = "businessUserDataTable_' + index + '" > < / table > \n' +
'< sc ' + ' ript type = "text/html" id = "businessUserDataDel_' + index + '" > \n' +
2021-11-08 20:28:13 +08:00
'< a class = "layui-btn layui-btn-xs layui-btn-danger" lay-event = "delete" > 删除< / a > \n' +
'< /sc' + 'ript>\n' +
'< / div > \n' +
'< / div > \n';
$('#randomBusinessUserLegendDiv').append(html);
userForEachData(index);
}
}
// 循环时创建每组数据对应的方法(当随机选择为任务接收人)
function userForEachData(index) {
var userId = receiverUserList[index].userId;
initBusinessSelectFor(userId);
// 初始话巡查事项下拉列表
function initBusinessSelectFor(userId) {
top.restAjax.get(top.restAjax.path('api/business/list-business/{userId}', [userId]), {}, null, function(code, data, args) {
2021-11-10 18:03:51 +08:00
laytpl(document.getElementById('businessUserSelectTemplate_' + index).innerHTML).render(data, function(html) {
document.getElementById('businessUserSelectTemplateBox_' + index).innerHTML = html;
2021-11-08 20:28:13 +08:00
});
2021-11-10 18:03:51 +08:00
$('#businessUserDiv_' + index).show();
form.render('select', 'businessUserSelectTemplateBox_' + index);
2021-11-08 20:28:13 +08:00
}, function(code, data) {
top.dialog.msg(data.msg);
});
}
// 治安突出问题change事件
2021-11-10 18:03:51 +08:00
form.on('select(businessUser_'+index+')', function(data){
2021-11-08 20:28:13 +08:00
if(!data.value) {
2021-11-10 18:03:51 +08:00
$('#businessUserDataDivDiv_' + index).hide();
2021-11-08 20:28:13 +08:00
}else {
var valueArr = data.value.split(',');
if(2 == valueArr.length) {
2021-11-10 18:03:51 +08:00
$('#businessUserDataDivDiv_' + index).show();
2021-11-08 20:28:13 +08:00
}else {
2021-11-10 18:03:51 +08:00
$('#businessUserDataDivDiv_' + index).hide();
2021-11-08 20:28:13 +08:00
}
}
form.render("select");
});
// 巡查数据点击事件
2021-11-10 18:03:51 +08:00
$(document).on('click', '#businessUserData_' + index, function() {
2021-11-08 20:28:13 +08:00
/*if(receiverUserList.length > 0) {
var userIds = '';
for(var i=0, item; item = receiverUserList[i++];) {
if(i > 1) {
userIds += '_';
}
userIds += item['userId'];
}
top.dialog.dialogData.selectedUserIds = userIds;
}*/
// 获取巡查事项的选中值
2021-11-10 18:03:51 +08:00
var valueArr = $("#businessUser_"+index+" option:selected").val().split(',');
2021-11-08 20:28:13 +08:00
getDataListFor(valueArr[1]);
});
// 通过巡查事项所配置的信息(业务描述)来进行业务分拨处理
function getDataListFor(summary) {
top.dialog.dialogData.selectedDataArray = [];
top.dialog.open({
title: '选择巡查数据',
url: top.restAjax.path('route/business/' + summary, []),
width: '1040px',
height: '98%',
onClose: function () {
var matterListFor = [];
if(top.dialog.dialogData.selectedDataArray.length > 0) {
matterListFor = top.dialog.dialogData.selectedDataArray;
for(var matterIdx=0;matterIdx< matterListFor.length ; matterIdx + + ) {
matterListFor[matterIdx].matterIdx = index;
}
2021-11-10 18:03:51 +08:00
var valueArr = $("#businessUser_"+index+" option:selected").val();
2021-11-08 20:28:13 +08:00
var userObj = {};
userObj.userId = receiverUserList[index].userId;
userObj.userName = receiverUserList[index].userName;
userObj.userIdx = index;
var receiverUserListFor = [];
receiverUserListFor.push(userObj);
2021-11-10 18:03:51 +08:00
if(0 == randomList.length || randomList.length < receiverUserList.length ) {
2021-11-08 20:28:13 +08:00
randomList.push({
business: valueArr,
matterList: matterListFor,
receiveUserList: receiverUserListFor
})
}else {
var k = 0;
flag: for(;k < randomList.length ; k + + ) {
console.log(k);
var userList = randomList[k].receiveUserList;
for(var l=0;l< userList.length ; l + + ) {
if(userId == userList[l].userId) {
break flag;
}
}
}
randomList[k].matterList = matterListFor;
}
$.unique(randomList);
}
console.log(randomList)
$.unique(matterListFor);
if(matterListFor.length > 0) {
2021-11-10 18:03:51 +08:00
$('#businessUserDataDiv_' + index).show();
2021-11-08 20:28:13 +08:00
initMatterTableFor(matterListFor);
}
}
})
}
function initMatterTableFor(row) {
table.render({
2021-11-10 18:03:51 +08:00
elem: '#businessUserDataTable_' + index
2021-11-08 20:28:13 +08:00
,cols: [
[
,{field: 'matterId', title: 'matterId', hide: true}
,{field: 'name', title: '事项名称', width: 300}
,{field: 'man', title: '负责人', width: 200}
,{field: 'phone', title: '联系方式', width: 200}
,{field: 'time', title: '时间', width: 200}
2021-11-10 18:03:51 +08:00
,{fixed: '', title:'操作', width: 119, align:'center', toolbar: '#businessUserDataDel_' + index}
2021-11-08 20:28:13 +08:00
]
]
,data: row
});
reloadMatterTableFor(row);
}
function reloadMatterTableFor(matterListFor) {
2021-11-10 18:03:51 +08:00
table.reload('businessUserDataTable_' + index, {});
2021-11-08 20:28:13 +08:00
businessDel(matterListFor);
}
function businessDel(matterListFor) {
//监听行工具事件
2021-11-10 18:03:51 +08:00
table.on('tool(businessUserDataTable_' + index + ')', function(obj){
2021-11-08 20:28:13 +08:00
var data = obj.data
,layEvent = obj.event;
if(layEvent === 'delete'){
layer.confirm('真的删除行么', function(delIndex){
obj.del();
layer.close(delIndex);
var i = 0;
for (;i < matterListFor.length ; i + + ) {
if (data.matterId == matterListFor[i].matterId) {
break;
}
}
matterListFor.splice(i, 1);
var userId = receiverUserList[index].userId;
var k = 0;
flag: for(;k < randomList.length ; k + + ) {
console.log(k);
var userList = randomList[k].receiveUserList;
for(var l=0;l< userList.length ; l + + ) {
if(userId == userList[l].userId) {
break flag;
}
}
}
randomList[k].matterList = matterListFor;
if(0 == matterListFor.length) {
2021-11-10 18:03:51 +08:00
$('#businessUserDataDiv_' + index).hide();
2021-11-08 20:28:13 +08:00
}
});
}
});
}
}
// 通过模板类型控制页面展示内容
function getDataByTemType(templateType) {
if('固定任务' == templateType) {
$('#businessDiv').show();
$('#randomCountDiv').hide();
initBusinessSelect();
}
if('单随机任务' == templateType) {
$('#randomCountDiv').show();
$('#businessDiv').hide();
}
if('双随机任务' == templateType) {
}
}
// 通过id获取任务任务模板中的任务频率的相关信息
function getTaskRateMsg(taskRateId) {
var loadLayerIndex;
top.restAjax.get(top.restAjax.path('api/rate/get/{taskRateId}', [taskRateId]), {}, null, function(code, data) {
reportCount = data.reportCount;
$('#reportCount').val(reportCount);
$('#reportCount').attr('readonly', 'readonly');
taskRate = data.rateType;
}, function(code, data) {
top.dialog.msg(data.msg);
}, function() {
loadLayerIndex = top.dialog.msg(top.dataMessage.loading, {icon: 16, time: 0, shade: 0.3});
}, function() {
top.dialog.close(loadLayerIndex);
});
}
//初始化百度地图
function initMap(longitude, latitude) {
map = new BMap.Map("mapContainer", {enableMapClick: false,});
var point = new BMap.Point(longitude, latitude);
map.centerAndZoom(point, 13);
map.disableDoubleClickZoom();
map.addControl(new BMap.NavigationControl());
map.addControl(new BMap.ScaleControl());
map.addControl(new BMap.OverviewMapControl());
map.addControl(new BMap.MapTypeControl());
map.enableScrollWheelZoom();//启用地图滚轮放大缩小
map.enableContinuousZoom();//开启缩放平滑
// 点击获取地址
var geocoder= new BMap.Geocoder();
mapMarkPoint(map, point);
map.addEventListener("click", function(e) {
map.clearOverlays();
$('#missionLocationLng').val(e.point.lng);
$('#missionLocationLat').val(e.point.lat);
point = new BMap.Point(e.point.lng, e.point.lat);
mapMarkPoint(map, point);
geocoder.getLocation(e.point, function(rs) {
$('#shopAddress').val(rs.address);
});
});
}
// 地图打点
function mapMarkPoint(map, point) {
var marker = new BMap.Marker(point);
map.addOverlay(marker);
}
// 初始化任务一级地区下拉选择
function initTaskArea1NameSelect() {
2021-11-30 17:40:20 +08:00
top.restAjax.get(top.restAjax.path('api/mongo/area/list-all/parent-id/0', []), {}, null, function(code, data, args) {
2021-11-08 20:28:13 +08:00
laytpl(document.getElementById('taskArea1NameSelectTemplate').innerHTML).render(data, function(html) {
document.getElementById('taskArea1NameSelectTemplateBox').innerHTML = html;
});
form.render('select', 'taskArea1NameSelectTemplateBox');
}, function(code, data) {
top.dialog.msg(data.msg);
});
}
// 初始化任务二级地区下拉选择
function initTaskArea2NameSelect(value) {
if(!value) {
var data = [
{
areaId: '',
areaName: '请选择上级数据'
}
];
laytpl(document.getElementById('taskArea2NameSelectTemplate').innerHTML).render(data, function(html) {
document.getElementById('taskArea2NameSelectTemplateBox').innerHTML = html;
});
form.render('select', 'taskArea2NameSelectTemplateBox');
}else {
2021-11-30 17:40:20 +08:00
top.restAjax.get(top.restAjax.path('api/mongo/area/list-all/parent-id/' + value, []), {}, null, function(code, data, args) {
2021-11-08 20:28:13 +08:00
laytpl(document.getElementById('taskArea2NameSelectTemplate').innerHTML).render(data, function(html) {
document.getElementById('taskArea2NameSelectTemplateBox').innerHTML = html;
});
form.render('select', 'taskArea2NameSelectTemplateBox');
}, function(code, data) {
top.dialog.msg(data.msg);
});
}
}
// 初始化任务三级地区下拉选择
function initTaskArea3NameSelect(value) {
if(!value) {
var data = [
{
areaId: '',
areaName: '请选择上级数据'
}
];
laytpl(document.getElementById('taskArea3NameSelectTemplate').innerHTML).render(data, function(html) {
document.getElementById('taskArea3NameSelectTemplateBox').innerHTML = html;
});
form.render('select', 'taskArea3NameSelectTemplateBox');
}else {
2021-11-30 17:40:20 +08:00
top.restAjax.get(top.restAjax.path('api/mongo/area/list-all/parent-id/' + value, []), {}, null, function(code, data, args) {
2021-11-08 20:28:13 +08:00
laytpl(document.getElementById('taskArea3NameSelectTemplate').innerHTML).render(data, function(html) {
document.getElementById('taskArea3NameSelectTemplateBox').innerHTML = html;
});
form.render('select', 'taskArea3NameSelectTemplateBox');
}, function(code, data) {
top.dialog.msg(data.msg);
});
}
}
// 初始化任务四级地区下拉选择
function initTaskArea4NameSelect(value) {
if(!value) {
var data = [
{
areaId: '',
areaName: '请选择上级数据'
}
];
laytpl(document.getElementById('taskArea4NameSelectTemplate').innerHTML).render(data, function(html) {
document.getElementById('taskArea4NameSelectTemplateBox').innerHTML = html;
});
form.render('select', 'taskArea4NameSelectTemplateBox');
}else {
2021-11-30 17:40:20 +08:00
top.restAjax.get(top.restAjax.path('api/mongo/area/list-all/parent-id/' + value, []), {}, null, function(code, data, args) {
2021-11-08 20:28:13 +08:00
laytpl(document.getElementById('taskArea4NameSelectTemplate').innerHTML).render(data, function(html) {
document.getElementById('taskArea4NameSelectTemplateBox').innerHTML = html;
});
form.render('select', 'taskArea4NameSelectTemplateBox');
}, function(code, data) {
top.dialog.msg(data.msg);
});
}
}
// 初始化任务五级地区下拉选择
function initTaskArea5NameSelect(value) {
if(!value) {
var data = [
{
areaId: '',
areaName: '请选择上级数据'
}
];
laytpl(document.getElementById('taskArea5NameSelectTemplate').innerHTML).render(data, function(html) {
document.getElementById('taskArea5NameSelectTemplateBox').innerHTML = html;
});
form.render('select', 'taskArea5NameSelectTemplateBox');
}else {
2021-11-30 17:40:20 +08:00
top.restAjax.get(top.restAjax.path('api/mongo/area/list-all/parent-id/' + value, []), {}, null, function(code, data, args) {
2021-11-08 20:28:13 +08:00
laytpl(document.getElementById('taskArea5NameSelectTemplate').innerHTML).render(data, function(html) {
document.getElementById('taskArea5NameSelectTemplateBox').innerHTML = html;
});
form.render('select', 'taskArea5NameSelectTemplateBox');
}, function(code, data) {
top.dialog.msg(data.msg);
});
}
}
// 任务一级change事件
form.on('select(taskArea1Name)', function(data){
if(!data.value) {
$('#taskArea1Id').val('')
$('#taskArea1Code').val('')
$('#area2Div').hide();
$('#area3Div').hide();
$('#area4Div').hide();
$('#area5Div').hide();
$('#mapDiv').hide();
}else {
var valueArr = data.value.split(',');
if(5 == valueArr.length) {
$('#taskArea1Id').val(valueArr[0]);
$('#taskArea1Code').val(valueArr[1]);
$('#taskArea1Name').val(valueArr[4]);
$('#mapDiv').show();
initMap(valueArr[2], valueArr[3])
}
$('#area2Div').show();
$('#area3Div').hide();
$('#area4Div').hide();
$('#area5Div').hide();
2021-11-30 17:40:20 +08:00
initTaskArea2NameSelect(valueArr[0]);
2021-11-08 20:28:13 +08:00
}
$("#taskArea2Name").empty();
form.render("select");
});
// 任务二级change事件
form.on('select(taskArea2Name)', function(data){
if(!data.value) {
$('#taskArea2Id').val('')
$('#taskArea2Code').val('')
$('#area3Div').hide();
$('#area4Div').hide();
$('#area5Div').hide();
}else {
var valueArr = data.value.split(',');
if(5 == valueArr.length) {
$('#taskArea2Id').val(valueArr[0]);
$('#taskArea2Code').val(valueArr[1]);
$('#taskArea2Name').val(valueArr[4]);
$('#mapDiv').show();
initMap(valueArr[2], valueArr[3])
}
$('#area3Div').show();
$('#area4Div').hide();
$('#area5Div').hide();
2021-11-30 17:40:20 +08:00
initTaskArea3NameSelect(valueArr[0]);
2021-11-08 20:28:13 +08:00
}
$("#taskArea3Name").empty();
form.render("select");
});
// 任务三级change事件
form.on('select(taskArea3Name)', function(data){
if(!data.value) {
$('#taskArea3Id').val('')
$('#taskArea3Code').val('')
$('#area4Div').hide();
$('#area5Div').hide();
}else {
var valueArr = data.value.split(',');
if(5 == valueArr.length) {
$('#taskArea3Id').val(valueArr[0]);
$('#taskArea3Code').val(valueArr[1]);
$('#taskArea3Name').val(valueArr[4]);
$('#mapDiv').show();
initMap(valueArr[2], valueArr[3])
}
$('#area4Div').show();
$('#area5Div').hide();
2021-11-30 17:40:20 +08:00
initTaskArea4NameSelect(valueArr[0]);
2021-11-08 20:28:13 +08:00
}
$("#taskArea4Name").empty();
form.render("select");
});
// 任务四级change事件
form.on('select(taskArea4Name)', function(data){
if(!data.value) {
$('#taskArea4Id').val('')
$('#taskArea4Code').val('')
$('#area5Div').hide();
}else {
var valueArr = data.value.split(',');
if(5 == valueArr.length) {
$('#taskArea4Id').val(valueArr[0]);
$('#taskArea4Code').val(valueArr[1]);
$('#taskArea4Name').val(valueArr[4]);
$('#mapDiv').show();
initMap(valueArr[2], valueArr[3])
}
$('#area5Div').show();
2021-11-30 17:40:20 +08:00
initTaskArea5NameSelect(valueArr[0]);
2021-11-08 20:28:13 +08:00
}
$("#taskArea5Name").empty();
form.render("select");
});
// 任务五级change事件
form.on('select(taskArea5Name)', function(data){
if(!data.value) {
$('#taskArea5Id').val('')
$('#taskArea5Code').val('')
}else {
var valueArr = data.value.split(',');
if(5 == valueArr.length) {
$('#taskArea5Id').val(valueArr[0]);
$('#taskArea5Code').val(valueArr[1]);
$('#taskArea5Name').val(valueArr[4]);
$('#mapDiv').show();
initMap(valueArr[2], valueArr[3])
}
}
});
function showHide() {
$('#area2Div').hide();
$('#area3Div').hide();
$('#area4Div').hide();
$('#area5Div').hide();
}
showHide();
// 初始化日期
function initDate() {
// 日期选择
laydate.render({
elem: '#distributeTime',
format: 'yyyy-MM-dd HH:mm:ss',
type: 'datetime',
value: new Date(),
min: 'new Date()'
});
laydate.render({
elem: '#distributeDeadline',
format: 'yyyy-MM-dd HH:mm:ss',
type: 'datetime',
min: 'new Date()',
done: function(value, date, endDate){
$('#distributeDeadline').change();
deadlineFun(value);
}
});
}
function deadlineFun(value) {
if('' != taskRate) {
if('多次任务' == taskRate) {
$('#distributeDeadline').val('');
$('#deadlineDiv').show();
var deadlineObj = {};
deadlineObj['deadlineTime'] = value;
deadlineList.push(deadlineObj);
initDeadlineTable(deadlineList);
}
if('单次任务' == taskRate) {
deadlineList = [];
$('#deadlineDiv').hide();
}
}
}
function initDeadlineTable(row) {
table.render({
elem: '#deadlineTable'
,cols: [
[
,{field: 'deadlineTime', title: '截止日期'}
,{fixed: '', title:'操作', width: 107, align:'center', toolbar: '#deadline'}
]
]
,data: row
});
reloadDeadlineTable();
}
function reloadDeadlineTable() {
table.reload('deadlineTable', {});
}
//监听行工具事件
table.on('tool(deadlineTable)', function(obj){
var data = obj.data
,layEvent = obj.event;
if(layEvent === 'delete'){
layer.confirm('真的删除行么', function(index){
obj.del();
layer.close(index);
var i = 0;
for (;i < deadlineList.length ; i + + ) {
if (data.deadlineTime == deadlineList[i].deadlineTime) {
break;
}
}
deadlineList.splice(i, 1);
if(0 == deadlineList.length) {
$('#deadlineDiv').hide();
}
});
}
});
function closeBox() {
parent.layer.close(parent.layer.getFrameIndex(window.name));
}
// 初始化内容
function initData() {
initDate();
initTaskArea1NameSelect();
initUrgentLevelSelect();
}
initData();
// 提交表单
form.on('submit(submitForm)', function(formData) {
console.log(randomList)
top.dialog.confirm(top.dataMessage.commit, function(index) {
top.dialog.close(index);
var loadLayerIndex;
if($.isEmptyObject(templateObj)) {
top.dialog.msg('请选择下派模板!');
return false;
}else {
formData.field['taskTemplate'] = templateObj.templateId;
}
if(deadlineList.length > 0) {
delete formData.field.distributeDeadline;
for(var i=0;i< deadlineList.length ; i + + ) {
delete deadlineList[i].LAY_TABLE_INDEX;
}
}
if('固定任务' == templateType) {
if (null == receiverUserList || '' == receiverUserList || receiverUserList.length < = 0) {
top.dialog.msg('请选择任务接收人');
return false;
}
}
formData.field['deadlineList'] = deadlineList;
formData.field['receiverUserList'] = receiverUserList;
formData.field['matterList'] = matterList;
if(randomList.length > 0) {
console.log(randomList)
for(var i=0;i< randomList.length ; i + + ) {
if('' == randomList[i].business) {
top.dialog.msg('巡查事项不能为空');
return false;
}
if(randomList[i].receiveUserList.length < = 0) {
top.dialog.msg('任务接收人不能为空');
return false;
}
if(randomList[i].matterList.length < = 0) {
top.dialog.msg('事项列表不能为空');
return false;
}
}
}
formData.field['randomList'] = randomList;
formData.field['distributeTaskType'] = '巡查任务';
top.restAjax.post(top.restAjax.path('api/distribute/save', []), formData.field, null, function(code, data) {
var layerIndex = top.dialog.msg(top.dataMessage.commitSuccess, {
time: 0,
btn: [top.dataMessage.button.yes, top.dataMessage.button.no],
shade: 0.3,
yes: function(index) {
top.dialog.close(index);
window.location.reload();
},
btn2: function() {
closeBox();
}
});
}, function(code, data) {
top.dialog.msg(data.msg);
}, function() {
loadLayerIndex = top.dialog.msg(top.dataMessage.committing, {icon: 16, time: 0, shade: 0.3});
}, function() {
top.dialog.close(loadLayerIndex);
});
});
return false;
});
$('.close').on('click', function() {
closeBox();
});
});
< / script >
< / body >
< / html >