137 lines
2.9 KiB
JavaScript
137 lines
2.9 KiB
JavaScript
layui.use([ 'element', 'table', 'laydate', 'form' ], function() {
|
|
var $ = layui.jquery;
|
|
var table = layui.table;
|
|
var laydate = layui.laydate;
|
|
var element = layui.element;
|
|
var form = layui.form;
|
|
|
|
// 生成表格
|
|
table.render({
|
|
elem : '#productTable',
|
|
url : '../../../getProductList',
|
|
toolbar : '#toolbarDemo',
|
|
title : '价格表',// 导出文件名
|
|
id : 'productTableAll',
|
|
// 开启分页
|
|
page : {
|
|
layout : [ 'count', 'prev', 'page', 'next', 'skip', 'limit' ]
|
|
},
|
|
limits : [10,30,50,100,999],
|
|
where:{
|
|
proTypeLabel : ''
|
|
},
|
|
cellMinWidth : 80, // 全局定义常规单元格的最小宽度,layui 2.2.1 新增
|
|
cols : [ [ {
|
|
type : 'numbers',
|
|
title : '序号',
|
|
width : 80,
|
|
fixed : "left"
|
|
},{
|
|
field : 'proTypeLabel',
|
|
width : 150,
|
|
align : 'center',
|
|
title : '产品类型',
|
|
},{
|
|
field : 'kindLabel',
|
|
width : 240,
|
|
align : 'center',
|
|
title : '产品种类1',
|
|
},{
|
|
field : 'kind1Label',
|
|
width : 240,
|
|
align : 'center',
|
|
title : '产品种类2',
|
|
},{
|
|
field : 'kind2Label',
|
|
width : 240,
|
|
align : 'center',
|
|
title : '产品种类3',
|
|
},{
|
|
field : 'length',
|
|
align : 'center',
|
|
title : '长',
|
|
width : 100
|
|
},{
|
|
field : 'width',
|
|
align : 'center',
|
|
title : '宽',
|
|
width : 100
|
|
},{
|
|
field : 'count',
|
|
align : 'center',
|
|
title : '数量',
|
|
edit : 'text',
|
|
width : 120
|
|
},{
|
|
field : 'price',
|
|
align : 'center',
|
|
title : '价格',
|
|
edit : 'text',
|
|
width : 120
|
|
},{
|
|
field : 'priceMultiple',
|
|
align : 'center',
|
|
title : '倍数',
|
|
edit : 'text',
|
|
width : 120
|
|
},{
|
|
field : 'weight',
|
|
align : 'center',
|
|
title : '重量',
|
|
edit : 'text',
|
|
width : 120
|
|
}/*,{
|
|
fixed : 'right',
|
|
title : '操作',
|
|
align : 'center',
|
|
width : 150,
|
|
toolbar : '#barDemo'
|
|
} */] ],
|
|
parseData : function(res) { //将原始数据解析成 table 组件所规定的数据
|
|
return {
|
|
"code" : 0, //解析接口状态
|
|
"msg" : "", //解析提示文本
|
|
"count" : res.data.list.total,//解析数据长度
|
|
"data" : res.data.list.list//解析数据列表
|
|
};
|
|
}
|
|
});
|
|
|
|
//点击查询按钮,重载表格
|
|
$('#searchBtn').on('click', function() {
|
|
table.reload('productTableAll', {
|
|
method : 'get',
|
|
where : {
|
|
proTypeLabel : $("#proTypeLabel").val()
|
|
},
|
|
page : {
|
|
curr : 1
|
|
}
|
|
});
|
|
return false;
|
|
});
|
|
|
|
//监听单元格编辑
|
|
table.on('edit(productTable)', function(obj){
|
|
var value = obj.value, //得到修改后的值
|
|
data = obj.data, //得到所在行所有键值
|
|
field = obj.field; //得到字段
|
|
$.ajax({
|
|
url:"../../../updatePriceById",
|
|
data:{
|
|
proId: data.proId,
|
|
value: value,
|
|
field: field
|
|
},
|
|
type:"post",
|
|
success:function (data) {
|
|
if (data.code == 200) {
|
|
layer.msg('修改成功!',{icon:6,offset:"auto",time:1000});//提示框
|
|
}else{
|
|
layer.msg('修改失败!',{icon:5,offset:"auto",time:1000});//提示框
|
|
}
|
|
}
|
|
});
|
|
});
|
|
});
|