2020-12-07 14:12:37 +08:00
|
|
|
|
<style scoped>
|
|
|
|
|
|
.roles {
|
|
|
|
|
|
height: 100%;
|
|
|
|
|
|
}
|
|
|
|
|
|
</style>
|
|
|
|
|
|
<template>
|
|
|
|
|
|
<div class="roles">
|
|
|
|
|
|
<!-- 主页面 -->
|
|
|
|
|
|
<div class="main-list" >
|
|
|
|
|
|
<!-- 顶部工具栏 -->
|
|
|
|
|
|
<div class="main-modal"></div>
|
|
|
|
|
|
<div class="top-tools" >
|
|
|
|
|
|
<div class="top-tool-main-right" >
|
|
|
|
|
|
<div class="top-tool-search">
|
2020-12-08 22:14:52 +08:00
|
|
|
|
<search-input :searchMsg="searchMsg" @search="search" ref="searchInput" ></search-input>
|
2020-12-07 14:12:37 +08:00
|
|
|
|
</div>
|
2020-12-14 20:25:24 +08:00
|
|
|
|
<button :title="$t('overall.createRoles')" @click="add" class="nz-btn nz-btn-size-normal nz-btn-style-light margin-l-20" v-has="'role_toAdd'"
|
2020-12-08 22:14:52 +08:00
|
|
|
|
id="roles-add" type="button">
|
2020-12-07 14:12:37 +08:00
|
|
|
|
<i class="nz-icon-create-square nz-icon"></i>
|
|
|
|
|
|
</button>
|
2020-12-14 20:25:24 +08:00
|
|
|
|
<delete-button :delete-objs="batchDeleteObjs" :filter-function="(arr)=>{return '?ids='+arr.map(t=>t.id).join(',')}" @after="getTableData" api="sys/role" v-has="'role_delete'"></delete-button>
|
2020-12-07 14:12:37 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
<!-- 顶部分页组件,当打开底部上滑框时出现 -->
|
|
|
|
|
|
<div class="pagination-top pagination-top-hide display-none"></div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<!-- 自定义table列 -->
|
|
|
|
|
|
<transition name="el-zoom-in-top">
|
|
|
|
|
|
<element-set
|
|
|
|
|
|
:custom-table-title.sync="tools.customTableTitle"
|
|
|
|
|
|
:original-table-title="tableTitle"
|
2020-12-08 22:14:52 +08:00
|
|
|
|
@close="tools.showCustomTableTitle = false"
|
2020-12-07 14:12:37 +08:00
|
|
|
|
ref="customTableTitle"
|
2020-12-08 22:14:52 +08:00
|
|
|
|
v-if="tools.showCustomTableTitle"
|
2020-12-07 14:12:37 +08:00
|
|
|
|
></element-set>
|
|
|
|
|
|
</transition>
|
|
|
|
|
|
<el-table
|
|
|
|
|
|
:data="tableData"
|
2020-12-08 22:14:52 +08:00
|
|
|
|
:height="mainTableHeight"
|
|
|
|
|
|
@selection-change="(selection)=>{this.batchDeleteObjs=selection}"
|
|
|
|
|
|
@sort-change="tableDataSort"
|
2020-12-07 14:12:37 +08:00
|
|
|
|
border
|
2020-12-08 22:14:52 +08:00
|
|
|
|
class="nz-table"
|
2020-12-07 14:12:37 +08:00
|
|
|
|
ref="rolesTable"
|
2020-12-08 22:14:52 +08:00
|
|
|
|
style="width: 100%;"
|
2020-12-07 14:12:37 +08:00
|
|
|
|
v-loading="tools.loading"
|
|
|
|
|
|
>
|
|
|
|
|
|
<el-table-column
|
|
|
|
|
|
:resizable="false"
|
2020-12-08 22:14:52 +08:00
|
|
|
|
align="center"
|
2020-12-07 14:12:37 +08:00
|
|
|
|
type="selection"
|
2020-12-08 22:14:52 +08:00
|
|
|
|
width="40">
|
2020-12-07 14:12:37 +08:00
|
|
|
|
</el-table-column>
|
|
|
|
|
|
<el-table-column
|
|
|
|
|
|
:fixed="item.fixed"
|
2020-12-08 22:14:52 +08:00
|
|
|
|
:key="`col-${index}`"
|
2020-12-07 14:12:37 +08:00
|
|
|
|
:label="item.label"
|
|
|
|
|
|
:prop="item.prop"
|
2020-12-08 22:14:52 +08:00
|
|
|
|
:resizable="true"
|
2020-12-07 14:12:37 +08:00
|
|
|
|
:sort-orders="['ascending', 'descending']"
|
2020-12-08 22:14:52 +08:00
|
|
|
|
v-for="(item, index) in tools.customTableTitle"
|
|
|
|
|
|
v-if="item.show"
|
2020-12-07 14:12:37 +08:00
|
|
|
|
>
|
2020-12-08 22:14:52 +08:00
|
|
|
|
<template slot="header" slot-scope="scope">
|
|
|
|
|
|
<span :title="item.label" class="tag-header" v-if="item.type == 'tag'"><span class="tag-value">{{item.label}}</span><span style="color:orange;"> [Notification]</span></span>
|
2020-12-07 14:12:37 +08:00
|
|
|
|
<span v-else><span>{{item.label}}</span></span>
|
|
|
|
|
|
</template>
|
2020-12-08 22:14:52 +08:00
|
|
|
|
<template :column="item" slot-scope="scope">
|
|
|
|
|
|
<div class="content-right-options" v-if="item.prop == 'option'">
|
2020-12-08 10:35:13 +08:00
|
|
|
|
<template v-if="scope.row.buildIn != 1">
|
2020-12-14 20:25:24 +08:00
|
|
|
|
<span :id="'roles-edit-'+scope.row.id" :title="$t('overall.edit')" @click="edit(scope.row)" class="content-right-option" v-has="'role_toEdit'"><i :class="{'gray-filter':scope.row.buildIn == 1}" class="nz-icon nz-icon-edit"></i></span>
|
2020-12-08 10:35:13 +08:00
|
|
|
|
|
2020-12-14 20:25:24 +08:00
|
|
|
|
<span :id="'roles-del-'+scope.row.id" :title="$t('overall.delete')" @click="del(scope.row)" class="content-right-option" v-has="'role_delete'"><i :class="{'gray-filter':scope.row.buildIn == 1}" class="nz-icon nz-icon-delete"></i></span>
|
2020-12-08 10:35:13 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
<template v-else>
|
2020-12-08 22:14:52 +08:00
|
|
|
|
<span :id="'roles-detail-'+scope.row.id" :title="$t('overall.view')" @click="detail(scope.row)" class="content-right-option"><i class="nz-icon nz-icon-view"></i></span>
|
2020-12-08 10:35:13 +08:00
|
|
|
|
</template>
|
2020-12-07 14:12:37 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
<template v-if="item.prop == 'name'">
|
|
|
|
|
|
<template v-if="scope.row.i18n">
|
|
|
|
|
|
<span>{{$t(scope.row.i18n)}}</span>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<template v-else-if="scope.row.name">
|
|
|
|
|
|
<span>{{scope.row.name}}</span>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<template v-else>
|
|
|
|
|
|
<span>-</span>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<span v-else>{{scope.row[item.prop]}}</span>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</el-table-column>
|
2020-12-08 22:14:52 +08:00
|
|
|
|
<el-table-column fixed="right" width="28">
|
|
|
|
|
|
<template :resizable="false" slot="header" slot-scope="scope">
|
2020-12-07 14:12:37 +08:00
|
|
|
|
<span @mousedown.stop="!tools.showCustomTableTitle && (tools.showCustomTableTitle = true)" class="nz-table-gear">
|
|
|
|
|
|
<i class="nz-icon nz-icon-gear"></i>
|
|
|
|
|
|
</span>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</el-table-column>
|
|
|
|
|
|
</el-table>
|
2020-12-14 20:25:24 +08:00
|
|
|
|
<button :class="{'to-top-is-hover': tools.tableHover}" :style="{top: tools.toTopBtnTop}" @click="toTop(scrollWrap)" class="to-top" v-show="tools.showTopBtn "><i class="nz-icon nz-icon-top"></i></button>
|
2020-12-07 14:12:37 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
<transition name="right-box">
|
2020-12-08 22:14:52 +08:00
|
|
|
|
<role-box :detail="rightBox.detail" :role="role" @close="closeRightBox" v-if="rightBox.show"></role-box>
|
2020-12-07 14:12:37 +08:00
|
|
|
|
</transition>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
|
|
|
import deleteButton from "../../common/deleteButton";
|
|
|
|
|
|
import roleBox from '../../common/rightBox/roleBox';
|
2020-12-14 20:25:24 +08:00
|
|
|
|
import bus from "../../../libs/bus";
|
2020-12-07 14:12:37 +08:00
|
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
|
name: "roles",
|
|
|
|
|
|
components: {
|
|
|
|
|
|
'role-box': roleBox,
|
|
|
|
|
|
'delete-button':deleteButton,
|
|
|
|
|
|
},
|
|
|
|
|
|
data() {
|
|
|
|
|
|
return {
|
|
|
|
|
|
//侧滑
|
|
|
|
|
|
rightBox: {
|
|
|
|
|
|
show: false,
|
2020-12-08 10:35:13 +08:00
|
|
|
|
detail:false
|
2020-12-07 14:12:37 +08:00
|
|
|
|
},
|
|
|
|
|
|
/*工具参数*/
|
|
|
|
|
|
tools: {
|
|
|
|
|
|
loading: false, //是否显示table加载动画
|
|
|
|
|
|
toTopBtnTop: this.$tableHeight.toTopBtnTop, //to-top按钮的top属性
|
|
|
|
|
|
tableHover: false, //控制滚动条和top按钮同时出现
|
|
|
|
|
|
showTopBtn: false, //显示To top按钮
|
|
|
|
|
|
showCustomTableTitle: false, //自定义列弹框是否显示
|
|
|
|
|
|
customTableTitle: [], //自定义列工具的数据
|
|
|
|
|
|
},
|
|
|
|
|
|
mainTableHeight: this.$tableHeight.normal, //主列表table高度
|
|
|
|
|
|
batchDeleteObjs:[],
|
|
|
|
|
|
role: {},
|
|
|
|
|
|
|
|
|
|
|
|
tableId: 'rolesTable', //需要分页的table的id,用于记录每页数量
|
|
|
|
|
|
blankRole: { //空白对象
|
|
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
pageObj: { //分页对象
|
|
|
|
|
|
pageNo: 1,
|
|
|
|
|
|
pageSize: 50,
|
|
|
|
|
|
total: 0
|
|
|
|
|
|
},
|
|
|
|
|
|
tableTitle: [ //原table列
|
|
|
|
|
|
{
|
|
|
|
|
|
label: 'ID',
|
|
|
|
|
|
prop: 'id',
|
|
|
|
|
|
show: true,
|
|
|
|
|
|
width: 80
|
|
|
|
|
|
}, {
|
|
|
|
|
|
label: this.$t("config.roles.name"),
|
|
|
|
|
|
prop: 'name',
|
|
|
|
|
|
show: true,
|
|
|
|
|
|
}, {
|
|
|
|
|
|
label: this.$t("config.roles.remark"),
|
|
|
|
|
|
prop: 'remark',
|
|
|
|
|
|
show: true,
|
|
|
|
|
|
}, {
|
|
|
|
|
|
label: this.$t('config.roles.option'),
|
|
|
|
|
|
prop: 'option',
|
|
|
|
|
|
show: true,
|
|
|
|
|
|
width: 120,
|
|
|
|
|
|
fixed: "right"
|
|
|
|
|
|
}
|
|
|
|
|
|
],
|
|
|
|
|
|
tableData: [],
|
|
|
|
|
|
searchMsg: { //给搜索框子组件传递的信息
|
|
|
|
|
|
zheze_none: true,
|
|
|
|
|
|
searchLabelList: [{
|
|
|
|
|
|
id: 10,
|
|
|
|
|
|
name: this.$t('config.roles.name'),
|
|
|
|
|
|
type: 'input',
|
|
|
|
|
|
label: this.$t('config.roles.name'),
|
|
|
|
|
|
disabled: false
|
|
|
|
|
|
}],
|
|
|
|
|
|
},
|
|
|
|
|
|
searchLabel: {}, //搜索参数
|
2020-12-14 20:25:24 +08:00
|
|
|
|
scrollWrap: null,
|
2020-12-07 14:12:37 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
methods: {
|
|
|
|
|
|
closeRightBox(refresh) {
|
|
|
|
|
|
this.rightBox.show = false;
|
|
|
|
|
|
if (refresh) {
|
|
|
|
|
|
this.getTableData();
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
edit(u) {
|
|
|
|
|
|
if(u.buildIn == 1){
|
|
|
|
|
|
return ;
|
|
|
|
|
|
}
|
|
|
|
|
|
this.role = JSON.parse(JSON.stringify(u));
|
|
|
|
|
|
this.rightBox.show = true;
|
2020-12-08 10:35:13 +08:00
|
|
|
|
this.rightBox.detail=false;
|
2020-12-07 14:12:37 +08:00
|
|
|
|
},
|
|
|
|
|
|
del(u) {
|
|
|
|
|
|
if(u.buildIn == 1){
|
|
|
|
|
|
return ;
|
|
|
|
|
|
}
|
|
|
|
|
|
this.$confirm(this.$t("tip.confirmDelete"), {
|
|
|
|
|
|
confirmButtonText: this.$t("tip.yes"),
|
|
|
|
|
|
cancelButtonText: this.$t("tip.no"),
|
|
|
|
|
|
type: 'warning'
|
|
|
|
|
|
}).then(() => {
|
|
|
|
|
|
this.$delete("sys/role?ids=" + u.id).then(response => {
|
|
|
|
|
|
if (response.code === 200) {
|
|
|
|
|
|
this.$message({duration: 2000, type: 'success', message: this.$t("tip.deleteSuccess")});
|
|
|
|
|
|
this.getTableData();
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.$message.error(response.msg);
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
});
|
|
|
|
|
|
},
|
|
|
|
|
|
getTableData() {
|
|
|
|
|
|
this.$set(this.searchLabel, "pageNo", this.pageObj.pageNo);
|
|
|
|
|
|
this.$set(this.searchLabel, "pageSize", this.pageObj.pageSize);
|
|
|
|
|
|
this.tools.loading = true;
|
|
|
|
|
|
this.$get('sys/role', this.searchLabel).then(response => {
|
|
|
|
|
|
this.tools.loading = false;
|
|
|
|
|
|
if (response.code === 200) {
|
|
|
|
|
|
this.tableData = response.data.list;
|
|
|
|
|
|
this.pageObj.total = response.data.total
|
|
|
|
|
|
this.tools.loading = false;
|
2020-12-14 20:25:24 +08:00
|
|
|
|
if (!this.scrollWrap) {
|
|
|
|
|
|
this.$nextTick(() => {
|
|
|
|
|
|
this.scrollWrap = this.$refs.rolesTable.bodyWrapper;
|
|
|
|
|
|
this.toTopBtnHandler(this.scrollWrap);
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
2020-12-07 14:12:37 +08:00
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
add() {
|
|
|
|
|
|
this.role = this.newRole();
|
|
|
|
|
|
this.rightBox.show = true;
|
2020-12-08 10:35:13 +08:00
|
|
|
|
this.rightBox.detail=false;
|
2020-12-07 14:12:37 +08:00
|
|
|
|
},
|
|
|
|
|
|
esc() {
|
|
|
|
|
|
this.rightBox.show = false;
|
2020-12-08 10:35:13 +08:00
|
|
|
|
this.rightBox.detail=false;
|
|
|
|
|
|
},
|
|
|
|
|
|
detail:function(data){
|
|
|
|
|
|
this.role = JSON.parse(JSON.stringify(data))
|
|
|
|
|
|
this.rightBox.show = true;
|
|
|
|
|
|
this.rightBox.detail=true;
|
2020-12-07 14:12:37 +08:00
|
|
|
|
},
|
|
|
|
|
|
newRole() {
|
|
|
|
|
|
return JSON.parse(JSON.stringify(this.blankRole));
|
|
|
|
|
|
},
|
|
|
|
|
|
pageNo(val) {
|
|
|
|
|
|
this.pageObj.pageNo = val;
|
|
|
|
|
|
this.getTableData();
|
|
|
|
|
|
},
|
|
|
|
|
|
pageSize(val) {
|
|
|
|
|
|
this.pageObj.pageSize = val;
|
|
|
|
|
|
localStorage.setItem('nz-pageSize-' + localStorage.getItem('nz-username') + '-' + this.tableId, val);
|
|
|
|
|
|
this.getTableData();
|
|
|
|
|
|
},
|
|
|
|
|
|
search(searchObj) {
|
|
|
|
|
|
this.searchLabel = {};
|
|
|
|
|
|
this.pageObj.pageNo = 1;
|
|
|
|
|
|
for (let item in searchObj) {
|
|
|
|
|
|
if (searchObj[item]) {
|
|
|
|
|
|
this.$set(this.searchLabel, item, searchObj[item]);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if(this.$refs.rolesTable){
|
|
|
|
|
|
this.$refs.rolesTable.bodyWrapper.scrollTop = 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
this.getTableData();
|
|
|
|
|
|
},
|
|
|
|
|
|
// 数据排序
|
|
|
|
|
|
tableDataSort(item){
|
|
|
|
|
|
let orderBy = '';
|
|
|
|
|
|
if(item.order === 'ascending') {
|
|
|
|
|
|
orderBy = item.prop;
|
|
|
|
|
|
}
|
|
|
|
|
|
if(item.order === 'descending') {
|
|
|
|
|
|
orderBy = '-' + item.prop;
|
|
|
|
|
|
}
|
|
|
|
|
|
this.$set(this.searchLabel, "orderBy", orderBy);
|
|
|
|
|
|
this.getTableData();
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
created(){
|
|
|
|
|
|
//是否存在分页缓存
|
|
|
|
|
|
let pageSize = localStorage.getItem('nz-pageSize-' + localStorage.getItem('nz-username') + '-' + this.tableId);
|
|
|
|
|
|
if (pageSize != 'undefined' && pageSize != null) {
|
|
|
|
|
|
this.pageObj.pageSize = pageSize
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
2020-12-14 20:25:24 +08:00
|
|
|
|
beforeDestroy() {
|
|
|
|
|
|
this.scrollbarWrap.removeEventListener('scroll', bus.debounce);
|
|
|
|
|
|
},
|
2020-12-07 14:12:37 +08:00
|
|
|
|
mounted() {
|
|
|
|
|
|
//初始化表头
|
|
|
|
|
|
this.tools.customTableTitle = localStorage.getItem("nz-tableTitle-" + localStorage.getItem("nz-username") + "-" + this.$route.path)
|
|
|
|
|
|
? JSON.parse(localStorage.getItem("nz-tableTitle-" + localStorage.getItem("nz-username") + "-" + this.$route.path))
|
|
|
|
|
|
: this.tableTitle;
|
|
|
|
|
|
this.getTableData();
|
|
|
|
|
|
},
|
|
|
|
|
|
}
|
|
|
|
|
|
</script>
|