ソースを参照

fixed: 替换老UI方法

liuyang 2 年 前
コミット
c2a5579da4

+ 24 - 0
src/api/flow.ts

@ -177,3 +177,27 @@ export function getLogicDetailById(id: any) {
177 177
  });
178 178
}
179 179
/** 接口end */
180
181
// 获取数据源列表
182
export function getSqlList() {
183
  return AIotRequest.get({
184
    url: flow.database
185
  });
186
}
187
188
// 获取域名列表接口
189
export function getFunctionList() {
190
  return AIotRequest.get({
191
    url: flow.getFunctionList
192
  });
193
}
194
195
// 测试接口
196
export function testLogic(data: any, id: any) {
197
  return AIotRequest.patch({
198
    url: `{flow.logicMgmt}/${id}`,
199
    data
200
  });
201
}
202
203
//

+ 3 - 3
src/views/_components/_flow/Index.vue

@ -145,14 +145,14 @@ function initGraph() {
145 145
          sourcePorts.filter((el) => el.id === sourcePort)?.[0].group ===
146 146
          'input'
147 147
        ) {
148
          // proxy.$utils.ipuMessage('不能从输入节点进行连线!', 'error')
148
          proxy.$message.error('不能从输入节点进行连线!');
149 149
          return false;
150 150
        }
151 151
        if (
152 152
          tartgetPorts.filter((el) => el.id === targetPort)?.[0].group ===
153 153
          'output'
154 154
        ) {
155
          // proxy.$utils.ipuMessage('不能连接输出节点!', 'error')
155
          proxy.$message.error('不能连接输出节点!');
156 156
          return false;
157 157
        }
158 158
        return true;
@ -163,7 +163,7 @@ function initGraph() {
163 163
        const connectionCount = magnet.getAttribute('connection-count');
164 164
        const max = connectionCount ? parseInt(connectionCount, 10) : 1;
165 165
        if (max === 0) {
166
          proxy.$utils.ipuMessage('请配置路由分发节点!', 'error');
166
          proxy.$message.error('请配置路由分发节点!');
167 167
        }
168 168
        const outgoingEdges = graph.value.getOutgoingEdges(cell);
169 169
        if (outgoingEdges) {

+ 0 - 101
src/views/_components/_flow/ToolBar.vue

@ -24,10 +24,6 @@
24 24
25 25
<script setup>
26 26
import { defineProps, ref, getCurrentInstance, onMounted } from 'vue';
27
// import { computed, defineProps, ref, getCurrentInstance, onMounted } from 'vue';
28
29
// import { useRoute } from 'vue-router';
30
// import NodeDataFormate from './nodeDataFormate.js';
31 27
32 28
const emits = defineEmits(['toolHandelClick']);
33 29
@ -44,108 +40,11 @@ defineProps({
44 40
const { proxy } = getCurrentInstance();
45 41
46 42
const targetNode = ref(null);
47
// const route = useRoute();
48
// const flowId = computed(() => route.query.id);
49
50
// const url = '';
51
52 43
// 点击事件
53 44
const handleClick = (name) => {
54 45
  emits('toolHandelClick', name);
55
  // const cells = props.graph.getSelectedCells();
56
  // console.log(cells);
57
58
  // switch (name) {
59
  //   case 'tool-undo':
60
  //     props.graph.history.undo();
61
  //     break;
62
  //   case 'tool-redo':
63
  //     props.graph.history.redo();
64
  //     break;
65
  //   case 'tool-copy':
66
  //     proxy.$utils.ipuMessage('已复制至剪切板!');
67
  //     if (cells.length) {
68
  //       props.graph.copy(cells);
69
  //     }
70
  //     break;
71
  //   case 'tool-cut':
72
  //     if (cells.length) {
73
  //       proxy.$utils.ipuMessage('已剪切至剪切板!');
74
  //       props.graph.cut(cells);
75
  //     }
76
  //     break;
77
  //   case 'tool-paste':
78
  //     if (!props.graph.isClipboardEmpty()) {
79
  //       const cells = props.graph.paste({ offset: 100 });
80
  //       props.graph.cleanSelection();
81
  //       props.graph.select(cells);
82
  //     }
83
  //     break;
84
  //   case 'tool-delete':
85
  //     if (cells.length) {
86
  //       props.graph.cut(cells);
87
  //       props.graph.cleanClipboard();
88
  //     }
89
  //     break;
90
  //   case 'tool-save':
91
  //     // eslint-disable-next-line no-use-before-define
92
  //     saveFlowData();
93
  //     break;
94
  //   case 'tool-send':
95
  //     // eslint-disable-next-line no-use-before-define
96
  //     publishFlow();
97
  //     break;
98
  //   case 'tool-var':
99
  //     proxy.$eBus.emit('open:right-panel');
100
  //     break;
101
  //   default:
102
  //     break;
103
  // }
104 46
};
105 47
106
// 获取所有节点信息
107
// function getNodesData() {
108
//   return NodeDataFormate.nodeDataFormate(props.graph);
109
// }
110
111
// 保存流程图
112
// async function saveFlowData() {
113
//   const databusData = JSON.parse(localStorage.getItem('panelGlobal')) || {};
114
//   const params = {
115
//     jsonData: JSON.stringify(props.graph),
116
//     databusData: JSON.stringify(databusData[flowId.value]),
117
//     stateValue: '1',
118
//     nodesData: getNodesData()
119
//   };
120
121
//   console.log(params);
122
//   await proxy.$reqPatch(`${url}/${flowId.value}`, params).then((res) => {
123
//     if (res.data.resultCode === '0') {
124
//       proxy.$utils.ipuMessage('流程保存成功!');
125
//     } else {
126
//       proxy.$utils.ipuMessage(res.data.resultMsg, 'error');
127
//     }
128
//   });
129
// }
130
// 发布逻辑流
131
// async function publishFlow() {
132
//   // const nodes = props.graph.getNodes()
133
//   const databusData = JSON.parse(localStorage.getItem('panelGlobal')) || {};
134
//   const params = {
135
//     jsonData: JSON.stringify(props.graph),
136
//     databusData: JSON.stringify(databusData[flowId.value]),
137
//     stateValue: '2',
138
//     nodesData: getNodesData()
139
//   };
140
//   await proxy.$reqPatch(`${url}/${flowId.value}`, params).then((res) => {
141
//     if (res.data.resultCode === '0') {
142
//       proxy.$utils.ipuMessage('流程发布成功!');
143
//     } else {
144
//       proxy.$utils.ipuMessage(res.data.resultMsg, 'error');
145
//     }
146
//   });
147
// }
148
149 48
onMounted(() => {
150 49
  proxy.$eBus.on('select-node', (data) => {
151 50
    targetNode.value = data;

+ 0 - 458
src/views/_components/_flow/flowHooks.js

@ -1,458 +0,0 @@
1
import { getCurrentInstance, ref } from 'vue';
2
import { Graph, Addon, Shape, Dom, Point } from '@antv/x6';
3
import { useStore } from 'vuex';
4
5
const { Dnd } = Addon;
6
7
export function useFlowHooks(flowId, container) {
8
  const store = useStore();
9
  const { proxy } = getCurrentInstance();
10
  const dnd = ref(null);
11
  const graph = ref(null);
12
  const graphData = ref(null);
13
  const curEdge = ref(null);
14
  const zoom = ref(1);
15
16
  function setGraphSize() {
17
    if (graph.value && container) {
18
      graph.value.resize(container.clientWidth, container.clientHeight);
19
      graph.value.centerContent();
20
    }
21
  }
22
  // 注册路由
23
  function registerRouter() {
24
    Graph.registerRouter('custom', (vertices, args, view) => {
25
      const start = view.sourceAnchor;
26
      const points = [];
27
      points.push(new Point(start.x + 48, start.y));
28
      points.push(
29
        new Point(
30
          view.targetBBox.leftMiddle.x - 20,
31
          view.targetBBox.leftMiddle.y
32
        )
33
      );
34
      return points;
35
    });
36
  }
37
  // 初始化形状
38
  function initGraphShape() {
39
    graph.value.fromJSON({});
40
    console.log(graphData.value);
41
    graph.value.fromJSON(graphData.value);
42
  }
43
  // 初始化dnd
44
  function initDnd() {
45
    return new Dnd({
46
      target: graph.value,
47
      scaled: false,
48
      animation: true,
49
      validateNode(droppingNode, options) {
50
        return droppingNode.shape === 'html'
51
          ? new Promise((resolve) => {
52
              const { draggingNode, draggingGraph } = options;
53
              const view = draggingGraph.findView(draggingNode);
54
              const contentElem = view.findOne('foreignObject > body > div');
55
              Dom.addClass(contentElem, 'validating');
56
              setTimeout(() => {
57
                Dom.removeClass(contentElem, 'validating');
58
                resolve(true);
59
              }, 3000);
60
            })
61
          : true;
62
      }
63
    });
64
  }
65
  // 初始化事件
66
  function initEvent(graph) {
67
    graph.on('edge:mouseenter', ({ cell }) => {
68
      if (cell) {
69
        let removeBtnCfg = {};
70
        if (cell.isEdge()) {
71
          removeBtnCfg = { distance: '30%' };
72
        }
73
        if (cell.isNode()) {
74
          const cellView = graph.value.findView(cell);
75
          cellView.addClass(`${cell.shape}-selected`);
76
          removeBtnCfg = { x: 0, y: 0, offset: { x: -5, y: -5 } };
77
        }
78
        cell.addTools({
79
          name: 'button-remove', // 工具名称
80
          args: removeBtnCfg // 工具对应的参数
81
        });
82
      }
83
    });
84
85
    graph.on('edge:mouseleave', ({ cell }) => {
86
      cell.removeTools();
87
    });
88
    graph.on('node:added', () => {
89
      store.commit('sceneFlow/setCurrentNodes', graph.getNodes());
90
    });
91
    // 双击节点,打开弹窗
92
    graph.on('node:dblclick', () => {
93
      const cells = graph.getSelectedCells();
94
      // const data = cells[0].store.data
95
      proxy.$eBus.emit('select:node', cells[0].store.data);
96
    });
97
    graph.on('node:mousedown', () => {});
98
    graph.on('node:selected', () => {
99
      // const data = cell.node.getData()
100
      // proxy.$eBus.emit('select-node', cell)
101
    });
102
    graph.on('cell:dblclick', (cell) => {
103
      proxy.$eBus.emit('select-node', cell);
104
    });
105
    graph.on('edge:click', (e, edge) => {
106
      /**
107
       * 判断连线的source cell,如果是route节点,则可以进行label的编辑与新增
108
       */
109
      // const data = cells[0].store.data
110
      // proxy.$eBus.emit('select:node', cells[0].store.data)
111
      console.log(e, edge);
112
    });
113
114
    graph.on('edge:contextmenu', ({ edge }) => {
115
      curEdge.value = edge;
116
      const curCell = edge.getSourceCell();
117
      console.log(curCell);
118
    });
119
    graph.on('node:changed', (e, node, view) => {
120
      // const cells = graph.getSelectedCells()
121
      // debugger
122
      // const data = cells[0].store.data
123
      console.log(node, view);
124
      proxy.$eBus.emit('change:node', e.cell.store.data);
125
    });
126
    // 单机选中节点,右键打开弹窗
127
    // graph.on('node:contextmenu', ({ e, x, y, cell, view }) => {
128
    graph.on('node:contextmenu', () => {
129
      // const data = cell.getData();
130
      // const data = cells[0].store.data
131
      // proxy.$eBus.emit('select:node', data)
132
    });
133
    // 点击空白处关闭弹窗
134
    graph.on('blank:dblclick', () => {
135
      proxy.$eBus.emit('open:right-panel');
136
    });
137
    graph.on('blank:mousedown', () => {});
138
139
    // 复制
140
    graph.bindKey(['meta+c', 'ctrl+c'], () => {
141
      const cells = graph.getSelectedCells();
142
      if (cells.length) {
143
        graph.copy(cells);
144
      }
145
      return false;
146
    });
147
    // 剪切
148
    graph.bindKey(['meta+x', 'ctrl+x'], () => {
149
      const cells = graph.getSelectedCells();
150
      if (cells.length) {
151
        graph.cut(cells);
152
      }
153
      return false;
154
    });
155
    // 粘贴
156
    graph.bindKey(['meta+v', 'ctrl+v'], () => {
157
      if (!graph.isClipboardEmpty()) {
158
        const cells = graph.paste({ offset: 100 });
159
        graph.cleanSelection();
160
        graph.select(cells);
161
      }
162
      return false;
163
    });
164
    // 删除
165
    graph.bindKey(['meta+d', 'ctrl+d'], () => {
166
      const cells = graph.getSelectedCells();
167
      if (cells.length) {
168
        graph.cut(cells);
169
        graph.cleanClipboard();
170
      }
171
      return false;
172
    });
173
    // 保存数据
174
    graph.bindKey(['meta+p', 'ctrl+p'], () => {
175
      localStorage.setItem('grphData', JSON.stringify(graph.toJSON()));
176
      return false;
177
    });
178
179
    // undo redo
180
    graph.bindKey(['meta+z', 'ctrl+z'], () => {
181
      if (graph.history.canUndo()) {
182
        graph.history.undo();
183
      }
184
      return false;
185
    });
186
    graph.bindKey(['meta+shift+z', 'ctrl+shift+z'], () => {
187
      if (graph.history.canRedo()) {
188
        graph.history.redo();
189
      }
190
      return false;
191
    });
192
193
    // select all
194
    graph.bindKey(['ctrl+a', 'meta+a'], () => {
195
      const nodes = graph.getNodes();
196
      if (nodes) {
197
        graph.select(nodes);
198
      }
199
    });
200
201
    // delete
202
    graph.bindKey('backspace', () => {
203
      const cells = graph.getSelectedCells();
204
      if (cells.length) {
205
        graph.removeCells(cells);
206
        proxy.$eBus.emit('close:right-panel');
207
      }
208
    });
209
210
    // zoom 放大
211
    graph.bindKey(['ctrl+1', 'meta+1'], () => {
212
      zoom.value = graph.zoom();
213
      if (zoom.value < 2) {
214
        graph.zoom(0.1);
215
      }
216
    });
217
    // 缩小
218
    graph.bindKey(['ctrl+2', 'meta+2'], () => {
219
      zoom.value = graph.zoom();
220
      if (zoom.value > 0.5) {
221
        graph.zoom(-0.1);
222
      }
223
    });
224
    // 聚焦
225
    graph.bindKey(['ctrl+3', 'meta+3'], () => {
226
      graph.centerContent();
227
    });
228
  }
229
  // 初始化图表
230
  function initGraph() {
231
    const container = document.getElementById('flow');
232
    container.addEventListener('dragover', (event) => {
233
      event.preventDefault();
234
    });
235
    const graph = new Graph({
236
      container,
237
      height: 'calc(100vh - 100px)',
238
      background: {
239
        color: '#F8F8F8'
240
      },
241
      // autoResize: true,
242
      // 滚动
243
      // scroller: {
244
      //   enabled: true,
245
      //   pageVisible: false, // 是否分页
246
      //   pageBreak: false, // 是否显示分页符
247
      //   pannable: true // 启用画布平移能力
248
      // },
249
      panning: {
250
        enabled: true
251
      },
252
      mousewheel: {
253
        enabled: true
254
      },
255
      scaling: {
256
        min: 0.5,
257
        max: 2
258
      },
259
      // @:网格
260
      grid: {
261
        size: 10,
262
        visible: true
263
      },
264
      // 对齐线
265
      snapline: {
266
        enabled: true // @:对齐线
267
      },
268
      // 剪切板启用(复制,粘贴,剪切功能)
269
      clipboard: true,
270
      // 键盘启用(键盘快捷键功能)
271
      keyboard: true,
272
      // 历史记录(回退前进功能)
273
      history: true,
274
      //
275
      connection: {
276
        enabled: true // @:开启连线交互
277
      },
278
      // 配置全局连线规则
279
      connecting: {
280
        snap: true,
281
        anchor: 'center', // 锚点位置
282
        allowBlank: false, // 是否允许连接空白位置
283
        allowLoop: false, // 是否允许循环创建节点
284
        allowPort: true, // 是否允许边链接到链接桩,
285
        allowNode: false,
286
        highlight: true,
287
        // snap: true, // 自动吸附(50px)
288
        createEdge() {
289
          return new Shape.Edge({
290
            attrs: {
291
              line: {
292
                stroke: '#B1B1B1',
293
                strokeWidth: 1,
294
                targetMarker: {
295
                  name: 'block',
296
                  width: 5,
297
                  height: 9
298
                }
299
              }
300
            },
301
            router: 'custom',
302
            zIndex: 0,
303
            connector: {
304
              name: '',
305
              args: {
306
                radius: 90
307
              }
308
            }
309
          });
310
        },
311
        //  判断节点是否可被连接
312
        validateConnection({ sourcePort, targetPort, sourceCell, targetCell }) {
313
          const data = targetCell.getData();
314
          // @: xx类型节点不被连接 start节点不能被连接
315
          if (data.name === 'start') {
316
            return false;
317
          }
318
          const tartgetPorts = targetCell.getPorts();
319
          const sourcePorts = sourceCell.getPorts();
320
          /**
321
           * 1. 如果源点的group为input时,不允许连接
322
           * 2. 如果target的group为output时,不允许连接
323
           */
324
          if (
325
            sourcePorts.filter((el) => el.id === sourcePort)?.[0].group ===
326
            'input'
327
          ) {
328
            // proxy.$utils.ipuMessage('不能从输入节点进行连线!', 'error')
329
            return false;
330
          }
331
          if (
332
            tartgetPorts.filter((el) => el.id === targetPort)?.[0].group ===
333
            'output'
334
          ) {
335
            // proxy.$utils.ipuMessage('不能连接输出节点!', 'error')
336
            return false;
337
          }
338
          return true;
339
        },
340
        // 限制链接桩只能链接一条边(需在ports中设置connectionCount)
341
        validateMagnet({ magnet, cell }) {
342
          let count = 0;
343
          const connectionCount = magnet.getAttribute('connection-count');
344
          const max = connectionCount ? parseInt(connectionCount, 10) : 1;
345
          if (max === 0) {
346
            proxy.$utils.ipuMessage('请配置路由分发节点!', 'error');
347
          }
348
          const outgoingEdges = graph.getOutgoingEdges(cell);
349
          if (outgoingEdges) {
350
            outgoingEdges.forEach((edge) => {
351
              const edgeView = graph.findViewByCell(edge);
352
              if (edgeView.sourceMagnet === magnet) {
353
                count += 1;
354
              }
355
            });
356
          }
357
          return count < max;
358
        }
359
      },
360
      // 节点拖拽到另外一个节点中
361
      embedding: {
362
        enabled: true,
363
        findParent({ node }) {
364
          const bbox = node.getBBox();
365
          return this.getNodes().filter((item) => {
366
            // @: 只有data.parent为true的节点才是父节点
367
            const data = item.getData();
368
            if (data && data.parent) {
369
              const targetBBox = item.getBBox();
370
              return bbox.isIntersectWithRect(targetBBox);
371
            }
372
            return false;
373
          });
374
        }
375
      },
376
      // 节点选中
377
      selecting: {
378
        enabled: true,
379
        multiple: false, // 多选
380
        rubberband: false, // @:是否启用框选
381
        movable: true,
382
        showNodeSelectionBox: true,
383
        filter: [] // @:['xx'] xx节点不能被选中
384
      }
385
    });
386
387
    graph.on('mouseEvent', (data) => {
388
      const { e } = data;
389
      switch (data.eventName) {
390
        case 'mouseDown':
391
          graph.mouseDownMoveFlag = !e.state;
392
          // 记录点击位置
393
          graph.mouseDownPos = e;
394
          break;
395
        case 'mouseUp':
396
          graph.mouseDownMoveFlag = false;
397
          // 一次移动结束,记录最终view偏移量
398
          graph.viewTranslate = { ...graph.viewOffset };
399
          break;
400
        case 'mouseMove':
401
          if (graph.mouseDownMoveFlag) {
402
            const vt = graph.viewTranslate;
403
            // 设置偏移位置
404
            const tx = e.graphX - graph.mouseDownPos.graphX + vt.graphX || 0;
405
            const ty = e.graphY - graph.mouseDownPos.graphY + vt.graphY || 0;
406
            // 保存view偏移量
407
            graph.viewOffset = { graphX: tx, graphY: ty };
408
            graph.view.setTranslate(tx, ty);
409
          }
410
          break;
411
        default:
412
          break;
413
      }
414
    });
415
    return graph;
416
  }
417
  // 获取线上数据
418
  function getNodesData() {
419
    const url = proxy.$api.logicMgmt;
420
    proxy
421
      .$reqGet(`${url}/${flowId}`)
422
      .then((res) => {
423
        if (res.data.resultCode === '0') {
424
          graphData.value = JSON.parse(res.data.result?.jsonData) || {};
425
          const panelGlobal = {};
426
          panelGlobal[flowId] = JSON.parse(res.data.result?.databusData) || {};
427
          localStorage.setItem('panelGlobal', JSON.stringify(panelGlobal));
428
        }
429
      })
430
      .catch((err) => {
431
        console.log(err);
432
      })
433
      .finally(() => {
434
        initFlow();
435
      });
436
  }
437
  // 初始化
438
  function initFlow() {
439
    Graph.unregisterRouter('custom');
440
    registerRouter();
441
    if (!graph.value) {
442
      graph.value = initGraph();
443
    }
444
    dnd.value = initDnd();
445
    initEvent(graph.value);
446
    if (graphData.value) {
447
      initGraphShape();
448
    }
449
    setGraphSize();
450
  }
451
452
  return {
453
    dnd,
454
    graph,
455
    graphData,
456
    getNodesData
457
  };
458
}

+ 4 - 6
src/views/_components/panel/PanelFunction.vue

@ -42,6 +42,7 @@ import { getCurrentInstance, ref, watch } from 'vue';
42 42
import CommonPanel from './common/CommonPanel.vue';
43 43
import InputOutputTab from './sql-components/InputOutputTab.vue';
44 44
import ParamItem from './common/ParamItem.vue';
45
import { getFunctionList } from '../../../api/flow';
45 46
46 47
const { proxy } = getCurrentInstance();
47 48
const props = defineProps({
@ -157,19 +158,16 @@ function setNodeAttrData() {
157 158
//   }
158 159
// }
159 160
160
async function getFunctionList() {
161
  const url = proxy.$api.getFunctionList;
162
  await proxy
163
    .$reqGet(url)
161
async function getList() {
162
  await getFunctionList()
164 163
    .then((res) => {
165 164
      domainList.value = res.data.result;
166
      // initData()
167 165
    })
168 166
    .catch((err) => {
169 167
      console.log(err);
170 168
    });
171 169
}
172
getFunctionList();
170
getList();
173 171
// 选择domain
174 172
function changeDomain(data) {
175 173
  nameList.value =

+ 14 - 11
src/views/_components/panel/PanelGlobal.vue

@ -20,12 +20,12 @@
20 20
            ></el-input>
21 21
          </el-form-item>
22 22
          <el-form-item label="服务方法" prop="method">
23
            <el-select
23
            <common-select
24 24
              v-model="basicFormData.method"
25 25
              class="form-item"
26 26
              :options="methodsOptions"
27 27
              placeholder="请选择服务方法"
28
            ></el-select>
28
            ></common-select>
29 29
          </el-form-item>
30 30
          <el-form-item label="服务描述">
31 31
            <el-input
@ -75,20 +75,26 @@
75 75
76 76
    <!-- 自定义属性声明 -->
77 77
    <!-- 模型声明 -->
78
    <el-table
78
    <common-table
79 79
      v-if="activeName === 'models' || activeName === 'customAttrs'"
80 80
      class="global-table"
81 81
      :table-header="table[activeName]?.header"
82 82
      :table-data="table[activeName]?.data"
83 83
    >
84 84
      <template #custom="scope">
85
        <el-icon
85
        <!-- <el-icon
86 86
          v-if="activeName === 'customAttrs'"
87 87
          class="icon"
88 88
          @click="editFn(scope.row)"
89 89
        >
90 90
          <Edit></Edit>
91
        </el-icon>
91
        </el-icon> -->
92
        <common-icon
93
          v-if="activeName === 'customAttrs'"
94
          name="common-bianji"
95
          @click="editFn(scope.row)"
96
        ></common-icon>
97
92 98
        <!-- 删除 -->
93 99
        <el-popconfirm
94 100
          :title="deleteTitle[activeName]"
@ -96,11 +102,12 @@
96 102
          @cancel="cancelEvent"
97 103
        >
98 104
          <template #reference>
99
            <el-icon class="icon"><Delete></Delete></el-icon>
105
            <!-- <el-icon class="icon"><Delete></Delete></el-icon> -->
106
            <common-icon name="common-shanchu"></common-icon>
100 107
          </template>
101 108
        </el-popconfirm>
102 109
      </template>
103
    </el-table>
110
    </common-table>
104 111
  </div>
105 112
  <dialog-panel
106 113
    v-if="isShowPanel"
@ -130,7 +137,6 @@
130 137
import { computed, reactive, ref, watch } from 'vue';
131 138
132 139
import XLSX from 'xlsx';
133
134 140
// 模型属性引入
135 141
import { useRoute } from 'vue-router';
136 142
import { useStore } from 'vuex';
@ -218,9 +224,6 @@ watch(
218 224
// 处理整体服务数据
219 225
function parsePanelGlobalData() {
220 226
  const panelGlobalData = ref({});
221
  // if (localStorage.getItem('panelGlobal')) {
222
  //   panelGlobalData.value = JSON.parse(localStorage.getItem('panelGlobal'))
223
  // }
224 227
  panelGlobalData.value[flowId.value] = table.value;
225 228
  localStorage.setItem('panelGlobal', JSON.stringify(panelGlobalData.value));
226 229
}

+ 5 - 5
src/views/_components/panel/PanelSql.vue

@ -97,6 +97,7 @@
97 97
import { getCurrentInstance, reactive, ref, watch } from 'vue';
98 98
import MyCode from '../_codemirror/MyCode.vue';
99 99
import InputOutputTab from './sql-components/InputOutputTab.vue';
100
import { getSQLList } from '../../../api/flow';
100 101
101 102
const { proxy } = getCurrentInstance();
102 103
const props = defineProps({
@ -273,9 +274,8 @@ const propsMap = ref({
273 274
  label: 'showName'
274 275
});
275 276
// 获取数据库列表
276
function getSQLList() {
277
  proxy
278
    .$reqGet(proxy.$api.database)
277
function getList() {
278
  getSQLList()
279 279
    .then((res) => {
280 280
      if (res.data.resultCode === '0') {
281 281
        datasources.value = res.data.result.map((item) => {
@ -287,7 +287,7 @@ function getSQLList() {
287 287
        });
288 288
      } else {
289 289
        datasources.value = [];
290
        proxy.$utils.ipuMessage(res.data.resultMsg, 'error');
290
        proxy.$message.error(res.data.resultMsg);
291 291
      }
292 292
    })
293 293
    .catch((err) => {
@ -295,7 +295,7 @@ function getSQLList() {
295 295
      datasources.value = [];
296 296
    });
297 297
}
298
getSQLList();
298
getList();
299 299
watch(
300 300
  panelData.value,
301 301
  () => {

+ 2 - 2
src/views/_components/panel/common/AddFormItem.vue

@ -17,13 +17,13 @@
17 17
          class="int int2"
18 18
          placeholder="请输入value"
19 19
        ></el-input>
20
        <el-select
20
        <common-select
21 21
          v-if="options && options.length"
22 22
          v-model="item.value"
23 23
          class="int int2"
24 24
          placeholder="请选择"
25 25
          :options="options"
26
        ></el-select>
26
        ></common-select>
27 27
        <el-icon
28 28
          v-if="index < datas.length - 1"
29 29
          class="icon"

+ 35 - 50
src/views/flow/_components/ApiDetailPage.vue

@ -15,7 +15,7 @@
15 15
          -->
16 16
          <el-button
17 17
            :disabled="props.versionState === 'PUBLISHED'"
18
            @click.stop="stopTest"
18
            @click.stop="logicOperation(3, '确定测试该接口吗?')"
19 19
          >
20 20
            测试
21 21
          </el-button>
@ -24,7 +24,7 @@
24 24
              apiDetail?.state !== 'STARTED' ||
25 25
              props.versionState === 'PUBLISHED'
26 26
            "
27
            @click.stop="stopLogic"
27
            @click.stop="logicOperation(4, '确定停用该api吗?')"
28 28
          >
29 29
            停用
30 30
          </el-button>
@ -161,6 +161,7 @@
161 161
<script setup>
162 162
// import JsonEditorVue from 'json-editor-vue3';
163 163
import { getCurrentInstance, onMounted, ref, watch } from 'vue';
164
import { logicModeUpdate, testLogic } from '../../../api/flow';
164 165
165 166
const { proxy } = getCurrentInstance();
166 167
const emits = defineEmits(['editLogicApi', 'initApiInfo']);
@ -190,50 +191,35 @@ function initApiInfo() {
190 191
  emits('initApiInfo');
191 192
}
192 193
// 测试按钮
193
function stopTest() {
194
  proxy.$utils.confirmMessage('确定测试该接口吗?').then(() => {
195
    const url = proxy.$api.logicMgmt;
196
    const params = {
197
      stateValue: 3
198
    };
199
    proxy
200
      .$reqPatch(`${url}/${props.apiDetail?.id}`, params)
201
      .then((res) => {
202
        if (res.data.resultCode === '0') {
203
          proxy.$utils.ipuMessage('测试成功');
204
        } else {
205
          proxy.$utils.ipuMessage(res.data.resultMsg, 'error');
206
        }
207
      })
208
      .catch((err) => {
209
        console.log(err);
210
      })
211
      .finally(() => {
212
        initApiInfo();
213
      });
214
  });
215
}
216
// 停用
217
function stopLogic() {
218
  proxy.$utils.confirmMessage('确定停用该api吗?').then(() => {
219
    const url = proxy.$api.logicMgmt;
220
    const params = {
221
      stateValue: '4'
222
    };
223
    proxy
224
      .$reqPatch(`${url}/${props.apiDetail?.id}`, params)
225
      .then((res) => {
226
        if (res.data.resultCode === '0') {
227
          proxy.$utils.ipuMessage('api已下架!');
228
        } else {
229
          proxy.$utils.ipuMessage(res.data.resultMsg, 'error');
230
        }
231
      })
232
      .catch((err) => {
233
        console.log(err);
234
      });
235
  });
194
function logicOperation(state, msg) {
195
  proxy
196
    .$confirm(msg, '警告', {
197
      confirmButtonText: '确定',
198
      cancelButtonText: '取消',
199
      type: 'warning'
200
    })
201
    .then(() => {
202
      const params = {
203
        stateValue: state
204
      };
205
206
      logicModeUpdate(params, props.apiDetail?.id)
207
        .then((res) => {
208
          if (res.data.resultCode === '0') {
209
            proxy.$message.success(res.resultMsg);
210
          } else {
211
            proxy.$message.error(res.resultMsg, 'error');
212
          }
213
        })
214
        .catch((err) => {
215
          console.log(err);
216
        })
217
        .finally(() => {
218
          initApiInfo();
219
        });
220
    });
236 221
}
222
237 223
// 接口详情
238 224
function apiDetailHooks() {
239 225
  const request = ref({
@ -300,17 +286,16 @@ function testHooks() {
300 286
    testResponse.value = {};
301 287
  }
302 288
  updateTestData();
289
303 290
  function test() {
304
    const { testLogic } = proxy.$api;
305 291
    const { params } = testRequest.value;
306
    proxy
307
      .$reqPost(`${testLogic}/${props.apiDetail.id}`, params)
292
    testLogic(params, props.apiDetail.id)
308 293
      .then((res) => {
309 294
        if (res.data.resultCode === '0') {
310
          proxy.$utils.ipuMessage('请求成功!');
295
          proxy.$message.success('请求成功!');
311 296
          testResponse.value = res.data.result;
312 297
        } else {
313
          proxy.$utils.ipuMessage(res.data.resultMsg, 'error');
298
          proxy.$message.error(res.data.resultMsg);
314 299
        }
315 300
      })
316 301
      .catch((err) => {