添加工种选择树

This commit is contained in:
wans 2021-05-04 14:25:41 +08:00
parent 418a4975e2
commit a6e0f471a6
3 changed files with 122 additions and 6 deletions

View File

@ -4,7 +4,7 @@
<resultMap id="classPlanDTO" type="cn.com.tenlion.pojo.dtos.classplan.ClassPlanDTO">
<id column="class_plan_id" property="classPlanId"/>
<id column="org_id" property="orgId"/>
<result column="org_id" property="orgId"/>
<result column="plan_number" property="planNumber"/>
<result column="plan_name" property="planName"/>
<result column="plan_type" property="planType"/>
@ -265,6 +265,7 @@
<!-- 列表 -->
<select id="list" parameterType="map" resultMap="classPlanDTO">
SELECT
t1.class_plan_id,
t1.plan_number,
t1.org_id,
t1.plan_name,

View File

@ -66,7 +66,10 @@
<div class="layui-col-md4">
<div class="layui-form-item">
<label class="layui-form-label">培训工种</label>
<div class="layui-input-block layui-form" id="workerCatalogSelectTemplateBox" lay-filter="workerCatalogSelectTemplateBox"></div>
<div class="layui-input-block">
<input type="text" id="workerCatalog" name="workerCatalog" class="layui-input" value="" placeholder="请选择培训工种" readonly="readonly" maxlength="255">
</div>
<!--<div class="layui-input-block layui-form" id="workerCatalogSelectTemplateBox" lay-filter="workerCatalogSelectTemplateBox"></div>
<script id="workerCatalogSelectTemplate" type="text/html">
<select id="workerCatalog" name="workerCatalog" lay-verify="required">
<option value="">请选择培训工种</option>
@ -74,7 +77,7 @@
<option value="{{item.dictionaryId}}">{{item.dictionaryName}}</option>
{{# } }}
</select>
</script>
</script>-->
</div>
</div>
<div class="layui-col-md4">
@ -216,11 +219,22 @@
}
initData();
$(document).on('click', '#workerCatalog', function() {
layer.open({
type: 2,
title: '选择工种',
closeBtn: 1,
area: ['200px', '400px'],
shadeClose: false,
anim: 2,
content: top.restAjax.path('route/classplan/select-tree.html', []),
end: function() {
}
});
});
// 初始化培训工种下拉选择
function initWorkerCatalogSelect() {
laytpl(document.getElementById('workerCatalogSelectTemplate').innerHTML).render([], function(html) {
document.getElementById('workerCatalogSelectTemplateBox').innerHTML = html;
});
/*top.restAjax.get(top.restAjax.path('api/datadictionary/listdictionarybyparentid/cbb5f8a8-595c-4df4-b38e-7cbb715f754f', []), {}, null, function(code, data, args) {
laytpl(document.getElementById('workerCatalogSelectTemplate').innerHTML).render(data, function(html) {
document.getElementById('workerCatalogSelectTemplateBox').innerHTML = html;

View File

@ -0,0 +1,101 @@
<!doctype html>
<html lang="en">
<head>
<base href="/signup/">
<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">
<link rel="stylesheet" href="assets/js/vendor/zTree3/css/metroStyle/metroStyle.css"/>
<link rel="stylesheet" href="assets/layuiadmin/style/common.css" media="all">
</head>
<body>
<div class="layui-anim layui-anim-fadein">
<div class="layui-card">
<div class="layui-card-body left-tree-wrap">
<div id="leftTreeWrap">
<ul id="leftTree" class="ztree"></ul>
</div>
</div>
</div>
</div>
<script src="assets/js/vendor/wangEditor/wangEditor.min.js"></script>
<script src="assets/js/vendor/ckplayer/ckplayer/ckplayer.js"></script>
<script src="assets/js/vendor/viewer/viewer.min.js"></script>
<script src="assets/layuiadmin/layui/layui.js"></script>
<script>
var common;
layui.config({
base: 'assets/layuiadmin/'
}).extend({
index: 'lib/index'
}).use(['index', 'ztree', 'common'], function() {
common = layui.common;
var $ = layui.$;
var $win = $(window);
var resizeTimeout = null;
var parentId = '0';
function initData(){
initThree();
initSize();
}
initData();
// 初始化大小
function initSize() {
$('#leftTreeWrap').css({
height: $win.height(),
overflow: 'auto'
});
}
// 初始化树
function initThree() {
var setting = {
async: {
enable: true,
autoLoad: true,
type: 'get',
url: top.restAjax.path('api/worktype/listztree', []),
autoParam: ['id'],
otherParam: {
id : function () {
return parentId;
}
},
dataFilter: function (treeId, parentNode, childNodes) {
if (!childNodes) return null;
for (var i = 0, l = childNodes.length; i < l; i++) {
childNodes[i].name = childNodes[i].name.replace(/\.n/g, '.');
}
return childNodes;
}
},
callback: {
onClick: function (event, treeId, treeNode) {
if(treeNode.isParent == true){
return;
}
parentId = treeNode.id;
return false;
}
},
};
var zTree = $.fn.zTree.init($("#leftTree"), setting);
}
// 事件 - 页面变化
$win.on('resize', function() {
clearTimeout(resizeTimeout);
resizeTimeout = setTimeout(function() {
initSize();
}, 500);
});
});
</script>
</body>
</html>