2023-02-11 00:44:00 +08:00
|
|
|
|
<template>
|
2023-04-05 20:13:35 +08:00
|
|
|
|
<ContentWrap>
|
2023-03-11 15:54:45 +08:00
|
|
|
|
<!-- 搜索工作栏 -->
|
2023-03-11 17:57:22 +08:00
|
|
|
|
<el-form class="-mb-15px" :inline="true">
|
2023-03-11 15:54:45 +08:00
|
|
|
|
<el-form-item>
|
2023-03-11 16:00:01 +08:00
|
|
|
|
<el-button
|
|
|
|
|
type="primary"
|
2023-04-02 23:52:56 +08:00
|
|
|
|
plain
|
2023-04-05 20:13:35 +08:00
|
|
|
|
@click="openForm('create')"
|
2023-03-11 16:00:01 +08:00
|
|
|
|
v-hasPermi="['infra:data-source-config:create']"
|
|
|
|
|
>
|
2023-03-11 15:54:45 +08:00
|
|
|
|
<Icon icon="ep:plus" class="mr-5px" /> 新增
|
|
|
|
|
</el-button>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-form>
|
2023-04-05 20:13:35 +08:00
|
|
|
|
</ContentWrap>
|
2023-03-11 15:54:45 +08:00
|
|
|
|
|
2023-03-11 17:57:22 +08:00
|
|
|
|
<!-- 列表 -->
|
2023-04-05 20:13:35 +08:00
|
|
|
|
<ContentWrap>
|
|
|
|
|
<el-table v-loading="loading" :data="list">
|
2023-03-11 15:54:45 +08:00
|
|
|
|
<el-table-column label="主键编号" align="center" prop="id" />
|
|
|
|
|
<el-table-column label="数据源名称" align="center" prop="name" />
|
|
|
|
|
<el-table-column label="数据源连接" align="center" prop="url" :show-overflow-tooltip="true" />
|
|
|
|
|
<el-table-column label="用户名" align="center" prop="username" />
|
|
|
|
|
<el-table-column
|
|
|
|
|
label="创建时间"
|
|
|
|
|
align="center"
|
|
|
|
|
prop="createTime"
|
|
|
|
|
width="180"
|
|
|
|
|
:formatter="dateFormatter"
|
2023-02-11 00:44:00 +08:00
|
|
|
|
/>
|
2023-03-11 15:54:45 +08:00
|
|
|
|
<el-table-column label="操作" align="center">
|
|
|
|
|
<template #default="scope">
|
|
|
|
|
<el-button
|
|
|
|
|
link
|
|
|
|
|
type="primary"
|
2023-04-05 20:13:35 +08:00
|
|
|
|
@click="openForm('update', scope.row.id)"
|
2023-03-11 16:00:01 +08:00
|
|
|
|
v-hasPermi="['infra:data-source-config:update']"
|
2023-03-11 17:57:22 +08:00
|
|
|
|
:disabled="scope.row.id === 0"
|
2023-03-11 15:54:45 +08:00
|
|
|
|
>
|
|
|
|
|
编辑
|
|
|
|
|
</el-button>
|
|
|
|
|
<el-button
|
|
|
|
|
link
|
|
|
|
|
type="danger"
|
|
|
|
|
@click="handleDelete(scope.row.id)"
|
2023-03-11 16:00:01 +08:00
|
|
|
|
v-hasPermi="['infra:data-source-config:delete']"
|
2023-03-11 17:57:22 +08:00
|
|
|
|
:disabled="scope.row.id === 0"
|
2023-03-11 15:54:45 +08:00
|
|
|
|
>
|
|
|
|
|
删除
|
|
|
|
|
</el-button>
|
|
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
|
|
|
|
</el-table>
|
2023-04-05 20:13:35 +08:00
|
|
|
|
</ContentWrap>
|
2023-03-11 15:54:45 +08:00
|
|
|
|
|
|
|
|
|
<!-- 表单弹窗:添加/修改 -->
|
2023-04-05 20:13:35 +08:00
|
|
|
|
<DataSourceConfigForm ref="formRef" @success="getList" />
|
2023-02-11 00:44:00 +08:00
|
|
|
|
</template>
|
2023-06-21 19:35:11 +08:00
|
|
|
|
<script lang="ts" setup>
|
2023-03-11 15:54:45 +08:00
|
|
|
|
import { dateFormatter } from '@/utils/formatTime'
|
|
|
|
|
import * as DataSourceConfigApi from '@/api/infra/dataSourceConfig'
|
2023-04-05 20:13:35 +08:00
|
|
|
|
import DataSourceConfigForm from './DataSourceConfigForm.vue'
|
2023-06-21 19:14:34 +08:00
|
|
|
|
|
|
|
|
|
defineOptions({ name: 'InfraDataSourceConfig' })
|
|
|
|
|
|
2023-02-11 00:44:00 +08:00
|
|
|
|
const message = useMessage() // 消息弹窗
|
2023-03-11 15:54:45 +08:00
|
|
|
|
const { t } = useI18n() // 国际化
|
2023-02-11 00:44:00 +08:00
|
|
|
|
|
2023-03-11 15:54:45 +08:00
|
|
|
|
const loading = ref(true) // 列表的加载中
|
|
|
|
|
const list = ref([]) // 列表的数据
|
2023-02-11 00:44:00 +08:00
|
|
|
|
|
2023-03-28 23:18:10 +08:00
|
|
|
|
/** 查询列表 */
|
2023-03-11 15:54:45 +08:00
|
|
|
|
const getList = async () => {
|
|
|
|
|
loading.value = true
|
|
|
|
|
try {
|
|
|
|
|
list.value = await DataSourceConfigApi.getDataSourceConfigList()
|
|
|
|
|
} finally {
|
|
|
|
|
loading.value = false
|
|
|
|
|
}
|
2023-02-11 00:44:00 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-03-11 15:54:45 +08:00
|
|
|
|
/** 添加/修改操作 */
|
2023-04-05 20:13:35 +08:00
|
|
|
|
const formRef = ref()
|
|
|
|
|
const openForm = (type: string, id?: number) => {
|
|
|
|
|
formRef.value.open(type, id)
|
2023-02-11 00:44:00 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-03-11 15:54:45 +08:00
|
|
|
|
/** 删除按钮操作 */
|
|
|
|
|
const handleDelete = async (id: number) => {
|
|
|
|
|
try {
|
|
|
|
|
// 删除的二次确认
|
|
|
|
|
await message.delConfirm()
|
|
|
|
|
// 发起删除
|
|
|
|
|
await DataSourceConfigApi.deleteDataSourceConfig(id)
|
|
|
|
|
message.success(t('common.delSuccess'))
|
|
|
|
|
// 刷新列表
|
|
|
|
|
await getList()
|
|
|
|
|
} catch {}
|
2023-02-11 00:44:00 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-03-11 15:54:45 +08:00
|
|
|
|
/** 初始化 **/
|
|
|
|
|
onMounted(() => {
|
|
|
|
|
getList()
|
|
|
|
|
})
|
2023-02-11 00:44:00 +08:00
|
|
|
|
</script>
|