|
@@ -26,7 +26,7 @@
|
|
|
<el-button type="primary" link icon="Delete" v-auth="['db:connection:remove']" @click="deleteConnection(scope.row)"> 删除 </el-button>
|
|
|
</template>
|
|
|
</ProTable>
|
|
|
- <FormDialog ref="formDialogRef" />
|
|
|
+ <FormDialog :items-options="itemsOptions" :model="connectionForm" ref="formDialogRef" />
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
@@ -36,11 +36,21 @@ import { useHandleData } from '@/hooks/useHandleData'
|
|
|
import ProTable from '@/components/ProTable/index.vue'
|
|
|
import FormDialog from '@/components/FormDialog/index.vue'
|
|
|
import { ProTableInstance, ColumnProps } from '@/components/ProTable/interface'
|
|
|
-import { listConnectionApi, delConnectionApi, addConnectionApi, updateConnectionApi, getConnectionApi } from '@/api/modules/db/connection'
|
|
|
+import {
|
|
|
+ listConnectionApi,
|
|
|
+ delConnectionApi,
|
|
|
+ addConnectionApi,
|
|
|
+ updateConnectionApi,
|
|
|
+ getConnectionApi,
|
|
|
+ getTypesApi,
|
|
|
+ getDriversApi
|
|
|
+} from '@/api/modules/db/connection'
|
|
|
|
|
|
// ProTable 实例
|
|
|
const proTable = ref<ProTableInstance>()
|
|
|
|
|
|
+let connectionForm = ref({ type: '' })
|
|
|
+
|
|
|
// 删除数据库链接信息
|
|
|
const deleteConnection = async (params: any) => {
|
|
|
await useHandleData(delConnectionApi, params.id, '删除【' + params.id + '】数据库链接')
|
|
@@ -57,18 +67,15 @@ const batchDelete = async (ids: string[]) => {
|
|
|
const formDialogRef = ref<InstanceType<typeof FormDialog> | null>(null)
|
|
|
// 打开弹框的功能
|
|
|
const openDialog = async (type: number, title: string, row?: any) => {
|
|
|
- let res = { data: {} }
|
|
|
+ connectionForm.value = { type: '' }
|
|
|
if (row?.id) {
|
|
|
- res = await getConnectionApi(row?.id || null)
|
|
|
+ const res = await getConnectionApi(row?.id || null)
|
|
|
+ connectionForm.value = res.data
|
|
|
}
|
|
|
- // 重置表单
|
|
|
- setItemsOptions()
|
|
|
const params = {
|
|
|
title,
|
|
|
width: 580,
|
|
|
isEdit: type !== 3,
|
|
|
- itemsOptions: itemsOptions,
|
|
|
- model: type == 1 ? {} : res.data,
|
|
|
api: type == 1 ? addConnectionApi : updateConnectionApi,
|
|
|
getTableList: proTable.value?.getTableList
|
|
|
}
|
|
@@ -125,69 +132,82 @@ const columns = reactive<ColumnProps<any>[]>([
|
|
|
{ prop: 'operation', label: '操作', width: 230, fixed: 'right' }
|
|
|
])
|
|
|
// 表单配置项
|
|
|
-let itemsOptions: ProForm.ItemsOptions[] = []
|
|
|
-const setItemsOptions = () => {
|
|
|
- itemsOptions = [
|
|
|
- {
|
|
|
- label: '链接名称',
|
|
|
- prop: 'name',
|
|
|
- rules: [{ required: true, message: '链接名称不能为空', trigger: 'blur' }],
|
|
|
- compOptions: {
|
|
|
- placeholder: '请输入链接名称'
|
|
|
- }
|
|
|
- },
|
|
|
- {
|
|
|
- label: '数据库类型',
|
|
|
- prop: 'type',
|
|
|
- rules: [{ required: true, message: '数据库类型不能为空', trigger: 'blur' }],
|
|
|
- compOptions: {
|
|
|
- placeholder: '请输入数据库类型'
|
|
|
- }
|
|
|
- },
|
|
|
- {
|
|
|
- label: '驱动版本',
|
|
|
- prop: 'driverVersion',
|
|
|
- rules: [{ required: true, message: '驱动版本不能为空', trigger: 'blur' }],
|
|
|
- compOptions: {
|
|
|
- placeholder: '请输入驱动版本'
|
|
|
- }
|
|
|
- },
|
|
|
- {
|
|
|
- label: '驱动类名',
|
|
|
- prop: 'driver',
|
|
|
- rules: [{ required: true, message: '驱动类名不能为空', trigger: 'blur' }],
|
|
|
- compOptions: {
|
|
|
- placeholder: '请输入驱动类名'
|
|
|
- }
|
|
|
- },
|
|
|
- {
|
|
|
- label: 'jdbc-url连接串',
|
|
|
- prop: 'url',
|
|
|
- rules: [{ required: true, message: 'jdbc-url连接串不能为空', trigger: 'blur' }],
|
|
|
- compOptions: {
|
|
|
- type: 'textarea',
|
|
|
- clearable: true,
|
|
|
- placeholder: '请输入内容'
|
|
|
- }
|
|
|
- },
|
|
|
- {
|
|
|
- label: '数据库账号',
|
|
|
- prop: 'userName',
|
|
|
- rules: [{ required: true, message: '数据库账号不能为空', trigger: 'blur' }],
|
|
|
- compOptions: {
|
|
|
- placeholder: '请输入数据库账号'
|
|
|
- }
|
|
|
- },
|
|
|
- {
|
|
|
- label: '账号密码',
|
|
|
- prop: 'password',
|
|
|
- rules: [{ required: true, message: '账号密码不能为空', trigger: 'blur' }],
|
|
|
- compOptions: {
|
|
|
- placeholder: '请输入账号密码',
|
|
|
- type: 'password',
|
|
|
- showPassword: true
|
|
|
+let itemsOptions = ref<ProForm.ItemsOptions[]>([
|
|
|
+ {
|
|
|
+ label: '链接名称',
|
|
|
+ prop: 'name',
|
|
|
+ rules: [{ required: true, message: '链接名称不能为空', trigger: 'blur' }],
|
|
|
+ compOptions: {
|
|
|
+ placeholder: '请输入链接名称'
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: '数据库类型',
|
|
|
+ prop: 'type',
|
|
|
+ rules: [{ required: true, message: '数据库类型不能为空', trigger: 'blur' }],
|
|
|
+ compOptions: {
|
|
|
+ elTagName: 'select',
|
|
|
+ enum: getTypesApi,
|
|
|
+ labelKey: 'type',
|
|
|
+ valueKey: 'type',
|
|
|
+ placeholder: '请输入数据库类型',
|
|
|
+ onChange: value => {
|
|
|
+ if (value) {
|
|
|
+ getDriversApi(value).then(res => {
|
|
|
+ itemsOptions.value[2].compOptions.enum = res.data
|
|
|
+ })
|
|
|
+ console.log('itemsOptions', itemsOptions)
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- ]
|
|
|
-}
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: '驱动版本',
|
|
|
+ prop: 'driverVersion',
|
|
|
+ rules: [{ required: true, message: '驱动版本不能为空', trigger: 'blur' }],
|
|
|
+ compOptions: {
|
|
|
+ elTagName: 'select',
|
|
|
+ labelKey: 'driverVersion',
|
|
|
+ valueKey: 'driverVersion',
|
|
|
+ placeholder: '请输入驱动版本'
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: '驱动类名',
|
|
|
+ prop: 'driver',
|
|
|
+ rules: [{ required: true, message: '驱动类名不能为空', trigger: 'blur' }],
|
|
|
+ compOptions: {
|
|
|
+ placeholder: '请输入驱动类名'
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: 'jdbc-url',
|
|
|
+ prop: 'url',
|
|
|
+ tooltip: 'jdbc:dm://localhost:5236',
|
|
|
+ rules: [{ required: true, message: 'jdbc-url连接串不能为空', trigger: 'blur' }],
|
|
|
+ compOptions: {
|
|
|
+ type: 'textarea',
|
|
|
+ clearable: true,
|
|
|
+ placeholder: '请输入内容'
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: '数据库账号',
|
|
|
+ prop: 'userName',
|
|
|
+ rules: [{ required: true, message: '数据库账号不能为空', trigger: 'blur' }],
|
|
|
+ compOptions: {
|
|
|
+ placeholder: '请输入数据库账号'
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: '账号密码',
|
|
|
+ prop: 'password',
|
|
|
+ rules: [{ required: true, message: '账号密码不能为空', trigger: 'blur' }],
|
|
|
+ compOptions: {
|
|
|
+ placeholder: '请输入账号密码',
|
|
|
+ type: 'password',
|
|
|
+ showPassword: true
|
|
|
+ }
|
|
|
+ }
|
|
|
+])
|
|
|
</script>
|