修改测试bug 优化页面
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
<template>
|
||||
<div>
|
||||
<el-dialog v-model="dialogVisible" title="自定义功能管理" width="600">
|
||||
<el-dialog v-model="dialogVisible" title="自定义功能管理" width="650">
|
||||
<div style="display: flex; justify-content: end" class="mb10">
|
||||
<el-button icon="el-icon-Plus" type="primary" @click="add">新增</el-button>
|
||||
</div>
|
||||
<div style="height: calc(100vh / 2); max-height: 400px">
|
||||
<div style="height: 300px; max-height: 400px">
|
||||
<vxe-table
|
||||
border
|
||||
ref="tableRef"
|
||||
@@ -25,6 +25,7 @@
|
||||
<el-switch
|
||||
v-model="row.state"
|
||||
inline-prompt
|
||||
:disabled="!hasAdmin && row.scope"
|
||||
:active-value="1"
|
||||
:inactive-value="0"
|
||||
active-text="已激活"
|
||||
@@ -33,11 +34,29 @@
|
||||
/>
|
||||
</template>
|
||||
</vxe-column>
|
||||
<vxe-column field="startTime" title="是否全局" v-if="hasAdmin">
|
||||
<template #default="{ row }">
|
||||
<el-switch
|
||||
v-model="row.scope"
|
||||
inline-prompt
|
||||
:active-value="1"
|
||||
width="50px"
|
||||
:inactive-value="0"
|
||||
active-text="是"
|
||||
inactive-text="否"
|
||||
:before-change="() => beforeChange1(row)"
|
||||
/>
|
||||
</template>
|
||||
</vxe-column>
|
||||
<vxe-column field="startTime" title="操作">
|
||||
<template #default="{ row }">
|
||||
<el-button type="primary" link @click="edit(row)">编辑</el-button>
|
||||
<el-button type="primary" link @click="edit(row)" v-if="!(!hasAdmin && row.scope)">
|
||||
编辑
|
||||
</el-button>
|
||||
|
||||
<el-button type="danger" link @click="deletes(row)">删除</el-button>
|
||||
<el-button type="danger" link @click="deletes(row)" v-if="!(!hasAdmin && row.scope)">
|
||||
删除
|
||||
</el-button>
|
||||
</template>
|
||||
</vxe-column>
|
||||
</vxe-table>
|
||||
@@ -49,18 +68,20 @@
|
||||
import { ref, reactive } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { defaultAttribute } from '@/components/table/defaultAttribute'
|
||||
import { getDashboardPageByUserId, deleteDashboard, activatePage } from '@/api/system-boot/csstatisticalset'
|
||||
import { getDashboardPageByUserId, deleteDashboard, activatePage, scopePage } from '@/api/system-boot/csstatisticalset'
|
||||
import { useAdminInfo } from '@/stores/adminInfo'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { useNavTabs } from '@/stores/navTabs'
|
||||
import { getMenu } from '@/utils/router'
|
||||
|
||||
const { push } = useRouter()
|
||||
|
||||
const dialogVisible = ref(false)
|
||||
const route = useRouter()
|
||||
const navTabs = useNavTabs()
|
||||
const adminInfo = useAdminInfo()
|
||||
const pageList: any = ref([])
|
||||
const hasAdmin = adminInfo.roleCode.some(item => item.includes('operation_manager') || item.includes('root'))
|
||||
|
||||
const open = () => {
|
||||
dialogVisible.value = true
|
||||
@@ -68,7 +89,10 @@ const open = () => {
|
||||
}
|
||||
const init = () => {
|
||||
getDashboardPageByUserId({ id: adminInfo.id, state: false }).then(res => {
|
||||
pageList.value = res.data
|
||||
pageList.value = res.data.filter(item => {
|
||||
item.scope = item.userId == '0' ? 1 : 0
|
||||
return item
|
||||
})
|
||||
})
|
||||
}
|
||||
// 新增
|
||||
@@ -93,7 +117,7 @@ const beforeChange = (row: any): Promise<boolean> => {
|
||||
type: 'warning'
|
||||
})
|
||||
.then(() => {
|
||||
activatePage({ id: row.id, state: row.state == 0 ? 1 : 0 }).then( async(res: any) => {
|
||||
activatePage({ id: row.id, state: row.state == 0 ? 1 : 0 }).then(async (res: any) => {
|
||||
if (res.code == 'A0000') {
|
||||
ElMessage({
|
||||
type: 'success',
|
||||
@@ -102,19 +126,45 @@ const beforeChange = (row: any): Promise<boolean> => {
|
||||
}
|
||||
init()
|
||||
resolve(true)
|
||||
await getMenu()
|
||||
await setTimeout(() => {
|
||||
navTabs.refresh()
|
||||
await getMenu()
|
||||
await setTimeout(() => {
|
||||
navTabs.refresh()
|
||||
}, 1000)
|
||||
|
||||
})
|
||||
})
|
||||
.catch(() => {
|
||||
ElMessage({
|
||||
type: 'info',
|
||||
message: '已取消删除'
|
||||
.catch(() => {})
|
||||
})
|
||||
}
|
||||
// 全局
|
||||
const beforeChange1 = (row: any): Promise<boolean> => {
|
||||
return new Promise(resolve => {
|
||||
// setTimeout(() => {
|
||||
// loading1.value = false
|
||||
// ElMessage.success('Switch success')
|
||||
// return resolve(true)
|
||||
// }, 1000)
|
||||
ElMessageBox.confirm('此操作将页面配置成全局, 是否继续?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
})
|
||||
.then(() => {
|
||||
scopePage({ id: row.id, userId: row.scope == 0 ? '0' : adminInfo.id }).then(async (res: any) => {
|
||||
if (res.code == 'A0000') {
|
||||
ElMessage({
|
||||
type: 'success',
|
||||
message: '操作成功!'
|
||||
})
|
||||
}
|
||||
init()
|
||||
resolve(true)
|
||||
await getMenu()
|
||||
await setTimeout(() => {
|
||||
navTabs.refresh()
|
||||
}, 1000)
|
||||
})
|
||||
})
|
||||
.catch(() => {})
|
||||
})
|
||||
}
|
||||
// 删除
|
||||
|
||||
Reference in New Issue
Block a user