251 lines
8.7 KiB
HTML
251 lines
8.7 KiB
HTML
|
|
<!DOCTYPE html>
|
||
|
|
<html lang="en" xmlns="http://www.w3.org/1999/html">
|
||
|
|
<head>
|
||
|
|
<meta charset="UTF-8">
|
||
|
|
<title>分公司管理--新增</title>
|
||
|
|
<link rel="stylesheet" type="text/css" media="screen" href="../../layui-v2.8.18/layui/css/layui.css">
|
||
|
|
<link rel="stylesheet" type="text/css" media="screen" href="../../css/publicStyles.css">
|
||
|
|
<link rel="stylesheet" href="../../css/ztree/zTreeStyle/zTreeStyle.css" type="text/css">
|
||
|
|
<style>
|
||
|
|
.layui-form-label {
|
||
|
|
width: 16%;
|
||
|
|
}
|
||
|
|
|
||
|
|
.layui-inline {
|
||
|
|
width: 90%
|
||
|
|
}
|
||
|
|
|
||
|
|
.layui-input {
|
||
|
|
width: 84%
|
||
|
|
}
|
||
|
|
|
||
|
|
textarea {
|
||
|
|
resize: none;
|
||
|
|
}
|
||
|
|
|
||
|
|
.layui-form-select dl {
|
||
|
|
position: absolute;
|
||
|
|
left: 16%;
|
||
|
|
top: 50px;
|
||
|
|
padding: 5px 0;
|
||
|
|
z-index: 899;
|
||
|
|
min-width: 84%;
|
||
|
|
border: 1px solid #eee;
|
||
|
|
max-height: 300px;
|
||
|
|
overflow-y: auto;
|
||
|
|
background-color: #fff;
|
||
|
|
border-radius: 2px;
|
||
|
|
box-shadow: 1px 1px 4px rgb(0 0 0 / 8%);
|
||
|
|
box-sizing: border-box;
|
||
|
|
}
|
||
|
|
|
||
|
|
xm-select {
|
||
|
|
background-color: #FFF;
|
||
|
|
position: relative;
|
||
|
|
border: 1px solid #E6E6E6;
|
||
|
|
border-radius: 2px;
|
||
|
|
display: block;
|
||
|
|
width: 100%;
|
||
|
|
cursor: pointer;
|
||
|
|
outline: none;
|
||
|
|
height: 45px !important;
|
||
|
|
}
|
||
|
|
|
||
|
|
xm-select > .xm-tips {
|
||
|
|
color: #757575 !important;
|
||
|
|
padding: 0 10px;
|
||
|
|
position: absolute;
|
||
|
|
display: flex;
|
||
|
|
height: 100%;
|
||
|
|
align-items: center;
|
||
|
|
font-family: math;
|
||
|
|
font-size: 16px !important;
|
||
|
|
margin-top: 2px !important;
|
||
|
|
}
|
||
|
|
|
||
|
|
xm-select > .xm-label .scroll .label-content {
|
||
|
|
display: flex;
|
||
|
|
padding: 7px 10px !important;
|
||
|
|
}
|
||
|
|
#orgContent{
|
||
|
|
display:none;
|
||
|
|
overflow: auto;
|
||
|
|
width: 30%;
|
||
|
|
height: 300px;
|
||
|
|
position: absolute;
|
||
|
|
z-index: 999;
|
||
|
|
background-color: rgb(255 255 255);
|
||
|
|
left: 195.875px;
|
||
|
|
border: 1px solid #e1e1e1;
|
||
|
|
top: 48px;
|
||
|
|
}
|
||
|
|
.layui-input {
|
||
|
|
width: 65%;
|
||
|
|
}
|
||
|
|
.layui-form-select .layui-edge {
|
||
|
|
left: 82%;
|
||
|
|
}
|
||
|
|
</style>
|
||
|
|
</head>
|
||
|
|
<body>
|
||
|
|
<form class="layui-form" id="projectForm" action="" method="post" onsubmit=" return false">
|
||
|
|
<input id="id" hidden="hidden"/>
|
||
|
|
<div class="layui-form-item" style="margin-top: 2%;width: 99%">
|
||
|
|
<div class="layui-form-item" style="margin-top: 3%;">
|
||
|
|
<div class="layui-inline">
|
||
|
|
<label class="layui-form-label"><i class="tip-required" style="color: red;font-size: 20px">*</i>项目部名称:</label>
|
||
|
|
<input type="text" name="orgName" lay-verify="required" id="orgName" class="layui-input" maxlength="100" oninput="checkMaxLength(this)">
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
<div class="layui-form-item" style="margin-top: 20px;">
|
||
|
|
<div class="layui-inline">
|
||
|
|
<label class="layui-form-label"><i class="tip-required" style="color: red;font-size: 20px">*</i>所属公司:</label>
|
||
|
|
<select id="parentId" class="layui-select" name="parentId" lay-verify="required">
|
||
|
|
</select>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
<div class="layui-form-item" style="display: none">
|
||
|
|
<div class="layui-input-block">
|
||
|
|
<button type="submit" class="layui-btn subBtn" id="commit" lay-submit lay-filter="formDemo">提交
|
||
|
|
</button>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
</form>
|
||
|
|
</body>
|
||
|
|
</html>
|
||
|
|
<script type="text/javascript" src="../../js/jquery/jquery-3.6.0.js"></script>
|
||
|
|
<script type="text/javascript" src="../../js/jq.js"></script>
|
||
|
|
<script type="text/javascript" src="../../layui-v2.8.18/layui/layui.js"></script>
|
||
|
|
<script type="text/javascript" src="../../js/publicJs.js"></script>
|
||
|
|
<script type="text/javascript" src="../../js/common_methon.js"></script>
|
||
|
|
<script type="text/javascript" src="../../js/dict.js"></script>
|
||
|
|
<script type="text/javascript" src="../../js/select.js"></script>
|
||
|
|
<script src="../../css/ztree/3.5/jquery.ztree.all.min.js"></script>
|
||
|
|
<script type="text/javascript">
|
||
|
|
var form;
|
||
|
|
var layuiForm;
|
||
|
|
var laydate;
|
||
|
|
var id = localStorage.getItem("id");
|
||
|
|
$(function () {
|
||
|
|
layui.use(['form', 'laydate', 'upload'], function () {
|
||
|
|
form = layui.form; //只有执行了这一步,部分表单元素才会自动修饰成功
|
||
|
|
layuiForm = form;
|
||
|
|
laydate = layui.laydate;
|
||
|
|
form.render();
|
||
|
|
form.verify({});
|
||
|
|
getSelect(form, '');
|
||
|
|
/**
|
||
|
|
* 修改方法调用数据回显
|
||
|
|
*/
|
||
|
|
if (id != '') {
|
||
|
|
getList();
|
||
|
|
}
|
||
|
|
|
||
|
|
// 验证成功后才会执行下面的操作
|
||
|
|
form.on('submit(formDemo)', function (data) {
|
||
|
|
console.log(data.field);
|
||
|
|
data.field.id = id;
|
||
|
|
addInfo(data); //新增方法
|
||
|
|
});
|
||
|
|
});
|
||
|
|
});
|
||
|
|
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 新增或修改的提交方法
|
||
|
|
* @param formData
|
||
|
|
* @returns {boolean}
|
||
|
|
*/
|
||
|
|
function addInfo(formData) {
|
||
|
|
var tip = '保存';
|
||
|
|
var formUrl = ctxPath + "/corporate/addProjectInfo";
|
||
|
|
if (id != '') {
|
||
|
|
formUrl = ctxPath + "/corporate/updateInfo";
|
||
|
|
tip = '修改';
|
||
|
|
}
|
||
|
|
formData.field.id = id;
|
||
|
|
// 加载提示
|
||
|
|
addLoadingMsg = top.layer.msg('数据上传中,请稍候...', {
|
||
|
|
icon: 16,
|
||
|
|
scrollbar: false,
|
||
|
|
time: 0,
|
||
|
|
shade: [0.8, '#393D49']
|
||
|
|
});
|
||
|
|
$.ajax({
|
||
|
|
type: 'post',
|
||
|
|
async: false, // 默认异步true,false表示同步
|
||
|
|
url: formUrl, // 请求地址
|
||
|
|
contentType: "application/json; charset=utf-8",
|
||
|
|
dataType: 'json', // 服务器返回数据类型
|
||
|
|
data: JSON.stringify(formData.field), //获取提交的表单字段
|
||
|
|
success: function (data) {
|
||
|
|
if (data.resMsg === "发起成功") {
|
||
|
|
parent.layer.closeAll();
|
||
|
|
top.layer.close(addLoadingMsg); //再执行关闭
|
||
|
|
parent.layer.msg(tip + '成功', {icon: 1, time: 2000});
|
||
|
|
window.parent.location.reload();
|
||
|
|
}else {
|
||
|
|
top.layer.close(addLoadingMsg); //再执行关闭
|
||
|
|
parent.layer.msg(tip + '失败', {icon: 2, time: 2000});
|
||
|
|
}
|
||
|
|
},
|
||
|
|
error: function (XMLHttpRequest, textStatus, e) {
|
||
|
|
layer.msg('数据请求发生异常,请稍后重试', {icon: 16, scrollbar: false});
|
||
|
|
top.layer.close(addLoadingMsg); //再执行关闭
|
||
|
|
}
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 根据id获取单个数据进行回显
|
||
|
|
*/
|
||
|
|
function getList() {
|
||
|
|
$.ajax({
|
||
|
|
type: 'POST',
|
||
|
|
async: false, // 默认异步true,false表示同步
|
||
|
|
url: ctxPath + '/corporate/getListProject',// 请求地址
|
||
|
|
dataType: 'json', // 服务器返回数据类型
|
||
|
|
data: {'id': id}, //获取提交的表单字段
|
||
|
|
success: function (data) {
|
||
|
|
var resMsg = data.resMsg;
|
||
|
|
if ("数据获取成功" === resMsg) {
|
||
|
|
let info = data.obj.corporateBean;
|
||
|
|
$("#orgName").val(info.orgName);
|
||
|
|
getSelect(form, info.value);
|
||
|
|
}
|
||
|
|
},
|
||
|
|
error: function (XMLHttpRequest, textStatus, e) {
|
||
|
|
// layer.close(loadingMsg);
|
||
|
|
layer.msg('数据请求发生异常,请稍后重试', {icon: 16, scrollbar: false});
|
||
|
|
}
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
function getSelect(form,Id) {
|
||
|
|
$("#parentId").html("");
|
||
|
|
$.ajax({
|
||
|
|
type: 'post',
|
||
|
|
url: ctxPath + '/selectUtil/getBranchName',
|
||
|
|
data: {
|
||
|
|
},
|
||
|
|
async: false,
|
||
|
|
success: function (data) {
|
||
|
|
var html = '<option value="">--请选择--</option>';
|
||
|
|
for (var i = 0; i < data.length; i++) {
|
||
|
|
if (Id == data[i].id) {
|
||
|
|
html += '<option selected="selected" value=\'' + data[i].id + '\'>' + data[i].name + '</option>';
|
||
|
|
} else {
|
||
|
|
html += '<option value=\'' + data[i].id + '\'>' + data[i].name + '</option>';
|
||
|
|
}
|
||
|
|
}
|
||
|
|
$("#parentId").html(html);
|
||
|
|
layui.form.render('select'); //这里就是我们要渲染的地方了
|
||
|
|
},
|
||
|
|
error: function (err) {
|
||
|
|
console.log("获取分公司下拉列表出错:", err);
|
||
|
|
}
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
</script>
|