mirror of
https://github.com/continew-org/continew-admin-ui.git
synced 2025-09-10 20:57:10 +08:00
refactor: 优化系统管理相关代码
This commit is contained in:
@@ -94,7 +94,7 @@
|
||||
<script setup lang="ts">
|
||||
import { type FormInstance, Message } from '@arco-design/web-vue'
|
||||
import { useWindowSize } from '@vueuse/core'
|
||||
import { addStorage, getStorage, updateStorage } from '@/apis/system'
|
||||
import { addStorage, getStorage, updateStorage } from '@/apis/system/storage'
|
||||
import { useForm } from '@/hooks'
|
||||
import { useDict } from '@/hooks/app'
|
||||
import { encryptByRsa } from '@/utils/encrypt'
|
||||
@@ -103,13 +103,15 @@ import { isIPv4 } from '@/utils/validate'
|
||||
const emit = defineEmits<{
|
||||
(e: 'save-success'): void
|
||||
}>()
|
||||
|
||||
const { width } = useWindowSize()
|
||||
const { storage_type_enum } = useDict('storage_type_enum')
|
||||
|
||||
const dataId = ref('')
|
||||
const visible = ref(false)
|
||||
const isUpdate = computed(() => !!dataId.value)
|
||||
const title = computed(() => (isUpdate.value ? '修改存储' : '新增存储'))
|
||||
const formRef = ref<FormInstance>()
|
||||
const { storage_type_enum } = useDict('storage_type_enum')
|
||||
|
||||
const rules: FormInstance['rules'] = {
|
||||
name: [{ required: true, message: '请输入名称' }],
|
||||
@@ -152,23 +154,6 @@ const reset = () => {
|
||||
resetForm()
|
||||
}
|
||||
|
||||
const visible = ref(false)
|
||||
// 新增
|
||||
const onAdd = () => {
|
||||
reset()
|
||||
dataId.value = ''
|
||||
visible.value = true
|
||||
}
|
||||
|
||||
// 修改
|
||||
const onUpdate = async (id: string) => {
|
||||
reset()
|
||||
dataId.value = id
|
||||
const res = await getStorage(id)
|
||||
Object.assign(form, res.data)
|
||||
visible.value = true
|
||||
}
|
||||
|
||||
// 保存
|
||||
const save = async () => {
|
||||
try {
|
||||
@@ -193,5 +178,21 @@ const save = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
// 新增
|
||||
const onAdd = () => {
|
||||
reset()
|
||||
dataId.value = ''
|
||||
visible.value = true
|
||||
}
|
||||
|
||||
// 修改
|
||||
const onUpdate = async (id: string) => {
|
||||
reset()
|
||||
dataId.value = id
|
||||
const { data } = await getStorage(id)
|
||||
Object.assign(form, data)
|
||||
visible.value = true
|
||||
}
|
||||
|
||||
defineExpose({ onAdd, onUpdate })
|
||||
</script>
|
||||
|
@@ -1,8 +1,8 @@
|
||||
<template>
|
||||
<div class="table-page">
|
||||
<GiTable
|
||||
row-key="id"
|
||||
title="存储管理"
|
||||
row-key="id"
|
||||
:data="dataList"
|
||||
:columns="columns"
|
||||
:loading="loading"
|
||||
@@ -51,12 +51,12 @@
|
||||
</template>
|
||||
<template #action="{ record }">
|
||||
<a-space>
|
||||
<a-link v-permission="['system:storage:update']" @click="onUpdate(record)">修改</a-link>
|
||||
<a-link v-permission="['system:storage:update']" title="修改" @click="onUpdate(record)">修改</a-link>
|
||||
<a-link
|
||||
v-permission="['system:storage:delete']"
|
||||
status="danger"
|
||||
:title="record.isDefault ? '默认存储不能删除' : undefined"
|
||||
:disabled="record.disabled"
|
||||
:disabled="record.isDefault"
|
||||
:title="record.isDefault ? '默认存储不能删除' : '删除'"
|
||||
@click="onDelete(record)"
|
||||
>
|
||||
删除
|
||||
@@ -71,13 +71,13 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import StorageAddDrawer from './StorageAddDrawer.vue'
|
||||
import { type StorageQuery, type StorageResp, deleteStorage, listStorage } from '@/apis/system'
|
||||
import { type StorageQuery, type StorageResp, deleteStorage, listStorage } from '@/apis/system/storage'
|
||||
import type { TableInstanceColumns } from '@/components/GiTable/type'
|
||||
import { DisEnableStatusList } from '@/constant/common'
|
||||
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: 'SystemStorage' })
|
||||
|
||||
@@ -94,7 +94,6 @@ const {
|
||||
search,
|
||||
handleDelete,
|
||||
} = useTable((page) => listStorage({ ...queryForm, ...page }), { immediate: true })
|
||||
|
||||
const columns: TableInstanceColumns[] = [
|
||||
{
|
||||
title: '序号',
|
||||
@@ -104,8 +103,8 @@ const columns: TableInstanceColumns[] = [
|
||||
},
|
||||
{ title: '名称', dataIndex: 'name', slotName: 'name', width: 140, ellipsis: true, tooltip: true },
|
||||
{ title: '编码', dataIndex: 'code', ellipsis: true, tooltip: true },
|
||||
{ title: '状态', slotName: 'status', align: 'center' },
|
||||
{ title: '类型', slotName: 'type', align: 'center' },
|
||||
{ title: '状态', dataIndex: 'status', slotName: 'status', align: 'center' },
|
||||
{ title: '类型', dataIndex: 'type', slotName: 'type', align: 'center' },
|
||||
{ title: '访问密钥', dataIndex: 'accessKey', ellipsis: true, tooltip: true },
|
||||
{ title: '终端节点', dataIndex: 'endpoint', ellipsis: true, tooltip: true },
|
||||
{ title: '桶名称', dataIndex: 'bucketName', ellipsis: true, tooltip: true },
|
||||
@@ -117,6 +116,7 @@ const columns: TableInstanceColumns[] = [
|
||||
{ title: '修改时间', dataIndex: 'updateTime', width: 180, show: false },
|
||||
{
|
||||
title: '操作',
|
||||
dataIndex: 'action',
|
||||
slotName: 'action',
|
||||
width: 130,
|
||||
align: 'center',
|
||||
@@ -134,7 +134,10 @@ const reset = () => {
|
||||
|
||||
// 删除
|
||||
const onDelete = (record: StorageResp) => {
|
||||
return handleDelete(() => deleteStorage(record.id), { content: `是否确定删除存储 [${record.name}]?`, showModal: true })
|
||||
return handleDelete(() => deleteStorage(record.id), {
|
||||
content: `是否确定删除存储「${record.name}」?`,
|
||||
showModal: true,
|
||||
})
|
||||
}
|
||||
|
||||
const StorageAddDrawerRef = ref<InstanceType<typeof StorageAddDrawer>>()
|
||||
|
Reference in New Issue
Block a user