调整代码
This commit is contained in:
parent
cf1e71c04d
commit
f57e0e2b40
|
|
@ -48,7 +48,7 @@
|
||||||
icon="ArrowRight"
|
icon="ArrowRight"
|
||||||
:props="{
|
:props="{
|
||||||
children: 'children',
|
children: 'children',
|
||||||
label: 'menuName'
|
label: 'menuName',
|
||||||
}"
|
}"
|
||||||
empty-text=""
|
empty-text=""
|
||||||
show-checkbox
|
show-checkbox
|
||||||
|
|
@ -65,23 +65,17 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { defineComponent, reactive, onMounted, Ref, ref, toRefs } from 'vue'
|
import { defineComponent, reactive, onMounted, Ref, ref, toRefs } from 'vue'
|
||||||
import {
|
import { apiConfigGetMenu, apiConfigGetAuth, apiRoleAdd, apiRoleEdit, apiRoleDetail } from '@/api/auth'
|
||||||
apiConfigGetMenu,
|
import { ElInput, ElForm } from 'element-plus'
|
||||||
apiConfigGetAuth,
|
import FooterBtns from '@/components/footer-btns/index.vue'
|
||||||
apiRoleAdd,
|
import { useAdmin } from '@/core/hooks/app'
|
||||||
apiRoleEdit,
|
import { flatten } from '@/utils/util'
|
||||||
apiRoleDetail
|
import { ElMessage } from 'element-plus'
|
||||||
} from '@/api/auth'
|
|
||||||
import { ElInput, ElForm } from 'element-plus'
|
|
||||||
import FooterBtns from '@/components/footer-btns/index.vue'
|
|
||||||
import { useAdmin } from '@/core/hooks/app'
|
|
||||||
import { flatten } from '@/utils/util'
|
|
||||||
import { ElMessage } from 'element-plus'
|
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
components: {
|
components: {
|
||||||
FooterBtns
|
FooterBtns,
|
||||||
},
|
},
|
||||||
setup() {
|
setup() {
|
||||||
const { route, router } = useAdmin()
|
const { route, router } = useAdmin()
|
||||||
|
|
@ -98,13 +92,13 @@ export default defineComponent({
|
||||||
menus: [], // 权限,就选中的菜单id
|
menus: [], // 权限,就选中的菜单id
|
||||||
isDisable: 0,
|
isDisable: 0,
|
||||||
sort: '',
|
sort: '',
|
||||||
menuIds: '' // 菜单ID数组,逗号隔开
|
menuIds: '', // 菜单ID数组,逗号隔开
|
||||||
},
|
},
|
||||||
|
|
||||||
menu: {
|
menu: {
|
||||||
permissionsTree: [], // 菜单
|
permissionsTree: [], // 菜单
|
||||||
allAuthKeys: [] // 菜单全部的id
|
allAuthKeys: [], // 菜单全部的id
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -115,17 +109,17 @@ export default defineComponent({
|
||||||
required: true,
|
required: true,
|
||||||
message: '请输入角色名称',
|
message: '请输入角色名称',
|
||||||
trigger: ['blur'],
|
trigger: ['blur'],
|
||||||
pattern: /(^[^\s]*$)/ // 不能输入空格
|
pattern: /(^[^\s]*$)/, // 不能输入空格
|
||||||
}
|
},
|
||||||
],
|
],
|
||||||
sort: [
|
sort: [
|
||||||
{
|
{
|
||||||
required: true,
|
required: true,
|
||||||
message: '请输入排序',
|
message: '请输入排序',
|
||||||
trigger: 'blur',
|
trigger: 'blur',
|
||||||
pattern: /(^[0-9]\d*$)/
|
pattern: /(^[0-9]\d*$)/,
|
||||||
}
|
},
|
||||||
]
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
// 确定提交
|
// 确定提交
|
||||||
|
|
@ -161,7 +155,6 @@ export default defineComponent({
|
||||||
const roleAdd = () => {
|
const roleAdd = () => {
|
||||||
apiRoleAdd({ ...formData.value })
|
apiRoleAdd({ ...formData.value })
|
||||||
.then((res: any) => {
|
.then((res: any) => {
|
||||||
console.log('res', res)
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
router.back()
|
router.back()
|
||||||
}, 500)
|
}, 500)
|
||||||
|
|
@ -180,7 +173,7 @@ export default defineComponent({
|
||||||
|
|
||||||
apiRoleEdit({
|
apiRoleEdit({
|
||||||
...formData.value,
|
...formData.value,
|
||||||
id: id.value
|
id: id.value,
|
||||||
})
|
})
|
||||||
.then((res: any) => {
|
.then((res: any) => {
|
||||||
console.log('res', res)
|
console.log('res', res)
|
||||||
|
|
@ -197,7 +190,7 @@ export default defineComponent({
|
||||||
// 角色详情
|
// 角色详情
|
||||||
const roleDetail = () => {
|
const roleDetail = () => {
|
||||||
apiRoleDetail({
|
apiRoleDetail({
|
||||||
id: id.value
|
id: id.value,
|
||||||
})
|
})
|
||||||
.then((res: any) => {
|
.then((res: any) => {
|
||||||
console.log('res', res)
|
console.log('res', res)
|
||||||
|
|
@ -217,7 +210,7 @@ export default defineComponent({
|
||||||
if (!data.id) {
|
if (!data.id) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const index = formData.value.menus.findIndex(item => item == data.id)
|
const index = formData.value.menus.findIndex((item) => item == data.id)
|
||||||
if (checked) {
|
if (checked) {
|
||||||
index == -1 && (formData.value.menus as any).push(data.id)
|
index == -1 && (formData.value.menus as any).push(data.id)
|
||||||
return
|
return
|
||||||
|
|
@ -262,16 +255,16 @@ export default defineComponent({
|
||||||
onSubmit,
|
onSubmit,
|
||||||
handlePermissionsCheckChange,
|
handlePermissionsCheckChange,
|
||||||
close,
|
close,
|
||||||
allSelect
|
allSelect,
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.role-edit {
|
.role-edit {
|
||||||
:deep .el-textarea {
|
:deep .el-textarea {
|
||||||
width: 340px;
|
width: 340px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue