btxtgxq-system-city/src/main/resources/static/route/communityboss/save.html
2021-06-17 11:16:43 +08:00

548 lines
24 KiB
HTML
Executable File

<!doctype html>
<html lang="en">
<head>
<base href="/servicecity/">
<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">
</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" lay-filter="dataForm">
<div class="layui-form-item">
<label class="layui-form-label">地区名称</label>
<div class="layui-input-block">
<input type="text" name="areaName" id="areaName" placeholder="请选择地区" class="layui-input">
<input type="hidden" name="areaId" id="areaId">
</div>
</div>
<div class="layui-form-item" id="communityBossParentNameDiv">
<label class="layui-form-label">上级片长</label>
<div class="layui-input-block">
<input type="text" name="communityBossParentName" id="communityBossParentName" placeholder="请选择上级片长" class="layui-input">
<input type="hidden" name="communityBossParentUserId" id="communityBossParentUserId">
<input type="hidden" name="communityBossParentId" id="communityBossParentId">
</div>
</div>
<div class="layui-form-item" id="communityNameDiv">
<label class="layui-form-label">社区名称</label>
<div class="layui-input-block">
<input type="text" name="communityName" id="communityName" placeholder="请输入社区名称" class="layui-input">
<input type="hidden" name="communityId" id="communityId">
</div>
</div>
<div class="layui-form-item" id="districtNameDiv">
<label class="layui-form-label">小区名称</label>
<div class="layui-input-block">
<input type="text" name="districtName" id="districtName" placeholder="请输入小区名称" class="layui-input" readonly="readonly">
<input type="hidden" name="districtId" id="districtId">
</div>
</div>
<div class="layui-form-item" id="buildingNameDiv">
<label class="layui-form-label">楼宇名称</label>
<div class="layui-input-block">
<input type="text" name="buildingName" id="buildingName" placeholder="请输入楼宇名称" class="layui-input" readonly="readonly">
<input type="hidden" name="buildingId" id="buildingId">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">片长</label>
<div class="layui-input-block">
<input type="text" name="communityBossName" id="communityBossName" placeholder="请选择片长" class="layui-input">
<input type="hidden" name="communityBossUserId" id="communityBossUserId">
</div>
</div>
<div class="layui-form-item" id="communityBossUsernameDiv">
<label class="layui-form-label">用户名</label>
<div class="layui-input-block">
<input type="text" name="communityBossUsername" id="communityBossUsername" placeholder="请选择片长" readonly class="layui-input">
</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 src="assets/layuiadmin/layui/layui.js"></script>
<script type="text/javascript">
layui.config({
base: 'assets/layuiadmin/' //静态资源所在路径
}).extend({
index: 'lib/index' //主入口模块
}).use(['index', 'form', 'laydate'], function() {
var $ = layui.$;
var form = layui.form;
var dictionaryParentId = top.restAjax.params(window.location.href).dictParentId;
var hrefParams = top.restAjax.params(window.location.href);
var communityBossLevel = hrefParams.communityBossLevel;
var formObject = {
communityBossUserId: null,
communityBossUsername: null,
communityBossName: null,
communityBossParentUserId: '0',
communityBossParentName: null,
communityBossLevel: communityBossLevel,
areaId: null,
areaName: null,
communityId: null,
communityName: null,
districtId:null,
districtName:null,
buildingId:null,
buildingName:null
};
var selectedCommunities = [];
var selectedDistricts = [];
var selectedBuildings = [];
var checkCommunityBossIdTimeout = null;
// 页面加载时,判断显示隐藏元素的方法
function pageShow() {
// 上级片长、社区名称
if(formObject.communityBossLevel > 1) {
$('#communityBossParentNameDiv').show();
$('#communityNameDiv').show();
}else {
$('#communityBossParentNameDiv').hide();
$('#communityNameDiv').hide();
}
if(formObject.communityBossLevel == 3 || formObject.communityBossLevel == 4 || formObject.communityBossLevel == 5){
$("#districtNameDiv").show();
}else{
$("#districtNameDiv").hide();
}
if(formObject.communityBossLevel == 4 || formObject.communityBossLevel == 5){
$("#buildingNameDiv").show();
}else{
$("#buildingNameDiv").hide();
}
// 用用户名
if(formObject.communityBossUserId != null) {
$('#communityBossUsernameDiv').show();
}else {
$('#communityBossUsernameDiv').hide();
}
}
pageShow();
// selectAreaFun调用
function areaIdChange(val) {
formObject.communityBossParentUserId = null;
formObject.communityBossParentName = null;
}
// selectHeightCommunityBossFun调用
function communityBossParentUserIdChange(val) {
selectedCommunities = [];
}
// selectCommunityFun调用
function selectedCommunitiesChange(val) {
if(val.length == 0) {
formObject.communityId = null;
formObject.communityName = null;
} else {
var communityId = '';
var communityName = '';
for(var i = 0, item = val[i]; item = val[i++];) {
if(communityId.length > 0) {
communityId += ',';
communityName += ',';
}
communityId += item.id;
communityName += item.name;
}
formObject.communityId = communityId;
formObject.communityName = communityName;
}
}
// 片长选择变化(选择片长弹窗调用)
function bossIdChange(val, userUserName) {
if(val == null) {
return;
}
$('#communityBossUsernameDiv').show();
$('#communityBossUsername').val(userUserName);
}
// 点击地区名称选择输入框,弹出层方法
$(document).on('click', '#areaName', function() {
selectArea();
});
// 点击上级片长选择输入框,弹出层方法
$(document).on('click', '#communityBossParentName', function() {
selectHeightCommunityBoss();
});
// 点击社区名称选择输入框,弹出层方法
$(document).on('click', '#communityName', function() {
selectCommunity();
});
// 点击片长选择输入框,弹出层方法
$(document).on('click', '#communityBossName', function() {
selectDepartmentUsers();
});
// 点击小区选择输入框,弹出层方法
$(document).on('click', '#districtName', function() {
selectDistrict();
});
// 点击楼宇选择输入框,弹出层方法
$(document).on('click', '#buildingName', function() {
selectBuilding();
});
function closeBox() {
parent.layer.close(parent.layer.getFrameIndex(window.name));
}
form.on('submit(submitForm)', function(formData) {
var loadLayerIndex;
top.dialog.confirm(top.dataMessage.commit, function(index) {
top.dialog.close(index);
formData.field['communityBossLevel'] = formObject.communityBossLevel;
top.restAjax.post(top.restAjax.path('api/communityboss/savecommunityboss', []), formData.field, null, function (code, data) {
// success
var layerIndex = top.dialog.msg(top.dataMessage.commitSuccess, {
time: 0,
btn: [top.dataMessage.button.yes, top.dataMessage.button.no],
shade: 0.3,
yes: function () {
top.dialog.close(layerIndex);
window.location.reload();
},
btn2: function () {
closeBox();
}
});
}, function (code, data) {
// error
top.dialog.msg(data.msg);
}, function () {
// before
loadLayerIndex = top.dialog.msg(top.dataMessage.committing, {icon: 16, time: 0, shade: 0.3});
}, function () {
// complete
top.dialog.close(loadLayerIndex);
});
});
return false;
})
function selectDepartmentUsers() {
top.dialog.dialogData.selectedUserIds = $('#communityBossUserId').val();
top.dialog.user({
url: top.restAjax.path('route/system/user/select-department-user.html', []),
title: '选择组织部门人员',
width: '500px',
height: '500px',
onClose: function () {
var userIds = '';
var userNames = '';
var userUserName = '';
var selectedUsers = top.dialog.dialogData.selectedDepartmentUsers;
if(selectedUsers != null && selectedUsers.length > 0) {
if(selectedUsers.length > 1) {
top.dialog.msg('最多选择一名人员,请重新选择');
return false;
}
var selectedUserIds = '';
for (var i = 0, item; item = selectedUsers[i++];) {
if(userIds.length > 0) {
userIds += ',';
userNames += ',';
userUserName += ',';
}
userIds += item.userId;
userNames += item.userName;
userUserName += item.userUsername;
}
bossIdChange(userIds, userUserName);
}
$('#communityBossName').val(userNames);
$('#communityBossUserId').val(userIds);
}
});
}
function selectArea() {
top.dialog.tree({
title: '所属地区',
apiUri: 'api/dict/listztreedict',
width: '200px',
height: '400px',
defaultParams: {id: '9d179f05-3ea0-48f7-853c-d3b7124b791c'},
selectedNodes: [
{
id: formObject.areaId,
name: formObject.areaName,
title: formObject.areaName
}
],
onClose: function() {
var selectNodes = top.dialog.dialogTreeData.selectedNodes;
if(typeof(selectNodes) != 'undefined' && selectNodes != null) {
if(selectNodes.length > 0) {
var selectedNode = selectNodes[0];
formObject.areaId = selectedNode.id;
formObject.areaName = selectedNode.name;
areaIdChange();
$('#areaId').val(selectedNode.id);
$('#areaName').val(selectedNode.name);
} else {
formObject.areaId = null;
formObject.areaName = null;
areaIdChange();
$('#areaId').val();
$('#areaName').val();
}
}
}
});
}
function selectHeightCommunityBoss() {
if(formObject.areaId == null) {
top.dialog.msg('请先选择地区');
return;
}
top.dialog.tree({
title: '选择上级片长',
apiUri: 'api/communityboss/listcommunityboss',
width: '200px',
height: '400px',
otherParams: {
areaId: formObject.areaId,
communityBossLevel: parseInt(formObject.communityBossLevel) - 1
},
dataFilter: function(treeId, parentNode, childNodes) {
for(var i = 0, item = childNodes[i]; item = childNodes[i++];) {
item.name = item.communityBossName;
item.id = item.communityBossUserId;
item.title = item.communityBossId;
}
return childNodes;
},
selectedNodes: [
{
id: formObject.communityBossParentUserId,
name: formObject.communityBossParentName,
title: formObject.communityBossId
}
],
onClose: function() {
var selectNodes = top.dialog.dialogTreeData.selectedNodes;
if(typeof(selectNodes) != 'undefined' && selectNodes != null) {
if(selectNodes.length > 0) {
var selectedNode = selectNodes[0];
formObject.communityBossParentId = selectedNode.title;
formObject.communityBossParentUserId = selectedNode.id;
formObject.communityBossParentName = selectedNode.name;
communityBossParentUserIdChange();
$('#communityBossParentId').val(selectedNode.title);
$('#communityBossParentUserId').val(selectedNode.id);
$('#communityBossParentName').val(selectedNode.name);
} else {
formObject.communityBossParentId = null;
formObject.communityBossParentUserId = null;
formObject.communityBossParentName = null;
communityBossParentUserIdChange();
$('#communityBossParentId').val('');
$('#communityBossParentUserId').val('');
$('#communityBossParentName').val('');
}
}
}
});
}
// 选择社区
function selectCommunity() {
if(formObject.areaId == null) {
top.dialog.msg('请先选择地区');
return;
}
var communityBossLevel = parseInt(formObject.communityBossLevel) - 1;
var apiUri = null;
var otherParams = null;
if(formObject.communityBossLevel == '2') {
apiUri = 'api/community/listcommunity';
otherParams = {
areaId: formObject.areaId
}
} else if(formObject.communityBossLevel == '3') {
apiUri = top.restAjax.path('api/communityboss/listcommunitybosscommunity/{communityBossId}', [formObject.communityBossParentId]);
otherParams = {}
} else if(formObject.communityBossLevel == '4') {
apiUri = top.restAjax.path('api/communityboss/listcommunitybosscommunity/{communityBossId}', [formObject.communityBossParentId]);
otherParams = {}
} else if(formObject.communityBossLevel == '5') {
apiUri = top.restAjax.path('api/communityboss/listcommunitybosscommunity/{communityBossId}', [formObject.communityBossParentId]);
otherParams = {}
} else {
return;
}
top.dialog.tree({
title: '选择社区',
apiUri: apiUri,
width: '200px',
height: '400px',
otherParams: otherParams,
dataFilter: function(treeId, parentNode, childNodes) {
for(var i = 0, item = childNodes[i]; item = childNodes[i++];) {
item.name = item.communityName;
item.id = item.communityId;
}
return childNodes;
},
check: {
enable: true,
selectType: 'checkbox',
checkboxType: {Y: 'ps', N: 'ps'},
radioType: 'level',
},
selectedNodes: selectedCommunities,
onClose: function() {
var selectNodes = top.dialog.dialogTreeData.selectedNodes;
if(typeof(selectNodes) != 'undefined' && selectNodes != null) {
selectedCommunities = selectNodes;
selectedCommunitiesChange(selectedCommunities);
$('#communityName').val(formObject.communityName);
$('#communityId').val(formObject.communityId);
}
}
});
}
//选择小区
function selectDistrict(){
if(formObject.communityId == null) {
top.dialog.msg('请先选择社区');
return;
}
top.dialog.tree({
title: '选择小区',
apiUri: top.restAjax.path('api/citydistrict/listCityDistrictByCommunityIds/{communityIds}', [formObject.communityId]),
width: '200px',
height: '400px',
otherParams: {},
dataFilter: function(treeId, parentNode, childNodes) {
for(var i = 0, item = childNodes[i]; item = childNodes[i++];) {
item.name = item.districtName;
item.id = item.cityDistrictId;
}
return childNodes;
},
check: {
enable: true,
selectType: 'checkbox',
checkboxType: {Y: 'ps', N: 'ps'},
radioType: 'level',
},
selectedNodes: selectedDistricts,
onClose: function() {
var selectNodes = top.dialog.dialogTreeData.selectedNodes;
if(typeof(selectNodes) != 'undefined' && selectNodes != null) {
var districtName = '';
var districtId = '';
for(var i = 0, item = selectNodes[i]; item = selectNodes[i++];) {
if(districtId.length > 0) {
districtId += ',';
districtName += ',';
}
districtId += item.id;
districtName += item.name;
}
formObject.districtId = districtId;
formObject.districtName = districtName;
$('#districtId').val(formObject.districtId);
$('#districtName').val(formObject.districtName);
}
}
});
}
//选择楼宇
function selectBuilding(){
if(formObject.districtId == null) {
top.dialog.msg('请先选择小区');
return;
}
top.dialog.tree({
title: '选择楼宇',
apiUri: top.restAjax.path('api/citybuilding/listCityBuildingByDistrictIds/{districtId}', [formObject.districtId]),
width: '200px',
height: '400px',
otherParams: {},
dataFilter: function(treeId, parentNode, childNodes) {
for(var i = 0, item = childNodes[i]; item = childNodes[i++];) {
item.name = item.buildingName;
item.id = item.cityBuildingId;
}
return childNodes;
},
check: {
enable: true,
selectType: 'checkbox',
checkboxType: {Y: 'ps', N: 'ps'},
radioType: 'level',
},
selectedNodes: selectedBuildings,
onClose: function() {
var selectNodes = top.dialog.dialogTreeData.selectedNodes;
if(typeof(selectNodes) != 'undefined' && selectNodes != null) {
var buildingName = '';
var buildingId = '';
for(var i = 0, item = selectNodes[i]; item = selectNodes[i++];) {
if(buildingId.length > 0) {
buildingId += ',';
buildingName += ',';
}
buildingId += item.id;
buildingName += item.name;
}
formObject.buildingId = buildingId;
formObject.buildingName = buildingName;
$('#buildingId').val(formObject.buildingId);
$('#buildingName').val(formObject.buildingName);
}
}
});
}
$('.close').on('click', function() {
closeBox();
});
});
</script>
</body>
</html>