393 lines
16 KiB
PHP
393 lines
16 KiB
PHP
<?php
|
||
|
||
/**
|
||
* @author Any
|
||
* @description KISS
|
||
* @date 2022年7月12日
|
||
* @version 1.0.0
|
||
*
|
||
* _____LOG_____
|
||
*
|
||
*/
|
||
use yii\widgets\LinkPager;
|
||
use app\models\PaymentConfig;
|
||
|
||
$this->title = '支付配置列表';
|
||
$this->params['breadcrumbs'][] = $this->title;
|
||
|
||
$status_labels = PaymentConfig::statusLabels();
|
||
$status = \Yii::$app->request->get('status');
|
||
$pay_type = \Yii::$app->request->get('pay_type');
|
||
?>
|
||
<div class="layui-fluid">
|
||
<div class="layui-card">
|
||
<div class="layui-card-header">
|
||
<?= $this->title ?>
|
||
</div>
|
||
<div class="layui-card-header layuiadmin-card-header-auto">
|
||
<div class="layui-form-item">
|
||
<div class="layui-inline">
|
||
<a class=" layui-btn" href="<?=\Yii::$app->urlManager->createUrl(["admin/setting/payment-config-edit"])?>">添加支付配置</a>
|
||
</div>
|
||
<div class="layui-inline layui-float-right layui-form">
|
||
|
||
<div class="layui-inline layui-form-item">
|
||
<div class="layui-input-inline">
|
||
<select class="layui-select" name="pay_type">
|
||
<option value="" <?=$pay_type=== null ? 'selected' : ''?>>支付类型</option>
|
||
<?php foreach ($pay_types as $index => $item):?>
|
||
<?php if(!$item['is_show']){continue;}?>
|
||
<option value="<?=$item['short_name']?>" <?=$pay_type == $item['pay_short'] && $pay_type != null ? 'selected' : ''?>><?=$item['name']?></option>
|
||
<?php endforeach;?>
|
||
</select>
|
||
</div>
|
||
</div>
|
||
<div class="layui-inline layui-form-item">
|
||
<div class="layui-input-inline">
|
||
<select class="layui-select" name="status">
|
||
<option value="" <?=$status === null ? 'selected' : ''?>>全部状态</option>
|
||
<?php foreach ($status_labels as $key => $val):?>
|
||
<option value="<?=$key?>" <?=$status == $key && $status != null ? 'selected' : ''?>><?=$val?></option>
|
||
<?php endforeach;?>
|
||
</select>
|
||
</div>
|
||
</div>
|
||
<div class="layui-inline layui-form-item">
|
||
<label class="layui-form-label">关键词</label>
|
||
<div class="layui-input-block">
|
||
<input type="text" name="keywords" placeholder="搜索名称" autocomplete="off" class="layui-input" value="<?=\Yii::$app->request->get("keywords")?>">
|
||
</div>
|
||
</div>
|
||
<div class="layui-inline">
|
||
<button class="layui-btn layuiadmin-btn-useradmin" lay-submit lay-filter="dtable-search">
|
||
<i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
|
||
</button>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="layui-card-body">
|
||
<table id="dtable" lay-filter="dtable"></table>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<!--工具栏模板-->
|
||
<script type="text/html" id="toolBarTpl">
|
||
<div class="layui-btn-container">
|
||
<!--<button class="layui-btn layui-btn-sm" lay-event="add">添加</button>-->
|
||
<!--<button class="layui-btn layui-btn-sm layui-btn-danger" lay-event="batch_delete">批量删除</button>-->
|
||
</div>
|
||
</script>
|
||
<!--行操作列模板-->
|
||
<script type="text/html" id="rowBarTpl">
|
||
<button class="layui-btn layui-btn-xs" lay-event="edit">编辑</button>
|
||
{{# if(d.status == 0){ }}
|
||
<button class="layui-btn layui-btn-xs layui-btn-danger" lay-event="delete">删除</button>
|
||
{{# } }}
|
||
</script>
|
||
|
||
<script type="text/html" id="statusTpl">
|
||
<input type="checkbox" name="status" value="{{ d.id }}" {{ d.status == 1 ? 'checked' : '' }} lay-skin="switch" lay-text="启用|停用" lay-filter="switch_status">
|
||
</script>
|
||
|
||
<script>
|
||
<?php $this->beginBlock('js_script_wrap') ?>
|
||
layui.config({
|
||
base: '/statics/layuiadmin/' //静态资源所在路径
|
||
}).extend({
|
||
index: 'lib/index' //主入口模块
|
||
}).use(['index', 'user', 'table'], function () {
|
||
var $ = layui.$
|
||
, form = layui.form
|
||
, table = layui.table
|
||
, admin = layui.admin;
|
||
form.render();
|
||
|
||
//search
|
||
form.on('submit(dtable-search)', function (obj) {
|
||
var field = obj.field;
|
||
reload_table_data(field);
|
||
});
|
||
|
||
form.on('select(batch-action)', function (obj) {
|
||
var lay_event = obj.value;
|
||
var check_status = table.checkStatus('dtable');
|
||
var id = [];
|
||
$(check_status.data).each(function(index){
|
||
id.push(check_status.data[index]['id']);
|
||
});
|
||
|
||
var confirm_url = null;
|
||
var confirm_tip = null;
|
||
|
||
if(confirm_url != null){
|
||
layer.confirm(confirm_tip, {
|
||
btn: ['确定','取消']
|
||
}, function(){
|
||
$.ajax(confirm_url,{
|
||
type:"POST",
|
||
dataType:"json",
|
||
data:{
|
||
config_id:id,
|
||
_csrf:_csrf
|
||
},
|
||
success:function(res){
|
||
if(res.code == 0){
|
||
layer.msg(res.msg, {
|
||
offset: '15px'
|
||
,icon: 1
|
||
,time: 1000
|
||
}, function(){
|
||
location.reload();
|
||
});
|
||
} else {
|
||
layer.msg(res.msg, {
|
||
offset: '15px'
|
||
,icon: 2
|
||
,time: 1000
|
||
}, function(){
|
||
});
|
||
}
|
||
},
|
||
error:function(xhr,type,err){
|
||
layer.msg(xhr.responseText, {
|
||
offset: '15px'
|
||
,icon: 2
|
||
,time: 1000
|
||
}, function(){
|
||
});
|
||
}
|
||
})
|
||
}, function(){
|
||
});
|
||
}
|
||
});
|
||
|
||
//重新加载表格数据
|
||
function reload_table_data(conf){
|
||
table.reload('dtable', {
|
||
url:'<?=\Yii::$app->urlManager->createUrl(['admin/setting/payment-config'])?>'
|
||
,page: true
|
||
,where: conf
|
||
});
|
||
};
|
||
|
||
//执行渲染
|
||
table.render({
|
||
//指定原始表格元素选择器(推荐id选择器)
|
||
elem: '#dtable'
|
||
//容器高度
|
||
//,height: 315
|
||
//容器宽度
|
||
//,width: 720
|
||
//设置表头
|
||
,cols: [[
|
||
{checkbox: true}
|
||
, {field: 'id', title: 'ID', width: 80}
|
||
, {field: 'name', title: '标题', width: 280}
|
||
, {field: 'pay_type_cn', title: '支付类型', width: 120 }
|
||
, {field: 'status', title: '是否启用', templet:'#statusTpl', width: 200}
|
||
, {field: 'remark', title: '备注',}
|
||
, {field: 'created_at_cn', title: '添加时间', width: 180}
|
||
, {field: 'updated_at_cn', title: '更新时间', width: 180}
|
||
, {title: '操作',fixed: 'right', toolbar: '#rowBarTpl', width:200}
|
||
]
|
||
]
|
||
, url:'<?=\Yii::$app->urlManager->createUrl(['admin/setting/payment-config'])?>'
|
||
, page:true
|
||
//指向自定义工具栏模板选择器
|
||
, toolbar:'#toolBarTpl'
|
||
//头部工具栏右侧的图标按钮
|
||
, defaultToolbar:['filter', 'print', 'exports']
|
||
, limit: 20
|
||
, limits:[10,20,30,40,50,60,70,80,90,100]
|
||
, title:'<?=$this->title?>'
|
||
, data:[]
|
||
});
|
||
//监听工具栏
|
||
table.on('toolbar(dtable)', function(obj){
|
||
var lay_event = obj.event;
|
||
var check_status = table.checkStatus('dtable');
|
||
var id = [];
|
||
$(check_status.data).each(function(index){
|
||
id.push(check_status.data[index]['id']);
|
||
});
|
||
if(id.length == 0){
|
||
return layer.msg("请选择需要操作项");
|
||
}
|
||
|
||
var confirm_url = null;
|
||
var confirm_tip = null;
|
||
if(lay_event == 'batch_delete'){
|
||
confirm_url = "<?=\Yii::$app->urlManager->createUrl(['admin/setting/payment-config-delete'])?>";
|
||
confirm_tip = "确定将选中帮助删除吗";
|
||
}
|
||
|
||
if(confirm_url != null){
|
||
layer.confirm(confirm_tip, {
|
||
btn: ['确定','取消']
|
||
}, function(){
|
||
$.ajax(confirm_url,{
|
||
type:"POST",
|
||
dataType:"json",
|
||
data:{
|
||
config_id:id,
|
||
_csrf:_csrf
|
||
},
|
||
success:function(res){
|
||
if(res.code == 0){
|
||
layer.msg(res.msg, {
|
||
offset: '15px'
|
||
,icon: 1
|
||
,time: 1000
|
||
}, function(){
|
||
location.reload();
|
||
});
|
||
} else {
|
||
layer.msg(res.msg, {
|
||
offset: '15px'
|
||
,icon: 2
|
||
,time: 1000
|
||
}, function(){
|
||
});
|
||
}
|
||
},
|
||
error:function(xhr,type,err){
|
||
layer.msg(xhr.responseText, {
|
||
offset: '15px'
|
||
,icon: 2
|
||
,time: 1000
|
||
}, function(){
|
||
});
|
||
}
|
||
})
|
||
}, function(){
|
||
});
|
||
}
|
||
});
|
||
|
||
//监听工具条
|
||
table.on('tool(dtable)', function(obj){
|
||
var row_data = obj.data;
|
||
var lay_event = obj.event;
|
||
var id = row_data.id;
|
||
|
||
if(lay_event == 'edit'){
|
||
var url = "<?=\Yii::$app->urlManager->createUrl(['admin/setting/payment-config-edit'])?>" + "?id=" + id;
|
||
location.href= url;
|
||
return;
|
||
}
|
||
|
||
var confirm_url = null;
|
||
var confirm_tip = null;
|
||
if(lay_event == "delete"){
|
||
confirm_url = "<?=\Yii::$app->urlManager->createUrl(['admin/setting/payment-config-delete'])?>";
|
||
confirm_tip = "确定删除此帮助吗";
|
||
}
|
||
|
||
if(confirm_url != null){
|
||
layer.confirm(confirm_tip, {
|
||
btn: ['确定','取消']
|
||
}, function(){
|
||
$.ajax(confirm_url,{
|
||
type:"POST",
|
||
dataType:"json",
|
||
data:{
|
||
config_id:id,
|
||
_csrf:_csrf
|
||
},
|
||
success:function(res){
|
||
if(res.code == 0){
|
||
layer.msg(res.msg, {
|
||
offset: '15px'
|
||
,icon: 1
|
||
,time: 1000
|
||
}, function(){
|
||
location.reload();
|
||
});
|
||
} else {
|
||
layer.msg(res.msg, {
|
||
offset: '15px'
|
||
,icon: 2
|
||
,time: 1000
|
||
}, function(){
|
||
});
|
||
}
|
||
},
|
||
error:function(xhr,type,err){
|
||
layer.msg(xhr.responseText, {
|
||
offset: '15px'
|
||
,icon: 2
|
||
,time: 1000
|
||
}, function(){
|
||
});
|
||
}
|
||
})
|
||
}, function(){
|
||
});
|
||
}
|
||
});
|
||
form.on('switch(switch_status)', function(obj){
|
||
var lay_event = obj.elem.checked ? 'on' : 'off';
|
||
var id = this.value;
|
||
|
||
var confirm_url = null;
|
||
var confirm_tip = null;
|
||
|
||
if(lay_event == "on"){
|
||
confirm_url = "<?=\Yii::$app->urlManager->createUrl(['admin/setting/payment-config-open'])?>";
|
||
confirm_tip = "确定启用吗";
|
||
}
|
||
if(lay_event == "off"){
|
||
confirm_url = "<?=\Yii::$app->urlManager->createUrl(['admin/setting/payment-config-close'])?>";
|
||
confirm_tip = "确定停用吗";
|
||
}
|
||
if(confirm_url == null){
|
||
return;
|
||
}
|
||
|
||
$.ajax(confirm_url,{
|
||
type:"POST",
|
||
dataType:"json",
|
||
data:{
|
||
config_id:id,
|
||
_csrf:_csrf
|
||
},
|
||
success:function(res){
|
||
if(res.code == 0){
|
||
layer.msg(res.msg, {
|
||
offset: '15px'
|
||
,icon: 1
|
||
,time: 1000
|
||
}, function(){
|
||
location.reload();
|
||
});
|
||
} else {
|
||
layer.msg(res.msg, {
|
||
offset: '15px'
|
||
,icon: 2
|
||
,time: 1000
|
||
}, function(){
|
||
});
|
||
}
|
||
},
|
||
error:function(xhr,type,err){
|
||
layer.msg(xhr.responseText, {
|
||
offset: '15px'
|
||
,icon: 2
|
||
,time: 1000
|
||
}, function(){
|
||
});
|
||
}
|
||
})
|
||
});
|
||
|
||
});
|
||
<?php $this->endBlock(); ?>
|
||
</script>
|
||
<?php $this->registerJs($this->blocks['js_script_wrap'], \yii\web\View::POS_END); ?>
|
||
|
||
|
||
|