w-vue-middle
Version:
统一公共服务组件
249 lines (239 loc) • 7.09 kB
JavaScript
/*
* @Author: Jason Liu
* @Date: 2023-08-10 14:10:36
* @Desc:
*/
/**
* @Author: Jason Liu
* @description: 调度服务接口
*/
const $dispatchcenter = require('w-vue-middle/api/dispatchcenter');
/**
* @Author: Jason Liu
* @description: 数据集成服务
*/
const $dataIntegration = require('w-vue-middle/api/dataIntegration');
const config = require('../../config');
export default {
components: {},
props: {
value: {
type: Object,
default: () => {
return {
id: undefined,
data: {
id: undefined,
jobType: undefined,
jobGroupId: undefined,
},
};
},
},
},
data() {
return {
loading: false,
control_str: undefined,
controlsJobList: [],
controlKey: 0,
debuggerProcess: { show: false },
};
},
created() {
this.getControlsList();
},
methods: {
/**
* @Author: Jason Liu
* @description: 获取按钮组
*/
getControlsList() {},
/**
* @Author: Jason Liu
* @description: 开始拖动事件
*/
startDrag(e) {
if (this.debuggerProcess.show) {
this.$message.warning({
content: $t('调试状态,不可添加组件'),
key: 'startDrag',
});
return;
}
let job = this.value;
let target = e.target.dataset;
let info = undefined;
const getDrag = (list) => {
list.forEach((item) => {
if (item.children && item.children.length > 0) {
getDrag(item.children);
} else if (item.id == target.id) {
info = item;
}
});
};
getDrag(this.controlsJobList);
if (info) {
let node = {};
switch (target.type) {
case 'SubJob':
case 'SubTransform':
case 'IntegrationJob':
node = {
shape: 'custom-input',
label: info.name,
data: {
id: undefined,
name: info.name,
code: undefined,
type: info.type, //组件类型
jobId: info.id == target.type ? undefined : info.id, //子任务ID
jobName: info.id == target.type ? undefined : info.name, //子任务名称
clusterId: undefined, //集群ID
timeout: 1, //超时时间
timeoutUnit: 'h', //超时类型 秒:s 分:m 时:h
steps: [], //子任务相关节点概览信息
hops: [], //子任务连线概览
schema: 'public',
lookUp: false,
sourceType: 0, //数据来源 0:子集 1:公共
description: undefined,
},
};
break;
case 'Start':
case 'End':
node = {
shape: 'custom-rect',
label: info.name,
data: {
id: undefined,
name: info.name,
code: undefined,
type: info.type, //组件类型
description: undefined,
},
};
break;
default:
node = {
shape: 'custom-input',
label: info.name,
data: info,
};
break;
}
job.dnd.start(job.graph.createNode(node), e);
}
},
/**
* @Author: Jason Liu
* @description: 加载子数据内容
*/
loadToolChildrenMethod({ row }) {
return new Promise((resolve) => {
switch (row.key) {
case 'basic':
resolve(config.basic);
break;
case 'conversioncomponent':
resolve(config.conversioncomponent);
break;
case 'inputcomponent':
resolve(config.inputcomponent);
break;
case 'outputcomponent':
resolve(config.outputcomponent);
break;
case 'flow':
$dispatchcenter
.getJobInfo({
pageNum: 1,
pageSize: 1000000,
queryParams: {
F_isDel_eq: 0,
F_jobType_eq: 'transfer',
F_scheduleType_eq: 'CRON',
},
})
.then((req) => {
const childs = req.data.map((item) => {
item.id = item.jobInfoId;
item.name = item.jobDesc;
item.type = 'IntegrationJob';
return item;
});
// if (childs.length == 0) {
// row.hasChild = false;
// }
this.integrationJobList = childs;
resolve(childs);
});
break;
default:
let parentId = this.activeJob.id;
if (parentId.indexOf('new') > -1 || this.activeJob.data.jobType == 'flow') {
parentId = undefined;
resolve([]);
} else {
$dataIntegration
.getJobList({
pageNum: 1,
pageSize: 1000000,
queryParams: {
F_isDel_eq: 0,
F_jobType_eq: row.id,
F_parentId_eq: parentId,
},
})
.then((req) => {
const childs = req.data.map((item) => {
item.name = item.jobName;
item.type = row.type == 'job' ? 'SubJob' : 'SubTransform';
return item;
});
// if (childs.length == 0) {
// row.hasChild = false;
// }
resolve(childs);
})
.catch(() => {
//row.hasChild = false;
resolve([]);
});
break;
}
}
}).finally(() => {
this.controlKey++;
});
},
/**
* @Author: Jason Liu
* @description: 查询控件列表
*/
searchControlsList() {
const xTable = this.$refs.controlsJobList;
const column = xTable.getColumnByField('title');
// 修改第二个选项为勾选状态
const option = column.filters[0];
option.data = this.control_str;
option.checked = !!this.control_str;
// 修改条件之后,需要手动调用 updateData 处理表格数据
xTable.updateData();
},
/**
* @Author: Jason Liu
* @description: 查询设置
*/
filterName({ option, row }) {
return row.name.indexOf(option.data) > -1;
},
},
watch: {
'value.data.jonty'(val) {
this.getControlsList();
},
},
};