diff --git a/src/views/DataAnalyse/insight/consts.js b/src/views/DataAnalyse/insight/consts.js index 9ca3d5a7..3e2313f4 100644 --- a/src/views/DataAnalyse/insight/consts.js +++ b/src/views/DataAnalyse/insight/consts.js @@ -7,7 +7,10 @@ // 600=包装测试-标准(600_),601=包装测试-快速(601_),602=包装测试-配对(602_) export const showInsightTemplateType = [300, 301, 500, 501, 600, 601]; // 显示洞察报告 tab 的 template_type -// 看板类型:1=概念标准版,2=概念快测版,3=概念配对版,4=口味标准版,5=口味快测版,6=口味配对版 +// 看板类型: +// 1=概念标准版,2=概念快测版,3=概念配对版, +// 4=口味标准版,5=口味快测版,6=口味配对版 +// 7=包装标准版,8=包装快测版,9=包装配对版 export const reportTypeEnum = { concept_standard: 1, concept_quick: 2, @@ -32,11 +35,6 @@ export const reportTypeLabelMap = { [reportTypeEnum.package_pair]: '包装' }; -export const sectionShownTypeEnum = { - show: 2, - hide: 1 -}; - // 检查是否需要显示 “洞察报告” 这个标签页 // 仅标准版和快测版问卷显示该菜单 export function checkShowInsightTab({ templateType } = {}) { @@ -59,8 +57,29 @@ export function getInsightTypeStr(templateType) { return labelMap[templateType] || ''; } +export const sectionShownTypeEnum = { + show: 2, + hide: 1 +}; + +export const testItemTypeEnum = { + newest: 1, + standard: 0, + + 1: 'newest', + 0: 'standard' +}; + +export const testItemTypeLabelMap = { + [testItemTypeEnum.newest]: '新品', + [testItemTypeEnum.standard]: '标杆' +}; + export const reportUpdatingMessageText = '报告更新中,不能修改'; +export const codeList = ['概念编码', '口味编码', '包装编码']; +export const italicCodeList = [...codeList, '样本基数']; + // 报告表格某些行需要显示选择框,并且可以修改,此列表为区分此功能的文字 export const selectionList = [ '是否通过概念行动标准', diff --git a/src/views/DataAnalyse/insight/report/Report.vue b/src/views/DataAnalyse/insight/report/Report.vue index 6db7e906..ad526f04 100644 --- a/src/views/DataAnalyse/insight/report/Report.vue +++ b/src/views/DataAnalyse/insight/report/Report.vue @@ -5,6 +5,7 @@ import Overview from './section/Overview.vue'; import ProjectNameAndDecisionCriteria from './section/ProjectNameAndDecisionCriteria.vue'; import TestingConcept from './section/TestingConcept.vue'; import TestingTaste from './section/TestingTaste.vue'; +import TestingPackage from './section/TestingPackage.vue'; import GroupTab from './section/GroupTab.vue'; import CoreConclusion from './section/CoreConclusion.vue'; @@ -43,8 +44,10 @@ const readonly = computed(() => props.readonly || false); const updating = computed(() => props.updating || false); // 快测版报告内容和标准版基本一致,区别为快测版没有概念诊断部分 -// 看板类型:1=标准版,2=快测版,3=配对版,添加了口味,请参考下一行 -// 看板类型:1=概念标准版,2=概念快测版,3=概念配对版,4=口味标准版,5=口味快测版,6=口味配对版 +// 看板类型: +// 1=概念标准版,2=概念快测版,3=概念配对版, +// 4=口味标准版,5=口味快测版,6=口味配对版 +// 7=包装标准版,8=包装快测版,9=包装配对版 const type = computed(() => +props.report?.type); const testCom = computed(() => { @@ -57,6 +60,10 @@ const testCom = computed(() => { case reportTypeEnum.taste_quick: case reportTypeEnum.taste_pair: return TestingTaste; + case reportTypeEnum.package_standard: + case reportTypeEnum.package_quick: + case reportTypeEnum.package_pair: + return TestingPackage; } }); @@ -69,8 +76,8 @@ const comList = computed(() => { list.push(ProjectNameAndDecisionCriteria); // 项目名称及概念决策标准 list.push(testCom.value); // 测试概念/测试口味/测试包装 - list.push(GroupTab); // tab 切换 list.push(CoreConclusion); // 核心结论 + list.push(GroupTab); // tab 切换 list.push(DecisionIndicators); // 决策指标 if ( diff --git a/src/views/DataAnalyse/insight/report/components/StyledTable.vue b/src/views/DataAnalyse/insight/report/components/StyledTable.vue index deceb08b..47dc506d 100644 --- a/src/views/DataAnalyse/insight/report/components/StyledTable.vue +++ b/src/views/DataAnalyse/insight/report/components/StyledTable.vue @@ -1,6 +1,6 @@ + + + + diff --git a/src/views/DataAnalyse/insight/report/section/TestingConcept.vue b/src/views/DataAnalyse/insight/report/section/TestingConcept.vue index 802f37ec..7ea40ab6 100644 --- a/src/views/DataAnalyse/insight/report/section/TestingConcept.vue +++ b/src/views/DataAnalyse/insight/report/section/TestingConcept.vue @@ -1,124 +1,18 @@ - + diff --git a/src/views/DataAnalyse/insight/report/section/TestingPackage.vue b/src/views/DataAnalyse/insight/report/section/TestingPackage.vue new file mode 100644 index 00000000..f269a1e9 --- /dev/null +++ b/src/views/DataAnalyse/insight/report/section/TestingPackage.vue @@ -0,0 +1,18 @@ + + + + + diff --git a/src/views/DataAnalyse/insight/report/section/TestingTaste.vue b/src/views/DataAnalyse/insight/report/section/TestingTaste.vue index fb479493..08007410 100644 --- a/src/views/DataAnalyse/insight/report/section/TestingTaste.vue +++ b/src/views/DataAnalyse/insight/report/section/TestingTaste.vue @@ -4,19 +4,11 @@ import { computed, defineEmits, defineProps } from 'vue'; import SectionTitle from '../../components/SectionTitle.vue'; import Section from '../../components/Section.vue'; -import { defaultSectionEmits, defaultSectionProps } from '../../consts'; +import { defaultSectionEmits, defaultSectionProps, testItemTypeEnum } from '../../consts'; const emits = defineEmits(defaultSectionEmits); const props = defineProps(defaultSectionProps); -const typeEnum = { - newest: 1, - standard: 0, - - 1: 'newest', - 0: 'standard' -}; - const typeLabelMap = { 1: '新品口味', 0: '标杆口味' @@ -33,7 +25,7 @@ const list = computed(() => props.report?.config || []); v-for="item in list" :key="item.id" class="item" - :class="{ [typeEnum[item.concept_type]]: true }" + :class="{ [testItemTypeEnum[item.concept_type]]: true }" >
{{ typeLabelMap[item.concept_type] || '' }}{{ item.concept_encode || '' }} diff --git a/src/views/DataAnalyse/insight/report/section/diagnosis/ConceptDiagnosis.vue b/src/views/DataAnalyse/insight/report/section/diagnosis/ConceptDiagnosis.vue index 3906d934..d9230bc3 100644 --- a/src/views/DataAnalyse/insight/report/section/diagnosis/ConceptDiagnosis.vue +++ b/src/views/DataAnalyse/insight/report/section/diagnosis/ConceptDiagnosis.vue @@ -40,19 +40,19 @@ watch( child.question.list.forEach((group) => { group.options?.forEach?.((option) => { option.option_config.__rate__ = hotData.find((data) => { - if (data.key !== header.key) { - return false; - } - if (data.index.startsWith('Q')) { - const [temp, questionIndex] = /Q(\d*)A(\d*)/g.exec(data.index); + if (data.key !== header.key) { + return false; + } + if (data.index.startsWith('Q')) { + const [temp, questionIndex] = /Q(\d*)A(\d*)/g.exec(data.index); - if (group.relation_question_index === +questionIndex) { - return data.index === option.option_key; - } - } else { - return +data.index === +option.option_key; + if (group.relation_question_index === +questionIndex) { + return data.index === option.option_key; } - })?.rate || 0; + } else { + return +data.index === +option.option_key; + } + })?.rate || 0; option.option_config.__rate__ += '%'; }); }); diff --git a/src/views/DataAnalyse/insight/report/section/diagnosis/PeopleLike.vue b/src/views/DataAnalyse/insight/report/section/diagnosis/PeopleLike.vue index a08bf49c..17c0cbbd 100644 --- a/src/views/DataAnalyse/insight/report/section/diagnosis/PeopleLike.vue +++ b/src/views/DataAnalyse/insight/report/section/diagnosis/PeopleLike.vue @@ -195,7 +195,9 @@ function downloadHotAreaImage() { ctx.fillStyle = '#FFFFFF'; ctx.roundRect( textLeft - 4, - textTop - (textMetrics.actualBoundingBoxAscent + textMetrics.actualBoundingBoxDescent) * 0.5 - 6, + textTop + - (textMetrics.actualBoundingBoxAscent + textMetrics.actualBoundingBoxDescent) * 0.5 + - 6, textMetrics.width + 8, textMetrics.actualBoundingBoxAscent + textMetrics.actualBoundingBoxDescent + 8, 4 diff --git a/src/views/DataAnalyse/insight/report/section/diagnosis/ProductImage.vue b/src/views/DataAnalyse/insight/report/section/diagnosis/ProductImage.vue index 6cc88756..b6e74d6b 100644 --- a/src/views/DataAnalyse/insight/report/section/diagnosis/ProductImage.vue +++ b/src/views/DataAnalyse/insight/report/section/diagnosis/ProductImage.vue @@ -4,6 +4,8 @@ import { computed, defineProps } from 'vue'; import Section from '../../../components/Section.vue'; import StyledTable from '../../components/StyledTable.vue'; +import { codeList } from '../../../consts'; + const props = defineProps({ report: { type: Object, default: () => Object.assign({}) } }); @@ -16,7 +18,7 @@ function getTableCodeRow(tableData) { return ''; } const codeRow = tableData.dataVOS.find((row) => - Object.keys(row).find((key) => ['概念编码', '口味编码'].includes(row[key])) + Object.keys(row).find((key) => codeList.includes(row[key])) ); if (!codeRow) { return ''; diff --git a/src/views/DataAnalyse/insight/util.js b/src/views/DataAnalyse/insight/util.js index 61a5044e..122d9071 100644 --- a/src/views/DataAnalyse/insight/util.js +++ b/src/views/DataAnalyse/insight/util.js @@ -56,3 +56,51 @@ export function sortListForTableColSpan(options = {}) { return list; } + +/** + * 计算表格行的表头的宽度 + * @param data + * @param data.headerVOS {array} 表格的列的表头 + * @param data.dataVOS {array} 表格的数据 + * @returns {*|[]|number[]|undefined} + */ +export function getRowTitleColumnWidth(data) { + if (!data) { + return undefined; + } + + const header = data.headerVOS || []; + const tableData = data.dataVOS || []; + + const rowTitleIndex = header[0]?.dataIndex; + + if (!rowTitleIndex) { + return [280, 280]; + } + + const widthList = tableData.map((item) => { + const rowTitleList = item[rowTitleIndex].split('_'); + + if (rowTitleList.length > 1) { + return rowTitleList.map((str) => str.length * 14 + 36); + } + + return []; + }); + + return widthList.reduce((prev, curr) => { + if (!prev?.length) { + return curr; + } + if (!curr?.length) { + return prev; + } + + curr.forEach((currWidth, index) => { + prev[index] = Math.max(currWidth, prev[index], 120); + prev[index] = Math.ceil(prev[index] * 0.1) * 10; + }); + + return prev; + }, []); +}