diff --git a/internal/http/request/database_server.go b/internal/http/request/database_server.go index 53c9316240..e4021a6354 100644 --- a/internal/http/request/database_server.go +++ b/internal/http/request/database_server.go @@ -12,7 +12,7 @@ type DatabaseServerCreate struct { type DatabaseServerUpdate struct { ID uint `form:"id" json:"id" validate:"required,exists=database_servers id"` - Name string `form:"name" json:"name" validate:"required,not_exists=database_servers name"` + Name string `form:"name" json:"name" validate:"required"` Host string `form:"host" json:"host" validate:"required"` Port uint `form:"port" json:"port" validate:"required,number,gte=1,lte=65535"` Username string `form:"username" json:"username"` diff --git a/web/src/views/database/ServerList.vue b/web/src/views/database/ServerList.vue index cfc1506440..9598c29ef9 100644 --- a/web/src/views/database/ServerList.vue +++ b/web/src/views/database/ServerList.vue @@ -4,6 +4,10 @@ import { NButton, NInput, NInputGroup, NPopconfirm, NTag } from 'naive-ui' import database from '@/api/panel/database' import { formatDateTime } from '@/utils' +import UpdateServerModal from '@/views/database/UpdateServerModal.vue' + +const updateModal = ref(false) +const updateID = ref(0) const columns: any = [ { @@ -114,7 +118,7 @@ const columns: any = [ { title: '操作', key: 'actions', - width: 200, + width: 300, align: 'center', hideInExcel: true, render(row: any) { @@ -148,10 +152,33 @@ const columns: any = [ } } ), + h( + NButton, + { + size: 'small', + type: 'primary', + style: 'margin-left: 15px;', + onClick: () => { + updateID.value = row.id + updateModal.value = true + } + }, + { + default: () => '修改', + icon: renderIcon('material-symbols:edit-outline', { size: 14 }) + } + ), h( NPopconfirm, { - onPositiveClick: () => handleDelete(row.id) + onPositiveClick: () => { + // 防手贱 + if (['local_mysql', 'local_postgresql'].includes(row.name)) { + window.$message.error('内置服务器不能删除,如需删除请卸载对应应用') + return + } + handleDelete(row.id) + } }, { default: () => { @@ -215,7 +242,7 @@ onUnmounted(() => { { pageSizes: [20, 50, 100, 200] }" /> + diff --git a/web/src/views/database/UpdateServerModal.vue b/web/src/views/database/UpdateServerModal.vue new file mode 100644 index 0000000000..d6f9f10dc4 --- /dev/null +++ b/web/src/views/database/UpdateServerModal.vue @@ -0,0 +1,113 @@ + + + + + diff --git a/web/src/views/database/UpdateUserModal.vue b/web/src/views/database/UpdateUserModal.vue index 3d564153da..7cfc8a8ab6 100644 --- a/web/src/views/database/UpdateUserModal.vue +++ b/web/src/views/database/UpdateUserModal.vue @@ -13,7 +13,7 @@ const updateModel = ref({ const handleUpdate = () => { useRequest(() => database.userUpdate(id.value, updateModel.value)).onSuccess(() => { show.value = false - window.$message.success('更新成功') + window.$message.success('修改成功') window.$bus.emit('database-user:refresh') }) } @@ -36,7 +36,7 @@ watch( '编辑', - icon: renderIcon('material-symbols:edit', { size: 14 }) + default: () => '修改', + icon: renderIcon('material-symbols:edit-outline', { size: 14 }) } ), h(