修改:测试修改权限处理

This commit is contained in:
jmal 2021-01-12 18:01:48 +08:00
parent a5335b9e9c
commit 094ae8aeec
15 changed files with 125 additions and 33 deletions

View File

@ -247,4 +247,12 @@ export default {
params params
}) })
}, },
// 是否允许下载
isAllowDownload: function(params) {
return request({
url: '/isAllowDownload',
method: 'get',
params
})
},
} }

View File

@ -1622,6 +1622,8 @@ export default {
this.getFileList() this.getFileList()
} }
} }
}).catch(() => {
this.newFolderLoading = false
}) })
} else { } else {
this.newFolderLoading = false this.newFolderLoading = false
@ -2221,6 +2223,9 @@ export default {
} }
}).then(() => { }).then(() => {
this.$refs.fileListTable.clearSelection() this.$refs.fileListTable.clearSelection()
}).catch(() => {
this.renameLoading = false
this.editingIndex = -1
}) })
}, },
// 更多操作(多选) // 更多操作(多选)
@ -2652,17 +2657,20 @@ export default {
row = this.$refs.fileListTable.tableSelectData[0] row = this.$refs.fileListTable.tableSelectData[0]
} }
} }
this.shareDialog = true
this.shareFileName = row.name this.shareFileName = row.name
api.generate({ api.generate({
userId: row.userId, userId: row.userId,
fileId: row.id, fileId: row.id,
isFolder: row.isFolder isFolder: row.isFolder
}).then(res => { }).then(res => {
this.shareDialog = true
if (res.data) { if (res.data) {
this.shareLink = window.location.origin + '/s?s=' + res.data this.shareLink = window.location.origin + '/s?s=' + res.data
this.generateShareLinkLoading = false this.generateShareLinkLoading = false
} }
}).catch(() => {
this.shareDialog = false
this.generateShareLinkLoading = false
}) })
}, },
// 复制分享链接 // 复制分享链接
@ -2733,6 +2741,8 @@ export default {
// 移除列表 // 移除列表
this.removeSelectItme() this.removeSelectItme()
} }
}).catch(()=>{
this.rowContextData.isFavorite = !isFavorite
}) })
}, },
// 删除 // 删除

View File

@ -319,6 +319,15 @@
}, },
onFileSuccess(rootFile, file, response) { onFileSuccess(rootFile, file, response) {
const res = JSON.parse(response) const res = JSON.parse(response)
if(!res.data){
this.$message({
message: res.message,
type: 'error'
})
this.uploader.cancel()
this.close()
return;
}
const data = res.data const data = res.data
// 服务器自定义的错误(即虽返回200,但是是错误的情况),这种错误是Uploader无法拦截的 // 服务器自定义的错误(即虽返回200,但是是错误的情况),这种错误是Uploader无法拦截的
if (!data.upload) { if (!data.upload) {

View File

@ -36,7 +36,6 @@
class="simtext-dialog" class="simtext-dialog"
v-dialogDrag="{ dialogWidthPercent: dialogWidthPercent}"> v-dialogDrag="{ dialogWidthPercent: dialogWidthPercent}">
<div slot="title" class="simtext-header-title"> <div slot="title" class="simtext-header-title">
<!--<span class="title-name">{{file.name}}</span>-->
<span><file-path-nav class="title-name" :path="filePathNav" @loadPath="loadPath"></file-path-nav></span> <span><file-path-nav class="title-name" :path="filePathNav" @loadPath="loadPath"></file-path-nav></span>
<div class="title-extension"> <div class="title-extension">
<el-button v-if="isShowUpdateBtn" @click="saveAll(false)" :class="lightTheme?'':'dark-button'" size="small" :loading="updating">保存所有</el-button> <el-button v-if="isShowUpdateBtn" @click="saveAll(false)" :class="lightTheme?'':'dark-button'" size="small" :loading="updating">保存所有</el-button>
@ -681,7 +680,9 @@
that.modifyMsg = undefined that.modifyMsg = undefined
},1000) },1000)
} }
}) }).catch(() => {
this.updating = false
})
}, },
// 全屏 // 全屏
fullScreen() { fullScreen() {

View File

@ -100,7 +100,6 @@ export default {
handleNodeClick(node){ handleNodeClick(node){
this.valueTitle = node[this.props.label] this.valueTitle = node[this.props.label]
this.valueId = node[this.props.value] this.valueId = node[this.props.value]
this.$emit('getValue',this.valueId)
this.defaultExpandedKey = [] this.defaultExpandedKey = []
this.$refs.treeSelect.blur() this.$refs.treeSelect.blur()
this.$emit('input', this.valueId) this.$emit('input', this.valueId)
@ -111,7 +110,7 @@ export default {
this.valueId = null this.valueId = null
this.defaultExpandedKey = [] this.defaultExpandedKey = []
this.clearSelected() this.clearSelected()
this.$emit('getValue',null) this.$emit('input', '')
}, },
/* 清空选中样式 */ /* 清空选中样式 */
clearSelected(){ clearSelected(){

View File

@ -3,6 +3,7 @@
<div class="table-temp"> <div class="table-temp">
<el-table <el-table
:data="tableData" :data="tableData"
:max-height="tableMaxHeight"
row-key="id" row-key="id"
border border
size="medium" size="medium"
@ -81,6 +82,10 @@ export default {
return []; return [];
} }
}, },
lessClientHeight: {
type: Number,
default: 0
},
tableHeader: { tableHeader: {
type: Array, type: Array,
default: function() { default: function() {
@ -106,6 +111,7 @@ export default {
}, },
data() { data() {
return { return {
tableMaxHeight: document.documentElement.clientHeight,
multipleSelection: [], multipleSelection: [],
newPagination: { newPagination: {
pageIndex: 0, pageIndex: 0,
@ -114,7 +120,17 @@ export default {
} }
}; };
}, },
mounted() {
this.setMaxHeight()
let that = this
window.onresize = function (){
that.setMaxHeight()
}
},
methods: { methods: {
setMaxHeight(){
this.tableMaxHeight = document.documentElement.clientHeight - this.lessClientHeight
},
// 多选操作 // 多选操作
handleSelectionChange(val) { handleSelectionChange(val) {
this.multipleSelection = val; this.multipleSelection = val;
@ -135,11 +151,11 @@ export default {
} }
}); });
}, },
//后端排序 // 后端排序
sortChange(column) { sortChange(column) {
//调用父组件方法 //调用父组件方法
this.$emit('sortChange', { backData: column }); this.$emit('sortChange', { backData: column });
} },
} }
} }
</script> </script>

View File

@ -64,7 +64,7 @@ function setMenuList(next, to){
store.dispatch('user/setMenuList').then((res) => { store.dispatch('user/setMenuList').then((res) => {
const to = window.location.pathname const to = window.location.pathname
if(findPath(res.data, to)){ if(findPath(res.data, to)){
next({path: to}) next(window.location.pathname + window.location.search)
} else { } else {
next({path: store.getters.menuList[0].path}) next({path: store.getters.menuList[0].path})
} }
@ -82,10 +82,15 @@ function setMenuList(next, to){
* @returns {boolean} * @returns {boolean}
*/ */
function findPath(menuList, to, parentPath){ function findPath(menuList, to, parentPath){
for( let i = 0; i < menuList.length - 1; i++) { for( let i = 0; i < menuList.length; i++) {
const menu = menuList[i] const menu = menuList[i]
if(menu.menuType > 0){
continue
}
if(menu.children && menu.children.length > 0){ if(menu.children && menu.children.length > 0){
return findPath(menu.children, to, menu.path) if(findPath(menu.children, to, menu.path)){
return true
}
} }
if(parentPath){ if(parentPath){
menu.path = parentPath + '/' + menu.path menu.path = parentPath + '/' + menu.path

View File

@ -49,7 +49,7 @@ const actions = {
return new Promise( (resolve,reject) => { return new Promise( (resolve,reject) => {
menuApi.menuTree({userId: state.userId}).then((res) => { menuApi.menuTree({userId: state.userId}).then((res) => {
state.menuList = getMenuTree(res.data); state.menuList = getMenuTree(res.data);
commit('SET_MENU_LIST',state.menuList); commit('SET_MENU_LIST', state.menuList);
resetRouter(state.menuList) resetRouter(state.menuList)
router.options.routes = router.options.routes.concat(state.menuList); router.options.routes = router.options.routes.concat(state.menuList);
resolve(res) resolve(res)
@ -134,6 +134,7 @@ const actions = {
} }
function getMenuTree(menuList) { function getMenuTree(menuList) {
menuList = menuList.filter(menu => menu.menuType === 0)
return menuList.map(menu => { return menuList.map(menu => {
let router = {} let router = {}
if(menu.children && menu.children.length){ if(menu.children && menu.children.length){
@ -158,6 +159,7 @@ function getMenuTree(menuList) {
function findChildren(childrenMenu){ function findChildren(childrenMenu){
let children = [] let children = []
childrenMenu = childrenMenu.filter(menu => menu.menuType === 0)
childrenMenu.forEach(menu => { childrenMenu.forEach(menu => {
let router = { let router = {
path: menu.path, path: menu.path,

View File

@ -1,3 +1,4 @@
@import "src/styles/index";
a { a {
color: #1890ff; color: #1890ff;
text-decoration: none; text-decoration: none;
@ -16,7 +17,7 @@ a:hover {
} }
/deep/.box-card { /deep/.box-card {
margin: 0 auto; margin: 0 auto;
max-width: 1140px; max-width: 1240px;
min-width: 640px; min-width: 640px;
.clearfix { .clearfix {
font-size: 16px; font-size: 16px;
@ -30,6 +31,9 @@ a:hover {
} }
} }
} }
/deep/.el-card__body {
padding: 15px;
}
.table-search-header{ .table-search-header{
/deep/.el-card__header { /deep/.el-card__header {
padding: 18px 20px 0; padding: 18px 20px 0;

View File

@ -1,3 +1,5 @@
import fileApi from '@/api/file-api'
export default { export default {
baseUrl: '/api', baseUrl: '/api',
@ -20,15 +22,19 @@ export default {
window.open(url, '_blank') window.open(url, '_blank')
}, },
download: function(username, file) { download: function(username, file) {
let url = `${this.baseUrl}/file/${username}${file.path}${file.name}?o=download` fileApi.isAllowDownload().then(() => {
window.open(url, '_self') let url = `${this.baseUrl}/file/${username}${file.path}${file.name}?o=download`
window.open(url, '_self')
})
}, },
publicDownload: function(shareId, file) { publicDownload: function(shareId, file) {
let url = `${this.baseUrl}/public/s/download/${file.id}/${shareId}` let url = `${this.baseUrl}/public/s/download/${file.id}/${shareId}`
window.open(url, '_self') window.open(url, '_self')
}, },
packageDownload: function(fileIds, token) { packageDownload: function(fileIds, token) {
window.open(`${this.baseUrl}/packageDownload?fileIds=${fileIds}&jmal-token=${token}`, '_self') fileApi.isAllowDownload().then(() => {
window.open(`${this.baseUrl}/packageDownload?fileIds=${fileIds}&jmal-token=${token}`, '_self')
})
}, },
publicPackageDownload: function(shareId, fileIds) { publicPackageDownload: function(shareId, fileIds) {
window.open(`${this.baseUrl}/public/s/packageDownload?shareId=${shareId}&fileIds=${fileIds}`, '_self') window.open(`${this.baseUrl}/public/s/packageDownload?shareId=${shareId}&fileIds=${fileIds}`, '_self')

View File

@ -439,11 +439,8 @@ export default {
.wailian { .wailian {
margin-left: 8px; margin-left: 8px;
} }
/deep/.el-card__body {
min-width: 1080px;
}
/deep/ .el-dialog__body { /deep/ .el-dialog__body {
padding: 0 20px; padding: 0 15px;
} }
/deep/ .el-table-alone-page { /deep/ .el-table-alone-page {
tbody .el-table__row:hover { tbody .el-table__row:hover {

View File

@ -149,7 +149,7 @@ export default {
updateSetting(this.form).then((res)=> { updateSetting(this.form).then((res)=> {
this.$message.success("保存成功!") this.$message.success("保存成功!")
}).catch(()=> { }).catch(()=> {
this.$message.error("保存失败!")
}) })
} }
} }

View File

@ -55,11 +55,15 @@ export default {
this.syncLoading = true this.syncLoading = true
settingApi.sync({username: this.$store.state.user.name}).then(() => { settingApi.sync({username: this.$store.state.user.name}).then(() => {
this.syncLoading = false this.syncLoading = false
}).catch(() => {
this.syncLoading = false
}) })
}, },
webpChange(webpEnabled) { webpChange(webpEnabled) {
settingApi.disabledWebp({userId: this.$store.state.user.userId, disabled: !webpEnabled}).then(() => { settingApi.disabledWebp({userId: this.$store.state.user.userId, disabled: !webpEnabled}).then(() => {
webpEnabled ? this.$message.success('webp 以启用') : this.$message.warning('webp 以禁用') webpEnabled ? this.$message.success('webp 以启用') : this.$message.warning('webp 以禁用')
}).catch(() => {
this.webpEnabled = !this.webpEnabled
}) })
} }
} }

View File

@ -29,7 +29,19 @@
</el-col> </el-col>
<el-col :sm="12"> <el-col :sm="12">
<el-form-item label="权限标识:" prop="authority"> <el-form-item label="权限标识:" prop="authority">
<el-input placeholder="请输入权限标识" v-model="form.authority" /> <el-select
v-model="form.authority"
placeholder="请选择权限标识"
clearable
:popper-append-to-body="false"
>
<el-option
v-for="item in authorityList"
:key="item"
:label="item"
:value="item">
</el-option>
</el-select>
</el-form-item> </el-form-item>
<el-form-item label="排序号:" prop="sortNumber"> <el-form-item label="排序号:" prop="sortNumber">
<el-input-number v-model="form.sortNumber" controls-position="right" :min="0"></el-input-number> <el-input-number v-model="form.sortNumber" controls-position="right" :min="0"></el-input-number>
@ -78,6 +90,7 @@
<table-list <table-list
:has-selection="false" :has-selection="false"
:tableData="dataList" :tableData="dataList"
:less-client-height="210"
:loading="loading" :loading="loading"
:tableHeader="tableHeader" :tableHeader="tableHeader"
:pagination="pagination" :pagination="pagination"
@ -106,6 +119,7 @@ export default {
return { return {
title: "角色管理", title: "角色管理",
dataList: [], dataList: [],
authorityList: [],
loading: false, loading: false,
dialogVisible: false, dialogVisible: false,
dialogTitle: '', dialogTitle: '',
@ -183,6 +197,7 @@ export default {
}, },
mounted() { mounted() {
this.getMenuTree() this.getMenuTree()
this.getAuthorityList()
this.resize() this.resize()
}, },
methods: { methods: {
@ -206,6 +221,11 @@ export default {
this.pagination = data.backData; this.pagination = data.backData;
this.getMenuTree() this.getMenuTree()
}, },
getAuthorityList() {
menuApi.authorityList().then(res => {
this.authorityList = res.data
})
},
getMenuTree(){ getMenuTree(){
this.loading = true this.loading = true
menuApi.menuTree({ menuApi.menuTree({
@ -353,4 +373,7 @@ export default {
/deep/ .el-select { /deep/ .el-select {
width: 100%; width: 100%;
} }
/deep/.box-card {
max-width: 1440px;
}
</style> </style>

View File

@ -18,15 +18,19 @@
</div> </div>
</el-dialog> </el-dialog>
<el-dialog width="400px" title="分配权限" :visible.sync="dialogAuthVisible"> <el-dialog width="400px" title="分配权限" :visible.sync="dialogAuthVisible">
<el-tree <el-scrollbar>
ref="authTree" <el-tree
:data="menuList" style="max-height: 50vh"
show-checkbox ref="authTree"
node-key="id" :data="menuList"
default-expand-all :check-strictly="true"
:default-checked-keys="menuCheckedList" show-checkbox
:props="{value: 'id', label: 'name'}"> node-key="id"
</el-tree> default-expand-all
:default-checked-keys="menuCheckedList"
:props="{value: 'id', label: 'name'}">
</el-tree>
</el-scrollbar>
<div slot="footer" class="dialog-footer"> <div slot="footer" class="dialog-footer">
<el-button size="small" @click="dialogAuthVisible = false">取 消</el-button> <el-button size="small" @click="dialogAuthVisible = false">取 消</el-button>
<el-button size="small" type="primary" :loading="updateLoading" @click.native.prevent="saveAuth()">保 存</el-button> <el-button size="small" type="primary" :loading="updateLoading" @click.native.prevent="saveAuth()">保 存</el-button>
@ -64,6 +68,7 @@
</div> </div>
</div> </div>
<table-list <table-list
:less-client-height="290"
:tableData="dataList" :tableData="dataList"
:loading="loading" :loading="loading"
:tableHeader="tableHeader" :tableHeader="tableHeader"
@ -237,8 +242,12 @@ export default {
this.dialogAuthVisible = true this.dialogAuthVisible = true
const findIndex = this.dataList.findIndex(data => data.id === roleId) const findIndex = this.dataList.findIndex(data => data.id === roleId)
const role = this.dataList[findIndex] const role = this.dataList[findIndex]
this.form.id = role.id this.form = role
this.menuCheckedList = role.menuIds if(this.$refs.authTree){
this.$refs.authTree.setCheckedKeys(role.menuIds)
} else {
this.menuCheckedList = role.menuIds
}
}, },
handleEdit(id) { handleEdit(id) {
this.editMove = 2 this.editMove = 2
@ -322,7 +331,6 @@ export default {
}, },
onError() { onError() {
this.updateLoading = false this.updateLoading = false
this.dialogAuthVisible = false
} }
} }
} }