221 lines
8.5 KiB
JavaScript
221 lines
8.5 KiB
JavaScript
/**
|
||
* 加载绩效附表
|
||
*/
|
||
function getMaintenanceConfig4EquipmentCard(equipmentId, viewType) {
|
||
$("#maintenanceConfigtable").bootstrapTable({ // 对应table标签的id
|
||
url: ext.contextPath + '/maintenance/maintenanceEquipmentConfig/getlist.do', // 获取表格数据的url
|
||
cache: false, // 设置为 false 禁用 AJAX 数据缓存, 默认为true
|
||
striped: true, //表格显示条纹,默认为false
|
||
pagination: true, // 在表格底部显示分页组件,默认false
|
||
pageList: [10, 20, 50], // 设置页面可以显示的数据条数
|
||
pageSize: 10, // 页面数据条数
|
||
pageNumber: 1, // 首页页码
|
||
sidePagination: 'server', // 设置为服务器端分页
|
||
queryParams: function (params) { // 请求服务器数据时发送的参数,可以在这里添加额外的查询参数,返回false则终止请求
|
||
return {
|
||
rows: params.limit, // 每页要显示的数据条数
|
||
page: params.offset / params.limit + 1, // 每页显示数据的开始页码
|
||
sort: params.sort, // 要排序的字段
|
||
order: params.order,
|
||
equipmentId: equipmentId
|
||
}
|
||
},
|
||
onClickRow: function (row) {//单击行事件,执行查看功能
|
||
// viewMaintainFun(row.id);
|
||
},
|
||
sortName: 'id', // 要排序的字段
|
||
sortOrder: 'desc', // 排序规则
|
||
columns: [
|
||
{
|
||
field: 'id_d',
|
||
checkbox: true, // 显示一个勾选框
|
||
},
|
||
// {
|
||
// field: 'month', // 返回json数据中的name
|
||
// title: '起始月份', // 表格表头显示文字
|
||
// align: 'center', // 左右居中
|
||
// valign: 'middle',
|
||
// width: '20%',
|
||
// formatter: function (value, row, index) {
|
||
// return value + '月份';
|
||
// }
|
||
// },
|
||
{
|
||
field: 'title', // 返回json数据中的name
|
||
title: '保养名称', // 表格表头显示文字
|
||
align: 'center', // 左右居中
|
||
valign: 'middle',
|
||
width: '10%',
|
||
formatter: function (value, row, index) {
|
||
return value;
|
||
}
|
||
},
|
||
{
|
||
field: 'cycle', // 返回json数据中的name
|
||
title: '周期', // 表格表头显示文字
|
||
align: 'center', // 左右居中
|
||
valign: 'middle',
|
||
width: '10%',
|
||
formatter: function (value, row, index) {
|
||
return value + '个月';
|
||
}
|
||
},
|
||
{
|
||
field: 'lastTime', // 返回json数据中的name
|
||
title: '上次保养时间', // 表格表头显示文字
|
||
align: 'center', // 左右居中
|
||
valign: 'middle',
|
||
width: '20%',
|
||
formatter: function (value, row, index) {
|
||
return value.substring(0,10);
|
||
}
|
||
},
|
||
{
|
||
field: 'contents', // 返回json数据中的name
|
||
title: '保养内容', // 表格表头显示文字
|
||
align: 'center', // 左右居中
|
||
valign: 'middle',
|
||
width: '50%',
|
||
},
|
||
{
|
||
title: "操作",
|
||
align: 'center',
|
||
valign: 'middle',
|
||
width: '10%', // 定义列的宽度,单位为像素px
|
||
formatter: function (value, row, index) {
|
||
var buts = '';
|
||
// buts += '<button type="button" class="btn btn-default btn-sm" title="查看" onclick="doView_MainConfig(\'' + row.id + '\')"><i class="fa fa-eye"></i><span class="hidden-md hidden-lg"> 浏览</span></button>';
|
||
if (viewType != 'view') {
|
||
buts += '<button type="button" class="btn btn-default btn-sm" title="编辑" onclick="doEdit_MainConfig(\'' + row.id + '\')"><i class="fa fa-edit"></i><span class="hidden-md hidden-lg"> 编辑</span></button>';
|
||
buts += '<button type="button" class="btn btn-default btn-sm" title="删除" onclick="doDeleteOne_MainConfig(\'' + row.id + '\')"><i class="fa fa fa-trash-o"></i><span class="hidden-md hidden-lg"> 删除</span></button>';
|
||
}
|
||
buts = '<div class="btn-group" >' + buts + '</div>';
|
||
return buts;
|
||
}
|
||
}
|
||
],
|
||
onLoadSuccess: function () { //加载成功时执行
|
||
if (viewType == 'view') {
|
||
$("#maintenanceConfigtable").bootstrapTable('hideColumn', 'id_d');//隐藏上述variablevalue列
|
||
}
|
||
adjustBootstrapTableView("maintenanceConfigtable");
|
||
console.info("加载数据成功_备注");
|
||
},
|
||
onLoadError: function () { //加载失败时执行
|
||
console.info("加载数据失败_备注");
|
||
}
|
||
|
||
})
|
||
}
|
||
|
||
/**
|
||
* 弹窗备注选择页面
|
||
* @param equipmentId
|
||
*/
|
||
var doAdd_MainConfig = function (equipmentId) {
|
||
$.post(ext.contextPath + '/maintenance/maintenanceEquipmentConfig/doadd.do', {equipmentId: equipmentId}, function (data) {
|
||
$("#subMainConfigAddDiv").html(data);
|
||
openModal('SubModal_MainConfig_Add');
|
||
});
|
||
};
|
||
|
||
var doEdit_MainConfig = function (id) {
|
||
$.post(ext.contextPath + '/maintenance/maintenanceEquipmentConfig/doedit.do', {id: id}, function (data) {
|
||
$("#subMainConfigEditDiv").html(data);
|
||
openModal('SubModal_MainConfig_Edit');
|
||
});
|
||
};
|
||
|
||
var doView_MainConfig = function (id) {
|
||
$.post(ext.contextPath + '/maintenance/maintenanceEquipmentConfig/doview.do', {id: id}, function (data) {
|
||
$("#subRemarkViewDiv").html(data);
|
||
openModal('SubModal_MainConfig');
|
||
});
|
||
};
|
||
|
||
/**
|
||
* 删除关联的备注
|
||
*/
|
||
var doDelete_MainConfig = function () {
|
||
var checkedItems_remark = $("#maintenanceConfigtable").bootstrapTable('getSelections');
|
||
var datas = "";
|
||
$.each(checkedItems_remark, function (index, item) {
|
||
datas += item.id + ",";
|
||
});
|
||
if (datas == "") {
|
||
showAlert('d', '请先选择记录', 'mainAlertdiv');
|
||
} else {
|
||
swal({
|
||
text: "您确定要删除选中记录?",
|
||
dangerMode: true,
|
||
buttons: {
|
||
cancel: {
|
||
text: "取消",
|
||
value: null,
|
||
visible: true,
|
||
className: "btn btn-default btn-sm",
|
||
closeModal: true,
|
||
},
|
||
confirm: {
|
||
text: "确定",
|
||
value: true,
|
||
visible: true,
|
||
className: "btn btn-danger btn-sm",
|
||
closeModal: true
|
||
}
|
||
}
|
||
})
|
||
.then(function (willDelete) {
|
||
if (willDelete) {
|
||
$.post(ext.contextPath + '/maintenance/maintenanceEquipmentConfig/dodeletes.do', {ids: datas}, function (data) {
|
||
if (data > 0) {
|
||
$("#maintenanceConfigtable").bootstrapTable('refresh');
|
||
} else {
|
||
showAlert('d', '删除失败', 'mainAlertdiv');
|
||
}
|
||
});
|
||
|
||
}
|
||
});
|
||
}
|
||
};
|
||
|
||
/**
|
||
* 删除关联的备注
|
||
*/
|
||
var doDeleteOne_MainConfig = function (id) {
|
||
swal({
|
||
text: "您确定要删除此条记录?",
|
||
dangerMode: true,
|
||
buttons: {
|
||
cancel: {
|
||
text: "取消",
|
||
value: null,
|
||
visible: true,
|
||
className: "btn btn-default btn-sm",
|
||
closeModal: true,
|
||
},
|
||
confirm: {
|
||
text: "确定",
|
||
value: true,
|
||
visible: true,
|
||
className: "btn btn-danger btn-sm",
|
||
closeModal: true
|
||
}
|
||
}
|
||
})
|
||
.then(function (willDelete) {
|
||
if (willDelete) {
|
||
$.post(ext.contextPath + '/maintenance/maintenanceEquipmentConfig/dodelete.do', {id: id}, function (data) {
|
||
if (data > 0) {
|
||
$("#maintenanceConfigtable").bootstrapTable('refresh');
|
||
} else {
|
||
showAlert('d', '删除失败', 'mainAlertdiv');
|
||
}
|
||
});
|
||
|
||
}
|
||
});
|
||
};
|
||
|