部分修改
This commit is contained in:
parent
85cc0dc55f
commit
144413041a
|
|
@ -18,7 +18,7 @@
|
||||||
v-else
|
v-else
|
||||||
:to="{
|
:to="{
|
||||||
path: path,
|
path: path,
|
||||||
query: resolveQuery
|
query: resolveQuery,
|
||||||
}"
|
}"
|
||||||
>
|
>
|
||||||
<el-menu-item :index="path">
|
<el-menu-item :index="path">
|
||||||
|
|
@ -30,55 +30,55 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { queryToObject } from '@/utils/util'
|
import { queryToObject } from '@/utils/util'
|
||||||
import { isQuery } from '@/utils/validate'
|
import { isQuery } from '@/utils/validate'
|
||||||
import { computed, defineComponent, toRefs } from 'vue'
|
import { computed, defineComponent, toRefs } from 'vue'
|
||||||
import { RouteRecordRaw } from 'vue-router'
|
import { RouteRecordRaw } from 'vue-router'
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
components: {},
|
components: {},
|
||||||
props: {
|
props: {
|
||||||
route: {
|
route: {
|
||||||
type: Object,
|
type: Object,
|
||||||
default: () => ({})
|
default: () => ({}),
|
||||||
|
},
|
||||||
|
path: {
|
||||||
|
type: String,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
path: {
|
setup(props) {
|
||||||
type: String
|
const { path, route } = toRefs(props)
|
||||||
}
|
// 是否有子路由
|
||||||
},
|
const hasChildren = computed(() => {
|
||||||
setup(props) {
|
const children: RouteRecordRaw[] = route.value.children ?? []
|
||||||
const { path, route } = toRefs(props)
|
return !!children.filter((item) => !item.meta?.hidden).length
|
||||||
// 是否有子路由
|
})
|
||||||
const hasChildren = computed(() => {
|
// 解析路径,后台上传的并非完整路径
|
||||||
const children: RouteRecordRaw[] = route.value.children ?? []
|
const resolvePath = computed(() => (p?: string) => {
|
||||||
return !!children.filter(item => !item.meta?.hidden).length
|
return p !== undefined ? `${path.value}/${p}` : path.value
|
||||||
})
|
})
|
||||||
// 解析路径,后台上传的并非完整路径
|
// 解析参数'{id:1}'|| id=1 => {id: 1}
|
||||||
const resolvePath = computed(() => (p?: string) => {
|
const resolveQuery = computed(() => {
|
||||||
return p !== undefined ? `${path.value}/${p}` : path.value
|
const query = route.value.query
|
||||||
})
|
try {
|
||||||
// 解析参数'{id:1}'|| id=1 => {id: 1}
|
if (isQuery(query)) {
|
||||||
const resolveQuery = computed(() => {
|
return queryToObject(query)
|
||||||
const query = route.value.query
|
} else {
|
||||||
try {
|
return JSON.parse(query)
|
||||||
if (isQuery(query)) {
|
}
|
||||||
return queryToObject(query)
|
} catch (error) {}
|
||||||
} else {
|
})
|
||||||
return JSON.parse(query)
|
|
||||||
}
|
|
||||||
} catch (error) {}
|
|
||||||
})
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
hasChildren,
|
hasChildren,
|
||||||
resolvePath,
|
resolvePath,
|
||||||
resolveQuery
|
resolveQuery,
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.iconfont {
|
.iconfont {
|
||||||
font-size: 26px;
|
font-size: 18px;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
||||||
|
|
@ -70,6 +70,7 @@
|
||||||
import { ElForm } from 'element-plus'
|
import { ElForm } from 'element-plus'
|
||||||
import { useAdmin } from '@/core/hooks/app'
|
import { useAdmin } from '@/core/hooks/app'
|
||||||
import FooterBtns from '@/components/footer-btns/index.vue'
|
import FooterBtns from '@/components/footer-btns/index.vue'
|
||||||
|
import { ElMessage } from 'element-plus'
|
||||||
import { apiDeptAdd, apiDeptEdit, apiDeptDetail, apiDeptLists } from '@/api/organize'
|
import { apiDeptAdd, apiDeptEdit, apiDeptDetail, apiDeptLists } from '@/api/organize'
|
||||||
|
|
||||||
const { router, route } = useAdmin()
|
const { router, route } = useAdmin()
|
||||||
|
|
@ -169,6 +170,7 @@
|
||||||
: apiDeptAdd(formData.value)
|
: apiDeptAdd(formData.value)
|
||||||
promise.then(() => {
|
promise.then(() => {
|
||||||
setTimeout(() => router.go(-1), 500)
|
setTimeout(() => router.go(-1), 500)
|
||||||
|
ElMessage({ type: 'success', message: '保存成功' })
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -77,6 +77,7 @@
|
||||||
import Popup from '@/components/popup/index.vue'
|
import Popup from '@/components/popup/index.vue'
|
||||||
import { flatten } from '@/utils/util'
|
import { flatten } from '@/utils/util'
|
||||||
import { apiDeptLists, apiDeptDelete } from '@/api/organize'
|
import { apiDeptLists, apiDeptDelete } from '@/api/organize'
|
||||||
|
import { ElMessage } from 'element-plus'
|
||||||
|
|
||||||
// 表单数据
|
// 表单数据
|
||||||
const formData = reactive({
|
const formData = reactive({
|
||||||
|
|
@ -108,6 +109,7 @@
|
||||||
const handleDelete = (id: number) => {
|
const handleDelete = (id: number) => {
|
||||||
apiDeptDelete({ id }).then(() => {
|
apiDeptDelete({ id }).then(() => {
|
||||||
getDeptLists()
|
getDeptLists()
|
||||||
|
ElMessage({ type: 'success', message: '删除成功' })
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@
|
||||||
import { computed, defineComponent, onMounted, reactive, Ref, ref, toRefs } from 'vue'
|
import { computed, defineComponent, onMounted, reactive, Ref, ref, toRefs } from 'vue'
|
||||||
import FooterBtns from '@/components/footer-btns/index.vue'
|
import FooterBtns from '@/components/footer-btns/index.vue'
|
||||||
import { apiPostAdd, apiPostEdit, apiPostDetail } from '@/api/organize'
|
import { apiPostAdd, apiPostEdit, apiPostDetail } from '@/api/organize'
|
||||||
import { ElForm } from 'element-plus'
|
import { ElForm, ElMessage } from 'element-plus'
|
||||||
import { useAdmin } from '@/core/hooks/app'
|
import { useAdmin } from '@/core/hooks/app'
|
||||||
|
|
||||||
const { router, route } = useAdmin()
|
const { router, route } = useAdmin()
|
||||||
|
|
@ -119,6 +119,7 @@
|
||||||
: apiPostAdd(formData.value)
|
: apiPostAdd(formData.value)
|
||||||
promise.then(() => {
|
promise.then(() => {
|
||||||
setTimeout(() => router.go(-1), 500)
|
setTimeout(() => router.go(-1), 500)
|
||||||
|
ElMessage({ type: 'success', message: '保存成功' })
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -80,6 +80,7 @@
|
||||||
import Popup from '@/components/popup/index.vue'
|
import Popup from '@/components/popup/index.vue'
|
||||||
import { usePages } from '@/core/hooks/pages'
|
import { usePages } from '@/core/hooks/pages'
|
||||||
import { apiPostLists, apiPostDelete } from '@/api/organize'
|
import { apiPostLists, apiPostDelete } from '@/api/organize'
|
||||||
|
import { ElMessage } from 'element-plus'
|
||||||
|
|
||||||
// 表单数据
|
// 表单数据
|
||||||
const formData = reactive({
|
const formData = reactive({
|
||||||
|
|
@ -100,6 +101,7 @@
|
||||||
id,
|
id,
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
requestApi()
|
requestApi()
|
||||||
|
ElMessage({ type: 'success', message: '删除成功' })
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue