| | |
| | | <template> |
| | | <el-row class="out-box"> |
| | | <el-col :span="5"> |
| | | <div class="box"> |
| | | <el-scrollbar> |
| | | <el-col :span="5"> |
| | | <div class="box"> |
| | | <el-scrollbar> |
| | | <basic-container> |
| | | <avue-tree :option="treeOption" :data="treeData" @node-click="nodeClick"/> |
| | | </basic-container> |
| | | </el-scrollbar> |
| | | </div> |
| | | </el-col> |
| | | <el-col :span="19"> |
| | | <basic-container> |
| | | <avue-tree :option="treeOption" :data="treeData" @node-click="nodeClick" /> |
| | | <avue-crud :option="option" v-model:search="search" :table-loading="loading" :data="data" ref="crud" |
| | | v-model="form" :permission="permissionList" @row-del="rowDel" @row-update="rowUpdate" |
| | | @row-save="rowSave" |
| | | :before-open="beforeOpen" v-model:page="page" @search-change="searchChange" |
| | | @search-reset="searchReset" |
| | | @selection-change="selectionChange" @current-change="currentChange" @size-change="sizeChange" |
| | | @refresh-change="refreshChange" @on-load="onLoad"> |
| | | <template #menu-left> |
| | | <el-button type="danger" plain icon="el-icon-delete" v-if="permission.user_delete" |
| | | @click="handleDelete">删 除 |
| | | </el-button> |
| | | <el-button type="success" plain v-if="userInfo.role_name.includes('admin')" |
| | | icon="el-icon-upload" |
| | | @click="handleImport">导入 |
| | | </el-button> |
| | | <el-button type="warning" plain v-if="userInfo.role_name.includes('admin')" |
| | | icon="el-icon-download" |
| | | @click="handleExport">导出 |
| | | </el-button> |
| | | </template> |
| | | <template #deptName="{ row }"> |
| | | <el-tag>{{ row.deptName }}</el-tag> |
| | | </template> |
| | | <template #postName="{ row }"> |
| | | <el-tag>{{ row.postName }}</el-tag> |
| | | </template> |
| | | </avue-crud> |
| | | <el-dialog title="用户数据导入" append-to-body v-model="excelBox" width="555px"> |
| | | <avue-form :option="excelOption" v-model="excelForm" :upload-after="uploadAfter"> |
| | | <template #excelTemplate> |
| | | <el-button type="primary" @click="handleTemplate"> |
| | | 点击下载<i class="el-icon-download el-icon--right"></i> |
| | | </el-button> |
| | | </template> |
| | | </avue-form> |
| | | </el-dialog> |
| | | </basic-container> |
| | | </el-scrollbar> |
| | | </div> |
| | | </el-col> |
| | | <el-col :span="19"> |
| | | <basic-container> |
| | | <avue-crud :option="option" v-model:search="search" :table-loading="loading" :data="data" ref="crud" |
| | | v-model="form" :permission="permissionList" @row-del="rowDel" @row-update="rowUpdate" @row-save="rowSave" |
| | | :before-open="beforeOpen" v-model:page="page" @search-change="searchChange" @search-reset="searchReset" |
| | | @selection-change="selectionChange" @current-change="currentChange" @size-change="sizeChange" |
| | | @refresh-change="refreshChange" @on-load="onLoad"> |
| | | <template #menu-left> |
| | | <el-button type="danger" plain icon="el-icon-delete" v-if="permission.user_delete" @click="handleDelete">删 除 |
| | | </el-button> |
| | | <el-button type="success" plain v-if="userInfo.role_name.includes('admin')" icon="el-icon-upload" |
| | | @click="handleImport">导入 |
| | | </el-button> |
| | | <el-button type="warning" plain v-if="userInfo.role_name.includes('admin')" icon="el-icon-download" |
| | | @click="handleExport">导出 |
| | | </el-button> |
| | | </template> |
| | | <template #deptName="{ row }"> |
| | | <el-tag>{{ row.deptName }}</el-tag> |
| | | </template> |
| | | <template #postName="{ row }"> |
| | | <el-tag>{{ row.postName }}</el-tag> |
| | | </template> |
| | | </avue-crud> |
| | | <el-dialog title="用户数据导入" append-to-body v-model="excelBox" width="555px"> |
| | | <avue-form :option="excelOption" v-model="excelForm" :upload-after="uploadAfter"> |
| | | <template #excelTemplate> |
| | | <el-button type="primary" @click="handleTemplate"> |
| | | 点击下载<i class="el-icon-download el-icon--right"></i> |
| | | </el-button> |
| | | </template> |
| | | </avue-form> |
| | | </el-dialog> |
| | | </basic-container> |
| | | </el-col> |
| | | </el-col> |
| | | </el-row> |
| | | </template> |
| | | |
| | | |
| | | <script> |
| | | import { |
| | | getList, |
| | | getUser, |
| | | getUserPlatform, |
| | | remove, |
| | | update, |
| | | updatePlatform, |
| | | add, |
| | | grant, |
| | | resetPassword, |
| | | unlock, |
| | | getList, |
| | | getUser, |
| | | getUserPlatform, |
| | | remove, |
| | | update, |
| | | updatePlatform, |
| | | add, |
| | | grant, |
| | | resetPassword, |
| | | unlock, |
| | | } from '@/api/system/user'; |
| | | import { option } from '@/option/employee/list' |
| | | import { exportBlob } from '@/api/common'; |
| | | import { getDeptTree, getDeptLazyTree } from '@/api/system/dept'; |
| | | import { getRoleTree } from '@/api/system/role'; |
| | | import { getPostList } from '@/api/system/post'; |
| | | import { mapGetters } from 'vuex'; |
| | | import {option} from '@/option/employee/list' |
| | | import {exportBlob} from '@/api/common'; |
| | | import {getDeptTree, getDeptLazyTree} from '@/api/system/dept'; |
| | | import {getRoleTree} from '@/api/system/role'; |
| | | import {getPostList} from '@/api/system/post'; |
| | | import {mapGetters} from 'vuex'; |
| | | import website from '@/config/website'; |
| | | import { getToken } from '@/utils/auth'; |
| | | import { downloadXls } from '@/utils/util'; |
| | | import {getToken} from '@/utils/auth'; |
| | | import {downloadXls} from '@/utils/util'; |
| | | import NProgress from 'nprogress'; |
| | | import 'nprogress/nprogress.css'; |
| | | import func from '@/utils/func'; |
| | | |
| | | export default { |
| | | data() { |
| | | return { |
| | | form: {}, |
| | | search: {}, |
| | | roleBox: false, |
| | | excelBox: false, |
| | | platformBox: false, |
| | | initFlag: true, |
| | | selectionList: [], |
| | | query: {}, |
| | | loading: true, |
| | | platformLoading: false, |
| | | page: { |
| | | pageSize: 10, |
| | | currentPage: 1, |
| | | total: 0, |
| | | }, |
| | | platformPage: { |
| | | pageSize: 10, |
| | | currentPage: 1, |
| | | total: 0, |
| | | }, |
| | | init: { |
| | | roleTree: [], |
| | | deptTree: [], |
| | | }, |
| | | props: { |
| | | label: 'title', |
| | | value: 'key', |
| | | }, |
| | | roleGrantList: [], |
| | | roleTreeObj: [], |
| | | treeDeptId: '', |
| | | treeData: [], |
| | | treeOption: { |
| | | nodeKey: 'id', |
| | | lazy: true, |
| | | treeLoad: function (node, resolve) { |
| | | const parentId = node.level === 0 ? 0 : node.data.id; |
| | | getDeptLazyTree(parentId).then(res => { |
| | | resolve( |
| | | res.data.data.map(item => { |
| | | return { |
| | | ...item, |
| | | leaf: !item.hasChildren, |
| | | }; |
| | | }) |
| | | ); |
| | | }); |
| | | }, |
| | | addBtn: false, |
| | | menu: false, |
| | | size: 'small', |
| | | props: { |
| | | labelText: '标题', |
| | | label: 'title', |
| | | value: 'value', |
| | | children: 'children', |
| | | }, |
| | | }, |
| | | option: option, |
| | | data: [], |
| | | platformQuery: {}, |
| | | platformSelectionList: [], |
| | | platformData: [], |
| | | platformForm: {}, |
| | | platformOption: { |
| | | tip: false, |
| | | searchShow: true, |
| | | searchMenuSpan: 6, |
| | | border: true, |
| | | index: true, |
| | | selection: true, |
| | | viewBtn: true, |
| | | dialogClickModal: false, |
| | | menuWidth: 120, |
| | | editBtnText: '配置', |
| | | column: [ |
| | | { |
| | | label: '登录账号', |
| | | prop: 'account', |
| | | search: true, |
| | | display: false, |
| | | }, |
| | | { |
| | | label: '所属租户', |
| | | prop: 'tenantName', |
| | | slot: true, |
| | | display: false, |
| | | }, |
| | | { |
| | | label: '用户姓名', |
| | | prop: 'realName', |
| | | search: true, |
| | | display: false, |
| | | }, |
| | | { |
| | | label: '用户平台', |
| | | prop: 'userTypeName', |
| | | slot: true, |
| | | display: false, |
| | | }, |
| | | { |
| | | label: '用户平台', |
| | | type: 'select', |
| | | dicUrl: '/blade-system/dict/dictionary?code=user_type', |
| | | data() { |
| | | return { |
| | | form: {}, |
| | | search: {}, |
| | | roleBox: false, |
| | | excelBox: false, |
| | | platformBox: false, |
| | | initFlag: true, |
| | | selectionList: [], |
| | | query: {}, |
| | | loading: true, |
| | | platformLoading: false, |
| | | page: { |
| | | pageSize: 10, |
| | | currentPage: 1, |
| | | total: 0, |
| | | }, |
| | | platformPage: { |
| | | pageSize: 10, |
| | | currentPage: 1, |
| | | total: 0, |
| | | }, |
| | | init: { |
| | | roleTree: [], |
| | | deptTree: [], |
| | | }, |
| | | props: { |
| | | label: 'dictValue', |
| | | value: 'dictKey', |
| | | label: 'title', |
| | | value: 'key', |
| | | }, |
| | | dataType: 'number', |
| | | search: true, |
| | | hide: true, |
| | | display: false, |
| | | prop: 'userType', |
| | | rules: [ |
| | | { |
| | | required: true, |
| | | message: '请选择用户平台', |
| | | trigger: 'blur', |
| | | }, |
| | | ], |
| | | }, |
| | | { |
| | | label: '用户拓展', |
| | | prop: 'userExt', |
| | | type: 'textarea', |
| | | minRows: 8, |
| | | span: 24, |
| | | overHidden: true, |
| | | row: true, |
| | | hide: true, |
| | | }, |
| | | ], |
| | | }, |
| | | excelForm: {}, |
| | | excelOption: { |
| | | submitBtn: false, |
| | | emptyBtn: false, |
| | | column: [ |
| | | { |
| | | label: '模板上传', |
| | | prop: 'excelFile', |
| | | type: 'upload', |
| | | drag: true, |
| | | loadText: '模板上传中,请稍等', |
| | | span: 24, |
| | | propsHttp: { |
| | | res: 'data', |
| | | roleGrantList: [], |
| | | roleTreeObj: [], |
| | | treeDeptId: '', |
| | | treeData: [], |
| | | treeOption: { |
| | | nodeKey: 'id', |
| | | lazy: true, |
| | | treeLoad: function (node, resolve) { |
| | | const parentId = node.level === 0 ? 0 : node.data.id; |
| | | getDeptLazyTree(parentId).then(res => { |
| | | resolve( |
| | | res.data.data.map(item => { |
| | | return { |
| | | ...item, |
| | | leaf: !item.hasChildren, |
| | | }; |
| | | }) |
| | | ); |
| | | }); |
| | | }, |
| | | addBtn: false, |
| | | menu: false, |
| | | size: 'small', |
| | | props: { |
| | | labelText: '标题', |
| | | label: 'title', |
| | | value: 'value', |
| | | children: 'children', |
| | | }, |
| | | }, |
| | | tip: '请上传 .xls,.xlsx 标准格式文件', |
| | | action: '/blade-system/user/import-user', |
| | | }, |
| | | { |
| | | label: '数据覆盖', |
| | | prop: 'isCovered', |
| | | type: 'switch', |
| | | align: 'center', |
| | | width: 80, |
| | | dicData: [ |
| | | { |
| | | label: '否', |
| | | value: 0, |
| | | }, |
| | | { |
| | | label: '是', |
| | | value: 1, |
| | | }, |
| | | ], |
| | | value: 0, |
| | | slot: true, |
| | | rules: [ |
| | | { |
| | | required: true, |
| | | message: '请选择是否覆盖', |
| | | trigger: 'blur', |
| | | }, |
| | | ], |
| | | }, |
| | | { |
| | | label: '模板下载', |
| | | prop: 'excelTemplate', |
| | | formslot: true, |
| | | span: 24, |
| | | }, |
| | | ], |
| | | }, |
| | | }; |
| | | }, |
| | | watch: { |
| | | 'form.tenantId'() { |
| | | if (this.form.tenantId !== '' && this.initFlag) { |
| | | this.initData(this.form.tenantId); |
| | | } |
| | | option: option, |
| | | data: [], |
| | | platformQuery: {}, |
| | | platformSelectionList: [], |
| | | platformData: [], |
| | | platformForm: {}, |
| | | platformOption: { |
| | | tip: false, |
| | | searchShow: true, |
| | | searchMenuSpan: 6, |
| | | border: true, |
| | | index: true, |
| | | selection: true, |
| | | viewBtn: true, |
| | | dialogClickModal: false, |
| | | menuWidth: 120, |
| | | editBtnText: '配置', |
| | | column: [ |
| | | { |
| | | label: '登录账号', |
| | | prop: 'account', |
| | | search: true, |
| | | display: false, |
| | | }, |
| | | { |
| | | label: '所属租户', |
| | | prop: 'tenantName', |
| | | slot: true, |
| | | display: false, |
| | | }, |
| | | { |
| | | label: '用户姓名', |
| | | prop: 'realName', |
| | | search: true, |
| | | display: false, |
| | | }, |
| | | { |
| | | label: '用户平台', |
| | | prop: 'userTypeName', |
| | | slot: true, |
| | | display: false, |
| | | }, |
| | | { |
| | | label: '用户平台', |
| | | type: 'select', |
| | | dicUrl: '/blade-system/dict/dictionary?code=user_type', |
| | | props: { |
| | | label: 'dictValue', |
| | | value: 'dictKey', |
| | | }, |
| | | dataType: 'number', |
| | | search: true, |
| | | hide: true, |
| | | display: false, |
| | | prop: 'userType', |
| | | rules: [ |
| | | { |
| | | required: true, |
| | | message: '请选择用户平台', |
| | | trigger: 'blur', |
| | | }, |
| | | ], |
| | | }, |
| | | { |
| | | label: '用户拓展', |
| | | prop: 'userExt', |
| | | type: 'textarea', |
| | | minRows: 8, |
| | | span: 24, |
| | | overHidden: true, |
| | | row: true, |
| | | hide: true, |
| | | }, |
| | | ], |
| | | }, |
| | | excelForm: {}, |
| | | excelOption: { |
| | | submitBtn: false, |
| | | emptyBtn: false, |
| | | column: [ |
| | | { |
| | | label: '模板上传', |
| | | prop: 'excelFile', |
| | | type: 'upload', |
| | | drag: true, |
| | | loadText: '模板上传中,请稍等', |
| | | span: 24, |
| | | propsHttp: { |
| | | res: 'data', |
| | | }, |
| | | tip: '请上传 .xls,.xlsx 标准格式文件', |
| | | action: '/blade-system/user/import-user', |
| | | }, |
| | | { |
| | | label: '数据覆盖', |
| | | prop: 'isCovered', |
| | | type: 'switch', |
| | | align: 'center', |
| | | width: 80, |
| | | dicData: [ |
| | | { |
| | | label: '否', |
| | | value: 0, |
| | | }, |
| | | { |
| | | label: '是', |
| | | value: 1, |
| | | }, |
| | | ], |
| | | value: 0, |
| | | slot: true, |
| | | rules: [ |
| | | { |
| | | required: true, |
| | | message: '请选择是否覆盖', |
| | | trigger: 'blur', |
| | | }, |
| | | ], |
| | | }, |
| | | { |
| | | label: '模板下载', |
| | | prop: 'excelTemplate', |
| | | formslot: true, |
| | | span: 24, |
| | | }, |
| | | ], |
| | | }, |
| | | }; |
| | | }, |
| | | 'excelForm.isCovered'() { |
| | | if (this.excelForm.isCovered !== '') { |
| | | const column = this.findObject(this.excelOption.column, 'excelFile'); |
| | | column.action = `/blade-system/user/import-user?isCovered=${this.excelForm.isCovered}`; |
| | | } |
| | | }, |
| | | }, |
| | | computed: { |
| | | ...mapGetters(['userInfo', 'permission']), |
| | | permissionList() { |
| | | return { |
| | | addBtn: this.validData(this.permission.user_add, false), |
| | | viewBtn: this.validData(this.permission.user_view, false), |
| | | delBtn: this.validData(this.permission.user_delete, false), |
| | | editBtn: this.validData(this.permission.user_edit, false), |
| | | }; |
| | | }, |
| | | platformPermissionList() { |
| | | return { |
| | | addBtn: false, |
| | | viewBtn: false, |
| | | delBtn: false, |
| | | editBtn: this.validData(this.permission.user_edit, false), |
| | | }; |
| | | }, |
| | | ids() { |
| | | let ids = []; |
| | | this.selectionList.forEach(ele => { |
| | | ids.push(ele.id); |
| | | }); |
| | | return ids.join(','); |
| | | }, |
| | | }, |
| | | mounted() { |
| | | // 非租户模式默认加载管理组数据 |
| | | // if (!website.tenantMode) { |
| | | this.initData(website.tenantId); |
| | | // } |
| | | }, |
| | | methods: { |
| | | nodeClick(data) { |
| | | this.treeDeptId = data.id; |
| | | this.page.currentPage = 1; |
| | | this.onLoad(this.page); |
| | | }, |
| | | initData(tenantId) { |
| | | getRoleTree(tenantId).then(res => { |
| | | const column = this.findObject(this.option.group, 'roleId'); |
| | | column.dicData = res.data.data; |
| | | }); |
| | | getDeptTree(tenantId).then(res => { |
| | | const column = this.findObject(this.option.group, 'deptId'); |
| | | column.dicData = res.data.data; |
| | | }); |
| | | getPostList(tenantId).then(res => { |
| | | const column = this.findObject(this.option.group, 'postId'); |
| | | column.dicData = res.data.data; |
| | | }); |
| | | }, |
| | | submitRole() { |
| | | const roleList = this.$refs.treeRole.getCheckedKeys().join(','); |
| | | grant(this.ids, roleList).then(() => { |
| | | this.roleBox = false; |
| | | this.$message({ |
| | | type: 'success', |
| | | message: '操作成功!', |
| | | }); |
| | | this.onLoad(this.page); |
| | | }); |
| | | }, |
| | | rowSave(row, done, loading) { |
| | | row.deptId = func.join(row.deptId); |
| | | row.postId = func.join(row.postId); |
| | | row.userType = 2 |
| | | add(row).then( |
| | | () => { |
| | | this.initFlag = false; |
| | | this.onLoad(this.page); |
| | | this.$message({ |
| | | type: 'success', |
| | | message: '操作成功!', |
| | | }); |
| | | done(); |
| | | watch: { |
| | | 'form.tenantId'() { |
| | | if (this.form.tenantId !== '' && this.initFlag) { |
| | | this.initData(this.form.tenantId); |
| | | } |
| | | }, |
| | | error => { |
| | | window.console.log(error); |
| | | loading(); |
| | | } |
| | | ); |
| | | }, |
| | | rowUpdate(row, index, done, loading) { |
| | | row.deptId = func.join(row.deptId); |
| | | row.roleId = func.join(row.roleId); |
| | | row.postId = func.join(row.postId); |
| | | update(row).then( |
| | | () => { |
| | | this.initFlag = false; |
| | | this.onLoad(this.page); |
| | | this.$message({ |
| | | type: 'success', |
| | | message: '操作成功!', |
| | | }); |
| | | done(); |
| | | 'excelForm.isCovered'() { |
| | | if (this.excelForm.isCovered !== '') { |
| | | const column = this.findObject(this.excelOption.column, 'excelFile'); |
| | | column.action = `/blade-system/user/import-user?isCovered=${this.excelForm.isCovered}`; |
| | | } |
| | | }, |
| | | error => { |
| | | window.console.log(error); |
| | | loading(); |
| | | } |
| | | ); |
| | | }, |
| | | rowDel(row) { |
| | | this.$confirm('确定将选择数据删除?', { |
| | | confirmButtonText: '确定', |
| | | cancelButtonText: '取消', |
| | | type: 'warning', |
| | | }) |
| | | .then(() => { |
| | | return remove(row.id); |
| | | }) |
| | | .then(() => { |
| | | this.onLoad(this.page); |
| | | this.$message({ |
| | | type: 'success', |
| | | message: '操作成功!', |
| | | }); |
| | | }); |
| | | }, |
| | | searchReset() { |
| | | this.query = {}; |
| | | this.treeDeptId = ''; |
| | | this.onLoad(this.page); |
| | | }, |
| | | searchChange(params, done) { |
| | | this.query = params; |
| | | this.page.currentPage = 1; |
| | | this.onLoad(this.page, params); |
| | | done(); |
| | | }, |
| | | selectionChange(list) { |
| | | this.selectionList = list; |
| | | }, |
| | | selectionClear() { |
| | | this.selectionList = []; |
| | | this.$refs.crud.toggleSelection(); |
| | | }, |
| | | handleDelete() { |
| | | if (this.selectionList.length === 0) { |
| | | this.$message.warning('请选择至少一条数据'); |
| | | return; |
| | | } |
| | | this.$confirm('确定将选择数据删除?', { |
| | | confirmButtonText: '确定', |
| | | cancelButtonText: '取消', |
| | | type: 'warning', |
| | | }) |
| | | .then(() => { |
| | | return remove(this.ids); |
| | | }) |
| | | .then(() => { |
| | | this.onLoad(this.page); |
| | | this.$message({ |
| | | type: 'success', |
| | | message: '操作成功!', |
| | | }); |
| | | this.$refs.crud.toggleSelection(); |
| | | }); |
| | | }, |
| | | handleReset() { |
| | | if (this.selectionList.length === 0) { |
| | | this.$message.warning('请选择至少一条数据'); |
| | | return; |
| | | } |
| | | this.$confirm('确定将选择账号密码重置为123456?', { |
| | | confirmButtonText: '确定', |
| | | cancelButtonText: '取消', |
| | | type: 'warning', |
| | | }) |
| | | .then(() => { |
| | | return resetPassword(this.ids); |
| | | }) |
| | | .then(() => { |
| | | this.$message({ |
| | | type: 'success', |
| | | message: '操作成功!', |
| | | }); |
| | | this.$refs.crud.toggleSelection(); |
| | | }); |
| | | }, |
| | | handleGrant() { |
| | | if (this.selectionList.length === 0) { |
| | | this.$message.warning('请选择至少一条数据'); |
| | | return; |
| | | } |
| | | this.roleTreeObj = []; |
| | | if (this.selectionList.length === 1) { |
| | | this.roleTreeObj = this.selectionList[0].roleId.split(','); |
| | | } |
| | | getRoleTree().then(res => { |
| | | this.roleGrantList = res.data.data; |
| | | this.roleBox = true; |
| | | }); |
| | | }, |
| | | handlePlatform() { |
| | | this.platformBox = true; |
| | | }, |
| | | handleLock() { |
| | | if (this.selectionList.length === 0) { |
| | | this.$message.warning('请选择至少一条数据'); |
| | | return; |
| | | } |
| | | this.$confirm('确定将选择账号解封?', { |
| | | confirmButtonText: '确定', |
| | | cancelButtonText: '取消', |
| | | type: 'warning', |
| | | }) |
| | | .then(() => { |
| | | return unlock(this.ids); |
| | | }) |
| | | .then(() => { |
| | | this.$message({ |
| | | type: 'success', |
| | | message: '操作成功!', |
| | | }); |
| | | }); |
| | | }, |
| | | handleImport() { |
| | | this.excelBox = true; |
| | | }, |
| | | uploadAfter(res, done, loading, column) { |
| | | window.console.log(column); |
| | | this.excelBox = false; |
| | | this.refreshChange(); |
| | | done(); |
| | | }, |
| | | handleExport() { |
| | | const account = func.toStr(this.search.account); |
| | | const realName = func.toStr(this.search.realName); |
| | | this.$confirm('是否导出用户数据?', '提示', { |
| | | confirmButtonText: '确定', |
| | | cancelButtonText: '取消', |
| | | type: 'warning', |
| | | }).then(() => { |
| | | NProgress.start(); |
| | | exportBlob( |
| | | `/blade-system/user/export-user?${this.website.tokenHeader |
| | | }=${getToken()}&account=${account}&realName=${realName}` |
| | | ).then(res => { |
| | | downloadXls(res.data, `用户数据表${this.$dayjs().format('YYYY-MM-DD')}.xlsx`); |
| | | NProgress.done(); |
| | | }); |
| | | }); |
| | | }, |
| | | handleTemplate() { |
| | | exportBlob( |
| | | `/blade-system/user/export-template?${this.website.tokenHeader}=${getToken()}` |
| | | ).then(res => { |
| | | downloadXls(res.data, '用户数据模板.xlsx'); |
| | | }); |
| | | }, |
| | | beforeOpen(done, type) { |
| | | if (['edit', 'view'].includes(type)) { |
| | | getUser(this.form.id).then(res => { |
| | | this.form = res.data.data; |
| | | if (this.form.hasOwnProperty('deptId')) { |
| | | this.form.deptId = this.form.deptId.split(','); |
| | | } |
| | | if (this.form.hasOwnProperty('roleId')) { |
| | | this.form.roleId = this.form.roleId.split(','); |
| | | } |
| | | if (this.form.hasOwnProperty('postId')) { |
| | | this.form.postId = this.form.postId.split(','); |
| | | } |
| | | }); |
| | | } |
| | | this.initFlag = true; |
| | | done(); |
| | | }, |
| | | currentChange(currentPage) { |
| | | this.page.currentPage = currentPage; |
| | | }, |
| | | sizeChange(pageSize) { |
| | | this.page.pageSize = pageSize; |
| | | }, |
| | | refreshChange() { |
| | | this.onLoad(this.page, this.query); |
| | | }, |
| | | onLoad(page, params = {}) { |
| | | this.loading = true; |
| | | getList( |
| | | page.currentPage, |
| | | page.pageSize, |
| | | // Object.assign(params, this.query), |
| | | Object.assign(params, { |
| | | ...this.query, |
| | | userType: 2 |
| | | }), |
| | | this.treeDeptId |
| | | ).then(res => { |
| | | const data = res.data.data; |
| | | this.page.total = data.total; |
| | | this.data = data.records; |
| | | this.loading = false; |
| | | this.selectionClear(); |
| | | }); |
| | | }, |
| | | platformRowUpdate(row, index, done, loading) { |
| | | updatePlatform(row.id, row.userType, row.userExt).then( |
| | | () => { |
| | | this.platformOnLoad(this.platformPage); |
| | | this.$message({ |
| | | type: 'success', |
| | | message: '操作成功!', |
| | | }); |
| | | done(); |
| | | computed: { |
| | | ...mapGetters(['userInfo', 'permission']), |
| | | permissionList() { |
| | | return { |
| | | addBtn: this.validData(this.permission.user_add, false), |
| | | viewBtn: this.validData(this.permission.user_view, false), |
| | | delBtn: this.validData(this.permission.user_delete, false), |
| | | editBtn: this.validData(this.permission.user_edit, false), |
| | | }; |
| | | }, |
| | | error => { |
| | | window.console.log(error); |
| | | loading(); |
| | | } |
| | | ); |
| | | platformPermissionList() { |
| | | return { |
| | | addBtn: false, |
| | | viewBtn: false, |
| | | delBtn: false, |
| | | editBtn: this.validData(this.permission.user_edit, false), |
| | | }; |
| | | }, |
| | | ids() { |
| | | let ids = []; |
| | | this.selectionList.forEach(ele => { |
| | | ids.push(ele.id); |
| | | }); |
| | | return ids.join(','); |
| | | }, |
| | | }, |
| | | platformBeforeOpen(done, type) { |
| | | if (['edit', 'view'].includes(type)) { |
| | | getUserPlatform(this.platformForm.id).then(res => { |
| | | this.platformForm = res.data.data; |
| | | }); |
| | | } |
| | | done(); |
| | | mounted() { |
| | | // 非租户模式默认加载管理组数据 |
| | | // if (!website.tenantMode) { |
| | | this.initData(website.tenantId); |
| | | // } |
| | | }, |
| | | platformSearchReset() { |
| | | this.platformQuery = {}; |
| | | this.platformOnLoad(this.platformPage); |
| | | methods: { |
| | | nodeClick(data) { |
| | | this.treeDeptId = data.id; |
| | | this.page.currentPage = 1; |
| | | this.onLoad(this.page); |
| | | }, |
| | | initData(tenantId) { |
| | | getRoleTree(tenantId).then(res => { |
| | | const column = this.findObject(this.option.group, 'roleId'); |
| | | column.dicData = res.data.data; |
| | | }); |
| | | getDeptTree(tenantId).then(res => { |
| | | const column = this.findObject(this.option.group, 'deptId'); |
| | | column.dicData = res.data.data; |
| | | }); |
| | | getPostList(tenantId).then(res => { |
| | | const column = this.findObject(this.option.group, 'postId'); |
| | | column.dicData = res.data.data; |
| | | }); |
| | | }, |
| | | submitRole() { |
| | | const roleList = this.$refs.treeRole.getCheckedKeys().join(','); |
| | | grant(this.ids, roleList).then(() => { |
| | | this.roleBox = false; |
| | | this.$message({ |
| | | type: 'success', |
| | | message: '操作成功!', |
| | | }); |
| | | this.onLoad(this.page); |
| | | }); |
| | | }, |
| | | rowSave(row, done, loading) { |
| | | row.deptId = func.join(row.deptId); |
| | | row.postId = func.join(row.postId); |
| | | row.userType = 2 |
| | | row.account = row.phone |
| | | row.roleId = '1123598816738675202' |
| | | add(row).then( |
| | | () => { |
| | | this.initFlag = false; |
| | | this.onLoad(this.page); |
| | | this.$message({ |
| | | type: 'success', |
| | | message: '操作成功!', |
| | | }); |
| | | done(); |
| | | }, |
| | | error => { |
| | | window.console.log(error); |
| | | loading(); |
| | | } |
| | | ); |
| | | }, |
| | | rowUpdate(row, index, done, loading) { |
| | | row.deptId = func.join(row.deptId); |
| | | row.roleId = func.join(row.roleId); |
| | | row.postId = func.join(row.postId); |
| | | update(row).then( |
| | | () => { |
| | | this.initFlag = false; |
| | | this.onLoad(this.page); |
| | | this.$message({ |
| | | type: 'success', |
| | | message: '操作成功!', |
| | | }); |
| | | done(); |
| | | }, |
| | | error => { |
| | | window.console.log(error); |
| | | loading(); |
| | | } |
| | | ); |
| | | }, |
| | | rowDel(row) { |
| | | this.$confirm('确定将选择数据删除?', { |
| | | confirmButtonText: '确定', |
| | | cancelButtonText: '取消', |
| | | type: 'warning', |
| | | }) |
| | | .then(() => { |
| | | return remove(row.id); |
| | | }) |
| | | .then(() => { |
| | | this.onLoad(this.page); |
| | | this.$message({ |
| | | type: 'success', |
| | | message: '操作成功!', |
| | | }); |
| | | }); |
| | | }, |
| | | searchReset() { |
| | | this.query = {}; |
| | | this.treeDeptId = ''; |
| | | this.onLoad(this.page); |
| | | }, |
| | | searchChange(params, done) { |
| | | this.query = params; |
| | | this.page.currentPage = 1; |
| | | this.onLoad(this.page, params); |
| | | done(); |
| | | }, |
| | | selectionChange(list) { |
| | | this.selectionList = list; |
| | | }, |
| | | selectionClear() { |
| | | this.selectionList = []; |
| | | this.$refs.crud.toggleSelection(); |
| | | }, |
| | | handleDelete() { |
| | | if (this.selectionList.length === 0) { |
| | | this.$message.warning('请选择至少一条数据'); |
| | | return; |
| | | } |
| | | this.$confirm('确定将选择数据删除?', { |
| | | confirmButtonText: '确定', |
| | | cancelButtonText: '取消', |
| | | type: 'warning', |
| | | }) |
| | | .then(() => { |
| | | return remove(this.ids); |
| | | }) |
| | | .then(() => { |
| | | this.onLoad(this.page); |
| | | this.$message({ |
| | | type: 'success', |
| | | message: '操作成功!', |
| | | }); |
| | | this.$refs.crud.toggleSelection(); |
| | | }); |
| | | }, |
| | | handleReset() { |
| | | if (this.selectionList.length === 0) { |
| | | this.$message.warning('请选择至少一条数据'); |
| | | return; |
| | | } |
| | | this.$confirm('确定将选择账号密码重置为123456?', { |
| | | confirmButtonText: '确定', |
| | | cancelButtonText: '取消', |
| | | type: 'warning', |
| | | }) |
| | | .then(() => { |
| | | return resetPassword(this.ids); |
| | | }) |
| | | .then(() => { |
| | | this.$message({ |
| | | type: 'success', |
| | | message: '操作成功!', |
| | | }); |
| | | this.$refs.crud.toggleSelection(); |
| | | }); |
| | | }, |
| | | handleGrant() { |
| | | if (this.selectionList.length === 0) { |
| | | this.$message.warning('请选择至少一条数据'); |
| | | return; |
| | | } |
| | | this.roleTreeObj = []; |
| | | if (this.selectionList.length === 1) { |
| | | this.roleTreeObj = this.selectionList[0].roleId.split(','); |
| | | } |
| | | getRoleTree().then(res => { |
| | | this.roleGrantList = res.data.data; |
| | | this.roleBox = true; |
| | | }); |
| | | }, |
| | | handlePlatform() { |
| | | this.platformBox = true; |
| | | }, |
| | | handleLock() { |
| | | if (this.selectionList.length === 0) { |
| | | this.$message.warning('请选择至少一条数据'); |
| | | return; |
| | | } |
| | | this.$confirm('确定将选择账号解封?', { |
| | | confirmButtonText: '确定', |
| | | cancelButtonText: '取消', |
| | | type: 'warning', |
| | | }) |
| | | .then(() => { |
| | | return unlock(this.ids); |
| | | }) |
| | | .then(() => { |
| | | this.$message({ |
| | | type: 'success', |
| | | message: '操作成功!', |
| | | }); |
| | | }); |
| | | }, |
| | | handleImport() { |
| | | this.excelBox = true; |
| | | }, |
| | | uploadAfter(res, done, loading, column) { |
| | | window.console.log(column); |
| | | this.excelBox = false; |
| | | this.refreshChange(); |
| | | done(); |
| | | }, |
| | | handleExport() { |
| | | const account = func.toStr(this.search.account); |
| | | const realName = func.toStr(this.search.realName); |
| | | this.$confirm('是否导出用户数据?', '提示', { |
| | | confirmButtonText: '确定', |
| | | cancelButtonText: '取消', |
| | | type: 'warning', |
| | | }).then(() => { |
| | | NProgress.start(); |
| | | exportBlob( |
| | | `/blade-system/user/export-user?${this.website.tokenHeader |
| | | }=${getToken()}&account=${account}&realName=${realName}` |
| | | ).then(res => { |
| | | downloadXls(res.data, `用户数据表${this.$dayjs().format('YYYY-MM-DD')}.xlsx`); |
| | | NProgress.done(); |
| | | }); |
| | | }); |
| | | }, |
| | | handleTemplate() { |
| | | exportBlob( |
| | | `/blade-system/user/export-template?${this.website.tokenHeader}=${getToken()}` |
| | | ).then(res => { |
| | | downloadXls(res.data, '用户数据模板.xlsx'); |
| | | }); |
| | | }, |
| | | beforeOpen(done, type) { |
| | | if (['edit', 'view'].includes(type)) { |
| | | getUser(this.form.id).then(res => { |
| | | this.form = res.data.data; |
| | | if (this.form.hasOwnProperty('deptId')) { |
| | | this.form.deptId = this.form.deptId.split(','); |
| | | } |
| | | if (this.form.hasOwnProperty('roleId')) { |
| | | this.form.roleId = this.form.roleId.split(','); |
| | | } |
| | | if (this.form.hasOwnProperty('postId')) { |
| | | this.form.postId = this.form.postId.split(','); |
| | | } |
| | | }); |
| | | } |
| | | this.initFlag = true; |
| | | done(); |
| | | }, |
| | | currentChange(currentPage) { |
| | | this.page.currentPage = currentPage; |
| | | }, |
| | | sizeChange(pageSize) { |
| | | this.page.pageSize = pageSize; |
| | | }, |
| | | refreshChange() { |
| | | this.onLoad(this.page, this.query); |
| | | }, |
| | | onLoad(page, params = {}) { |
| | | this.loading = true; |
| | | getList( |
| | | page.currentPage, |
| | | page.pageSize, |
| | | // Object.assign(params, this.query), |
| | | Object.assign(params, { |
| | | ...this.query, |
| | | userType: 2 |
| | | }), |
| | | this.treeDeptId |
| | | ).then(res => { |
| | | const data = res.data.data; |
| | | this.page.total = data.total; |
| | | this.data = data.records; |
| | | this.loading = false; |
| | | this.selectionClear(); |
| | | }); |
| | | }, |
| | | platformRowUpdate(row, index, done, loading) { |
| | | updatePlatform(row.id, row.userType, row.userExt).then( |
| | | () => { |
| | | this.platformOnLoad(this.platformPage); |
| | | this.$message({ |
| | | type: 'success', |
| | | message: '操作成功!', |
| | | }); |
| | | done(); |
| | | }, |
| | | error => { |
| | | window.console.log(error); |
| | | loading(); |
| | | } |
| | | ); |
| | | }, |
| | | platformBeforeOpen(done, type) { |
| | | if (['edit', 'view'].includes(type)) { |
| | | getUserPlatform(this.platformForm.id).then(res => { |
| | | this.platformForm = res.data.data; |
| | | }); |
| | | } |
| | | done(); |
| | | }, |
| | | platformSearchReset() { |
| | | this.platformQuery = {}; |
| | | this.platformOnLoad(this.platformPage); |
| | | }, |
| | | platformSearchChange(params, done) { |
| | | this.platformQuery = params; |
| | | this.platformPage.currentPage = 1; |
| | | this.platformOnLoad(this.platformPage, params); |
| | | done(); |
| | | }, |
| | | platformSelectionChange(list) { |
| | | this.platformSelectionList = list; |
| | | }, |
| | | platformSelectionClear() { |
| | | this.platformSelectionList = []; |
| | | this.$refs.platformCrud.toggleSelection(); |
| | | }, |
| | | platformCurrentChange(currentPage) { |
| | | this.platformPage.currentPage = currentPage; |
| | | }, |
| | | platformSizeChange(pageSize) { |
| | | this.platformPage.pageSize = pageSize; |
| | | }, |
| | | platformRefreshChange() { |
| | | this.platformOnLoad(this.platformPage, this.platformQuery); |
| | | }, |
| | | platformOnLoad(page, params = {}) { |
| | | this.platformLoading = true; |
| | | getList( |
| | | page.currentPage, |
| | | page.pageSize, |
| | | // Object.assign(params, this.query), |
| | | Object.assign(params, { |
| | | ...this.query, |
| | | userType: 2 |
| | | }), |
| | | this.treeDeptId |
| | | ).then(res => { |
| | | const data = res.data.data; |
| | | this.platformPage.total = data.total; |
| | | this.platformData = data.records; |
| | | this.platformLoading = false; |
| | | this.selectionClear(); |
| | | }); |
| | | }, |
| | | }, |
| | | platformSearchChange(params, done) { |
| | | this.platformQuery = params; |
| | | this.platformPage.currentPage = 1; |
| | | this.platformOnLoad(this.platformPage, params); |
| | | done(); |
| | | }, |
| | | platformSelectionChange(list) { |
| | | this.platformSelectionList = list; |
| | | }, |
| | | platformSelectionClear() { |
| | | this.platformSelectionList = []; |
| | | this.$refs.platformCrud.toggleSelection(); |
| | | }, |
| | | platformCurrentChange(currentPage) { |
| | | this.platformPage.currentPage = currentPage; |
| | | }, |
| | | platformSizeChange(pageSize) { |
| | | this.platformPage.pageSize = pageSize; |
| | | }, |
| | | platformRefreshChange() { |
| | | this.platformOnLoad(this.platformPage, this.platformQuery); |
| | | }, |
| | | platformOnLoad(page, params = {}) { |
| | | this.platformLoading = true; |
| | | getList( |
| | | page.currentPage, |
| | | page.pageSize, |
| | | // Object.assign(params, this.query), |
| | | Object.assign(params, { |
| | | ...this.query, |
| | | userType: 2 |
| | | }), |
| | | this.treeDeptId |
| | | ).then(res => { |
| | | const data = res.data.data; |
| | | this.platformPage.total = data.total; |
| | | this.platformData = data.records; |
| | | this.platformLoading = false; |
| | | this.selectionClear(); |
| | | }); |
| | | }, |
| | | }, |
| | | }; |
| | | </script> |
| | | |
| | | |
| | | <style lang="scss" scoped> |
| | | .box { |
| | | height: 800px; |
| | | height: 800px; |
| | | } |
| | | |
| | | .el-scrollbar { |
| | | height: 100%; |
| | | height: 100%; |
| | | } |
| | | |
| | | .box .el-scrollbar__wrap { |
| | | overflow: scroll; |
| | | overflow: scroll; |
| | | } |
| | | |
| | | :deep() { |
| | | .el-tree-node__children { |
| | | .el-tree-node[aria-checked = 'false'] { |
| | | position: relative; |
| | | &::after, |
| | | &::before { |
| | | content: ''; |
| | | position: absolute; |
| | | } |
| | | .el-tree-node__children { |
| | | .el-tree-node[aria-checked = 'false'] { |
| | | position: relative; |
| | | |
| | | &::after { |
| | | top: 50%; |
| | | left: 11px; |
| | | width: 20px; |
| | | border: .5px dashed gray; |
| | | } |
| | | &::before { |
| | | top: 0; |
| | | height: 100%; |
| | | left: 11px; |
| | | border: .5px dashed gray; |
| | | } |
| | | &:last-child { |
| | | &::before { |
| | | height: 50%; |
| | | &::after, |
| | | &::before { |
| | | content: ''; |
| | | position: absolute; |
| | | } |
| | | |
| | | &::after { |
| | | top: 50%; |
| | | left: 11px; |
| | | width: 20px; |
| | | border: .5px dashed gray; |
| | | } |
| | | |
| | | &::before { |
| | | top: 0; |
| | | height: 100%; |
| | | left: 11px; |
| | | border: .5px dashed gray; |
| | | } |
| | | |
| | | &:last-child { |
| | | &::before { |
| | | height: 50%; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | </style> |
| | | |