|
|
@@ -1,13 +1,14 @@
|
|
|
<template>
|
|
|
<div style="padding-right: 100px; display: flex; flex-direction: row; justify-content: flex-end; align-items: center">
|
|
|
- <!-- <el-button type="info" @click="body = policy" v-if="existPolicy">重置数据</el-button> -->
|
|
|
- <el-button type="success" @click="reportedPolicy" :disabled="!existPolicy">采集数据上报</el-button>
|
|
|
- <span style="color: #dea7b3; margin-left: 6px">{{ existPolicy ? "采集数据手动上报" : "未发现手动采集策略" }}</span>
|
|
|
+ <el-button type="success" @click="reportedPolicy" :disabled="!policyStore.policyExist">采集数据上报</el-button>
|
|
|
+ <span style="color: #dea7b3; margin-left: 6px">{{ policyStore.policyExist ? "采集数据手动上报" : "未发现手动采集策略" }}</span>
|
|
|
</div>
|
|
|
- <distribute-post url="/config/api/v1/sendPolicy" :body="body" @distribute="existPolicy = true"></distribute-post>
|
|
|
+ <distribute-post url="/config/api/v1/sendPolicy" :body="body" @distribute="policyStore.getPolicy()"></distribute-post>
|
|
|
</template>
|
|
|
<script setup lang="ts">
|
|
|
import request from "@/api/http";
|
|
|
+import { usePolicyStore } from "@/store/policy";
|
|
|
+const policyStore = usePolicyStore();
|
|
|
|
|
|
const policy = {
|
|
|
taskId: "518BB5B8-7551-418A-BFDD-A90C1CC66F03",
|
|
|
@@ -92,20 +93,10 @@ const policy = {
|
|
|
],
|
|
|
};
|
|
|
|
|
|
-const body = ref<any>(policy);
|
|
|
-const existPolicy = ref<boolean>(false);
|
|
|
+const body = ref<any>(policyStore.policyExist ? policyStore.policyBody : policy);
|
|
|
|
|
|
const reportedPolicy = async function () {
|
|
|
let data: any = await request({ url: "/config/api/v1/reportedPolicy", method: "GET" });
|
|
|
data.resp_code == 200 ? ElMessage.success(data.resp_msg || "上报成功") : ElMessage.error(data.resp_msg || "上报失败");
|
|
|
};
|
|
|
-onMounted(async () => {
|
|
|
- let { resp_msg }: any = await request({ url: "/config/api/v1/getPolicy", method: "GET" });
|
|
|
- try {
|
|
|
- body.value = JSON.parse(resp_msg);
|
|
|
- existPolicy.value = true;
|
|
|
- } catch (error) {
|
|
|
- existPolicy.value = false;
|
|
|
- }
|
|
|
-});
|
|
|
</script>
|