import Magix from 'magix' import View from 'dmp-new/view' Magix.applyStyle('@./report.less') export default View.extend({ tmpl: '@report.html', async init(options) { this.options = options const loc = Magix.Router.parse() const taskId = loc.get('id') const [report, statusIds] = await Promise.all([ this.getReport(taskId), this.getStatusIds() ]) this.updater.set({ taskId, report, statusIds }) this.observeLocation(['transferType']) // this.assign(options) }, assign(options) { this.options = options return true }, async render() { const loc = Magix.Router.parse() const tabs = [ { text: '品牌竞争流入分析', value: '1' }, { text: '品牌竞争流出分析', value: '2' } ] const { transferType = tabs[0].value } = loc.params const isInflow = transferType === '1' this.updater.digest({ tabs, transferType, isInflow }) // 计算好要吸顶的topbar的宽度 // this._setTopBarWidth() // // 吸顶处理 // this._setBarTop() }, async getStatusIds() { try { const params = {} const models = [ { name: 'api_asset_deeplink_statusList_get', params } ] const [model] = await this.fetch(models) const data = model.get('data', []) return data .filter(item => { return item.id != 0 }) .map(item => { item.name += '人群' return item }) } catch (error) { console.error(error) } }, async getReport(taskId) { try { const params = { taskId } const models = [ { name: 'api_deeplink_compete_task_$id_get', params, pathParams: [taskId] } ] const [model] = await this.fetch(models) const data = model.get('data', {}) return data } catch (error) { console.error(error) } }, 'changeTransferType'(e) { const { transferType } = this.updater.get() Magix.Router.to({ transferType }) } })