Skip to content

Commit ee96760

Browse files
committed
fix: deleteButtonDisabled
1 parent 6a87ccd commit ee96760

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

ui/src/api/type/role.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ interface FormItemModel {
6262
rules?: Arrayable<FormItemRule>,
6363
hidden?: (e: any) => boolean,
6464
selectProps?: {
65-
options?: { label: string, value: string }[]
65+
options?: { label: string, value: string, disabledFunction?: (e: any) => boolean }[]
6666
placeholder?: string
6767
multiple?: boolean
6868
clearableFunction?: (e: any) => boolean

ui/src/views/system/role/component/MemberFormContent.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
:placeholder="model.selectProps?.placeholder ?? $t('common.selectPlaceholder')" :clearable="model.selectProps?.clearableFunction?model.selectProps?.clearableFunction?.(element): true" filterable
99
multiple style="width: 100%" collapse-tags collapse-tags-tooltip v-bind="model.selectProps">
1010
<el-option v-for="opt in model.selectProps?.options" :key="opt.value" :label="opt.label"
11-
:value="opt.value" />
11+
:value="opt.value" :disabled="opt.disabledFunction?.(element)" />
1212
</el-select>
1313
</el-form-item>
1414
<!-- 删除按钮 -->

ui/src/views/system/user-manage/component/UserDrawer.vue

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
</el-drawer>
7070
</template>
7171
<script setup lang="ts">
72-
import {ref, reactive, watch, onBeforeMount} from 'vue'
72+
import {ref, reactive, watch, onBeforeMount, computed} from 'vue'
7373
import type {FormInstance} from 'element-plus'
7474
import userManageApi from '@/api/system/user-manage'
7575
import {MsgSuccess} from '@/utils/message'
@@ -103,9 +103,10 @@ const roleFormItem = ref<FormItemModel[]>([]);
103103
const adminRoleList = ref<any[]>([])
104104
const workspaceFormItem = ref<FormItemModel[]>([])
105105
106+
const isAdmin = computed(() => userForm.value['id'] === 'f0dd8f71-e4ee-11ee-8c84-a8a1595801ab')
107+
106108
function deleteButtonDisabled(element: any) {
107-
// 内置的admin
108-
if (userForm.value['id'] === 'f0dd8f71-e4ee-11ee-8c84-a8a1595801ab' && element.role_id === 'ADMIN') {
109+
if (isAdmin.value && ['ADMIN','WORKSPACE_MANAGE', 'USER'].includes(element.role_id)) {
109110
return true
110111
}
111112
return false
@@ -161,15 +162,15 @@ async function getWorkspaceFormItem() {
161162
},
162163
],
163164
selectProps: {
164-
// TODO
165165
options:
166166
res.data?.map((item) => ({
167167
label: item.name,
168168
value: item.id,
169+
disabledFunction: (e: any)=> isAdmin.value && ['WORKSPACE_MANAGE', 'USER'].includes(e.role_id) && item.id === 'default'
169170
})) || [],
170171
placeholder: `${t('common.selectPlaceholder')}${t('views.role.member.workspace')}`,
171172
clearableFunction: (e)=>{
172-
return !(userForm.value['id'] === 'f0dd8f71-e4ee-11ee-8c84-a8a1595801ab' && ['WORKSPACE_MANAGE', 'USER'].includes(e.role_id))
173+
return !(isAdmin.value && ['WORKSPACE_MANAGE', 'USER'].includes(e.role_id))
173174
}
174175
},
175176
},

0 commit comments

Comments
 (0)