w-vue-middle
Version:
统一公共服务组件
1,153 lines (1,113 loc) • 32 kB
JavaScript
/*
* @Author: Jason Liu
* @Date: 2022-11-24 10:00:26
* @Desc: 规范模型设计服务
*/
import draggable from 'vuedraggable';
import jsonView from 'vue-json-views';
//设计表格控件
const designTables = require('./designTables').default;
//表格关系配置控件
const relationshipDesign = require('./relationshipDesign').default;
//复合字段设置
const compoundFields = require('./compoundFields').default;
//过滤条件设置
const conditionalFilters = require('./conditionalFilters').default;
//追加脚本
const compoundSqlScript = require('./compoundSqlScript').default;
//字段设置
const fieldSettings = require('./fieldSettings').default;
//模型预览
const modelPreview = require('./modelPreview').default;
//设置联合信息
const unionDesign = require('./unionDesign').default;
/**
* @Author: Jason Liu
* @description: 表格明细信息
*/
const tableDetail = require('./tableDetail').default;
/**
* @Author: Jason Liu
* @description: 表转换
*/
const convertTable = require('./convertTable').default;
const $datadevelopmentmain = require('w-vue-middle/api/datadevelopment');
const $datadevelopment = require('w-vue-middle/api/datadevelopment/standardModel');
const glSqlEditor = require('w-vue-middle/components/glSqlEditor').default;
const debugDesign = require('w-vue-middle/components/debugDesign').default;
const newField = {
id: undefined, //数据ID
pk: false,
code: undefined, //显示编码名字
columnName: undefined, //物理字段名,不可修改
columnAccuracy: 0, //精度
columnSize: 42, //长度
columnType: 'S', //列类型枚举
name: undefined, //字段名称
notNull: true, //是否为空
defaultValucone: null, //默认值
description: undefined, //字段描述
autoincrement: null, //自动递增
rule: null, //规则
type: '2',
//冗余数据
dataElementCode: undefined, //元数据代码
dataSystemCode: null, //系统代码
defineCode: null, //自定义代码
dictionaryId: null, //字典ID
metaModelId: null,
parentId: undefined, //上级ID
position: undefined, //位置
sortNumber: 0, //排序
tableName: null,
status: 1,
valueDomainCode: null,
options: [],
};
const newModel = {
modelInfo: {
id: undefined,
code: 'fct_',
name: undefined,
desc: undefined,
nickName: undefined,
categoryId: undefined, //分类ID
topicId: undefined,
type: 0, //类型 0 规范建模 1 维度建模
isPublic: 0,
taskType: 'STREAMING',
sourceDbId: undefined, //数据源ID
sourceDbSchemaName: undefined, //SchemaName
sourceType: 1, //来源类型 1 标准规范 2 数据源采集
remark: undefined, //描述信息
unionType: 'union', //联合类型
},
tables: [],
joins: [],
filters: [],
sqlScripts: [],
unions: {
fields: [],
models: [],
},
};
export default {
name: 'standardModelDesign',
components: {
draggable,
designTables,
relationshipDesign,
tableDetail,
compoundFields,
conditionalFilters,
compoundSqlScript,
glSqlEditor,
fieldSettings,
modelPreview,
debugDesign,
jsonView,
unionDesign,
convertTable,
},
props: {
value: {
type: Boolean,
default: false,
},
dataId: {
type: [Number, String], //数据ID
default: undefined,
},
categoryId: {
type: [Number, String], //分类ID
default: undefined,
},
type: {
type: [Number, String], //类型
default: 0,
},
},
data() {
return {
loading: false,
show: this.value,
status: undefined, //设计状态 添加:add 关联:join
talbeKey: 0,
tabActive: 1,
relationList: [], //关联列表
cloneRow: {}, //克隆的数据
dataList: [], //数据列列表
previewLoading: false, //预览数据请求
tableInfo: {
show: false,
id: undefined,
table: undefined,
},
convertInfo: {
//转换表格
show: false,
id: undefined,
table: undefined,
},
fieldInfo: {
//设置的复合字段
show: false,
column: {
...newField,
},
},
showSetFilters: false, //显示过滤条件设置
setSQLScript: {
//追加sql脚本
show: false,
info: {
code: undefined,
name: undefined,
desc: undefined, //描述
fields: [], //关联字段
script: undefined, //脚本内容
},
},
labelCol: { span: 8 },
wrapperCol: { span: 16 },
rules: {
code: [{ required: true, message: $t('请输入模型代码'), trigger: 'blur' }],
name: [{ required: true, message: $t('请输入模型名称'), trigger: 'blur' }],
},
dataInfo: JSON.copyData(newModel),
sqlScript: {
//脚本信息
calcEngine: undefined,
createTable: undefined,
},
dimensionList: [],
debugShow: false, //调试
showSetUnion: false, //设置联合
isShowUnionSelect: false, //是否显示设置联合字段
unionFields: [], //选择联合字段
models: [], //联合模型
newUnionModel: JSON.copyData(newModel), //
activeModel: JSON.copyData(newModel), //选中模型
activatId: undefined,
showConfig: false,
viewConfig: {},
viewPager: {
pageNum: 1,
pageSize: 30,
},
designkey: 0,
isChangeCode: false, //是否修改了编码
};
},
methods: {
/**
* @Author: Jason Liu
* @description: 发布
*/
releaseThis() {
this.loading = true;
$datadevelopment
.publishStandardModel(this.dataInfo.modelInfo)
.then((req) => {
if (req.data.isSucccess) {
this.dataInfo.modelInfo.isPublic = 1;
this.$emit('change');
this.$message.success($t('模型发布成功!'));
} else {
this.$message.error(req.data.publicErrorStage);
}
})
.finally(() => {
this.loading = false;
});
},
/**
* @Author: Jason Liu
* @description: 查看配置
*/
viewCode() {
this.showConfig = true;
this.viewConfig = {
...this.dataInfo.modelInfo,
filters: this.dataInfo.filters,
joins: this.dataInfo.joins,
map: {},
sqlScripts: this.dataInfo.sqlScripts,
tables: this.dataInfo.tables,
unions: {
fields: this.unionFields,
models: this.models,
},
};
},
/**
* @Author: Jason Liu
* @description: 保存当前页面数据内容
*/
saveThis() {
//TODO:必须有主键效验
//TODO:字段编码不可以重复
//TODO:维度模型,是否维度不能有2个
this.$refs.ruleForm.validate((valid) => {
if (valid) {
let model = {
...this.dataInfo.modelInfo,
filters: JSON.stringify(this.dataInfo.filters || '[]'),
joins: JSON.stringify(this.dataInfo.joins || '[]'),
map: {},
sqlScripts: JSON.stringify(this.dataInfo.sqlScripts || '[]'),
tables: JSON.stringify(this.dataInfo.tables || '[]'),
unions: JSON.stringify({
fields: this.unionFields,
models: this.models,
}),
};
if (model.tables.length > 0) {
console.log(this.dataInfo.tables);
let pass = true;
let columnmaps = {}; //编码映射
this.dataInfo.tables.forEach((table) => {
table.columns.forEach((column, i) => {
if (columnmaps[column.code]) {
pass = false;
this.$notification.warning({
message: $t('编码重复无法保存'),
key: 'eorr',
description: $t(
'{slot1}第[{slot2}]行的{slot3} 与 {slot4}第[{slot5}]行的{slot6} 的编码重复',
{
slot1: columnmaps[column.code].tableName,
slot2: columnmaps[column.code].index,
slot3: columnmaps[column.code].name,
slot4: table.name,
slot5: i + 1,
slot6: column.name,
},
),
});
} else {
columnmaps[column.code] = {
tableName: table.name,
index: i + 1,
name: column.name,
};
}
});
});
if (pass) {
this.loading = true;
$datadevelopment
.saveStandardModel(model)
.then((req) => {
this.setModelInfo(req.data);
this.$message.success($t('模型保存成功!'));
this.$emit('change');
})
.finally(() => {
this.loading = false;
});
}
} else {
this.$message.error($t('请至少选择配置一个主表信息!'));
}
}
});
},
/**
* @Author: Jason Liu
* @description: 搜索表信息
*/
searchTableInfo(val) {
if (this.$refs.fieldSettings) {
this.$refs.fieldSettings.search(val);
}
},
/**
* @Author: Jason Liu
* @description: 开始克隆事件
*/
cloneStart(e) {
if (this.relationList.length == 0) {
this.status = 'add';
} else {
this.status = 'join';
}
},
/**
* @Author: Jason Liu
* @description: 结束克隆事件
*/
cloneEnd(e) {
this.status = undefined;
this.$emit('end', e);
},
/**
* @Author: Jason Liu
* @description: 移动事件
*/
cloneMove(e) {
return true;
},
/**
* @Author: Jason Liu
* @description: 获取标准模型信息
* @return {*}
*/
getModelDetail(table) {
if (this.activeModel.modelInfo.sourceType == 2) {
return $datadevelopmentmain
.collectionDataInfo(
{
collectType: 'column', // 采集类型:schema、table、column
dsId: this.activeModel.modelInfo.sourceDbId,
schema: this.activeModel.modelInfo.sourceDbSchemaName,
tableName: table.code,
},
table,
)
.then((req) => {
return req.data;
});
} else {
return $datadevelopment.getModelDetail(table).then((req) => {
return req.data.semanticFieldMetadataVOList.map((item) => {
return {
...item,
columnName: item.code,
attr: 'S', //属性
dimkey: undefined, //维度key [模型id].[表id].[字段id]
dimName: undefined,
isdim: false, //是否维度key
type: '1',
visible: true,
};
});
});
}
},
/**
* @Author: Jason Liu
* @description: 拖动发生变化事件
*/
changeEntry(evt) {
if (evt.added) {
let table = {
...evt.added.element,
_X_ROW_CHILD: undefined,
_X_ROW_KEY: undefined,
};
let mess = this.$message.loading({
content: $t('数据解析中'),
duration: 0,
key: 'addTable',
});
if (!this.isChangeCode) {
this.dataInfo.modelInfo.code = `fct_${evt.added.element.code}`;
}
this.getModelDetail(table)
.then((req) => {
this.activeModel.tables.push({
...table,
tableId: table.id,
isMain: true, //主表
type: '1', //类型 引用:1 复合:2 自定义:3
columns: req,
});
//初始化关系配置内容
this.relationList.push({
...table,
option: {
sourceId: undefined, //来源ID
targetId: undefined, //目标ID
joinType: undefined, //关联类型
type: undefined, //关联的方式 关系配置方式:0 SQL自定配置模式:1
conditions: undefined,
sqlStr: undefined,
},
joins: [],
});
console.log(this.relationList);
})
.finally(() => {
mess();
});
}
//this.talbeKey++;
},
/**
* @Author: Jason Liu
* @description: 添加关联关系
*/
changeJoins(evt) {
this.designkey++;
if (evt.added) {
//添加表数据
let table = {
...evt.added.element,
_X_ROW_CHILD: undefined,
_X_ROW_KEY: undefined,
joins: [],
};
this.activeModel.tables.push(table);
} else if (evt.join) {
this.changeTable(evt.join.element.source); //来源表无论新增还是修改都出发修改事件
if (evt.join.element.isNew) {
//新增加的关联
this.activeModel.joins.push(evt.join.element.option);
this.activeModel.tables.push({
...evt.join.element.target,
isMain: false, //主表
tableId: evt.join.element.target.id,
type: '1', //类型 引用:1 复合:2 自定义:3
});
} else {
//更新关联数据
this.changeTable(evt.join.element.target); //触发目标表修改事件
//关联的修改
this.activeModel.joins = this.activeModel.joins.map((item) => {
if (
item.sourceId == evt.join.element.option.sourceId &&
item.targetId == evt.join.element.option.targetId
) {
item = evt.join.element.option;
}
return item;
});
}
} else if (evt.delete) {
//删除冗余关联
let joinindex = this.activeModel.joins.findIndex((item) => {
return (
item.sourceId == evt.delete.element.option.sourceId &&
item.targetId == evt.delete.element.option.targetId
);
});
this.activeModel.joins.splice(joinindex, 1);
let index = this.activeModel.tables.findIndex((tab) => {
return tab.id == evt.delete.element.id;
});
this.activeModel.tables.splice(index, 1);
let compoundTable = this.activeModel.tables.find((table) => {
return table.type == '2';
});
if (compoundTable) {
compoundTable.columns = compoundTable.columns.filter((com_col, i) => {
let pass = true;
com_col.options.forEach((option) => {
option.filters.forEach((fil) => {
if (fil.tableId == evt.delete.element.id) {
pass = false;
}
});
});
return pass;
});
if (compoundTable.columns.length == 0) {
this.activeModel.tables.splice(0, 1);
}
}
//过滤条件清空
this.activeModel.filters = [];
} else if (evt.filters) {
//设置过滤条件
this.showSetFilters = true;
} else if (evt.sqlscript) {
this.viewSQLScript(evt.sqlscript.element);
}
//this.talbeKey++;
},
/**
* @Author: Jason Liu
* @description: 显示聚合设置
*/
setFilter() {
this.showSetFilters = true;
},
/**
* @Author: Jason Liu
* @description: 修改脚本
*/
changeSqlScript(field) {
let script = this.activeModel.sqlScripts.find((item) => {
return item.fields.indexOf(field.id) > -1;
});
if (!script) {
script = {
id: undefined,
code: undefined,
name: undefined,
desc: undefined, //描述
fields: [field.id], //关联字段
script: undefined, //脚本内容
};
}
this.viewSQLScript(script);
},
/**
* @Author: Jason Liu
* @description: 查看sql脚本信息
*/
viewSQLScript(
script = {
id: undefined,
code: undefined,
name: undefined,
desc: undefined, //描述
fields: [], //关联字段
script: undefined, //脚本内容
},
) {
this.setSQLScript = {
show: true,
info: script,
};
},
/**
* @Author: Jason Liu
* @description: 删除事件
*/
deleteEntry() {},
/**
* @Author: Jason Liu
* @description: 切换主题事件
*/
clearSourceInfo() {
this.relationList = [];
this.activeModel.tables = [];
this.activeModel.joins = [];
this.activeModel.filters = [];
this.activeModel.sqlScripts = [];
this.sqlScript = {
//脚本信息
calcEngine: undefined,
createTable: undefined,
};
},
/**
* @Author: Jason Liu
* @description: 显示表格信息
*/
showTables(table) {
let stable = this.activeModel.tables.find((item) => {
return item.id == table.id;
});
this.tableInfo = {
show: true,
id: table.id,
table: stable,
};
},
/**
* @Author: Jason Liu
* @description: 转换表
*/
convertTable(table) {
let stable = this.activeModel.tables.find((item) => {
return item.id == table.id;
});
this.convertInfo = {
show: true,
id: table.id,
table: stable,
};
},
/**
* @Author: Jason Liu
* @description: 转换表确认事件
*/
convertTableInfo(e) {
this.activeModel.tables.forEach((table) => {
if (table.id == e.old.id) {
table.id = e.new.id;
table.code = e.new.code;
table.name = e.new.name;
table.tableId = e.new.code;
table.columns = table.columns.map((column) => {
column.parentId = table.id;
return column;
});
}
});
this.convertInfo.show = false;
this.parseRelationList();
this.talbeKey++;
},
/**
* @Author: Jason Liu
* @description: 修改表格信息
*/
changeTable(table) {
this.activeModel.tables = this.activeModel.tables.map((item) => {
if (item.id == table.id) {
item.columns = [...table.columns];
}
return item;
});
},
/**
* @Author: Jason Liu
* @description: 删除表格column信息
*/
deleteTableColumns(row) {
let iscompound = false;
this.activeModel.tables.forEach((item) => {
let index = item.columns.findIndex((col) => {
return col.id == row.id;
});
if (index >= 0) {
item.columns.splice(index, 1);
if (item.type == '2' && item.columns.length == 0) {
iscompound = true;
}
}
});
if (iscompound) {
this.activeModel.tables.splice(0, 1);
}
//this.talbeKey++;
},
/**
* @Author: Jason Liu
* @description: 显示复合字段
*/
viewCompoundField(row = undefined) {
if (this.activeModel.tables.length > 0) {
if (!row) {
row = {
...newField,
notNull: true,
visible: true,
id: `${new Date().getTime()}`,
options: [{ value: undefined, filters: [] }],
};
}
this.fieldInfo = {
show: true,
column: row,
};
} else {
this.$message.warning($t('请先设置主表信息!'));
}
},
/**
* @Author: Jason Liu
* @description: 修改复合字段
*/
changeCompoundFields(field) {
let compoundTable = this.activeModel.tables.find((table) => {
return table.type == '2';
});
if (!compoundTable) {
let id = `${new Date().getTime()}`;
compoundTable = {
id: id,
tableId: id,
name: $t('复合字段'),
isMain: false, //主表
type: '2', //类型 引用:1 复合:2 自定义:3
columns: [
{
...field,
attr: 'S', //属性
dimkey: undefined, //维度key [模型id].[表id].[字段id]
dimName: undefined,
isdim: false, //是否维度key
visible: true,
},
],
};
this.activeModel.tables.unshift(compoundTable);
} else {
let hass = false;
compoundTable.columns.forEach((col, i) => {
if (col.id == field.id) {
hass = true;
compoundTable.columns[i] = field;
}
});
if (!hass) {
compoundTable.columns.push(field);
}
}
this.talbeKey++;
},
/**
* @Author: Jason Liu
* @description: 修改追加脚本信息
*/
chaneSQLScript(sqlInfo) {
if (!sqlInfo.id) {
sqlInfo.id = `${new Date().getTime()}`;
}
let _scriptInfo = this.activeModel.sqlScripts.find((script) => {
return script.id == sqlInfo.id;
});
if (_scriptInfo) {
_scriptInfo = sqlInfo;
} else {
this.activeModel.sqlScripts.push(sqlInfo);
}
},
/**
* @Author: Jason Liu
* @description: 删除追加脚本
*/
deleteSQLScript(sqlInfo) {
let index = this.activeModel.sqlScripts.findIndex((script) => {
return script.id == sqlInfo.id;
});
this.activeModel.sqlScripts.splice(index, 1);
},
/**
* @Author: Jason Liu
* @description: 转换显示的表格信息
*/
parseRelationList() {
this.relationList = [];
//初始化关系配置内容
let table = this.activeModel.tables.find((item) => {
return item.isMain;
});
if (table) {
//获取关联的表格信息
const getJoinTable = (relation) => {
this.activeModel.joins.forEach((join) => {
if (join.sourceId == relation.tableId) {
let joinTable = this.activeModel.tables.find((item) => {
return item.tableId == join.targetId;
});
//关联表信息
let joinRelation = {
...joinTable,
option: {
sourceId: join.sourceId, //来源ID
targetId: join.targetId, //目标ID
joinType: join.joinType, //关联类型
type: join.type, //关联的方式 关系配置方式:0 SQL自定配置模式:1
conditions: join.conditions,
sqlStr: join.sqlStr,
},
joins: [],
};
getJoinTable(joinRelation);
relation.joins.push(joinRelation);
}
});
};
//主表信息
let mainRelation = {
...table,
option: {
sourceId: undefined, //来源ID
targetId: undefined, //目标ID
joinType: undefined, //关联类型
type: undefined, //关联的方式 关系配置方式:0 SQL自定配置模式:1
conditions: undefined,
sqlStr: undefined,
},
joins: [],
};
getJoinTable(mainRelation);
this.relationList.push(mainRelation);
console.log(this.relationList);
}
},
/**
* @Author: Jason Liu
* @description: 获取模型sql信息
*/
getStandardModelSQL(id) {
$datadevelopment.getStandardModelSQL({ id: id }).then((req) => {
this.sqlScript = {
//脚本信息
calcEngine: req[0].data,
createTable: req[1].data,
};
});
},
/**
* @Author: Jason Liu
* @description: 设置模型信息
*/
setModelInfo(data) {
let newInfo = {
//建模平细腻系
modelInfo: {
id: data.id,
code: data.code,
name: data.name,
desc: data.desc,
nickName: data.nickName,
categoryId: data.categoryId, //分类ID
topicId: data.topicId,
type: data.type,
isPublic: data.isPublic,
taskType: data.taskType || 'STREAMING',
sourceDbId: data.sourceDbId, //数据源ID
sourceDbSchemaName: data.sourceDbSchemaName, //SchemaName
sourceType: data.sourceType || 1, //来源类型 1 标准规范 2 数据源采集
remark: data.remark,
},
tables: JSON.parse(data.tables || '[]'),
joins: JSON.parse(data.joins || '[]'),
filters: JSON.parse(data.filters || '[]'),
sqlScripts: JSON.parse(data.sqlScripts || '[]'),
};
if (data.unions) {
let modelUnions = JSON.parse(data.unions);
this.models = modelUnions.models || []; //联合模型
this.unionFields = modelUnions.fields || [];
}
if (newInfo.tables) {
newInfo.tables = newInfo.tables.map((table) => {
table.visible = !!table.visible;
table.columns = table.columns.map((column) => {
column.visible = !!column.visible;
return column;
});
return table;
});
}
this.dataInfo = newInfo;
this.getActiveModel();
this.getStandardModelSQL(data.id);
},
/**
* @Author: Jason Liu
* @description: 获取模型详情
*/
getModelInfo() {
if (this.dataId) {
this.loading = true;
$datadevelopment
.getStandardModel({ id: this.dataId })
.then((req) => {
this.isChangeCode = true;
this.setModelInfo(req.data);
})
.finally(() => {
this.loading = false;
});
} else {
this.relationList = [];
this.sqlScript = {
//脚本信息
calcEngine: undefined,
createTable: undefined,
};
this.isChangeCode = false;
this.dataInfo = {
//建模平细腻系
modelInfo: {
id: undefined,
code: 'fct_',
name: undefined,
desc: undefined,
nickName: undefined,
categoryId: this.categoryId, //分类ID
topicId: undefined,
type: this.type,
isPublic: 0,
taskType: 'STREAMING',
sourceDbId: undefined, //数据源ID
sourceDbSchemaName: undefined, //SchemaName
sourceType: 1, //来源类型 1 标准规范 2 数据源采集
},
tables: [],
joins: [],
filters: [],
sqlScripts: [],
};
this.activeModel = this.dataInfo;
this.models = []; //联合模型
this.unionFields = [];
}
},
/**
* @Author: Jason Liu
* @description: 复制内容
*/
copyData(data) {
this.$copyClipboard(data);
},
/**
* @Author: Jason Liu
* @description: 获取维度列表
*/
getDimensionList() {
$datadevelopment.getAllDimModelKey().then((req) => {
this.dimensionList = req.data;
});
},
/**
* @Author: Jason Liu
* @description: 修改显示的字段事件
*/
changeViewField() {
if (this.$refs.previewList) {
this.$refs.previewList.resetColumn();
}
},
/**
* @Author: Jason Liu
* @description: 获取预览读取的数组字段列
*/
getExtColumns() {
let columns = [];
this.activeModel.tables.forEach((table) => {
table.columns.forEach((column) => {
if (column.visible) {
columns.push(column.code);
}
});
});
return columns;
},
/**
* @Author: Jason Liu
* @description: 预览建模数据
*/
previewDataList() {
let columns = this.getExtColumns();
if (columns.length > 0) {
this.previewLoading = true;
$datadevelopment
.previewModelDetail({
model: { id: this.activeModel.modelInfo.id },
queryParams: {
extColumns: columns.join(','), //显示的字段名 ‘,’分割
},
...this.viewPager,
})
.then((req) => {
this.dataList = req.data;
})
.finally(() => {
this.previewLoading = false;
});
} else {
this.$message.warning($t('请至少选择一个预览字段信息!'));
}
},
/**
* @Author: Jason Liu
* @description: 添加关联
*/
addSetUnion() {
this.showSetUnion = true; //设置联合
this.isChangeCode = true;
this.newUnionModel = {
//
modelInfo: {
id: `${new Date().getTime()}`,
code: 'fct_',
name: undefined,
desc: undefined,
nickName: undefined,
categoryId: undefined, //分类ID
topicId: undefined,
type: this.type, //类型 0 规范建模 1 维度建模
isPublic: 0,
taskType: 'STREAMING',
sourceDbId: undefined, //数据源ID
sourceDbSchemaName: undefined, //SchemaName
sourceType: 1, //来源类型 1 标准规范 2 数据源采集
remark: undefined, //描述信息
},
tables: [],
joins: [],
filters: [],
sqlScripts: [],
};
},
/**
* @Author: Jason Liu
* @description: 编辑关联内容
*/
editSetUnion(union) {
this.showSetUnion = true; //设置联合
this.newUnionModel = JSON.copyData(union);
},
/**
* @Author: Jason Liu
* @description: 确认添加
*/
callUnion() {
this.$refs.ruleUnion.validate((valid) => {
if (valid) {
this.analysisUnion();
this.showSetUnion = false;
}
});
},
/**
* @Author: Jason Liu
* @description: 解析关联
*/
analysisUnion() {
let tempUnion = JSON.copyData(this.newUnionModel);
let callUnionIndex = this.models.findIndex((model) => {
return model.modelInfo.id == tempUnion.modelInfo.id;
});
if (callUnionIndex > -1) {
this.models[callUnionIndex] = tempUnion;
} else {
this.models.push(tempUnion);
}
this.getActiveModel(tempUnion);
},
/**
* @Author: Jason Liu
* @description: 获取选中的模型
*/
getActiveModel(model) {
if (!model) {
model = this.dataInfo;
this.designkey++;
}
this.activatId = model.modelInfo.id;
this.activeModel = model;
this.parseRelationList();
},
/**
* @Author: Jason Liu
* @description: 删除联合
*/
deletUnions(index) {
this.models.splice(index, 1);
if (this.models.length == 0) {
this.unionFields = [];
} else {
this.unionFields = this.unionFields.map((field) => {
field.maps.splice(index, 1);
return field;
});
}
this.getActiveModel();
},
/**
* @Author: Jason Liu
* @description: 显示关联字段设置
*/
showUnionSelectDesign() {
this.isShowUnionSelect = true;
},
},
watch: {
value(val) {
this.show = val;
if (val) {
//this.getTopicCatalogList();
this.getModelInfo();
this.getDimensionList();
} else {
this.activeModel.modelInfo.topicId = undefined;
this.unions = []; //清除联合属性
this.tabActive = 1;
}
},
show(val) {
this.$emit('input', val);
},
},
};