|
|
<template> <div class="mod-role"> <el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()"> <el-form-item> <el-input v-model="dataForm.roleName" :placeholder="$t('sys.role.roleName')" clearable></el-input> </el-form-item> <el-form-item> <el-button type="primary" @click="getDataList()">{{buttons.search || $t('sys.common.search') }}</el-button> <el-button type="primary" @click="addOrUpdateHandle()"> {{buttons.add|| $t('sys.common.add')}}</el-button> </el-form-item> </el-form> <el-table :data="dataList" border v-loading="dataListLoading" @selection-change="selectionChangeHandle" style="width: 100%;"> <el-table-column prop="roleName" header-align="center" align="center" :label="buttons.roleName||$t('sys.role.roleName')"> </el-table-column> <el-table-column prop="remark" header-align="center" align="center" :label="buttons.remark||$t('sys.role.remark')"> </el-table-column> <el-table-column prop="createTime" header-align="center" align="center" width="180" :label="buttons.createTime||$t('sys.common.createTime')"> </el-table-column> <el-table-column fixed="right" header-align="center" align="center" width="150" :label="buttons.cz||$t('sys.common.operation')"> <template slot-scope="scope"> <a type="text" size="small" @click="addOrUpdateHandle(scope.row.roleId)">{{buttons.edit||$t('sys.common.edit')}}</a> <a type="text" size="small" @click="deleteHandle(scope.row.roleId)">{{buttons.delete|| $t('sys.common.delete')}}</a>
<!-- <a type="text" size="small" @click="showAuthCustomerReportModal(scope.row)">{{buttons.reportRole || '报表赋权'}}</a>--> </template> </el-table-column> </el-table> <el-pagination @size-change="sizeChangeHandle" @current-change="currentChangeHandle" :current-page="pageIndex" :page-sizes="[20, 50, 100, 200,500]" :page-size="pageSize" :total="totalPage" layout="total, sizes, prev, pager, next, jumper"> </el-pagination> <!-- 弹窗, 新增 / 修改 --> <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update> <!--报表赋权限--> <authCustomerReport ref="authCustomerReport" :close-on-click-modal="false" :visible.sync="showAuthCustomerReportFlag" @refreshDataList="getDataList">
</authCustomerReport>
</div></template>
<script>import { searchSysLanguageParam, searchFunctionButtonList, saveButtonList,} from "@/api/sysLanguage.js" import AddOrUpdate from './role-add-or-update' import authCustomerReport from '../report/com_auth_customer_report' /**/ export default { data () { return { showAuthCustomerReportFlag: false, dataForm: { roleName: '' }, dataList: [], pageIndex: 1, pageSize: 20, totalPage: 0, dataListLoading: false, dataListSelections: [], addOrUpdateVisible: false, buttons: { cz: this.$t('sys.common.operation'), search: this.$t('sys.common.search'), add: this.$t('sys.common.add'), edit: this.$t('sys.common.edit'), delete: this.$t('sys.common.delete'), reportRole: this.$t('sys.role.reportRole'), roleName: this.$t('sys.role.roleName'), remark: this.$t('sys.role.remark'), createTime: this.$t('sys.common.createTime') }, } }, components: { AddOrUpdate, authCustomerReport,/*报表赋权限*/ }, activated () { this.getDataList() }, methods: { // 获取button的词典
getFunctionButtonList() { let queryButton = { functionId: this.$route.meta.menuId, tableId: '*', languageCode: this.$i18n.locale, objectType: 'button' } searchFunctionButtonList(queryButton).then(({data}) => { if (data.code == 0 && data.data) { this.buttons = data.data } }) }, // 获取数据列表
getDataList () { this.dataListLoading = true this.$http({ url: this.$http.adornUrl('/sys/role/list'), method: 'get', params: this.$http.adornParams({ 'page': this.pageIndex, 'limit': this.pageSize, 'roleName': this.dataForm.roleName }) }).then(({data}) => { if (data && data.code === 0) { this.dataList = data.page.list this.totalPage = data.page.totalCount } else { this.dataList = [] this.totalPage = 0 } this.dataListLoading = false }) }, // 每页数
sizeChangeHandle (val) { this.pageSize = val this.pageIndex = 1 this.getDataList() }, // 当前页
currentChangeHandle (val) { this.pageIndex = val this.getDataList() }, // 多选
selectionChangeHandle (val) { this.dataListSelections = val }, // 新增 / 修改
addOrUpdateHandle (id) { this.addOrUpdateVisible = true this.$nextTick(() => { this.$refs.addOrUpdate.init(id) }) }, // 删除
deleteHandle (id) { var ids = id ? [id] : this.dataListSelections.map(item => { return item.roleId }) this.$confirm(this.$t('sys.role.confirmDelete'), this.$t('sys.common.tip'), { confirmButtonText: this.$t('sys.common.confirm'), cancelButtonText: this.$t('sys.common.cancel'), type: 'warning' }).then(() => { this.$http({ url: this.$http.adornUrl('/sys/role/delete'), method: 'post', data: this.$http.adornData(ids, false) }).then(({data}) => { if (data && data.code === 0) { this.$message.success(this.$t('sys.common.success')) this.getDataList() } else { this.$message.error(data.msg) } }) }).catch(() => {}) },
/*给角色报表赋权限*/ showAuthCustomerReportModal(currentRow){ this.$nextTick(() => { this.showAuthCustomerReportFlag = true; this.$refs.authCustomerReport.init(currentRow); }); }, }, created() { //this.getFunctionButtonList()
} }</script>
|