503 lines
20 KiB
PHP
503 lines
20 KiB
PHP
<?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_labels = Store::statusLabels1();
|
||
$status = \Yii::$app->request->get('status');
|
||
?>
|
||
<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">
|
||
<!--<a class=" layui-btn" href="<?= \Yii::$app->urlManager->createUrl(["admin/feedback/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="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">
|
||
<div class="layui-input-inline">
|
||
<select class="layui-select" name="is_send_sms">
|
||
<option value="">短信状态</option>
|
||
<option value="1">已发送</option>
|
||
<option value="2">待发送</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">
|
||
<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>-->
|
||
</div>
|
||
</script>
|
||
<!--行操作列模板-->
|
||
<script type="text/html" id="rowBarTpl">
|
||
{{# if(d.status == 0){ }}
|
||
<button class="layui-btn layui-btn-xs" lay-event="status_yes">同意</button>
|
||
<button class="layui-btn layui-btn-xs layui-btn-danger" lay-event="status_no">拒绝</button>
|
||
{{# }else if(d.status == 1){ }}
|
||
<button class="layui-btn layui-btn-xs" lay-event="send_yes_sms">发送成为店长短信</button>
|
||
{{# }else{ }}
|
||
<button class="layui-btn layui-btn-xs" lay-event="send_no_sms">发送拒绝成为店长短信</button>
|
||
<button class="layui-btn layui-btn-xs layui-btn-danger" lay-event="delete_data">删除</button>
|
||
{{# } }}
|
||
</script>
|
||
|
||
|
||
<!--<script type="text/html" id="statusTpl">-->
|
||
<!-- {{# if(d.status == '0'){ }}-->
|
||
<!-- <span class="layui-badge layui-bg-red">待审核</span>-->
|
||
<!-- {{# } else if{ d.status == '1' }}-->
|
||
<!-- <span class="layui-badge layui-bg-blue">通过</span>-->
|
||
<!-- {{# } else if{ d.status == '2' }}-->
|
||
<!-- <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 layui-bg-black">待审核</span>
|
||
{{# } else if(d.status == '1'){ }}
|
||
<span class="layui-badge layui-bg-blue">已分配</span>
|
||
{{# } else if(d.status == '2'){ }}
|
||
<span class="layui-badge layui-bg-red">拒绝</span>
|
||
{{# } }}
|
||
</script>
|
||
|
||
<script type="text/html" id="statusSmsTpl">
|
||
{{# if(d.is_send_sms == '2'){ }}
|
||
<span class="layui-badge layui-bg-blue layui-bg-black">待发送</span>
|
||
{{# } else { }}
|
||
<span class="layui-badge layui-bg-blue">已发送</span>
|
||
{{# } }}
|
||
</script>
|
||
|
||
|
||
|
||
<script id="recharge_html" type="text/html">
|
||
<div style='padding:10px' class="layui-form">
|
||
|
||
<!-- <div class="layui-inline layui-form-item">-->
|
||
<!-- <div class="layui-input-inline">-->
|
||
<!-- <select class="layui-select" name="cat_id">-->
|
||
<!-- <option value="">全部店长</option>-->
|
||
<!-- --><?php //foreach ($user_list as $index => $item): ?>
|
||
<!-- <option value="--><? //= $item['user_id'] ?><!--">-->
|
||
<? //= $item['username'] ?><!--</option>-->
|
||
<!-- --><?php //endforeach; ?>
|
||
<!-- </select>-->
|
||
<!-- </div>-->
|
||
<!-- </div>-->
|
||
<!-- </div>-->
|
||
|
||
<div class="layui-form-item">
|
||
<label class="layui-form-label ">全部店长</label>
|
||
<div class="layui-input-block">
|
||
<select name="distribution_user_id">
|
||
<option value="">请选择店长</option>
|
||
<?php foreach ($user_list as $key => $val): ?>
|
||
<option value="<?= $val['user_id'] ?>"><?= $val['username'] ?></option>
|
||
<?php endforeach; ?>
|
||
</select>
|
||
</div>
|
||
</div>
|
||
<div class="layui-card-footer layui-text-center layui-mt-15 layui-mb-15">
|
||
<a class="layui-btn layui-btn-sm confirm-btn" lay-submit="" lay-filter="layui-recharge-submit"
|
||
href="javascript:;">确定</a>
|
||
<a class="layui-btn layui-btn-sm layui-btn-primary cancel-btn" href="javascript:;">取消</a>
|
||
</div>
|
||
</div>>
|
||
</script>
|
||
|
||
|
||
<script>
|
||
<?php $this->beginBlock('js_script_wrap') ?>
|
||
|
||
|
||
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-make'])?>'
|
||
, page: true
|
||
, where: conf
|
||
});
|
||
};
|
||
|
||
//执行渲染
|
||
table.render({
|
||
//指定原始表格元素选择器(推荐id选择器)
|
||
elem: '#dtable'
|
||
//容器高度
|
||
//,height: 315
|
||
//容器宽度
|
||
//,width: 720
|
||
//设置表头
|
||
, cols: [[
|
||
{checkbox: true}
|
||
, {field: 'id', title: 'ID', width: 80}
|
||
, {field: 'store_name', title: '门店名称'}
|
||
, {field: 'username', title: '申请人'}
|
||
, {field: 'mobile_phone', title: '手机号'}
|
||
, {field: 'make_time', title: '预约时间', width: 150}
|
||
, {field: 'store_username', title: '分配店长', width: 150}
|
||
, {field: 'msg', title: '提交信息', width: 150}
|
||
, {field: 'status', title: '状态', templet: '#statusTpl', width: 80}
|
||
, { title: '短信状态', templet: '#statusSmsTpl', width: 120}
|
||
, {field: 'store_id', width: 10, hide: true}
|
||
, {field: 'created_at_cn', title: '申请时间', width: 180}
|
||
, {title: '操作', fixed: 'right', toolbar: '#rowBarTpl', width: 230}
|
||
]
|
||
]
|
||
, url: '<?=\Yii::$app->urlManager->createUrl(['admin/store/store-make'])?>'
|
||
, page: true
|
||
//指向自定义工具栏模板选择器
|
||
, toolbar: '#toolBarTpl'
|
||
//头部工具栏右侧的图标按钮
|
||
, defaultToolbar: []
|
||
, 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 distribution_user_id = row_data.distribution_user_id;
|
||
var make_time = row_data.make_time;
|
||
|
||
var confirm_url = null;
|
||
var confirm_tip = null;
|
||
var ids = [];
|
||
ids.push(id);
|
||
|
||
//if (lay_event == "status_yes") {
|
||
//
|
||
// confirm_url = "<?//=\Yii::$app->urlManager->createUrl(['admin/store/shopowner-status-yes'])?>//";
|
||
// confirm_tip = "确定同意该用户店长申请吗?";
|
||
//}
|
||
if (lay_event == "status_no") {
|
||
confirm_url = "<?=\Yii::$app->urlManager->createUrl(['admin/store/store-make-status-no'])?>";
|
||
confirm_tip = "确定拒绝该用户店长预约吗?";
|
||
}
|
||
|
||
if (lay_event == "status_yes") {
|
||
confirm_url = "<?=\Yii::$app->urlManager->createUrl(['admin/store/store-make-status-yes'])?>";
|
||
confirm_tip = "确定同意该用户店长预约吗?";
|
||
}
|
||
|
||
if (lay_event == "send_yes_sms") {
|
||
confirm_url = "<?=\Yii::$app->urlManager->createUrl(['admin/store/store-make-send-yes-sms'])?>";
|
||
confirm_tip = "确定发送用户店长成功预约短信吗?";
|
||
}
|
||
|
||
if (lay_event == "send_no_sms") {
|
||
confirm_url = "<?=\Yii::$app->urlManager->createUrl(['admin/store/store-make-send-no-sms'])?>";
|
||
confirm_tip = "确定发送拒绝用户店长预约短信吗?";
|
||
}
|
||
if (lay_event == "delete_data") {
|
||
confirm_url = "<?=\Yii::$app->urlManager->createUrl(['admin/store/store-make-delete'])?>";
|
||
confirm_tip = "确定删除记录吗?";
|
||
}
|
||
|
||
|
||
//if (lay_event == 'edit') {
|
||
// confirm_url = "<?//=\Yii::$app->urlManager->createUrl(['admin/store/edit'])?>//" + "?id=" + id;
|
||
// location.href = confirm_url;
|
||
// return;
|
||
//}
|
||
|
||
if (confirm_url != null) {
|
||
layer.confirm(confirm_tip, {
|
||
btn: ['确定', '取消']
|
||
}, function (index) {
|
||
layer.close(index)
|
||
$.ajax(confirm_url, {
|
||
type: "POST",
|
||
dataType: "json",
|
||
data: {
|
||
make_time: row_data.make_time,
|
||
store_id: row_data.store_id,
|
||
id: row_data.id,
|
||
_csrf: _csrf
|
||
},
|
||
success: function (res) {
|
||
if (res.code == 0) {
|
||
if (lay_event == 'find_qrcode') {
|
||
var imgHtml = "<img src='" + res.data + "' width='500px' height='500px'/>";
|
||
//弹出层
|
||
layer.open({
|
||
type: 1,
|
||
shade: 0,
|
||
offset: 'auto',
|
||
area: 'auth',
|
||
shadeClose: true,
|
||
scrollbar: false,
|
||
title: "图片预览", //不显示标题
|
||
content: imgHtml, //捕获的元素,注意:最好该指定的元素要存放在body最外层,否则可能被其它的相对元素所影响
|
||
});
|
||
} else {
|
||
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 (lay_event == 'batch_qrcode') {
|
||
confirm_url = "<?=\Yii::$app->urlManager->createUrl(['admin/store/batch-qrcode'])?>";
|
||
location.href = confirm_url;
|
||
return;
|
||
}
|
||
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/delete'])?>";
|
||
confirm_tip = "确定将选中门店删除吗";
|
||
}
|
||
|
||
if (lay_event == 'batch_status_yes') {
|
||
confirm_url = "<?=\Yii::$app->urlManager->createUrl(['admin/store/status-yes'])?>";
|
||
confirm_tip = "确定将选中门店变更为营业吗";
|
||
}
|
||
if (lay_event == 'batch_status_no') {
|
||
confirm_url = "<?=\Yii::$app->urlManager->createUrl(['admin/store/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);
|
||
});
|
||
});
|
||
|
||
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); ?>
|
||
|