UNPKG

w-vue-middle

Version:

统一公共服务组件

146 lines (140 loc) 3.5 kB
/* * @Author: Jason Liu * @Date: 2023-11-29 13:37:07 * @Desc: */ /** * @Author: Jason Liu * @description: 数据集成服务 */ const { saveKafkaDebugContent, getKafkaDebugContent, getV3TemplateList, } = require('w-vue-middle/api/dataIntegration'); const { wXmlEditor, wJsonEditor } = require('w-vue-middle/codeEditor'); export default { components: { wXmlEditor, wJsonEditor }, props: { value: { type: String, default: () => { return undefined; }, }, jobData: { type: Object, default: () => { return { id: undefined, jobType: undefined, jsonDetail: undefined, }; }, }, }, watch: { value(val) { this.content = val; }, content(val) { this.$emit('input', val); }, jobData(val) { this.nodeData = val; this.getStatic(); }, }, data() { return { publicVersion: '6.0.2401', nodeData: this.jobData, stepData: { ip: undefined, modelType: 'json', sourceId: undefined, sourceType: undefined, }, isView: false, //是否显示 content: undefined, //kafka XML静态调试脚本 loading: false, }; }, created() { this.getStatic(); }, methods: { /** * @Author: Jason Liu * @description: 保存静态消息 */ save() { this.loading = true; saveKafkaDebugContent({ content: this.content, jobId: this.nodeData.id, }) .then(() => { this.$message.success($t('消息内容保存成功!')); }) .finally(() => { this.loading = false; }); }, /** * @Author: Jason Liu * @description: 获取消息 */ getContentMasage() { if (this.isView && this.stepData.templateKey) { this.loading = true; //获取静态消息 const getContent = getKafkaDebugContent({ jobId: this.nodeData.id }); //获取模版 const getTemplate = getV3TemplateList({ pageNum: 1, pageSize: 1, queryParams: { F_v3Key_eq: this.stepData.templateKey }, }); Promise.all([getContent, getTemplate]) .then((reqs) => { if (reqs[0].data && reqs[0].data.content) { this.content = reqs[0].data.content; } else if (reqs[1].data && reqs[1].data) { this.content = reqs[1].data[0].requestTemplate; } }) .finally(() => { this.loading = false; }); } }, /** * @Author: Jason Liu * @description: 获取状态 */ getStatic() { if (this.nodeData.jsonDetail) { let has = false; this.nodeData.jsonDetail.steps.forEach((step) => { const { data } = step; if (data.type == 'KafaInputs') { this.stepData = { ip: data.ip, modelType: data.modelType || 'json', sourceId: data.sourceId, templateKey: data.templateKey, sourceType: data.sourceType, }; has = true; return false; } }); this.isView = has; this.getContentMasage(); } else { this.isView = false; } }, }, };