提交 69329fd8 authored 作者: 王鹏飞's avatar 王鹏飞

chore: 旅程增加触发和关闭按钮

上级 d4fdc150
...@@ -52,12 +52,11 @@ export function ruleQuery(data: { experiment_id: string; filters: string }) { ...@@ -52,12 +52,11 @@ export function ruleQuery(data: { experiment_id: string; filters: string }) {
} }
// 保存实验旅程数据规则 // 保存实验旅程数据规则
export function saveRule(data: { export function saveRule(data: { itinerary_id: string; data_generate_mode: string; data_generate_frequency: string; auto_generate_rule: string; graph: string }) {
itinerary_id: string
data_generate_mode: string
data_generate_frequency: string
auto_generate_rule: string
graph: string
}) {
return httpRequest.post('/api/resource/v1/backend/experiment-itinerary/save-data-config', data) return httpRequest.post('/api/resource/v1/backend/experiment-itinerary/save-data-config', data)
} }
// 取消、触发旅程
export function updateTriggerStatus(data: { itinerary_id: string; trigger_status: 0 | 1 }) {
return httpRequest.post('/api/lab/v1/experiment/itinerary/trigger', data)
}
...@@ -5,7 +5,7 @@ import type { ConnectionType } from '@/composables/useAllData' ...@@ -5,7 +5,7 @@ import type { ConnectionType } from '@/composables/useAllData'
import { ElMessage } from 'element-plus' import { ElMessage } from 'element-plus'
import TripFlow from '@/components/flow/Index.vue' import TripFlow from '@/components/flow/Index.vue'
import TripFlowSidebar from '@/components/flow/Sidebar.vue' import TripFlowSidebar from '@/components/flow/Sidebar.vue'
import { getTripTemplate, getTripConnections, getTripTemplateDemo, updateTripTemplateDemo } from '../api' import { getTripTemplate, getTripConnections, getTripTemplateDemo, updateTripTemplateDemo, updateTriggerStatus } from '../api'
import { useMapStore } from '@/stores/map' import { useMapStore } from '@/stores/map'
import { getNameByValue, tripTemplateTypeList } from '@/utils/dictionary' import { getNameByValue, tripTemplateTypeList } from '@/utils/dictionary'
const BindConnection = defineAsyncComponent(() => import('../components/BindConnection.vue')) const BindConnection = defineAsyncComponent(() => import('../components/BindConnection.vue'))
...@@ -15,12 +15,14 @@ const props = defineProps<{ id: string }>() ...@@ -15,12 +15,14 @@ const props = defineProps<{ id: string }>()
const statusList = useMapStore().getMapValuesByKey('system_status') const statusList = useMapStore().getMapValuesByKey('system_status')
const detail = ref<TripTemplate>() const detail = ref<TripTemplate>()
const triggerStatus = ref<number>(0)
const score = computed(() => { const score = computed(() => {
return detail.value ? parseFloat(detail.value?.score) : 0 return detail.value ? parseFloat(detail.value?.score) : 0
}) })
function fetchInfo() { function fetchInfo() {
getTripTemplate({ id: props.id }).then(res => { getTripTemplate({ id: props.id }).then(res => {
detail.value = res.data.detail detail.value = res.data.detail
triggerStatus.value = parseInt(res.data.detail.is_trigger)
}) })
} }
...@@ -63,6 +65,13 @@ let configVisible = $ref(false) ...@@ -63,6 +65,13 @@ let configVisible = $ref(false)
function handleConfig() { function handleConfig() {
configVisible = true configVisible = true
} }
function handleChantTriggerStatus(status: 0 | 1) {
updateTriggerStatus({ itinerary_id: props.id, trigger_status: status }).then(() => {
triggerStatus.value = status
ElMessage.success('修改成功')
})
}
</script> </script>
<template> <template>
<AppCard title="固定旅程模版配置" v-if="detail"> <AppCard title="固定旅程模版配置" v-if="detail">
...@@ -115,15 +124,13 @@ function handleConfig() { ...@@ -115,15 +124,13 @@ function handleConfig() {
<el-row justify="center"> <el-row justify="center">
<el-button plain auto-insert-space @click="$router.push('/trip/template')">取消</el-button> <el-button plain auto-insert-space @click="$router.push('/trip/template')">取消</el-button>
<el-button type="primary" auto-insert-space @click="handleSubmit">保存</el-button> <el-button type="primary" auto-insert-space @click="handleSubmit">保存</el-button>
<el-button type="primary" auto-insert-space :disabled="triggerStatus === 1" @click="handleChantTriggerStatus(1)">触发旅程</el-button>
<el-button type="primary" auto-insert-space :disabled="triggerStatus === 0" @click="handleChantTriggerStatus(0)">关闭旅程</el-button>
</el-row> </el-row>
</template> </template>
</TripFlow> </TripFlow>
</AppCard> </AppCard>
<!-- 配置连接 --> <!-- 配置连接 -->
<BindConnection <BindConnection v-model="configVisible" :data="detail" v-if="configVisible && detail" @update="fetchConnections"></BindConnection>
v-model="configVisible"
:data="detail"
v-if="configVisible && detail"
@update="fetchConnections"></BindConnection>
</template> </template>
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论