8235395e by lihua

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

1 parent 6f51b92f
...@@ -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"
...@@ -611,6 +612,13 @@ const handleDataSelectFormSelectChange = async (val, row, formInfo) => { ...@@ -611,6 +612,13 @@ const handleDataSelectFormSelectChange = async (val, row, formInfo) => {
611 return; 612 return;
612 } 613 }
613 let dsInfo = currDatasourceSelect.value = dataSourceList.value.find(d => d.guid == val); 614 let dsInfo = currDatasourceSelect.value = dataSourceList.value.find(d => d.guid == val);
615 if (dsInfo.databaseType == 'obs') {
616 sampleTableFields.value = [];
617 parseFileDataSum.value = [];
618 sampleTableData.value = [];
619 setDataSelectFormItems(Object.assign({}, formInfo, { file: !formInfo['file'] ? [] : formInfo['file'], tableName: '', qualifiedIdentifier: [] }))
620 return;
621 }
614 //清除数据表得值,重新获取下拉列表 622 //清除数据表得值,重新获取下拉列表
615 const res: any = await getDsTableByDs({ 623 const res: any = await getDsTableByDs({
616 pageSize: -1, 624 pageSize: -1,
...@@ -660,6 +668,10 @@ const handleDataSelectFormSelectChange = async (val, row, formInfo) => { ...@@ -660,6 +668,10 @@ const handleDataSelectFormSelectChange = async (val, row, formInfo) => {
660 } 668 }
661 }); 669 });
662 } else if (row.field == 'handleType') { 670 } else if (row.field == 'handleType') {
671 // 第一种匿名处理类型是不可以选择obs类型的。
672 if (val == '01' && formInfo.dataSourceGuid && currDatasourceSelect.value.databaseType == 'obs') {
673 formInfo.dataSourceGuid = '';
674 }
663 setDataSelectFormItems(formInfo); 675 setDataSelectFormItems(formInfo);
664 } 676 }
665 } 677 }
...@@ -694,10 +706,14 @@ const setDataSelectFormItems = (info, isDetail = false) => { ...@@ -694,10 +706,14 @@ const setDataSelectFormItems = (info, isDetail = false) => {
694 item.default = ''; 706 item.default = '';
695 } 707 }
696 } else if (item.field == 'qualifiedIdentifier') { 708 } else if (item.field == 'qualifiedIdentifier') {
697 item.visible = info['handleType'] == '02' && info['dataSource'] != 3; 709 item.visible = info['handleType'] == '02' && info['dataSource'] != 3 && !(info['dataSourceGuid'] && currDatasourceSelect.value?.databaseType === 'obs');
698 if (info['dataSource'] == 3) { 710 if (info['dataSource'] == 3) {
699 item.options = qualifiedIdentifierFloderList.value; 711 item.options = qualifiedIdentifierFloderList.value;
700 } 712 }
713 } else if (item.field == 'tableName') {
714 item.visible = !(info['dataSourceGuid'] && currDatasourceSelect.value?.databaseType === 'obs');//数据源类型为obs的没有数据表选择
715 } else if (item.field == 'dataSourceGuid') {
716 item.options = info.handleType == '02' ? dataSourceList.value : dataSourceList.value.filter(d => d.databaseType !== 'obs')
701 } 717 }
702 }); 718 });
703 stepsInfo.value = info.handleType == '02' ? reportStepsInfo.value : originStepsInfo.value; 719 stepsInfo.value = info.handleType == '02' ? reportStepsInfo.value : originStepsInfo.value;
...@@ -1368,6 +1384,11 @@ const changeStep = async (val) => { ...@@ -1368,6 +1384,11 @@ const changeStep = async (val) => {
1368 } else if (val == 2) { 1384 } else if (val == 2) {
1369 formRef.value?.ruleFormRef?.validate((valid) => { 1385 formRef.value?.ruleFormRef?.validate((valid) => {
1370 if (valid) { 1386 if (valid) {
1387 let formInline = formRef.value?.formInline;
1388 // if (formInline?.handleType == '01' && formInline?.dataSourceGuid && currDatasourceSelect.value?.databaseType === 'obs') {
1389
1390 // return;
1391 // }
1371 if (formRef.value?.formInline?.dataSource == 2 && !sampleTableFields.value?.length) { 1392 if (formRef.value?.formInline?.dataSource == 2 && !sampleTableFields.value?.length) {
1372 proxy.$ElMessage.error('上传文件的字段不能为空'); 1393 proxy.$ElMessage.error('上传文件的字段不能为空');
1373 return; 1394 return;
...@@ -1497,17 +1518,21 @@ const changeStep = async (val) => { ...@@ -1497,17 +1518,21 @@ const changeStep = async (val) => {
1497 formRef.value?.ruleFormRef?.validate((valid, errorItem) => { 1518 formRef.value?.ruleFormRef?.validate((valid, errorItem) => {
1498 if (valid) { 1519 if (valid) {
1499 let dataSource = formRef.value?.formInline?.dataSource; 1520 let dataSource = formRef.value?.formInline?.dataSource;
1500 if (dataSource == 2 && !sampleTableFields.value?.length) { 1521 if (dataSource == 2 && currDatasourceSelect.value.databaseType !== 'obs' && !sampleTableFields.value?.length) {
1501 proxy.$ElMessage.error('上传文件的字段不能为空'); 1522 proxy.$ElMessage.error('上传文件的字段不能为空');
1502 return; 1523 return;
1503 } 1524 }
1504 if (dataSource != 3) { 1525 if (dataSource != 3) {
1526 if (currDatasourceSelect.value.databaseType === 'obs' && saveParams.dataSourceGuid) {
1527 exec(saveParams);
1528 } else {
1505 dataSimpleFormRef.value?.ruleFormRef?.validate((valid) => { 1529 dataSimpleFormRef.value?.ruleFormRef?.validate((valid) => {
1506 if (valid) { 1530 if (valid) {
1507 // Object.assign(saveParams, { riskThreshold: '0.05' }); 1531 // Object.assign(saveParams, { riskThreshold: '0.05' });
1508 exec(saveParams); 1532 exec(saveParams);
1509 } 1533 }
1510 }); 1534 });
1535 }
1511 } else { 1536 } else {
1512 if (!clickSelectNode.value.path) { 1537 if (!clickSelectNode.value.path) {
1513 proxy.$ElMessage.error('请先上传文件'); 1538 proxy.$ElMessage.error('请先上传文件');
...@@ -1632,24 +1657,25 @@ onBeforeMount(() => { ...@@ -1632,24 +1657,25 @@ onBeforeMount(() => {
1632 fileRes?.msg && ElMessage.error(fileRes?.msg); 1657 fileRes?.msg && ElMessage.error(fileRes?.msg);
1633 } 1658 }
1634 // 会出现从文件切换到数据库时没有数据库列表的问题。 1659 // 会出现从文件切换到数据库时没有数据库列表的问题。
1635 const res: any = await getDatabase({ connectStatus: 1 }); 1660 const res: any = await getDatabase({ connectStatus: 1, isAllStorageType: 'Y' });
1636 if (res?.code == proxy.$passCode) { 1661 if (res?.code == proxy.$passCode) {
1637 dataSourceList.value = res.data || []; 1662 dataSourceList.value = res.data || [];
1638 let item = dataSelectInfoItems.value.find(item => item.field == 'dataSourceGuid'); 1663 let item = dataSelectInfoItems.value.find(item => item.field == 'dataSourceGuid');
1639 item && (item.options = dataSourceList.value); 1664 item && (item.options = detailInfo.value.handleType == '01' ? dataSourceList.value.filter(d => d.databaseType !== 'obs') : dataSourceList.value);
1640 } else { 1665 } else {
1641 proxy.$ElMessage.error(res.msg); 1666 proxy.$ElMessage.error(res.msg);
1642 } 1667 }
1643 } else if (dataSource == 1) { 1668 } else if (dataSource == 1) {
1644 const res: any = await getDatabase({ connectStatus: 1 }); 1669 const res: any = await getDatabase({ connectStatus: 1, isAllStorageType: 'Y' });
1645 if (res?.code == proxy.$passCode) { 1670 if (res?.code == proxy.$passCode) {
1646 dataSourceList.value = res.data || []; 1671 dataSourceList.value = res.data || [];
1647 let item = dataSelectInfoItems.value.find(item => item.field == 'dataSourceGuid'); 1672 let item = dataSelectInfoItems.value.find(item => item.field == 'dataSourceGuid');
1648 item && (item.options = dataSourceList.value); 1673 item && (item.options = detailInfo.value.handleType == '01' ? dataSourceList.value.filter(d => d.databaseType !== 'obs') : dataSourceList.value);
1649 } else { 1674 } else {
1650 proxy.$ElMessage.error(res.msg); 1675 proxy.$ElMessage.error(res.msg);
1651 } 1676 }
1652 currDatasourceSelect.value = dataSourceList.value.find(d => d.guid == detailInfo.value.dataSourceGuid); 1677 currDatasourceSelect.value = dataSourceList.value.find(d => d.guid == detailInfo.value.dataSourceGuid);
1678 if (currDatasourceSelect.value.databaseType != 'obs') {
1653 const tableRes: any = await getDsTableByDs({ 1679 const tableRes: any = await getDsTableByDs({
1654 pageSize: -1, 1680 pageSize: -1,
1655 pageIndex: 1, 1681 pageIndex: 1,
...@@ -1687,6 +1713,7 @@ onBeforeMount(() => { ...@@ -1687,6 +1713,7 @@ onBeforeMount(() => {
1687 ElMessage.error(res.msg); 1713 ElMessage.error(res.msg);
1688 } 1714 }
1689 }); 1715 });
1716 }
1690 } else if (dataSource == 3) { 1717 } else if (dataSource == 3) {
1691 processFolderRefresh(); 1718 processFolderRefresh();
1692 } 1719 }
...@@ -1700,11 +1727,12 @@ onBeforeMount(() => { ...@@ -1700,11 +1727,12 @@ onBeforeMount(() => {
1700 } 1727 }
1701 }); 1728 });
1702 } else { 1729 } else {
1703 getDatabase({ connectStatus: 1 }).then((res: any) => { 1730 // TODO,传参是否查询全部,包括obs类型的数据源
1731 getDatabase({ connectStatus: 1, isAllStorageType: 'Y' }).then((res: any) => {
1704 if (res.code == proxy.$passCode) { 1732 if (res.code == proxy.$passCode) {
1705 dataSourceList.value = res.data || []; 1733 dataSourceList.value = res.data || [];
1706 let item = dataSelectInfoItems.value.find(item => item.field == 'dataSourceGuid'); 1734 let item = dataSelectInfoItems.value.find(item => item.field == 'dataSourceGuid');
1707 item && (item.options = dataSourceList.value); 1735 item && (item.options = dataSourceList.value.filter(d => d.databaseType !== 'obs'));
1708 } else { 1736 } else {
1709 proxy.$ElMessage.error(res.msg); 1737 proxy.$ElMessage.error(res.msg);
1710 } 1738 }
......
...@@ -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!