| | |
| | | <template>
|
| | | <div>
|
| | | <div class="body" :style="{height:mainHeight+'px'}">
|
| | | <div class="bodyTopButtonGroup">
|
| | | <el-button v-waves type="primary" icon="el-icon-circle-plus-outline" @click="add('add')">新增</el-button>
|
| | | <el-button v-waves type="danger" icon="el-icon-error" @click="batchCancel">批量取消授权</el-button>
|
| | | <!-- <el-button v-waves type="warning" icon="el-icon-close">关闭</el-button>-->
|
| | | </div>
|
| | |
|
| | | <div class="bodyTopFormGroup">
|
| | | <el-form
|
| | | ref="form"
|
| | | :model="form"
|
| | | label-width="100px"
|
| | | inline
|
| | | style="display: flex;"
|
| | | >
|
| | | <div class="elForm">
|
| | | <el-form-item label="角色编码" style=" display: flex;">
|
| | | <el-select
|
| | | v-model="form.role_code"
|
| | | style="width:200px"
|
| | | placeholder="请选择"
|
| | | @change="roleChange"
|
| | | >
|
| | | <el-option
|
| | | v-for="item in roleArr"
|
| | | :key="item.rolecode"
|
| | | :label="item.rolename"
|
| | | :value="item.rolecode"
|
| | | />
|
| | | </el-select>
|
| | | </el-form-item>
|
| | | <el-form-item label="用户编码" style=" display: flex;">
|
| | | <el-input v-model="form.usercode" placeholder="请输入" style="width: 200px" />
|
| | | </el-form-item>
|
| | | <el-form-item label="用户名称" style=" display: flex;">
|
| | | <el-input v-model="form.username" placeholder="请输入" style="width: 200px" />
|
| | | </el-form-item>
|
| | |
|
| | | <el-form-item label="组织编码" style=" display: flex;">
|
| | | <el-cascader
|
| | | ref="cascader"
|
| | | v-model="form.storg_code"
|
| | | :options="cascaderOptions"
|
| | | filterable
|
| | | :props="defaultProps"
|
| | | :show-all-levels="false"
|
| | | />
|
| | | </el-form-item>
|
| | | <el-form-item v-show="isExpandForm" label="岗位名称" style=" display: flex;">
|
| | | <el-select
|
| | | v-model="form.post_code"
|
| | | style="width:200px"
|
| | | multiple
|
| | | collapse-tags
|
| | | placeholder="请选择"
|
| | | >
|
| | | <el-option
|
| | | v-for="item in postArr"
|
| | | :key="item.postcode"
|
| | | :label="item.postname"
|
| | | :value="item.postcode"
|
| | | />
|
| | | </el-select>
|
| | | </el-form-item>
|
| | | <el-form-item v-show="isExpandForm" label="班组编码" style=" display: flex;">
|
| | | <el-select
|
| | | v-model="form.group_code"
|
| | | style="width:200px"
|
| | | multiple
|
| | | collapse-tags
|
| | | placeholder="请选择"
|
| | | >
|
| | | <el-option
|
| | | v-for="item in groupArr"
|
| | | :key="item.usergroupcode"
|
| | | :label="item.usergroupname"
|
| | | :value="item.usergroupcode"
|
| | | />
|
| | | </el-select>
|
| | | </el-form-item>
|
| | | </div>
|
| | | <div
|
| | | class="bodySearchReset"
|
| | | :style="{marginLeft:$store.state.app.sidebar.opened? $store.state.settings.menuIsHorizontal?'15%':'3%':'10%'}"
|
| | | >
|
| | | <el-button v-waves type="primary" icon="el-icon-search" @click="getRoleAssignedUserData">查询</el-button>
|
| | | <el-button v-waves type="info" icon="el-icon-refresh" @click="reset">重置</el-button>
|
| | | </div>
|
| | | </el-form>
|
| | | <div
|
| | | class="bodyTopFormExpand"
|
| | | >
|
| | | <svg-icon
|
| | | v-show="mouseHoverType==='mouseout'"
|
| | | style="cursor: pointer"
|
| | | :icon-class="!isExpandForm?'doubleDown3':'doubleUp3'"
|
| | | @mouseenter="mouseHoverType=$event.type"
|
| | | />
|
| | | <svg-icon
|
| | | v-show="mouseHoverType==='mouseenter'"
|
| | | style="cursor: pointer"
|
| | | :icon-class="!isExpandForm?'doubleDown':'doubleUp'"
|
| | | @click="isExpandForm=!isExpandForm"
|
| | | @mouseout="mouseHoverType=$event.type"
|
| | | />
|
| | | </div>
|
| | | </div>
|
| | |
|
| | | <div class="elTableDiv">
|
| | | <el-table
|
| | | ref="tableDataRef"
|
| | | class="tableFixed"
|
| | | :data="tableData"
|
| | | :height="isExpandForm?tableHeight:(tableHeight+40)+'px'"
|
| | | border
|
| | | row-class-name="custom-row"
|
| | | :style="{width: 100+'%',height:isExpandForm?tableHeight:(tableHeight+40)+'px',}"
|
| | | highlight-current-row
|
| | | :row-key="getRowKey"
|
| | | :header-cell-style="this.$headerCellStyle"
|
| | | :cell-style="this.$cellStyle"
|
| | | @selection-change="handleSelectionChange"
|
| | | @sort-change="sortChange"
|
| | | >
|
| | | <el-table-column
|
| | | type="selection"
|
| | | width="50"
|
| | | :reserve-selection="true"
|
| | | fixed
|
| | | />
|
| | | <el-table-column
|
| | | prop="rowNum"
|
| | | width="50"
|
| | | fixed
|
| | | label="序号"
|
| | | />
|
| | | <el-table-column
|
| | | prop="usercode"
|
| | | label="用户编码"
|
| | | sortable="custom"
|
| | | />
|
| | | <el-table-column
|
| | | prop="username"
|
| | | label="用户名称"
|
| | | sortable="custom"
|
| | | />
|
| | | <el-table-column
|
| | | prop="storg_name"
|
| | | label="所属组织"
|
| | | sortable="custom"
|
| | | />
|
| | | <el-table-column
|
| | | prop="rolename"
|
| | | label="角色"
|
| | | show-overflow-tooltip
|
| | | sortable="custom"
|
| | | >
|
| | | <template slot-scope="{row}">
|
| | | {{ row.rolename ? row.rolename : '/' }}
|
| | | </template>
|
| | | </el-table-column>
|
| | | <el-table-column
|
| | | prop="postname"
|
| | | label="岗位"
|
| | | sortable="custom"
|
| | | show-overflow-tooltip
|
| | | >
|
| | | <template slot-scope="{row}">
|
| | | {{ row.postname ? row.postname : '/' }}
|
| | | </template>
|
| | | </el-table-column>
|
| | | <el-table-column
|
| | | prop="group_name"
|
| | | label="班组"
|
| | | show-overflow-tooltip
|
| | | sortable="custom"
|
| | | >
|
| | | <template slot-scope="{row}">
|
| | | {{ row.group_name ? row.group_name : '/' }}
|
| | | </template>
|
| | | </el-table-column>
|
| | |
|
| | | <el-table-column
|
| | | label="操作"
|
| | | width="200"
|
| | | fixed="right"
|
| | | >
|
| | | <template slot-scope="{row}">
|
| | | <div class="operationClass">
|
| | | <el-button
|
| | | type="text"
|
| | | style="cursor: pointer;font-size: 14px"
|
| | | @click="cancel(row.usercode)"
|
| | | >取消授权
|
| | | </el-button>
|
| | |
|
| | | </div>
|
| | | </template>
|
| | | </el-table-column>
|
| | | </el-table>
|
| | | </div>
|
| | | <!--分页-->
|
| | | <pagination
|
| | | :total="total"
|
| | | :page.sync="form.page"
|
| | | :limit.sync="form.rows"
|
| | | align="right"
|
| | | layout="total,prev, pager, next,sizes,jumper"
|
| | | popper-class="select_bottom"
|
| | | @pagination="getRoleAssignedUserData"
|
| | | />
|
| | | </div>
|
| | |
|
| | | <el-dialog
|
| | | v-el-drag-dialog
|
| | | title="新增"
|
| | | :visible.sync="dialogVisible"
|
| | | width="1200px"
|
| | | :close-on-click-modal="false"
|
| | | top="15vh"
|
| | | @closed="handleClose"
|
| | | @close="handleClose"
|
| | | >
|
| | | <div>
|
| | | <el-table
|
| | | ref="tableDataDialogRef"
|
| | | class="tableFixed"
|
| | | :data="tableDataDialog"
|
| | | row-class-name="custom-row"
|
| | |
|
| | | height="400"
|
| | | border
|
| | | :style="{width: 100+'%',height:'400px',}"
|
| | | highlight-current-row
|
| | | :row-key="getRowKey"
|
| | | :header-cell-style="this.$headerCellStyle"
|
| | | :cell-style="this.$cellStyle"
|
| | | @selection-change="handleDialogSelectionChange"
|
| | | >
|
| | | <el-table-column
|
| | | type="selection"
|
| | | width="50"
|
| | | :reserve-selection="true"
|
| | | fixed
|
| | | />
|
| | | <el-table-column
|
| | | prop="rowNum"
|
| | | width="50"
|
| | | fixed
|
| | | label="序号"
|
| | | />
|
| | | <el-table-column
|
| | | prop="usercode"
|
| | | label="用户编码"
|
| | | />
|
| | | <el-table-column
|
| | | prop="username"
|
| | | label="用户名称"
|
| | | />
|
| | | <el-table-column
|
| | | prop="storg_name"
|
| | | label="所属组织"
|
| | | />
|
| | | <el-table-column
|
| | | prop="rolename"
|
| | | show-overflow-tooltip
|
| | | label="角色"
|
| | | >
|
| | | <template slot-scope="{row}">
|
| | | {{ row.rolename?row.rolename:'/' }}
|
| | | </template>
|
| | | </el-table-column>
|
| | | <el-table-column
|
| | | prop="postname"
|
| | | label="岗位"
|
| | | show-overflow-tooltip
|
| | | >
|
| | | <template slot-scope="{row}">
|
| | | {{ row.postname?row.postname:'/' }}
|
| | | </template>
|
| | | </el-table-column>
|
| | | <el-table-column
|
| | | prop="group_name"
|
| | | show-overflow-tooltip
|
| | | label="班组"
|
| | | >
|
| | | <template slot-scope="{row}">
|
| | | {{ row.group_name?row.group_name:'/' }}
|
| | | </template>
|
| | | </el-table-column>
|
| | | </el-table>
|
| | | <!--分页-->
|
| | | <pagination
|
| | | :total="totalDialog"
|
| | | :page.sync="dialogForm.page"
|
| | | :limit.sync="dialogForm.rows"
|
| | | align="right"
|
| | | style="margin-top: 10px;"
|
| | | layout="total,prev, pager, next,sizes,jumper"
|
| | | popper-class="select_bottom"
|
| | | @pagination="add"
|
| | | />
|
| | | </div>
|
| | | <span slot="footer" class="dialog-footer">
|
| | | <div class="footerButton">
|
| | | <el-button
|
| | | v-waves
|
| | | @click="dialogVisibleCancel"
|
| | | >取 消</el-button>
|
| | | <el-button
|
| | | v-waves
|
| | | type="primary"
|
| | | :loading="$store.state.app.buttonIsDisabled"
|
| | | :disabled="$store.state.app.buttonIsDisabled"
|
| | | @click="dialogVisibleConfirm"
|
| | | >确 定</el-button>
|
| | | </div>
|
| | | </span>
|
| | | </el-dialog>
|
| | |
|
| | | </div>
|
| | | </template>
|
| | |
|
| | | <script>
|
| | | import Pagination from '@/components/Pagination'
|
| | | import {
|
| | | RoleAssignedUserBatchAdd,
|
| | | RoleAssignedUserBatchCancel,
|
| | | RoleAssignedUserData
|
| | | } from '@/api/basicSettings'
|
| | | import elDragDialog from '@/directive/el-drag-dialog'
|
| | | import waves from '@/directive/waves'
|
| | | import arrayToTree from 'array-to-tree'
|
| | | import { GroupsPermissions, PostPermissions, PrentOrganization, RolePermissions } from '@/api/GeneralBasicData'
|
| | |
|
| | | export default {
|
| | | name: 'RoleDivider',
|
| | | components: {
|
| | | Pagination
|
| | | },
|
| | | directives: { elDragDialog, waves },
|
| | | data() {
|
| | | return {
|
| | | mouseHoverType: 'mouseout',
|
| | | isExpandForm: false,
|
| | | mainHeight: 0,
|
| | | tableHeight: 0,
|
| | | form: {
|
| | | flag: 'TRUE', // TRUE(已关联) FALSE(未关联)
|
| | | role_code: '', // 角色编码
|
| | | usercode: '', // 用户编码
|
| | | username: '', // 用户名称
|
| | | storg_code: [], //
|
| | | post_code: [], //
|
| | | group_code: [], //
|
| | | prop: 'lm_date', // 排序字段
|
| | | order: 'desc', // 排序字段
|
| | | page: 1, // 第几页
|
| | | rows: 20 // 每页多少条
|
| | | },
|
| | | total: 10,
|
| | | tableData: [],
|
| | |
|
| | | cascaderOptions: [],
|
| | | defaultProps: {
|
| | | checkStrictly: true,
|
| | | expandTrigger: 'hover',
|
| | | value: 'torg_code',
|
| | | label: 'torg_name'
|
| | | },
|
| | | roleArr: [],
|
| | | postArr: [],
|
| | | groupArr: [],
|
| | |
|
| | | dialogVisible: false,
|
| | | dialogForm: {
|
| | | page: 1, // 第几页
|
| | | rows: 20 // 每页多少条
|
| | | },
|
| | | tableDataDialog: [],
|
| | | totalDialog: 10,
|
| | |
|
| | | batchRoleCode: [],
|
| | | batchDialogRoleCode: []
|
| | |
|
| | | }
|
| | | },
|
| | | activated() {
window.addEventListener('resize', this.getHeight)
this.getHeight()
},
created() {
|
| | | },
|
| | | mounted() {
|
| | | window.addEventListener('resize', this.getHeight)
|
| | | this.getHeight()
|
| | |
|
| | | this.getAllSelectData()
|
| | | this.getPrentOrganization()
|
| | | },
|
| | | methods: {
|
| | | // 组织架构大列表查询
|
| | | async getRoleAssignedUserData() {
|
| | | if (window.location.hash.indexOf('?') !== -1) {
|
| | | this.form.role_code = window.location.hash.split('?')[1].split('=')[1]
|
| | | }
|
| | |
|
| | | if (!this.form.role_code) {
|
| | | this.form.role_code = this.roleArr[0].rolecode
|
| | | }
|
| | |
|
| | | this.form.storg_code = this.form.storg_code ? this.form.storg_code[this.form.storg_code.length - 1] : ''
|
| | | this.form.post_code = this.form.post_code ? this.form.post_code.join(',') : ''
|
| | | this.form.group_code = this.form.group_code ? this.form.group_code.join(',') : ''
|
| | |
|
| | | const res = await RoleAssignedUserData(this.form)
|
| | | this.tableData = res.data
|
| | | this.total = res.count
|
| | | },
|
| | | async getPrentOrganization() {
|
| | | const { data: res } = await PrentOrganization()
|
| | | this.cascaderOptions = arrayToTree(res, {
|
| | | parentProperty: 'parent_id',
|
| | | customID: 'torg_code',
|
| | | childrenProperty: 'children'
|
| | | })
|
| | | },
|
| | | // 岗位 角色 班组
|
| | | async getAllSelectData() {
|
| | | const { data: res2 } = await RolePermissions()
|
| | | this.roleArr = res2
|
| | | await this.getRoleAssignedUserData()
|
| | |
|
| | | const { data: res1 } = await PostPermissions()
|
| | | this.postArr = res1
|
| | |
|
| | | const { data: res3 } = await GroupsPermissions()
|
| | | this.groupArr = res3
|
| | | },
|
| | | // 排序改变时
|
| | | sortChange({ column, prop, order }) {
|
| | | if (order === 'descending') {
|
| | | order = 'desc'
|
| | | } else if (order === 'ascending') {
|
| | | order = 'asc'
|
| | | } else {
|
| | | order = 'desc'
|
| | | }
|
| | | this.form.order = order
|
| | | this.form.prop = prop
|
| | | this.getRoleAssignedUserData()
|
| | | },
|
| | | // 重置
|
| | | reset() {
|
| | | this.form.usercode = ''
|
| | | this.form.username = ''
|
| | |
|
| | | this.form.storg_code = []
|
| | | this.form.post_code = []
|
| | | this.form.group_code = []
|
| | | this.getRoleAssignedUserData()
|
| | | },
|
| | | roleChange(val) {
|
| | | this.getRoleAssignedUserData()
|
| | | this.batchRoleCode = []
|
| | | this.$refs.tableDataRef.clearSelection()
|
| | | },
|
| | |
|
| | | async cancel(code) {
|
| | | // if (!this.form.role_code) {
|
| | | // return this.$message.error('')
|
| | | // }
|
| | |
|
| | | const res = await RoleAssignedUserBatchCancel([code], this.form.role_code)
|
| | | if (res.code === '200') {
|
| | | this.$notify.success('取消授权成功!')
|
| | | await this.getRoleAssignedUserData()
|
| | | } else {
|
| | | this.$notify.error('取消授权失败!')
|
| | | }
|
| | | },
|
| | |
|
| | | async batchCancel() {
|
| | | const res = await RoleAssignedUserBatchCancel(this.batchRoleCode, this.form.role_code)
|
| | | if (res.code === '200') {
|
| | | this.$notify.success(this.batchRoleCode.length + '个用户取消授权成功!')
|
| | | await this.getRoleAssignedUserData()
|
| | | this.batchRoleCode = []
|
| | | this.$refs.tableDataRef.clearSelection()
|
| | | } else {
|
| | | this.$notify.error(this.batchRoleCode.length + '个用户取消授权失败!')
|
| | | }
|
| | | },
|
| | |
|
| | | // 新增按钮
|
| | | async add() {
|
| | | this.dialogVisible = true
|
| | |
|
| | | const data = {
|
| | | flag: 'FALSE', // TRUE(已关联) FALSE(未关联)
|
| | | role_code: this.form.role_code, // 角色编码
|
| | | usercode: '', // 用户编码
|
| | | username: '', // 用户名称
|
| | | storg_code: '', //
|
| | | post_code: '', //
|
| | | group_code: '', //
|
| | | prop: 'lm_date', // 排序字段
|
| | | order: 'desc', // 排序字段
|
| | | page: this.dialogForm.page, // 第几页
|
| | | rows: this.dialogForm.rows // 每页多少条
|
| | | }
|
| | | const res = await RoleAssignedUserData(data)
|
| | | this.tableDataDialog = res.data
|
| | | this.totalDialog = res.count
|
| | | },
|
| | |
|
| | | // 对话框关闭事件
|
| | | handleClose() {
|
| | | // this.form.flag = 'TRUE'
|
| | | },
|
| | | getRowKey(row) {
|
| | | return row.usercode
|
| | | },
|
| | | handleSelectionChange(rows) {
|
| | | this.batchRoleCode = rows.map(i => i.usercode)
|
| | | },
|
| | | handleDialogSelectionChange(rows) {
|
| | | this.batchDialogRoleCode = rows.map(i => i.usercode)
|
| | | },
|
| | | // 对话框取消
|
| | | dialogVisibleCancel() {
|
| | | this.dialogVisible = false
|
| | | },
|
| | | // 对话框确认
|
| | | async dialogVisibleConfirm() {
|
| | | const res = await RoleAssignedUserBatchAdd(this.batchDialogRoleCode, this.form.role_code)
|
| | | if (res.code === '200') {
|
| | | this.$notify.success(this.batchDialogRoleCode.length + '个用户新增授权成功!')
|
| | | await this.getRoleAssignedUserData()
|
| | | this.batchDialogRoleCode = []
|
| | | this.$refs.tableDataDialogRef.clearSelection()
|
| | | this.dialogVisible = false
|
| | | } else {
|
| | | this.$notify.error(this.batchDialogRoleCode.length + '个用户新增授权失败!')
|
| | | }
|
| | | },
|
| | | // 获取页面高度
|
| | | getHeight() {
|
| | | this.$nextTick(() => {
|
| | | this.mainHeight = window.innerHeight - 85
|
| | | this.tableHeight = this.mainHeight - 255
|
| | | this.$refs.tableDataRef.doLayout()
|
| | | })
|
| | | }
|
| | | }
|
| | | }
|
| | | </script>
|
| | | <template> |
| | | <div> |
| | | <div class="body" :style="{height:mainHeight+'px'}"> |
| | | <div class="bodyTopButtonGroup"> |
| | | <el-button v-waves type="primary" icon="el-icon-circle-plus-outline" @click="add('add')">新增</el-button> |
| | | <el-button v-waves type="danger" icon="el-icon-error" @click="batchCancel">批量取消授权</el-button> |
| | | <!-- <el-button v-waves type="warning" icon="el-icon-close">关闭</el-button>--> |
| | | </div> |
| | | |
| | | <div class="bodyTopFormGroup"> |
| | | <el-form |
| | | ref="form" |
| | | :model="form" |
| | | label-width="100px" |
| | | inline |
| | | style="display: flex;" |
| | | > |
| | | <div class="elForm"> |
| | | <el-form-item label="角色编码" style=" display: flex;"> |
| | | <el-select |
| | | v-model="form.role_code" |
| | | style="width:200px" |
| | | placeholder="请选择" |
| | | @change="roleChange" |
| | | > |
| | | <el-option |
| | | v-for="item in roleArr" |
| | | :key="item.rolecode" |
| | | :label="item.rolename" |
| | | :value="item.rolecode" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="用户编码" style=" display: flex;"> |
| | | <el-input v-model="form.usercode" placeholder="请输入" style="width: 200px" /> |
| | | </el-form-item> |
| | | <el-form-item label="用户名称" style=" display: flex;"> |
| | | <el-input v-model="form.username" placeholder="请输入" style="width: 200px" /> |
| | | </el-form-item> |
| | | |
| | | <el-form-item label="组织编码" style=" display: flex;"> |
| | | <el-cascader |
| | | ref="cascader" |
| | | v-model="form.storg_code" |
| | | :options="cascaderOptions" |
| | | filterable |
| | | :props="defaultProps" |
| | | :show-all-levels="false" |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item v-show="isExpandForm" label="岗位名称" style=" display: flex;"> |
| | | <el-select |
| | | v-model="form.post_code" |
| | | style="width:200px" |
| | | multiple |
| | | collapse-tags |
| | | placeholder="请选择" |
| | | > |
| | | <el-option |
| | | v-for="item in postArr" |
| | | :key="item.postcode" |
| | | :label="item.postname" |
| | | :value="item.postcode" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item v-show="isExpandForm" label="班组编码" style=" display: flex;"> |
| | | <el-select |
| | | v-model="form.group_code" |
| | | style="width:200px" |
| | | multiple |
| | | collapse-tags |
| | | placeholder="请选择" |
| | | > |
| | | <el-option |
| | | v-for="item in groupArr" |
| | | :key="item.usergroupcode" |
| | | :label="item.usergroupname" |
| | | :value="item.usergroupcode" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | </div> |
| | | <div |
| | | class="bodySearchReset" |
| | | :style="{marginLeft:$store.state.app.sidebar.opened? $store.state.settings.menuIsHorizontal?'15%':'3%':'10%'}" |
| | | > |
| | | <el-button v-waves type="primary" icon="el-icon-search" @click="getRoleAssignedUserData">查询</el-button> |
| | | <el-button v-waves type="info" icon="el-icon-refresh" @click="reset">重置</el-button> |
| | | </div> |
| | | </el-form> |
| | | <div |
| | | class="bodyTopFormExpand" |
| | | > |
| | | <svg-icon |
| | | v-show="mouseHoverType==='mouseout'" |
| | | style="cursor: pointer" |
| | | :icon-class="!isExpandForm?'doubleDown3':'doubleUp3'" |
| | | @mouseenter="mouseHoverType=$event.type" |
| | | /> |
| | | <svg-icon |
| | | v-show="mouseHoverType==='mouseenter'" |
| | | style="cursor: pointer" |
| | | :icon-class="!isExpandForm?'doubleDown':'doubleUp'" |
| | | @click="isExpandForm=!isExpandForm" |
| | | @mouseout="mouseHoverType=$event.type" |
| | | /> |
| | | </div> |
| | | </div> |
| | | |
| | | <div class="elTableDiv"> |
| | | <el-table |
| | | ref="tableDataRef" |
| | | class="tableFixed" |
| | | :data="tableData" |
| | | :height="isExpandForm?tableHeight:(tableHeight+40)+'px'" |
| | | border |
| | | row-class-name="custom-row" |
| | | :style="{width: 100+'%',height:isExpandForm?tableHeight:(tableHeight+40)+'px',}" |
| | | highlight-current-row |
| | | :row-key="getRowKey" |
| | | :header-cell-style="this.$headerCellStyle" |
| | | :cell-style="this.$cellStyle" |
| | | @selection-change="handleSelectionChange" |
| | | @sort-change="sortChange" |
| | | > |
| | | <el-table-column |
| | | type="selection" |
| | | width="50" |
| | | :reserve-selection="true" |
| | | fixed |
| | | /> |
| | | <el-table-column |
| | | prop="rowNum" |
| | | width="50" |
| | | fixed |
| | | label="序号" |
| | | /> |
| | | <el-table-column |
| | | prop="usercode" |
| | | label="用户编码" |
| | | sortable="custom" |
| | | /> |
| | | <el-table-column |
| | | prop="username" |
| | | label="用户名称" |
| | | sortable="custom" |
| | | /> |
| | | <el-table-column |
| | | prop="storg_name" |
| | | label="所属组织" |
| | | sortable="custom" |
| | | /> |
| | | <el-table-column |
| | | prop="rolename" |
| | | label="角色" |
| | | show-overflow-tooltip |
| | | sortable="custom" |
| | | > |
| | | <template slot-scope="{row}"> |
| | | {{ row.rolename ? row.rolename : '/' }} |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column |
| | | prop="postname" |
| | | label="岗位" |
| | | sortable="custom" |
| | | show-overflow-tooltip |
| | | > |
| | | <template slot-scope="{row}"> |
| | | {{ row.postname ? row.postname : '/' }} |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column |
| | | prop="group_name" |
| | | label="班组" |
| | | show-overflow-tooltip |
| | | sortable="custom" |
| | | > |
| | | <template slot-scope="{row}"> |
| | | {{ row.group_name ? row.group_name : '/' }} |
| | | </template> |
| | | </el-table-column> |
| | | |
| | | <el-table-column |
| | | label="操作" |
| | | width="200" |
| | | fixed="right" |
| | | > |
| | | <template slot-scope="{row}"> |
| | | <div class="operationClass"> |
| | | <el-button |
| | | type="text" |
| | | style="cursor: pointer;font-size: 14px" |
| | | @click="cancel(row.usercode)" |
| | | >取消授权 |
| | | </el-button> |
| | | |
| | | </div> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | </div> |
| | | <!--分页--> |
| | | <pagination |
| | | :total="total" |
| | | :page.sync="form.page" |
| | | :limit.sync="form.rows" |
| | | align="right" |
| | | layout="total,prev, pager, next,sizes,jumper" |
| | | popper-class="select_bottom" |
| | | @pagination="getRoleAssignedUserData" |
| | | /> |
| | | </div> |
| | | |
| | | <el-dialog |
| | | v-el-drag-dialog |
| | | title="新增" |
| | | :visible.sync="dialogVisible" |
| | | width="1200px" |
| | | :close-on-click-modal="false" |
| | | top="15vh" |
| | | @closed="handleClose" |
| | | @close="handleClose" |
| | | > |
| | | <div> |
| | | <el-table |
| | | ref="tableDataDialogRef" |
| | | class="tableFixed" |
| | | :data="tableDataDialog" |
| | | row-class-name="custom-row" |
| | | |
| | | height="400" |
| | | border |
| | | :style="{width: 100+'%',height:'400px',}" |
| | | highlight-current-row |
| | | :row-key="getRowKey" |
| | | :header-cell-style="this.$headerCellStyle" |
| | | :cell-style="this.$cellStyle" |
| | | @selection-change="handleDialogSelectionChange" |
| | | > |
| | | <el-table-column |
| | | type="selection" |
| | | width="50" |
| | | :reserve-selection="true" |
| | | fixed |
| | | /> |
| | | <el-table-column |
| | | prop="rowNum" |
| | | width="50" |
| | | fixed |
| | | label="序号" |
| | | /> |
| | | <el-table-column |
| | | prop="usercode" |
| | | label="用户编码" |
| | | /> |
| | | <el-table-column |
| | | prop="username" |
| | | label="用户名称" |
| | | /> |
| | | <el-table-column |
| | | prop="storg_name" |
| | | label="所属组织" |
| | | /> |
| | | <el-table-column |
| | | prop="rolename" |
| | | show-overflow-tooltip |
| | | label="角色" |
| | | > |
| | | <template slot-scope="{row}"> |
| | | {{ row.rolename?row.rolename:'/' }} |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column |
| | | prop="postname" |
| | | label="岗位" |
| | | show-overflow-tooltip |
| | | > |
| | | <template slot-scope="{row}"> |
| | | {{ row.postname?row.postname:'/' }} |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column |
| | | prop="group_name" |
| | | show-overflow-tooltip |
| | | label="班组" |
| | | > |
| | | <template slot-scope="{row}"> |
| | | {{ row.group_name?row.group_name:'/' }} |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | <!--分页--> |
| | | <pagination |
| | | :total="totalDialog" |
| | | :page.sync="dialogForm.page" |
| | | :limit.sync="dialogForm.rows" |
| | | align="right" |
| | | style="margin-top: 10px;" |
| | | layout="total,prev, pager, next,sizes,jumper" |
| | | popper-class="select_bottom" |
| | | @pagination="add" |
| | | /> |
| | | </div> |
| | | <span slot="footer" class="dialog-footer"> |
| | | <div class="footerButton"> |
| | | <el-button |
| | | v-waves |
| | | @click="dialogVisibleCancel" |
| | | >取 消</el-button> |
| | | <el-button |
| | | v-waves |
| | | type="primary" |
| | | :loading="$store.state.app.buttonIsDisabled" |
| | | :disabled="$store.state.app.buttonIsDisabled" |
| | | @click="dialogVisibleConfirm" |
| | | >确 定</el-button> |
| | | </div> |
| | | </span> |
| | | </el-dialog> |
| | | |
| | | </div> |
| | | </template> |
| | | |
| | | <script> |
| | | import Pagination from '@/components/Pagination' |
| | | import { |
| | | RoleAssignedUserBatchAdd, |
| | | RoleAssignedUserBatchCancel, |
| | | RoleAssignedUserData |
| | | } from '@/api/basicSettings' |
| | | import elDragDialog from '@/directive/el-drag-dialog' |
| | | import waves from '@/directive/waves' |
| | | import arrayToTree from 'array-to-tree' |
| | | import { GroupsPermissions, PostPermissions, PrentOrganization, RolePermissions } from '@/api/GeneralBasicData' |
| | | |
| | | export default { |
| | | name: 'RoleDivider', |
| | | components: { |
| | | Pagination |
| | | }, |
| | | directives: { elDragDialog, waves }, |
| | | data() { |
| | | return { |
| | | mouseHoverType: 'mouseout', |
| | | isExpandForm: false, |
| | | mainHeight: 0, |
| | | tableHeight: 0, |
| | | form: { |
| | | flag: 'TRUE', // TRUE(已关联) FALSE(未关联) |
| | | role_code: '', // 角色编码 |
| | | usercode: '', // 用户编码 |
| | | username: '', // 用户名称 |
| | | storg_code: [], // |
| | | post_code: [], // |
| | | group_code: [], // |
| | | prop: 'lm_date', // 排序字段 |
| | | order: 'desc', // 排序字段 |
| | | page: 1, // 第几页 |
| | | rows: 20 // 每页多少条 |
| | | }, |
| | | total: 10, |
| | | tableData: [], |
| | | |
| | | cascaderOptions: [], |
| | | defaultProps: { |
| | | checkStrictly: true, |
| | | expandTrigger: 'hover', |
| | | value: 'torg_code', |
| | | label: 'torg_name' |
| | | }, |
| | | roleArr: [], |
| | | postArr: [], |
| | | groupArr: [], |
| | | |
| | | dialogVisible: false, |
| | | dialogForm: { |
| | | page: 1, // 第几页 |
| | | rows: 20 // 每页多少条 |
| | | }, |
| | | tableDataDialog: [], |
| | | totalDialog: 10, |
| | | |
| | | batchRoleCode: [], |
| | | batchDialogRoleCode: [] |
| | | |
| | | } |
| | | }, |
| | | activated() { |
| | | window.addEventListener('resize', this.getHeight) |
| | | this.getHeight() |
| | | this.getAllSelectData() |
| | | this.getPrentOrganization() |
| | | }, |
| | | created() { |
| | | }, |
| | | mounted() { |
| | | window.addEventListener('resize', this.getHeight) |
| | | this.getHeight() |
| | | |
| | | this.getAllSelectData() |
| | | this.getPrentOrganization() |
| | | }, |
| | | methods: { |
| | | // 组织架构大列表查询 |
| | | async getRoleAssignedUserData() { |
| | | if (window.location.hash.indexOf('?') !== -1) { |
| | | this.form.role_code = window.location.hash.split('?')[1].split('=')[1] |
| | | } |
| | | |
| | | if (!this.form.role_code) { |
| | | this.form.role_code = this.roleArr[0].rolecode |
| | | } |
| | | |
| | | this.form.storg_code = this.form.storg_code ? this.form.storg_code[this.form.storg_code.length - 1] : '' |
| | | this.form.post_code = this.form.post_code ? this.form.post_code.join(',') : '' |
| | | this.form.group_code = this.form.group_code ? this.form.group_code.join(',') : '' |
| | | |
| | | const res = await RoleAssignedUserData(this.form) |
| | | this.tableData = res.data |
| | | this.total = res.count |
| | | }, |
| | | async getPrentOrganization() { |
| | | const { data: res } = await PrentOrganization() |
| | | this.cascaderOptions = arrayToTree(res, { |
| | | parentProperty: 'parent_id', |
| | | customID: 'torg_code', |
| | | childrenProperty: 'children' |
| | | }) |
| | | }, |
| | | // 岗位 角色 班组 |
| | | async getAllSelectData() { |
| | | const { data: res2 } = await RolePermissions() |
| | | this.roleArr = res2 |
| | | await this.getRoleAssignedUserData() |
| | | |
| | | const { data: res1 } = await PostPermissions() |
| | | this.postArr = res1 |
| | | |
| | | const { data: res3 } = await GroupsPermissions() |
| | | this.groupArr = res3 |
| | | }, |
| | | // 排序改变时 |
| | | sortChange({ column, prop, order }) { |
| | | if (order === 'descending') { |
| | | order = 'desc' |
| | | } else if (order === 'ascending') { |
| | | order = 'asc' |
| | | } else { |
| | | order = 'desc' |
| | | } |
| | | this.form.order = order |
| | | this.form.prop = prop |
| | | this.getRoleAssignedUserData() |
| | | }, |
| | | // 重置 |
| | | reset() { |
| | | this.form.usercode = '' |
| | | this.form.username = '' |
| | | |
| | | this.form.storg_code = [] |
| | | this.form.post_code = [] |
| | | this.form.group_code = [] |
| | | this.getRoleAssignedUserData() |
| | | }, |
| | | roleChange(val) { |
| | | this.getRoleAssignedUserData() |
| | | this.batchRoleCode = [] |
| | | this.$refs.tableDataRef.clearSelection() |
| | | }, |
| | | |
| | | async cancel(code) { |
| | | // if (!this.form.role_code) { |
| | | // return this.$message.error('') |
| | | // } |
| | | |
| | | const res = await RoleAssignedUserBatchCancel([code], this.form.role_code) |
| | | if (res.code === '200') { |
| | | this.$notify.success('取消授权成功!') |
| | | await this.getRoleAssignedUserData() |
| | | } else { |
| | | this.$notify.error('取消授权失败!') |
| | | } |
| | | }, |
| | | |
| | | async batchCancel() { |
| | | const res = await RoleAssignedUserBatchCancel(this.batchRoleCode, this.form.role_code) |
| | | if (res.code === '200') { |
| | | this.$notify.success(this.batchRoleCode.length + '个用户取消授权成功!') |
| | | await this.getRoleAssignedUserData() |
| | | this.batchRoleCode = [] |
| | | this.$refs.tableDataRef.clearSelection() |
| | | } else { |
| | | this.$notify.error(this.batchRoleCode.length + '个用户取消授权失败!') |
| | | } |
| | | }, |
| | | |
| | | // 新增按钮 |
| | | async add() { |
| | | this.dialogVisible = true |
| | | |
| | | const data = { |
| | | flag: 'FALSE', // TRUE(已关联) FALSE(未关联) |
| | | role_code: this.form.role_code, // 角色编码 |
| | | usercode: '', // 用户编码 |
| | | username: '', // 用户名称 |
| | | storg_code: '', // |
| | | post_code: '', // |
| | | group_code: '', // |
| | | prop: 'lm_date', // 排序字段 |
| | | order: 'desc', // 排序字段 |
| | | page: this.dialogForm.page, // 第几页 |
| | | rows: this.dialogForm.rows // 每页多少条 |
| | | } |
| | | const res = await RoleAssignedUserData(data) |
| | | this.tableDataDialog = res.data |
| | | this.totalDialog = res.count |
| | | }, |
| | | |
| | | // 对话框关闭事件 |
| | | handleClose() { |
| | | // this.form.flag = 'TRUE' |
| | | }, |
| | | getRowKey(row) { |
| | | return row.usercode |
| | | }, |
| | | handleSelectionChange(rows) { |
| | | this.batchRoleCode = rows.map(i => i.usercode) |
| | | }, |
| | | handleDialogSelectionChange(rows) { |
| | | this.batchDialogRoleCode = rows.map(i => i.usercode) |
| | | }, |
| | | // 对话框取消 |
| | | dialogVisibleCancel() { |
| | | this.dialogVisible = false |
| | | }, |
| | | // 对话框确认 |
| | | async dialogVisibleConfirm() { |
| | | const res = await RoleAssignedUserBatchAdd(this.batchDialogRoleCode, this.form.role_code) |
| | | if (res.code === '200') { |
| | | this.$notify.success(this.batchDialogRoleCode.length + '个用户新增授权成功!') |
| | | await this.getRoleAssignedUserData() |
| | | this.batchDialogRoleCode = [] |
| | | this.$refs.tableDataDialogRef.clearSelection() |
| | | this.dialogVisible = false |
| | | } else { |
| | | this.$notify.error(this.batchDialogRoleCode.length + '个用户新增授权失败!') |
| | | } |
| | | }, |
| | | // 获取页面高度 |
| | | getHeight() { |
| | | this.$nextTick(() => { |
| | | this.mainHeight = window.innerHeight - 85 |
| | | this.tableHeight = this.mainHeight - 255 |
| | | this.$refs.tableDataRef.doLayout() |
| | | }) |
| | | } |
| | | } |
| | | } |
| | | </script> |