parent
387049fc5c
commit
363fd5c0ba
@ -0,0 +1,286 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title></title>
|
||||
<link rel="stylesheet" href="../../../component/layui/css/layui.css" />
|
||||
<link rel="stylesheet" href="../../../component/pear/css/module/toast.css" />
|
||||
|
||||
<style>
|
||||
.layui-table-cell {
|
||||
height: 50px;
|
||||
line-height: 40px;
|
||||
}
|
||||
|
||||
th {
|
||||
color: #303133;
|
||||
background-color: #f5f7fa;
|
||||
}
|
||||
|
||||
.layui-card {
|
||||
box-shadow: 0 0 0 0 rgba(0, 0, 0, 0) !important;
|
||||
margin-bottom: 0 !important;
|
||||
}
|
||||
|
||||
.layui-form-item {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.layui-table td,
|
||||
.layui-table th {
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.bp {
|
||||
background-color: rgba(23, 179, 163, .1);
|
||||
padding: 5px 10px;
|
||||
height: 32px;
|
||||
line-height: 30px;
|
||||
font-size: 12px;
|
||||
color: #17b3a3;
|
||||
border-radius: 4px;
|
||||
-webkit-box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
border: 1px solid rgba(23, 179, 163, .2);
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.xp {
|
||||
background-color: rgba(144, 147, 153, .1);
|
||||
padding: 5px 10px;
|
||||
height: 32px;
|
||||
line-height: 30px;
|
||||
font-size: 12px;
|
||||
color: #909399;
|
||||
border-radius: 4px;
|
||||
-webkit-box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
border: 1px solid rgba(144, 147, 153, .2);
|
||||
white-space: nowrap;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body class="layui-form">
|
||||
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-body">
|
||||
<!-- <div class="layui-form-item layui-inline">
|
||||
<label class="layui-form-label" style="width: auto;">设备名称:</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" id="personName" lay-affix="clear" lay-filter="clear" placeholder="请输入设备名称"
|
||||
class="layui-input">
|
||||
</div>
|
||||
</div> -->
|
||||
<div class="layui-form-item layui-inline">
|
||||
<label class="layui-form-label" style="width: auto;">学科:</label>
|
||||
<div class="layui-input-inline" id="kmView">
|
||||
</div>
|
||||
<script id="kmScript" type="text/html">
|
||||
<select id="kmId" lay-filter="km">
|
||||
{{# layui.each(d, function(index, item){ }}
|
||||
<option value="{{item.km_code}}">{{item.km_name}}</option>
|
||||
{{# }); }}
|
||||
</select>
|
||||
</script>
|
||||
</div>
|
||||
<div class="layui-form-item layui-inline">
|
||||
<label class="layui-form-label" style="width: auto;">分类:</label>
|
||||
<div class="layui-input-inline" id="fenlei" style="width: 241px;">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item layui-inline">
|
||||
<button class="layui-btn layui-btn-sm" lay-submit lay-filter="user-query">
|
||||
<i class="layui-icon layui-icon-search"></i>
|
||||
查询
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<table class="layui-table" id="myTable"></table>
|
||||
<script type="text/html" id="pbyq_templet">
|
||||
|
||||
{{# if(d.bp_xp > 0){ }}
|
||||
<span class="bp" hover="test()">必配</span>
|
||||
{{# } else { }}
|
||||
<span class="xp">选配</span>
|
||||
{{# } }}
|
||||
|
||||
</script>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<script src="../../../component/layui/layui.js"></script>
|
||||
<script src="../../../component/pear/xm-select.js"></script>
|
||||
|
||||
<script>
|
||||
layui.extend({
|
||||
toast: '../../../component/pear/module/toast' // {/}的意思即代表采用自有路径,即不跟随 base 路径
|
||||
}).use(['toast'], function () {
|
||||
var $ = layui.jquery;
|
||||
var table = layui.table;
|
||||
var toast = layui.toast;
|
||||
var form = layui.form;
|
||||
var laytpl = layui.laytpl;
|
||||
|
||||
var xmSelectData = [];
|
||||
|
||||
var fenleiSelect;
|
||||
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
async: false,
|
||||
url: "/QingLong/zbdc/getKm",
|
||||
success: function (res) {
|
||||
var kmTpl = kmScript.innerHTML,
|
||||
kmView = document.getElementById('kmView');
|
||||
laytpl(kmTpl).render(res.data, function (html) {
|
||||
kmView.innerHTML = html;
|
||||
});
|
||||
form.render();
|
||||
getXmSelect();
|
||||
tableRender("");
|
||||
}
|
||||
});
|
||||
|
||||
function test() {
|
||||
console.log(1111);
|
||||
}
|
||||
|
||||
|
||||
|
||||
function getXmSelect() {
|
||||
fenleiSelect = xmSelect.render({
|
||||
el: '#fenlei',
|
||||
clickClose: true,
|
||||
radio: true,
|
||||
autoRow: true,
|
||||
model: {
|
||||
icon: 'hidden'
|
||||
},
|
||||
tree: {
|
||||
show: true,
|
||||
showFolderIcon: true,
|
||||
showLine: true,
|
||||
indent: 20,
|
||||
strict: false,
|
||||
simple: true,
|
||||
expandedKeys: [-3],
|
||||
clickCheck: true,
|
||||
clickExpand: false,
|
||||
},
|
||||
data: [],
|
||||
prop: {
|
||||
value: "id",
|
||||
name: "level_name"
|
||||
}
|
||||
});
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
async: false,
|
||||
url: '/QingLong/zbdc/getKmFeiLeiTree?km_code=' + $("#kmId").val(),
|
||||
success: function (res) {
|
||||
xmSelectData = res.data;
|
||||
fenleiSelect.update({
|
||||
data: res.data
|
||||
});
|
||||
fenleiSelect.changeExpandedKeys(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
form.on('select(km)', function (data) {
|
||||
getXmSelect();
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function findNodeAndParents(levelName) {
|
||||
function search(node, path) {
|
||||
const newPath = [...path, node.level_name];
|
||||
if (node.level_name === levelName) {
|
||||
return newPath;
|
||||
}
|
||||
if (node.children) {
|
||||
for (const child of node.children) {
|
||||
const result = search(child, newPath);
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
for (const root of xmSelectData) {
|
||||
const result = search(root, []);
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
form.on('submit(user-query)', function () {
|
||||
|
||||
var selectArr = fenleiSelect.getValue();
|
||||
if (selectArr.length > 0) {
|
||||
const levelName = selectArr[0].level_name;
|
||||
const result = findNodeAndParents(levelName);
|
||||
tableRender(result.join(','));
|
||||
}
|
||||
else {
|
||||
tableRender("");
|
||||
}
|
||||
|
||||
// 阻止表单的默认提交行为
|
||||
return false;
|
||||
});
|
||||
|
||||
|
||||
function tableRender(fenlei_name) {
|
||||
table.render({
|
||||
elem: '#myTable',
|
||||
url: '/QingLong/zbdc/getFill',
|
||||
where: {
|
||||
km_code: $("#kmId").val(),
|
||||
level_filter: fenlei_name
|
||||
},
|
||||
cellExpandedMode: "tips",
|
||||
height: 'full-70',
|
||||
page: {
|
||||
limit: 15
|
||||
, layout: ['count', 'prev', 'page', 'next', 'skip']
|
||||
, prev: "上一页"
|
||||
, next: "下一页"
|
||||
},
|
||||
cols: [[
|
||||
{ title: '序号', align: 'center', width: "5%", type: 'numbers' },
|
||||
{ title: '分类', field: 'level', align: 'center', width: "15%" },
|
||||
{ title: '分类代码', field: 'fldm', align: 'center', width: "10%" },
|
||||
{ title: '名称', field: 'mc', align: 'center', width: "10%" },
|
||||
{ title: '规格型号功能', field: 'ggxhgn', align: 'center', width: "25%" },
|
||||
{ title: '单位', field: 'dw', align: 'center', width: "5%" },
|
||||
{ title: '应配数量', field: 'ypsl', align: 'center', width: "5%" },
|
||||
{ title: '配备要求', align: 'center', width: "5%", templet: '#pbyq_templet' },
|
||||
{ title: '备注', field: 'bz', align: 'center', width: "10%" },
|
||||
{ title: '现有数量', templet: '<input class="layui-input aabbxx" value="{{d.xysl}}">', align: 'center', width: "10%", style: 'cursor: pointer;' }
|
||||
|
||||
]],
|
||||
// skin: 'line',
|
||||
defaultToolbar: []
|
||||
|
||||
});
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
Loading…
Reference in new issue