mirror of
https://github.com/continew-org/continew-admin-ui.git
synced 2025-09-15 02:57:08 +08:00
Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
29
src/apis/system/dept.ts
Normal file
29
src/apis/system/dept.ts
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
import http from '@/utils/http'
|
||||||
|
import type * as System from './type'
|
||||||
|
|
||||||
|
const BASE_URL = '/system/dept'
|
||||||
|
|
||||||
|
/** @desc 查询部门列表 */
|
||||||
|
export function listDept(query: System.DeptQuery) {
|
||||||
|
return http.get<System.DeptResp[]>(`${BASE_URL}/tree`, query)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @desc 查询部门详情 */
|
||||||
|
export function getDept(id: string) {
|
||||||
|
return http.get<System.DeptResp>(`${BASE_URL}/${id}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @desc 新增部门 */
|
||||||
|
export function addDept(data: any) {
|
||||||
|
return http.post<boolean>(`${BASE_URL}`, data)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @desc 修改部门 */
|
||||||
|
export function updateDept(data: any, id: string) {
|
||||||
|
return http.put(`${BASE_URL}/${id}`, data)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @desc 删除部门 */
|
||||||
|
export function deleteDept(id: string) {
|
||||||
|
return http.del(`${BASE_URL}/${id}`)
|
||||||
|
}
|
@@ -1 +1,3 @@
|
|||||||
|
export * from './dept'
|
||||||
export * from './log'
|
export * from './log'
|
||||||
|
export * from './storage'
|
||||||
|
29
src/apis/system/storage.ts
Normal file
29
src/apis/system/storage.ts
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
import http from '@/utils/http'
|
||||||
|
import type * as System from './type'
|
||||||
|
|
||||||
|
const BASE_URL = '/system/storage'
|
||||||
|
|
||||||
|
/** @desc 查询存储列表 */
|
||||||
|
export function listStorage(query: System.StorageQuery) {
|
||||||
|
return http.get<PageRes<System.StorageResp[]>>(`${BASE_URL}`, query)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @desc 查询存储详情 */
|
||||||
|
export function getStorage(id: string) {
|
||||||
|
return http.get<System.StorageResp>(`${BASE_URL}/${id}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @desc 新增存储 */
|
||||||
|
export function addStorage(data: any) {
|
||||||
|
return http.post(`${BASE_URL}`, data)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @desc 修改存储 */
|
||||||
|
export function updateStorage(data: any, id: string) {
|
||||||
|
return http.put(`${BASE_URL}/${id}`, data)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @desc 删除存储 */
|
||||||
|
export function deleteStorage(id: string) {
|
||||||
|
return http.del(`${BASE_URL}/${id}`)
|
||||||
|
}
|
@@ -1,3 +1,24 @@
|
|||||||
|
/** 系统部门类型 */
|
||||||
|
export interface DeptResp {
|
||||||
|
id: string
|
||||||
|
name: string
|
||||||
|
sort: number
|
||||||
|
status: 1 | 2
|
||||||
|
isSystem: boolean
|
||||||
|
description: string
|
||||||
|
createUserString: string
|
||||||
|
createTime: string
|
||||||
|
updateUserString: string
|
||||||
|
updateTime: string
|
||||||
|
parentId: string
|
||||||
|
children: DeptResp[]
|
||||||
|
}
|
||||||
|
export interface DeptQuery {
|
||||||
|
description?: string
|
||||||
|
status?: number
|
||||||
|
sort?: Array<string>
|
||||||
|
}
|
||||||
|
|
||||||
/** 系统日志类型 */
|
/** 系统日志类型 */
|
||||||
export interface LogResp {
|
export interface LogResp {
|
||||||
id: string
|
id: string
|
||||||
@@ -31,3 +52,28 @@ export interface LogQuery extends PageQuery {
|
|||||||
createTime?: string
|
createTime?: string
|
||||||
status?: number
|
status?: number
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 系统存储类型 */
|
||||||
|
export type StorageResp = {
|
||||||
|
id: string
|
||||||
|
name: string
|
||||||
|
code: string
|
||||||
|
type: number
|
||||||
|
accessKey: string
|
||||||
|
secretKey: string
|
||||||
|
endpoint: string
|
||||||
|
bucketName: string
|
||||||
|
domain: string
|
||||||
|
description: string
|
||||||
|
isDefault: boolean
|
||||||
|
sort: number
|
||||||
|
status: number
|
||||||
|
createUserString: string
|
||||||
|
createTime: string
|
||||||
|
updateUserString: string
|
||||||
|
updateTime: string
|
||||||
|
}
|
||||||
|
export interface StorageQuery extends PageQuery {
|
||||||
|
description?: string
|
||||||
|
status?: number
|
||||||
|
}
|
1
src/types/components.d.ts
vendored
1
src/types/components.d.ts
vendored
@@ -37,5 +37,6 @@ declare module 'vue' {
|
|||||||
ParentView: typeof import('./../components/ParentView/index.vue')['default']
|
ParentView: typeof import('./../components/ParentView/index.vue')['default']
|
||||||
RouterLink: typeof import('vue-router')['RouterLink']
|
RouterLink: typeof import('vue-router')['RouterLink']
|
||||||
RouterView: typeof import('vue-router')['RouterView']
|
RouterView: typeof import('vue-router')['RouterView']
|
||||||
|
TextCopy: typeof import('./../components/TextCopy/index.vue')['default']
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
151
src/views/system/dept/AddDeptModal.vue
Normal file
151
src/views/system/dept/AddDeptModal.vue
Normal file
@@ -0,0 +1,151 @@
|
|||||||
|
<template>
|
||||||
|
<a-modal
|
||||||
|
v-model:visible="visible"
|
||||||
|
:title="title"
|
||||||
|
:mask-closable="false"
|
||||||
|
:esc-to-close="false"
|
||||||
|
:modal-style="{ maxWidth: '520px' }"
|
||||||
|
width="90%"
|
||||||
|
@before-ok="save"
|
||||||
|
@close="reset"
|
||||||
|
>
|
||||||
|
<GiForm ref="formRef" v-model="form" :options="options" :columns="columns" />
|
||||||
|
</a-modal>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { getDept, addDept, updateDept } from '@/apis'
|
||||||
|
import type { DeptReq } from './type'
|
||||||
|
import { Message } from '@arco-design/web-vue'
|
||||||
|
import { GiForm, type Columns } from '@/components/GiForm'
|
||||||
|
import { useForm } from '@/hooks'
|
||||||
|
import { useDept } from '@/hooks/app'
|
||||||
|
|
||||||
|
const { deptList, getDeptList } = useDept()
|
||||||
|
|
||||||
|
const dataId = ref('')
|
||||||
|
const isUpdate = computed(() => !!dataId.value)
|
||||||
|
const title = computed(() => (isUpdate.value ? '修改部门' : '新增部门'))
|
||||||
|
const formRef = ref<InstanceType<typeof GiForm>>()
|
||||||
|
|
||||||
|
const options: Options = {
|
||||||
|
form: {},
|
||||||
|
col: { xs: 24, sm: 24, md: 24, lg: 24, xl: 24, xxl: 24 },
|
||||||
|
btns: { hide: true }
|
||||||
|
}
|
||||||
|
|
||||||
|
const columns: Columns = [
|
||||||
|
{
|
||||||
|
label: '上级部门',
|
||||||
|
field: 'parentId',
|
||||||
|
type: 'tree-select',
|
||||||
|
data: deptList,
|
||||||
|
props: {
|
||||||
|
allowClear: true,
|
||||||
|
allowSearch: true,
|
||||||
|
fallbackOption: false,
|
||||||
|
filterTreeNode(searchKey, nodeData) {
|
||||||
|
if (nodeData.title) {
|
||||||
|
return nodeData.title.toLowerCase().indexOf(searchKey.toLowerCase()) > -1
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ label: '名称', field: 'name', type: 'input', rules: [{ required: true, message: '请输入名称' }] },
|
||||||
|
{
|
||||||
|
label: '排序',
|
||||||
|
field: 'sort',
|
||||||
|
type: 'input-number',
|
||||||
|
props: {
|
||||||
|
min: 1,
|
||||||
|
mode: 'button'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '描述',
|
||||||
|
field: 'description',
|
||||||
|
type: 'textarea',
|
||||||
|
props: {
|
||||||
|
maxLength: 200,
|
||||||
|
autoSize: { minRows: 3, maxRows: 5 }
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '状态',
|
||||||
|
field: 'status',
|
||||||
|
type: 'switch',
|
||||||
|
props: {
|
||||||
|
type: 'round',
|
||||||
|
checkedValue: 1,
|
||||||
|
uncheckedValue: 2,
|
||||||
|
checkedText: '启用',
|
||||||
|
uncheckedText: '禁用'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
const { form, resetForm } = useForm<DeptReq>({
|
||||||
|
name: '',
|
||||||
|
parentId: undefined,
|
||||||
|
sort: 999,
|
||||||
|
status: 1,
|
||||||
|
})
|
||||||
|
|
||||||
|
// 重置
|
||||||
|
const reset = () => {
|
||||||
|
formRef.value?.formRef?.resetFields()
|
||||||
|
resetForm()
|
||||||
|
}
|
||||||
|
|
||||||
|
const visible = ref(false)
|
||||||
|
// 新增
|
||||||
|
const onAdd = (id?: string) => {
|
||||||
|
if (!deptList.value.length) {
|
||||||
|
getDeptList()
|
||||||
|
}
|
||||||
|
reset()
|
||||||
|
form.parentId = id
|
||||||
|
dataId.value = ''
|
||||||
|
visible.value = true
|
||||||
|
}
|
||||||
|
|
||||||
|
// 修改
|
||||||
|
const onUpdate = async (id: string) => {
|
||||||
|
if (!deptList.value.length) {
|
||||||
|
await getDeptList()
|
||||||
|
}
|
||||||
|
reset()
|
||||||
|
dataId.value = id
|
||||||
|
const res = await getDept(id)
|
||||||
|
Object.assign(form, res.data)
|
||||||
|
visible.value = true
|
||||||
|
}
|
||||||
|
|
||||||
|
// 保存
|
||||||
|
const save = async () => {
|
||||||
|
try {
|
||||||
|
const isInvalid = await formRef.value?.formRef?.validate()
|
||||||
|
if (isInvalid) return false
|
||||||
|
if (isUpdate.value) {
|
||||||
|
await updateDept(form, dataId.value)
|
||||||
|
Message.success('修改成功')
|
||||||
|
} else {
|
||||||
|
await addDept(form)
|
||||||
|
Message.success('新增成功')
|
||||||
|
}
|
||||||
|
// 更新部门树
|
||||||
|
await getDeptList()
|
||||||
|
emit('save-success')
|
||||||
|
return true
|
||||||
|
} catch (error) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
(e: 'save-success'): void
|
||||||
|
}>()
|
||||||
|
|
||||||
|
defineExpose({ onAdd, onUpdate })
|
||||||
|
</script>
|
164
src/views/system/dept/index.vue
Normal file
164
src/views/system/dept/index.vue
Normal file
@@ -0,0 +1,164 @@
|
|||||||
|
<template>
|
||||||
|
<div class="gi_page">
|
||||||
|
<a-card title="部门管理" class="general-card">
|
||||||
|
<GiTable
|
||||||
|
ref="tableRef"
|
||||||
|
row-key="id"
|
||||||
|
:data="dataList"
|
||||||
|
:columns="columns"
|
||||||
|
:loading="loading"
|
||||||
|
:scroll="{ x: '100%', y: '100%', minWidth: 1000 }"
|
||||||
|
:pagination="false"
|
||||||
|
:disabledColumnKeys="['name']"
|
||||||
|
@refresh="search"
|
||||||
|
>
|
||||||
|
<template #expand-icon="{ expanded }">
|
||||||
|
<IconDown v-if="expanded" />
|
||||||
|
<IconRight v-else />
|
||||||
|
</template>
|
||||||
|
<template #custom-left>
|
||||||
|
<a-input v-model="queryForm.description" placeholder="请输入关键词" allow-clear @change="search">
|
||||||
|
<template #prefix><icon-search /></template>
|
||||||
|
</a-input>
|
||||||
|
<a-select
|
||||||
|
v-model="queryForm.status"
|
||||||
|
:options="DisEnableStatusList"
|
||||||
|
placeholder="请选择状态"
|
||||||
|
allow-clear
|
||||||
|
style="width: 150px"
|
||||||
|
@change="search"
|
||||||
|
/>
|
||||||
|
<a-button @click="reset">重置</a-button>
|
||||||
|
</template>
|
||||||
|
<template #custom-right>
|
||||||
|
<a-button type="primary" @click="onAdd">
|
||||||
|
<template #icon><icon-plus /></template>
|
||||||
|
<span>新增</span>
|
||||||
|
</a-button>
|
||||||
|
<a-tooltip content="导出">
|
||||||
|
<a-button>
|
||||||
|
<template #icon>
|
||||||
|
<icon-download />
|
||||||
|
</template>
|
||||||
|
</a-button>
|
||||||
|
</a-tooltip>
|
||||||
|
</template>
|
||||||
|
<template #status="{ record }">
|
||||||
|
<GiCellStatus :status="record.status" />
|
||||||
|
</template>
|
||||||
|
<template #isSystem="{ record }">
|
||||||
|
<a-tag v-if="record.isSystem" color="red" size="small">是</a-tag>
|
||||||
|
<a-tag v-else color="arcoblue" size="small">否</a-tag>
|
||||||
|
</template>
|
||||||
|
<template #action="{ record }">
|
||||||
|
<a-space>
|
||||||
|
<template #split>
|
||||||
|
<a-divider direction="vertical" :margin="0" />
|
||||||
|
</template>
|
||||||
|
<a-link @click="onUpdate(record)">修改</a-link>
|
||||||
|
<a-link @click="onAdd(record.id)">新增</a-link>
|
||||||
|
<a-popconfirm
|
||||||
|
type="warning"
|
||||||
|
content="是否确定删除该条数据?"
|
||||||
|
:ok-button-props="{ status: 'danger' }"
|
||||||
|
@ok="onDelete(record)"
|
||||||
|
>
|
||||||
|
<a-link
|
||||||
|
status="danger"
|
||||||
|
:title="record.isSystem ? '系统内置数据不能删除' : undefined"
|
||||||
|
:disabled="record.disabled"
|
||||||
|
>
|
||||||
|
删除
|
||||||
|
</a-link>
|
||||||
|
</a-popconfirm>
|
||||||
|
</a-space>
|
||||||
|
</template>
|
||||||
|
</GiTable>
|
||||||
|
</a-card>
|
||||||
|
|
||||||
|
<AddDeptModal ref="AddDeptModalRef" @save-success="search" />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { listDept, deleteDept, type DeptResp, type DeptQuery } from '@/apis'
|
||||||
|
import { Message, type TableInstance } from '@arco-design/web-vue'
|
||||||
|
import type GiTable from '@/components/GiTable/index.vue'
|
||||||
|
import AddDeptModal from './AddDeptModal.vue'
|
||||||
|
import { DisEnableStatusList } from '@/constant/common'
|
||||||
|
import { isMobile } from '@/utils'
|
||||||
|
|
||||||
|
defineOptions({ name: 'Dept' })
|
||||||
|
|
||||||
|
const columns: TableInstance['columns'] = [
|
||||||
|
{ title: '名称', dataIndex: 'name', width: 170, ellipsis: true, tooltip: true },
|
||||||
|
{ title: '状态', slotName: 'status', align: 'center' },
|
||||||
|
{ title: '排序', dataIndex: 'sort', align: 'center', show: false },
|
||||||
|
{ title: '系统内置', slotName: 'isSystem', align: 'center', show: false },
|
||||||
|
{ title: '描述', dataIndex: 'description', ellipsis: true, tooltip: true },
|
||||||
|
{ title: '创建人', dataIndex: 'createUserString', show: false, ellipsis: true, tooltip: true },
|
||||||
|
{ 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: 200, align: 'center', fixed: !isMobile() ? 'right' : undefined }
|
||||||
|
]
|
||||||
|
|
||||||
|
const queryForm = reactive({
|
||||||
|
description: undefined,
|
||||||
|
status: undefined,
|
||||||
|
sort: ['parentId,asc', 'sort,asc', 'createTime,desc']
|
||||||
|
})
|
||||||
|
|
||||||
|
const dataList = ref<DeptResp[]>([])
|
||||||
|
const loading = ref(false)
|
||||||
|
const tableRef = ref<InstanceType<typeof GiTable>>()
|
||||||
|
// 查询列表数据
|
||||||
|
const getDataList = async (query: DeptQuery = { ...queryForm }) => {
|
||||||
|
try {
|
||||||
|
loading.value = true
|
||||||
|
const res = await listDept(query)
|
||||||
|
dataList.value = res.data
|
||||||
|
await nextTick(() => {
|
||||||
|
tableRef.value?.tableRef?.expandAll(true)
|
||||||
|
})
|
||||||
|
} finally {
|
||||||
|
loading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查询
|
||||||
|
const search = () => {
|
||||||
|
getDataList()
|
||||||
|
}
|
||||||
|
|
||||||
|
// 重置
|
||||||
|
const reset = () => {
|
||||||
|
queryForm.description = undefined
|
||||||
|
queryForm.status = undefined
|
||||||
|
search()
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除
|
||||||
|
const onDelete = async (item: DeptResp) => {
|
||||||
|
await deleteDept(item.id)
|
||||||
|
Message.success('删除成功')
|
||||||
|
search()
|
||||||
|
}
|
||||||
|
|
||||||
|
const AddDeptModalRef = ref<InstanceType<typeof AddDeptModal>>()
|
||||||
|
// 新增
|
||||||
|
const onAdd = (id?: string) => {
|
||||||
|
AddDeptModalRef.value?.onAdd(id)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 修改
|
||||||
|
const onUpdate = (item: DeptResp) => {
|
||||||
|
AddDeptModalRef.value?.onUpdate(item.id)
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
search()
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped></style>
|
7
src/views/system/dept/type.ts
Normal file
7
src/views/system/dept/type.ts
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
export interface DeptReq {
|
||||||
|
parentId: string
|
||||||
|
name: string
|
||||||
|
sort: number
|
||||||
|
description: string
|
||||||
|
status: 1 | 2
|
||||||
|
}
|
166
src/views/system/storage/AddStorageModal.vue
Normal file
166
src/views/system/storage/AddStorageModal.vue
Normal file
@@ -0,0 +1,166 @@
|
|||||||
|
<template>
|
||||||
|
<a-drawer
|
||||||
|
v-model:visible="visible"
|
||||||
|
:title="title"
|
||||||
|
:mask-closable="false"
|
||||||
|
:esc-to-close="false"
|
||||||
|
:width="width >= 600 ? 600 : '100%'"
|
||||||
|
@before-ok="save"
|
||||||
|
@close="reset"
|
||||||
|
>
|
||||||
|
<a-form ref="formRef" :model="form" :rules="rules" size="large" auto-label-width>
|
||||||
|
<a-form-item label="名称" field="name">
|
||||||
|
<a-input v-model.trim="form.name" placeholder="请输入名称" />
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item label="编码" field="code">
|
||||||
|
<a-input v-model.trim="form.code" placeholder="请输入编码" :disabled="isUpdate" />
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item label="类型" field="type">
|
||||||
|
<a-select v-model.trim="form.type" :options="storage_type_enum" placeholder="请选择类型" />
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item v-if="form.type === 1" label="访问密钥" field="accessKey">
|
||||||
|
<a-input v-model.trim="form.accessKey" placeholder="请输入访问密钥" />
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item v-if="form.type === 1" label="私有密钥" field="secretKey">
|
||||||
|
<a-input v-model.trim="form.secretKey" placeholder="请输入私有密钥" />
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item v-if="form.type === 1" label="终端节点" field="endpoint">
|
||||||
|
<a-input v-model.trim="form.endpoint" placeholder="请输入终端节点" />
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item label="桶名称" field="bucketName">
|
||||||
|
<a-input v-model.trim="form.bucketName" placeholder="请输入桶名称" />
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item v-if="form.type === 1" label="域名" field="domain">
|
||||||
|
<a-input v-model.trim="form.domain" placeholder="请输入域名" />
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item
|
||||||
|
v-if="form.type === 2"
|
||||||
|
label="域名"
|
||||||
|
field="domain"
|
||||||
|
:rules="[
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入域名'
|
||||||
|
}
|
||||||
|
]"
|
||||||
|
>
|
||||||
|
<a-input v-model.trim="form.domain" placeholder="请输入域名" />
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item label="排序" field="sort">
|
||||||
|
<a-input-number v-model="form.sort" placeholder="请输入排序" :min="1" mode="button" />
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item label="描述" field="description">
|
||||||
|
<a-textarea
|
||||||
|
v-model.trim="form.description"
|
||||||
|
placeholder="请输入描述"
|
||||||
|
show-word-limit
|
||||||
|
:max-length="200"
|
||||||
|
:auto-size="{ minRows: 3, maxRows: 5 }"
|
||||||
|
/>
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item label="默认存储" field="isDefault">
|
||||||
|
<a-switch
|
||||||
|
v-model="form.isDefault"
|
||||||
|
type="round"
|
||||||
|
:checked-value="true"
|
||||||
|
:unchecked-value="false"
|
||||||
|
checked-text="是"
|
||||||
|
unchecked-text="否"
|
||||||
|
/>
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item label="状态" field="status">
|
||||||
|
<a-switch
|
||||||
|
v-model="form.status"
|
||||||
|
type="round"
|
||||||
|
:checked-value="1"
|
||||||
|
:unchecked-value="2"
|
||||||
|
checked-text="启用"
|
||||||
|
unchecked-text="禁用"
|
||||||
|
/>
|
||||||
|
</a-form-item>
|
||||||
|
</a-form>
|
||||||
|
</a-drawer>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { getStorage, addStorage, updateStorage } from '@/apis'
|
||||||
|
import type { StorageReq } from './type'
|
||||||
|
import { Message, type FormInstance } from "@arco-design/web-vue";
|
||||||
|
import { useForm } from '@/hooks'
|
||||||
|
import { useDict } from '@/hooks/app'
|
||||||
|
import { useWindowSize } from '@vueuse/core'
|
||||||
|
|
||||||
|
const { width } = useWindowSize()
|
||||||
|
const { storage_type_enum } = useDict('storage_type_enum')
|
||||||
|
|
||||||
|
const dataId = ref('')
|
||||||
|
const isUpdate = computed(() => !!dataId.value)
|
||||||
|
const title = computed(() => (isUpdate.value ? '修改存储' : '新增存储'))
|
||||||
|
const formRef = ref<FormInstance>()
|
||||||
|
|
||||||
|
const rules: FormInstance['rules'] = {
|
||||||
|
name: [{ required: true, message: '请输入名称' }],
|
||||||
|
code: [{ required: true, message: '请输入编码' }],
|
||||||
|
type: [{ required: true, message: '请选择类型' }],
|
||||||
|
accessKey: [{ required: true, message: '请输入访问密钥' }],
|
||||||
|
secretKey: [{ required: true, message: '请输入私有密钥' }],
|
||||||
|
endpoint: [{ required: true, message: '请输入终端节点' }],
|
||||||
|
bucketName: [{ required: true, message: '请输入桶名称' }]
|
||||||
|
}
|
||||||
|
|
||||||
|
const { form, resetForm } = useForm<StorageReq>({
|
||||||
|
name: '',
|
||||||
|
code: '',
|
||||||
|
type: 2,
|
||||||
|
sort: 999,
|
||||||
|
status: 1
|
||||||
|
})
|
||||||
|
|
||||||
|
// 重置
|
||||||
|
const reset = () => {
|
||||||
|
formRef.value?.resetFields()
|
||||||
|
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 {
|
||||||
|
const isInvalid = await formRef.value?.validate()
|
||||||
|
if (isInvalid) return false
|
||||||
|
if (isUpdate.value) {
|
||||||
|
await updateStorage(form, dataId.value)
|
||||||
|
Message.success('修改成功')
|
||||||
|
} else {
|
||||||
|
await addStorage(form)
|
||||||
|
Message.success('新增成功')
|
||||||
|
}
|
||||||
|
emit('save-success')
|
||||||
|
return true
|
||||||
|
} catch (error) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
(e: 'save-success'): void
|
||||||
|
}>()
|
||||||
|
|
||||||
|
defineExpose({ onAdd, onUpdate })
|
||||||
|
</script>
|
146
src/views/system/storage/index.vue
Normal file
146
src/views/system/storage/index.vue
Normal file
@@ -0,0 +1,146 @@
|
|||||||
|
<template>
|
||||||
|
<div class="gi_page">
|
||||||
|
<a-card title="存储管理" class="general-card">
|
||||||
|
<GiTable
|
||||||
|
ref="tableRef"
|
||||||
|
row-key="id"
|
||||||
|
:data="dataList"
|
||||||
|
:columns="columns"
|
||||||
|
:loading="loading"
|
||||||
|
:scroll="{ x: '100%', y: '100%', minWidth: 1300 }"
|
||||||
|
:pagination="pagination"
|
||||||
|
:disabledColumnKeys="['name']"
|
||||||
|
@refresh="search"
|
||||||
|
>
|
||||||
|
<template #custom-left>
|
||||||
|
<a-input v-model="queryForm.description" placeholder="请输入关键词" allow-clear @change="search">
|
||||||
|
<template #prefix><icon-search /></template>
|
||||||
|
</a-input>
|
||||||
|
<a-select
|
||||||
|
v-model="queryForm.status"
|
||||||
|
:options="DisEnableStatusList"
|
||||||
|
placeholder="请选择状态"
|
||||||
|
allow-clear
|
||||||
|
style="width: 150px"
|
||||||
|
@change="search"
|
||||||
|
/>
|
||||||
|
<a-button @click="reset">重置</a-button>
|
||||||
|
</template>
|
||||||
|
<template #custom-right>
|
||||||
|
<a-button type="primary" @click="onAdd">
|
||||||
|
<template #icon><icon-plus /></template>
|
||||||
|
<span>新增</span>
|
||||||
|
</a-button>
|
||||||
|
</template>
|
||||||
|
<template #name="{ record }">
|
||||||
|
<a-space fill>
|
||||||
|
<span>{{ record.name }}</span>
|
||||||
|
<a-tag v-if="record.isDefault" color="arcoblue" size="small" class="gi_round">
|
||||||
|
<template #default>默认</template>
|
||||||
|
</a-tag>
|
||||||
|
</a-space>
|
||||||
|
</template>
|
||||||
|
<template #type="{ record }">
|
||||||
|
<GiCellTag :value="record.type" :dict="storage_type_enum" />
|
||||||
|
</template>
|
||||||
|
<template #status="{ record }">
|
||||||
|
<GiCellStatus :status="record.status" />
|
||||||
|
</template>
|
||||||
|
<template #action="{ record }">
|
||||||
|
<a-space>
|
||||||
|
<template #split>
|
||||||
|
<a-divider direction="vertical" :margin="0" />
|
||||||
|
</template>
|
||||||
|
<a-link @click="onUpdate(record)">修改</a-link>
|
||||||
|
<a-link
|
||||||
|
status="danger"
|
||||||
|
:title="record.isDefault ? '默认存储库不能删除' : undefined"
|
||||||
|
:disabled="record.disabled"
|
||||||
|
@click="onDelete(record)"
|
||||||
|
>
|
||||||
|
删除
|
||||||
|
</a-link>
|
||||||
|
</a-space>
|
||||||
|
</template>
|
||||||
|
</GiTable>
|
||||||
|
</a-card>
|
||||||
|
|
||||||
|
<AddStorageModal ref="AddStorageModalRef" @save-success="search" />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { listStorage, deleteStorage, type StorageResp } from '@/apis'
|
||||||
|
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 { DisEnableStatusList } from '@/constant/common'
|
||||||
|
|
||||||
|
defineOptions({ name: 'Storage' })
|
||||||
|
|
||||||
|
const { storage_type_enum } = useDict('storage_type_enum')
|
||||||
|
|
||||||
|
const columns: TableInstance['columns'] = [
|
||||||
|
{
|
||||||
|
title: '序号',
|
||||||
|
width: 66,
|
||||||
|
align: 'center',
|
||||||
|
render: ({ rowIndex }) => h('span', {}, rowIndex + 1 + (pagination.current - 1) * pagination.pageSize)
|
||||||
|
},
|
||||||
|
{ 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: 'accessKey', ellipsis: true, tooltip: true },
|
||||||
|
{ title: '终端节点', dataIndex: 'endpoint', ellipsis: true, tooltip: true },
|
||||||
|
{ title: '桶名称', dataIndex: 'bucketName', ellipsis: true, tooltip: true },
|
||||||
|
{ title: '域名', dataIndex: 'domain', ellipsis: true, tooltip: true },
|
||||||
|
{ title: '描述', dataIndex: 'description', ellipsis: true, tooltip: true },
|
||||||
|
{ title: '创建人', dataIndex: 'createUserString', show: false, ellipsis: true, tooltip: true },
|
||||||
|
{ 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 }
|
||||||
|
]
|
||||||
|
|
||||||
|
const queryForm = reactive({
|
||||||
|
description: undefined,
|
||||||
|
status: undefined,
|
||||||
|
sort: ['createTime,desc']
|
||||||
|
})
|
||||||
|
|
||||||
|
const {
|
||||||
|
tableData: dataList,
|
||||||
|
loading,
|
||||||
|
pagination,
|
||||||
|
search,
|
||||||
|
handleDelete
|
||||||
|
} = useTable((p) => listStorage({ ...queryForm, page: p.page, size: p.size }), { immediate: true })
|
||||||
|
|
||||||
|
// 重置
|
||||||
|
const reset = () => {
|
||||||
|
queryForm.description = undefined
|
||||||
|
queryForm.status = undefined
|
||||||
|
search()
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除
|
||||||
|
const onDelete = (item: StorageResp) => {
|
||||||
|
return handleDelete(() => deleteStorage(item.id), { content: `是否确定删除存储 [${item.name}]?`, showModal: true })
|
||||||
|
}
|
||||||
|
|
||||||
|
const AddStorageModalRef = ref<InstanceType<typeof AddStorageModal>>()
|
||||||
|
// 新增
|
||||||
|
const onAdd = () => {
|
||||||
|
AddStorageModalRef.value?.onAdd()
|
||||||
|
}
|
||||||
|
|
||||||
|
// 修改
|
||||||
|
const onUpdate = (item: StorageResp) => {
|
||||||
|
AddStorageModalRef.value?.onUpdate(item.id)
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped></style>
|
14
src/views/system/storage/type.ts
Normal file
14
src/views/system/storage/type.ts
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
export interface StorageReq {
|
||||||
|
name: string
|
||||||
|
code: string
|
||||||
|
type: number
|
||||||
|
accessKey: string
|
||||||
|
secretKey: string
|
||||||
|
endpoint: string
|
||||||
|
bucketName: string
|
||||||
|
domain: string
|
||||||
|
sort: number
|
||||||
|
description: string
|
||||||
|
isDefault: boolean
|
||||||
|
status: 1 | 2
|
||||||
|
}
|
Reference in New Issue
Block a user