From 86a6a25bf35ac5d377b38c6b2a04dbb534e945e7 Mon Sep 17 00:00:00 2001
From: caorui <3165079241@qq.com>
Date: Fri, 1 Aug 2025 14:59:22 +0800
Subject: [PATCH] =?UTF-8?q?=E5=9C=BA=E6=99=AF=E4=B8=AD=E5=BF=83=E4=BB=A3?=
=?UTF-8?q?=E7=A0=81=E8=BF=AD=E4=BB=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/views/LinkUp/compoment/EditorItem.vue | 415 ++++++++++++++++++
src/views/LinkUp/compoment/addDialogChunk.vue | 397 ++++++++++-------
.../LinkUp/compoment/viewDialogChunk.vue | 384 +++++++++++++---
3 files changed, 975 insertions(+), 221 deletions(-)
create mode 100644 src/views/LinkUp/compoment/EditorItem.vue
diff --git a/src/views/LinkUp/compoment/EditorItem.vue b/src/views/LinkUp/compoment/EditorItem.vue
new file mode 100644
index 0000000..83145d3
--- /dev/null
+++ b/src/views/LinkUp/compoment/EditorItem.vue
@@ -0,0 +1,415 @@
+
+
+
+
+
+
+
+
diff --git a/src/views/LinkUp/compoment/addDialogChunk.vue b/src/views/LinkUp/compoment/addDialogChunk.vue
index b0c6036..1529379 100644
--- a/src/views/LinkUp/compoment/addDialogChunk.vue
+++ b/src/views/LinkUp/compoment/addDialogChunk.vue
@@ -575,6 +575,35 @@
+
+
+ 总记录
+ {{
+ OperationRecords.total ? OperationRecords.total : 0
+ }}
+
+
+ 运行成功
+ {{
+ OperationRecords.success ? OperationRecords.success : 0
+ }}
+
+
+ 运行失败
+
+ {{
+ OperationRecords.error ? OperationRecords.error : 0
+ }}
+
+
+
+
+
+ {{ item.accountName }}
+
+
+
+ 验证成功
+
+
+ 验证失败
+
+
+ 未验证
+
+
+
+
@@ -529,8 +614,9 @@ import FishCrontab from "fish-crontab";
import * as echarts from "echarts";
import { authApi } from "@/api/apis/auth";
import baseForm from "@/components/base/baseNewForm";
+import EditorItem from "./EditorItem.vue";
export default {
- components: { FishCrontab, baseRightDialog, baseForm },
+ components: { FishCrontab, baseRightDialog, baseForm, EditorItem },
data() {
return {
examineOperateDialog: false,
@@ -617,6 +703,19 @@ export default {
rowNum: "1",
pageLimit: "100",
},
+
+ parameterType: "body", //参数类型
+
+ editorRefs: {}, // 用来保存所有子组件的 editor DOM
+
+ // 运行记录
+ OperationRecords: {
+ total: 0,
+ success: 0,
+ error: 0,
+ },
+ OperationRecordsIndex: 2,
+ RelatedAccounts: [], //场景下关联的所有账户
};
},
methods: {
@@ -638,6 +737,7 @@ export default {
}
this.formRowData = formRow;
this.$refs.senceForm.choiceAssignment(formRow);
+ await this.GetSceneLog7Days();
await this.GetSceneStepList();
});
},
@@ -713,8 +813,14 @@ export default {
// 更新当前选中的步骤索引
this.currentRowData = rowData;
this.drawSelectIndex = index;
+ // 用来保存所有子组件的 editor DOM
+ this.editorRefs = {};
+ this.parameterType = "body";
this.GetSceneStepData();
},
+ registerEditorRef(refName, dom) {
+ this.$set(this.editorRefs, refName, dom);
+ },
/**
* 获取场景步骤数据
*/
@@ -759,10 +865,52 @@ export default {
) {
this.queryColumns();
}
+ // 非数据库应用
+ if (
+ this.currentRowData.options.apiId &&
+ this.currentRowData.options.appType != "9"
+ ) {
+ this.queryApiConfig();
+ }
});
}
}
},
+ switchTabs(val) {
+ this.parameterType = val;
+ // 非数据库应用
+ if (this.currentRowData.options.appType != "9") {
+ this.queryApiConfig("tab");
+ }
+ },
+ // 获取表字段
+ async queryApiConfig(type) {
+ if (!this.currentRowData.options.apiId) {
+ return;
+ }
+ this.outsideColumns = [];
+ let params = {
+ stepId: this.currentRowData.options.stepID, //账户id
+ apiId: this.currentRowData.options.apiId,
+ type: this.parameterType,
+ };
+ let res = await authApi(
+ "sysFlowStepApiConfigService",
+ "",
+ "queryApiConfig",
+ "",
+ params
+ );
+ this.drawMask = false;
+ if (res.status == "200") {
+ this.outsideColumns = res.attribute || [];
+ this.$nextTick(() => {
+ if (type == "tab") {
+ this.getStepConfig();
+ }
+ });
+ }
+ },
// 获取表字段
async queryColumns() {
this.outsideColumns = [];
@@ -802,15 +950,29 @@ export default {
params
);
if (res.status == "200") {
- const root = document.querySelector("#editorContainer");
+ let detailList = [];
if (
- res.attribute &&
- res.attribute.detailList &&
- res.attribute.detailList.length > 0
+ this.currentRowData.options.appType &&
+ this.currentRowData.options.appType == "9"
) {
- res.attribute.detailList.forEach((item) => {
- this.matchEditorItems(root, item.fieldName, item.html_label);
- });
+ detailList = res.attribute?.detailList || [];
+ } else {
+ if (this.parameterType == "body") {
+ detailList = res.attribute?.bodyIn
+ ? JSON.parse(res.attribute.bodyIn)
+ : [];
+ } else if (this.parameterType == "header") {
+ detailList = res.attribute?.headerIn
+ ? JSON.parse(res.attribute.headerIn)
+ : [];
+ } else if (this.parameterType == "query") {
+ detailList = res.attribute?.queryIn
+ ? JSON.parse(res.attribute.queryIn)
+ : [];
+ }
+ }
+ if (detailList.length > 0) {
+ this.recursivelyApplyHtmlLabel(this.outsideColumns, detailList);
}
if (
this.currentRowData.options &&
@@ -822,16 +984,93 @@ export default {
}
}
},
- matchEditorItems(rootElement, rootName, rootHtml) {
- const items = rootElement.querySelectorAll(".editorItem");
- items.forEach((item) => {
- const fieldName =
- item.querySelector(".el-form-item__label")?.innerText.trim() || "";
- const editor = item.querySelector(".content-editor");
- if (!editor) return;
- if (rootName == fieldName) {
- editor.innerHTML = rootHtml;
+ // 匹配数据
+ recursivelyApplyHtmlLabel(columns, detailList, path = []) {
+ columns.forEach((col, index) => {
+ const match = detailList.find(
+ (item) => item.fieldName === col.column_name
+ );
+ if (match && match.html_label) {
+ this.matchEditorItems(match, index, path);
}
+ if (
+ col.children &&
+ col.children.length > 0 &&
+ match.children &&
+ match.children.length > 0
+ ) {
+ this.recursivelyApplyHtmlLabel(col.children, match.children, [
+ ...path,
+ index,
+ ]);
+ }
+ });
+ },
+ // 回显
+ matchEditorItems(match, index, path = []) {
+ const refName =
+ "contentEditor" + match.fieldName + [...path, index].join("-");
+ // 这里获取ref
+ const refEl = this.editorRefs[refName];
+ if (match && match.html_label && refEl) {
+ // 可能refEl是数组,取第一个元素
+ if (Array.isArray(refEl)) {
+ refEl[0].innerHTML = match.html_label;
+ } else if (refEl instanceof HTMLElement) {
+ refEl.innerHTML = match.html_label;
+ }
+ }
+ },
+ // 场景记录改变
+ RecordsChange(type) {
+ this.OperationRecordsIndex = type;
+ },
+ // 获取最近7天运行统计
+ async GetSceneLog7Days() {
+ // let params = {
+ // sceneID: this.sceneID,
+ // isSuccess: this.flagRecordsIndex,
+ // };
+ // if (this.flagRecordsIndex == 2) {
+ // params.isSuccess = "";
+ // }
+ // let res = await GetSceneLog7Days(params);
+ // if (res.code == 1) {
+ let data = [];
+ let xData = [];
+ let yData = [];
+ data.forEach((item) => {
+ xData.push(item.column1);
+ yData.push(item.allCount);
+ });
+ this.renderChart(yData, xData);
+ // }
+ },
+ renderChart(data = [], xData = []) {
+ const option = {
+ tooltip: {
+ trigger: "axis",
+ },
+ xAxis: {
+ type: "category",
+ data: xData,
+ },
+ yAxis: {
+ type: "value",
+ },
+ series: [
+ {
+ name: "",
+ type: "line",
+ data: data,
+ },
+ ],
+ };
+ this.$nextTick(() => {
+ const chartContainer = document.getElementById("overProjectChart");
+ const chart = echarts.init(chartContainer);
+ this.chartData = chart;
+ chart.setOption(option);
});
},
// 发布场景
@@ -1762,4 +2001,39 @@ export default {
::v-deep .el-form-item {
margin-bottom: 0;
}
+
+.tabs {
+ display: flex;
+ align-items: center;
+ height: 32px;
+ background: #fff;
+ border-radius: 4px;
+ padding: 2px;
+ width: fit-content;
+ margin: 10px 0;
+
+ .tabsItem {
+ height: 28px;
+ line-height: 28px;
+ background: #fff;
+ border-radius: 3px;
+ font-size: 14px;
+ color: #999;
+ padding: 0 10px;
+ cursor: pointer;
+ }
+
+ .active {
+ background: #f5f5f5;
+ color: #333;
+ }
+}
+::v-deep .el-collapse-item__header {
+ padding-left: 10px !important;
+}
+.pie {
+ height: 300px;
+ padding-bottom: 10px;
+}
+