import Magix from 'magix' import * as View from '../../../../view' Magix.applyStyle('@./expand-crowd.less') const EMPTY_SYMBOL = '--' export default View.extend({ tmpl: '@expand-crowd.html', init (options) { this.options = options }, async render () { const types = [{ text: '默认', value: 0 }, { text: '放大', value: 16 }] const crowd = await this.getCrowdInfo() const lookalikeAlgoType = crowd.lookalikeAlgoType || types[0].value const lookalikeMultiple = crowd.lookalikeMultiple this.updater.digest({ EMPTY_SYMBOL, crowd, types, lookalikeAlgoType, lookalikeMultiple }) this.refreshCoverage() }, // 获取人群信息 async getCrowdInfo () { try { const models = [{ name: 'api_crowd_$id_get', pathParams: [this.options.crowdId] }] const [model] = await this.fetch(models) const data = model.get('data.crowd', {}) return data } catch (error) { this.alert('错误提示', error.msg || error.message || error, null, { mask: true }) } }, 'refreshCoverage' (e) { this.refreshCoverage() }, // 更新覆盖数 async refreshCoverage () { const { lookalikeMultiple, lookalikeAlgoType, crowd } = this.updater.get() try { this.updater.digest({ coverageLoading: true }) const params = { selectTagOptionSet: crowd.selectTagOptionSet, lookalikeAlgoType } if (lookalikeAlgoType == 16) { params.lookalikeMultiple = lookalikeMultiple } const models = [{ name: 'api_analysis_coverage_post', params, isJson: true }] const [model] = await this.fetch(models) const data = model.get('data', {}) const { coverage, hintDataSecurity, hintDataSecurityInfo } = data this.updater.digest({ coverageLoading: false, coverage, hintDataSecurity, hintDataSecurityInfo }) } catch (error) { this.alert('错误提示', error.msg || error.message || error, null, { mask: true }) } }, async 'expand' (e) { const { crowd, lookalikeMultiple, lookalikeAlgoType } = this.updater.get() delete crowd.baseCrowdExpression delete crowd.garudaExpression delete crowd.userExpression crowd.lookalikeAlgoType = lookalikeAlgoType if (lookalikeAlgoType == 0) { delete crowd.lookalikeMultiple } else { crowd.lookalikeMultiple = lookalikeMultiple } // 打标 crowd.extra.report_type_expand = '1' this.updater.digest({ saveLoading: true }) try { const models = [{ name: 'api_crowd_$id_put', isJson: true, params: crowd, pathParams: [this.options.crowdId] }] const [model] = await this.fetch(models) this.alert('提示', '恭喜,人群规模修改成功!', () => { this.options.dialog.close() }) } catch (error) { this.alert('错误提示', error.msg || error.message || error, null, { mask: true }) } this.updater.digest({ saveLoading: false }) } })