import Magix from 'magix' import View from '../../../../view' Magix.applyStyle('@./analyse-crowds.less') export default View.extend({ tmpl: '@analyse-crowds.html', init (options) { this.options = options }, async render () { // const loc = Magix.Router.parse() const { quota, desc } = await this.getData() const { analyseCrowd = {} } = this.options const { searchValue = '' } = this.updater.get() const list = this.searchCrowds(searchValue) this.updater.digest({ desc, analyseCrowd, originList: this.__list, searchValue, list, MAX_COUNT: quota }) }, async getData () { try { const params = {} const models = [{ name: 'api_asset_deeplink_market_crowdList_get', params }] const [model] = await this.fetch(models) const data = model.get('data', {}) this.__list = data.list ?? [] return data } catch (error) { this.alert('错误提示', error.msg || error.message || error) } }, 'addCrowds' (e) { const { MAX_COUNT, desc } = this.updater.get() const viewPath = '@./select-crowds' const viewOptions = { desc, MAX_COUNT, selectedCrowds: this.__list, callback: () => { this.render() } } const dialogOptions = { header: { title: '添加要分析的细分市场人群', tip: desc }, footer: { enter: true, cancel: true }, width: 780 } this.mxModal(viewPath, viewOptions, dialogOptions) }, 'showSubdivideCrowd' (e) { const { crowdId } = e.params this.options.dialog.close() Magix.Router.to({ crowdId }) }, 'remove' (e) { this._confirm({ title: '提示', content: '确定要删除吗?删除后额度立即释放,但再次添加市场后数据会重新累计。', enterCallback: async () => { try { const params = { crowdIds: e.params.crowdId } const models = [{ name: 'api_asset_deeplink_market_crowd_delete', isJson: true, params }] const [model] = await this.fetch(models) this.render() } catch (error) { this.alert('错误提示', error.msg || error.message || error) } } }, { type: 'highlight' }) }, searchCrowds (searchValue) { return this.__list.filter(crowd => { return crowd.crowdName.includes(searchValue) }) }, 'search' (e) { const { searchValue } = this.updater.get() const list = this.searchCrowds(searchValue) this.updater.digest({ list }) } })