/**
|
* 详情对话框
|
*/
|
var EquipmentMaintainTaskInfoDlg = {
|
data: {
|
id: "",
|
equipmentNo: "",
|
equipmentName: "",
|
taskNo: "",
|
planNo: "",
|
planName: "",
|
maintainType: "",
|
maintainState: "",
|
maintainResult: "",
|
reason: "",
|
maintainPrice: "",
|
externalMaintain: "",
|
maintainUser: "",
|
spareField1: "",
|
spareField2: "",
|
finishTime: "",
|
maintainTime: "",
|
remarks: ""
|
}
|
};
|
|
layui.use(['table','form', 'admin', 'ax','laydate','upload','formSelects'], function () {
|
var $ = layui.jquery;
|
var $ax = layui.ax;
|
var form = layui.form;
|
var admin = layui.admin;
|
var table = layui.table;
|
|
|
var dataList = new Array();
|
|
/**
|
* 物料档案管理
|
*/
|
var EqConfTable = {
|
tableId: "eqConfTable"
|
};
|
table.render({
|
elem: '#eqConfTable',page: true
|
, cols: [[ //标题栏
|
// {type: 'checkbox'},
|
{field: 'maintainContentCode', title: '编号'},
|
{field: 'maintainContentName', title: '名称'},
|
{field: 'maintainContentType', title: '类型'},
|
{field: 'maintainResult', title: '是否保养',templet: '#statusTpl'},
|
{field: 'maintainContent', title: '保养内容描述', edit: 'textarea'},
|
{align: 'center', toolbar: '#tableBar', title: '操作', minWidth: 120}
|
]]
|
,limit: 10
|
, data: dataList
|
, even: true
|
});
|
|
//获取详情信息,填充表单
|
var ajax = new $ax(Feng.ctxPath + "/equipmentMaintainTask/detail?id=" + Feng.getUrlParam("id"));
|
var result = ajax.start();
|
form.val('equipmentMaintainTaskForm', result.data);
|
var contentPlan = new $ax(Feng.ctxPath + "/equipmentMaintainContentTask/detailByMaintainPlanNo?taskNo=" + result.data.taskNo);
|
var Planresult = contentPlan.start();
|
|
Planresult.forEach(function (val, index) {
|
var obj = {
|
'maintainContentCode': val.maintainContentCode,
|
'maintainContentName': val.maintainContentName,
|
'maintainContentType': val.maintainContentType,
|
'maintainContent': val.maintainContent,
|
'maintainResult': val.maintainResult,
|
|
};
|
dataList.push(obj);
|
});
|
table.reload(EqConfTable.tableId, {
|
data: dataList
|
});
|
table.reload(EqConfTable.tableId, {
|
data: Planresult
|
});
|
console.log("加载数据后的dataList状态"+dataList);
|
|
$('#btnAdds').click(function () {
|
console.log("点击保养计划配置")
|
EqConfTable.btnForProcess();
|
});
|
|
EqConfTable.btnForProcess = function () {
|
layer.open({
|
type: 2,
|
title: '保养内容',
|
area: ['800px', '650px'],
|
content: Feng.ctxPath + '/equipmentMaintainContentConf/addListConf',
|
end: function () {
|
var info = $("#materialList").val();
|
console.log(info)
|
if (info != "") {
|
var tempList = eval(info);
|
tempList.forEach(function (val, index) {
|
var obj = {
|
'maintainContentCode': val.maintainContentCode,
|
'maintainContentName': val.maintainContentName,
|
'maintainContentType': val.maintainContentType,
|
'maintainContent': val.maintainContent,
|
};
|
dataList.push(obj);
|
});
|
table.reload(EqConfTable.tableId, {
|
data: dataList
|
});
|
$("#materialList").val("");
|
}
|
}
|
});
|
};
|
|
|
// 工具条点击事件
|
table.on('tool(' + EqConfTable.tableId + ')', function (obj) {
|
var data = obj.data;
|
var layEvent = obj.event;
|
|
if (layEvent === 'delete') {
|
EqConfTable.onDeleteItem(data);
|
}
|
});
|
|
//监听指定开关
|
form.on('switch(state)', function(data){
|
console.log("监听指定开关data id="+data.value);
|
// var ajax = new $ax(Feng.ctxPath + "/equipmentMaintainContentTask/editByState",function (data) {
|
// Feng.success("修改成功!");
|
// }, function (data) {
|
// Feng.error("修改失败!" + data.responseJSON.message);
|
// });
|
// ajax.set("id", data.value);
|
// ajax.set("maintainResult", this.checked ? '已保养' : '未保养');
|
// ajax.start();
|
// console.log("监听指定开关data id=");
|
var ajax = new $ax(Feng.ctxPath + "/equipmentMaintainContentTask/detail?id=" + data.value);
|
var result = ajax.start();
|
console.log(result.data.maintainContentCode);
|
|
for (let i = 0; i < dataList.length; i++) {
|
if (dataList[i].maintainContentCode === result.data.maintainContentCode) {
|
dataList[i].maintainResult = this.checked ? '已保养' : '未保养';
|
}
|
}
|
});
|
|
table.on('edit(eqConfTable)', function (data) {
|
// var value = obj.value, //得到修改后的值
|
// data = obj.data, //得到所在行所有键值
|
// field = obj.field; //得到字段
|
console.log(data.data)
|
// var ajax = new $ax(Feng.ctxPath + "/equipmentMaintainContentTask/editByState", function (data) {
|
// }, function (data) {
|
// Feng.error("更新失败!" + data.responseJSON.message)
|
// });
|
// ajax.set(data.data);
|
// ajax.start();
|
for (let i = 0; i < dataList.length; i++) {
|
if (dataList[i].maintainContentCode === data.data.maintainContentCode) {
|
dataList[i].maintainContent = data.value;
|
}
|
}
|
});
|
|
/**
|
* 点击删除
|
*
|
* @param data 点击按钮时候的行数据
|
*/
|
EqConfTable.onDeleteItem = function (data) {
|
let operation = function () {
|
for (let i = 0; i < dataList.length; i++) {
|
console.log(dataList[i].maintainContentCode)
|
console.log(data.maintainContentCode)
|
if (dataList[i].maintainContentCode === data.maintainContentCode) {
|
dataList.splice(i, 1);
|
Feng.success("删除成功!");
|
}
|
}
|
table.reload(EqConfTable.tableId, {
|
data: dataList
|
});
|
};
|
Feng.confirm("是否删除?", operation);
|
};
|
|
$('#cancel').click(function(){
|
window.location.href = Feng.ctxPath + '/equipmentMaintainTask'
|
});
|
|
//表单提交事件
|
form.on('submit(btnSubmit)', function (data) {
|
var ajax = new $ax(Feng.ctxPath + "/equipmentMaintainTask/editItem", function (data) {
|
Feng.success("更新成功!");
|
window.location.href = Feng.ctxPath + '/equipmentMaintainTask'
|
}, function (data) {
|
Feng.error("更新失败!" + data.responseJSON.message)
|
});
|
ajax.set(data.field);
|
ajax.set("dataList", JSON.stringify(dataList));
|
ajax.start();
|
|
return false;
|
});
|
|
});
|