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.

355 lines
16 KiB

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
<link rel="stylesheet" href="../../../component/pear/css/pear.css" />
<style>
.require-star {
position: absolute;
width: 3px;
height: 14px;
background-color: #ea4335;
top: 12px;
right: 8px;
border-radius: 1.5px;
}
.input-width {
max-width: 470px
}
</style>
</head>
<body>
<form class="layui-form" action="">
<div class="mainBox" style="overflow: hidden;">
<div class="main-container" style="margin-top: 20px;margin-bottom: 0;">
<div class="layui-form-item">
<label class="layui-form-label" style="width: 100px !important;"><span
class="require-star"></span>填报截止日期:</label>
<div class="layui-input-block" style="margin-left: 90px !important;">
<input type="text" class="layui-input input-width" lay-verify="required" name="deadline_time"
id="endDate" placeholder="请选择截止日期">
</div>
</div>
<div class="layui-form-item" style="margin-bottom: 0 !important;">
<label class="layui-form-label" style="width: 100px !important;"><span
class="require-star"></span>选择范围:</label>
<div class="layui-input-block" style="margin-left: 134px !important;">
<div class="layui-tab layui-tab-brief">
<ul class="layui-tab-title" style="border-bottom-style:none">
<li class="layui-this">按单位类型</li>
<li>按指定单位</li>
<li>按指定分组</li>
</ul>
<div class="layui-tab-content">
<div class="layui-tab-item layui-show">
<input type="checkbox" id="zsxx" lay-skin="tag" title="市直学校">
<input type="checkbox" id="szjf" lay-skin="tag" title="市直教辅单位">
<input type="checkbox" id="xqjyj" lay-skin="tag" title="县区教育局">
</div>
<div class="layui-tab-item">
<div style="display: flex;align-items:flex-end">
<div class="layui-input-inline" style="width: auto;">
<div class="layui-btn-container tag" lay-filter="orgs" lay-allowclose="true"
style="border-style:dashed;border-width:1px;border-color: #CCCCCC;height: 100px;width: 545px;padding: 10px;overflow: auto;">
</div>
</div>
<div class="layui-input-inline" style="width: auto;">
<button type="button" class="layui-btn layui-btn-primary layui-btn-xs"
lay-on="saveGroup">保存到分组</button>
</div>
</div>
<div id="tableDiv" style="width: 650px;">
<table id="data-table"></table>
<script type="text/html" id="table-toolbar">
<div class="layui-input-inline" style="margin-left: -16px;width: 150px !important;">
<select id="orgTypeId" name="orgTypeId" lay-filter="orgTypeId">
<option value="-1">全部</option>
<option value="5">市直教辅单位</option>
<option value="9">市直学校</option>
<option value="11">区县教育局</option>
</select>
</div>
<div class="layui-input-group" style="margin-left: -16px;">
<input type="text" id="org_name" placeholder="请输入单位名称" class="layui-input" lay-affix="clear" lay-filter="clear">
<div class="layui-input-split layui-input-suffix" style="cursor: pointer;" lay-on="confirm">
<i class="layui-icon layui-icon-search"></i>
</div>
</div>
</script>
<script type="text/html" id="select-enable">
<input type="checkbox" id="{{d.org_id}}" lay-skin="switch" lay-text="已选|未选" lay-filter="switchEnable"
{{ d.sw == true ? "checked" : "" }}>
</script>
</div>
</div>
<div class="layui-tab-item">
<table id="group-table"></table>
<script type="text/html" id="group-bar">
<button type="button" class="layui-btn layui-btn-xs layui-btn-danger">
<i class="layui-icon layui-icon-delete"></i>
</button>
</script>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="bottom">
<div class="button-container">
<button type="submit" class="pear-btn pear-btn-primary pear-btn-sm" lay-submit="" lay-filter="publish">
<i class="layui-icon layui-icon-release"></i>
发布
</button>
</div>
</div>
</form>
<script src="../../../component/layui/layui.js"></script>
<script src="../../../component/pear/pear.js"></script>
<script>
layui.use(['tag'], function () {
var form = layui.form;
var $ = layui.jquery;
var laydate = layui.laydate;
var tab = layui.tab;
var util = layui.util;
var tag = layui.tag;
var table = layui.table;
var bureauIds = [];
var jobId = GetQueryString("job_id");
laydate.render({
elem: '#endDate',
min: 0
});
table.render({
elem: '#data-table',
id: 'myTable',
url: '/QingLong/collect/getBureauList',
where: {
org_type_id: "-1",
org_name: $("#org_name").val()
},
height: 'full-130',
page: {
limit: 5
, layout: ['count', 'prev', 'page', 'next', 'skip']
, prev: "上一页"
, next: "下一页"
},
cols: [[
{ title: '序号', align: 'center', width: "5%", type: 'numbers' },
{ title: '单位名称', field: 'org_name', align: 'center' },
{ title: '单位类型', field: 'org_type_name', align: 'center', width: "20%" },
{ title: '操作', align: 'center', width: "25%", templet: '#select-enable' }
]],
skin: 'line',
toolbar: '#table-toolbar',
defaultToolbar: [],
parseData: function (res) {
var data = res.data;
for (var i = 0; i < data.length; i++) {
switch (data[i].org_type_id) {
case 5:
res.data[i].org_type_name = '市直教辅单位';
break;
case 9:
res.data[i].org_type_name = '市直学校';
break;
case 11:
res.data[i].org_type_name = '区县教育局';
break;
default:
res.data[i].org_type_name = '--';
break;
}
res.data[i].sw = false
if (bureauIds.includes(data[i].org_id)) {
res.data[i].sw = true
}
}
return res;
},
done: function (res, curr, count) {
var options = this;
// 获取当前行数据
table.getRowData = function (tableId, elem) {
var index = $(elem).closest('tr').data('index');
return table.cache[tableId][index] || {};
};
form.on('switch(switchEnable)', function (obj) {
var data = table.getRowData(options.id, this);
if (obj.elem.checked) {
tag.add('orgs', { text: data.org_name, id: data.org_id });
bureauIds.push(data.org_id);
}
else {
tag.delete('orgs', data.org_id);
}
});
}
});
table.render({
elem: '#group-table',
url: '/QingLong/collect/listGroup',
height: 'full-130',
cols: [[
{ type: 'checkbox', width: "5%" },
{ title: '序号', align: 'center', width: "5%", type: 'numbers' },
{ title: '分名称', field: 'group_name', align: 'center' },
{ title: '操作', toolbar: '#group-bar',align: 'center', width: "25%" }
]],
skin: 'line',
defaultToolbar: []
});
tag.on('delete(orgs)', function (data) {
var orgId = data.elem.prevObject.prevObject[0].getAttribute("lay-id");
bureauIds = bureauIds.filter(item => item !== orgId);
var switchElem = $('#' + orgId);
switchElem.prop('checked', false);
form.render();
});
util.on({
confirm: function () {
tableReload();
},
saveGroup: function () {
if (Array.isArray(bureauIds) && bureauIds.length === 0) {
layer.msg("请先选择单位!", {
icon: 2,
time: 1500
});
} else {
layer.open({
type: 2,
title: '保存分组',
shadeClose: true,
shade: 0,
area: ['600px', '200px'],
content: './save_group.html?bureau_ids=' + bureauIds.join(",")
});
}
}
});
form.on('select(orgTypeId)', function (data) {
tableReload()
});
form.on('input-affix(clear)', function (data) {
tableReload();
});
function tableReload() {
table.reloadData('myTable', {
where: {
org_type_id: $("#orgTypeId").val(),
org_name: $("#org_name").val()
},
scrollPos: false
});
}
form.on('submit(publish)', function (data) {
var shiZhiSchool = 0;
var shiZhiJiaoFu = 0;
var quXiaoJiaoYuJu = 0;
$('input[type="checkbox"]').each(function () {
var isChecked = $(this).prop('checked');
var checkboxText = $(this).attr('id');
if (isChecked) {
if (checkboxText == 'zsxx') {
shiZhiSchool = 1;
} else if (checkboxText == 'szjf') {
shiZhiJiaoFu = 1;
} else if (checkboxText == 'xqjyj') {
quXiaoJiaoYuJu = 1;
}
}
});
if (shiZhiSchool === 0 && shiZhiJiaoFu === 0 && quXiaoJiaoYuJu === 0 && Array.isArray(bureauIds) && bureauIds.length === 0) {
layer.msg("请选择发布范围!", {
icon: 3,
time: 1500
});
}
else {
data.field["job_id"] = jobId;
data.field["shiZhiSchool"] = shiZhiSchool;
data.field["shiZhiJiaoFu"] = shiZhiJiaoFu;
data.field["quXiaoJiaoYuJu"] = quXiaoJiaoYuJu;
data.field["bureauIds"] = bureauIds.join(",");
$.ajax({
url: '/QingLong/collect/publishJob',
type: 'post',
data: data.field,
success: function (result) {
if (result.success) {
layer.msg("发布成功!", {
icon: 1,
time: 1000
}, function () {
parent.layer.close(parent.layer.getFrameIndex(window.name));
parent.refresh();
});
} else {
layer.msg(result.message, {
icon: 2,
time: 2000
});
}
}
});
}
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>
<script>
</script>
</body>
</html>