You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
186 lines
6.1 KiB
186 lines
6.1 KiB
<#import "../master.ftl" as master>
|
|
<@master.layout>
|
|
|
|
<style>
|
|
#fm label {
|
|
width: 150px;
|
|
}
|
|
</style>
|
|
|
|
<div class="page-header">
|
|
<h3>机器设置</h3>
|
|
</div>
|
|
|
|
<!-- 机器展示列表 -->
|
|
<table id="dg" class="easyui-datagrid" style="width:100%;height:460px;display: none;"
|
|
data-options="pagination: true, showFooter: true, singleSelect:true, fitColumns:true , url:'/base/getVariousMachine',method:'POST',pageSize:20,toolbar:'#tb'">
|
|
<thead>
|
|
<tr>
|
|
<th data-options="field:'machineName',width:100">机器名称</th>
|
|
<th data-options="field:'jdbcUrl',width:400">数据库Url</th>
|
|
<th data-options="field:'machineType',width:400">机器类型</th>
|
|
<th data-options="field:'id',width:100,editor:'textbox',formatter:formatAction">操作</th>
|
|
</tr>
|
|
</thead>
|
|
</table>
|
|
<!-- 机器展示列表按钮 -->
|
|
<div id="tb" style="padding:10px 5px;display: none;">
|
|
<div>
|
|
<#if currentUser.isAdmin>
|
|
<a href="javascript:void(0)" id="tbAdd" class="easyui-linkbutton" iconCls="icon-add" onclick="addMachineModal()">新增机器</a>
|
|
</#if>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 机器新增和修改的按钮 -->
|
|
<div id="dlg" class="easyui-dialog" style="width:600px;display: none;"
|
|
closed="true" buttons="#dlg-buttons">
|
|
<form id="fm" method="post" novalidate style="margin:0;padding:20px 20px">
|
|
<div style="margin-bottom:10px">
|
|
<input id="dlg_machine_id" name="id" class="easyui-textbox">
|
|
<input id="dlg_machine_name" name="machineName" class="easyui-textbox" required="true" label="机器名称:" style="width:100%">
|
|
</div>
|
|
<div style="margin-bottom:10px">
|
|
<input id="dlg_jdbc_driver" name="jdbcDriver" class="easyui-textbox" required="true" label="数据库驱动" style="width:100%">
|
|
</div>
|
|
<div style="margin-bottom:10px">
|
|
<input id="dlg_jdbc_name" name="jdbcUrl" class="easyui-textbox" required="true" label="数据库Url" style="width:100%">
|
|
</div>
|
|
<div style="margin-bottom:10px">
|
|
<input id="dlg_jdbc_username" name="jdbcUsername" class="easyui-textbox" required="true" label="数据库用户:" style="width:100%">
|
|
</div>
|
|
<div style="margin-bottom:10px">
|
|
<input name="jdbcPassword" class="easyui-textbox" required="true" label="数据库密码:" style="width:100%">
|
|
</div>
|
|
<div style="margin-bottom:10px">
|
|
<select class="easyui-combobox" id="dlg_machine_type"name="machineType" required="true" label="机器类型" style="width:100%">
|
|
<option value="laser">镭射</option>
|
|
<option value="measure">测量机</option>
|
|
<option value="scanner">扫描机</option>
|
|
</select>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
<!-- 模态框功能按钮 -->
|
|
<div id="dlg-buttons" style="display: none;">
|
|
<a href="javascript:void(0)" class="easyui-linkbutton c6" iconCls="icon-ok" onclick="saveMachineData()" style="width:90px">Save</a>
|
|
<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#dlg').dialog('close')" style="width:90px">Cancel</a>
|
|
</div>
|
|
|
|
|
|
<script>
|
|
|
|
$(window).resize(function () {
|
|
$("#dg").datagrid({"height": $(window).height() - $(".datagrid").offset().top - 20});
|
|
});
|
|
|
|
$(function () {
|
|
$(window).resize();
|
|
});
|
|
|
|
|
|
$("#queryLink").click(function(){
|
|
var dg = $('#dg').datagrid({
|
|
queryParams: {
|
|
jobId: $("#jobId").val(),
|
|
createdDateFrom: $("#createdDateFrom").val(),
|
|
createdDateTo: $("#createdDateTo").val()
|
|
}
|
|
});
|
|
});
|
|
|
|
function passageway(value,row){
|
|
if("l"==value){
|
|
return "低速";
|
|
}else if("h"==value){
|
|
return "高速";
|
|
}
|
|
return "";
|
|
}
|
|
|
|
function formatAction(value,row){
|
|
let a = '';
|
|
<#if currentUser.isAdmin>
|
|
a = a + " <a href='javascript:editMachineModal();'>修改</a>";
|
|
a = a + " | <a href='javascript:deleteMachineData("+row.id+");'>删除</a>";
|
|
</#if>
|
|
return a;
|
|
}
|
|
|
|
|
|
//新增机器modal
|
|
var url;
|
|
function addMachineModal(){
|
|
$('#dlg').dialog('open').dialog('center').dialog('setTitle','新增机器');
|
|
$('#fm').form('clear');
|
|
$('#dlg_machine_id').textbox("setValue", 0);
|
|
$('#dlg_machine_id').next().hide();
|
|
url = '/base/addMachineData';
|
|
}
|
|
|
|
//修改机器的Modal
|
|
function editMachineModal(){
|
|
var row = $('#dg').datagrid('getSelected');
|
|
if (row){
|
|
$('#dlg').dialog('open').dialog('center').dialog('setTitle','修改机器');
|
|
$('#fm').form('load',row);
|
|
$('#dlg_machine_id').next().hide();
|
|
url = '/base/updateMachineData';
|
|
}else{
|
|
$.messager.alert('Warning','Please select a row.', 'warning');
|
|
}
|
|
}
|
|
|
|
//删除机器
|
|
function deleteMachineData(id) {
|
|
$.messager.confirm('Confirm', '确定删除?', function (r) {
|
|
if (r) {
|
|
$.post('/base/deleteMachineData', {id: id}, function (result) {
|
|
if (result.success) {
|
|
$('#dg').datagrid('reload');
|
|
$.messager.alert('Success', '删除成功', 'info');
|
|
} else {
|
|
$.messager.alert('Error', result.errorMsg, 'error');
|
|
}
|
|
}, 'json');
|
|
}
|
|
});
|
|
}
|
|
|
|
//延时
|
|
var delay = (function(){
|
|
var timer = 0;
|
|
return function(callback, ms){
|
|
clearTimeout (timer);
|
|
timer = setTimeout(callback, ms);
|
|
};
|
|
})();
|
|
|
|
|
|
//保存机器的参数
|
|
function saveMachineData(){
|
|
delay(function(){
|
|
$('#fm').form('submit',{
|
|
url: url,
|
|
onSubmit: function(){
|
|
return $(this).form('validate');
|
|
},
|
|
success: function(result){
|
|
var result = eval("("+result+")");
|
|
if (result.errorMsg){
|
|
$.messager.alert('error',result.errorMsg, 'error');
|
|
} else {
|
|
$('#dlg').dialog('close'); // close the dialog
|
|
$('#dg').datagrid('reload'); // reload the user data
|
|
}
|
|
}
|
|
});
|
|
}, 500);
|
|
}
|
|
|
|
|
|
</script>
|
|
|
|
|
|
</@master.layout>
|
|
|