mirror of
https://github.com/zclzone/vue-naive-admin.git
synced 2026-01-23 08:00:22 +08:00
style: lint
This commit is contained in:
@@ -12,10 +12,10 @@
|
||||
<h3>菜单</h3>
|
||||
<div class="flex">
|
||||
<n-input v-model:value="pattern" placeholder="搜索" clearable />
|
||||
<n-button class="ml-12" type="primary" @click="handleAdd()">
|
||||
<NButton class="ml-12" type="primary" @click="handleAdd()">
|
||||
<i class="i-material-symbols:add mr-4 text-14" />
|
||||
新增
|
||||
</n-button>
|
||||
</NButton>
|
||||
</div>
|
||||
|
||||
<n-tree
|
||||
@@ -28,8 +28,8 @@
|
||||
:on-update:selected-keys="onSelect"
|
||||
key-field="code"
|
||||
label-field="name"
|
||||
block-line
|
||||
default-expand-all
|
||||
|
||||
block-line default-expand-all
|
||||
/>
|
||||
</n-space>
|
||||
|
||||
@@ -39,9 +39,9 @@
|
||||
|
||||
<script setup>
|
||||
import { withModifiers } from 'vue'
|
||||
import ResAddOrEdit from './ResAddOrEdit.vue'
|
||||
import { NButton } from 'naive-ui'
|
||||
import api from '../api'
|
||||
import ResAddOrEdit from './ResAddOrEdit.vue'
|
||||
|
||||
defineProps({
|
||||
treeData: {
|
||||
@@ -86,7 +86,7 @@ function renderSuffix({ option }) {
|
||||
size: 'tiny',
|
||||
onClick: withModifiers(() => handleAdd({ parentId: option.id }), ['stop']),
|
||||
},
|
||||
{ default: () => '新增' }
|
||||
{ default: () => '新增' },
|
||||
),
|
||||
|
||||
h(
|
||||
@@ -98,7 +98,7 @@ function renderSuffix({ option }) {
|
||||
style: 'margin-left: 12px;',
|
||||
onClick: withModifiers(() => handleDelete(option), ['stop']),
|
||||
},
|
||||
{ default: () => '删除' }
|
||||
{ default: () => '删除' },
|
||||
),
|
||||
]
|
||||
}
|
||||
@@ -113,7 +113,8 @@ function handleDelete(item) {
|
||||
$message.success('删除成功', { key: 'deleteMenu' })
|
||||
emit('refresh')
|
||||
emit('update:currentMenu', null)
|
||||
} catch (error) {
|
||||
}
|
||||
catch (error) {
|
||||
$message.destroy('deleteMenu')
|
||||
}
|
||||
},
|
||||
|
||||
@@ -99,8 +99,12 @@
|
||||
<QuestionLabel label="显示状态" content="控制是否在菜单栏显示,不影响路由注册" />
|
||||
</template>
|
||||
<n-switch v-model:value="modalForm.show">
|
||||
<template #checked>显示</template>
|
||||
<template #unchecked>隐藏</template>
|
||||
<template #checked>
|
||||
显示
|
||||
</template>
|
||||
<template #unchecked>
|
||||
隐藏
|
||||
</template>
|
||||
</n-switch>
|
||||
</n-form-item-gi>
|
||||
<n-form-item-gi :span="12" path="enable">
|
||||
@@ -111,8 +115,12 @@
|
||||
/>
|
||||
</template>
|
||||
<n-switch v-model:value="modalForm.enable">
|
||||
<template #checked>启用</template>
|
||||
<template #unchecked>禁用</template>
|
||||
<template #checked>
|
||||
启用
|
||||
</template>
|
||||
<template #unchecked>
|
||||
禁用
|
||||
</template>
|
||||
</n-switch>
|
||||
</n-form-item-gi>
|
||||
<n-form-item-gi v-if="modalForm.type === 'MENU'" :span="12" path="keepAlive">
|
||||
@@ -123,8 +131,12 @@
|
||||
/>
|
||||
</template>
|
||||
<n-switch v-model:value="modalForm.keepAlive">
|
||||
<template #checked>是</template>
|
||||
<template #unchecked>否</template>
|
||||
<template #checked>
|
||||
是
|
||||
</template>
|
||||
<template #unchecked>
|
||||
否
|
||||
</template>
|
||||
</n-switch>
|
||||
</n-form-item-gi>
|
||||
<n-form-item-gi
|
||||
@@ -147,12 +159,12 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { MeModal } from '@/components'
|
||||
import QuestionLabel from './QuestionLabel.vue'
|
||||
import { useForm, useModal } from '@/composables'
|
||||
import api from '../api'
|
||||
import pagePathes from 'isme:page-pathes'
|
||||
import icons from 'isme:icons'
|
||||
import api from '../api'
|
||||
import QuestionLabel from './QuestionLabel.vue'
|
||||
import { MeModal } from '@/components'
|
||||
import { useForm, useModal } from '@/composables'
|
||||
|
||||
const props = defineProps({
|
||||
menus: {
|
||||
@@ -165,10 +177,10 @@ const emit = defineEmits(['refresh'])
|
||||
const menuOptions = computed(() => {
|
||||
return [{ name: '根菜单', id: '', children: props.menus || [] }]
|
||||
})
|
||||
const componentOptions = pagePathes.map((path) => ({ label: path, value: path }))
|
||||
const iconOptions = icons.map((item) => ({
|
||||
const componentOptions = pagePathes.map(path => ({ label: path, value: path }))
|
||||
const iconOptions = icons.map(item => ({
|
||||
label: () =>
|
||||
h('span', { class: 'flex items-center' }, [h('i', { class: item + ' text-18 mr-8' }), item]),
|
||||
h('span', { class: 'flex items-center' }, [h('i', { class: `${item} text-18 mr-8` }), item]),
|
||||
value: item,
|
||||
}))
|
||||
const layoutOptions = [
|
||||
@@ -203,17 +215,20 @@ async function onSave() {
|
||||
okLoading.value = true
|
||||
try {
|
||||
let newFormData
|
||||
if (!modalForm.value.parentId) modalForm.value.parentId = null
|
||||
if (!modalForm.value.parentId)
|
||||
modalForm.value.parentId = null
|
||||
if (modalAction.value === 'add') {
|
||||
const res = await api.addPermission(modalForm.value)
|
||||
newFormData = res.data
|
||||
} else if (modalAction.value === 'edit') {
|
||||
}
|
||||
else if (modalAction.value === 'edit') {
|
||||
await api.savePermission(modalForm.value.id, modalForm.value)
|
||||
}
|
||||
okLoading.value = false
|
||||
$message.success('保存成功')
|
||||
emit('refresh', modalAction.value === 'add' ? newFormData : modalForm.value)
|
||||
} catch (error) {
|
||||
}
|
||||
catch (error) {
|
||||
console.error(error)
|
||||
okLoading.value = false
|
||||
return false
|
||||
|
||||
Reference in New Issue
Block a user