fee6b498 by lxs

Merge branch 'develop' of http://117.78.60.236:8000/csbr-daop/fe-data-asset-management into develop

2 parents c617ba60 526d4baa
......@@ -671,6 +671,18 @@ export const getDbDirTableSelectList = (data) => request({
data
})
/**
* 数据库目录-字段查询下拉
* @param {Object}
* @path /db-dir/field/select-list
*/
export const getDbDirFieldSelectList = (data) => request({
url: `${import.meta.env.VITE_APP_CHECK_BASEURL}/db-dir/field/select-list`,
method: 'post',
data
})
/** 获取已有字段信息 */
......@@ -780,8 +792,6 @@ export const getDbDirDetail = (params) => request({
method: 'get',
})
/*********************业务规则配置 ************数据库目录************************* */
/**
......
......@@ -6,13 +6,24 @@
import { Warning } from "@element-plus/icons-vue";
import TableTools from '@/components/Tools/table_tools.vue';
import {
getCgDirTreeList, getCgDirFieldPageList, getDictionary, saveBizRuleConfig,
getDbDirTreeList, getDbDirTablePageList, getDbDirFieldPageList, getExecGuidAndName,
getClassifyTreeList, getCgLabelPageList, execTaskFieldList, execTaskSheetList, getTaskExeTreeList,
getDbFieldList, exportCgDir,
getDictionary,
saveBizRuleConfig,
getDbDirTreeList,
getDbDirTablePageList,
getDbDirFieldPageList,
getExecGuidAndName,
getClassifyTreeList,
getCgLabelPageList,
execTaskFieldList,
execTaskSheetList,
getTaskExeTreeList,
getDbFieldList,
exportCgDir,
getGradeList,
exportDbDirTable,
getDbDirDetail
getDbDirDetail,
getDbDirTableSelectList,
getDbDirFieldSelectList
} from '@/api/modules/dataInventory';
import { TableColumnWidth } from "@/utils/enum";
import router from "@/router";
......@@ -150,6 +161,7 @@ const searchItemList = ref([
value: 'guid',
},
clearable: true,
filterable: true,
},
{
label: "",
......@@ -195,6 +207,7 @@ const toSearch = (val: any, clear: boolean = false) => {
searchItemList.value.map(item => item.default = '')
}
// 差一个label标签 -- 未完成
if (activeName.value === 'first') {
getCgDirFieldPage({
pageIndex: 1,
pageSize: 50,
......@@ -205,6 +218,22 @@ const toSearch = (val: any, clear: boolean = false) => {
tableGuid: selectedB.value,
fieldGuid: selectedC.value,
});
}
if (activeName.value === 'second') {
getDataBaseFieldData({
pageIndex: 1,
pageSize: 50,
execGuid: execGuidInfo.value.execGuid,
databaseGuid: selectedA.value,
tableGuid: selectedB.value,
fieldGuid: selectedC.value,
});
}
if (activeName.value === 'second' && activeTab.value === 'word') {
getSearchTableList(1, selectedA.value);
getSearchTableList(2, selectedB.value);
getSearchTableList(3, selectedC.value);
}
};
......@@ -408,7 +437,11 @@ const dataBaseTableInfo = ref({
{
label: "新建方式", field: "foundMode", width: 140, getName: (scope) => {
let dataGrade = scope.row.foundMode;
return dataGrade == 1 ? '根据文件新建' : '已有表新建';
return dataGrade === 1
? '已有表新建'
: dataGrade === 2
? '根据文件新建'
: '--';
}
},
{
......@@ -713,9 +746,19 @@ const handleClick = (tab: any) => {
console.log(tab.props.name);
activeName.value = tab.props.name;
if (tab.props.name === 'second') {
optionsA.value = [];
optionsB.value = [];
optionsC.value = [];
getDataBaseTreeData();
getDataBaseTableData();
getDataBaseFieldData();
getDbDirTableSelectData(1, {});
} else {
optionsA.value = [];
optionsB.value = [];
optionsC.value = [];
getSearchTableList();
isShowWordSearch.value = true;
}
}
......@@ -770,6 +813,11 @@ const getDataBaseTableData = async (params = {}) => {
databaseGuid: "",
isDataAsset: '',
execGuid: execGuidInfo.value.execGuid,
tableName: "",
database: "",
label: "",
classifyDetailName: "",
gradeDetailName: ""
};
const finalParams = { ...dataBaseParams, ...params };
......@@ -946,17 +994,57 @@ const addIsShowDatabaseTip = () => {
// 表信息和字段信息切换
const activeTab = ref('table');
const isShowWordSearch = ref(true);
const setActiveTab = (tab) => {
console.log('setActiveTab', tab);
activeTab.value = tab;
if (tab === 'word' && activeName.value === 'second') {
isShowWordSearch.value = false;
optionsA.value = [];
optionsB.value = [];
optionsC.value = [];
getDbDirFieldSelectData(1);
} else {
isShowWordSearch.value = true;
optionsA.value = [];
optionsB.value = [];
optionsC.value = [];
getDbDirTableSelectData(1, {});
}
};
// 数据库字段搜索联动 getDbDirFieldSelectList
const getDbDirFieldSelectData = async (type, params = {}) => {
const inParams = {
condition: "database",
database: "",
tableName: "",
execGuid: execGuidInfo.value.execGuid,
};
const finalParams = { ...inParams, ...params };
const res: any = await getDbDirFieldSelectList(finalParams);
if (res.code == proxy.$passCode) {
console.log('getDbDirFieldSelectData', res);
if (type == 1) {
optionsA.value = res.data.map((item) => ({
dbGuid: item.database, // 数据库标识
name: item.database, // 数据库名称
}));
}
if (type == 2) {
optionsB.value = res.data.map((item) => ({
dbGuid: item.tableName, // 表标识
name: item.tableName, // 表名称
}));
}
} else {
proxy.$ElMessage.error(res.msg);
}
};
// 获取查询的数据库名 execTaskSheetList
const getSearchTableList = async (type = 1, dbGuid = '') => {
const res: any = await getDbFieldList({
execGuid: execGuidInfo.value.execGuid,
dbGuid,
......@@ -974,6 +1062,45 @@ const getSearchTableList = async (type = 1, dbGuid = '') => {
proxy.$ElMessage.error(res.msg);
}
};
//数据库目录搜索联动 getDbDirTableSelectList
const getDbDirTableSelectData = async (type, params = {}) => {
console.log('getDbDirTableSelectData', params);
const inParams = {
condition: "database",
database: "",
tableName: "",
execGuid: execGuidInfo.value.execGuid,
};
const finalParams = { ...inParams, ...params };
const res: any = await getDbDirTableSelectList(finalParams);
if (res.code == proxy.$passCode) {
console.log('getDbDirTableSelectData', res);
if (type == 1) {
optionsA.value = res.data.map((item) => ({
dbGuid: item.database, // 数据库标识
name: item.database, // 数据库名称
}));
}
if (type == 2) {
optionsB.value = res.data.map((item) => ({
dbGuid: item.tableName, // 表标识
name: item.tableName, // 表名称
}));
}
if (type == 3) {
optionsC.value = res.data.map((item) => ({
dbGuid: item.fieldName, // 字段标识
name: item.fieldName, // 字段名称
}));
}
} else {
proxy.$ElMessage.error(res.msg);
}
};
const selectedA = ref<any>(null);
const selectedB = ref<any>(null);
const selectedC = ref<any>(null);
......@@ -988,7 +1115,15 @@ const onAChange = async () => {
selectedC.value = null;
optionsB.value = [];
optionsC.value = [];
await getSearchTableList(2, selectedA.value); // 根据 A 动态加载 B 的选项
if (!selectedA.value) return;
if (activeName.value == 'first') {
await getSearchTableList(2, selectedA.value); // 分类分级搜索
}
if (activeName.value == 'second') {
console.log('onAChange', optionsA.value);
await getDbDirTableSelectData(2, { database: selectedA.value }); // 数据库搜索
}
};
// 第二个下拉框值改变时
......@@ -996,7 +1131,13 @@ const onBChange = async () => {
console.log('onBChange', selectedB.value);
selectedC.value = null;
optionsC.value = [];
await getSearchTableList(3, selectedB.value); // 根据 B 动态加载 C 的选项
if (!selectedB.value) return;
if (activeName.value == 'first') {
await getSearchTableList(3, selectedB.value); // 分类分级搜索
}
if (activeName.value == 'second') {
await getDbDirTableSelectData(3, { tableName: selectedB.value }); // 数据库搜索
}
};
// 导出
......@@ -1004,6 +1145,7 @@ const btnClick = async () => {
exportCgDir().then((res: any) => {
download(res, '分类分级目录数据.xlsx', 'excel')
});
};
// 数据库导出
const exportDB = async () => {
......@@ -1025,15 +1167,15 @@ const treeSelectNodeChange = (node, item) => {
<div class="classification-template-content">
<div class="v-table-tools">
<el-select v-model="selectedA" placeholder="选择数据库名" @change="onAChange" style="width: 140px; margin-right: 8px"
:clearable="false">
:clearable="true">
<el-option v-for="item in optionsA" :key="item.dbGuid" :label="item.name" :value="item.dbGuid" />
</el-select>
<el-select v-model="selectedB" placeholder="选择表名" :disabled="!selectedA" @change="onBChange"
style="width: 140px; margin-right: 8px" :clearable="false">
style="width: 140px; margin-right: 8px" :clearable="true">
<el-option v-for="item in optionsB" :key="item.dbGuid" :label="item.name" :value="item.dbGuid" />
</el-select>
<el-select v-model="selectedC" placeholder="选择字段名" :disabled="!selectedB" style="width: 140px;margin-right: 8px"
:clearable="false">
:clearable="true" v-if="isShowWordSearch">
<el-option v-for="item in optionsC" :key="item.dbGuid" :label="item.name" :value="item.dbGuid" />
</el-select>
<TableTools :searchItems="searchItemList" :init="false" :searchId="'files-standard-search'" @search="toSearch"
......
......@@ -377,23 +377,54 @@ const tableSwitchChange = async (state, scope, field) => {
const tableBtnClick = async (scope, value) => {
console.log('tableBtnClick', scope.row);
// await getGradeListData(scope.row.gradeGuid);
// // formItems进行回显,加上disabled: true 不能修改
// newCreateGradeFormItems.value.forEach(item => {
// item.default = scope.row[item.field];
// item.disabled = true;
// });
// matchChValue.value.value = scope.row.matchChValue;
// matchChValue.value.disabled = true;
// matchEnValue.value.value = scope.row.matchEnValue;
// matchEnValue.value.disabled = true;
// if (scope.row.vagueMatchRule) {
// // formRows进行回显
// formRows.value = scope.row.vagueMatchRule.map((item) => ({
// matchValue: item.matchValue,
// position: item.position,
// name: item.name,
// disabled: true
// }));
// } else {
// formRows.value = [{ matchValue: '', position: '', name: '', disabled: false }];
// }
// newCreateGradeStandardDialogInfo.value.visible = true;
newCreateGradeStandardDialogInfo.value.submitBtnLoading = false;
newCreateGradeStandardDialogInfo.value.title = '编辑标签';
await getGradeListData(scope.row.gradeGuid);
// 遍历classGradeTreeData 找到对应的guid item的refGradeGuid
classGradeTreeData.value.forEach((element: any) => {
if (element.guid === scope.row.classifyGuid) {
tempRefGradeGuid.value = element.refGradeGuid;
}
});
editLabelRow.value = scope.row;
// formItems进行回显,加上disabled: true 不能修改
newCreateGradeFormItems.value.forEach(item => {
item.default = scope.row[item.field];
item.disabled = true;
item.disabled = false;
});
matchChValue.value.value = scope.row.matchChValue;
matchChValue.value.disabled = true;
matchChValue.value.disabled = false;
matchEnValue.value.value = scope.row.matchEnValue;
matchEnValue.value.disabled = true;
matchEnValue.value.disabled = false;
if (scope.row.vagueMatchRule) {
// formRows进行回显
formRows.value = scope.row.vagueMatchRule.map((item) => ({
matchValue: item.matchValue,
position: item.position,
name: item.name,
disabled: true
disabled: false
}));
} else {
formRows.value = [{ matchValue: '', position: '', name: '', disabled: false }];
......
......@@ -330,7 +330,7 @@ watch(
watch(currDatasourceSelect, (val) => {
if (val?.tableName) {
getPreviewData();
// getPreviewData();
getTableStructure();
}
});
......@@ -395,7 +395,8 @@ const getTextAlign = (field) => {
<span>条数据</span>
</div>
<el-tabs class="preview-tabs" v-model="currDsPreviewActiveName">
<el-tab-pane label="查询结果" name="resultData" class="t-left">
<!-- resultData,tableStructure -->
<!-- <el-tab-pane label="查询结果" name="resultData" class="t-left">
<div v-if="!currDatasourceSelect?.tableName" class="no-select-table">
<img src="../../assets/images/no-data.png" :style="{ width: '96px', height: '96px' }" />
<span>请从已选库表中选择</span>
......@@ -419,8 +420,8 @@ const getTextAlign = (field) => {
:formatter="(row) => formatterPreviewDate(row, field)">
</el-table-column>
</el-table>
</el-tab-pane>
<el-tab-pane label="库表结构" name="tableStructure" class="t-left">
</el-tab-pane> -->
<el-tab-pane label="库表结构" name="resultData" class="t-left">
<div v-if="!currDatasourceSelect?.tableName" class="no-select-table">
<img src="../../assets/images/no-data.png" :style="{ width: '96px', height: '96px' }" />
<span>请从已选库表中选择</span>
......
......@@ -207,9 +207,11 @@ const nextStep = async () => {
//下一步获取表字段信息getNextTableInfo。getDsData 入参selectedDatabaseTable.value
const getNextTableInfo = async (params) => {
tableFieldsLoading.value = true;
const res: any = await getDsTableStructures(params);
if (res.code === proxy.$passCode) {
tableDataDetailInfo.value = res.data;
tableFieldsLoading.value = false;
} else {
proxy.$ElMessage.error(res.msg);
}
......@@ -470,63 +472,18 @@ const submitAsDraft = () => {
// }
const guid = ref('')
const saveBtn = ref(false)
const submit = async () => {
console.log('提交', tableDataDetailInfo.value, tableDataInfo.value)
const params = {
tableName: tableDataInfo.value[0].tableName,
tableChName: tableDataInfo.value[0].tableChName,
foundMode: route.query.foundMode,
}
saveBtn.value = true
// 校验表格数据是否填写完整
// if (!checkTableData(tableDataDetailInfo.value, tableDataInfo.value)) {
// return
// }
/**
"guid": "string",
"cgDirName": "string",
"dirGuid": "string",
"tableGuid": "string",
"tableName": "string",
"tableChName": "string",
"databaseGuid": "string",
"database": "string",
"dbType": "string",
"databaseChName": "string",
"foundMode": 0,
"state": 0,
"isDraft": "string",
"fieldRQVOList": [
{
"guid": "string",
"cgDirName": "string",
"dirGuid": "string",
"classifyName": "string",
"gradeDetailName": "string",
"tableGuid": "string",
"tableName": "string",
"tableChName": "string",
"databaseGuid": "string",
"database": "string",
"databaseChName": "string",
"fieldGuid": "string",
"fieldName": "string",
"fieldChName": "string",
"fieldType": "string",
"fieldLength": 0,
"fieldPrecision": 0,
"dimGuid": "string",
"dictionaryGuid": "string",
"sortValue": 0,
"isPrimary": "string",
"isFk": "string",
"isNotNull": "string",
"defaultValue": "string"
}
], 这是入参
*/
// 如果提交时没有 guid 则为新增type 0,否则为修改 type 1, 也要传参
if (!guid.value) {
saveOrUpdate({
try {
await saveOrUpdate({
tableName: tableDataInfo.value[0].tableName,
tableChName: tableDataInfo.value[0].tableChName,
databaseGuid: route.query.databaseGuid || '',
......@@ -535,8 +492,27 @@ const submit = async () => {
foundMode: route.query.foundMode,
isDraft: 'N',
}, 0)
saveBtn.value = false
} catch (error) {
saveBtn.value = false
}
} else {
saveOrUpdate({}, 1)
// 修改 saveOrUpdate({}, 1)
try {
await saveOrUpdate({
guid: guid.value,
tableName: tableDataInfo.value[0].tableName,
tableChName: tableDataInfo.value[0].tableChName,
databaseGuid: route.query.databaseGuid || '',
database: route.query.database || '',
databaseChName: route.query.databaseChName || '',
foundMode: route.query.foundMode,
isDraft: 'N',
}, 1)
saveBtn.value = false
} catch (error) {
saveBtn.value = false
}
}
}
......@@ -587,7 +563,7 @@ const saveOrUpdate = async (params: any = {}, type) => {
// 生成建表语句
const res2: any = await createTableSql(finalParams);
if (res2.code === proxy.$passCode) {
proxy.$ElMessage.success('建表生成成功!');
proxy.$ElMessage.success('建表sql生成成功!');
} else {
proxy.$ElMessage.error(res2.msg);
}
......@@ -610,7 +586,7 @@ const newCreateSqlFormItems = ref([{
type: 'select',
maxlength: 50,
placeholder: '请输入',
field: 'name',
field: 'dbType',
default: 'mysql',
options: options,
block: true,
......@@ -619,7 +595,7 @@ const newCreateSqlFormItems = ref([{
}]);
const newCreateSqlFormRules = ref({
name: [
dbType: [
{ required: true, message: '请选择数据库名称', trigger: 'blur' },
]
});
......@@ -641,6 +617,15 @@ const newCreateSqlDialogInfo = ref({
},
submit: async (btn, info) => {
// 校验tableDataInfo 分开校验
if (!tableDataInfo.value[0].tableName) {
proxy.$ElMessage.error('请填写数据库名称');
return;
}
if (!tableDataInfo.value[0].tableChName) {
proxy.$ElMessage.error('请填写数据库表');
return;
}
newCreateSqlDialogInfo.value.submitBtnLoading = true;
const params = {
...info,
......@@ -648,10 +633,18 @@ const newCreateSqlDialogInfo = ref({
tableChName: tableDataInfo.value[0].tableChName,
foundMode: route.query.foundMode,
isDraft: 'N',
databaseGuid: route.query.databaseGuid || '',
database: route.query.database || '',
databaseChName: route.query.databaseChName || '',
};
try {
await saveOrUpdate(params, 2);
newCreateSqlDialogInfo.value.submitBtnLoading = false;
newCreateSqlDialogInfo.value.visible = false;
newCreateSqlDialogInfo.value.visible = false;
} catch (error) {
newCreateSqlDialogInfo.value.submitBtnLoading = false;
}
}
}
})
......@@ -691,7 +684,7 @@ const inputLengthKeyUp = (regexp, scope, field, max: any = null, min: any = null
width: '100%',
'max-height': 'calc(100% - 16px)',
display: 'inline-block',
}">
}" v-loading="tableFieldsLoading">
<!-- 表名称列 -->
<el-table-column prop="tableName" label="表名称" width="180">
<template #header>
......@@ -932,7 +925,7 @@ const inputLengthKeyUp = (regexp, scope, field, max: any = null, min: any = null
<template v-else>
<el-button @click="previousStep">上一步</el-button>
<el-button type="primary" @click="submitAsDraft">保存为草稿</el-button>
<el-button type="primary" @click="submit">提交</el-button>
<el-button type="primary" @click="submit" v-loading="saveBtn">提交</el-button>
</template>
</div>
<Dialog_form :dialogConfigInfo="newCreateSqlDialogInfo" />
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!