main
kgdxpr 1 year ago
parent adf9c67cfb
commit 42c011b629

@ -28,9 +28,37 @@
}
.layui-table td,
.layui-table th {
.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>
@ -38,13 +66,13 @@
<div class="layui-card">
<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>
<div class="layui-input-inline">
<input type="text" id="personName" lay-affix="clear" lay-filter="clear" placeholder="请输入设备名称"
class="layui-input">
</div>
</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">
@ -70,6 +98,15 @@
</div>
<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>
@ -90,7 +127,7 @@
var xmSelectData = [];
var fenleiSelect;
$.ajax({
type: "GET",
@ -103,60 +140,74 @@
kmView.innerHTML = html;
});
form.render();
getXmSelect();
tableRender("");
}
});
var fenleiSelect = xmSelect.render({
el: '#fenlei',
clickClose: true,
radio: true,
autoRow: true,
model: {
icon: 'hidden',
label: {
type: 'text',
text: {
//左边拼接的字符
left: '',
//右边拼接的字符
right: '',
//中间的分隔符
separator: ', ',
},
function getXmSelect() {
fenleiSelect = xmSelect.render({
el: '#fenlei',
clickClose: true,
radio: true,
autoRow: true,
model: {
icon: 'hidden',
label: {
type: 'text',
text: {
//左边拼接的字符
left: '',
//右边拼接的字符
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: {
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);
}
});
}
$.ajax({
type: 'GET',
async: false,
url: '/QingLong/zbdc/getKmFeiLeiTree?km_code=xxty',
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];
@ -186,79 +237,89 @@
form.on('submit(user-query)', function () {
var selectArr = fenleiSelect.getValue();
console.log(selectArr[0].level_name);
const levelName = "少儿(趣味)田径";
const result = findNodeAndParents(levelName);
console.log(result.join(','));
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?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