edae90ba by xukangle

Merge branch 'dev_20241202_xukangle' into develop

2 parents f9a212b4 7196c065
......@@ -130,7 +130,7 @@ export const getTenantAttach = (params) => request({
/** 获取cron表达式最近五次执行时间 */
export const getCronExecTime = (cronExpress) => request({
url: `${import.meta.env.VITE_APP_API_BASEURL}/common/get-recently-time?cronExpress=${cronExpress}`,
url: `${import.meta.env.VITE_APP_PLAN_BASEURL}/common/get-recently-time?cronExpress=${cronExpress}`,
method: 'get'
})
......
......@@ -31,6 +31,7 @@ import { TableColumnWidth } from "@/utils/enum";
import router from "@/router";
import { download } from "@/utils/common";
import { getLabelList } from "@/api/modules/dataLabel";
import { de } from "element-plus/es/locale";
const currentPath = ref<string[]>([]);
const currentDatabasePath = ref<string[]>([]);
......@@ -531,7 +532,7 @@ const dataBaseTableInfo = ref({
},
{
label: "编辑表结构", value: "edit", click: (scope) => {
console.log('复制', scope);
console.log('编辑表结构', scope);
// foundMode 1 已有表新建 2 根据文件新建
if (scope.row.foundMode === 1) {
// 已有表新建编辑 editOpt 代表时编辑
......
......@@ -156,13 +156,15 @@ const batchDelete = () => {
};
// 暂存编辑的行数据
const tempRowData = ref<any>();
const tempRowData = ref<any>([]);
// 编辑行
const editRow = (row) => {
console.log('编辑:', row);
// 暂存编辑前的数据
tempRowData.value = { ...row };
// 暂存编辑前的数据 用于取消编辑时恢复原始数据,先判断是否已经暂存过tempRowData通过fieldGuid
if (!tempRowData.value.find((item) => item.fieldGuid === row.fieldGuid)) {
tempRowData.value.push({ ...row });
}
if (row.fieldLengthCondition) {
const arr = row.fieldLengthCondition.split('#')
row.lengthSymbol = arr[0]
......@@ -280,13 +282,13 @@ const saveData = async () => {
fieldPrecision: item.fieldPrecision,
dictionaryGuid: item.dictionaryGuid,
isUnique: item.isUnique,
isNotNull: item.isRequired,
notNull: item.notNull,
fieldValueRange: item.fieldValueRange
}
inParams.push(obj)
})
console.log('finalParams', inParams)
// console.log('finalParams', inParams)
const res: any = await saveBizRuleConfig(inParams)
if (res.code === proxy.$passCode) {
loading.value = false
......@@ -316,8 +318,9 @@ const cancel = () => {
// 点击取消
const cancelEdit = (row) => {
console.log('取消编辑:', row);
// 可在此恢复原始数据逻辑,如果需要
Object.assign(row, tempRowData.value);
// 可在此恢复原始数据逻辑,要查找暂存的数据 tempRowData 中 fieldGuid 与当前行的 fieldGuid 相同的数据
const tempRow = tempRowData.value.find((item) => item.fieldGuid === row.fieldGuid);
Object.assign(row, tempRow);
row.isEdit = false; // 退出编辑状态
}
......
......@@ -22,6 +22,7 @@ import {
import existingTableSelect from "./existingTableSelect.vue";
import useUserStore from "@/store/modules/user";
/** 草稿中未建表时就可以编辑表相关信息。如果建表之后就只能编辑字段。 不能修改字段英文名称,数据库修改英文名就相当于删除再添加。都可以直接跳转到*/
const { proxy } = getCurrentInstance() as any;
......@@ -142,6 +143,7 @@ const editRow = (row) => {
if (refGradeGuid.value) {
getGradeList({ classifyGradeGuid: refGradeGuid.value.refGradeGuid, pageIndex: 1, pageSize: -1 }).then((res: any) => {
if (res.code === proxy.$passCode) {
gradeInfo.value = res.data.records || [];
row.gradeOptions = res.data.records || [];
} else {
ElMessage.error(res.msg);
......@@ -153,8 +155,9 @@ const editRow = (row) => {
row.isEdit = true
}
const handleGradeChange = (row) => {
console.log('分级改变', row)
const gradeOptions = row.gradeOptions || [];
const matchedItem = gradeOptions.find((item) => item.guid === row.gradeDetailGuid);
if (matchedItem) {
......@@ -266,29 +269,59 @@ const getNextTableInfo = async (params) => {
}
};
const handleClassifyChange = (row, value) => {
console.log('分类改变', row, value)
if (!row.classifyDetailGuid) {
row.gradeGuid = null;
row.gradeOptions = [];
return;
// 查找目标节点的路径
const findDDatabasePath = (data: any[], targetGuid: string, path: string[] = [], route: string[] = []) => {
for (const item of data) {
path.push(item.classifyName); // 添加当前节点名称
route.push(item.classifyDetailGuid);
if (item.classifyDetailGuid === targetGuid) {
return {
path,
route
}; // 找到目标节点,返回路径
}
refGradeGuid.value = findRefGradeGuid(treeSelectOptions.value, row.classifyDetailGuid);
console.log('refGradeGuid', refGradeGuid.value)
row.classifyDetailName = refGradeGuid.value.classifyName;
getGradeList({ classifyGradeGuid: refGradeGuid.value.refGradeGuid, pageIndex: 1, pageSize: -1 }).then((res: any) => {
if (res.code === proxy.$passCode) {
row.gradeOptions = res.data.records || [];
} else {
ElMessage.error(res.msg);
if (item.children && item.children.length > 0) {
const result = findDDatabasePath(item.children, targetGuid, path, route);
if (result) return result; // 子节点找到目标节点,返回路径
}
});
path.pop(); // 回溯,移除当前节点
route.pop();
}
return null; // 未找到目标节点
};
// 存储分级数据
const gradeInfo = ref<any>();
const handleClassifyChange = (row, value) => {
const pathInfo = findDDatabasePath(treeSelectOptions.value, value)
row.classifyDetailNameRoutes = pathInfo.path;
row.classifyDetailGuidRoutes = pathInfo.route;
// if (!row.classifyDetailGuid) {
// row.gradeGuid = null;
// row.gradeOptions = [];
// return;
// }
// refGradeGuid.value = findRefGradeGuid(treeSelectOptions.value, row.classifyDetailGuid);
// row.classifyDetailName = refGradeGuid.value.classifyName;
// getGradeList({ classifyGradeGuid: refGradeGuid.value.refGradeGuid, pageIndex: 1, pageSize: -1 }).then((res: any) => {
// if (res.code === proxy.$passCode) {
// row.gradeOptions = res.data.records || [];
// } else {
// ElMessage.error(res.msg);
// }
// });
};
const handleNodeClick = (row, node, data) => {
// 在gradeInfo找到item.guid === row.gradeGuid
const matchedItem = gradeInfo.value.find((item) => item.guid === node.gradeGuid);
if (matchedItem) {
row.gradeDetailGuid = matchedItem.guid;
row.gradeDetailName = matchedItem.name;
}
}
const isPrevious = ref(false);
/** 上一步 */
const previousStep = () => {
......@@ -320,7 +353,7 @@ const editableFields = {
classifyDetailGuid: true, // 分类可编辑
fieldType: true, // 字段类型可编辑
fieldChName: true, // 字段中文名可编辑
sourceFieldChName: true, // 源字段中文名可编辑
}
const tableFieldsLoading = ref(false)
......@@ -401,18 +434,29 @@ const addRow = () => {
tableDataDetailInfo.value.push({
id: tableDataDetailInfo.value.length + 1,
fieldName: '',
fieldEnglish: '',
fieldChName: '',
fieldType: '',
length: '',
fieldPrecision: '',
isUnique: '',
isRequired: '',
fieldValueRange: '',
dictionaryGuid: '',
isEdit: true,
gradeOptions: [],
sourceDatabase: '',
sourceTableName: '',
sourceFieldName: '',
sourceFieldChName: '',
fieldLength: '',
isPrimary: '',
notNull: '',
isFk: '',
classifyDetailGuid: '',
classifyDetailName: '',
gradeDetailGuid: '',
gradeDetailName: '',
classifyDetailNameRoutes: [],
classifyDetailGuidRoutes: [],
})
}
......@@ -502,8 +546,6 @@ const submitAsDraft = async () => {
if (!editInfoData.value.guid) {
try {
await saveOrUpdate({
tableName: tableDataInfo.value[0].tableName,
tableChName: tableDataInfo.value[0].tableChName,
databaseGuid: route.query.databaseGuid || '',
database: route.query.database || '',
databaseChName: route.query.databaseChName || '',
......@@ -519,8 +561,6 @@ const submitAsDraft = async () => {
try {
await saveOrUpdate({
guid: editInfoData.value.guid,
tableName: tableDataInfo.value[0].tableName,
tableChName: tableDataInfo.value[0].tableChName,
databaseGuid: editInfoData.value.databaseGuid || '',
database: editInfoData.value.database || '',
databaseChName: editInfoData.value.databaseChName || '',
......@@ -598,7 +638,7 @@ const checkTableData = (tableDataDetailInfo) => {
// 校验主键字段
if (field.isPrimary === 'Y') {
hasPrimary = true;
if (field.isNotNull !== 'Y') {
if (field.notNull !== 'Y') {
ElMessage.error(`第 ${index} 个字段为主键,应设置为必填!`);
return false;
}
......@@ -625,48 +665,43 @@ const checkTableData = (tableDataDetailInfo) => {
const saveBtn = ref(false)
const submit = async () => {
console.log('提交', tableDataDetailInfo.value, tableDataInfo.value)
saveBtn.value = true
// 校验表格数据是否填写完整
// if (!checkTableData(tableDataDetailInfo.value)) {
// saveBtn.value = false
// return
// }
// // 如果提交时没有 guid 则为新增type 0,否则为修改 type 1, 也要传参
// if (!editInfoData.value.guid) {
// try {
// await saveOrUpdate({
// 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',
// }, 0)
// saveBtn.value = false
// } catch (error) {
// saveBtn.value = false
// }
// } else {
// // 修改 saveOrUpdate({}, 1)
// try {
// await saveOrUpdate({
// guid: editInfoData.value.guid,
// tableName: tableDataInfo.value[0].tableName,
// tableChName: tableDataInfo.value[0].tableChName,
// databaseGuid: editInfoData.value.databaseGuid || '',
// database: editInfoData.value.database || '',
// databaseChName: editInfoData.value.databaseChName || '',
// foundMode: editInfoData.value.foundMode,
// isDraft: 'N',
// tableGuid: route.query.tableGuid,
// }, 1)
// saveBtn.value = false
// } catch (error) {
// saveBtn.value = false
// }
// }
if (!checkTableData(tableDataDetailInfo.value)) {
saveBtn.value = false
return
}
// 如果提交时没有 guid 则为新增type 0,否则为修改 type 1, 也要传参
if (!editInfoData.value.guid) {
try {
await saveOrUpdate({
databaseGuid: route.query.databaseGuid || '',
database: route.query.database || '',
databaseChName: route.query.databaseChName || '',
foundMode: route.query.foundMode,
isDraft: 'N',
}, 0)
saveBtn.value = false
} catch (error) {
saveBtn.value = false
}
} else {
// 修改 saveOrUpdate({}, 1)
try {
await saveOrUpdate({
guid: editInfoData.value.guid,
databaseGuid: editInfoData.value.databaseGuid || '',
database: editInfoData.value.database || '',
databaseChName: editInfoData.value.databaseChName || '',
foundMode: editInfoData.value.foundMode,
isDraft: 'N',
tableGuid: route.query.tableGuid,
}, 1)
saveBtn.value = false
} catch (error) {
saveBtn.value = false
}
}
}
......@@ -675,29 +710,29 @@ const saveOrUpdate = async (params: any = {}, type) => {
// 要对tableDataDetailInfo.value 进行处理,将其转换为后台需要的格式
let TepmTableDataDetailInfo = tableDataDetailInfo.value.map(item => {
return {
classifyDetailGuid: item.classifyDetailGuid,
classifyDetailName: item.classifyDetailName,
database: item.database || editInfoData.value.database,
databaseChName: item.databaseChName || editInfoData.value.databaseChName,
databaseGuid: item.databaseGuid || editInfoData.value.databaseGuid,
dictionaryGuid: item.dictionaryGuid,
dimGuid: item.dimGuid,
fieldChName: item.fieldChName,
guid: item.guid,
sourceTableName: item.sourceTableName,
sourceDatabase: item.sourceDatabase,
sourceFieldName: item.sourceFieldName,
sourceFieldChName: item.sourceFieldChName,
fieldGuid: item.fieldGuid,
fieldLength: item.fieldLength,
fieldName: item.fieldName,
fieldPrecision: item.fieldPrecision,
fieldChName: item.fieldChName,
fieldType: item.fieldType,
gradeDetailGuid: item.gradeDetailGuid,
gradeDetailName: item.gradeDetailName,
guid: item.guid,
fieldLength: item.fieldLength,
fieldPrecision: item.fieldPrecision,
dimGuid: item.dimGuid,
dictionaryGuid: item.dictionaryGuid,
sortValue: item.sortValue,
isFk: item.isFk,
isNotNull: item.isNotNull,
notNull: item.notNull,
isPrimary: item.isPrimary,
sortValue: item.sortValue,
tableChName: tableDataInfo.value[0].tableChName,
tableGuid: route.query.tableGuid || '',
tableName: tableDataInfo.value[0].tableName,
classifyDetailGuid: item.classifyDetailGuid,
classifyDetailName: item.classifyDetailName,
gradeDetailGuid: item.gradeDetailGuid,
gradeDetailName: item.gradeDetailName,
classifyDetailNameRoutes: item.classifyDetailNameRoutes,
classifyDetailGuidRoutes: item.classifyDetailGuidRoutes,
}
})
const InParams = {
......@@ -705,8 +740,9 @@ const saveOrUpdate = async (params: any = {}, type) => {
cgDirName: '',
dirGuid: '',
tableGuid: '',
tableName: '',
tableChName: '',
tableName: tableDataInfo.value[0].tableName,
tableChName: tableDataInfo.value[0].tableChName,
description: tableDataInfo.value[0].description,
databaseGuid: '',
database: '',
databaseChName: '',
......@@ -715,6 +751,7 @@ const saveOrUpdate = async (params: any = {}, type) => {
fieldRQVOList: TepmTableDataDetailInfo
}
const finalParams = { ...InParams, ...params }
console.log('finalParams', finalParams)
// 使用switch case 语句
switch (type) {
case 0:
......@@ -818,8 +855,6 @@ const newCreateSqlDialogInfo = ref({
newCreateSqlDialogInfo.value.submitBtnLoading = true;
const params = {
...info,
tableName: tableDataInfo.value[0].tableName,
tableChName: tableDataInfo.value[0].tableChName,
foundMode: route.query.foundMode,
isDraft: 'N',
databaseGuid: route.query.databaseGuid || '',
......@@ -887,7 +922,8 @@ onActivated(() => {
</div>
<existingTableSelect v-show="stepsInfo.step === 0" :databaseList="databaseList" :table-create-type="2"
:execGuid="execGuid" @datasource-selected-change="handlDsSelectedChange"></existingTableSelect>
<div class="second-step-content" v-show="stepsInfo.step === 1">
<div class="second-step-content" v-show="stepsInfo.step === 1"
:style="`height: ${route.query.editOpt === '1' ? '100%' : 'calc(100% - 80px)'}`">
<div class="table_panel_wrap">
<el-table :data="tableDataInfo" :highlight-current-row="true" stripe border height="100%" row-key="guid"
tooltip-effect="light" :style="{
......@@ -996,7 +1032,7 @@ onActivated(() => {
</template>
</el-table-column>
<!-- 源字段英文 -->
<el-table-column prop="sourceFieldChName" label="源字段英文" width="150" show-overflow-tooltip>
<el-table-column prop="sourceFieldChName" label="源字段英文" width="120" show-overflow-tooltip>
<template #default="scope">
<!-- {{ scope.row.sourceFieldName ? scope.row.sourceFieldName : '--' }} -->
......@@ -1006,7 +1042,7 @@ onActivated(() => {
</template>
</el-table-column>
<!-- 源端字段 fieldType fieldTypeProps-->
<el-table-column prop="fieldType" label="源端字段类型" width="150">
<el-table-column prop="fieldType" label="源端字段类型" width="120">
<template #default="scope">
<div v-if="scope.row.isEdit">
<el-select v-model="scope.row.fieldType" placeholder="选择类型" clearable filterable
......@@ -1022,7 +1058,7 @@ onActivated(() => {
</el-table-column>
<!-- 长度(可编辑) -->
<el-table-column prop="fieldLength" label="长度" width="120" align="left">
<el-table-column prop="fieldLength" label="长度" width="100" align="left">
<template #default="scope">
<!-- 非编辑状态 -->
<span v-if="!scope.row.isEdit">
......@@ -1040,7 +1076,7 @@ onActivated(() => {
</el-table-column>
<!-- 精度(可编辑) -->
<el-table-column prop="fieldPrecision" label="精度" width="120" align="left">
<el-table-column prop="fieldPrecision" label="精度" width="100" align="left">
<template #default="scope">
<!-- 非编辑状态 -->
<span v-if="!scope.row.isEdit">
......@@ -1055,7 +1091,7 @@ onActivated(() => {
</template>
</el-table-column>
<!-- 关联字典(可编辑)el-tree-select 形式下拉形式 -->
<el-table-column prop="dictionaryGuid" label="关联字典" width="150" align="left">
<el-table-column prop="dictionaryGuid" label="关联字典" width="120" align="left">
<template #default="scope">
<span v-if="!scope.row.isEdit">{{ scope.row.dictionaryGuid
? dictionaryList.find((item: any) => item.guid === scope.row.dictionaryGuid)?.chName : '--' }}</span>
......@@ -1067,7 +1103,7 @@ onActivated(() => {
</el-table-column>
<!-- 数据是否唯一(可编辑) -->
<el-table-column prop="isPrimary" label="是否主键" width="150" align="left">
<el-table-column prop="isPrimary" label="是否主键" width="100" align="left">
<template #default="scope">
<span v-if="!scope.row.isEdit || !editableFields.isPrimary">{{ scope.row.isPrimary ?
(scope.row.isPrimary ===
......@@ -1079,7 +1115,7 @@ onActivated(() => {
</template>
</el-table-column>
<!-- 是否必填(可编辑) -->
<el-table-column prop="notNull" label="是否必填" width="120" align="left">
<el-table-column prop="notNull" label="是否必填" width="100" align="left">
<template #default="scope">
<span v-if="!scope.row.isEdit">{{ scope.row.notNull ? (scope.row.notNull ===
'Y' ? '是' : '否') : '--' }}</span>
......@@ -1092,23 +1128,25 @@ onActivated(() => {
<!-- 分类(不可编辑)classifyName -->
<el-table-column prop="classifyDetailGuid" label="分类" width="150">
<el-table-column prop="classifyDetailNameRoutes" label="分类" width="150" show-overflow-tooltip>
<template #default="scope">
<!-- 如果当前行是编辑状态,显示 tree-select -->
<div v-if="scope.row.isEdit">
<el-tree-select v-model="scope.row.classifyDetailGuid" :data="treeSelectOptions"
:props="treeSelectProps" placeholder="请选择分类" clearable filterable
@change="(value) => handleClassifyChange(scope.row, value)">
@change="(value) => handleClassifyChange(scope.row, value)"
@node-click="(node, data) => handleNodeClick(scope.row, node, data)">
</el-tree-select>
</div>
<!-- 否则直接显示分类名称 -->
<div v-else>
{{ scope.row.classifyDetailName || '--' }}
{{ Array.isArray(scope.row?.classifyDetailNameRoutes) ? scope.row.classifyDetailNameRoutes.join('/') :
'--' }}
</div>
</template>
</el-table-column>
<!-- 分级(不可编辑) -->
<el-table-column prop="gradeDetailGuid" label="分级" width="120" align="left">
<el-table-column prop="gradeDetailGuid" label="分级" width="100" align="left">
<template #default="scope">
<div v-if="scope.row.isEdit">
<el-select v-model="scope.row.gradeDetailGuid" placeholder="请选择分级" clearable filterable
......@@ -1172,7 +1210,7 @@ onActivated(() => {
}
.second-step-content {
height: calc(100% - 80px);
width: 100%;
padding: 16px;
......
......@@ -153,36 +153,96 @@ const treeSelectProps = {
};
const treeSelectOptions = ref<any>([]);
const getFieldTree = () => {
getTaskExeTreeList({ execGuid: execGuid.value }).then((res: any) => {
if (res.code == proxy.$passCode) {
// 存储引用分级的guid
const gradeGuidInfo = ref('');
const getFieldTree = async () => {
// getTaskExeTreeList({ execGuid: execGuid.value }).then((res: any) => {
// if (res.code == proxy.$passCode) {
// treeSelectOptions.value = res.data || [];
// gradeGuidInfo.value = res.data[0].refGradeGuid;
// } else {
// ElMessage.error(res.msg);
// }
// }).catch(() => {
// ElMessage.error('获取分类树形数据失败');
// })
const res: any = await getTaskExeTreeList({ execGuid: execGuid.value });
if (res.code === proxy.$passCode) {
treeSelectOptions.value = res.data || [];
gradeGuidInfo.value = res.data[0].refGradeGuid;
} else {
ElMessage.error(res.msg);
}
}).catch(() => {
ElMessage.error('获取分类树形数据失败');
})
}
// 查找目标节点的路径
const findDDatabasePath = (data: any[], targetGuid: string, path: string[] = [], route: string[] = []) => {
for (const item of data) {
path.push(item.classifyName); // 添加当前节点名称
route.push(item.classifyDetailGuid);
if (item.classifyDetailGuid === targetGuid) {
return {
path,
route
}; // 找到目标节点,返回路径
}
if (item.children && item.children.length > 0) {
const result = findDDatabasePath(item.children, targetGuid, path, route);
if (result) return result; // 子节点找到目标节点,返回路径
}
path.pop(); // 回溯,移除当前节点
route.pop();
}
return null; // 未找到目标节点
};
const gradeInfo = ref<any>();
const handleClassifyChange = (row, value) => {
const pathInfo = findDDatabasePath(treeSelectOptions.value, value)
row.classifyDetailNameRoutes = pathInfo.path;
row.classifyDetailGuidRoutes = pathInfo.route;
// 查找选中的节点
const selectedNode = getTreeNode(treeSelectOptions.value, value);
// const selectedNode = getTreeNode(treeSelectOptions.value, value);
// if (selectedNode) {
// getGradeList({ classifyGradeGuid: selectedNode.refGradeGuid, pageIndex: 1, pageSize: -1 }).then((res: any) => {
// if (res.code === proxy.$passCode) {
// gradeInfo.value = res.data.records || [];
// row.gradeOptions = res.data.records || [];
// } else {
// ElMessage.error(res.msg);
// }
// });
// row.classifyDetailName = selectedNode.classifyName;
// } else {
// console.error("未找到对应的节点");
// row.classifyDetailName = ""; // 重置分类名
// }
};
if (selectedNode) {
getGradeList({ classifyGradeGuid: selectedNode.refGradeGuid, pageIndex: 1, pageSize: -1 }).then((res: any) => {
const gradeOptions = ref<any>()
// 获取分级
const getGrade = async () => {
const res: any = await getGradeList({ classifyGradeGuid: gradeGuidInfo.value, pageIndex: 1, pageSize: -1 });
if (res.code === proxy.$passCode) {
row.gradeOptions = res.data.records || [];
gradeInfo.value = res.data.records || [];
gradeOptions.value = res.data.records || [];
} else {
ElMessage.error(res.msg);
}
});
console.log("选中的节点信息:", selectedNode);
row.classifyDetailName = selectedNode.classifyName; // 假设树节点的 `label` 是分类名
} else {
console.error("未找到对应的节点");
row.classifyDetailName = ""; // 重置分类名
}
const handleNodeClick = (row, node, data) => {
setTimeout(() => {
// 在gradeInfo找到item.guid === row.gradeGuid
const matchedItem = gradeInfo.value.find((item) => item.guid === node.gradeGuid);
if (matchedItem) {
row.gradeDetailGuid = matchedItem.guid;
row.gradeDetailName = matchedItem.name;
}
};
}, 300);
}
const getTreeNode = (tree, value) => {
for (const node of tree) {
if (node.classifyDetailGuid === value) {
......@@ -198,8 +258,7 @@ const getTreeNode = (tree, value) => {
const handleGradeChange = (row) => {
console.log('分级改变', row)
const gradeOptions = row.gradeOptions || [];
const matchedItem = gradeOptions.find((item) => item.guid === row.gradeDetailGuid);
const matchedItem = gradeOptions.value.find((item) => item.guid === row.gradeDetailGuid);
if (matchedItem) {
row.gradeDetailName = matchedItem.name;
}
......@@ -212,7 +271,7 @@ const gradeSelectProps = {
}
const nextStep = () => {
uploadFileRef.value.fileFormRef.ruleFormRef.validate((valid) => {
uploadFileRef.value.fileFormRef.ruleFormRef.validate(async (valid) => {
if (valid) {
if (!fileTableFields.value.length) {
ElMessage({
......@@ -241,7 +300,8 @@ const nextStep = () => {
if (!tableCreateInfo.value.tableFields.length) {
getSubjectField();
}
getFieldTree();
await getFieldTree();
await getGrade();
}
});
};
......@@ -1304,30 +1364,32 @@ const saveTable = async () => {
ElMessage.error(`第 ${index} 个字段的字段类型为浮点符型时,长度不能为空`);
return;
}
console.log(field, '---------------------');
if (field.isPrimary === 'Y') {
hasPrimary = true;
if (field.notNull != 'Y') {
ElMessage.error(`第 ${field.orderNum} 个字段为主键,应设置为必填`);
ElMessage.error(`第 ${index} 个字段为主键,应设置为必填`);
return;
}
if (field.dataType == 'text') {
ElMessage.error(`第 ${field.orderNum} 个字段为主键,字段类型不能设置为‘大字段型’`);
ElMessage.error(`第 ${index} 个字段为主键,字段类型不能设置为‘大字段型’`);
return;
}
if (field.dataType == 'json') {
ElMessage.error(`第 ${field.orderNum} 个字段为主键,字段类型不能设置为‘JSON类型’`);
ElMessage.error(`第 ${index} 个字段为主键,字段类型不能设置为‘JSON类型’`);
return;
}
if (field.dataType == 'bit') {
ElMessage.error(`第 ${field.orderNum} 个字段为主键,字段类型不能设置为‘布尔类型’`);
return;
}
} else {
if (!field.aggWay && isSumModel) {
ElMessage.error(`聚合模型的非主键字段必须设置聚合方式!`);
ElMessage.error(`第 ${index} 个字段为主键,字段类型不能设置为‘布尔类型’`);
return;
}
}
// } else {
// if (!field.aggWay && isSumModel) {
// ElMessage.error(`聚合模型的非主键字段必须设置聚合方式!`);
// return;
// }
// }
if (tableCreateInfo.value.isSync == 'Y' && field.notNull == 'Y' && !field.fileFieldName && (field.defaultValue === "" || field.defaultValue == null)) {
ElMessage.error(`第 ${index} 个字段为必填且建表勾选同步数据时,文件字段名和默认值不能同时为空`);
return;
......@@ -1397,7 +1459,7 @@ const saveTable = async () => {
gradeDetailName: item.gradeDetailName,
guid: item.guid,
isFk: item.isFk,
isNotNull: item.isNotNull,
notNull: item.isNotNull,
isPrimary: item.isPrimary,
sortValue: item.sortValue,
tableChName: addInfo.chName,
......@@ -1415,6 +1477,7 @@ const saveTable = async () => {
databaseGuid: route.query.databaseGuid || '',
database: route.query.database || '',
databaseChName: addInfo.databaseChName,
description: addInfo.description,
foundMode: 2,
isDraft: 'N',
fieldRQVOList: TepmTableDataDetailInfo
......@@ -1538,6 +1601,7 @@ const saveDraftTable = async () => {
databaseGuid: route.query.databaseGuid || '',
database: route.query.database || '',
databaseChName: addInfo.databaseChName,
description: addInfo.description,
foundMode: 2,
isDraft: 'Y',
fieldRQVOList: TepmTableDataDetailInfo
......@@ -1955,18 +2019,33 @@ const tableSelectFields = computed(() => {
</template>
</el-table-column>
<!-- 分类 -->
<el-table-column prop="classifyDetailGuid" label="分类" width="120px" align="center" show-overflow-tooltip>
<!-- <el-table-column prop="classifyDetailGuid" label="分类" width="120px" align="center" show-overflow-tooltip>
<template #default="scope">
<!-- 如果当前行是编辑状态,显示 tree-select -->
<div v-if="scope.row.isEdit">
<el-tree-select v-if="scope.row['isEdit']" v-model="scope.row['classifyDetailGuid']" placeholder="请选择"
:data="treeSelectOptions" :props="treeSelectProps" clearable filterable
@change="(value) => handleClassifyChange(scope.row, value)">
</el-tree-select>
</div>
<!-- 显示treeSelectOptions classifyDetailGuid所在itemclassifyName-->
<div v-else>{{ scope.row.classifyDetailName || '--' }}</div>
</template>
</el-table-column> -->
<el-table-column prop="classifyDetailNameRoutes" label="分类" width="150" show-overflow-tooltip>
<template #default="scope">
<!-- 如果当前行是编辑状态,显示 tree-select -->
<div v-if="scope.row.isEdit">
<el-tree-select v-if="scope.row['isEdit']" v-model="scope.row['classifyDetailGuid']"
:data="treeSelectOptions" :props="treeSelectProps" placeholder="请选择分类" clearable filterable
@change="(value) => handleClassifyChange(scope.row, value)"
@node-click="(node, data) => handleNodeClick(scope.row, node, data)">
</el-tree-select>
</div>
<!-- 否则直接显示分类名称 -->
<div v-else>
{{ Array.isArray(scope.row?.classifyDetailNameRoutes) ? scope.row.classifyDetailNameRoutes.join('/') :
'--' }}
</div>
</template>
</el-table-column>
<!-- 分级 -->
......@@ -1975,7 +2054,7 @@ const tableSelectFields = computed(() => {
<div v-if="scope.row.isEdit">
<el-select v-if="scope.row['isEdit']" v-model="scope.row['gradeDetailGuid']" placeholder="请选择分级"
clearable filterable :props="gradeSelectProps" @change="handleGradeChange(scope.row)">
<el-option v-for="(item, index) in scope.row.gradeOptions || []" :key="index" :label="item.name"
<el-option v-for="(item, index) in gradeOptions || []" :key="index" :label="item.name"
:value="item.guid"></el-option>
</el-select>
</div>
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!