layui.use(['table', 'admin', 'ax', 'func'], function () {
|
var $ = layui.$;
|
var table = layui.table;
|
var $ax = layui.ax;
|
var admin = layui.admin;
|
var func = layui.func;
|
|
/**
|
* 工艺路线子信息管理
|
*/
|
var ProductRouteChildInfo = {
|
tableId: "productRouteChildInfoTable"
|
};
|
|
getDictType();
|
|
/**
|
* 初始化表格的列
|
*/
|
ProductRouteChildInfo.initColumn = function () {
|
return [[
|
{type: 'checkbox'},
|
{field: 'id', hide: true, title: '主键id'},
|
{field: 'opCode', sort: true, title: '工序编码'},
|
{field: 'opName', sort: true, title: '工序名称'},
|
{field: 'stepNo', sort: true, title: '加工顺序'},
|
// {field: 'opType', sort: true, title: '工序类型'},
|
{
|
field: 'opType', align: "center", title: '工序类型', templet: function (d) {
|
switch(d.opType){
|
case "1" :
|
return "上线工序";
|
break;
|
case "2" :
|
return "过程工序";
|
break;
|
case "3" :
|
return "下线工序";
|
break;
|
default :
|
}
|
}
|
},
|
{field: 'remark', sort: true, title: '备注'},
|
{field: 'routeCode', sort: true, title: '流程编码'},
|
{align: 'center', toolbar: '#tableBar', title: '操作'}
|
]];
|
};
|
|
function getDictType(){
|
$.ajax({
|
type: "POST",
|
contentType: "application/json;charset=UTF-8",
|
url: Feng.ctxPath + '/dict/list?dictTypeId=1694972441967951874',
|
success: function (result) {
|
$.each(result.data, function (index, value) {
|
// $('#opType').append(new Option(value.code,value.name));// 下拉菜单里添加元素
|
$('#opType').append(new Option(value.name,value.code));// 下拉菜单里添加元素
|
});
|
layui.form.render("select");//重新渲染 固定写法
|
},
|
});
|
}
|
|
/**
|
* 点击查询按钮
|
*/
|
ProductRouteChildInfo.search = function () {
|
var queryData = {};
|
|
queryData['opCode'] = $('#opCode').val();
|
queryData['opName'] = $('#opName').val();
|
queryData['opType'] = $('#opType').val();
|
queryData['routeCode'] = $('#routeCode').val();
|
|
table.reload(ProductRouteChildInfo.tableId, {
|
where: queryData, page: {curr: 1}
|
});
|
};
|
|
/**
|
* 跳转到添加页面
|
*/
|
ProductRouteChildInfo.jumpAddPage = function () {
|
// window.location.href = Feng.ctxPath + '/productRouteChildInfo/add'
|
func.open({
|
height: 650,
|
title: '添加工艺路线子信息',
|
content: Feng.ctxPath + '/productRouteChildInfo/add?routeInfoCode=' + $("#routeInfoCode").val(),
|
tableId: ProductRouteChildInfo.tableId,
|
});
|
};
|
|
/**
|
* 跳转到编辑页面
|
*
|
* @param data 点击按钮时候的行数据
|
*/
|
ProductRouteChildInfo.jumpEditPage = function (data) {
|
// window.location.href = Feng.ctxPath + '/productRouteChildInfo/edit?id=' + data.id
|
func.open({
|
height: 650,
|
title: '工艺路线子信息',
|
content: Feng.ctxPath + '/productRouteChildInfo/edit?id=' + data.id,
|
tableId: ProductRouteChildInfo.tableId,
|
});
|
};
|
|
// 关闭页面
|
$('#btnBack').click(function () {
|
window.location.href = Feng.ctxPath + "/productRouteInfo";
|
});
|
|
/**
|
* 导出excel按钮
|
*/
|
ProductRouteChildInfo.exportExcel = function () {
|
var checkRows = table.checkStatus(ProductRouteChildInfo.tableId);
|
if (checkRows.data.length === 0) {
|
Feng.error("请选择要导出的数据");
|
} else {
|
table.exportFile(tableResult.config.id, checkRows.data, 'xls');
|
}
|
};
|
|
/**
|
* 点击删除
|
*
|
* @param data 点击按钮时候的行数据
|
*/
|
ProductRouteChildInfo.onDeleteItem = function (data) {
|
var operation = function () {
|
var ajax = new $ax(Feng.ctxPath + "/productRouteChildInfo/delete", function (data) {
|
Feng.success("删除成功!");
|
table.reload(ProductRouteChildInfo.tableId);
|
}, function (data) {
|
Feng.error("删除失败!" + data.responseJSON.message + "!");
|
});
|
ajax.set("id", data.id);
|
ajax.start();
|
};
|
Feng.confirm("是否删除?", operation);
|
};
|
|
var queryData = {};
|
queryData['routeCode'] = $('#routeInfoCode').val();
|
// 渲染表格
|
var tableResult = table.render({
|
elem: '#' + ProductRouteChildInfo.tableId,
|
url: Feng.ctxPath + '/productRouteChildInfo/list',
|
page: true,
|
height: "full-158",
|
cellMinWidth: 100,
|
where: queryData,
|
cols: ProductRouteChildInfo.initColumn()
|
});
|
|
// 搜索按钮点击事件
|
$('#btnSearch').click(function () {
|
ProductRouteChildInfo.search();
|
});
|
|
// 添加按钮点击事件
|
$('#btnAdd').click(function () {
|
|
ProductRouteChildInfo.jumpAddPage();
|
|
});
|
|
// 导出excel
|
$('#btnExp').click(function () {
|
ProductRouteChildInfo.exportExcel();
|
});
|
|
// 工具条点击事件
|
table.on('tool(' + ProductRouteChildInfo.tableId + ')', function (obj) {
|
var data = obj.data;
|
var layEvent = obj.event;
|
|
if (layEvent === 'edit') {
|
ProductRouteChildInfo.jumpEditPage(data);
|
} else if (layEvent === 'delete') {
|
ProductRouteChildInfo.onDeleteItem(data);
|
}
|
});
|
});
|