table.render({
elem: '#carInfoTable'
, url: ''
, title: ''
, where: {}
,request: {
pageName: 'pageNum' //页码的参数名称,默认:page
,limitName: 'pageSize' //每页数据量的参数名,默认:limit
}
, cols: [
[
{field: 'id', title: 'id', width: 50}
,{field: 'image', title: '里程表', align: "center", width: 100, templet:
function (data){
return '<img onclick="showimg(this)" style="display: inline-block; width: 50%; height: 109px;" src="' + data.carUrl + '">';
}
}
,{field: 'license', title: '车牌号', width: 120, edit: 'text'}
,{field: 'type', title: '型号', width: 100}
,{field: 'address', title: '存放地点', width: 230}
,{field: 'belong', title: '车辆归属', width: 230}
,{field: 'buyDate', title: '购置日期', width: 140}
,{field: 'contact', title: '联系人', width: 100}
,{field: 'phone', title: '联系电话', width: 140}
]
]
, page: true,
response: {
statusName: 'code', //规定返回的状态码字段为code
statusCode: 200 //规定成功的状态码味200
},
parseData: function (res) {
console.log(res)
return {
"code": 200, //解析接口状态
"msg": "", //解析提示文本
"data": res.data.list, //解析数据列表
"count": res.data.count
}
}
});
// 监听单元格编辑
table.on('edit(carInfoFilter)', function(obj){
var value = obj.value // 得到修改后的值
,data = obj.data // 得到所在行所有键值
,field = obj.field; // 得到字段
var updateData = {};
updateData[field] = value;
updateData.id = data.id;
console.log(updateData)
$.ajax({
url:""
,data: updateData
,success:function (res) {
if(res.status == 0){
layer.msg('更新成功');
}
}
});
});