mirror of
https://github.com/1Panel-dev/MaxKB.git
synced 2025-12-29 16:12:55 +00:00
fix: deleteButtonDisabled
This commit is contained in:
parent
6a87ccd908
commit
ee967606cf
|
|
@ -62,7 +62,7 @@ interface FormItemModel {
|
|||
rules?: Arrayable<FormItemRule>,
|
||||
hidden?: (e: any) => boolean,
|
||||
selectProps?: {
|
||||
options?: { label: string, value: string }[]
|
||||
options?: { label: string, value: string, disabledFunction?: (e: any) => boolean }[]
|
||||
placeholder?: string
|
||||
multiple?: boolean
|
||||
clearableFunction?: (e: any) => boolean
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
:placeholder="model.selectProps?.placeholder ?? $t('common.selectPlaceholder')" :clearable="model.selectProps?.clearableFunction?model.selectProps?.clearableFunction?.(element): true" filterable
|
||||
multiple style="width: 100%" collapse-tags collapse-tags-tooltip v-bind="model.selectProps">
|
||||
<el-option v-for="opt in model.selectProps?.options" :key="opt.value" :label="opt.label"
|
||||
:value="opt.value" />
|
||||
:value="opt.value" :disabled="opt.disabledFunction?.(element)" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<!-- 删除按钮 -->
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@
|
|||
</el-drawer>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import {ref, reactive, watch, onBeforeMount} from 'vue'
|
||||
import {ref, reactive, watch, onBeforeMount, computed} from 'vue'
|
||||
import type {FormInstance} from 'element-plus'
|
||||
import userManageApi from '@/api/system/user-manage'
|
||||
import {MsgSuccess} from '@/utils/message'
|
||||
|
|
@ -103,9 +103,10 @@ const roleFormItem = ref<FormItemModel[]>([]);
|
|||
const adminRoleList = ref<any[]>([])
|
||||
const workspaceFormItem = ref<FormItemModel[]>([])
|
||||
|
||||
const isAdmin = computed(() => userForm.value['id'] === 'f0dd8f71-e4ee-11ee-8c84-a8a1595801ab')
|
||||
|
||||
function deleteButtonDisabled(element: any) {
|
||||
// 内置的admin
|
||||
if (userForm.value['id'] === 'f0dd8f71-e4ee-11ee-8c84-a8a1595801ab' && element.role_id === 'ADMIN') {
|
||||
if (isAdmin.value && ['ADMIN','WORKSPACE_MANAGE', 'USER'].includes(element.role_id)) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
|
|
@ -161,15 +162,15 @@ async function getWorkspaceFormItem() {
|
|||
},
|
||||
],
|
||||
selectProps: {
|
||||
// TODO
|
||||
options:
|
||||
res.data?.map((item) => ({
|
||||
label: item.name,
|
||||
value: item.id,
|
||||
disabledFunction: (e: any)=> isAdmin.value && ['WORKSPACE_MANAGE', 'USER'].includes(e.role_id) && item.id === 'default'
|
||||
})) || [],
|
||||
placeholder: `${t('common.selectPlaceholder')}${t('views.role.member.workspace')}`,
|
||||
clearableFunction: (e)=>{
|
||||
return !(userForm.value['id'] === 'f0dd8f71-e4ee-11ee-8c84-a8a1595801ab' && ['WORKSPACE_MANAGE', 'USER'].includes(e.role_id))
|
||||
return !(isAdmin.value && ['WORKSPACE_MANAGE', 'USER'].includes(e.role_id))
|
||||
}
|
||||
},
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in New Issue