關於使用fastadmin的一些技巧
1.在對應js中使用後端的資料
後端:$this->assignconfig('變數名','變數值');
前端:config.變數名
例如:
$this->assignconfig('title','標題');
config.title
2.在原有的初始化**基礎上傳自己想傳的引數
table.bootstraptable(,,,
,,,,
, this);
var table = $(that.table).clone(true);
$(table).data("operate-del", null);
that.table = table;
return table.api.formatter.operate.call(that, value, row, index);}}
]],
queryparams: function (params) ;
var op = params.op ? json.parse(params.op) : {};
//filter.後跟的是在ajax裡使用的名稱只需修改這兩行
filter.id = config.hotel_id;
//opop後跟的也是ajax裡使用的名稱,後面是條件
op.id = '=';
params.filter = json.stringify(filter);
params.op = json.stringify(op);
// console.log(params);
return params;
}});
關鍵**:
queryparams: function (params) ;
var op = params.op ? json.parse(params.op) : {};
//filter.後跟的是在ajax裡使用的名稱只需修改這兩行
filter.id = config.hotel_id;
//opop後跟的也是ajax裡使用的名稱,後面是條件
op.id = '=';
params.filter = json.stringify(filter);
params.op = json.stringify(op);
// console.log(params);
return params;
}
3.新增或者修改後區域性區域性重新整理**而不重新整理頁面的做法
$('.btn-add').click(function()
});});
//這樣可以接收返回值
form.api.bindevent("form[role=form]", function(data, ret),function(data,ret));
4.關閉視窗並回傳資料
fast.api.close(data)
5.選擇乙個選項後關閉彈窗並把資料回傳給父級
彈窗裡的js
);
},},
formatter: function ()
}
父級裡的js
$('.select').click(function()});
});
6.去除操作欄中的刪除
, this);
var table = $(that.table).clone(true);
$(table).data("operate-del", null);
that.table = table;
return table.api.formatter.operate.call(that, value, row, index);
}}
7.預設編輯的彈窗100%
var table = $("#table");
$('.btn-editone').data('area',['100%','100%']);
table.on('load-success.bs.table', function (e, data) );
8.layer載入風格
var index = layer.load(0, ); //0代表載入的風格,支援0-2
關閉
layer.closeall('loading');
9.開啟乙個新視窗(不是彈窗)
backend.api.addtabs('order/order/edit?ids='+r.order_id,'訂單詳情');
10.tpl模版的使用
注意js中define中增加template
html中
js中
$(document).on('click','.room',function());
statuslist.push();
break;
case '2': //已入住
statuslist.push();
break;
case '4': //保潔
statuslist.push();
break;
}console.log(statuslist);
console.log(statuslist.length);
data=
layer.open();
})
11.監聽回車鍵按下
document.onkeydown = keylistener;
function keylistener(e)
}
12.datetimepicker自定義載入及使用(可以控制開始和結束時間的聯動)
html**
js**:
define(['jquery', 'bootstrap', 'backend', 'table', 'form','bootstrap-datetimepicker'], function ($, undefined, backend, table, form,datetimepicker) ,
showtodaybutton: true,
showclose: true
};$('#begin').datetimepicker(options);
$('#end').datetimepicker(options);
$("#begin").on("dp.change", function (e)
$('#end').data("datetimepicker").mindate(e.date);
});$("#end").on("dp.change", function (e) );
controller.api.bindevent();
},add: function () ,
edit: function () ,
order: function (),
api: }};
return controller;
});
關鍵是:define中增加bootstrap-datetimepicker
12.在表中以某個字段排序關鍵 sortable
,
FastAdmin使用建議
1.規劃好資料表 直接用命令建立後台管理選單 生成fa test表的crud php think crud t test 生成fa test表的crud且一鍵生成選單 php think crud t test u 1 刪除fa test表生成的crud php think crud t test ...
fastadmin 狀態的設定
在使用fastadmin過程中難免有忘記資料字段設定的時候,這裡主要是記錄一下怎麼來補救方式以及頁面篩選的 的設定。這是我們生產的結果,造成頁面的直接展示我們資料儲存的數字內容 我們可以給這個狀態新增乙個searchlist formatter table.api.formatter.status ...
fastadmin開發外掛程式的基本流程
fastadmin是一款基於thinkphp5 bootstrap的極速後台開發框架。以乙個學校管理外掛程式為例 phpstorm phpstudy nginx1.15.11 mysql8.0 php7.3.4 配置站點 我的網域名稱設定為fast51admin.localhost.nyist.vi...