UNPKG

w-vue-middle

Version:

统一公共服务组件

277 lines (270 loc) 6.67 kB
/* * @Author: Jason Liu * @Date: 2022-11-29 16:07:48 * @Desc: */ import draggable from 'vuedraggable'; const $datadevelopment = require('w-vue-middle/api/datadevelopment/standardModel'); const joinDesign = require('../joinDesign').default; export default { components: { draggable, joinDesign }, name: 'relationshipDesign', props: { value: { type: Array, default: () => { return []; }, }, isSub: { type: Boolean, default: false, }, tables: { type: Array, default: () => { return []; }, }, filters: { type: Array, default: () => { return []; }, }, sqlScript: { type: Array, default: () => { return []; }, }, parentNode: { //上级 type: Object, }, modelInfo: { type: Object, default: () => { return { id: undefined, code: undefined, name: undefined, desc: undefined, nickName: undefined, categoryId: undefined, //分类ID topicId: undefined, type: undefined, //类型 0 规范建模 1 维度建模 isPublic: 0, taskType: 'STREAMING', sourceDbId: undefined, //数据源ID sourceDbSchemaName: undefined, //SchemaName sourceType: 1, //来源类型 1 标准规范 2 数据源采集 }; }, }, }, data() { return { dataInfo: this.modelInfo, relationList: this.value, linkTable: undefined, setjoin: false, leftTable: { id: undefined, name: undefined, columns: [], }, //来源表 rightTable: { id: undefined, name: undefined, columns: undefined, }, // isNew: false, //是否添加关联 changeIndex: undefined, //修改关联的索引 option: { sourceId: undefined, //来源ID targetId: undefined, //目标ID joinType: undefined, //关联类型 type: undefined, //关联的方式 关系配置方式:0 SQL自定配置模式:1 conditions: undefined, sqlStr: undefined, }, //关联关系 joinKey: 1, }; }, created() {}, methods: { /** * @Author: Jason Liu * @description: 拷贝完成事件 */ changeEntry(evt, i) { if (evt.added) { let table = { ...evt.added.element, _X_ROW_CHILD: undefined, _X_ROW_KEY: undefined, joins: [], }; this.setjoin = true; this.leftTable = this.tables.find((t) => { return t.id == this.relationList[i].id; }); this.rightTable = table; this.linkTable = table; this.isNew = true; this.changeIndex = i; this.option = { sourceId: undefined, //来源ID targetId: undefined, //目标ID joinType: 'leftjoin', //关联类型 type: 0, //关联的方式 关系配置方式:0 SQL自定配置模式:1 conditions: [ { left: { columnName: undefined, //关联的字段名称 }, order: 0, relation: '=', //= > < >= <= != right: { columnName: undefined, }, }, ], sqlStr: undefined, }; } }, /** * @Author: Jason Liu * @description: 修改关联事件 */ changeJoin(config) { if (config.added || config.join || config.delete || config.filter) { this.$emit('change', config, this.relationList); } else { this.$emit( 'change', { added: { element: config, }, }, this.relationList, ); } }, /** * @Author: Jason Liu * @description: 显示表格明细信息 */ showTables(item) { this.$emit('click', item); }, /** * @Author: Jason Liu * @description: 转换表格 */ convertTable(item) { this.$emit('convert', item); }, /** * @Author: Jason Liu * @description: 设置过滤条件 */ setFilter() { this.$emit( 'change', { filters: { element: true, }, }, this.relationList, ); }, /** * @Author: Jason Liu * @description: 关联表格 */ joinTable(config) { this.$emit( 'change', { join: { element: config, }, }, this.relationList, ); if (config.isNew) { this.relationList[this.changeIndex].joins.push({ ...config.target, option: config.option, joins: [], }); } else { this.relationList[this.changeIndex].option = config.option; } this.joinKey++; }, /** * @Author: Jason Liu * @description: 显示关联 */ viewJoin(item, i) { this.changeIndex = i; this.leftTable = this.tables.find((t) => { return t.id == this.parentNode.id; }); this.rightTable = this.tables.find((t) => { return t.id == item.id; }); this.isNew = false; this.option = item.option; this.setjoin = true; }, /** * @Author: Jason Liu * @description: 删除 */ deleteTable(item, i) { this.$confirm({ title: $t('确定要将【{slot1}】删除吗?', { slot1: item.name }), content: $t('请谨慎操作,删除后会印象到相关的配置功能'), okText: $t('确定'), cancelText: $t('取消'), onOk: () => { let relation = this.relationList[i]; this.relationList.splice(i, 1); this.$emit( 'change', { delete: { element: relation, }, }, this.relationList, ); }, onCancel() {}, }); }, }, watch: { value(val) { this.relationList = val; }, relationList(val) { this.$emit('input', val); }, setjoin(val) { if (!val) { this.linkTable = undefined; } }, modelInfo(val) { this.dataInfo = val; }, }, };