Time range

The page display


Select the start time and end time table changes in the page


html Code


<form class="layui-form" action="">
<div class="layui-form-item">
<div class="layui-inline">
<label class="layui-form-label"> Date range </label>
<div class="layui-inline" id="test6">
<div class="layui-input-inline">
<input type="text" autocomplete="off" id="start_date" class="layui-input" placeholder=" Start date ">
<div class="layui-form-mid">-</div>
<div class="layui-input-inline">
<input type="text" autocomplete="off" id="end_date" class="layui-input" placeholder=" End date ">
</form> </div> <table id="detail" lay-filter="detail"></table>

JS Code

<script type="text/javascript">

layui.use(['table', 'layer', 'form'], function (){
var table = layui.table
,layer = layui.layer
,form = layui.form
,laydate = layui.laydate; // Custom initialization table method
window.initTable = function(start_date, end_date){
elem: '#detail'
,url: "{% url 'index:detail_data' %}" // Back end requested URL
,where: {
"data_center": $("#data_center").val() // The value of the drop-down box
,"start_date": start_date // Starting time
,"end_date": end_date // End time
// ,method: 'post'
,page: true
,cols: [[
{field: 'data_center', title: ' Data Center ', width: 150}
,{field: 'change', title: ' change '}
,{field: 'num', title: ' Number '}
,{field: 'reason', title: ' reason '}
,{field: 'diff_date', title: ' Time '}
,{field: '', title: ' operation ', align:'center', toolbar: '#barDemo'}
,response: {
statusName: 'code' // Field name that specifies the data status , Default :code
,statusCode: 10000 // Specify the successful status code , Default :0
,msgName: 'message' // Specify the field name of the status information , Default :msg
,countName: 'total' // Field name that specifies the total number of data , Default :count
,dataName: 'data' // Specifies the field name of the data list , Default :data
} // Get close to N God - Custom function
window.getRecentDay = function (day) {
var today = new Date();
var targetday_milliseconds = today.getTime() + 1000*60*60*24*day;
var tYear = today.getFullYear();
var tMonth = today.getMonth();
var tDate = today.getDate();
tMonth = doHandleMonth(tMonth + 1);
tDate = doHandleMonth(tDate);
return tYear+"-"+tMonth+"-"+tDate;
} // Processing month - Custom function
window.doHandleMonth = function (month) {
var m = month;
if(month.toString().length == 1){
m = "0" + month;
return m;
} // Date range
var start = laydate.render({
elem: '#start_date',
max: -1, // The maximum value is yesterday
value: getRecentDay(-30),
done: function (value, date){
if(value && (value>$('#end_date').val())){
end.config.min = {
year: date.year,
month: date.month-1,
initTable(value, $('#end_date').val()) // Call the custom initialization table method
var end = laydate.render({
elem: '#end_date',
max: -1, //
value: getRecentDay(-1), // The default time is yesterday
done: function (value, date){
start.config.max = {
year: date.year,
month: date.month-1,
initTable($('#start_date').val(), value) // Call the custom initialization table method
}); // Call the custom initialization table method ( Page initialization )
initTable(getRecentDay(-30), getRecentDay(-1));
}); </script>


stay layui.use Of {} Internally defined functions

window.func_name = function (params) {

stay layui.use Of {} In the call


Layui- More articles on custom functions and calls

  1. LR Custom functions and calls

    2.2. Custom functions and calls 2.2.1. Virtual user programming , Use C#  Language DLL stay VS To establish DLL The class library project , Write functions using public Statement : Realize function post compilation generation DLL: stay LR To establish  .Net Vuser foot ...

  2. php Learning notes : Call of custom function

    PHP Built in more than 1000 A function , So the function makes PHP Become a very powerful language . Most of the time, we can use the built-in functions of the system to meet the requirements , But a custom function encapsulates a set of code , Reuse code , The program structure and logic are clearer . ...

  3. matlab Custom functions and calls

    This blog mainly studies : First of all , Custom functions have many advantages , For example, reusable : Easy to correct , Later, it will be directly loaded into large projects ( what's more , Arguments are copied to formal parameters , Run time parameters are displayed independently in custom functions , This and C Dissimilarity ). second , adopt h ...

  4. Custom functions and call functions return Return value

    1.Q: Why do we have functions , What is a function ? A: Function can improve the modularity of application , And code reuse 2. The function is divided into two stages : 1. Define the stage 2. Call phase 3. About function calls : 01. The memory address of the function plus () It's called ...

  5. stay JS in , How a custom function calls a variable in another custom function

    function aa1511() { var chengshi=" Ma'anshan "; var shengfen=" Anhui Province "; return shengfen+&quo ...

  6. FastReport call Delphi In the conversion of RMB capitalization user-defined function

    FastReport call Delphi In the conversion of RMB capitalization user-defined function   FastReport call Delphi In the conversion of RMB capitalization user-defined function function TJzpzEdit1.MoneyCn(mmje ...

  7. Mysql - stored procedure / Custom function

    In database operation , Especially when it comes to some complicated systems , ineluctable , We'll use functions / Custom function , Or stored procedures . In actual projects , The fewer custom functions and stored procedures, the better , Because there are so many things , It's also a very difficult place to maintain ...

  8. Oracle Custom function 1

    User defined functions are blocks of code stored in a database , You can return the value to the caller . When called, it is like a system function , Such as max(value) function , among ,value It's called parameter . Function parameters are 3 Types . IN  Parameter type : Represents the parameter input to the function ...

  9. Oracle Custom function

    Core tips : Functions are used to return specific data . When executing, you need to find a variable to receive the return value of the function ; The grammar is as follows : create or replace function function_name ( argu1 [mode1] da ...

  10. python Custom function

    200 ? "200px" : this.width)!important;} --> Introduce stay Python in , Define a function to use def sentence , Write the function names in turn . Brackets . Reference in parentheses ...

Random recommendation

  1. Collections

    2017-01-06  22:50:43 Data structures and algorithms < How to learn data structure ?>: <How do I ...

  2. Centos in jdk Environment configuration of

    stay Centos in , To configure jdk Environment , I've been listening to this for a long time . especially , In one configuration , Led to my later root The user can't log in , And log in with other ordinary users , Use su - root Switch to root user , Can't use l ...

  3. Find out Android Rogue software

    Find out Android Rogue software http://www.william ...

  4. jquery Realize partial refresh of page ajax practice

    There are many ways to do it , The common ones are the following : Here's how to refresh the whole page : Sometimes it's possible to use  window.location.reload() Refresh current page . parent.location.reload() Refresh father ...

  5. NYOJ 16 Rectangle nesting ( Dynamic programming )

    Rectangle nesting The time limit : 3000 ms  |  Memory limit : 65535 KB difficulty : 4   describe Yes n A rectangle , Each rectangle can use a,b To describe , It means length and width . rectangular X(a,b) Can be nested in rectangles Y(c,d) If and only ...

  6. try catch finally What is the order of execution ?

    First, execute try, If there is an exception, execute catch, It will be carried out anyway finally A function must execute finally Part of . The execution process of a function is , When there is return in the future , The function will store the data in a certain location ...

  7. Set up node Server port and operating environment

    Generally speaking ,node You usually see such code in the server : ``` app.set('port', process.env.PORT || 3000); if ( process.env.NODE_ENV == ...

  8. Linux Second articles 【 System environment 、 Common commands 、SSH Connect 、 Installation development environment 】

    System environment We know Windows Its excellence lies in its graphical interface , and Linux Support for graphical interfaces is not so friendly - In fact, we are Windows All the operations on the graphical interface under the have to be changed into commands ! Yes, of course , We are Ub ...

  9. web Development performance optimization --- Distributed article

    1. Distributed architecture - Independent site development Modular and structured development , Realize multi resource sub site , Data sub base , Prepare for later distributed deployment , It is mainly divided into the following parts : web Site : 1.web Front end site 2. picture . File resource site 3. Management site 4 ...

  10. On the front end of mvvm And mvc

    It was used vue So long , But no serious attention mvvm And mvc, I'm really ashamed . Take advantage of the weekend just look at the online articles and books , Let's talk about my understanding . - The following pictures are taken from the Internet . One .MVC characteristic : Individual communications View (View): user ...