8235395e by lihua

数据源支持连接华为云obs类型

1 parent 6f51b92f
......@@ -17,7 +17,8 @@
formId="model-select-edit" col="col3 custom-form" @select-change="handleDataSelectFormSelectChange"
@uploadFileChange="uploadFileChange" @checkboxChange="handleDataSelectFormCheckboxChange" />
</ContentWrap>
<ContentWrap v-show="formRef?.formInline?.dataSource != 3" id="id-previewData" title="数据抽样预览" description=""
<!-- 抽样预览的表单填写配置,及表格展示 -->
<ContentWrap v-show="formRef?.formInline?.dataSource != 3 && !(formRef?.formInline?.dataSourceGuid && currDatasourceSelect?.databaseType === 'obs')" id="id-previewData" title="数据抽样预览" description=""
style="margin-top: 16px;">
<!-- 选择抽样预览的表单设置 -->
<Form ref="dataSimpleFormRef" :itemList="dataSimpleFormItems" :rules="dataSimpleFormRules"
......@@ -611,6 +612,13 @@ const handleDataSelectFormSelectChange = async (val, row, formInfo) => {
return;
}
let dsInfo = currDatasourceSelect.value = dataSourceList.value.find(d => d.guid == val);
if (dsInfo.databaseType == 'obs') {
sampleTableFields.value = [];
parseFileDataSum.value = [];
sampleTableData.value = [];
setDataSelectFormItems(Object.assign({}, formInfo, { file: !formInfo['file'] ? [] : formInfo['file'], tableName: '', qualifiedIdentifier: [] }))
return;
}
//清除数据表得值,重新获取下拉列表
const res: any = await getDsTableByDs({
pageSize: -1,
......@@ -660,6 +668,10 @@ const handleDataSelectFormSelectChange = async (val, row, formInfo) => {
}
});
} else if (row.field == 'handleType') {
// 第一种匿名处理类型是不可以选择obs类型的。
if (val == '01' && formInfo.dataSourceGuid && currDatasourceSelect.value.databaseType == 'obs') {
formInfo.dataSourceGuid = '';
}
setDataSelectFormItems(formInfo);
}
}
......@@ -694,10 +706,14 @@ const setDataSelectFormItems = (info, isDetail = false) => {
item.default = '';
}
} else if (item.field == 'qualifiedIdentifier') {
item.visible = info['handleType'] == '02' && info['dataSource'] != 3;
item.visible = info['handleType'] == '02' && info['dataSource'] != 3 && !(info['dataSourceGuid'] && currDatasourceSelect.value?.databaseType === 'obs');
if (info['dataSource'] == 3) {
item.options = qualifiedIdentifierFloderList.value;
}
} else if (item.field == 'tableName') {
item.visible = !(info['dataSourceGuid'] && currDatasourceSelect.value?.databaseType === 'obs');//数据源类型为obs的没有数据表选择
} else if (item.field == 'dataSourceGuid') {
item.options = info.handleType == '02' ? dataSourceList.value : dataSourceList.value.filter(d => d.databaseType !== 'obs')
}
});
stepsInfo.value = info.handleType == '02' ? reportStepsInfo.value : originStepsInfo.value;
......@@ -1368,6 +1384,11 @@ const changeStep = async (val) => {
} else if (val == 2) {
formRef.value?.ruleFormRef?.validate((valid) => {
if (valid) {
let formInline = formRef.value?.formInline;
// if (formInline?.handleType == '01' && formInline?.dataSourceGuid && currDatasourceSelect.value?.databaseType === 'obs') {
// return;
// }
if (formRef.value?.formInline?.dataSource == 2 && !sampleTableFields.value?.length) {
proxy.$ElMessage.error('上传文件的字段不能为空');
return;
......@@ -1497,17 +1518,21 @@ const changeStep = async (val) => {
formRef.value?.ruleFormRef?.validate((valid, errorItem) => {
if (valid) {
let dataSource = formRef.value?.formInline?.dataSource;
if (dataSource == 2 && !sampleTableFields.value?.length) {
if (dataSource == 2 && currDatasourceSelect.value.databaseType !== 'obs' && !sampleTableFields.value?.length) {
proxy.$ElMessage.error('上传文件的字段不能为空');
return;
}
if (dataSource != 3) {
dataSimpleFormRef.value?.ruleFormRef?.validate((valid) => {
if (valid) {
// Object.assign(saveParams, { riskThreshold: '0.05' });
exec(saveParams);
}
});
if (currDatasourceSelect.value.databaseType === 'obs' && saveParams.dataSourceGuid) {
exec(saveParams);
} else {
dataSimpleFormRef.value?.ruleFormRef?.validate((valid) => {
if (valid) {
// Object.assign(saveParams, { riskThreshold: '0.05' });
exec(saveParams);
}
});
}
} else {
if (!clickSelectNode.value.path) {
proxy.$ElMessage.error('请先上传文件');
......@@ -1632,61 +1657,63 @@ onBeforeMount(() => {
fileRes?.msg && ElMessage.error(fileRes?.msg);
}
// 会出现从文件切换到数据库时没有数据库列表的问题。
const res: any = await getDatabase({ connectStatus: 1 });
const res: any = await getDatabase({ connectStatus: 1, isAllStorageType: 'Y' });
if (res?.code == proxy.$passCode) {
dataSourceList.value = res.data || [];
let item = dataSelectInfoItems.value.find(item => item.field == 'dataSourceGuid');
item && (item.options = dataSourceList.value);
item && (item.options = detailInfo.value.handleType == '01' ? dataSourceList.value.filter(d => d.databaseType !== 'obs') : dataSourceList.value);
} else {
proxy.$ElMessage.error(res.msg);
}
} else if (dataSource == 1) {
const res: any = await getDatabase({ connectStatus: 1 });
const res: any = await getDatabase({ connectStatus: 1, isAllStorageType: 'Y' });
if (res?.code == proxy.$passCode) {
dataSourceList.value = res.data || [];
let item = dataSelectInfoItems.value.find(item => item.field == 'dataSourceGuid');
item && (item.options = dataSourceList.value);
item && (item.options = detailInfo.value.handleType == '01' ? dataSourceList.value.filter(d => d.databaseType !== 'obs') : dataSourceList.value);
} else {
proxy.$ElMessage.error(res.msg);
}
currDatasourceSelect.value = dataSourceList.value.find(d => d.guid == detailInfo.value.dataSourceGuid);
const tableRes: any = await getDsTableByDs({
pageSize: -1,
pageIndex: 1,
dataSourceGuid: detailInfo.value.dataSourceGuid,
database: currDatasourceSelect.value.databaseNameEn,
databaseType: currDatasourceSelect.value.databaseType,
tableName: '',
hadFlag: false
});
if (tableRes?.code == proxy.$passCode) {
dsTableList.value = tableRes.data?.records || [];
let item = dataSelectInfoItems.value.find(item => item.field == 'tableName');
item && (item.options = dsTableList.value);
} else {
proxy.$ElMessage.error(tableRes.msg);
}
getDsTableFieldColumn({
pageSize: 50,
pageIndex: 1,
dataSourceGuid: currDatasourceSelect.value.guid,
database: currDatasourceSelect.value.databaseNameEn,
databaseType: currDatasourceSelect.value.databaseType,
tableName: detailInfo.value.tableName,
}).then((res: any) => {
if (res.code == proxy.$passCode) {
sampleTableFields.value = res.data?.map(d => {
d.fieldDataType = d.dataType;
d.enName = d.columnName;
d.chName = d.columnZhName;
return d;
}) || [];
/** 判断有抽样数据,需要查询接口 */
getSampleDataByDsTable();
if (currDatasourceSelect.value.databaseType != 'obs') {
const tableRes: any = await getDsTableByDs({
pageSize: -1,
pageIndex: 1,
dataSourceGuid: detailInfo.value.dataSourceGuid,
database: currDatasourceSelect.value.databaseNameEn,
databaseType: currDatasourceSelect.value.databaseType,
tableName: '',
hadFlag: false
});
if (tableRes?.code == proxy.$passCode) {
dsTableList.value = tableRes.data?.records || [];
let item = dataSelectInfoItems.value.find(item => item.field == 'tableName');
item && (item.options = dsTableList.value);
} else {
ElMessage.error(res.msg);
proxy.$ElMessage.error(tableRes.msg);
}
});
getDsTableFieldColumn({
pageSize: 50,
pageIndex: 1,
dataSourceGuid: currDatasourceSelect.value.guid,
database: currDatasourceSelect.value.databaseNameEn,
databaseType: currDatasourceSelect.value.databaseType,
tableName: detailInfo.value.tableName,
}).then((res: any) => {
if (res.code == proxy.$passCode) {
sampleTableFields.value = res.data?.map(d => {
d.fieldDataType = d.dataType;
d.enName = d.columnName;
d.chName = d.columnZhName;
return d;
}) || [];
/** 判断有抽样数据,需要查询接口 */
getSampleDataByDsTable();
} else {
ElMessage.error(res.msg);
}
});
}
} else if (dataSource == 3) {
processFolderRefresh();
}
......@@ -1700,11 +1727,12 @@ onBeforeMount(() => {
}
});
} else {
getDatabase({ connectStatus: 1 }).then((res: any) => {
// TODO,传参是否查询全部,包括obs类型的数据源
getDatabase({ connectStatus: 1, isAllStorageType: 'Y' }).then((res: any) => {
if (res.code == proxy.$passCode) {
dataSourceList.value = res.data || [];
let item = dataSelectInfoItems.value.find(item => item.field == 'dataSourceGuid');
item && (item.options = dataSourceList.value);
item && (item.options = dataSourceList.value.filter(d => d.databaseType !== 'obs'));
} else {
proxy.$ElMessage.error(res.msg);
}
......
......@@ -20,6 +20,14 @@ import {
const { proxy } = getCurrentInstance() as any;
/** 数据库类型下拉列表 */
const databaseTypesList = ref([
{ label: "mysql", value: "mysql" },
{ label: "doris", value: "doris" },
{ label: "oracle", value: "oracle" },
{ label: "华为云obs", value: "obs" },
]);
const searchItemList = ref([
{
type: "select",
......@@ -39,11 +47,7 @@ const searchItemList = ref([
field: "databaseType",
default: "",
placeholder: "库类型",
options: [
{ label: "mysql", value: "mysql" },
{ label: "doris", value: "doris" },
{ label: "oracle", value: "oracle" },
],
options: databaseTypesList.value,
clearable: true,
},
{
......@@ -103,7 +107,9 @@ const tableInfo = ref({
{ label: "序号", type: "index", width: 56, align: "center" },
{ label: "数据源名称", field: "databaseNameZh", width: 120 },
{ label: "系统分层", field: "systemLayer", width: 96 },
{ label: "库类型", field: "databaseType", width: 96 },
{ label: "库类型", field: "databaseType", width: 96, getName: (scope) => {
return scope.row.databaseType && databaseTypesList.value.find(item => item.value === scope.row.databaseType)?.label || '--';
} },
{ label: "数据库名", field: "databaseNameEn", width: 200 },
{
label: "连通状态",
......@@ -206,11 +212,7 @@ const contents: any = ref({
placeholder: "请选择",
field: "databaseType",
default: "",
options: [
{ label: "mysql", value: "mysql" },
{ label: "doris", value: "doris" },
{ label: "oracle", value: "oracle" },
],
options: databaseTypesList.value,
clearable: true,
required: true,
},
......@@ -329,6 +331,18 @@ const contents: any = ref({
required: true,
},
{
type: 'radio-group',
label: '是否https协议',
field: 'isHttpsProtocol',
default: 'Y',
required: true,
visible: false,
options: [
{ label: '是', value: 'Y' },
{ label: '否', value: 'N' },
],
},
{
label: "连接属性",
type: "textarea-tips",
placeholder: "请输入",
......@@ -941,7 +955,7 @@ const dialogInfo = ref({
footer: {
btns: [
{ type: "default", label: "取消", value: "cancel" },
{ type: "primary", label: "确定", value: "submit" },
{ type: "primary", label: "确定", value: "submit", loading: false },
],
textBtns: [{ type: "primary", label: "连通测试", value: "connect" }],
},
......@@ -993,13 +1007,30 @@ const setFormItems = (name, info: any = null) => {
child.default = info[child.field] ?? "";
}
});
} else if (item.field == 'isHttpsProtocol') {
item.visible = info.databaseType == "obs";
item.default = info[item.field] || "Y";
} else if (item.field == 'bizSystem') {
item.visible = info.systemLayer == '业务系统';
item.default = info[item.field] || "";
}
else {
} else {
item.default = info[item.field] || "";
}
if (item.field == 'host') {
item.label = info.databaseType == "obs" ? "地址" : "服务器";
contentFormInfo.rules.host[0].message = info.databaseType == "obs" ? "请填写地址" : "请填写服务器IP地址";
} else if (item.field == 'port') {
item.visible = info.databaseType != "obs";
} else if (item.field == 'logonUser') {
item.label = info.databaseType == "obs" ? "凭证ID" : "用户名";
contentFormInfo.rules.logonUser[0].message = info.databaseType == "obs" ? "请填写凭证ID" : "请填写用户名";
} else if (item.field == 'password') {
item.label = info.databaseType == "obs" ? "凭证Key" : "密码";
contentFormInfo.rules.password[0].message = info.databaseType == "obs" ? "请填写凭证Key" : "请填写密码";
} else if (item.field == 'databaseNameEn') {
item.label = info.databaseType == "obs" ? "桶名称" : "数据库名";
contentFormInfo.rules.databaseNameEn[0].message = info.databaseType == "obs" ? "请填写桶名称" : "请填写数据库名";
}
});
} else {
formItems.value.map((item) => {
......@@ -1224,10 +1255,13 @@ const dialogBtnClick = (btn, info) => {
password: info.password,
feLoadUrl: info.feLoadUrl,
beLoadUrl: info.beLoadUrl,
dorisJdbcUrl: info.dorisJdbcUrl
dorisJdbcUrl: info.dorisJdbcUrl,
isHttpsProtocol: info.isHttpsProtocol,
};
dialogInfo.value.footer.btns[1].loading = true;
addDataSource(params)
.then((res: any) => {
dialogInfo.value.footer.btns[1].loading = false;
if (res.code == proxy.$passCode) {
getFirstPageData();
ElMessage({
......@@ -1244,6 +1278,7 @@ const dialogBtnClick = (btn, info) => {
}
})
.catch(() => {
dialogInfo.value.footer.btns[1].loading = false;
// dialogInfo.value.footer.btns.map((item: any) => delete item.disabled)
});
} else {
......@@ -1258,11 +1293,14 @@ const dialogBtnClick = (btn, info) => {
: info.password,
feLoadUrl: info.feLoadUrl,
beLoadUrl: info.beLoadUrl,
dorisJdbcUrl: info.dorisJdbcUrl
dorisJdbcUrl: info.dorisJdbcUrl,
isHttpsProtocol: info.isHttpsProtocol,
};
params.guid = currTableData.value.guid;
dialogInfo.value.footer.btns[1].loading = true;
updateDataSource(params)
.then((res: any) => {
dialogInfo.value.footer.btns[1].loading = false;
if (res.code == proxy.$passCode) {
getTableData();
ElMessage({
......@@ -1279,6 +1317,7 @@ const dialogBtnClick = (btn, info) => {
// dialogInfo.value.footer.btns.map((item: any) => delete item.disabled)
})
.catch(() => {
dialogInfo.value.footer.btns[1].loading = false;
// dialogInfo.value.footer.btns.map((item: any) => delete item.disabled)
});
}
......@@ -1291,6 +1330,7 @@ const dialogBtnClick = (btn, info) => {
logonUser: info.logonUser,
password: info.password,
linkage: info.linkage,
isHttpsProtocol: info.isHttpsProtocol,
};
checkDataSourceConnectTest(params).then((res: any) => {
if (res.code == proxy.$passCode) {
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!