layui如何在没有请求接口的情况下查询数据列表
MoreExpressCompanies:function(e){
var that = e.data.context
that.dialog = M.ui.dialog.init({
url: that.base.parseToPath.tpl(‘deliveryManagement/more-express-companies.tpl’, true),(这是我工作中弹框的公用方法不必纠结,换成自己的即可)
title: ‘’(提示框),
width:500,
height:450,
callback: function () {
table.render({
elem: ‘#More_Express_Companies’,(table的id)
data:that.expressCode(你获取的数据源),
request: {
pageName: ‘pageNum’ //页码的参数名称,默认:page
,
limitName: ‘pageSize’ //每页数据量的参数名,默认:limit
},
contentType: ‘application/json’,
limit: 5,
headers: { Authorization: that.userInfo },(请求令牌)
method: "post",
cellMinWidth: 80, //全局定义常规单元格的最小宽度,layui 2.2.1 新增
cols: [[
{ type: 'radio' },
{ field: 'corporate_name', title: '公司名称',align: 'center'},
]],
page:true
})
that.register()(获取列表后重新调用方法里面的方法,可以用自己的)
},
button: [{
html: '确定',
callback: function () {
var chooseData = layui.table.checkStatus('More_Express_Companies');
if (chooseData.data.length == 0) {
M.ui.waiting.creat({
status: false,
time: 500,
text: '请至少选择一项!',
hide: false,
});(提示的公用方法)
console.log(chooseData.data)
return false
}else{
M.ui.waiting.creat({
status: true,
time: 500,
text: '添加成功!',
hide: false
});(提示的公用方法)
var gshArr= JSON.parse(JSON.stringify(that.jjsArr));(转成字符串在转成数组)
gshArr.unshift(chooseData.data[0]);
that.base.renderSelect({
data:gshArr,
config:{
selectName:'courierServices'
}
})
form.val('deliveryNoteCreation',{
courierServices:chooseData.data[0].itemCode
})
}
}
},
{
html: '返回',
callback: function (dialog) {
dialog.dismiss();
}
}
]
}, this)
},
查询方式
dialogCustomerSearch: function (e) {
var that = e.data.context;
console.log(that)
var exPress = $(’.fastmall’).val()(获取你在输入框里面的值)
var ids=[](定义一个数组,把push的值存进去)
for(var i=0;i<that.expressCode.length;i++){
if(that.expressCode[i].itemName.indexOf(exPress)!=-1){
ids.push(that.expressCode[i])
}
}
//执行重载
layui.table.reload(‘More_Express_Companies’, {
data:ids,
page: {
curr: 1 //重新从第 1 页开始
},
})
},
下一篇: 母牛的故事-Java