import Magix from 'magix' import * as View from '../../../../view' Magix.applyStyle('@./channel-analysis.less') export default View.extend({ tmpl: '@channel-analysis.html', init (options) { this.options = options }, async render () { const { selectedIndicators, noOperator, hidePeer } = this.options const channelDatas = await this.getData() if (this.options.callback) { this.options.callback($.extend(true, [], channelDatas)) } this.updater.digest({ hidePeer, selectedIndicators, channelDatas, noOperator }) }, async getData () { try { const { beginDate, endDate, selectedIndicators } = this.options const models = [{ name: 'api_report_channel_list_get', params: { beginDate, endDate, indicators: selectedIndicators.map(ind => ind.key) } }] const [model] = await this.fetch(models) const data = model.get('data', []) return data } catch (error) { this.alert('错误提示', error.msg || error.message || error, null, { mask: true }) } }, // 投放趋势分析 'showAdTrend' (e) { const viewPath = '@./ad-trend' const { indicators, selectedIndicators, beginDate, endDate } = this.options const { deliverType, channelName } = e.params const viewOptions = { endDate, beginDate, deliverType, indicators, selectedIndicators } const dialogOptions = { header: { title: `${channelName}渠道投放分析` }, width: 1060, footer: { enterText: '关闭', cancel: false } } this.mxModal(viewPath, viewOptions, dialogOptions) }, // 渠道投放优化 'showChannelOptimize' (e) { const viewPath = '@./channel-optimize' const { deliverType, channelName } = e.params const viewOptions = { channelName, deliverType } const dialogOptions = { header: { title: `${channelName}渠道投放优化` }, width: 1060, footer: { enterText: '关闭', cancel: false } } this.mxModal(viewPath, viewOptions, dialogOptions) } })