import Magix from 'magix' import View from 'dmp-new/view' import { COLOR_NEW, COLOR_STOCK } from '../constant' import { getAssetVO, getReachedAssetVO, getGmvVO, getReachedGmvVO } from './summary-config' Magix.applyStyle('@./summary.less') export default View.extend({ tmpl: '@summary.html', init(options) { this.options = options }, async render() { const loc = Magix.Router.parse() const { report, taskId, isCustom, benchmarkBrands, benchmarkId } = this.options const data = await this.getData('0') // 总资产规模 const assetVO = getAssetVO(isCustom) // 营销贡献资产规模 const reachedAssetVO = getReachedAssetVO(isCustom) // 总资产成交 const gmvVO = getGmvVO(isCustom) // 营销贡献成交规模 const reachedGmvVO = getReachedGmvVO(isCustom) // 营销触达占比 const reachedProportion = { total: { name: '营销触达占比', value: data.reachedAssetVO.reachedUvRate, format: 'rate' }, new: { name: '新增资产触达贡献率', value: data.reachedAssetVO.reachedNewUvContriRate, format: 'rate' }, stock: { name: '存量资产营销触达贡献率', value: data.reachedAssetVO.reachedStockUvContriRate, format: 'rate' } } // 营销触达成交金额占比 const reachedGmvProportion = { total: { name: '营销触达成交额占比', value: data.reachedGmvVO.reachedGmvRate, format: 'rate' }, new: { name: '新增资产成交营销贡献率', value: data.reachedGmvVO.reachedNewGmvContriRate, format: 'rate' }, stock: { name: '存量资产成交营销贡献率', value: data.reachedGmvVO.reachedStockGmvContriRate, format: 'rate' } } this.updater.digest({ benchmarkBrands, benchmarkId, assetVO, reachedAssetVO, gmvVO, reachedGmvVO, reachedProportion, reachedGmvProportion, data, isCompare: false, COLOR_NEW, COLOR_STOCK, report, taskId, isCustom }) // 加载对比同行数据 this.renderBenchmark() }, // 加载对比同行数据 async renderBenchmark() { const { isCompare, dataCompare } = this.updater.get() // if (isCompare && !dataCompare) { if (isCompare) { this.updater.digest({ loadingCompare: true }) try { const dataCompare = await this.getData('1') this.updater.set({ dataCompare }) } catch (error) { this.alert('提示', error.msg || error.message) } this.updater.digest({ loadingCompare: false }) } }, async getData(benchmark) { const { report, taskId, isCustom } = this.options const { benchmarkId } = this.updater.get() const params = { brandId: report.brandId, taskId, benchmark } if (benchmark == '1' && !isCustom) { params.benchmarkId = benchmarkId } const models = [ { name: 'api_deeplink_report_detail_overview_get', params } ] const [model] = await this.fetch(models) const data = model.get('data', {}) return data }, 'showCompare'(e) { this.renderBenchmark() }, 'changeBenchmarkBrand'(e) { this.renderBenchmark() } })