mirror of https://gitee.com/stylefeng/guns
【hr_organization】功能调整优化
parent
c783f0f2ef
commit
8116103641
|
@ -1,16 +1,40 @@
|
|||
layui.use(['table', 'form', 'func', 'HttpRequest', 'xmSelect', 'util'], function () {
|
||||
layui.use(['table', 'form', 'func', 'HttpRequest', 'tree', 'util'], function () {
|
||||
var $ = layui.$;
|
||||
var table = layui.table;
|
||||
var form = layui.form;
|
||||
var func = layui.func;
|
||||
var HttpRequest = layui.HttpRequest;
|
||||
var xmSelect = layui.xmSelect;
|
||||
var tree = layui.tree;
|
||||
|
||||
// 职位表管理
|
||||
var Organization = {
|
||||
tableId: "organizationTable"
|
||||
};
|
||||
|
||||
|
||||
/* 渲染树形 */
|
||||
function renderTree() {
|
||||
$.get(Feng.ctxPath + '/hrOrganization/treeLayui', function (data) {
|
||||
tree.render({
|
||||
elem: '#organizationTree',
|
||||
onlyIconControl: true,
|
||||
data: data.data,
|
||||
click: function (rest) {
|
||||
$('#organizationTree').find('.ew-tree-click').removeClass('ew-tree-click');
|
||||
$(rest.elem).children('.layui-tree-entry').addClass('ew-tree-click');
|
||||
table.reload(Organization.tableId, {
|
||||
where: {organizationId: rest.data.id},
|
||||
page: {curr: 1}
|
||||
});
|
||||
}
|
||||
});
|
||||
$('#organizationTree').find('.layui-tree-entry:first>.layui-tree-main>.layui-tree-txt').trigger('click');
|
||||
});
|
||||
}
|
||||
|
||||
renderTree();
|
||||
|
||||
// 初始化表格的列
|
||||
Organization.initColumn = function () {
|
||||
return [[
|
||||
|
@ -40,7 +64,7 @@ layui.use(['table', 'form', 'func', 'HttpRequest', 'xmSelect', 'util'], function
|
|||
func.open({
|
||||
height: 800,
|
||||
title: '添加机构',
|
||||
content: Feng.ctxPath + '/hrOrganization/addView',
|
||||
content: Feng.ctxPath + '/organization/addView',
|
||||
tableId: Organization.tableId
|
||||
});
|
||||
};
|
||||
|
@ -68,24 +92,29 @@ layui.use(['table', 'form', 'func', 'HttpRequest', 'xmSelect', 'util'], function
|
|||
// 点击删除
|
||||
Organization.delete = function (data) {
|
||||
var operation = function () {
|
||||
ajaxUtil.post(Feng.ctxPath + "/hrOrganization/delete", {"orgId":data.positionId},function (data) {
|
||||
var httpRequest = new HttpRequest(Feng.ctxPath + "/hrOrganization/delete", 'post', function (data) {
|
||||
Feng.success("删除成功!");
|
||||
table.reload(Organization.tableId);
|
||||
},function (data) {
|
||||
}, function (data) {
|
||||
Feng.error("删除失败!" + data.responseJSON.message + "!");
|
||||
});
|
||||
httpRequest.set(data);
|
||||
httpRequest.start(true);
|
||||
};
|
||||
Feng.confirm("是否删除?", operation);
|
||||
};
|
||||
|
||||
// 修改职位状态
|
||||
Organization.updateStatus = function (positionId, checked) {
|
||||
ajaxUtil.post(Feng.ctxPath + "/hrOrganization/updateStatus", {"orgId":positionId,"statusFlag":checked},function (data) {
|
||||
Feng.success("修改成功!");
|
||||
},function (data) {
|
||||
Feng.error("修改失败!" + data.responseJSON.message);
|
||||
Organization.updateStatus = function (orgId, checked) {
|
||||
var httpRequest = new HttpRequest(Feng.ctxPath + "/hrOrganization/updateStatus", 'post', function (data) {
|
||||
table.reload(Organization.tableId);
|
||||
Feng.success("修改成功!");
|
||||
}, function (data) {
|
||||
table.reload(Organization.tableId);
|
||||
Feng.error("修改失败!" + data.responseJSON.message);
|
||||
});
|
||||
httpRequest.set({"orgId": orgId, "statusFlag": checked});
|
||||
httpRequest.start(true);
|
||||
};
|
||||
|
||||
// 渲染表格
|
||||
|
@ -128,8 +157,8 @@ layui.use(['table', 'form', 'func', 'HttpRequest', 'xmSelect', 'util'], function
|
|||
|
||||
// 修改状态
|
||||
form.on('switch(status)', function (obj) {
|
||||
var positionId = obj.elem.value;
|
||||
var orgId = obj.elem.value;
|
||||
var checked = obj.elem.checked ? 1 : 2;
|
||||
Organization.updateStatus(positionId, checked);
|
||||
Organization.updateStatus(orgId, checked);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,10 +1,38 @@
|
|||
layui.use(['form', 'admin', 'HttpRequest'], function () {
|
||||
layui.use(['form', 'admin', 'HttpRequest', 'xmSelect'], function () {
|
||||
var $ = layui.$;
|
||||
var form = layui.form;
|
||||
var admin = layui.admin;
|
||||
var HttpRequest = layui.HttpRequest;
|
||||
var xmSelect = layui.xmSelect;
|
||||
var insXmSel;
|
||||
|
||||
/* 渲染树形 */
|
||||
function renderTree() {
|
||||
$.get(Feng.ctxPath + '/hrOrganization/treeLayui', function (data) {
|
||||
insXmSel = xmSelect.render({
|
||||
el: '#organizationEditParentSel',
|
||||
height: '250px',
|
||||
data: data.data,
|
||||
model: {label: {type: 'text'}},
|
||||
prop: {name: 'title', value: 'id'},
|
||||
radio: true,
|
||||
clickClose: true,
|
||||
tree: {
|
||||
show: true,
|
||||
indent: 15,
|
||||
strict: false,
|
||||
expandedKeys: true
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
renderTree();
|
||||
|
||||
//表单提交事件
|
||||
form.on('submit(btnSubmit)', function (data) {
|
||||
//获取机构id
|
||||
data.field.orgParentId = insXmSel.getValue('valueStr');
|
||||
var request = new HttpRequest(Feng.ctxPath + "/hrOrganization/add", 'post', function (data) {
|
||||
admin.closeThisDialog();
|
||||
Feng.success("添加成功!");
|
||||
|
|
|
@ -1,16 +1,45 @@
|
|||
layui.use(['form', 'admin', 'HttpRequest'], function () {
|
||||
layui.use(['form', 'admin', 'HttpRequest', 'xmSelect'], function () {
|
||||
var $ = layui.$;
|
||||
var form = layui.form;
|
||||
var admin = layui.admin;
|
||||
var HttpRequest = layui.HttpRequest;
|
||||
var xmSelect = layui.xmSelect;
|
||||
var insXmSel;
|
||||
|
||||
//获取信息详情填充表单
|
||||
var request = new HttpRequest(Feng.ctxPath + "/hrOrganization/detail?orgId=" + Feng.getUrlParam("orgId"), 'get');
|
||||
var result = request.start();
|
||||
console.log(result);
|
||||
|
||||
form.val('organizationForm', result.data);
|
||||
renderTree(result.data.orgParentId);
|
||||
|
||||
/* 渲染树形 */
|
||||
function renderTree(orgParentId) {
|
||||
$.get(Feng.ctxPath + '/hrOrganization/treeLayui', function (data) {
|
||||
insXmSel = xmSelect.render({
|
||||
el: '#organizationEditParentSel',
|
||||
height: '250px',
|
||||
data: data.data,
|
||||
initValue: [orgParentId],
|
||||
model: {label: {type: 'text'}},
|
||||
prop: {name: 'title', value: 'id'},
|
||||
radio: true,
|
||||
clickClose: true,
|
||||
tree: {
|
||||
show: true,
|
||||
indent: 15,
|
||||
strict: false,
|
||||
expandedKeys: true
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
//表单提交事件
|
||||
form.on('submit(btnSubmit)', function (data) {
|
||||
//获取机构id
|
||||
data.field.orgParentId = insXmSel.getValue('valueStr');
|
||||
|
||||
var request = new HttpRequest(Feng.ctxPath + "/hrOrganization/edit", 'post', function (data) {
|
||||
admin.closeThisDialog();
|
||||
Feng.success("修改成功!");
|
||||
|
|
|
@ -93,10 +93,11 @@ layui.use(['table', 'form', 'func', 'HttpRequest', 'util'], function () {
|
|||
// 修改职位状态
|
||||
Position.updateStatus = function (positionId, checked) {
|
||||
var httpRequest = new HttpRequest(Feng.ctxPath + "/hrPosition/updateStatus", 'post', function (data) {
|
||||
table.reload(Position.tableId);
|
||||
Feng.success("修改成功!");
|
||||
}, function (data) {
|
||||
Feng.error("修改失败!" + data.responseJSON.message);
|
||||
table.reload(Position.tableId);
|
||||
Feng.error("修改失败!" + data.responseJSON.message);
|
||||
});
|
||||
httpRequest.set({"positionId": positionId, "statusFlag": checked});
|
||||
httpRequest.start(true);
|
||||
|
|
|
@ -10,18 +10,18 @@
|
|||
<div class="layui-card">
|
||||
<div class="layui-card-body" style="padding: 10px;">
|
||||
<!-- 树工具栏 -->
|
||||
<!-- <div class="layui-form toolbar" id="organizationTreeBar">-->
|
||||
<!-- <button id="organizationAddBtn" class="layui-btn layui-btn-sm icon-btn">-->
|
||||
<!-- <i class="layui-icon"></i>添加-->
|
||||
<!-- </button> -->
|
||||
<!-- <button id="organizationEditBtn" class="layui-btn layui-btn-sm layui-btn-warm icon-btn">-->
|
||||
<!-- <i class="layui-icon"></i>修改-->
|
||||
<!-- </button> -->
|
||||
<!-- <button id="organizationDelBtn"-->
|
||||
<!-- class="layui-btn layui-btn-sm layui-btn-danger icon-btn">-->
|
||||
<!-- <i class="layui-icon"></i>删除-->
|
||||
<!-- </button>-->
|
||||
<!-- </div>-->
|
||||
<!-- <div class="layui-form toolbar" id="organizationTreeBar">-->
|
||||
<!-- <button id="organizationAddBtn" class="layui-btn layui-btn-sm icon-btn">-->
|
||||
<!-- <i class="layui-icon"></i>添加-->
|
||||
<!-- </button> -->
|
||||
<!-- <button id="organizationEditBtn" class="layui-btn layui-btn-sm layui-btn-warm icon-btn">-->
|
||||
<!-- <i class="layui-icon"></i>修改-->
|
||||
<!-- </button> -->
|
||||
<!-- <button id="organizationDelBtn"-->
|
||||
<!-- class="layui-btn layui-btn-sm layui-btn-danger icon-btn">-->
|
||||
<!-- <i class="layui-icon"></i>删除-->
|
||||
<!-- </button>-->
|
||||
<!-- </div>-->
|
||||
<!-- 左树 -->
|
||||
<div id="organizationTree"></div>
|
||||
</div>
|
||||
|
@ -56,6 +56,6 @@
|
|||
</script>
|
||||
|
||||
<script type="text/html" id="statusTpl">
|
||||
<input type="checkbox" lay-filter="status" value="{{d.positionId}}" lay-skin="switch" lay-text="正常|锁定" {{d.statusFlag=='1'?'checked':''}} />
|
||||
<input type="checkbox" lay-filter="status" value="{{d.orgId}}" lay-skin="switch" lay-text="正常|锁定" {{d.statusFlag=='1'?'checked':''}}/>
|
||||
</script>
|
||||
@}
|
|
@ -6,8 +6,14 @@
|
|||
<div class="layui-card-header">基本信息</div>
|
||||
<div class="layui-card-body">
|
||||
<div class="layui-form-item layui-row">
|
||||
<input name="positionId" type="hidden"/>
|
||||
<input name="orgId" type="hidden"/>
|
||||
|
||||
<div class="layui-inline layui-col-md12">
|
||||
<label class="layui-form-label">上级机构<span style="color: red;">*</span></label>
|
||||
<div class="layui-input-block">
|
||||
<div id="organizationEditParentSel" class="ew-xmselect-tree"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-inline layui-col-md12">
|
||||
<label class="layui-form-label">机构名称<span style="color: red;">*</span></label>
|
||||
<div class="layui-input-block">
|
||||
|
@ -27,9 +33,9 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="layui-inline layui-col-md12">
|
||||
<label class="layui-form-label">备注<span style="color: red;">*</span></label>
|
||||
<label class="layui-form-label">备注</label>
|
||||
<div class="layui-input-block">
|
||||
<textarea id="orgRemark" name="orgRemark" placeholder="请输入备注" class="layui-textarea" lay-verify="required" required></textarea>
|
||||
<textarea id="orgRemark" name="orgRemark" placeholder="请输入备注" class="layui-textarea"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -6,8 +6,14 @@
|
|||
<div class="layui-card-header">基本信息</div>
|
||||
<div class="layui-card-body">
|
||||
<div class="layui-form-item layui-row">
|
||||
<input name="positionId" type="hidden"/>
|
||||
<input name="orgId" type="hidden"/>
|
||||
|
||||
<div class="layui-inline layui-col-md12">
|
||||
<label class="layui-form-label">上级机构<span style="color: red;">*</span></label>
|
||||
<div class="layui-input-block">
|
||||
<div id="organizationEditParentSel" class="ew-xmselect-tree"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-inline layui-col-md12">
|
||||
<label class="layui-form-label">机构名称<span style="color: red;">*</span></label>
|
||||
<div class="layui-input-block">
|
||||
|
@ -27,9 +33,9 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="layui-inline layui-col-md12">
|
||||
<label class="layui-form-label">备注<span style="color: red;">*</span></label>
|
||||
<label class="layui-form-label">备注</label>
|
||||
<div class="layui-input-block">
|
||||
<textarea id="orgRemark" name="orgRemark" placeholder="请输入备注" class="layui-textarea" lay-verify="required" required></textarea>
|
||||
<textarea id="orgRemark" name="orgRemark" placeholder="请输入备注" class="layui-textarea"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue