update
This commit is contained in:
parent
79a1d261d8
commit
f6a0bc8161
|
|
@ -1,5 +1,20 @@
|
|||
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);
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
@ -1,6 +1,8 @@
|
|||
import type { RouteRecordRaw } from "vue-router";
|
||||
import TableLayout from "lib/layout/TableLayout.vue";
|
||||
import MainLayout from "lib/layout/MainLayout.vue";
|
||||
import { indexStore } from "lib/stores";
|
||||
|
||||
const routes: Array<RouteRecordRaw> = [
|
||||
{
|
||||
meta: {
|
||||
|
|
|
|||
|
|
@ -143,10 +143,9 @@ export default {
|
|||
})
|
||||
})
|
||||
.finally(() => {
|
||||
this.$router.push('/')
|
||||
// setTimeout(() => {
|
||||
// location.reload()
|
||||
// }, 1000)
|
||||
this.$router.push('/').then(() => {
|
||||
location.reload()
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,18 +8,32 @@ const data: TableData = {
|
|||
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: [
|
||||
async (self: any) => {
|
||||
if (self.bean) {
|
||||
const res = await self.api?.getResources({ type: "page", page: 1, size: 1000 })
|
||||
const res2 = await self.api?.getResources({ type: "api", page: 1, size: 1000 })
|
||||
self.bean.resources = [...res.data.items, ...res2.data.items].map((item: any) => {
|
||||
const res = await self.api?.getResources({ type: "", page: 1, size: 1000 })
|
||||
const resources = res.data.items?.map((item: any) => {
|
||||
const type = item.type === 'page' ? '页面' : '接口'
|
||||
return {
|
||||
key: item.id,
|
||||
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 findItem = form.data.find((i: any) => i.key === 'resource')
|
||||
findItem.values[form.show] = resources
|
||||
console.log('row', row)
|
||||
console.log('form', form)
|
||||
console.log('resource', resources)
|
||||
},
|
||||
data: [
|
||||
{
|
||||
|
|
@ -122,7 +133,7 @@ const data: TableData = {
|
|||
return self.bean ? self.bean.resources : []
|
||||
},
|
||||
multiple: true,
|
||||
must: true
|
||||
must: false
|
||||
},
|
||||
],
|
||||
subFun(self, data) {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,14 @@
|
|||
import type { TableData } from 'lib/type/TableData'
|
||||
import './index.less'
|
||||
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 = {
|
||||
rowKey: 'id',
|
||||
defaultExpandAll: true,
|
||||
|
|
@ -84,7 +92,7 @@ const data: TableData = {
|
|||
self.bean.jsonFormData = {}
|
||||
// self.bean.fieldMap = {}
|
||||
}
|
||||
}
|
||||
},
|
||||
],
|
||||
fliter: [
|
||||
{
|
||||
|
|
@ -166,7 +174,8 @@ const data: TableData = {
|
|||
subFun(self, data, row) {
|
||||
return self.api?.updateData({...data, id: String(data.id), pid: String(row.pid)})
|
||||
}
|
||||
}
|
||||
},
|
||||
getHide: () => !getDangerEdit()
|
||||
},
|
||||
{
|
||||
key: 'content',
|
||||
|
|
@ -215,11 +224,13 @@ const data: TableData = {
|
|||
subFun(self, data, row) {
|
||||
return self.api?.updateData({...data, id: String(data.id), pid: String(row.pid)})
|
||||
}
|
||||
}
|
||||
},
|
||||
getHide: () => !getDangerEdit()
|
||||
},
|
||||
{
|
||||
key: 'table_tools',
|
||||
name: '操作',
|
||||
getHide: () => !getDangerEdit(),
|
||||
buttons: [
|
||||
{
|
||||
type: 'dialogForm',
|
||||
|
|
|
|||
|
|
@ -2,6 +2,13 @@ import type { TableData } from 'lib/type/TableData'
|
|||
import { categoryTypes } from '../../data/const'
|
||||
import utils from 'lib/utils'
|
||||
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()
|
||||
types = categoryTypes.filter(item => pathname.includes(item.path))
|
||||
|
||||
|
|
@ -108,7 +115,11 @@ const data: TableData = {
|
|||
type: 'input',
|
||||
must: true,
|
||||
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)
|
||||
},
|
||||
getDisable: () => {
|
||||
return !pathname.includes('/jobs')
|
||||
const pathname = utils.getPathName()
|
||||
if(pathname.includes('/jobs')) {
|
||||
return false
|
||||
}
|
||||
return !getDangerEdit()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue