2019-11-08 09:13:38 +08:00
|
|
|
<template>
|
|
|
|
<div class="role">
|
|
|
|
<div class="role__head">
|
|
|
|
<div class="role__head--title">
|
|
|
|
{{ $t(titleI18n) }}
|
|
|
|
</div>
|
|
|
|
<div class="role__head--add">
|
2020-04-16 15:52:56 +08:00
|
|
|
<el-button v-if="userId == room.creatorId" :disabled="addRoleDis" icon="el-icon-plus" circle plain @click="handleAddUser()" />
|
2019-11-08 09:13:38 +08:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="role__container">
|
|
|
|
<ul class="role__container--list">
|
|
|
|
<li v-for="(node, index) in options" :key="index">
|
|
|
|
<span>{{ node.nickName }}</span>
|
|
|
|
<i v-if="userId == room.creatorId" class="el-icon-close delete" @click="handleDelUser(node, index)" />
|
|
|
|
<div v-if="hasDevice" style="float: right; margin-right: 15px;">
|
|
|
|
<el-cascader
|
2019-11-08 18:15:52 +08:00
|
|
|
v-if="roleType == 'IBP'"
|
2019-11-08 09:13:38 +08:00
|
|
|
v-model="node.deviceCode"
|
|
|
|
size="mini"
|
|
|
|
:placeholder="$t('global.choose')"
|
2020-05-22 10:43:23 +08:00
|
|
|
:disabled="isDisable || starting"
|
2019-11-08 09:13:38 +08:00
|
|
|
:options="deviceList"
|
2019-11-08 18:15:52 +08:00
|
|
|
@change="handleUpdUser(node, index)"
|
2019-11-08 09:13:38 +08:00
|
|
|
/>
|
2019-11-08 18:15:52 +08:00
|
|
|
<el-select
|
2020-03-17 14:54:03 +08:00
|
|
|
v-if="roleType.toUpperCase() == 'ATTENDANT' || roleType.toUpperCase() === 'STATION_SUPERVISOR'"
|
2019-11-08 18:15:52 +08:00
|
|
|
v-model="node.deviceCode"
|
|
|
|
:placeholder="$t('global.choose')"
|
|
|
|
size="mini"
|
2020-05-22 10:43:23 +08:00
|
|
|
:disabled="isDisable || starting"
|
2019-11-08 18:15:52 +08:00
|
|
|
@change="handleUpdUser(node, index)"
|
|
|
|
>
|
|
|
|
<el-option
|
2020-05-19 10:24:48 +08:00
|
|
|
v-for="(item,deviceIndex) in deviceList"
|
|
|
|
:key="deviceIndex"
|
2019-11-08 18:15:52 +08:00
|
|
|
:label="item.name"
|
|
|
|
:value="item.code"
|
|
|
|
:disabled="item.disabled"
|
|
|
|
style="margin-left: 10px"
|
|
|
|
/>
|
|
|
|
</el-select>
|
2019-11-08 09:13:38 +08:00
|
|
|
</div>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
|
|
|
export default {
|
|
|
|
props: {
|
|
|
|
titleI18n: {
|
|
|
|
type: String,
|
|
|
|
required: true
|
|
|
|
},
|
|
|
|
room: {
|
|
|
|
type:Object,
|
|
|
|
required: true
|
|
|
|
},
|
|
|
|
options: {
|
|
|
|
type: Array,
|
|
|
|
required: true
|
|
|
|
},
|
|
|
|
roleType: {
|
|
|
|
type: String,
|
|
|
|
default: ''
|
|
|
|
},
|
|
|
|
deviceList: {
|
|
|
|
type: Array,
|
|
|
|
default() {
|
|
|
|
return [];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
};
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
hasDevice() {
|
2020-03-17 14:54:03 +08:00
|
|
|
return ['ATTENDANT', 'IBP', 'STATION_SUPERVISOR'].includes(this.roleType.toUpperCase());
|
2019-11-08 18:15:52 +08:00
|
|
|
},
|
|
|
|
isDisable() {
|
|
|
|
return this.userId != this.room.creatorId;
|
|
|
|
},
|
|
|
|
userId() {
|
|
|
|
return this.$store.state.user ? this.$store.state.user.id : '';
|
2020-04-16 15:52:56 +08:00
|
|
|
},
|
|
|
|
addRoleDis() {
|
|
|
|
if (this.roleType === 'CI' && this.options.length > 0) {
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
2020-05-22 10:43:23 +08:00
|
|
|
},
|
2020-06-11 09:43:02 +08:00
|
|
|
drawWay() {
|
|
|
|
return this.$route.query.drawWay + '';
|
|
|
|
},
|
2020-05-22 10:43:23 +08:00
|
|
|
starting() {
|
2020-06-11 09:43:02 +08:00
|
|
|
return this.drawWay != 'true' && this.room.state == '02';
|
2019-11-08 09:13:38 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
handleAddUser() {
|
2019-11-08 18:15:52 +08:00
|
|
|
this.$emit('addUser', { roleType: this.roleType });
|
2019-11-08 09:13:38 +08:00
|
|
|
},
|
2019-11-08 18:15:52 +08:00
|
|
|
handleUpdUser(node, index) {
|
|
|
|
this.$emit('changeUser', { roleType: this.roleType, user: node, deviceList: this.deviceList });
|
2019-11-08 09:13:38 +08:00
|
|
|
},
|
|
|
|
handleDelUser(node, index) {
|
2019-11-08 18:15:52 +08:00
|
|
|
this.$emit('delUser', { roleType: this.roleType, user: node, deviceList: this.deviceList });
|
2019-11-08 09:13:38 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped lang="scss">
|
|
|
|
ul,
|
|
|
|
li {
|
|
|
|
list-style: none;
|
|
|
|
padding: 0;
|
|
|
|
margin: 0;
|
|
|
|
}
|
|
|
|
.role {
|
|
|
|
border: 1px solid #ccc;
|
|
|
|
height: 200px;
|
|
|
|
display: flex;
|
|
|
|
flex-direction: column;
|
|
|
|
justify-content: space-between;
|
|
|
|
position: relative;
|
|
|
|
|
|
|
|
&__head {
|
|
|
|
border-bottom: 1px solid #ccc;
|
|
|
|
background: #f0f0f0;
|
|
|
|
display: flex;
|
2020-04-16 15:52:56 +08:00
|
|
|
height: 33px;
|
2019-11-08 09:13:38 +08:00
|
|
|
justify-content: space-between;
|
|
|
|
align-items: center;
|
|
|
|
padding: 3px;
|
|
|
|
&--title {
|
|
|
|
font-size: 14px;
|
|
|
|
font-weight: bold;
|
2019-11-18 17:11:40 +08:00
|
|
|
margin-left:10px;
|
2019-11-08 09:13:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
&--add {
|
2019-11-18 17:11:40 +08:00
|
|
|
margin-right:2px;
|
2019-11-08 09:13:38 +08:00
|
|
|
/deep/ .el-button.is-circle {
|
|
|
|
padding: 5px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
&__container {
|
|
|
|
flex-grow: 1;
|
|
|
|
&--list {
|
|
|
|
li {
|
|
|
|
height: 30px;
|
|
|
|
line-height: 30px;
|
|
|
|
padding-left: 10px;
|
2019-11-12 14:56:53 +08:00
|
|
|
display: flow-root;
|
2019-11-08 09:13:38 +08:00
|
|
|
|
|
|
|
&:hover {
|
|
|
|
background: #D6E0F2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.delete {
|
|
|
|
float: right;
|
|
|
|
margin-right: 10px;
|
|
|
|
margin-top: 7px;
|
|
|
|
cursor: pointer;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|