入驻申请页面js筛选功能优化

This commit is contained in:
liuxiaoquan 2023-03-14 01:58:33 +08:00
parent 50d6fdef3b
commit bc5ec1eee7

View File

@ -1,7 +1,12 @@
{extend name="common/base"/}
<!-- 主体 -->
{block name="body"}
<style>
.layui-btn-group{
display:flex;
}
</style>
<div class="p-3">
@ -18,7 +23,8 @@
<label class="layui-form-label">选择时间</label>
<div class="layui-input-block">
<div class="layui-btn-group">
<input id="chonse_date" type="hidden" name="chonse_date" value="" readonly placeholder="选择时间">
<input id="chonse_start_date" type="hidden" name="start_date" value="" readonly placeholder="选择时间">
<input id="chonse_end_date" type="hidden" name="end_date" value="" readonly placeholder="选择时间">
<button name="both" lay-filter="chonse_date" type="button" class="layui-btn layui-btn-normal">全部</button>
<button name="today" lay-submit="" lay-filter="chonse_date" type="button" class="layui-btn layui-btn-normal layui-btn-primary">今天</button>
<button name="yeserday" lay-submit="" lay-filter="chonse_date" type="button" class="layui-btn layui-btn-normal layui-btn-primary">昨天</button>
@ -34,13 +40,11 @@
<!-- <label class="layui-form-label">日期范围</label> -->
<div class="layui-inline" id="range_date">
<div class="layui-input-inline">
<input type="text" autocomplete="off" name="start_date" id="test-startDate-1" class="layui-input"
placeholder="开始日期">
<input type="text" autocomplete="off" name="start_date" id="start-date" class="layui-input" placeholder="开始日期">
</div>
<div class="layui-form-mid">-</div>
<div class="layui-input-inline">
<input type="text" autocomplete="off" name="end_date" id="test-endDate-1" class="layui-input"
placeholder="结束日期">
<input type="text" autocomplete="off" name="end_date" id="end-date" class="layui-input" placeholder="结束日期">
</div>
</div>
</div>
@ -48,22 +52,22 @@
</div>
<div class="layui-form-item">
<div class="layui-input-inline" style="width:35%;">
<div class="layui-input-inline" style="width:45%;">
<div class="layui-form-item">
<label class="layui-form-label">商户审核</label>
<div class="layui-input-block">
<div class="layui-btn-group">
<input type="hidden" id="status" name="status" value="" readonly placeholder="核审状态值">
<button name="both" lay-submit="" lay-filter="statusform" type="button" class="layui-btn layui-btn-normal">全部</button>
<button name="wait_status" lay-submit="" lay-filter="statusform" type="button" class="layui-btn layui-btn-normal layui-btn-primary">待审核</button>
<button name="success_status" lay-submit="" lay-filter="statusform" type="button" class="layui-btn layui-btn-normal layui-btn-primary">审核通过</button>
<button name="failed_status" lay-submit="" lay-filter="statusform" type="button" class="layui-btn layui-btn-normal layui-btn-primary">审核未通过</button>
<button name="wait" lay-submit="" lay-filter="statusform" type="button" class="layui-btn layui-btn-normal layui-btn-primary">待审核</button>
<button name="success" lay-submit="" lay-filter="statusform" type="button" class="layui-btn layui-btn-normal layui-btn-primary">审核通过</button>
<button name="failed" lay-submit="" lay-filter="statusform" type="button" class="layui-btn layui-btn-normal layui-btn-primary">审核未通过</button>
</div>
</div>
</div>
</div>
<div class="layui-input-inline" style="width:35%;float:none;">
<div class="layui-input-inline" style="width:45%;float:none;">
<div class="layui-form-item">
<label class="layui-form-label">商户分类</label>
<div class="layui-input-block">
@ -83,7 +87,7 @@
<div class="layui-form-item">
<div class="layui-input-inline" style="width:35%;">
<div class="layui-input-inline" style="width:45%;">
<div class="layui-form-item">
<label class="layui-form-label">店铺类型</label>
<div class="layui-input-block">
@ -97,10 +101,10 @@
</div>
</div>
<div class="layui-input-inline" style="width:35%;">
<div class="layui-input-inline" style="width:45%;">
<div class="layui-form-item">
<label class="layui-form-label">关键字</label>
<div class="layui-input-block">
<div class="layui-input-block" style="display:flex">
<input style="width:70%;float:left" type="text" name="keywords" placeholder="请输入关键字"
class="layui-input" autocomplete="off" />
<button class="layui-btn layui-btn-normal" lay-submit=""
@ -210,11 +214,11 @@
width: 150,
templet: function(d){
if (d.status==0){
return '待审核'
return '<span style="color:yellow">待审核</span>'
}else if(d.status==1){
return '已审核'
return '<span style="color:green">已审核</span>'
}else if(d.status==2){
return '审核未通过'
return '<span style="color:red">审核未通过</span>'
}
}
}, {
@ -281,8 +285,10 @@
elem: '#range_date'
//设置开始日期、日期日期的 input 选择器
//数组格式为 2.6.6 开始新增,之前版本直接配置 true 或任意分割字符即可
, range: ['#test-startDate-1', '#test-endDate-1']
, range: ['#start-date', '#end-date']
,done: function(value, date, endDate){
switchDateForm(true);
active['reload'] ? active['reload'].call(this) : '';
}
});
@ -321,35 +327,74 @@
//选择时间
form.on('submit(chonse_date)', function(data){
var now = new Date().getTime(); //获取毫秒数
let start_date = '';
let end_date = getDaysAgo();
let value = '';
let name = data.elem.name;
if (name =='today') {
value = now;
start_date=end_date;
}else if(name == 'yeserday'){
value = new Date(now - 1 * 86400 * 1000).getTime();
start_date = end_date = getDaysAgo(1);
}else if(name == 'week'){
value = new Date(now - 7 * 86400 * 1000).getTime()+'-'+now;
start_date = getDaysAgo(7);
}else if(name == '30day'){
value = new Date(now - 30 * 86400 * 1000).getTime()+'-'+now;
start_date = getDaysAgo(30);
}else if(name == 'month'){
var day = now.getDate();//当前天份
console.log(day);
var day = (new Date()).getMonth()+1;//当前月份
value = new Date(now - day * 86400 * 1000).getTime()
let days = (new Date).getDate()-1
start_date = getDaysAgo(days);
}else if(name == 'year'){
value = now.getFullYear();//获取当前年份
var year = (new Date()).getFullYear();//获取当前年份
start_date = year+'-01-01'
}
$('#chonse_date').val(value);
switchDateForm(false);
$('#chonse_start_date').val(start_date);
$('#chonse_end_date').val(end_date);
active['reload'] ? active['reload'].call(this) : '';
return false;
})
// 两个时间表单是互斥的,只能提交一个
function switchDateForm(chonse=false)
{
let range = chonse?false:true;
$('#start-date').attr("disabled",range);
$('#end-date').attr("disabled",range);
$('#chonse_start_date').attr("disabled",chonse);
$('#chonse_end_date').attr("disabled",chonse);
if (chonse) {
$('#chonse_start_date').val("");
$('#chonse_end_date').val("");
}else{
$('#start-date').val("");
$('#end-date').val("");
}
}
// 商户审核
form.on('submit(statusform)', function(data) {
$('#status').val(data.elem.name);
let name = data.elem.name
let status = 0;
if (name=='wait') {
status = 0;
}else if(name=='success'){
status = 1;
}else if(name=='failed'){
status = 2;
}
if (name=='both'){
$('#status').attr('disabled', true);
}else{
$('#status').attr('disabled', false);
}
$('#status').val(status);
active['reload'] ? active['reload'].call(this) : '';
return false;
});
@ -363,6 +408,21 @@
});
//获取n天以前日期
function getDaysAgo(n=0) {
let myDate = new Date();
let lw = new Date(myDate - 1000 * 60 * 60 * 24 * n); //最后一个数字30可改n天前的意思
let lastY = lw.getFullYear();
let lastM = lw.getMonth() + 1;
let lastD = lw.getDate();
lastM = lastM < 10 ? "0" + lastM : lastM;
lastD = lastD < 10 ? "0" + lastD : lastD;
let startData = lastY+"-"+lastM+"-" +lastD; //n天之前日期
return startData;
}
// 获取表单所有参数
function getformdata() {
var form = $('#filterform').serializeArray();