| | |
| | | <template> |
| | | <basic-container> |
| | | <avue-crud |
| | | :option="option" |
| | | :table-loading="loading" |
| | | :data="data" |
| | | ref="crud" |
| | | v-model="form" |
| | | :permission="permissionList" |
| | | :before-open="beforeOpen" |
| | | @row-del="rowDel" |
| | | @row-update="rowUpdate" |
| | | @row-save="rowSave" |
| | | @search-change="searchChange" |
| | | @search-reset="searchReset" |
| | | @selection-change="selectionChange" |
| | | @current-change="currentChange" |
| | | @size-change="sizeChange" |
| | | @refresh-change="refreshChange" |
| | | @on-load="onLoad" |
| | | @tree-load="treeLoad" |
| | | > |
| | | <avue-crud :option="option" :table-loading="loading" :data="data" ref="crud" v-model="form" |
| | | :permission="permissionList" :before-open="beforeOpen" @row-del="rowDel" @row-update="rowUpdate" |
| | | @row-save="rowSave" @search-change="searchChange" @search-reset="searchReset" @selection-change="selectionChange" |
| | | @current-change="currentChange" @size-change="sizeChange" @refresh-change="refreshChange" @on-load="onLoad" |
| | | @tree-load="treeLoad"> |
| | | <template #menu="{ row }"> |
| | | <el-button |
| | | type="primary" |
| | | text |
| | | icon="el-icon-setting" |
| | | v-if="permission.api_scope_setting" |
| | | plain |
| | | style="border: 0; background-color: transparent !important" |
| | | @click.stop="handleDataScope(row)" |
| | | >权限配置 |
| | | <el-button type="primary" text icon="el-icon-setting" v-if="permission.api_scope_setting" plain |
| | | style="border: 0; background-color: transparent !important" @click.stop="handleDataScope(row)">权限配置 |
| | | </el-button> |
| | | </template> |
| | | <template #name="{ row }"> |
| | | <i :class="row.source" class="namei"/> |
| | | <i :class="row.source" class="namei" /> |
| | | <span>{{ row.name }}</span> |
| | | </template> |
| | | <template #source="{ row }"> |
| | |
| | | </div> |
| | | </template> |
| | | </avue-crud> |
| | | <el-drawer |
| | | :title="`[${scopeMenuName}] 接口权限配置`" |
| | | v-model="drawerVisible" |
| | | :direction="direction" |
| | | append-to-body |
| | | :before-close="handleDrawerClose" |
| | | size="1000px" |
| | | > |
| | | <el-drawer :title="`[${scopeMenuName}] 接口权限配置`" v-model="drawerVisible" :direction="direction" append-to-body |
| | | :before-close="handleDrawerClose" size="1000px"> |
| | | <basic-container> |
| | | <avue-crud |
| | | :option="optionScope" |
| | | :data="dataScope" |
| | | :page="pageScope" |
| | | v-model="formScope" |
| | | :table-loading="scopeLoading" |
| | | ref="crudScope" |
| | | @row-del="rowDelScope" |
| | | @row-update="rowUpdateScope" |
| | | @row-save="rowSaveScope" |
| | | :before-open="beforeOpenScope" |
| | | @search-change="searchChangeScope" |
| | | @search-reset="searchResetScope" |
| | | @selection-change="selectionChangeScope" |
| | | @current-change="currentChangeScope" |
| | | @size-change="sizeChangeScope" |
| | | @on-load="onLoadScope" |
| | | > |
| | | <avue-crud :option="optionScope" :data="dataScope" :page="pageScope" v-model="formScope" |
| | | :table-loading="scopeLoading" ref="crudScope" @row-del="rowDelScope" @row-update="rowUpdateScope" |
| | | @row-save="rowSaveScope" :before-open="beforeOpenScope" @search-change="searchChangeScope" |
| | | @search-reset="searchResetScope" @selection-change="selectionChangeScope" @current-change="currentChangeScope" |
| | | @size-change="sizeChangeScope" @on-load="onLoadScope"> |
| | | <template #menu-left> |
| | | <el-button type="danger" icon="el-icon-delete" plain @click="handleDeleteScope" |
| | | >删 除 |
| | | <el-button type="danger" icon="el-icon-delete" plain @click="handleDeleteScope">删 除 |
| | | </el-button> |
| | | </template> |
| | | <template #scopeType="{ row }"> |
| | |
| | | </template> |
| | | |
| | | <script> |
| | | import { add, remove, update, getLazyMenuList, getMenu } from '@/api/system/menu'; |
| | | import { add, remove, update, getLazyMenuList, getMenu } from '@/api/system/menu' |
| | | import { |
| | | addApiScope, |
| | | removeApiScope, |
| | | updateApiScope, |
| | | getListApiScope, |
| | | getMenuApiScope, |
| | | } from '@/api/system/scope'; |
| | | import { mapGetters } from 'vuex'; |
| | | import iconList from '@/config/iconList'; |
| | | } from '@/api/system/scope' |
| | | import { mapGetters } from 'vuex' |
| | | import iconList from '@/config/iconList' |
| | | |
| | | export default { |
| | | data() { |
| | | data () { |
| | | return { |
| | | form: {}, |
| | | selectionList: [], |
| | |
| | | delBtn: false, |
| | | menuWidth: 150, |
| | | dialogClickModal: false, |
| | | |
| | | height: 'auto', |
| | | calcHeight: 20, |
| | | |
| | | column: [ |
| | | { |
| | | label: '菜单名称', |
| | |
| | | ], |
| | | }, |
| | | dataScope: [], |
| | | }; |
| | | } |
| | | }, |
| | | |
| | | computed: { |
| | | ...mapGetters(['permission']), |
| | | permissionList() { |
| | | permissionList () { |
| | | return { |
| | | addBtn: this.validData(this.permission.menu_add, false), |
| | | viewBtn: this.validData(this.permission.menu_view, false), |
| | | delBtn: this.validData(this.permission.menu_delete, false), |
| | | editBtn: this.validData(this.permission.menu_edit, false), |
| | | }; |
| | | } |
| | | }, |
| | | ids() { |
| | | let ids = []; |
| | | ids () { |
| | | let ids = [] |
| | | this.selectionList.forEach(ele => { |
| | | ids.push(ele.id); |
| | | }); |
| | | return ids.join(','); |
| | | ids.push(ele.id) |
| | | }) |
| | | return ids.join(',') |
| | | }, |
| | | scopeIds() { |
| | | let ids = []; |
| | | scopeIds () { |
| | | let ids = [] |
| | | this.selectionListScope.forEach(ele => { |
| | | ids.push(ele.id); |
| | | }); |
| | | return ids.join(','); |
| | | ids.push(ele.id) |
| | | }) |
| | | return ids.join(',') |
| | | }, |
| | | }, |
| | | methods: { |
| | | // 菜单管理模块 |
| | | rowSave(row, done, loading) { |
| | | rowSave (row, done, loading) { |
| | | add(row).then( |
| | | () => { |
| | | this.onLoad(this.page); |
| | | this.onLoad(this.page) |
| | | this.$message({ |
| | | type: 'success', |
| | | message: '操作成功!', |
| | | }); |
| | | done(); |
| | | }) |
| | | done() |
| | | }, |
| | | error => { |
| | | window.console.log(error); |
| | | loading(); |
| | | window.console.log(error) |
| | | loading() |
| | | } |
| | | ); |
| | | ) |
| | | }, |
| | | rowUpdate(row, index, done, loading) { |
| | | rowUpdate (row, index, done, loading) { |
| | | update(row).then( |
| | | () => { |
| | | this.onLoad(this.page); |
| | | this.onLoad(this.page) |
| | | this.$message({ |
| | | type: 'success', |
| | | message: '操作成功!', |
| | | }); |
| | | done(); |
| | | }) |
| | | done() |
| | | }, |
| | | error => { |
| | | window.console.log(error); |
| | | loading(); |
| | | window.console.log(error) |
| | | loading() |
| | | } |
| | | ); |
| | | ) |
| | | }, |
| | | rowDel(row) { |
| | | rowDel (row) { |
| | | this.$confirm('确定将选择数据删除?', { |
| | | confirmButtonText: '确定', |
| | | cancelButtonText: '取消', |
| | | type: 'warning', |
| | | }) |
| | | .then(() => { |
| | | return remove(row.id); |
| | | return remove(row.id) |
| | | }) |
| | | .then(() => { |
| | | this.onLoad(this.page); |
| | | this.onLoad(this.page) |
| | | this.$message({ |
| | | type: 'success', |
| | | message: '操作成功!', |
| | | }); |
| | | }); |
| | | }) |
| | | }) |
| | | }, |
| | | searchReset() { |
| | | this.query = {}; |
| | | this.parentId = 0; |
| | | this.onLoad(this.page); |
| | | searchReset () { |
| | | this.query = {} |
| | | this.parentId = 0 |
| | | this.onLoad(this.page) |
| | | }, |
| | | searchChange(params, done) { |
| | | this.query = params; |
| | | this.parentId = ''; |
| | | this.page.currentPage = 1; |
| | | this.onLoad(this.page, params); |
| | | done(); |
| | | searchChange (params, done) { |
| | | this.query = params |
| | | this.parentId = '' |
| | | this.page.currentPage = 1 |
| | | this.onLoad(this.page, params) |
| | | done() |
| | | }, |
| | | selectionChange(list) { |
| | | this.selectionList = list; |
| | | selectionChange (list) { |
| | | this.selectionList = list |
| | | }, |
| | | selectionClear() { |
| | | this.selectionList = []; |
| | | this.$refs.crud.toggleSelection(); |
| | | selectionClear () { |
| | | this.selectionList = [] |
| | | this.$refs.crud.toggleSelection() |
| | | }, |
| | | handleDelete() { |
| | | handleDelete () { |
| | | if (this.selectionList.length === 0) { |
| | | this.$message.warning('请选择至少一条数据'); |
| | | return; |
| | | this.$message.warning('请选择至少一条数据') |
| | | return |
| | | } |
| | | this.$confirm('确定将选择数据删除?', { |
| | | confirmButtonText: '确定', |
| | |
| | | type: 'warning', |
| | | }) |
| | | .then(() => { |
| | | return remove(this.ids); |
| | | return remove(this.ids) |
| | | }) |
| | | .then(() => { |
| | | this.onLoad(this.page); |
| | | this.onLoad(this.page) |
| | | this.$message({ |
| | | type: 'success', |
| | | message: '操作成功!', |
| | | }); |
| | | this.$refs.crud.toggleSelection(); |
| | | }); |
| | | }) |
| | | this.$refs.crud.toggleSelection() |
| | | }) |
| | | }, |
| | | beforeOpen(done, type) { |
| | | beforeOpen (done, type) { |
| | | if (['edit', 'view'].includes(type)) { |
| | | getMenu(this.form.id).then(res => { |
| | | this.form = res.data.data; |
| | | }); |
| | | this.form = res.data.data |
| | | }) |
| | | } |
| | | done(); |
| | | done() |
| | | }, |
| | | currentChange(currentPage) { |
| | | this.page.currentPage = currentPage; |
| | | currentChange (currentPage) { |
| | | this.page.currentPage = currentPage |
| | | }, |
| | | sizeChange(pageSize) { |
| | | this.page.pageSize = pageSize; |
| | | sizeChange (pageSize) { |
| | | this.page.pageSize = pageSize |
| | | }, |
| | | refreshChange() { |
| | | this.onLoad(this.page, this.query); |
| | | refreshChange () { |
| | | this.onLoad(this.page, this.query) |
| | | }, |
| | | onLoad(page, params = {}) { |
| | | this.loading = true; |
| | | onLoad (page, params = {}) { |
| | | this.loading = true |
| | | getLazyMenuList(this.parentId, Object.assign(params, this.query)).then(res => { |
| | | this.data = res.data.data; |
| | | this.loading = false; |
| | | this.selectionClear(); |
| | | }); |
| | | this.data = res.data.data |
| | | this.loading = false |
| | | this.selectionClear() |
| | | }) |
| | | }, |
| | | treeLoad(tree, treeNode, resolve) { |
| | | const parentId = tree.id; |
| | | treeLoad (tree, treeNode, resolve) { |
| | | const parentId = tree.id |
| | | getLazyMenuList(parentId).then(res => { |
| | | resolve(res.data.data); |
| | | }); |
| | | resolve(res.data.data) |
| | | }) |
| | | }, |
| | | // 数据权限模块 |
| | | handleDataScope(row) { |
| | | this.drawerVisible = true; |
| | | this.scopeMenuId = row.id; |
| | | this.scopeMenuName = row.name; |
| | | this.onLoadScope(this.pageScope); |
| | | handleDataScope (row) { |
| | | this.drawerVisible = true |
| | | this.scopeMenuId = row.id |
| | | this.scopeMenuName = row.name |
| | | this.onLoadScope(this.pageScope) |
| | | }, |
| | | handleDrawerClose(hide) { |
| | | hide(); |
| | | handleDrawerClose (hide) { |
| | | hide() |
| | | }, |
| | | rowSaveScope(row, done, loading) { |
| | | rowSaveScope (row, done, loading) { |
| | | row = { |
| | | ...row, |
| | | menuId: this.scopeMenuId, |
| | | }; |
| | | } |
| | | addApiScope(row).then( |
| | | () => { |
| | | this.onLoadScope(this.pageScope); |
| | | this.onLoadScope(this.pageScope) |
| | | this.$message({ |
| | | type: 'success', |
| | | message: '操作成功!', |
| | | }); |
| | | done(); |
| | | }) |
| | | done() |
| | | }, |
| | | error => { |
| | | window.console.log(error); |
| | | loading(); |
| | | window.console.log(error) |
| | | loading() |
| | | } |
| | | ); |
| | | ) |
| | | }, |
| | | rowUpdateScope(row, index, done, loading) { |
| | | rowUpdateScope (row, index, done, loading) { |
| | | row = { |
| | | ...row, |
| | | menuId: this.scopeMenuId, |
| | | }; |
| | | } |
| | | updateApiScope(row).then( |
| | | () => { |
| | | this.onLoadScope(this.pageScope); |
| | | this.onLoadScope(this.pageScope) |
| | | this.$message({ |
| | | type: 'success', |
| | | message: '操作成功!', |
| | | }); |
| | | done(); |
| | | }) |
| | | done() |
| | | }, |
| | | error => { |
| | | window.console.log(error); |
| | | loading(); |
| | | window.console.log(error) |
| | | loading() |
| | | } |
| | | ); |
| | | ) |
| | | }, |
| | | rowDelScope(row) { |
| | | rowDelScope (row) { |
| | | this.$confirm('确定将选择数据删除?', { |
| | | confirmButtonText: '确定', |
| | | cancelButtonText: '取消', |
| | | type: 'warning', |
| | | }) |
| | | .then(() => { |
| | | return removeApiScope(row.id); |
| | | return removeApiScope(row.id) |
| | | }) |
| | | .then(() => { |
| | | this.onLoadScope(this.pageScope); |
| | | this.onLoadScope(this.pageScope) |
| | | this.$message({ |
| | | type: 'success', |
| | | message: '操作成功!', |
| | | }); |
| | | }); |
| | | }) |
| | | }) |
| | | }, |
| | | handleDeleteScope() { |
| | | handleDeleteScope () { |
| | | if (this.selectionListScope.length === 0) { |
| | | this.$message.warning('请选择至少一条数据'); |
| | | return; |
| | | this.$message.warning('请选择至少一条数据') |
| | | return |
| | | } |
| | | this.$confirm('确定将选择数据删除?', { |
| | | confirmButtonText: '确定', |
| | |
| | | type: 'warning', |
| | | }) |
| | | .then(() => { |
| | | return removeApiScope(this.scopeIds); |
| | | return removeApiScope(this.scopeIds) |
| | | }) |
| | | .then(() => { |
| | | this.onLoadScope(this.pageScope); |
| | | this.onLoadScope(this.pageScope) |
| | | this.$message({ |
| | | type: 'success', |
| | | message: '操作成功!', |
| | | }); |
| | | this.$refs.crudScope.toggleSelection(); |
| | | }); |
| | | }) |
| | | this.$refs.crudScope.toggleSelection() |
| | | }) |
| | | }, |
| | | beforeOpenScope(done, type) { |
| | | beforeOpenScope (done, type) { |
| | | if (['edit', 'view'].includes(type)) { |
| | | getMenuApiScope(this.formScope.id).then(res => { |
| | | this.formScope = res.data.data; |
| | | }); |
| | | this.formScope = res.data.data |
| | | }) |
| | | } |
| | | done(); |
| | | done() |
| | | }, |
| | | searchResetScope() { |
| | | this.onLoadScope(this.pageScope); |
| | | searchResetScope () { |
| | | this.onLoadScope(this.pageScope) |
| | | }, |
| | | searchChangeScope(params, done) { |
| | | this.onLoadScope(this.pageScope, params); |
| | | done(); |
| | | searchChangeScope (params, done) { |
| | | this.onLoadScope(this.pageScope, params) |
| | | done() |
| | | }, |
| | | selectionChangeScope(list) { |
| | | this.selectionListScope = list; |
| | | selectionChangeScope (list) { |
| | | this.selectionListScope = list |
| | | }, |
| | | currentChangeScope(currentPage) { |
| | | this.pageScope.currentPage = currentPage; |
| | | currentChangeScope (currentPage) { |
| | | this.pageScope.currentPage = currentPage |
| | | }, |
| | | sizeChangeScope(pageSize) { |
| | | this.pageScope.pageSize = pageSize; |
| | | sizeChangeScope (pageSize) { |
| | | this.pageScope.pageSize = pageSize |
| | | }, |
| | | onLoadScope(page, params = {}) { |
| | | this.scopeLoading = true; |
| | | onLoadScope (page, params = {}) { |
| | | this.scopeLoading = true |
| | | const values = { |
| | | ...params, |
| | | menuId: this.scopeMenuId, |
| | | }; |
| | | } |
| | | getListApiScope(page.currentPage, page.pageSize, Object.assign(values, this.query)).then( |
| | | res => { |
| | | const data = res.data.data; |
| | | this.pageScope.total = data.total; |
| | | this.dataScope = data.records; |
| | | this.selectionListScope = []; |
| | | this.scopeLoading = false; |
| | | const data = res.data.data |
| | | this.pageScope.total = data.total |
| | | this.dataScope = data.records |
| | | this.selectionListScope = [] |
| | | this.scopeLoading = false |
| | | } |
| | | ); |
| | | ) |
| | | }, |
| | | }, |
| | | }; |
| | | } |
| | | </script> |
| | | |
| | | <style scoped lang="scss"> |
| | |
| | | <template> |
| | | <basic-container> |
| | | <avue-crud |
| | | :option="option" |
| | | :table-loading="loading" |
| | | :data="data" |
| | | ref="crud" |
| | | v-model="form" |
| | | :permission="permissionList" |
| | | :before-open="beforeOpen" |
| | | :before-close="beforeClose" |
| | | @row-del="rowDel" |
| | | @row-update="rowUpdate" |
| | | @row-save="rowSave" |
| | | @search-change="searchChange" |
| | | @search-reset="searchReset" |
| | | @selection-change="selectionChange" |
| | | @current-change="currentChange" |
| | | @size-change="sizeChange" |
| | | @refresh-change="refreshChange" |
| | | @on-load="onLoad" |
| | | @tree-load="treeLoad" |
| | | > |
| | | <avue-crud :option="option" :table-loading="loading" :data="data" ref="crud" v-model="form" |
| | | :permission="permissionList" :before-open="beforeOpen" :before-close="beforeClose" @row-del="rowDel" |
| | | @row-update="rowUpdate" @row-save="rowSave" @search-change="searchChange" @search-reset="searchReset" |
| | | @selection-change="selectionChange" @current-change="currentChange" @size-change="sizeChange" |
| | | @refresh-change="refreshChange" @on-load="onLoad" @tree-load="treeLoad"> |
| | | <template #menu="{ row }"> |
| | | <el-button |
| | | type="primary" |
| | | text |
| | | icon="el-icon-setting" |
| | | v-if="permission.data_scope_setting" |
| | | plain |
| | | style="border: 0; background-color: transparent !important" |
| | | @click.stop="handleDataScope(row)" |
| | | >权限配置 |
| | | <el-button type="primary" text icon="el-icon-setting" v-if="permission.data_scope_setting" plain |
| | | style="border: 0; background-color: transparent !important" @click.stop="handleDataScope(row)">权限配置 |
| | | </el-button> |
| | | </template> |
| | | <template #name="{ row }"> |
| | | <i :class="row.source" class="namei" /> |
| | | <i :class="row.source" class="namei" /> |
| | | <span>{{ row.name }}</span> |
| | | </template> |
| | | <template #source="{ row }"> |
| | |
| | | </div> |
| | | </template> |
| | | </avue-crud> |
| | | <el-drawer |
| | | :title="`[${scopeMenuName}] 数据权限配置`" |
| | | v-model="drawerVisible" |
| | | :direction="direction" |
| | | append-to-body |
| | | :before-close="handleDrawerClose" |
| | | size="1000px" |
| | | > |
| | | <el-drawer :title="`[${scopeMenuName}] 数据权限配置`" v-model="drawerVisible" :direction="direction" append-to-body |
| | | :before-close="handleDrawerClose" size="1000px"> |
| | | <basic-container> |
| | | <avue-crud |
| | | :option="optionScope" |
| | | :data="dataScope" |
| | | :page="pageScope" |
| | | v-model="formScope" |
| | | :table-loading="scopeLoading" |
| | | ref="crudScope" |
| | | @row-del="rowDelScope" |
| | | @row-update="rowUpdateScope" |
| | | @row-save="rowSaveScope" |
| | | :before-open="beforeOpenScope" |
| | | @search-change="searchChangeScope" |
| | | @search-reset="searchResetScope" |
| | | @selection-change="selectionChangeScope" |
| | | @current-change="currentChangeScope" |
| | | @size-change="sizeChangeScope" |
| | | @on-load="onLoadScope" |
| | | > |
| | | <avue-crud :option="optionScope" :data="dataScope" :page="pageScope" v-model="formScope" |
| | | :table-loading="scopeLoading" ref="crudScope" @row-del="rowDelScope" @row-update="rowUpdateScope" |
| | | @row-save="rowSaveScope" :before-open="beforeOpenScope" @search-change="searchChangeScope" |
| | | @search-reset="searchResetScope" @selection-change="selectionChangeScope" @current-change="currentChangeScope" |
| | | @size-change="sizeChangeScope" @on-load="onLoadScope"> |
| | | <template #menu-left> |
| | | <el-button type="danger" icon="el-icon-delete" plain @click="handleDeleteScope" |
| | | >删 除 |
| | | <el-button type="danger" icon="el-icon-delete" plain @click="handleDeleteScope">删 除 |
| | | </el-button> |
| | | </template> |
| | | <template #scopeType="{ row }"> |
| | |
| | | </template> |
| | | |
| | | <script> |
| | | import { add, remove, update, getLazyMenuList, getMenu } from '@/api/system/menu'; |
| | | import { add, remove, update, getLazyMenuList, getMenu } from '@/api/system/menu' |
| | | import { |
| | | addDataScope, |
| | | removeDataScope, |
| | | updateDataScope, |
| | | getListDataScope, |
| | | getMenuDataScope, |
| | | } from '@/api/system/scope'; |
| | | import { mapGetters } from 'vuex'; |
| | | import iconList from '@/config/iconList'; |
| | | import func from '@/utils/func'; |
| | | } from '@/api/system/scope' |
| | | import { mapGetters } from 'vuex' |
| | | import iconList from '@/config/iconList' |
| | | import func from '@/utils/func' |
| | | |
| | | export default { |
| | | data() { |
| | | data () { |
| | | return { |
| | | form: {}, |
| | | selectionList: [], |
| | |
| | | delBtn: false, |
| | | menuWidth: 150, |
| | | dialogClickModal: false, |
| | | |
| | | height: 'auto', |
| | | calcHeight: 20, |
| | | |
| | | column: [ |
| | | { |
| | | label: '菜单名称', |
| | |
| | | ], |
| | | }, |
| | | dataScope: [], |
| | | }; |
| | | } |
| | | }, |
| | | watch: { |
| | | 'formScope.scopeType'() { |
| | | this.initScope(); |
| | | 'formScope.scopeType' () { |
| | | this.initScope() |
| | | }, |
| | | }, |
| | | computed: { |
| | | ...mapGetters(['permission']), |
| | | permissionList() { |
| | | permissionList () { |
| | | return { |
| | | addBtn: this.validData(this.permission.menu_add, false), |
| | | viewBtn: this.validData(this.permission.menu_view, false), |
| | | delBtn: this.validData(this.permission.menu_delete, false), |
| | | editBtn: this.validData(this.permission.menu_edit, false), |
| | | }; |
| | | } |
| | | }, |
| | | ids() { |
| | | let ids = []; |
| | | ids () { |
| | | let ids = [] |
| | | this.selectionList.forEach(ele => { |
| | | ids.push(ele.id); |
| | | }); |
| | | return ids.join(','); |
| | | ids.push(ele.id) |
| | | }) |
| | | return ids.join(',') |
| | | }, |
| | | scopeIds() { |
| | | let ids = []; |
| | | scopeIds () { |
| | | let ids = [] |
| | | this.selectionListScope.forEach(ele => { |
| | | ids.push(ele.id); |
| | | }); |
| | | return ids.join(','); |
| | | ids.push(ele.id) |
| | | }) |
| | | return ids.join(',') |
| | | }, |
| | | }, |
| | | methods: { |
| | | initScope() { |
| | | const scopeType = func.toInt(this.formScope.scopeType); |
| | | const watchMode = this.watchMode; |
| | | initScope () { |
| | | const scopeType = func.toInt(this.formScope.scopeType) |
| | | const watchMode = this.watchMode |
| | | let column = '-', |
| | | name = '暂无'; |
| | | name = '暂无' |
| | | if (scopeType === 1) { |
| | | column = '-'; |
| | | name = '全部可见'; |
| | | column = '-' |
| | | name = '全部可见' |
| | | } else if (scopeType === 2) { |
| | | column = 'create_user'; |
| | | name = '本人可见'; |
| | | column = 'create_user' |
| | | name = '本人可见' |
| | | } else if (scopeType === 3) { |
| | | column = 'create_dept'; |
| | | name = '所在机构可见'; |
| | | column = 'create_dept' |
| | | name = '所在机构可见' |
| | | } else if (scopeType === 4) { |
| | | column = 'create_dept'; |
| | | name = '所在机构可见及子级可见'; |
| | | column = 'create_dept' |
| | | name = '所在机构可见及子级可见' |
| | | } else if (scopeType === 5) { |
| | | column = ''; |
| | | name = '自定义'; |
| | | column = '' |
| | | name = '自定义' |
| | | } |
| | | this.$refs.crudScope.option.column.filter(item => { |
| | | if (watchMode) { |
| | | if (item.prop === 'scopeName') { |
| | | this.formScope.scopeName = `${this.scopeMenuName} [${name}]`; |
| | | this.formScope.scopeName = `${this.scopeMenuName} [${name}]` |
| | | } |
| | | if (item.prop === 'resourceCode') { |
| | | this.formScope.resourceCode = this.scopeMenuCode; |
| | | this.formScope.resourceCode = this.scopeMenuCode |
| | | } |
| | | if (item.prop === 'scopeColumn') { |
| | | this.formScope.scopeColumn = column; |
| | | this.formScope.scopeColumn = column |
| | | } |
| | | } |
| | | if (item.prop === 'scopeValue') { |
| | | item.display = scopeType === 5; |
| | | item.display = scopeType === 5 |
| | | } |
| | | }); |
| | | }) |
| | | }, |
| | | // 菜单管理模块 |
| | | rowSave(row, done, loading) { |
| | | rowSave (row, done, loading) { |
| | | add(row).then( |
| | | () => { |
| | | this.onLoad(this.page); |
| | | this.onLoad(this.page) |
| | | this.$message({ |
| | | type: 'success', |
| | | message: '操作成功!', |
| | | }); |
| | | done(); |
| | | }) |
| | | done() |
| | | }, |
| | | error => { |
| | | window.console.log(error); |
| | | loading(); |
| | | window.console.log(error) |
| | | loading() |
| | | } |
| | | ); |
| | | ) |
| | | }, |
| | | rowUpdate(row, index, done, loading) { |
| | | rowUpdate (row, index, done, loading) { |
| | | update(row).then( |
| | | () => { |
| | | this.onLoad(this.page); |
| | | this.onLoad(this.page) |
| | | this.$message({ |
| | | type: 'success', |
| | | message: '操作成功!', |
| | | }); |
| | | done(); |
| | | }) |
| | | done() |
| | | }, |
| | | error => { |
| | | window.console.log(error); |
| | | loading(); |
| | | window.console.log(error) |
| | | loading() |
| | | } |
| | | ); |
| | | ) |
| | | }, |
| | | rowDel(row) { |
| | | rowDel (row) { |
| | | this.$confirm('确定将选择数据删除?', { |
| | | confirmButtonText: '确定', |
| | | cancelButtonText: '取消', |
| | | type: 'warning', |
| | | }) |
| | | .then(() => { |
| | | return remove(row.id); |
| | | return remove(row.id) |
| | | }) |
| | | .then(() => { |
| | | this.onLoad(this.page); |
| | | this.onLoad(this.page) |
| | | this.$message({ |
| | | type: 'success', |
| | | message: '操作成功!', |
| | | }); |
| | | }); |
| | | }) |
| | | }) |
| | | }, |
| | | searchReset() { |
| | | this.query = {}; |
| | | this.parentId = 0; |
| | | this.onLoad(this.page); |
| | | searchReset () { |
| | | this.query = {} |
| | | this.parentId = 0 |
| | | this.onLoad(this.page) |
| | | }, |
| | | searchChange(params, done) { |
| | | this.query = params; |
| | | this.parentId = ''; |
| | | this.page.currentPage = 1; |
| | | this.onLoad(this.page, params); |
| | | done(); |
| | | searchChange (params, done) { |
| | | this.query = params |
| | | this.parentId = '' |
| | | this.page.currentPage = 1 |
| | | this.onLoad(this.page, params) |
| | | done() |
| | | }, |
| | | selectionChange(list) { |
| | | this.selectionList = list; |
| | | selectionChange (list) { |
| | | this.selectionList = list |
| | | }, |
| | | selectionClear() { |
| | | this.selectionList = []; |
| | | this.$refs.crud.toggleSelection(); |
| | | selectionClear () { |
| | | this.selectionList = [] |
| | | this.$refs.crud.toggleSelection() |
| | | }, |
| | | handleDelete() { |
| | | handleDelete () { |
| | | if (this.selectionList.length === 0) { |
| | | this.$message.warning('请选择至少一条数据'); |
| | | return; |
| | | this.$message.warning('请选择至少一条数据') |
| | | return |
| | | } |
| | | this.$confirm('确定将选择数据删除?', { |
| | | confirmButtonText: '确定', |
| | |
| | | type: 'warning', |
| | | }) |
| | | .then(() => { |
| | | return remove(this.ids); |
| | | return remove(this.ids) |
| | | }) |
| | | .then(() => { |
| | | this.onLoad(this.page); |
| | | this.onLoad(this.page) |
| | | this.$message({ |
| | | type: 'success', |
| | | message: '操作成功!', |
| | | }); |
| | | this.$refs.crud.toggleSelection(); |
| | | }); |
| | | }) |
| | | this.$refs.crud.toggleSelection() |
| | | }) |
| | | }, |
| | | beforeOpen(done, type) { |
| | | beforeOpen (done, type) { |
| | | if (['edit', 'view'].includes(type)) { |
| | | getMenu(this.form.id).then(res => { |
| | | this.form = res.data.data; |
| | | }); |
| | | this.form = res.data.data |
| | | }) |
| | | } |
| | | done(); |
| | | done() |
| | | }, |
| | | beforeClose(done) { |
| | | this.formScope = {}; |
| | | done(); |
| | | beforeClose (done) { |
| | | this.formScope = {} |
| | | done() |
| | | }, |
| | | currentChange(currentPage) { |
| | | this.page.currentPage = currentPage; |
| | | currentChange (currentPage) { |
| | | this.page.currentPage = currentPage |
| | | }, |
| | | sizeChange(pageSize) { |
| | | this.page.pageSize = pageSize; |
| | | sizeChange (pageSize) { |
| | | this.page.pageSize = pageSize |
| | | }, |
| | | refreshChange() { |
| | | this.onLoad(this.page, this.query); |
| | | refreshChange () { |
| | | this.onLoad(this.page, this.query) |
| | | }, |
| | | onLoad(page, params = {}) { |
| | | this.loading = true; |
| | | onLoad (page, params = {}) { |
| | | this.loading = true |
| | | getLazyMenuList(this.parentId, Object.assign(params, this.query)).then(res => { |
| | | this.data = res.data.data; |
| | | this.loading = false; |
| | | this.selectionClear(); |
| | | }); |
| | | this.data = res.data.data |
| | | this.loading = false |
| | | this.selectionClear() |
| | | }) |
| | | }, |
| | | treeLoad(tree, treeNode, resolve) { |
| | | const parentId = tree.id; |
| | | treeLoad (tree, treeNode, resolve) { |
| | | const parentId = tree.id |
| | | getLazyMenuList(parentId).then(res => { |
| | | resolve(res.data.data); |
| | | }); |
| | | resolve(res.data.data) |
| | | }) |
| | | }, |
| | | // 数据权限模块 |
| | | handleDataScope(row) { |
| | | this.drawerVisible = true; |
| | | this.scopeMenuId = row.id; |
| | | this.scopeMenuCode = row.code; |
| | | this.scopeMenuName = row.name; |
| | | this.onLoadScope(this.pageScope); |
| | | handleDataScope (row) { |
| | | this.drawerVisible = true |
| | | this.scopeMenuId = row.id |
| | | this.scopeMenuCode = row.code |
| | | this.scopeMenuName = row.name |
| | | this.onLoadScope(this.pageScope) |
| | | }, |
| | | handleDrawerClose(hide) { |
| | | hide(); |
| | | handleDrawerClose (hide) { |
| | | hide() |
| | | }, |
| | | rowSaveScope(row, done, loading) { |
| | | rowSaveScope (row, done, loading) { |
| | | row = { |
| | | ...row, |
| | | menuId: this.scopeMenuId, |
| | | }; |
| | | } |
| | | addDataScope(row).then( |
| | | () => { |
| | | this.onLoadScope(this.pageScope); |
| | | this.onLoadScope(this.pageScope) |
| | | this.$message({ |
| | | type: 'success', |
| | | message: '操作成功!', |
| | | }); |
| | | done(); |
| | | }) |
| | | done() |
| | | }, |
| | | error => { |
| | | window.console.log(error); |
| | | loading(); |
| | | window.console.log(error) |
| | | loading() |
| | | } |
| | | ); |
| | | ) |
| | | }, |
| | | rowUpdateScope(row, index, done, loading) { |
| | | rowUpdateScope (row, index, done, loading) { |
| | | row = { |
| | | ...row, |
| | | menuId: this.scopeMenuId, |
| | | }; |
| | | } |
| | | updateDataScope(row).then( |
| | | () => { |
| | | this.onLoadScope(this.pageScope); |
| | | this.onLoadScope(this.pageScope) |
| | | this.$message({ |
| | | type: 'success', |
| | | message: '操作成功!', |
| | | }); |
| | | done(); |
| | | }) |
| | | done() |
| | | }, |
| | | error => { |
| | | window.console.log(error); |
| | | loading(); |
| | | window.console.log(error) |
| | | loading() |
| | | } |
| | | ); |
| | | ) |
| | | }, |
| | | rowDelScope(row) { |
| | | rowDelScope (row) { |
| | | this.$confirm('确定将选择数据删除?', { |
| | | confirmButtonText: '确定', |
| | | cancelButtonText: '取消', |
| | | type: 'warning', |
| | | }) |
| | | .then(() => { |
| | | return removeDataScope(row.id); |
| | | return removeDataScope(row.id) |
| | | }) |
| | | .then(() => { |
| | | this.onLoadScope(this.pageScope); |
| | | this.onLoadScope(this.pageScope) |
| | | this.$message({ |
| | | type: 'success', |
| | | message: '操作成功!', |
| | | }); |
| | | }); |
| | | }) |
| | | }) |
| | | }, |
| | | handleDeleteScope() { |
| | | handleDeleteScope () { |
| | | if (this.selectionListScope.length === 0) { |
| | | this.$message.warning('请选择至少一条数据'); |
| | | return; |
| | | this.$message.warning('请选择至少一条数据') |
| | | return |
| | | } |
| | | this.$confirm('确定将选择数据删除?', { |
| | | confirmButtonText: '确定', |
| | |
| | | type: 'warning', |
| | | }) |
| | | .then(() => { |
| | | return removeDataScope(this.scopeIds); |
| | | return removeDataScope(this.scopeIds) |
| | | }) |
| | | .then(() => { |
| | | this.onLoadScope(this.pageScope); |
| | | this.onLoadScope(this.pageScope) |
| | | this.$message({ |
| | | type: 'success', |
| | | message: '操作成功!', |
| | | }); |
| | | this.$refs.crudScope.toggleSelection(); |
| | | }); |
| | | }) |
| | | this.$refs.crudScope.toggleSelection() |
| | | }) |
| | | }, |
| | | beforeOpenScope(done, type) { |
| | | beforeOpenScope (done, type) { |
| | | if (['add'].includes(type)) { |
| | | this.watchMode = true; |
| | | this.initScope(); |
| | | this.watchMode = true |
| | | this.initScope() |
| | | } |
| | | if (['edit', 'view'].includes(type)) { |
| | | this.watchMode = false; |
| | | this.watchMode = false |
| | | getMenuDataScope(this.formScope.id).then(res => { |
| | | this.formScope = res.data.data; |
| | | }); |
| | | this.formScope = res.data.data |
| | | }) |
| | | } |
| | | done(); |
| | | done() |
| | | }, |
| | | searchResetScope() { |
| | | this.onLoadScope(this.pageScope); |
| | | searchResetScope () { |
| | | this.onLoadScope(this.pageScope) |
| | | }, |
| | | searchChangeScope(params, done) { |
| | | this.onLoadScope(this.pageScope, params); |
| | | done(); |
| | | searchChangeScope (params, done) { |
| | | this.onLoadScope(this.pageScope, params) |
| | | done() |
| | | }, |
| | | selectionChangeScope(list) { |
| | | this.selectionListScope = list; |
| | | selectionChangeScope (list) { |
| | | this.selectionListScope = list |
| | | }, |
| | | currentChangeScope(currentPage) { |
| | | this.pageScope.currentPage = currentPage; |
| | | currentChangeScope (currentPage) { |
| | | this.pageScope.currentPage = currentPage |
| | | }, |
| | | sizeChangeScope(pageSize) { |
| | | this.pageScope.pageSize = pageSize; |
| | | sizeChangeScope (pageSize) { |
| | | this.pageScope.pageSize = pageSize |
| | | }, |
| | | onLoadScope(page, params = {}) { |
| | | this.scopeLoading = true; |
| | | onLoadScope (page, params = {}) { |
| | | this.scopeLoading = true |
| | | const values = { |
| | | ...params, |
| | | menuId: this.scopeMenuId, |
| | | }; |
| | | } |
| | | getListDataScope(page.currentPage, page.pageSize, Object.assign(values, this.query)).then( |
| | | res => { |
| | | const data = res.data.data; |
| | | this.pageScope.total = data.total; |
| | | this.dataScope = data.records; |
| | | this.selectionListScope = []; |
| | | this.scopeLoading = false; |
| | | const data = res.data.data |
| | | this.pageScope.total = data.total |
| | | this.dataScope = data.records |
| | | this.selectionListScope = [] |
| | | this.scopeLoading = false |
| | | } |
| | | ); |
| | | ) |
| | | }, |
| | | }, |
| | | }; |
| | | } |
| | | </script> |
| | | |
| | | <style scoped lang="scss"> |
| | |
| | | <template> |
| | | <basic-container> |
| | | <avue-crud |
| | | :option="option" |
| | | :table-loading="loading" |
| | | :data="data" |
| | | ref="crud" |
| | | v-model="form" |
| | | :permission="permissionList" |
| | | :before-open="beforeOpen" |
| | | @row-del="rowDel" |
| | | @row-update="rowUpdate" |
| | | @row-save="rowSave" |
| | | @search-change="searchChange" |
| | | @search-reset="searchReset" |
| | | @selection-change="selectionChange" |
| | | @current-change="currentChange" |
| | | @size-change="sizeChange" |
| | | @refresh-change="refreshChange" |
| | | @on-load="onLoad" |
| | | > |
| | | <avue-crud :option="option" :table-loading="loading" :data="data" ref="crud" v-model="form" |
| | | :permission="permissionList" :before-open="beforeOpen" @row-del="rowDel" @row-update="rowUpdate" |
| | | @row-save="rowSave" @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" |
| | | icon="el-icon-delete" |
| | | v-if="permission.role_delete" |
| | | plain |
| | | @click="handleDelete" |
| | | >删 除 |
| | | <el-button type="danger" icon="el-icon-delete" v-if="permission.role_delete" plain @click="handleDelete">删 除 |
| | | </el-button> |
| | | <el-button |
| | | icon="el-icon-setting" |
| | | v-if="userInfo.role_name.includes('admin')" |
| | | @click="handleRole" |
| | | plain |
| | | >权限设置 |
| | | <el-button icon="el-icon-setting" v-if="userInfo.role_name.includes('admin')" @click="handleRole" plain>权限设置 |
| | | </el-button> |
| | | <!-- --> |
| | | </template> |
| | |
| | | <el-dialog title="角色权限配置" append-to-body v-model="box" width="345px"> |
| | | <el-tabs type="border-card"> |
| | | <el-tab-pane label="菜单权限"> |
| | | <el-tree |
| | | :data="menuGrantList" |
| | | show-checkbox |
| | | node-key="id" |
| | | ref="treeMenu" |
| | | :default-checked-keys="menuTreeObj" |
| | | :props="props" |
| | | > |
| | | <el-tree :data="menuGrantList" show-checkbox node-key="id" ref="treeMenu" :default-checked-keys="menuTreeObj" |
| | | :props="props"> |
| | | </el-tree> |
| | | </el-tab-pane> |
| | | <!-- <el-tab-pane label="数据权限"> |
| | |
| | | grantTree, |
| | | remove, |
| | | update, |
| | | } from '@/api/system/role'; |
| | | import { mapGetters } from 'vuex'; |
| | | import website from '@/config/website'; |
| | | } from '@/api/system/role' |
| | | import { mapGetters } from 'vuex' |
| | | import website from '@/config/website' |
| | | |
| | | export default { |
| | | data() { |
| | | data () { |
| | | return { |
| | | form: {}, |
| | | box: false, |
| | |
| | | viewBtn: true, |
| | | dialogWidth: 900, |
| | | dialogClickModal: false, |
| | | |
| | | height: 'auto', |
| | | calcHeight: 20, |
| | | |
| | | column: [ |
| | | { |
| | | label: '角色名称', |
| | |
| | | ], |
| | | }, |
| | | data: [], |
| | | }; |
| | | } |
| | | }, |
| | | computed: { |
| | | ...mapGetters(['userInfo', 'permission']), |
| | | permissionList() { |
| | | permissionList () { |
| | | return { |
| | | addBtn: this.validData(this.permission.role_add, false), |
| | | viewBtn: this.validData(this.permission.role_view, false), |
| | | delBtn: this.validData(this.permission.role_delete, false), |
| | | editBtn: this.validData(this.permission.role_edit, false), |
| | | }; |
| | | } |
| | | }, |
| | | ids() { |
| | | let ids = []; |
| | | ids () { |
| | | let ids = [] |
| | | this.selectionList.forEach(ele => { |
| | | ids.push(ele.id); |
| | | }); |
| | | return ids.join(','); |
| | | ids.push(ele.id) |
| | | }) |
| | | return ids.join(',') |
| | | }, |
| | | idsArray() { |
| | | let ids = []; |
| | | idsArray () { |
| | | let ids = [] |
| | | this.selectionList.forEach(ele => { |
| | | ids.push(ele.id); |
| | | }); |
| | | return ids; |
| | | ids.push(ele.id) |
| | | }) |
| | | return ids |
| | | }, |
| | | }, |
| | | methods: { |
| | | initData(roleId) { |
| | | initData (roleId) { |
| | | getRoleTreeById(roleId).then(res => { |
| | | const column = this.findObject(this.option.column, 'parentId'); |
| | | column.dicData = res.data.data; |
| | | }); |
| | | const column = this.findObject(this.option.column, 'parentId') |
| | | column.dicData = res.data.data |
| | | }) |
| | | }, |
| | | submit() { |
| | | const menuList = this.$refs.treeMenu.getCheckedKeys(); |
| | | submit () { |
| | | const menuList = this.$refs.treeMenu.getCheckedKeys() |
| | | // const dataScopeList = this.$refs.treeDataScope.getCheckedKeys(); |
| | | const dataScopeList = []; |
| | | const dataScopeList = [] |
| | | // const apiScopeList = this.$refs.treeApiScope.getCheckedKeys(); |
| | | const apiScopeList = []; |
| | | const apiScopeList = [] |
| | | grant(this.idsArray, menuList, dataScopeList, apiScopeList).then(() => { |
| | | this.box = false; |
| | | this.box = false |
| | | this.$message({ |
| | | type: 'success', |
| | | message: '操作成功!', |
| | | }); |
| | | this.onLoad(this.page); |
| | | }); |
| | | }) |
| | | this.onLoad(this.page) |
| | | }) |
| | | }, |
| | | rowSave(row, done, loading) { |
| | | rowSave (row, done, loading) { |
| | | add(row).then( |
| | | () => { |
| | | this.onLoad(this.page); |
| | | this.onLoad(this.page) |
| | | this.$message({ |
| | | type: 'success', |
| | | message: '操作成功!', |
| | | }); |
| | | done(); |
| | | }) |
| | | done() |
| | | }, |
| | | error => { |
| | | window.console.log(error); |
| | | loading(); |
| | | window.console.log(error) |
| | | loading() |
| | | } |
| | | ); |
| | | ) |
| | | }, |
| | | rowUpdate(row, index, done, loading) { |
| | | rowUpdate (row, index, done, loading) { |
| | | update(row).then( |
| | | () => { |
| | | this.onLoad(this.page); |
| | | this.onLoad(this.page) |
| | | this.$message({ |
| | | type: 'success', |
| | | message: '操作成功!', |
| | | }); |
| | | done(); |
| | | }) |
| | | done() |
| | | }, |
| | | error => { |
| | | window.console.log(error); |
| | | loading(); |
| | | window.console.log(error) |
| | | loading() |
| | | } |
| | | ); |
| | | ) |
| | | }, |
| | | rowDel(row) { |
| | | rowDel (row) { |
| | | this.$confirm('确定将选择数据删除?', { |
| | | confirmButtonText: '确定', |
| | | cancelButtonText: '取消', |
| | | type: 'warning', |
| | | }) |
| | | .then(() => { |
| | | return remove(row.id); |
| | | return remove(row.id) |
| | | }) |
| | | .then(() => { |
| | | this.onLoad(this.page); |
| | | this.onLoad(this.page) |
| | | this.$message({ |
| | | type: 'success', |
| | | message: '操作成功!', |
| | | }); |
| | | }); |
| | | }) |
| | | }) |
| | | }, |
| | | |
| | | searchReset() { |
| | | this.query = {}; |
| | | this.onLoad(this.page); |
| | | searchReset () { |
| | | this.query = {} |
| | | this.onLoad(this.page) |
| | | }, |
| | | searchChange(params, done) { |
| | | this.query = params; |
| | | this.page.currentPage = 1; |
| | | this.onLoad(this.page, params); |
| | | done(); |
| | | searchChange (params, done) { |
| | | this.query = params |
| | | this.page.currentPage = 1 |
| | | this.onLoad(this.page, params) |
| | | done() |
| | | }, |
| | | selectionChange(list) { |
| | | this.selectionList = list; |
| | | selectionChange (list) { |
| | | this.selectionList = list |
| | | }, |
| | | selectionClear() { |
| | | this.selectionList = []; |
| | | this.$refs.crud.toggleSelection(); |
| | | selectionClear () { |
| | | this.selectionList = [] |
| | | this.$refs.crud.toggleSelection() |
| | | }, |
| | | beforeOpen(done, type) { |
| | | beforeOpen (done, type) { |
| | | if (['add', 'edit'].includes(type)) { |
| | | this.initData(this.form.id); |
| | | this.initData(this.form.id) |
| | | } |
| | | done(); |
| | | done() |
| | | }, |
| | | handleRole() { |
| | | handleRole () { |
| | | if (this.selectionList.length !== 1) { |
| | | this.$message.warning('只能选择一条数据'); |
| | | return; |
| | | this.$message.warning('只能选择一条数据') |
| | | return |
| | | } |
| | | this.menuTreeObj = []; |
| | | this.dataScopeTreeObj = []; |
| | | this.apiScopeTreeObj = []; |
| | | this.menuTreeObj = [] |
| | | this.dataScopeTreeObj = [] |
| | | this.apiScopeTreeObj = [] |
| | | grantTree().then(res => { |
| | | this.menuGrantList = res.data.data.menu; |
| | | this.dataScopeGrantList = res.data.data.dataScope; |
| | | this.apiScopeGrantList = res.data.data.apiScope; |
| | | this.menuGrantList = res.data.data.menu |
| | | this.dataScopeGrantList = res.data.data.dataScope |
| | | this.apiScopeGrantList = res.data.data.apiScope |
| | | getRole(this.ids).then(res => { |
| | | this.menuTreeObj = res.data.data.menu; |
| | | this.dataScopeTreeObj = res.data.data.dataScope; |
| | | this.apiScopeTreeObj = res.data.data.apiScope; |
| | | this.box = true; |
| | | }); |
| | | }); |
| | | this.menuTreeObj = res.data.data.menu |
| | | this.dataScopeTreeObj = res.data.data.dataScope |
| | | this.apiScopeTreeObj = res.data.data.apiScope |
| | | this.box = true |
| | | }) |
| | | }) |
| | | }, |
| | | handleDelete() { |
| | | handleDelete () { |
| | | if (this.selectionList.length === 0) { |
| | | this.$message.warning('请选择至少一条数据'); |
| | | return; |
| | | this.$message.warning('请选择至少一条数据') |
| | | return |
| | | } |
| | | this.$confirm('确定将选择数据删除?', { |
| | | confirmButtonText: '确定', |
| | |
| | | type: 'warning', |
| | | }) |
| | | .then(() => { |
| | | return remove(this.ids); |
| | | return remove(this.ids) |
| | | }) |
| | | .then(() => { |
| | | this.onLoad(this.page); |
| | | this.onLoad(this.page) |
| | | this.$message({ |
| | | type: 'success', |
| | | message: '操作成功!', |
| | | }); |
| | | this.$refs.crud.toggleSelection(); |
| | | }); |
| | | }) |
| | | this.$refs.crud.toggleSelection() |
| | | }) |
| | | }, |
| | | currentChange(currentPage) { |
| | | this.page.currentPage = currentPage; |
| | | currentChange (currentPage) { |
| | | this.page.currentPage = currentPage |
| | | }, |
| | | sizeChange(pageSize) { |
| | | this.page.pageSize = pageSize; |
| | | sizeChange (pageSize) { |
| | | this.page.pageSize = pageSize |
| | | }, |
| | | refreshChange() { |
| | | this.onLoad(this.page, this.query); |
| | | refreshChange () { |
| | | this.onLoad(this.page, this.query) |
| | | }, |
| | | onLoad(page, params = {}) { |
| | | this.loading = true; |
| | | onLoad (page, params = {}) { |
| | | this.loading = true |
| | | getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => { |
| | | this.data = res.data.data; |
| | | this.loading = false; |
| | | this.selectionClear(); |
| | | }); |
| | | this.data = res.data.data |
| | | this.loading = false |
| | | this.selectionClear() |
| | | }) |
| | | }, |
| | | }, |
| | | }; |
| | | } |
| | | </script> |
| | | <style scoped lang="scss"> |
| | | </style> |
| | | <style scoped lang="scss"></style> |
| | |
| | | <template> |
| | | <basic-container> |
| | | <avue-crud |
| | | :option="option" |
| | | :table-loading="loading" |
| | | :data="data" |
| | | v-model:page="page" |
| | | ref="crud" |
| | | @row-del="rowDel" |
| | | v-model="form" |
| | | :permission="permissionList" |
| | | @row-save="rowSave" |
| | | @row-update="rowUpdate" |
| | | :before-open="beforeOpen" |
| | | @search-change="searchChange" |
| | | @search-reset="searchReset" |
| | | @selection-change="selectionChange" |
| | | @current-change="currentChange" |
| | | @size-change="sizeChange" |
| | | @refresh-change="refreshChange" |
| | | @on-load="onLoad" |
| | | > |
| | | <avue-crud :option="option" :table-loading="loading" :data="data" v-model:page="page" ref="crud" @row-del="rowDel" |
| | | v-model="form" :permission="permissionList" @row-save="rowSave" @row-update="rowUpdate" :before-open="beforeOpen" |
| | | @search-change="searchChange" @search-reset="searchReset" @selection-change="selectionChange" |
| | | @current-change="currentChange" @size-change="sizeChange" @refresh-change="refreshChange" @on-load="onLoad"> |
| | | </avue-crud> |
| | | </basic-container> |
| | | </template> |
| | | |
| | | <script> |
| | | import { getList, remove, add, update } from '@/api/device/devicePerMenu'; |
| | | import { mapGetters } from 'vuex'; |
| | | import { getList, remove, add, update } from '@/api/device/devicePerMenu' |
| | | import { mapGetters } from 'vuex' |
| | | |
| | | export default { |
| | | data() { |
| | | data () { |
| | | return { |
| | | form: {}, |
| | | query: {}, |
| | |
| | | excelBtn: false, |
| | | dialogClickModal: false, |
| | | grid: false, |
| | | |
| | | height: 'auto', |
| | | calcHeight: 20, |
| | | |
| | | column: [ |
| | | { |
| | | label: '名称', |
| | |
| | | ], |
| | | }, |
| | | data: [], |
| | | }; |
| | | } |
| | | }, |
| | | computed: { |
| | | ...mapGetters(['permission']), |
| | | permissionList() { |
| | | permissionList () { |
| | | return { |
| | | addBtn: this.validData(this.permission.device_per_menu_add, true), |
| | | viewBtn: this.validData(this.permission.device_per_menu_view, true), |
| | | delBtn: this.validData(this.permission.device_per_menu_delete, true), |
| | | editBtn: this.validData(this.permission.device_per_menu_edit, true), |
| | | }; |
| | | } |
| | | }, |
| | | ids() { |
| | | let ids = []; |
| | | ids () { |
| | | let ids = [] |
| | | this.selectionList.forEach(ele => { |
| | | ids.push(ele.id); |
| | | }); |
| | | return ids.join(','); |
| | | ids.push(ele.id) |
| | | }) |
| | | return ids.join(',') |
| | | }, |
| | | }, |
| | | methods: { |
| | | rowSave(row, done, loading) { |
| | | rowSave (row, done, loading) { |
| | | add(row).then( |
| | | () => { |
| | | this.initFlag = false; |
| | | this.onLoad(this.page); |
| | | this.initFlag = false |
| | | this.onLoad(this.page) |
| | | this.$message({ |
| | | type: 'success', |
| | | message: '操作成功!', |
| | | }); |
| | | done(); |
| | | }) |
| | | done() |
| | | }, |
| | | error => { |
| | | window.console.log(error); |
| | | loading(); |
| | | window.console.log(error) |
| | | loading() |
| | | } |
| | | ); |
| | | ) |
| | | }, |
| | | rowUpdate(row, index, done, loading) { |
| | | rowUpdate (row, index, done, loading) { |
| | | update(row).then( |
| | | () => { |
| | | this.onLoad(this.page); |
| | | this.onLoad(this.page) |
| | | this.$message({ |
| | | type: 'success', |
| | | message: '操作成功!', |
| | | }); |
| | | done(); |
| | | }) |
| | | done() |
| | | }, |
| | | error => { |
| | | window.console.log(error); |
| | | loading(); |
| | | window.console.log(error) |
| | | loading() |
| | | } |
| | | ); |
| | | ) |
| | | }, |
| | | rowDel(row) { |
| | | rowDel (row) { |
| | | this.$confirm('确定将选择数据删除?', { |
| | | confirmButtonText: '确定', |
| | | cancelButtonText: '取消', |
| | | type: 'warning', |
| | | }) |
| | | .then(() => { |
| | | return remove(row.id); |
| | | return remove(row.id) |
| | | }) |
| | | .then(() => { |
| | | this.onLoad(this.page); |
| | | this.onLoad(this.page) |
| | | this.$message({ |
| | | type: 'success', |
| | | message: '操作成功!', |
| | | }); |
| | | }); |
| | | }) |
| | | }) |
| | | }, |
| | | searchReset() { |
| | | this.query = {}; |
| | | this.onLoad(this.page); |
| | | searchReset () { |
| | | this.query = {} |
| | | this.onLoad(this.page) |
| | | }, |
| | | searchChange(params, done) { |
| | | this.query = params; |
| | | this.page.currentPage = 1; |
| | | this.onLoad(this.page, params); |
| | | done(); |
| | | searchChange (params, done) { |
| | | this.query = params |
| | | this.page.currentPage = 1 |
| | | this.onLoad(this.page, params) |
| | | done() |
| | | }, |
| | | selectionChange(list) { |
| | | this.selectionList = list; |
| | | selectionChange (list) { |
| | | this.selectionList = list |
| | | }, |
| | | selectionClear() { |
| | | this.selectionList = []; |
| | | this.$refs.crud.toggleSelection(); |
| | | selectionClear () { |
| | | this.selectionList = [] |
| | | this.$refs.crud.toggleSelection() |
| | | }, |
| | | handleDelete() { |
| | | handleDelete () { |
| | | if (this.selectionList.length === 0) { |
| | | this.$message.warning('请选择至少一条数据'); |
| | | return; |
| | | this.$message.warning('请选择至少一条数据') |
| | | return |
| | | } |
| | | this.$confirm('确定将选择数据删除?', { |
| | | confirmButtonText: '确定', |
| | |
| | | type: 'warning', |
| | | }) |
| | | .then(() => { |
| | | return remove(this.ids); |
| | | return remove(this.ids) |
| | | }) |
| | | .then(() => { |
| | | this.onLoad(this.page); |
| | | this.onLoad(this.page) |
| | | this.$message({ |
| | | type: 'success', |
| | | message: '操作成功!', |
| | | }); |
| | | this.$refs.crud.toggleSelection(); |
| | | }); |
| | | }) |
| | | this.$refs.crud.toggleSelection() |
| | | }) |
| | | }, |
| | | beforeOpen(done, type) { |
| | | done(); |
| | | beforeOpen (done, type) { |
| | | done() |
| | | }, |
| | | currentChange(currentPage) { |
| | | this.page.currentPage = currentPage; |
| | | currentChange (currentPage) { |
| | | this.page.currentPage = currentPage |
| | | }, |
| | | sizeChange(pageSize) { |
| | | this.page.pageSize = pageSize; |
| | | sizeChange (pageSize) { |
| | | this.page.pageSize = pageSize |
| | | }, |
| | | refreshChange() { |
| | | this.onLoad(this.page, this.query); |
| | | refreshChange () { |
| | | this.onLoad(this.page, this.query) |
| | | }, |
| | | onLoad(page, params = {}) { |
| | | this.loading = true; |
| | | onLoad (page, params = {}) { |
| | | this.loading = true |
| | | getList(page.currentPage, page.pageSize, params).then(res => { |
| | | const data = res.data.data; |
| | | this.page.total = data.total; |
| | | this.data = data.records; |
| | | this.loading = false; |
| | | this.selectionClear(); |
| | | }); |
| | | const data = res.data.data |
| | | this.page.total = data.total |
| | | this.data = data.records |
| | | this.loading = false |
| | | this.selectionClear() |
| | | }) |
| | | }, |
| | | }, |
| | | }; |
| | | } |
| | | </script> |
| | | |
| | | <style> |
| | |
| | | background-color: aqua; |
| | | border-radius: 4px; |
| | | } |
| | | |
| | | .firmware_status:hover { |
| | | cursor: pointer; |
| | | /* color: aqua; */ |
| | | } |
| | | </style> |
| | | <style scoped lang="scss"> |
| | | </style> |
| | | <style scoped lang="scss"></style> |