|
@@ -29,7 +29,7 @@ import { ref, reactive, nextTick } from 'vue';
|
|
|
import api from '/@/api/rule';
|
|
|
import axios from 'axios';
|
|
|
import { ruleRequired } from '/@/utils/validator';
|
|
|
-import { ElMessage } from 'element-plus';
|
|
|
+import { ElMessage } from 'element-plus';
|
|
|
|
|
|
const emit = defineEmits(['getList']);
|
|
|
|
|
@@ -40,6 +40,11 @@ const props = defineProps({
|
|
|
},
|
|
|
});
|
|
|
|
|
|
+const headers = {
|
|
|
+ Authorization: 'Bearer ' + JSON.parse(sessionStorage.token),
|
|
|
+};
|
|
|
+const flowsUrl = window.location.protocol + '//' + window.location.hostname + '/rule-engine/flow';
|
|
|
+
|
|
|
const showDialog = ref(false);
|
|
|
const formRef = ref();
|
|
|
|
|
@@ -65,7 +70,7 @@ const onSubmit = async () => {
|
|
|
|
|
|
if (!formData.id) {
|
|
|
const { data } = await axios.post(
|
|
|
- window.location.protocol + '//' + window.location.hostname + '/rule-engine/flow',
|
|
|
+ flowsUrl,
|
|
|
{
|
|
|
label: formData.name,
|
|
|
disabled: true,
|
|
@@ -74,12 +79,25 @@ const onSubmit = async () => {
|
|
|
nodes: [],
|
|
|
},
|
|
|
{
|
|
|
- headers: {
|
|
|
- Authorization: 'Bearer ' + JSON.parse(sessionStorage.token),
|
|
|
- },
|
|
|
+ headers,
|
|
|
}
|
|
|
);
|
|
|
formData.flowId = data.id;
|
|
|
+ } else {
|
|
|
+ // 找到所有规则
|
|
|
+ const { data: flows } = await axios.get(flowsUrl + 's', { headers });
|
|
|
+
|
|
|
+ const flow = flows.find((item: any) => item.id === formData.flowId);
|
|
|
+
|
|
|
+ if (!flow) {
|
|
|
+ ElMessage.error('规则不存在');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ flow.label = formData.name;
|
|
|
+
|
|
|
+ // 设置规则状态
|
|
|
+ await axios.post(flowsUrl + 's', flows, { headers });
|
|
|
}
|
|
|
|
|
|
const theApi = formData.id ? api.edit : api.add;
|