This commit is contained in:
zhangjianjun 2026-03-28 18:32:01 +08:00
parent 79a1d261d8
commit f6a0bc8161
6 changed files with 71 additions and 18 deletions

View File

@ -1,5 +1,20 @@
import type { App } from 'vue' import type { App } from 'vue'
import routes from 'src/routes'
import { indexStore } from 'lib/stores'
const store = indexStore();
const resource = store.$state.kwargs.resource;
export default function BeforeMount(app: App<Element>) { export default function BeforeMount(app: App<Element>) {
const resourcePaths = resource.map((item: any) => item.path);
routes.forEach((route: any) => {
if (route && route.children) {
route.children.forEach((child: any) => {
const path = route.path + '/' + child.path;
child.meta.hidden = !resourcePaths.includes(path)
})
if(route.meta) {
route.meta.hidden = route.children.every((child: any) => child.meta.hidden);
}
}
})
} }

View File

@ -1,6 +1,8 @@
import type { RouteRecordRaw } from "vue-router"; import type { RouteRecordRaw } from "vue-router";
import TableLayout from "lib/layout/TableLayout.vue"; import TableLayout from "lib/layout/TableLayout.vue";
import MainLayout from "lib/layout/MainLayout.vue"; import MainLayout from "lib/layout/MainLayout.vue";
import { indexStore } from "lib/stores";
const routes: Array<RouteRecordRaw> = [ const routes: Array<RouteRecordRaw> = [
{ {
meta: { meta: {

View File

@ -143,10 +143,9 @@ export default {
}) })
}) })
.finally(() => { .finally(() => {
this.$router.push('/') this.$router.push('/').then(() => {
// setTimeout(() => { location.reload()
// location.reload() })
// }, 1000)
}) })
} }
} }

View File

@ -8,18 +8,32 @@ const data: TableData = {
addNods: [ addNods: [
], ],
methods: {
formtTree(self: TableData, data: any) {
data.forEach((item: any) => {
item.key = item.id + ""
if (item.children && item.children.length > 0 && self.methods) {
item.children = self.methods.formtTree(self, item.children)
}
else {
delete item.children
}
})
return data
}
},
launchTask: [ launchTask: [
async (self: any) => { async (self: any) => {
if (self.bean) { if (self.bean) {
const res = await self.api?.getResources({ type: "page", page: 1, size: 1000 }) const res = await self.api?.getResources({ type: "", page: 1, size: 1000 })
const res2 = await self.api?.getResources({ type: "api", page: 1, size: 1000 }) const resources = res.data.items?.map((item: any) => {
self.bean.resources = [...res.data.items, ...res2.data.items].map((item: any) => {
const type = item.type === 'page' ? '页面' : '接口' const type = item.type === 'page' ? '页面' : '接口'
return { return {
key: item.id, key: item.id,
name: `${type}${item.name}` name: `${type}${item.name}`
} }
}) })
self.bean.resources = resources
} }
} }
], ],
@ -103,9 +117,6 @@ const data: TableData = {
const resources = res.data.map((item: any) => item.id) const resources = res.data.map((item: any) => item.id)
const findItem = form.data.find((i: any) => i.key === 'resource') const findItem = form.data.find((i: any) => i.key === 'resource')
findItem.values[form.show] = resources findItem.values[form.show] = resources
console.log('row', row)
console.log('form', form)
console.log('resource', resources)
}, },
data: [ data: [
{ {
@ -122,7 +133,7 @@ const data: TableData = {
return self.bean ? self.bean.resources : [] return self.bean ? self.bean.resources : []
}, },
multiple: true, multiple: true,
must: true must: false
}, },
], ],
subFun(self, data) { subFun(self, data) {

View File

@ -1,6 +1,14 @@
import type { TableData } from 'lib/type/TableData' import type { TableData } from 'lib/type/TableData'
import './index.less' import './index.less'
import JsonFormDialog from 'src/components/JsonFormDialog.vue' import JsonFormDialog from 'src/components/JsonFormDialog.vue'
import { indexStore } from 'lib/stores';
const store = indexStore();
const getDangerEdit = () => {
const resource = store.$state.kwargs.resource;
const editPermission = resource.some((item: any) => item.path === "#dangerousEdits")
return editPermission
}
const data: TableData = { const data: TableData = {
rowKey: 'id', rowKey: 'id',
defaultExpandAll: true, defaultExpandAll: true,
@ -84,7 +92,7 @@ const data: TableData = {
self.bean.jsonFormData = {} self.bean.jsonFormData = {}
// self.bean.fieldMap = {} // self.bean.fieldMap = {}
} }
} },
], ],
fliter: [ fliter: [
{ {
@ -166,7 +174,8 @@ const data: TableData = {
subFun(self, data, row) { subFun(self, data, row) {
return self.api?.updateData({...data, id: String(data.id), pid: String(row.pid)}) return self.api?.updateData({...data, id: String(data.id), pid: String(row.pid)})
} }
} },
getHide: () => !getDangerEdit()
}, },
{ {
key: 'content', key: 'content',
@ -215,11 +224,13 @@ const data: TableData = {
subFun(self, data, row) { subFun(self, data, row) {
return self.api?.updateData({...data, id: String(data.id), pid: String(row.pid)}) return self.api?.updateData({...data, id: String(data.id), pid: String(row.pid)})
} }
} },
getHide: () => !getDangerEdit()
}, },
{ {
key: 'table_tools', key: 'table_tools',
name: '操作', name: '操作',
getHide: () => !getDangerEdit(),
buttons: [ buttons: [
{ {
type: 'dialogForm', type: 'dialogForm',

View File

@ -2,6 +2,13 @@ import type { TableData } from 'lib/type/TableData'
import { categoryTypes } from '../../data/const' import { categoryTypes } from '../../data/const'
import utils from 'lib/utils' import utils from 'lib/utils'
let types: any[] = [] let types: any[] = []
import { indexStore } from 'lib/stores';
const store = indexStore();
const getDangerEdit = () => {
const resource = store.$state.kwargs.resource;
const editPermission = resource.some((item: any) => item.path === "#dangerousEdits")
return editPermission
}
const pathname = utils.getPathName() const pathname = utils.getPathName()
types = categoryTypes.filter(item => pathname.includes(item.path)) types = categoryTypes.filter(item => pathname.includes(item.path))
@ -108,7 +115,11 @@ const data: TableData = {
type: 'input', type: 'input',
must: true, must: true,
getDisable: () => { getDisable: () => {
return !pathname.includes('/jobs') const pathname = utils.getPathName()
if(pathname.includes('/jobs')) {
return false
}
return !getDangerEdit()
} }
}, },
// { // {
@ -134,7 +145,11 @@ const data: TableData = {
return self.api?.deleteData(data) return self.api?.deleteData(data)
}, },
getDisable: () => { getDisable: () => {
return !pathname.includes('/jobs') const pathname = utils.getPathName()
if(pathname.includes('/jobs')) {
return false
}
return !getDangerEdit()
} }
} }
} }