cxfoot/modules/admin/views/store/store-user.php
2023-10-27 14:25:12 +08:00

511 lines
20 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
use app\models\Store;
/**
* @author Any
* @description KISS
* @date 2021年6月30日
* @version 1.0.0
*
* _____LOG_____
*
*/
$this->title = '人员管理';
$this->params['breadcrumbs'][] = $this->title;
$status = \Yii::$app->request->get('status');
$user_type = \Yii::$app->request->get('user_type');
?>
<style type="text/css">
.layui-table-cell {
height: auto;
}
</style>
<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 layui-float-right layui-form">
<div class="layui-inline layui-form-item">
<div class="layui-input-inline">
<select class="layui-select" name="status">
<option value="" <?=$status === null ? 'selected' : ''?>>全部门店状态</option>
<option value="0" <?=$status == 0 && $status != null ? 'selected' : ''?>>停业</option>
<option value="1" <?=$status == 1 && $status != null ? 'selected' : ''?>>营业</option>
</select>
</div>
</div>
<div class="layui-inline layui-form-item">
<div class="layui-input-inline">
<select class="layui-select" name="user_type">
<option value="" <?=$user_type === null ? 'selected' : ''?>>全部人员</option>
<option value="1" <?=$user_type == 1 && $user_type != null ? 'selected' : ''?>>门店管理员</option>
<!-- <option value="2" --><?//=$user_type == 2 && $user_type != null ? 'selected' : ''?><!-->门店服务员</option>-->
<option value="3" <?=$user_type == 3 && $user_type != null ? 'selected' : ''?>>门店医师</option>
</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">
<div id="cd_location_body">
<div>门店管理员后台地址:<span id="cd_location"></span>/store</div>
<div>如果本机浏览器访问不了,则在本机中换个浏览器进行访问,或开启浏览器无痕模式进行访问</div>
<div>本地址访问人员:门店管理员、门店医师</div>
</div>
<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 layui-btn-normal" lay-event="batch_status_yes">批量正常</button>
<button class="layui-btn layui-btn-sm layui-btn-danger" lay-event="batch_status_no">批量封禁</button>
<button class="layui-btn layui-btn-sm layui-btn-danger" lay-event="batch_delete">批量删除</button>
</div>
</script>
<!--行操作列模板-->
<script type="text/html" id="rowBarTpl">
{{# if(d.status == '0'){ }}
<button class="layui-btn layui-btn-xs layui-btn-danger" lay-event="status_no">封禁</button>
{{# } else{ }}
<button class="layui-btn layui-btn-xs layui-btn-normal" lay-event="status_yes">切换正常</button>
{{# } }}
<button class="layui-btn layui-btn-xs" lay-event="edit">编辑</button>
<button class="layui-btn layui-btn-xs layui-btn-danger" lay-event="delete">删除</button>
</script>
<script type="text/html" id="storestatusTpl">
{{# if(d.store_status == '0'){ }}
<span class="layui-badge layui-bg-red">停业</span>
{{# } else{ }}
<span class="layui-badge layui-bg-blue">营业</span>
{{# } }}
</script>
<script type="text/html" id="statusTpl">
{{# if(d.status == '0'){ }}
<span class="layui-badge layui-bg-blue">正常</span>
{{# } else{ }}
<span class="layui-badge layui-bg-red">封禁</span>
{{# } }}
</script>
<script type="text/html" id="usertypeTpl">
{{# if(d.user_type == '1'){ }}
<span class="layui-badge layui-bg-black">门店管理员</span>
{{# } else if(d.user_type == '3'){ }}
<span class="layui-badge layui-bg-green">门店医师</span>
{{# } }}
</script>
<script type="text/html" id="realnameTpl">
<img src="{{d.avatar_url}}" style="width:24px;height:24px;border-radius: 24px;margin-right: 4px;">{{d.real_name}}
</script>
<!--<script type="text/html" id="gjsmsTpl">-->
<!-- {{# if(d.gjsms == 1){ }}-->
<!-- <input type="checkbox" lay-skin="switch" checked="" data="{{d.mobile_phone}}" lay-filter="switchgjsmsTpl" lay-text="接收|不接收">-->
<!-- {{# }else{ }}-->
<!-- <input type="checkbox" lay-skin="switch" data="{{d.mobile_phone}}" lay-filter="switchgjsmsTpl" lay-text="接收|不接收">-->
<!-- {{# } }}-->
<!--</script>-->
<!--<script type="text/html" id="ghsmsTpl">-->
<!-- {{# if(d.ghsms == 1){ }}-->
<!-- <input type="checkbox" checked="" lay-skin="switch" data="{{d.mobile_phone}}" lay-filter="switchghsmsTpl" lay-text="接收|不接收">-->
<!-- {{# }else{ }}-->
<!-- <input type="checkbox" lay-skin="switch" data="{{d.mobile_phone}}" lay-filter="switchghsmsTpl" lay-text="接收|不接收">-->
<!-- {{# } }}-->
<!--</script>-->
<script>
<?php $this->beginBlock('js_script_wrap') ?>
$('#cd_location_body').hide();
layui.config({
base: '/statics/layuiadmin/' //静态资源所在路径
}).extend({
index: 'lib/index' //主入口模块
}).use(['index', 'user', 'table','form'], 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);
});
//重新加载表格数据
function reload_table_data(conf){
table.reload('dtable', {
url:'<?=\Yii::$app->urlManager->createUrl(['admin/store/store-user'])?>'
,page: true
,where: conf
});
}
$('#cd_location').html(window.location.origin);
$('#cd_location_body').show();
//执行渲染
table.render({
//指定原始表格元素选择器推荐id选择器
elem: '#dtable'
//容器高度
//,height: 315
//容器宽度
//,width: 720
//设置表头
,cols: [[
{checkbox: true}
, {field: 'id', title: 'ID', width: 80}
, {field: 'name', title: '门店名称'}
, {field: 'business', title: '营业时间', width: 110}
, {field: 'store_status', title: '门店状态',templet:'#storestatusTpl', width: 110}
, {field: 'username', title: 'PC端账号', width: 150}
, {field: 'real_name', title: '管理员', templet:'#realnameTpl'}
, {field: 'status', title: '状态',templet:'#statusTpl', width: 80}
, {field: 'user_type', title: '角色',templet:'#usertypeTpl', width: 110}
, {field: 'created_at_cn', title: '创建时间', width: 150}
// , {title: '归还短信',templet:'#ghsmsTpl', width: 150}
// , {title: '告警短信',templet:'#gjsmsTpl', width: 150}
, {title: '操作',fixed: 'right', toolbar: '#rowBarTpl', width:200}
]
]
, url:'<?=\Yii::$app->urlManager->createUrl(['admin/store/store-user'])?>'
, 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:[]
, done: function(res, curr, count){
setTimeout(function(){
$(".layui-table-main tr").each(function (index ,val) {
$(".layui-table-fixed").each(function () {
$($(this).find(".layui-table-body tbody tr")[index]).height($(val).height());
});
});
$(".layui-table-header tr").each(function (index ,val) {
$(".layui-table-fixed").each(function () {
$($(this).find(".layui-table-header thead tr")[index]).height($(val).height());
});
});
},500);
}
});
//监听工具条
table.on('tool(dtable)', function(obj){
var row_data = obj.data;
var lay_event = obj.event;
var id = row_data.id;
var confirm_url = null;
var confirm_tip = null;
var ids = [];
ids.push(id);
if(lay_event == "delete"){
confirm_url = "<?=\Yii::$app->urlManager->createUrl(['admin/store/store-user-delete'])?>";
confirm_tip = "确定删除此账号吗";
}
if(lay_event == "status_yes"){
confirm_url = "<?=\Yii::$app->urlManager->createUrl(['admin/store/store-user-status-yes'])?>";
confirm_tip = "确定此账号变更为正常吗?";
}
if(lay_event == "status_no"){
confirm_url = "<?=\Yii::$app->urlManager->createUrl(['admin/store/store-user-status-no'])?>";
confirm_tip = "确定此账号变更为封禁吗?";
}
if(lay_event == 'edit'){
confirm_url = "<?=\Yii::$app->urlManager->createUrl(['admin/store/store-user-edit'])?>" + "?id="+id;
location.href= confirm_url;
return;
}
if(confirm_url != null){
layer.confirm(confirm_tip, {
btn: ['确定','取消']
}, function(){
$.ajax(confirm_url,{
type:"POST",
dataType:"json",
data:{
ids:ids,
_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('toolbar(dtable)', function(obj){
var lay_event = obj.event;
var check_status = table.checkStatus('dtable');
var ids = [];
$(check_status.data).each(function(index){
ids.push(check_status.data[index]['id']);
});
if(ids.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/store/store-user-delete'])?>";
confirm_tip = "确定将选中账号删除吗";
}
if(lay_event == 'batch_status_yes'){
confirm_url = "<?=\Yii::$app->urlManager->createUrl(['admin/store/store-user-status-yes'])?>";
confirm_tip = "确定将选中账号变更为正常吗";
}
if(lay_event == 'batch_status_no'){
confirm_url = "<?=\Yii::$app->urlManager->createUrl(['admin/store/store-user-status-no'])?>";
confirm_tip = "确定将选中账号变更为封禁吗";
}
if(confirm_url != null){
layer.confirm(confirm_tip, {
btn: ['确定','取消']
}, function(){
$.ajax(confirm_url,{
type:"POST",
dataType:"json",
data:{
ids:ids,
_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('select(province)',function(res){
app.province_id = res.value;
$(app.province).each(function (i) {
if (app.province[i].id == app.province_id) {
app.city = app.province_id != 0 ? app.province[i].list : [];
//app.city_id = app.province_id != 0 ? app.province[i].list[0]['id'] : 0;
app.area = app.province_id != 0 ? app.city[0].list : [];
//app.area_id = app.province_id != 0 ? app.city[0].list[0]['id'] : 0;
app.province_id = app.province_id == 0 ? '' : app.province_id;
app.$forceUpdate();
setTimeout(function(){
form.render('select');
},500);
return true;
}
});
});
form.on('select(city)',function(res){
app.city_id = res.value;
$(app.city).each(function (i) {
if (app.city[i].id == app.city_id) {
app.area = app.city[i].list;
//app.area_id = app.city[i].list[0]['id'];
app.$forceUpdate();
setTimeout(function(){
form.render('select');
},500);
return true;
}
});
});
form.on('select(area)',function(res){
app.area_id = res.value;
setTimeout(function(){
form.render('select');
},500);
});
//监听指定开关
form.on('switch(switchgjsmsTpl)', function(data){
var url = '<?=\Yii::$app->urlManager->createUrl(['admin/store/store-user-setsms'])?>';
$.ajax(url, {
type: "POST",
dataType: "json",
data: {
_csrf:_csrf,
type:'gjsms',
mobile_phone:$(this).attr('data')
},
timeout: 10000,
success: function (res) {
if (res.code == 0) {
} else {
layer.msg(res.msg, {
offset: '15px'
, icon: 2
, time: 1000
}, function () {
window.location.reload()
});
}
},
error: function (xhr, type, err) {
layer.msg(xhr.responseText, {
offset: '15px'
, icon: 2
, time: 1000
}, function () {
window.location.reload()
});
},
complete: function () {
}
})
});
//监听指定开关
form.on('switch(switchghsmsTpl)', function(data){
var url = '<?=\Yii::$app->urlManager->createUrl(['admin/store/store-user-setsms'])?>';
$.ajax(url, {
type: "POST",
dataType: "json",
data: {
_csrf:_csrf,
type:'ghsms',
mobile_phone:$(this).attr('data')
},
timeout: 10000,
success: function (res) {
if (res.code == 0) {
} else {
layer.msg(res.msg, {
offset: '15px'
, icon: 2
, time: 1000
}, function () {
window.location.reload()
});
}
},
error: function (xhr, type, err) {
layer.msg(xhr.responseText, {
offset: '15px'
, icon: 2
, time: 1000
}, function () {
window.location.reload()
});
},
complete: function () {
}
})
});
});
function previewImg(obj) {
var img = new Image();
img.src = obj.src;
var imgw = img.width;
var imgh = img.height;
var img_th = imgh / imgw * 500;
var imgHtml = "<img src='" + obj.src + "' width='500px' height='"+img_th+"px'/>";
//弹出层
layer.open({
type: 1,
shade: 0.8,
offset: 'auto',
area: [500 + 'px',(img_th+50)+'px'],
shadeClose:true,
scrollbar: false,
title: "图片预览", //不显示标题
content: imgHtml, //捕获的元素注意最好该指定的元素要存放在body最外层否则可能被其它的相对元素所影响
cancel: function () {
//layer.msg('捕获就是从页面已经存在的元素上包裹layer的结构', { time: 5000, icon: 6 });
}
});
}
<?php $this->endBlock(); ?>
</script>
<?php $this->registerJs($this->blocks['js_script_wrap'], \yii\web\View::POS_END); ?>