347 lines
12 KiB
PHP
347 lines
12 KiB
PHP
<?php
|
||
|
||
/**
|
||
* @author Any
|
||
* @description KISS
|
||
* @date 2021年9月15日
|
||
* @version 1.0.0
|
||
*
|
||
* _____LOG_____
|
||
*
|
||
*/
|
||
use app\widgets\PickFile;
|
||
use app\components\EncryptHelper;
|
||
$this->title = $model->isNewRecord ? '创建卡券' : '编辑门店人员';
|
||
$this->params['breadcrumbs'][] = ['label' => '人员列表' , 'url' => [\Yii::$app->urlManager->createUrl(["admin/store/store-user"])]];
|
||
$this->params['breadcrumbs'][] = $this->title;
|
||
?>
|
||
<style>
|
||
.layui-input-block {
|
||
margin-left: 160px;
|
||
}
|
||
.layui-form-label {
|
||
width: 120px;
|
||
}
|
||
.laydate-time-list{padding-bottom:0;overflow:hidden}
|
||
.laydate-time-list>li{width:50%!important;}
|
||
.laydate-time-list>li:last-child { display: none;}
|
||
.user_div {
|
||
margin: 2px 5px 2px 8px;
|
||
height: 20%;
|
||
width: 6%;
|
||
float: left;
|
||
position: relative;
|
||
}
|
||
</style>
|
||
<div class="layui-fluid">
|
||
<div class="layui-card">
|
||
<div class="layui-card-header"><?= $this->title ?></div>
|
||
<div class="layui-card-body">
|
||
<div class="layui-row">
|
||
<div class="layui-col-md10">
|
||
<div class="layui-form">
|
||
|
||
<div class="layui-form-item">
|
||
<label class="layui-form-label required">卡券</label>
|
||
<div class="layui-input-block">
|
||
<select name="coupon_id" lay-filter="coupon">
|
||
<option value=""></option>
|
||
<?php foreach ($coupon as $key => $val):?>
|
||
<option value="<?=$val['id']?>"><?=$val['title']?></option>
|
||
<?php endforeach;?>
|
||
</select>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="layui-form-item">
|
||
<label class="layui-form-label required">发放用户</label>
|
||
<div class="layui-input-block">
|
||
<input type="radio" name="user_type" value="0" checked title="全部" lay-filter="user_type">
|
||
<input type="radio" name="user_type" value="1" title="指定用户" lay-filter="user_type">
|
||
</div>
|
||
<div class="layui-form-mid layui-word-aux"></div>
|
||
</div>
|
||
|
||
|
||
<div class="layui-inline layui-form-item" id="user_ids" style="display: none;float: left;">
|
||
<label class="layui-form-label">选择用户</label>
|
||
<div class="layui-input-block layui-btn-container">
|
||
<button type="button" class="layui-btn layui-btn-primary layui-border-blue" lay-submit lay-filter="add_user">添加用户</button>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="layui-inline layui-form-item" id="user_list" style="display: none;float: left;width:100%;">
|
||
<label class="layui-form-label"></label>
|
||
<div class="layui-input-block" style="height:450px;overflow-y:auto;border-width: 1px;">
|
||
<div class="user_div" :id="'user_div_'+index" v-for="(item,index) in user_list" :value="item.id" :data-index="index" @mouseenter="mouseenter(index)"
|
||
@mouseleave="mouseLeave(index)">
|
||
<img class="user_img" src="/statics/images/avatar.jpg" alt="" style="width: 100%;position: relative;top:0px;left:0px;">
|
||
<img class="user_cross" :id="'user_cross_'+index" src="/statics/images/cross.png" alt="" @click="del(index)" style="width:28%; position:absolute;left:54px;top:-3px;cursor: pointer;display: none">
|
||
<p style="font-size: 5px">{{item.name}}</p>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="layui-form-item">
|
||
<div class="layui-input-block">
|
||
<div class="" >
|
||
<button class="layui-btn" lay-submit="" lay-filter="layui-form-submit">保存</button>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
|
||
</div>
|
||
</div>
|
||
<div class="layui-col-md2">
|
||
<div class="layui-input-block"></div>
|
||
</div>
|
||
<div class="layui-col-md5">
|
||
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
|
||
<div class="layui-card-body" id="user_html" style="display: none">
|
||
|
||
<div class="layui-inline layui-form-item layui-form" style="width: 100%">
|
||
<label class="layui-form-label">关键词</label>
|
||
<div class="layui-input-inline" style="width: 50%">
|
||
<input type="text" name="keywords" placeholder="搜索昵称、用户名、真实姓名、手机号" autocomplete="off" class="layui-input" value="">
|
||
</div>
|
||
<div class="layui-inline">
|
||
<button class="layui-btn layuiadmin-btn-useradmin" lay-submit lay-filter="dtable-search">搜索</button>
|
||
</div>
|
||
</div>
|
||
|
||
<table class="layui-table" lay-data="{url:'<?= \Yii::$app->urlManager->createUrl(["/admin/user-coupon/search-user"]) ?>', id:'user_list',page: true,limit: 8}" lay-filter="user_list">
|
||
<thead>
|
||
<tr>
|
||
<th lay-data="{field:'nickname'}">用户昵称</th>
|
||
<th lay-data="{field:'real_name'}">真实姓名</th>
|
||
<th lay-data="{field:'mobile_phone'}">手机号</th>
|
||
<th lay-data="{fixed: 'right',align:'center',toolbar: '#barDemo'}"></th>
|
||
</tr>
|
||
</thead>
|
||
</table>
|
||
|
||
<script type="text/html" id="barDemo">
|
||
<a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="yes">选择</a>
|
||
</script>
|
||
</div>
|
||
|
||
|
||
|
||
<script type="text/javascript">
|
||
<?php $this->beginBlock('js_script_wrap') ?>
|
||
|
||
var user_list = []
|
||
|
||
var app = new Vue({
|
||
el: '#user_list',
|
||
data: {
|
||
user_list:user_list,
|
||
seen:false
|
||
},
|
||
methods: {
|
||
//移入
|
||
mouseenter(obj) {
|
||
$('#user_cross_'+obj).show()
|
||
},
|
||
//移出
|
||
mouseLeave(obj) {
|
||
$('#user_cross_'+obj).hide()
|
||
},
|
||
del(obj){
|
||
layer.msg('删除成功', {
|
||
time: 600
|
||
})
|
||
user_list.splice(obj,1)
|
||
}
|
||
}
|
||
});
|
||
|
||
layui.config({
|
||
base: '/statics/layuiadmin/' //静态资源所在路径
|
||
}).extend({
|
||
index: 'lib/index' //主入口模块
|
||
}).use(['index', 'user', 'tree','layer','laydate','table'], function () {
|
||
var $ = layui.$
|
||
, setter = layui.setter
|
||
, tree = layui.tree
|
||
, admin = layui.admin
|
||
, router = layui.router()
|
||
, form = layui.form
|
||
, laydate = layui.laydate
|
||
, table = layui.table
|
||
, search = router.search;
|
||
|
||
|
||
form.on('radio(user_type)', function(data){
|
||
console.log(data.value)
|
||
if(data.value === '1'){
|
||
$('#user_ids').show()
|
||
$('#user_list').show()
|
||
}else{
|
||
$('#user_ids').hide()
|
||
$('#user_list').hide()
|
||
}
|
||
});
|
||
|
||
// $('.user_div').hover(function () {
|
||
// console.log('11')
|
||
// },function () {
|
||
// console.log('22')
|
||
// })
|
||
|
||
|
||
form.on('select(coupon)', function(data){
|
||
console.log(data.elem); //得到select原始DOM对象
|
||
console.log(data.value); //得到被选中的值
|
||
console.log(data.othis); //得到美化后的DOM对象
|
||
});
|
||
|
||
//监听单元格编辑
|
||
table.on('tool(user_list)', function(obj){
|
||
var data = obj.data;
|
||
if(obj.event === 'yes'){
|
||
var tmp = {}
|
||
tmp.id = data.id
|
||
if(data.real_name === ''){
|
||
tmp.name = data.nickname
|
||
}else{
|
||
tmp.name = data.real_name
|
||
}
|
||
tmp.avatar_url = data.avatar_url
|
||
user_list.push(tmp)
|
||
layer.msg('添加成功', {
|
||
time: 600
|
||
})
|
||
}
|
||
});
|
||
|
||
form.on('submit(dtable-search)', function (obj) {
|
||
var field = obj.field;
|
||
console.log(field)
|
||
reload_table_data(field);
|
||
});
|
||
|
||
//重新加载表格数据
|
||
function reload_table_data(conf){
|
||
table.reload('user_list', {
|
||
url:'<?=\Yii::$app->urlManager->createUrl(['admin/user-coupon/search-user'])?>'
|
||
,page: true
|
||
,where: conf
|
||
});
|
||
};
|
||
|
||
form.on('submit(add_user)', function (obj) {
|
||
var content = $("#user_html");
|
||
reload_table_data();
|
||
layer.open({
|
||
type: 1
|
||
,offset: 'auto'
|
||
,title: false //不显示标题栏
|
||
,closeBtn: false
|
||
,id: 'layerDemo'
|
||
,content: content
|
||
,btn: ['关闭']
|
||
,btnAlign: 'c' //按钮居中
|
||
,area: ['700px','600px'] //宽高
|
||
,shade: 0 //不显示遮罩
|
||
,moveType: 1 //拖拽模式,0或者1
|
||
,yes: function(index,layero){
|
||
//执行渲染
|
||
console.log('关闭')
|
||
layer.close(index)
|
||
},
|
||
});
|
||
|
||
|
||
})
|
||
|
||
|
||
form.render();
|
||
|
||
//提交
|
||
var submitLock = false;
|
||
form.on('submit(layui-form-submit)', function (obj) {
|
||
|
||
|
||
if (submitLock) {
|
||
return false;
|
||
}
|
||
submitLock = true;
|
||
//请求登入接口
|
||
//console.log(obj)
|
||
var url = '<?= \Yii::$app->urlManager->createUrl(["/admin/user-coupon/edit"]) ?>';
|
||
var returnUrl = "<?= $return_url ?>";
|
||
var data = obj.field;
|
||
data.user_list = user_list
|
||
data._csrf = _csrf;
|
||
console.log(data)
|
||
$.ajax(url, {
|
||
type: "POST",
|
||
dataType: "json",
|
||
data: data,
|
||
timeout: 10000,
|
||
beforeSend: function () {
|
||
i = ityzl_SHOW_LOAD_LAYER();
|
||
},
|
||
success: function (res) {
|
||
ityzl_CLOSE_LOAD_LAYER(i);
|
||
console.log(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 () {
|
||
submitLock = false;
|
||
});
|
||
}
|
||
},
|
||
error: function (xhr, type, err) {
|
||
layer.msg(xhr.responseText, {
|
||
offset: '15px'
|
||
, icon: 2
|
||
, time: 1000
|
||
}, function () {
|
||
submitLock = false;
|
||
});
|
||
},
|
||
complete: function () {
|
||
submitLock = false;
|
||
}
|
||
})
|
||
});
|
||
|
||
});
|
||
<?php $this->endBlock(); ?>
|
||
function ityzl_SHOW_LOAD_LAYER(){
|
||
return layer.msg('生成中,请勿关闭或刷新页面!请耐心等待...', {icon: 16,shade: [0.5, '#f5f5f5'],scrollbar: false,offset: '100px', time:1000000}) ;
|
||
}
|
||
function ityzl_CLOSE_LOAD_LAYER(index){
|
||
layer.close(index);
|
||
}
|
||
</script>
|
||
<?php $this->registerJs($this->blocks['js_script_wrap'], \yii\web\View::POS_END); ?>
|
||
|
||
|
||
|
||
|
||
|
||
|