main
kgdxpr 1 year ago
parent adf9c67cfb
commit 42c011b629

@ -28,9 +28,37 @@
} }
.layui-table td, .layui-table td,
.layui-table th { .layui-table th {
font-size: 12px; 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> </style>
</head> </head>
@ -38,13 +66,13 @@
<div class="layui-card"> <div class="layui-card">
<div class="layui-card-body"> <div class="layui-card-body">
<div class="layui-form-item layui-inline"> <!-- <div class="layui-form-item layui-inline">
<label class="layui-form-label" style="width: auto;">设备名称:</label> <label class="layui-form-label" style="width: auto;">设备名称:</label>
<div class="layui-input-inline"> <div class="layui-input-inline">
<input type="text" id="personName" lay-affix="clear" lay-filter="clear" placeholder="请输入设备名称" <input type="text" id="personName" lay-affix="clear" lay-filter="clear" placeholder="请输入设备名称"
class="layui-input"> class="layui-input">
</div> </div>
</div> </div> -->
<div class="layui-form-item layui-inline"> <div class="layui-form-item layui-inline">
<label class="layui-form-label" style="width: auto;">学科:</label> <label class="layui-form-label" style="width: auto;">学科:</label>
<div class="layui-input-inline" id="kmView"> <div class="layui-input-inline" id="kmView">
@ -70,6 +98,15 @@
</div> </div>
<table class="layui-table" id="myTable"></table> <table class="layui-table" id="myTable"></table>
<script type="text/html" id="pbyq_templet">
{{# if(d.bp_xp > 0){ }}
<span class="bp">必配</span>
{{# } else { }}
<span class="xp">选配</span>
{{# } }}
</script>
</div> </div>
</div> </div>
@ -90,7 +127,7 @@
var xmSelectData = []; var xmSelectData = [];
var fenleiSelect;
$.ajax({ $.ajax({
type: "GET", type: "GET",
@ -103,60 +140,74 @@
kmView.innerHTML = html; kmView.innerHTML = html;
}); });
form.render(); form.render();
getXmSelect();
tableRender("");
} }
}); });
var fenleiSelect = xmSelect.render({
el: '#fenlei', function getXmSelect() {
clickClose: true, fenleiSelect = xmSelect.render({
radio: true, el: '#fenlei',
autoRow: true, clickClose: true,
model: { radio: true,
icon: 'hidden', autoRow: true,
label: { model: {
type: 'text', icon: 'hidden',
text: { label: {
//左边拼接的字符 type: 'text',
left: '', text: {
//右边拼接的字符 //左边拼接的字符
right: '', left: '',
//中间的分隔符 //右边拼接的字符
separator: ', ', right: '',
}, //中间的分隔符
separator: ', ',
},
}
},
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"
} }
}, });
tree: { $.ajax({
show: true, type: 'GET',
showFolderIcon: true, async: false,
showLine: true, url: '/QingLong/zbdc/getKmFeiLeiTree?km_code=' + $("#kmId").val(),
indent: 20, success: function (res) {
strict: false, xmSelectData = res.data;
simple: true, fenleiSelect.update({
expandedKeys: [-3], data: res.data
clickCheck: true, });
clickExpand: false, fenleiSelect.changeExpandedKeys(true);
}, }
data: [], });
prop: { }
value: "id",
name: "level_name"
}
});
$.ajax({
type: 'GET', form.on('select(km)', function (data) {
async: false, getXmSelect();
url: '/QingLong/zbdc/getKmFeiLeiTree?km_code=xxty',
success: function (res) {
xmSelectData = res.data;
fenleiSelect.update({
data: res.data
});
fenleiSelect.changeExpandedKeys(true);
}
}); });
function findNodeAndParents(levelName) { function findNodeAndParents(levelName) {
function search(node, path) { function search(node, path) {
const newPath = [...path, node.level_name]; const newPath = [...path, node.level_name];
@ -186,79 +237,89 @@
form.on('submit(user-query)', function () { form.on('submit(user-query)', function () {
var selectArr = fenleiSelect.getValue(); var selectArr = fenleiSelect.getValue();
console.log(selectArr[0].level_name); if (selectArr.length > 0) {
const levelName = selectArr[0].level_name;
const levelName = "少儿(趣味)田径"; const result = findNodeAndParents(levelName);
const result = findNodeAndParents(levelName); tableRender(result.join(','));
console.log(result.join(',')); }
else{
tableRender("");
}
// 阻止表单的默认提交行为 // 阻止表单的默认提交行为
return false; return false;
}); });
function tableRender(fenlei_name) {
table.render({
elem: '#myTable',
url: '/QingLong/zbdc/getFill?km_code=xxty',
where: {
km_code: $("#kmId").val(),
level_filter: fenlei_name
},
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: "10%" },
{ title: '分类代码', field: 'fldm', align: 'center', width: "10%" },
{ title: '名称', field: 'mc', align: 'center', width: "10%" },
{ title: '规格型号功能', field: 'ggxhgn', align: 'center', width: "15%" },
{ title: '单位', field: 'dw', align: 'center', width: "5%" },
{ title: '应配数量', field: 'ypsl', align: 'center', width: "5%" },
{ title: '配备要求', align: 'center', width: "5%", templet: '#pbyq_templet' },
{ title: '现有数量', templet: '<input class="layui-input aabbxx">', align: 'center', width: "10%", style: 'cursor: pointer;' },
{ title: '备注', field: 'bz', align: 'center', width: "25%" }
]],
// skin: 'line',
defaultToolbar: [],
done: function (res, curr, count) {
var tempVal = '';
var options = this;
// 获取当前行数据
table.getRowData = function (tableId, elem) {
var index = $(elem).closest('tr').data('index');
return table.cache[tableId][index] || {};
};
$(".aabbxx").focus(function () {
tempVal = this.value.trim();
});
$(".aabbxx").blur(function () {
var curVal = this.value.trim();
var data = table.getRowData(options.id, this);
console.log(JSON.stringify(data), curVal, options.id);
if (tempVal != curVal) {
toast.success({
// title: '提示',
message: '数据保存成功!',
position: 'topRight',
timeout: 1200,
close: false
});
}
table.render({
elem: '#myTable', });
url: '/QingLong/zbdc/getFill?km_code=xxty', }
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: "10%" },
{ title: '分类代码', field: 'fldm', align: 'center', width: "10%" },
{ title: '名称', field: 'mc', align: 'center', width: "10%" },
{ title: '规格型号功能', field: 'ggxhgn', align: 'center', width: "10%" },
{ title: '单位', field: 'dw', align: 'center', width: "5%" },
{ title: '应配数量', field: 'ypsl', align: 'center', width: "5%" },
{ title: '配备要求', field: 'bp_xp', align: 'center', width: "5%" },
{ title: '现有数量', templet: '<input class="layui-input aabbxx">', align: 'center', width: "10%", style: 'cursor: pointer;' },
{ title: '备注', field: 'bz', align: 'center', width: "25%" }
]],
// skin: 'line',
defaultToolbar: [],
done: function (res, curr, count) {
var tempVal = '';
var options = this;
// 获取当前行数据
table.getRowData = function (tableId, elem) {
var index = $(elem).closest('tr').data('index');
return table.cache[tableId][index] || {};
};
$(".aabbxx").focus(function () {
tempVal = this.value.trim();
});
$(".aabbxx").blur(function () {
var curVal = this.value.trim();
var data = table.getRowData(options.id, this);
console.log(JSON.stringify(data), curVal, options.id);
if (tempVal != curVal) {
toast.success({
// title: '提示',
message: '数据保存成功!',
position: 'topRight',
timeout: 1200,
close: false
});
}
});
}
});

Loading…
Cancel
Save