Skip to content

Commit

Permalink
1
Browse files Browse the repository at this point in the history
  • Loading branch information
wujun728 committed Oct 16, 2024
1 parent dac8b26 commit 359835e
Show file tree
Hide file tree
Showing 8 changed files with 1,077 additions and 6 deletions.
3 changes: 2 additions & 1 deletion jun_layui_easyweb/page/system/organization.html
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,8 @@

<!-- js部分 -->
<script type="text/javascript" src="../../assets/libs/layui/layui.js"></script>
<script type="text/javascript" src="../../assets/js/common.js?v=318"></script>
<script type="text/javascript" src="../../assets/js/common.js?v=318"></script>
<script type="text/javascript" src="../../assets/module/treeTable.js?v=318"></script>
<script>
layui.use(['layer', 'form', 'table', 'util', 'admin', 'tree', 'dropdown', 'xmSelect', 'treeTable'], function () {
var $ = layui.jquery;
Expand Down
145 changes: 145 additions & 0 deletions jun_layui_ruoyi/extend/sql/form_tree.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
<!-- 注意这里不需要写`<html><body>`这些东西,它是一个html片段,不是完整的html页面 -->
<form id="organizationEditForm" lay-filter="organizationEditForm" class="layui-form model-form"
style="padding-right: 20px;">
<input name="organizationId" type="hidden"/>
<div class="layui-row">
<div class="layui-col-md6">
<div class="layui-form-item">
<label class="layui-form-label layui-form-required">上级机构:</label>
<div class="layui-input-block">
<div id="organizationEditParentSel" class="ew-xmselect-tree"></div>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label layui-form-required">机构名称:</label>
<div class="layui-input-block">
<input name="organizationName" placeholder="请输入机构名称" class="layui-input"
lay-verType="tips" lay-verify="required" required/>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label layui-form-required">机构全称:</label>
<div class="layui-input-block">
<input name="organizationFullName" placeholder="请输入机构全称" class="layui-input"
lay-verType="tips" lay-verify="required" required/>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label layui-form-required">机构类型:</label>
<div class="layui-input-block">
<select name="organizationType" lay-verType="tips" lay-verify="required" required>
<option value="">请选择机构类型</option>
<option value="1">公司</option>
<option value="2">子公司</option>
<option value="3">部门</option>
<option value="4">小组</option>
</select>
</div>
</div>
</div>
<div class="layui-col-md6">
<div class="layui-form-item">
<label class="layui-form-label layui-form-required">排序号:</label>
<div class="layui-input-block">
<input name="sortNumber" placeholder="请输入排序号" class="layui-input" type="number"
lay-verType="tips" lay-verify="required" required/>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">备注:</label>
<div class="layui-input-block">
<textarea name="comments" placeholder="请输入备注" class="layui-textarea"></textarea>
</div>
</div>
</div>
</div>
<div class="layui-form-item text-right">
<button class="layui-btn" lay-filter="organizationEditSubmit" lay-submit>保存</button>
<button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button>
</div>
</form>

<script>
layui.use(['layer', 'form', 'admin', 'xnUtil', 'xmSelect'], function () {
var $ = layui.jquery;
var layer = layui.layer;
var form = layui.form;
var admin = layui.admin;
var xnUtil = layui.xnUtil;
var xmSelect = layui.xmSelect;

var editData = admin.getLayerData('#extForm').data;

var extOrgTreeRenderIns = {};
// admin.req(getProjectUrl() + 'sysOrg/tree', function(res){
admin.req( 'tree.json', function(res){
// 渲染下拉树
extOrgTreeRenderIns = xmSelect.render({
el: '#extOrgSelectBox',
name: 'orgId',
height: '250px',
layVerify: 'required',
layVerType: 'tips',
data: res.data,
initValue: editData ? [editData.orgId] : [],
model: {label: {type: 'text'}},
prop: {
name: 'title',
value: 'id'
},
radio: true,
clickClose: true,
tree: {
show: true,
indent: 15,
strict: false,
expandedKeys: true
},
tips: '请选择附属机构'
});
}, {async: false});

// 渲染远程数据下拉
var extPosDataRenderIns = {};
// admin.req(getProjectUrl() + 'sysPos/list', function(res){
admin.req( 'sysPosList.json', function(res){
extPosDataRenderIns = xmSelect.render({
el: '#extPosSelectBox',
name: 'posId',
data: res.data,
layVerify: 'required',
layVerType: 'tips',
radio: true,
clickClose: true,
model: { icon:'hidden', label: { type: 'text' }},
prop: {
name: 'name',
value: 'id'
},
tips: '请选择附属职位'
});
}, {async: false});

if(editData !== null && editData !== undefined) {
form.val('extForm', editData);
extPosDataRenderIns.setValue([editData.posId]);
}

// 表单提交事件
form.on('submit(extFormSubmitBtn)', function () {
var resultData = {};
var selectExtOrgData = extOrgTreeRenderIns.getValue();
var selectExtPosData = extPosDataRenderIns.getValue();
resultData.posId = selectExtPosData[0].id;
resultData.posCode = selectExtPosData[0].code;
resultData.posName = selectExtPosData[0].name;
resultData.orgId = selectExtOrgData[0].id;
resultData.orgName = selectExtOrgData[0].title;
admin.putLayerData('formOk', true, '#extForm');
admin.putLayerData('resultData', resultData, '#extForm');
admin.closeDialog('#extForm');
return false;
});

});
</script>
Loading

0 comments on commit 359835e

Please sign in to comment.