From 04eca1de43393aa2d471fc5a388ec4c600046c0f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9B=B9=E7=A3=8A?= <45566618@qq.com>
Date: Thu, 3 Apr 2025 16:37:52 +0800
Subject: [PATCH] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E6=BA=90=E7=AE=A1=E7=90=86?=
=?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=89=80=E5=B1=9E=E6=9C=BA=E6=9E=84=EF=BC=8C?=
=?UTF-8?q?=E5=B9=B6=E5=B0=86=E6=95=B0=E6=8D=AE=E6=BA=90=E7=BC=96=E7=A0=81?=
=?UTF-8?q?=E6=8C=87=E5=AE=9A=E4=B8=BA=E6=9C=BA=E6=9E=84=E7=BC=96=E7=A0=81?=
=?UTF-8?q?=EF=BC=8C=E5=B0=86=E5=BC=B9=E7=AA=97=E6=94=B9=E6=88=90=E6=8A=BD?=
=?UTF-8?q?=E5=B1=89?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../components/InstitutionAreaLeftTree.vue | 2 +-
.../monitor/datasource/DataSourceDrawer.vue | 146 ++++++++++++++++++
.../monitor/datasource/DataSourceModal.vue | 33 +++-
.../monitor/datasource/datasource.api.ts | 29 ++--
.../monitor/datasource/datasource.data.ts | 49 ++++--
src/views/monitor/datasource/index.vue | 47 ++++--
6 files changed, 266 insertions(+), 40 deletions(-)
create mode 100644 src/views/monitor/datasource/DataSourceDrawer.vue
diff --git a/src/views/admin/institution/components/InstitutionAreaLeftTree.vue b/src/views/admin/institution/components/InstitutionAreaLeftTree.vue
index 9547ca7..f3a9fc7 100644
--- a/src/views/admin/institution/components/InstitutionAreaLeftTree.vue
+++ b/src/views/admin/institution/components/InstitutionAreaLeftTree.vue
@@ -252,7 +252,7 @@
});
}
- // 搜索事件
+ // 搜索事件pnp
async function onSearch(value: string) {
if (value) {
try {
diff --git a/src/views/monitor/datasource/DataSourceDrawer.vue b/src/views/monitor/datasource/DataSourceDrawer.vue
new file mode 100644
index 0000000..67058ba
--- /dev/null
+++ b/src/views/monitor/datasource/DataSourceDrawer.vue
@@ -0,0 +1,146 @@
+
+
+
+
+
+
+
+
+
+ 测试
+
+
+
+
+ handleChange(value,model)">
+
+
+ {{item.departName}}
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/views/monitor/datasource/DataSourceModal.vue b/src/views/monitor/datasource/DataSourceModal.vue
index e45d9d1..523ec0f 100644
--- a/src/views/monitor/datasource/DataSourceModal.vue
+++ b/src/views/monitor/datasource/DataSourceModal.vue
@@ -11,6 +11,15 @@
+
+ handleChange(value,model)">
+
+
+ {{item.departName}}
+
+
+
+
@@ -19,13 +28,14 @@
import { BasicModal, useModalInner } from '/@/components/Modal';
import { BasicForm, useForm } from '/@/components/Form/index';
import { formSchema } from './datasource.data';
- import { saveOrUpdateDataSource, getDataSourceById, testConnection } from './datasource.api';
+ import { saveOrUpdateDataSource, getDataSourceById, testConnection, queryDeparts } from './datasource.api';
import { useMessage } from '/@/hooks/web/useMessage';
const { createMessage } = useMessage();
// Emits声明
const emit = defineEmits(['register', 'success']);
const isUpdate = ref(true);
+ const departOptions = ref([]);
//表单配置
const [registerForm, { getFieldsValue, resetFields, validateFields, setFieldsValue, validate }] = useForm({
// labelWidth: 150,
@@ -36,8 +46,14 @@
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
//重置表单
await resetFields();
+
setModalProps({ confirmLoading: false });
isUpdate.value = !!data?.isUpdate;
+ if (unref(isUpdate)){
+ await getDepartOptions('');
+ }else{
+ await getDepartOptions('1');
+ }
if (unref(isUpdate)) {
//获取详情
data.record = await getDataSourceById({ id: data.record.id });
@@ -50,6 +66,21 @@
//设置标题
const title = computed(() => (!unref(isUpdate) ? '新增数据源' : '编辑数据源'));
+ async function getDepartOptions(addFLag){
+ departOptions.value = [];
+ const data = await queryDeparts({ addFLag : addFLag });
+ console.log(data);
+ Object.assign(departOptions.value, data);
+ }
+
+ async function handleChange(value,formData){
+ if(value == null){
+ formData["code"] = "";
+ }else{
+ formData["code"] = value;
+ }
+ }
+
async function handleTest() {
let keys = ['dbType', 'dbDriver', 'dbUrl', 'dbName', 'dbUsername', 'dbPassword'];
// 获取以上字段的值,并清除校验状态
diff --git a/src/views/monitor/datasource/datasource.api.ts b/src/views/monitor/datasource/datasource.api.ts
index 3aa0580..7b9a0f6 100644
--- a/src/views/monitor/datasource/datasource.api.ts
+++ b/src/views/monitor/datasource/datasource.api.ts
@@ -9,17 +9,18 @@ enum Api {
delete = '/sys/dataSource/delete',
testConnection = '/online/cgreport/api/testConnection',
deleteBatch = '/sys/dataSource/deleteBatch',
- exportXlsUrl = 'sys/dataSource/exportXls',
- importExcelUrl = 'sys/dataSource/importExcel',
+ departList = '/sys/dataSource/departList',
+ // exportXlsUrl = 'sys/dataSource/exportXls',
+ // importExcelUrl = 'sys/dataSource/importExcel',
}
-/**
- * 导出api
- */
-export const getExportUrl = Api.exportXlsUrl;
-/**
- * 导入api
- */
-export const getImportUrl = Api.importExcelUrl;
+// /**
+// * 导出api
+// */
+// export const getExportUrl = Api.exportXlsUrl;
+// /**
+// * 导入api
+// */
+// export const getImportUrl = Api.importExcelUrl;
/**
* 查询数据源列表
@@ -81,3 +82,11 @@ export const batchDeleteDataSource = (params, handleSuccess) => {
},
});
};
+
+/**
+ * 查询机构列表
+ * @param params
+ */
+export const queryDeparts = (params) => {
+ return defHttp.get({ url: Api.departList, params });
+};
diff --git a/src/views/monitor/datasource/datasource.data.ts b/src/views/monitor/datasource/datasource.data.ts
index de403f8..8de6db7 100644
--- a/src/views/monitor/datasource/datasource.data.ts
+++ b/src/views/monitor/datasource/datasource.data.ts
@@ -69,45 +69,65 @@ const dbUrlMap = {
};
export const columns: BasicColumn[] = [
+ {
+ title: '所属机构',
+ dataIndex: 'sysOrgCode_dictText',
+ width: 150,
+ align: 'left',
+ },
+ {
+ title: '数据源编码',
+ dataIndex: 'code',
+ width: 150,
+ align: 'left',
+ },
{
title: '数据源名称',
dataIndex: 'name',
- width: 200,
+ width: 150,
align: 'left',
},
{
title: '数据库类型',
dataIndex: 'dbType_dictText',
- width: 200,
+ width: 150,
+ align: 'left',
},
{
title: '驱动类',
dataIndex: 'dbDriver',
width: 200,
+ align: 'left',
},
{
title: '数据源地址',
dataIndex: 'dbUrl',
- },
- {
- title: '用户名',
- dataIndex: 'dbUsername',
- width: 200,
+ align: 'left',
},
];
export const searchFormSchema: FormSchema[] = [
+ {
+ field: 'sysOrgCode',
+ label: '所属机构',
+ component: 'JDictSelectTag',
+ componentProps: {
+ dictCode: "sys_depart,depart_name,org_code,org_category='1' and del_flag = '0' order by org_code",
+ placeholder: '请选择机构',
+ },
+ colProps: { span: 6 },
+ },
{
field: 'name',
label: '数据源名称',
component: 'Input',
- colProps: { span: 8 },
+ colProps: { span: 6 },
},
{
field: 'dbType',
label: '数据库类型',
component: 'JDictSelectTag',
- colProps: { span: 8 },
+ colProps: { span: 6 },
componentProps: () => {
return {
dictCode: 'database_type',
@@ -123,14 +143,19 @@ export const formSchema: FormSchema[] = [
component: 'Input',
show: false,
},
+ {
+ field: 'sysOrgCode',
+ label: '所属机构',
+ component: 'Input',
+ required: true,
+ slot: 'departSelect',
+ },
{
field: 'code',
label: '数据源编码',
component: 'Input',
required: true,
- dynamicDisabled: ({ values }) => {
- return !!values.id;
- },
+ dynamicDisabled: true
},
{
field: 'name',
diff --git a/src/views/monitor/datasource/index.vue b/src/views/monitor/datasource/index.vue
index f12f5af..da356e6 100644
--- a/src/views/monitor/datasource/index.vue
+++ b/src/views/monitor/datasource/index.vue
@@ -3,8 +3,8 @@
新增
- 导出
- 导入
+
@@ -24,26 +24,30 @@
-
+
+