diff --git a/src/views/DataAnalyse/insight/Index.vue b/src/views/DataAnalyse/insight/Index.vue index 862b9c4a..596ce64d 100644 --- a/src/views/DataAnalyse/insight/Index.vue +++ b/src/views/DataAnalyse/insight/Index.vue @@ -3,16 +3,13 @@ import { onBeforeUnmount, ref } from 'vue' import { useRoute } from 'vue-router' import { message, Modal } from 'ant-design-vue' - import InsightEmpty from './components/InsightEmpty.vue' import InsightShare from './components/InsightShare.vue' import Report from './report/Report.vue' - import { editInsightReport, getInsightReport, checkReportStatus, updateInsightReport } from './api' - const route = useRoute() const sn = route.query.sn || '' @@ -26,11 +23,10 @@ const report = ref({}) const saving = ref(0) const saveParams = ref({}) - getReport(true) async function getReport(fullLoading) { - if(loading.value) { + if (loading.value) { return } loading.value = true @@ -51,17 +47,20 @@ async function getReport(fullLoading) { } function initSaveParams() { - const totalData = report.value.chatVOS?.find?.((data) => data.type.startsWith('决策指标-总体')) || {} + const totalData = + report.value.chatVOS?.find?.((data) => data.type.startsWith('决策指标-总体')) || {} const headersFirstIndex = totalData.headerVOS?.[0]?.dataIndex || '' - const standardRow = totalData.dataVOS?.find?.((record) => record[headersFirstIndex] === '是否通过概念行动标准') || {} + const standardRow = + totalData.dataVOS?.find?.((record) => + ['是否通过概念行动标准', '是否通过口味行动标准'].includes(record[headersFirstIndex]) + ) || {} const actions = {} Object.keys(standardRow).forEach((key) => { - if(standardRow[key] !== '是否通过概念行动标准') { + if (!['是否通过概念行动标准', '是否通过口味行动标准'].includes(standardRow[key])) { actions[key] = standardRow[key] } }) - const params = { id: report.value.id, decisionCriteria: report.value.decisionIndicators, // 决策标准 @@ -74,7 +73,7 @@ function initSaveParams() { actions // 是否通过行动标准 1 是 2 否 } - Object.keys(params).forEach((key) => saveParams.value[key] = params[key]) + Object.keys(params).forEach((key) => (saveParams.value[key] = params[key])) } async function onInitReport() { @@ -82,7 +81,7 @@ async function onInitReport() { const params = { surveySn: sn } const data = await updateInsightReport(params).catch((e) => e) - if(!data?.data?.code) { + if (!data?.data?.code) { await getReport(false) } @@ -104,7 +103,7 @@ function onUpdateReport() { } async function onConfirmUpdateReport() { - if(updating.value) { + if (updating.value) { return } updating.value = true @@ -115,11 +114,10 @@ async function onConfirmUpdateReport() { await getReport() } - async function editReport(evt) { saving.value += 1 - Object.keys(evt || {}).forEach((key) => saveParams.value[key] = evt[key]) + Object.keys(evt || {}).forEach((key) => (saveParams.value[key] = evt[key])) await editInsightReport(saveParams.value).catch(() => '') saving.value -= 1 @@ -137,15 +135,19 @@ function mergeReport(params) { report.value.cityLevelQuotaHidden = params.cityLevelQuota_Hidden // 购买意愿-省市等级 是否隐藏 1是 2否 const total = report.value?.chatVOS?.find?.((data) => data.type.startsWith('决策指标-总体')) - if(total && params.actions) { - const result = total.dataVOS?.find?.((data) => '是否通过概念行动标准' === data[total.headerVOS?.[0]?.dataIndex]) || {} - Object.keys(params.actions).forEach((key) => result[key] = params.actions[key]) + if (total && params.actions) { + const result = + total.dataVOS?.find?.((data) => + ['是否通过概念行动标准', '是否通过口味行动标准'].includes( + data[total.headerVOS?.[0]?.dataIndex] + ) + ) || {} + Object.keys(params.actions).forEach((key) => (result[key] = params.actions[key])) } } - function startLooping() { - if(!timer) { + if (!timer) { return } stopLooping() @@ -161,7 +163,6 @@ function stopLooping() { onBeforeUnmount(stopLooping) - async function getReportStatus() { const params = { sn, @@ -176,7 +177,7 @@ async function getReportStatus() { // 2=有新的报告产生,已完成,需要重新请求报告展示接口 // 3=老报告的词云更新完了,需要重新请求报告展示接口 - switch(data?.data?.code) { + switch (data?.data?.code) { case 0: updating.value = false break @@ -195,19 +196,18 @@ async function getReportStatus() {