mirror of
				https://github.com/continew-org/continew-admin-ui.git
				synced 2025-10-31 22:57:15 +08:00 
			
		
		
		
	chore(system/storage): 完善存储管理权限指令
This commit is contained in:
		| @@ -4,7 +4,7 @@ import hasRole from './permission/hasRole' | ||||
|  | ||||
| export default { | ||||
|   install(Vue: App) { | ||||
|     Vue.directive('hasPerm', hasPerm) | ||||
|     Vue.directive('hasRole', hasRole) | ||||
|     Vue.directive('permission', hasPerm) | ||||
|     Vue.directive('role', hasRole) | ||||
|   } | ||||
| } | ||||
|   | ||||
| @@ -2,8 +2,8 @@ import type { DirectiveBinding, Directive } from 'vue' | ||||
| import { useUserStore } from '@/stores' | ||||
|  | ||||
| /** | ||||
|  * @desc v-hasPerm 操作权限处理 | ||||
|  * @desc 使用 v-hasPerm="['home:btn:add']" | ||||
|  * @desc v-permission 操作权限处理 | ||||
|  * @desc 使用 v-permission="['system:user:add']" | ||||
|  */ | ||||
| function checkPermission(el: HTMLElement, binding: DirectiveBinding) { | ||||
|   const userStore = useUserStore() | ||||
|   | ||||
| @@ -112,6 +112,13 @@ const { form, resetForm } = useForm<StorageReq>({ | ||||
|   name: '', | ||||
|   code: '', | ||||
|   type: 2, | ||||
|   accessKey: undefined, | ||||
|   secretKey: undefined, | ||||
|   endpoint: undefined, | ||||
|   bucketName: undefined, | ||||
|   domain: undefined, | ||||
|   description: undefined, | ||||
|   isDefault: false, | ||||
|   sort: 999, | ||||
|   status: 1 | ||||
| }) | ||||
| @@ -2,7 +2,6 @@ | ||||
|   <div class="gi_page"> | ||||
|     <a-card title="存储管理" class="general-card"> | ||||
|       <GiTable | ||||
|         ref="tableRef" | ||||
|         row-key="id" | ||||
|         :data="dataList" | ||||
|         :columns="columns" | ||||
| @@ -27,7 +26,7 @@ | ||||
|           <a-button @click="reset">重置</a-button> | ||||
|         </template> | ||||
|         <template #custom-right> | ||||
|           <a-button type="primary" @click="onAdd"> | ||||
|           <a-button v-has-perm="['system:storage:add']" type="primary" @click="onAdd"> | ||||
|             <template #icon><icon-plus /></template> | ||||
|             <span>新增</span> | ||||
|           </a-button> | ||||
| @@ -48,11 +47,9 @@ | ||||
|         </template> | ||||
|         <template #action="{ record }"> | ||||
|           <a-space> | ||||
|             <template #split> | ||||
|               <a-divider direction="vertical" :margin="0" /> | ||||
|             </template> | ||||
|             <a-link @click="onUpdate(record)">修改</a-link> | ||||
|             <a-link v-permission="['system:storage:update']" @click="onUpdate(record)">修改</a-link> | ||||
|             <a-link | ||||
|               v-permission="['system:storage:delete']" | ||||
|               status="danger" | ||||
|               :title="record.isDefault ? '默认存储库不能删除' : undefined" | ||||
|               :disabled="record.disabled" | ||||
| @@ -65,17 +62,18 @@ | ||||
|       </GiTable> | ||||
|     </a-card> | ||||
|  | ||||
|     <AddStorageModal ref="AddStorageModalRef" @save-success="search" /> | ||||
|     <StorageAddModal ref="StorageAddModalRef" @save-success="search" /> | ||||
|   </div> | ||||
| </template> | ||||
|  | ||||
| <script setup lang="ts"> | ||||
| import { listStorage, deleteStorage, type StorageResp } from '@/apis' | ||||
| import StorageAddModal from './StorageAddModal.vue' | ||||
| import type { TableInstance } from '@arco-design/web-vue' | ||||
| import AddStorageModal from './AddStorageModal.vue' | ||||
| import { useTable } from '@/hooks' | ||||
| import { useDict } from '@/hooks/app' | ||||
| import { isMobile } from '@/utils' | ||||
| import has from '@/utils/has' | ||||
| import { DisEnableStatusList } from '@/constant/common' | ||||
|  | ||||
| defineOptions({ name: 'Storage' }) | ||||
| @@ -102,7 +100,14 @@ const columns: TableInstance['columns'] = [ | ||||
|   { title: '创建时间', dataIndex: 'createTime', width: 180 }, | ||||
|   { title: '修改人', dataIndex: 'updateUserString', show: false, ellipsis: true, tooltip: true }, | ||||
|   { title: '修改时间', dataIndex: 'updateTime', width: 180, show: false }, | ||||
|   { title: '操作', slotName: 'action', width: 130, align: 'center', fixed: !isMobile() ? 'right' : undefined } | ||||
|   { | ||||
|     title: '操作', | ||||
|     slotName: 'action', | ||||
|     width: 130, | ||||
|     show: has.hasPermOr(['system:storage:update', 'system:storage:delete']), | ||||
|     align: 'center', | ||||
|     fixed: !isMobile() ? 'right' : undefined | ||||
|   } | ||||
| ] | ||||
|  | ||||
| const queryForm = reactive({ | ||||
| @@ -131,15 +136,15 @@ const onDelete = (item: StorageResp) => { | ||||
|   return handleDelete(() => deleteStorage(item.id), { content: `是否确定删除存储 [${item.name}]?`, showModal: true }) | ||||
| } | ||||
|  | ||||
| const AddStorageModalRef = ref<InstanceType<typeof AddStorageModal>>() | ||||
| const StorageAddModalRef = ref<InstanceType<typeof StorageAddModal>>() | ||||
| // 新增 | ||||
| const onAdd = () => { | ||||
|   AddStorageModalRef.value?.onAdd() | ||||
|   StorageAddModalRef.value?.onAdd() | ||||
| } | ||||
|  | ||||
| // 修改 | ||||
| const onUpdate = (item: StorageResp) => { | ||||
|   AddStorageModalRef.value?.onUpdate(item.id) | ||||
|   StorageAddModalRef.value?.onUpdate(item.id) | ||||
| } | ||||
| </script> | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user