8c47e418 by lihua

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

1 parent 338f111e
...@@ -17,7 +17,8 @@ ...@@ -17,7 +17,8 @@
17 formId="model-select-edit" col="col3 custom-form" @select-change="handleDataSelectFormSelectChange" 17 formId="model-select-edit" col="col3 custom-form" @select-change="handleDataSelectFormSelectChange"
18 @uploadFileChange="uploadFileChange" @checkboxChange="handleDataSelectFormCheckboxChange" /> 18 @uploadFileChange="uploadFileChange" @checkboxChange="handleDataSelectFormCheckboxChange" />
19 </ContentWrap> 19 </ContentWrap>
20 <ContentWrap v-show="formRef?.formInline?.dataSource != 3" id="id-previewData" title="数据抽样预览" description="" 20 <!-- 抽样预览的表单填写配置,及表格展示 -->
21 <ContentWrap v-show="formRef?.formInline?.dataSource != 3 && !(formRef?.formInline?.dataSourceGuid && currDatasourceSelect?.databaseType === 'obs')" id="id-previewData" title="数据抽样预览" description=""
21 style="margin-top: 16px;"> 22 style="margin-top: 16px;">
22 <!-- 选择抽样预览的表单设置 --> 23 <!-- 选择抽样预览的表单设置 -->
23 <Form ref="dataSimpleFormRef" :itemList="dataSimpleFormItems" :rules="dataSimpleFormRules" 24 <Form ref="dataSimpleFormRef" :itemList="dataSimpleFormItems" :rules="dataSimpleFormRules"
...@@ -614,6 +615,13 @@ const handleDataSelectFormSelectChange = async (val, row, formInfo) => { ...@@ -614,6 +615,13 @@ const handleDataSelectFormSelectChange = async (val, row, formInfo) => {
614 return; 615 return;
615 } 616 }
616 let dsInfo = currDatasourceSelect.value = dataSourceList.value.find(d => d.guid == val); 617 let dsInfo = currDatasourceSelect.value = dataSourceList.value.find(d => d.guid == val);
618 if (dsInfo.databaseType == 'obs') {
619 sampleTableFields.value = [];
620 parseFileDataSum.value = [];
621 sampleTableData.value = [];
622 setDataSelectFormItems(Object.assign({}, formInfo, { file: !formInfo['file'] ? [] : formInfo['file'], tableName: '', qualifiedIdentifier: [] }))
623 return;
624 }
617 //清除数据表得值,重新获取下拉列表 625 //清除数据表得值,重新获取下拉列表
618 const res: any = await getDsTableByDs({ 626 const res: any = await getDsTableByDs({
619 pageSize: -1, 627 pageSize: -1,
...@@ -663,6 +671,10 @@ const handleDataSelectFormSelectChange = async (val, row, formInfo) => { ...@@ -663,6 +671,10 @@ const handleDataSelectFormSelectChange = async (val, row, formInfo) => {
663 } 671 }
664 }); 672 });
665 } else if (row.field == 'handleType') { 673 } else if (row.field == 'handleType') {
674 // 第一种匿名处理类型是不可以选择obs类型的。
675 if (val == '01' && formInfo.dataSourceGuid && currDatasourceSelect.value.databaseType == 'obs') {
676 formInfo.dataSourceGuid = '';
677 }
666 setDataSelectFormItems(formInfo); 678 setDataSelectFormItems(formInfo);
667 } 679 }
668 } 680 }
...@@ -697,10 +709,14 @@ const setDataSelectFormItems = (info, isDetail = false) => { ...@@ -697,10 +709,14 @@ const setDataSelectFormItems = (info, isDetail = false) => {
697 item.default = ''; 709 item.default = '';
698 } 710 }
699 } else if (item.field == 'qualifiedIdentifier') { 711 } else if (item.field == 'qualifiedIdentifier') {
700 item.visible = info['handleType'] == '02' && info['dataSource'] != 3; 712 item.visible = info['handleType'] == '02' && info['dataSource'] != 3 && !(info['dataSourceGuid'] && currDatasourceSelect.value?.databaseType === 'obs');
701 if (info['dataSource'] == 3) { 713 if (info['dataSource'] == 3) {
702 item.options = qualifiedIdentifierFloderList.value; 714 item.options = qualifiedIdentifierFloderList.value;
703 } 715 }
716 } else if (item.field == 'tableName') {
717 item.visible = !(info['dataSourceGuid'] && currDatasourceSelect.value?.databaseType === 'obs');//数据源类型为obs的没有数据表选择
718 } else if (item.field == 'dataSourceGuid') {
719 item.options = info.handleType == '02' ? dataSourceList.value : dataSourceList.value.filter(d => d.databaseType !== 'obs')
704 } 720 }
705 }); 721 });
706 stepsInfo.value = info.handleType == '02' ? reportStepsInfo.value : originStepsInfo.value; 722 stepsInfo.value = info.handleType == '02' ? reportStepsInfo.value : originStepsInfo.value;
...@@ -1393,6 +1409,11 @@ const changeStep = async (val) => { ...@@ -1393,6 +1409,11 @@ const changeStep = async (val) => {
1393 } else if (val == 2) { 1409 } else if (val == 2) {
1394 formRef.value?.ruleFormRef?.validate((valid) => { 1410 formRef.value?.ruleFormRef?.validate((valid) => {
1395 if (valid) { 1411 if (valid) {
1412 let formInline = formRef.value?.formInline;
1413 // if (formInline?.handleType == '01' && formInline?.dataSourceGuid && currDatasourceSelect.value?.databaseType === 'obs') {
1414
1415 // return;
1416 // }
1396 if (formRef.value?.formInline?.dataSource == 2 && !sampleTableFields.value?.length) { 1417 if (formRef.value?.formInline?.dataSource == 2 && !sampleTableFields.value?.length) {
1397 proxy.$ElMessage.error('上传文件的字段不能为空'); 1418 proxy.$ElMessage.error('上传文件的字段不能为空');
1398 return; 1419 return;
...@@ -1522,17 +1543,21 @@ const changeStep = async (val) => { ...@@ -1522,17 +1543,21 @@ const changeStep = async (val) => {
1522 formRef.value?.ruleFormRef?.validate((valid, errorItem) => { 1543 formRef.value?.ruleFormRef?.validate((valid, errorItem) => {
1523 if (valid) { 1544 if (valid) {
1524 let dataSource = formRef.value?.formInline?.dataSource; 1545 let dataSource = formRef.value?.formInline?.dataSource;
1525 if (dataSource == 2 && !sampleTableFields.value?.length) { 1546 if (dataSource == 2 && currDatasourceSelect.value.databaseType !== 'obs' && !sampleTableFields.value?.length) {
1526 proxy.$ElMessage.error('上传文件的字段不能为空'); 1547 proxy.$ElMessage.error('上传文件的字段不能为空');
1527 return; 1548 return;
1528 } 1549 }
1529 if (dataSource != 3) { 1550 if (dataSource != 3) {
1551 if (currDatasourceSelect.value.databaseType === 'obs' && saveParams.dataSourceGuid) {
1552 exec(saveParams);
1553 } else {
1530 dataSimpleFormRef.value?.ruleFormRef?.validate((valid) => { 1554 dataSimpleFormRef.value?.ruleFormRef?.validate((valid) => {
1531 if (valid) { 1555 if (valid) {
1532 // Object.assign(saveParams, { riskThreshold: '0.05' }); 1556 // Object.assign(saveParams, { riskThreshold: '0.05' });
1533 exec(saveParams); 1557 exec(saveParams);
1534 } 1558 }
1535 }); 1559 });
1560 }
1536 } else { 1561 } else {
1537 if (!selectCurrPath.value) { 1562 if (!selectCurrPath.value) {
1538 proxy.$ElMessage.error('请先上传文件'); 1563 proxy.$ElMessage.error('请先上传文件');
...@@ -1657,24 +1682,25 @@ onBeforeMount(() => { ...@@ -1657,24 +1682,25 @@ onBeforeMount(() => {
1657 fileRes?.msg && ElMessage.error(fileRes?.msg); 1682 fileRes?.msg && ElMessage.error(fileRes?.msg);
1658 } 1683 }
1659 // 会出现从文件切换到数据库时没有数据库列表的问题。 1684 // 会出现从文件切换到数据库时没有数据库列表的问题。
1660 const res: any = await getDatabase({ connectStatus: 1 }); 1685 const res: any = await getDatabase({ connectStatus: 1, isAllStorageType: 'Y' });
1661 if (res?.code == proxy.$passCode) { 1686 if (res?.code == proxy.$passCode) {
1662 dataSourceList.value = res.data || []; 1687 dataSourceList.value = res.data || [];
1663 let item = dataSelectInfoItems.value.find(item => item.field == 'dataSourceGuid'); 1688 let item = dataSelectInfoItems.value.find(item => item.field == 'dataSourceGuid');
1664 item && (item.options = dataSourceList.value); 1689 item && (item.options = detailInfo.value.handleType == '01' ? dataSourceList.value.filter(d => d.databaseType !== 'obs') : dataSourceList.value);
1665 } else { 1690 } else {
1666 proxy.$ElMessage.error(res.msg); 1691 proxy.$ElMessage.error(res.msg);
1667 } 1692 }
1668 } else if (dataSource == 1) { 1693 } else if (dataSource == 1) {
1669 const res: any = await getDatabase({ connectStatus: 1 }); 1694 const res: any = await getDatabase({ connectStatus: 1, isAllStorageType: 'Y' });
1670 if (res?.code == proxy.$passCode) { 1695 if (res?.code == proxy.$passCode) {
1671 dataSourceList.value = res.data || []; 1696 dataSourceList.value = res.data || [];
1672 let item = dataSelectInfoItems.value.find(item => item.field == 'dataSourceGuid'); 1697 let item = dataSelectInfoItems.value.find(item => item.field == 'dataSourceGuid');
1673 item && (item.options = dataSourceList.value); 1698 item && (item.options = detailInfo.value.handleType == '01' ? dataSourceList.value.filter(d => d.databaseType !== 'obs') : dataSourceList.value);
1674 } else { 1699 } else {
1675 proxy.$ElMessage.error(res.msg); 1700 proxy.$ElMessage.error(res.msg);
1676 } 1701 }
1677 currDatasourceSelect.value = dataSourceList.value.find(d => d.guid == detailInfo.value.dataSourceGuid); 1702 currDatasourceSelect.value = dataSourceList.value.find(d => d.guid == detailInfo.value.dataSourceGuid);
1703 if (currDatasourceSelect.value.databaseType != 'obs') {
1678 const tableRes: any = await getDsTableByDs({ 1704 const tableRes: any = await getDsTableByDs({
1679 pageSize: -1, 1705 pageSize: -1,
1680 pageIndex: 1, 1706 pageIndex: 1,
...@@ -1712,6 +1738,7 @@ onBeforeMount(() => { ...@@ -1712,6 +1738,7 @@ onBeforeMount(() => {
1712 ElMessage.error(res.msg); 1738 ElMessage.error(res.msg);
1713 } 1739 }
1714 }); 1740 });
1741 }
1715 } else if (dataSource == 3) { 1742 } else if (dataSource == 3) {
1716 processFolderRefresh(); 1743 processFolderRefresh();
1717 } 1744 }
...@@ -1725,11 +1752,12 @@ onBeforeMount(() => { ...@@ -1725,11 +1752,12 @@ onBeforeMount(() => {
1725 } 1752 }
1726 }); 1753 });
1727 } else { 1754 } else {
1728 getDatabase({ connectStatus: 1 }).then((res: any) => { 1755 // TODO,传参是否查询全部,包括obs类型的数据源
1756 getDatabase({ connectStatus: 1, isAllStorageType: 'Y' }).then((res: any) => {
1729 if (res.code == proxy.$passCode) { 1757 if (res.code == proxy.$passCode) {
1730 dataSourceList.value = res.data || []; 1758 dataSourceList.value = res.data || [];
1731 let item = dataSelectInfoItems.value.find(item => item.field == 'dataSourceGuid'); 1759 let item = dataSelectInfoItems.value.find(item => item.field == 'dataSourceGuid');
1732 item && (item.options = dataSourceList.value); 1760 item && (item.options = dataSourceList.value.filter(d => d.databaseType !== 'obs'));
1733 } else { 1761 } else {
1734 proxy.$ElMessage.error(res.msg); 1762 proxy.$ElMessage.error(res.msg);
1735 } 1763 }
......
...@@ -20,6 +20,14 @@ import { ...@@ -20,6 +20,14 @@ import {
20 20
21 const { proxy } = getCurrentInstance() as any; 21 const { proxy } = getCurrentInstance() as any;
22 22
23 /** 数据库类型下拉列表 */
24 const databaseTypesList = ref([
25 { label: "mysql", value: "mysql" },
26 { label: "doris", value: "doris" },
27 { label: "oracle", value: "oracle" },
28 { label: "华为云obs", value: "obs" },
29 ]);
30
23 const searchItemList = ref([ 31 const searchItemList = ref([
24 { 32 {
25 type: "select", 33 type: "select",
...@@ -39,11 +47,7 @@ const searchItemList = ref([ ...@@ -39,11 +47,7 @@ const searchItemList = ref([
39 field: "databaseType", 47 field: "databaseType",
40 default: "", 48 default: "",
41 placeholder: "库类型", 49 placeholder: "库类型",
42 options: [ 50 options: databaseTypesList.value,
43 { label: "mysql", value: "mysql" },
44 { label: "doris", value: "doris" },
45 { label: "oracle", value: "oracle" },
46 ],
47 clearable: true, 51 clearable: true,
48 }, 52 },
49 { 53 {
...@@ -103,7 +107,9 @@ const tableInfo = ref({ ...@@ -103,7 +107,9 @@ const tableInfo = ref({
103 { label: "序号", type: "index", width: 56, align: "center" }, 107 { label: "序号", type: "index", width: 56, align: "center" },
104 { label: "数据源名称", field: "databaseNameZh", width: 120 }, 108 { label: "数据源名称", field: "databaseNameZh", width: 120 },
105 { label: "系统分层", field: "systemLayer", width: 96 }, 109 { label: "系统分层", field: "systemLayer", width: 96 },
106 { label: "库类型", field: "databaseType", width: 96 }, 110 { label: "库类型", field: "databaseType", width: 96, getName: (scope) => {
111 return scope.row.databaseType && databaseTypesList.value.find(item => item.value === scope.row.databaseType)?.label || '--';
112 } },
107 { label: "数据库名", field: "databaseNameEn", width: 200 }, 113 { label: "数据库名", field: "databaseNameEn", width: 200 },
108 { 114 {
109 label: "连通状态", 115 label: "连通状态",
...@@ -206,11 +212,7 @@ const contents: any = ref({ ...@@ -206,11 +212,7 @@ const contents: any = ref({
206 placeholder: "请选择", 212 placeholder: "请选择",
207 field: "databaseType", 213 field: "databaseType",
208 default: "", 214 default: "",
209 options: [ 215 options: databaseTypesList.value,
210 { label: "mysql", value: "mysql" },
211 { label: "doris", value: "doris" },
212 { label: "oracle", value: "oracle" },
213 ],
214 clearable: true, 216 clearable: true,
215 required: true, 217 required: true,
216 }, 218 },
...@@ -329,6 +331,18 @@ const contents: any = ref({ ...@@ -329,6 +331,18 @@ const contents: any = ref({
329 required: true, 331 required: true,
330 }, 332 },
331 { 333 {
334 type: 'radio-group',
335 label: '是否https协议',
336 field: 'isHttpsProtocol',
337 default: 'Y',
338 required: true,
339 visible: false,
340 options: [
341 { label: '是', value: 'Y' },
342 { label: '否', value: 'N' },
343 ],
344 },
345 {
332 label: "连接属性", 346 label: "连接属性",
333 type: "textarea-tips", 347 type: "textarea-tips",
334 placeholder: "请输入", 348 placeholder: "请输入",
...@@ -941,7 +955,7 @@ const dialogInfo = ref({ ...@@ -941,7 +955,7 @@ const dialogInfo = ref({
941 footer: { 955 footer: {
942 btns: [ 956 btns: [
943 { type: "default", label: "取消", value: "cancel" }, 957 { type: "default", label: "取消", value: "cancel" },
944 { type: "primary", label: "确定", value: "submit" }, 958 { type: "primary", label: "确定", value: "submit", loading: false },
945 ], 959 ],
946 textBtns: [{ type: "primary", label: "连通测试", value: "connect" }], 960 textBtns: [{ type: "primary", label: "连通测试", value: "connect" }],
947 }, 961 },
...@@ -993,13 +1007,30 @@ const setFormItems = (name, info: any = null) => { ...@@ -993,13 +1007,30 @@ const setFormItems = (name, info: any = null) => {
993 child.default = info[child.field] ?? ""; 1007 child.default = info[child.field] ?? "";
994 } 1008 }
995 }); 1009 });
1010 } else if (item.field == 'isHttpsProtocol') {
1011 item.visible = info.databaseType == "obs";
1012 item.default = info[item.field] || "Y";
996 } else if (item.field == 'bizSystem') { 1013 } else if (item.field == 'bizSystem') {
997 item.visible = info.systemLayer == '业务系统'; 1014 item.visible = info.systemLayer == '业务系统';
998 item.default = info[item.field] || ""; 1015 item.default = info[item.field] || "";
999 } 1016 } else {
1000 else {
1001 item.default = info[item.field] || ""; 1017 item.default = info[item.field] || "";
1002 } 1018 }
1019 if (item.field == 'host') {
1020 item.label = info.databaseType == "obs" ? "地址" : "服务器";
1021 contentFormInfo.rules.host[0].message = info.databaseType == "obs" ? "请填写地址" : "请填写服务器IP地址";
1022 } else if (item.field == 'port') {
1023 item.visible = info.databaseType != "obs";
1024 } else if (item.field == 'logonUser') {
1025 item.label = info.databaseType == "obs" ? "凭证ID" : "用户名";
1026 contentFormInfo.rules.logonUser[0].message = info.databaseType == "obs" ? "请填写凭证ID" : "请填写用户名";
1027 } else if (item.field == 'password') {
1028 item.label = info.databaseType == "obs" ? "凭证Key" : "密码";
1029 contentFormInfo.rules.password[0].message = info.databaseType == "obs" ? "请填写凭证Key" : "请填写密码";
1030 } else if (item.field == 'databaseNameEn') {
1031 item.label = info.databaseType == "obs" ? "桶名称" : "数据库名";
1032 contentFormInfo.rules.databaseNameEn[0].message = info.databaseType == "obs" ? "请填写桶名称" : "请填写数据库名";
1033 }
1003 }); 1034 });
1004 } else { 1035 } else {
1005 formItems.value.map((item) => { 1036 formItems.value.map((item) => {
...@@ -1224,10 +1255,13 @@ const dialogBtnClick = (btn, info) => { ...@@ -1224,10 +1255,13 @@ const dialogBtnClick = (btn, info) => {
1224 password: info.password, 1255 password: info.password,
1225 feLoadUrl: info.feLoadUrl, 1256 feLoadUrl: info.feLoadUrl,
1226 beLoadUrl: info.beLoadUrl, 1257 beLoadUrl: info.beLoadUrl,
1227 dorisJdbcUrl: info.dorisJdbcUrl 1258 dorisJdbcUrl: info.dorisJdbcUrl,
1259 isHttpsProtocol: info.isHttpsProtocol,
1228 }; 1260 };
1261 dialogInfo.value.footer.btns[1].loading = true;
1229 addDataSource(params) 1262 addDataSource(params)
1230 .then((res: any) => { 1263 .then((res: any) => {
1264 dialogInfo.value.footer.btns[1].loading = false;
1231 if (res.code == proxy.$passCode) { 1265 if (res.code == proxy.$passCode) {
1232 getFirstPageData(); 1266 getFirstPageData();
1233 ElMessage({ 1267 ElMessage({
...@@ -1244,6 +1278,7 @@ const dialogBtnClick = (btn, info) => { ...@@ -1244,6 +1278,7 @@ const dialogBtnClick = (btn, info) => {
1244 } 1278 }
1245 }) 1279 })
1246 .catch(() => { 1280 .catch(() => {
1281 dialogInfo.value.footer.btns[1].loading = false;
1247 // dialogInfo.value.footer.btns.map((item: any) => delete item.disabled) 1282 // dialogInfo.value.footer.btns.map((item: any) => delete item.disabled)
1248 }); 1283 });
1249 } else { 1284 } else {
...@@ -1258,11 +1293,14 @@ const dialogBtnClick = (btn, info) => { ...@@ -1258,11 +1293,14 @@ const dialogBtnClick = (btn, info) => {
1258 : info.password, 1293 : info.password,
1259 feLoadUrl: info.feLoadUrl, 1294 feLoadUrl: info.feLoadUrl,
1260 beLoadUrl: info.beLoadUrl, 1295 beLoadUrl: info.beLoadUrl,
1261 dorisJdbcUrl: info.dorisJdbcUrl 1296 dorisJdbcUrl: info.dorisJdbcUrl,
1297 isHttpsProtocol: info.isHttpsProtocol,
1262 }; 1298 };
1263 params.guid = currTableData.value.guid; 1299 params.guid = currTableData.value.guid;
1300 dialogInfo.value.footer.btns[1].loading = true;
1264 updateDataSource(params) 1301 updateDataSource(params)
1265 .then((res: any) => { 1302 .then((res: any) => {
1303 dialogInfo.value.footer.btns[1].loading = false;
1266 if (res.code == proxy.$passCode) { 1304 if (res.code == proxy.$passCode) {
1267 getTableData(); 1305 getTableData();
1268 ElMessage({ 1306 ElMessage({
...@@ -1279,6 +1317,7 @@ const dialogBtnClick = (btn, info) => { ...@@ -1279,6 +1317,7 @@ const dialogBtnClick = (btn, info) => {
1279 // dialogInfo.value.footer.btns.map((item: any) => delete item.disabled) 1317 // dialogInfo.value.footer.btns.map((item: any) => delete item.disabled)
1280 }) 1318 })
1281 .catch(() => { 1319 .catch(() => {
1320 dialogInfo.value.footer.btns[1].loading = false;
1282 // dialogInfo.value.footer.btns.map((item: any) => delete item.disabled) 1321 // dialogInfo.value.footer.btns.map((item: any) => delete item.disabled)
1283 }); 1322 });
1284 } 1323 }
...@@ -1291,6 +1330,7 @@ const dialogBtnClick = (btn, info) => { ...@@ -1291,6 +1330,7 @@ const dialogBtnClick = (btn, info) => {
1291 logonUser: info.logonUser, 1330 logonUser: info.logonUser,
1292 password: info.password, 1331 password: info.password,
1293 linkage: info.linkage, 1332 linkage: info.linkage,
1333 isHttpsProtocol: info.isHttpsProtocol,
1294 }; 1334 };
1295 checkDataSourceConnectTest(params).then((res: any) => { 1335 checkDataSourceConnectTest(params).then((res: any) => {
1296 if (res.code == proxy.$passCode) { 1336 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!