You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
307 lines
9.6 KiB
307 lines
9.6 KiB
<!DOCTYPE html>
|
|
<html>
|
|
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title></title>
|
|
<link href="../../component/pear/css/pear.css" rel="stylesheet" />
|
|
<link rel="stylesheet" href="../../component/other/css/zTreeStyle.css" />
|
|
</head>
|
|
|
|
<body>
|
|
<form class="layui-form">
|
|
|
|
<div class="layui-card">
|
|
<div class="layui-card-body">
|
|
<div class="layui-inline" style="margin: 5px 0 5px 0">
|
|
<label class="layui-form-label" style="width: 85px;">任务名称:</label>
|
|
<div class="layui-input-inline" style="margin-right: 8px;">
|
|
<input type="text" autocomplete="off" lay-verify="required" name="taskName" id="taskName"
|
|
placeholder="请输入任务名称" class="layui-input" style="width: 500px;">
|
|
</div>
|
|
<font color="red" style="font-weight: bold;">*</font>
|
|
</div>
|
|
|
|
</div>
|
|
<div class="layui-card-body">
|
|
<div class="layui-inline" style="margin: 5px 0 5px 0">
|
|
<label class="layui-form-label" style="width: 85px;">表单模板:</label>
|
|
<div class="layui-input-inline" id="moduleSelectView" style="margin-right: 8px;width: 500px;"></div>
|
|
<script id="moduleSelectScript" type="text/html">
|
|
<select name="moduleSelect" id="moduleSelect" lay-verify="required" lay-search>
|
|
<option value="">请选择或搜索表单模板</option>
|
|
{{# layui.each(d.data, function(index, item){ }}
|
|
<option value="{{item.module_id}}">{{item.module_name}}</option>
|
|
{{# }); }}
|
|
</select>
|
|
</script>
|
|
|
|
<font color="red" style="font-weight: bold;">*</font>
|
|
</div>
|
|
|
|
</div>
|
|
<div class="layui-card-body">
|
|
<div class="layui-inline" style="margin: 5px 0 5px 0">
|
|
<label class="layui-form-label" style="width: 85px;">结束日期:</label>
|
|
<div class="layui-input-inline" style="margin-right: 8px;">
|
|
<!-- <input type="text" id="taskName" placeholder="请输入任务名称" class="layui-input" style="width: 500px;"> -->
|
|
<input type="text" name="endDate" id="endDate" lay-verify="date" placeholder="请选择结束日期"
|
|
autocomplete="off" class="layui-input" style="width: 500px;">
|
|
|
|
</div>
|
|
<font color="red" style="font-weight: bold;">*</font>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="layui-card">
|
|
<div class="layui-card-header" style="font-weight: bold;">
|
|
快速选择接收范围
|
|
</div>
|
|
|
|
<div class="layui-card-body" style="display: flex;align-items: center;">
|
|
<label class="layui-form-label" style="width: 85px;">学校类型:</label>
|
|
<div style="width: 100%;">
|
|
<select name="schoolType" xm-select="schoolTypeXm" xm-select-skin="normal">
|
|
<option value="幼儿园">幼儿园</option>
|
|
<option value="小学">小学</option>
|
|
<option value="初级中学">初级中学</option>
|
|
<option value="高级中学">高级中学</option>
|
|
<option value="完全中学">完全中学</option>
|
|
<option value="九年一贯制学校">九年一贯制学校</option>
|
|
<option value="十二年一贯制学校">十二年一贯制学校</option>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="layui-card-body" style="display: flex;align-items: center;">
|
|
<label class="layui-form-label" style="width: 85px;">区(县):</label>
|
|
<div style="width: 100%;">
|
|
<select name="area" xm-select="areaXm" xm-select-skin="normal">
|
|
<option value="雨湖区">雨湖区</option>
|
|
<option value="岳塘区">岳塘区</option>
|
|
<option value="湘潭县">湘潭县</option>
|
|
<option value="湖南湘潭高新技术产业园区">湖南湘潭高新技术产业园区</option>
|
|
<option value="湘潭昭山示范区">湘潭昭山示范区</option>
|
|
<option value="湘潭九华示范区">湘潭九华示范区</option>
|
|
<option value="湘乡市">湘乡市</option>
|
|
<option value="韶山市">韶山市</option>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="layui-card">
|
|
<div class="layui-card-header" style="font-weight: bold;">
|
|
准确选择接收单位
|
|
</div>
|
|
<div class="layui-card-body">
|
|
<div id="treeDemo" class="ztree" style="height: 162px;overflow-y:auto;"></div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- <button class="layui-btn example-btn" lay-submit lay-filter="test-query">获取选中</button> -->
|
|
<div class="bottom">
|
|
<div class="button-container">
|
|
<button type="submit" class="pear-btn pear-btn-primary pear-btn-sm" lay-submit lay-filter="save-task">
|
|
确 定<i class="layui-icon layui-icon-right"></i>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
</form>
|
|
<script src="../../component/layui/layui.js"></script>
|
|
<script src="../../component/pear/pear.js"></script>
|
|
<script src="../../component/other/js/base64.js"></script>
|
|
<script src="../../component/other/js/jquery.min.js"></script>
|
|
<script src="../../component/other/js/jquery.ztree.core.min.js"></script>
|
|
<script src="../../component/other/js/jquery.ztree.excheck.min.js"></script>
|
|
|
|
<script>
|
|
layui.use(['select', 'laytpl', 'jquery', 'form', 'laydate'], function () {
|
|
var form = layui.form
|
|
, select = layui.select
|
|
, laytpl = layui.laytpl
|
|
, laydate = layui.laydate
|
|
, $ = layui.jquery;
|
|
|
|
//日期
|
|
laydate.render({
|
|
elem: '#endDate'
|
|
});
|
|
|
|
let taskId = GetQueryString("task_id");
|
|
let asyncFinish = 0;
|
|
let rangeJson;
|
|
let expandArr;
|
|
let checkArr;
|
|
|
|
//获取表单模板下拉菜单
|
|
$.ajax({
|
|
type: "GET",
|
|
dataType: "json",
|
|
url: "/Mars/listModule?page=1&limit=1000",
|
|
success: function (data) {
|
|
var moduleSelectTpl = moduleSelectScript.innerHTML,
|
|
moduleSelectView = document.getElementById('moduleSelectView');
|
|
laytpl(moduleSelectTpl).render(data, function (html) {
|
|
moduleSelectView.innerHTML = html;
|
|
form.render()
|
|
});
|
|
}
|
|
});
|
|
|
|
//获取回显信息
|
|
$.ajax({
|
|
url: "/Mars/getTask",
|
|
data: { "task_id": taskId },
|
|
type: 'GET',
|
|
success: function (result) {
|
|
if (result.success) {
|
|
expandArr = result.data.expandInfo;
|
|
rangeJson = JSON.parse(result.data.range_json);
|
|
checkArr = rangeJson.receiveOrgs;
|
|
//调用树的初始化
|
|
initTree();
|
|
|
|
$("#taskName").val(result.data.task_name);
|
|
$("#moduleSelect").val(result.data.module_id);
|
|
let endDate = result.data.end_date;
|
|
$("#endDate").val(endDate.substr(0, 10));
|
|
|
|
select.value('schoolTypeXm', rangeJson.receiveRangeSchoolType);
|
|
select.value('areaXm', rangeJson.receiveRangeArea);
|
|
|
|
|
|
form.render()
|
|
|
|
|
|
} else {
|
|
layer.msg(result.message, {
|
|
icon: 2,
|
|
time: 1000
|
|
});
|
|
}
|
|
}
|
|
});
|
|
|
|
|
|
var treeObj;
|
|
var setting = {
|
|
async: {
|
|
enable: true,
|
|
url: "/Mars/getSelectTree",
|
|
autoParam: ["id"],
|
|
type: "get"
|
|
},
|
|
check: {
|
|
enable: true
|
|
},
|
|
callback: {
|
|
onAsyncSuccess: zTreeOnAsyncSuccess
|
|
}
|
|
};
|
|
|
|
//初始化tree
|
|
function initTree() {
|
|
$(document).ready(function () {
|
|
treeObj = $.fn.zTree.init($("#treeDemo"), setting);
|
|
});
|
|
}
|
|
|
|
function zTreeOnAsyncSuccess(event, treeId, treeNode, msg) {
|
|
if (typeof (treeNode) == "undefined") {
|
|
var node = treeObj.getNodeByTId("1");
|
|
treeObj.expandNode(node, true);
|
|
} else {
|
|
var nodeId = expandArr.shift();
|
|
var node = treeObj.getNodeByParam("id", nodeId, null);
|
|
treeObj.expandNode(node, true);
|
|
if (expandArr.length === 0) {
|
|
if (asyncFinish === 1) {
|
|
selectedCheckNode();
|
|
}
|
|
asyncFinish = 1;
|
|
}
|
|
}
|
|
};
|
|
|
|
function selectedCheckNode() {
|
|
checkArr.forEach((item) => {
|
|
var checkNode = treeObj.getNodeByParam("id", item, null);
|
|
treeObj.checkNode(checkNode, true, true);
|
|
});
|
|
}
|
|
|
|
form.on('submit(save-task)', function (data) {
|
|
|
|
let _field = data.field;
|
|
let taskName = _field.taskName;
|
|
let moduleId = _field.moduleSelect;
|
|
let endDate = _field.endDate;
|
|
|
|
let receiveRangeSchoolType = select.value('schoolTypeXm', 'val');
|
|
let receiveRangeArea = select.value('areaXm', 'val');
|
|
let receiveOrgs = [];
|
|
|
|
var nodes = treeObj.getCheckedNodes(true);
|
|
for (var i = 0; i < nodes.length; i++) {
|
|
if (!nodes[i].getCheckStatus().half) {
|
|
receiveOrgs.push(nodes[i].id)
|
|
}
|
|
}
|
|
|
|
if (receiveRangeSchoolType.length == 0 && receiveRangeArea.length == 0 && receiveOrgs.length == 0) {
|
|
layer.msg("必须选择接收范围或单位", {
|
|
icon: 2,
|
|
time: 2500
|
|
});
|
|
return;
|
|
}
|
|
|
|
var receiveObj = { "receiveRangeSchoolType": receiveRangeSchoolType, "receiveRangeArea": receiveRangeArea, "receiveOrgs": receiveOrgs }
|
|
|
|
$.ajax({
|
|
type: "POST",
|
|
url: "/Mars/updateTask",
|
|
data: { "task_id": taskId, "module_id": moduleId, "task_name": taskName, "end_date": endDate, "range_json": JSON.stringify(receiveObj) },
|
|
success: function (data) {
|
|
if (data.success) {
|
|
layer.msg(data.message, {
|
|
icon: 1,
|
|
time: 1500
|
|
}, function () {
|
|
parent.layer.close(parent.layer.getFrameIndex(window.name));
|
|
parent.parentTableRender();
|
|
});
|
|
} else {
|
|
layer.msg(data.message, {
|
|
icon: 2,
|
|
time: 1000
|
|
});
|
|
}
|
|
}
|
|
});
|
|
|
|
return false;
|
|
|
|
|
|
});
|
|
|
|
function GetQueryString(name, istop) {
|
|
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
|
|
var r = window.location.search.substr(1).match(reg);
|
|
if (typeof (istop) != "undefined") r = top.location.search.substr(1).match(reg);
|
|
|
|
if (r != null) return unescape(r[2]);
|
|
return null;
|
|
}
|
|
});
|
|
</script>
|
|
</body>
|
|
|
|
</html> |