UNPKG

w-vue-middle

Version:

统一公共服务组件

191 lines (182 loc) 4.87 kB
/* * @Author: Jason Liu * @Date: 2023-05-04 14:33:45 * @Desc: */ //数据源选择 const dataSourcesSelection = require('../dataSourcesSelection').default; //schema选择 const dataSchemaSelection = require('../dataSchemaSelection').default; const dataTableSelection = require('../dataTableSelection').default; //输出映射设置 const tableOutputMap = require('../tableOutputMap').default; export default { components: { dataSourcesSelection, dataSchemaSelection, dataTableSelection, tableOutputMap }, props: { value: { type: Object, }, referData: { type: Object, default: () => { return undefined; }, }, getSource: { type: Function, default: () => { return false; }, }, job: { type: Object, default: () => { return undefined; }, }, }, data() { return { nodeData: this.value, loading: false, tables: [], //表格列表 columns: [], setMap: false, //设置关联 sourceColumns: [], kafkaTables: [], }; }, created() { this.getSourceColumns(); }, methods: { /** * @Author: Jason Liu * @description: 设置默认map信息 * @return {*} */ setDefautlMap(e) { let mapping = this.nodeData.mapping; this.nodeData.mapping = this.nodeData.columns.map((column) => { let original = mapping.find((chen) => { if (chen.target.columnName) { if (chen.target.tableAsName) { return ( chen.target.columnName.toLocaleLowerCase() == column.columnName.toLocaleLowerCase() && chen.target.tableAsName.toLocaleLowerCase() == column.tableAsName.toLocaleLowerCase() ); } else { return ( chen.target.columnName.toLocaleLowerCase() == column.columnName.toLocaleLowerCase() ); } } else { return false; } }); let source = { pk: false, columnName: undefined, select: undefined, type: 'fun', columnType: undefined, description: undefined, columnTypeFlink: undefined, lockType: false, }; if (original) { return { target: column, source: { ...source, ...original.source, }, }; } else { return { target: column, source: { ...source, }, }; } }); }, /** * @Author: Jason Liu * @description: 获取来源列表 */ getSourceColumns(isSend = false) { if (this.nodeData.tableName) { this.loading = true; let source = this.getSource(); if (source && source.length > 0) { let node = source[0].data; this.nodeData.sourceNodeType = node.type; this.sourceColumns = node.columns.filter((col) => { col.tableAsName = col.tableAsName || col.tableName || node.asName || node.tableName; return !col.notuse; }); } else if (isSend) { this.$message.warning($t('请指定来源输入信息')); } } setTimeout(() => { this.setDefautlMap(); this.loading = false; }, 300); }, /** * @Author: Jason Liu * @description: 修改数据源事件 */ changeNodeData(value) { this.$emit('change', this.nodeData); }, /** * @Author: Jason Liu * @description: 修改Mapping事件 */ changeMappingData() { //由于组件是拷贝对象处理,故需要将数据传递到上层 this.nodeData.mapping.forEach((map) => { //主键同步 this.nodeData.columns.forEach((column) => { if ( map.target.tableAsName == column.tableAsName && map.target.columnName == column.columnName ) { column.pk = map.target.pk; } }); }); this.$emit('input', this.nodeData); this.changeNodeData(); }, /** * @Author: Jason Liu * @description: 修改schema事件 */ changeSchema() { this.changeNodeData(); }, /** * @Author: Jason Liu * @description: 刷新表格事件 */ changeTableData() { this.getSourceColumns(); this.changeNodeData(); }, }, watch: { value(value) { this.nodeData = value; }, nodeData() { this.$emit('input', this.nodeData); }, }, };