码迷,mamicode.com
首页 > 其他好文 > 详细

角色管理 模态框 传值 动态显示

时间:2017-11-29 19:58:07      阅读:183      评论:0      收藏:0      [点我收藏+]

标签:ott   transform   return   content   root   obj   名称   open   edit   

<?php
/**
* Created by PhpStorm.
* User: 信息部
* Date: 2017/10/26
* Time: 10:58
*/
use PSI\assets\VueAsset;
VueAsset::register($this);
$this->title=‘角色管理‘;
?>

<style>
.contents{
border:1px solid pink;
min-height:190px;
text-align:center;
position:relative;
padding-bottom:30px;
}
.contentMan{
padding:7px 0;
font-weight:bold;
position:relative;
}
.contentRoot{
/* border:1px solid gray; */
}
.contentMan .trash{
position:absolute;
right:10px;
color:red;
top:10px;
cursor:pointer;
}
.edit{
position:absolute;
bottom:0;
width: 100%;
height: 28px;
line-height: 28px;
background: #f3eeef;
cursor:pointer;
}
.edit a{
color:blue;
text-decoration:none;
}
/* 模态框 */
.modal-mask {
position: fixed;
z-index: 9998;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, .5);
display: table;
transition: opacity .3s ease;
}

.modal-wrapper {
display: table-cell;
vertical-align: middle;
}

.modal-container {
width: 500px;
margin: 0px auto;
padding: 20px 30px;
background-color: #fff;
border-radius: 2px;
box-shadow: 0 2px 8px rgba(0, 0, 0, .33);
transition: all .3s ease;
font-family: Helvetica, Arial, sans-serif;
border:1px dashed gold;
font-weight:bold;
}
@media screen and (max-width: 520px) {
.modal-container {
width: 100%;
margin: 0px auto;
padding: 20px 30px;
background-color: #fff;
border-radius: 2px;
box-shadow: 0 2px 8px rgba(0, 0, 0, .33);
transition: all .3s ease;
font-family: Helvetica, Arial, sans-serif;
border:1px dashed gold;
}
}
.modal-header h3 {
margin-top: 0;
color: #42b983;
font-weight:bold;
font-size:18px;
}

.modal-body {
margin: 20px 0;
}

.modal-default-button {
float: right;
}

/*
* The following styles are auto-applied to elements with
* transition="modal" when their visibility is toggled
* by Vue.js.
*
* You can easily play with the modal transition by editing
* these styles.
*/

.modal-enter {
opacity: 0;
}

.modal-leave-active {
opacity: 0;
}

.modal-enter .modal-container,
.modal-leave-active .modal-container {
-webkit-transform: scale(1.1);
transform: scale(1.1);
}
.roleFont{
color:#44449c;
padding:0 10px;
}
.labelS{
position:relative;
border:1px dashed gold;
text-align:center;
}
.errorTips{
position:relative;
padding:7px 0;
border:2px solid red;
color:red;
text-align:center;
}
.attention{
border: 1px dashed gold;
position: relative;
top: 10px;
left: 10px;
}
.attention .attentionRed{
color:gold;
}
.modal-header{
position:relative;
border:none;
padding:0;
}
.modal-footer {
padding: 0px;
text-align: right;
border:none;
}
.closeMask{
position: absolute;
top: -9px;
right: -18px;
font-size: 23px;
color: gold;
border: 1px dashed gold;
cursor:pointer;
width:25px;
height:25px;
text-align:center;
line-height:22px;
}
.deleteBtn{
padding:7px 25px;
border:1px dashed;
}
.form-control{
border:1px dashed gold;
}
.colorRED{
color:red;
font-size:22px;
position:relative;
top:7px;
}
</style>
<script type="text/x-template" id="item-template">
<div>
<div class=‘container‘>
<div class=‘row‘>
<div class=‘pull-left‘><h1>角色管理</h1></div>
<div class=‘pull-right‘>
<a href="/admin/admin-role/role-create" class="btn btn-success changetranche">添加角色</a>
</div>
</div>
<div class=‘row‘>
<div class=‘col-xs-4‘ v-for=‘item in lists‘ v-show=‘item.deleteHid‘ @mouseover=‘showContent(item)‘ @mouseout=‘hideContent(item)‘>
<div class="contents" >
<div class="contentMan">
{{item.content}}
<i class=‘fa fa-trash-o trash‘ v-show=‘item.show‘ @click="showModalTrash(item.content,item.id)" id="show-modal"></i>
</div>
<div class=‘contentRoot‘>{{item.description}}</div>
<div class="edit" v-show=‘item.show‘ ><a href="/admin/admin-role/role-create">编辑</a></div>
</div>
</div>
</div>
</div>

<!-- 模态框START -->
<div v-if="showModal">
<transition name="modal">
<div class="modal-mask">
<div class="modal-wrapper">
<div class="modal-container">

<div class="modal-header">
<span class="closeMask" @click="showModal = false">x</span>
<slot name="header">
请输入角色名称 <span class=‘roleFont‘>{{roleName}}</span>确认删除
</slot>
</div>

<div class="modal-body">
<div class="row">
<label for="roleNames" class="col-sm-3 control-label labelS"><b class="colorRED">*</b>角色名称</label>
<div class="col-sm-5 ">
<input type="text" class="form-control" v-model=‘roleNames‘ id="roleNames" placeholder="请输入角色名称">
</div>
<label for="roleNames" class="col-sm-4 control-label errorTips" v-show="errorTip">请输入正确的角色名称</label>
</div>
<div class="row">
<div class="attention col-sm-offset-3"><b class="attentionRed">注意</b>:删除角色会影响该角色下的所有账号</div>
</div>
</div>

<div class="modal-footer">
<slot name="footer">
<button class="modal-default-button deleteBtn btn btn-primary btn-lg" @click="showModalDelete">
删除
</button>
</slot>
</div>
</div>
</div>
</div>
</transition>
</div>
<!-- 模态框END -->
</div>
</script>

<div id="demo">
<item ></item>
<!-- <button >Show Modal</button> -->
<!-- use the modal component, pass in the prop -->
</div>

<script>
<?php $this->beginBlock(‘js‘) ?>
var client = axios.create({
baseURL: ‘‘,
timeout: 5000,
responseType: ‘json‘, // default
headers: {
‘Content-Type‘: ‘application/x-www-form-urlencoded;charset=UTF-8‘
},
withCredentials: false,
transformResponse: [
function(data) {
return data
}
]
});



Vue.component(‘item‘,{
template: ‘#item-template‘,
props:{
model: Object
},
data:function(){
return{
open:false,
showModal:false,
roleName:‘‘,
roleNames:‘‘,
errorTip:false,
ids:‘‘,
lists:[
{
content: ‘1 item‘,
description:‘问了客服就拉升等级分类举案说法‘,
id:1,
show: false,
deleteHid:true
},{
content: ‘2 item‘,
show: false,
deleteHid:true,
description:‘问了客服就拉升等级分类举案说法‘,
id:2
},
{
content: ‘3 item‘,
id:3,
show: false,
deleteHid:true,
description:‘问了客服就拉升等级分类举案说法‘
},
{
content: ‘4 item‘,
id:4,
show: false,
deleteHid:true,
description:‘问了客服就拉升等级分类举案说法‘
},
{
content: ‘2 item‘,
show: false,
id:3,
deleteHid:true,
description:‘问了客服就拉升等级分类举案说法‘
}
]

}
},
created:function(){
client.post(‘hello‘,{}).then(function (response) {
this.lists=response
})
.catch(function (error) {
console.log(error)
})
},
methods:{
showContent:function(item){
item.show = true
},
hideContent:function(item){
item.show=false
},
showModalTrash:function(content,ids){
this.showModal=true
this.ids=ids
this.roleName=content
},
showModalDelete:function(){
if(this.roleName==this.roleNames)
{
this.errorTip=false
this.showModal=false
for(var i=0;i<this.lists.length;i++){
if(this.roleNames==this.lists[i].content&&this.ids==this.lists[i].id){
this.lists[i].deleteHid=false
}
}
// 向后台传送要删除的数据
client.post(‘hello‘,{
roleName: this.roleName,
ID:this.ids
}).then(function (response) {
 
})
.catch(function (error) {
console.log(error)
})

// this.roleNames=‘ ‘
}else{
this.errorTip=true
}
}
}

}
)

var demo=new Vue({
el: ‘#demo‘,
data: {
 
}
})
<?php $this->endBlock() ?>
<?php $this->registerJs($this->blocks[‘js‘], \yii\web\View::POS_END); ?>
</script>

角色管理 模态框 传值 动态显示

标签:ott   transform   return   content   root   obj   名称   open   edit   

原文地址:http://www.cnblogs.com/MR-cui/p/7921898.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!