import * as Sub from 'dmp-new/gallery/mx-table/sub' import * as View from 'dmp-new/view' import Magix from 'magix' Magix.applyStyle('@./list.less') // const noExpandTypes = [41, 42, 46, 47] //支持打开子标签列表的人群类型 //1: 默认人群类型 //14: 数据银行 //30: 粉丝洞察创建的人群 //74: 人群组合 //47: 人群工厂 const expandTypes = [1, 14, 30, 74] const businessTypePathMap = { 41: '/crowds/keywords', //关键词圈人 42: '/crowds/super-new', //超级新用户 47: '/crowds/custom', //自定义人群 48: '/crowds/polaris-crowd', //新用户拓展 49: '/crowds/create?isRemarketing=true', //再营销圈人 50: '/crowds/lbs/create', //lbs线下圈人 64: '/crowds/lbs/create-building', //lbs线下圈楼 74: '/crowds/custom?isCombine=true' //自定义组合人群 } const tagMarketPath = '/crowds/create' //标签市场圈人 const YOUKU_ADM_IDS = [32, 108] const sceneMap = { '0': '自定义场景', '1': '拉新场景', '2': '维旧场景', '3': '大促场景' } const DONGFENG_ID = 35 //东风系统id const listTypeMap = [{ text: '我的营销人群', value: '1' }, { text: '合作方人群', value: '2' }] const crowdVersionTypes = [{ text: '旧版人群', value: '2' }] export default View.extend({ tmpl: '@list-table.html', mixins: [Sub], init(options) { this.options = options this.observeLocation(['currentPage', 'pageSize', 'crowdName', 'groupId', 'status', 'listType', 'crowdNew']) if (options.selectedCrowd) { this._selectedCrowd = options.selectedCrowd } }, async render(timeStamp) { let me = this let user = this.updater.get('user') let all = this.updater.get('all') let isXiaoer = user.loginUser.operType == all.xiaoerOperType let isDmp = user.loginUser.operType == all.dmpOperType let isIsv = user.loginUser.operType == all.isvOperType const loc = Magix.Router.parse() let groups = await this.getGroups() const status = [{ title: '全部状态', value: '' }, { title: '已同步', value: '2' }, { title: '准备中', value: '1' }, { title: '未同步', value: '0' }] let listType = this.options.listType || loc.get('listType') || '1' this.updater.set({ isIsv, isDmp, timeStamp, listType, crowdVersionTypes, sceneMap, DONGFENG_ID, listTypeMap, isCustom: this.options.isCustom, selectedCrowdId: this._selectedCrowd && this._selectedCrowd.crowdId, isSelect: this.options.isSelect, isXiaoer, expandTypes, xiaoerOperType: all.xiaoerOperType, groups, status, YOUKU_ADM_IDS, computeBatchSyncChecked(params) { let batchSyncAccounts = me.updater.get('batchSyncAccounts') for (const item of batchSyncAccounts) { if (params.channel.id == DONGFENG_ID && isXiaoer) { //东风渠道特殊处理 if (item.appId == params.channel.id && item.ext.agentId.includes(params.account.targetId + '')) { return 'checked' } } else { if (item.appId == params.channel.id && item.targets.includes(params.account.targetId + '')) { return 'checked' } } } } }) let crowds = await this.getCrowds() this.addTagListToCrowds(crowds) let list = crowds.list let pager = crowds.pager let checked = this.updater.get('checked') || [] $.extend(true, pager, loc.params) me.updater.set({ list, pager, isShowMove: false, isShowBatchSync: false, batchSyncIndex: 0, batchSyncAccounts: [], // checked //选中的人群 }) me.updater.digest({ isCheckAll: me.getIsCheckAll() }) }, //从人群列表的selectTagOptionSet获取所有标签列表,打平附加到人群列表的allSet里 addTagListToCrowds(crowds) { for (const crowd of crowds.list) { crowd.allSet = this.getAllSet(crowd) } }, getAllSet(crowd) { let allSet = [] if (crowd.selectTagOptionSet) { function recur(selectTagOptionSet) { for (const item of selectTagOptionSet) { if (item.selects && item.selects.length) { allSet.push(item) } if (item.selectTagOptionSet && item.selectTagOptionSet.length) { recur(item.selectTagOptionSet) } } } recur([crowd.selectTagOptionSet]) } return allSet }, //线下数据圈人浮层 'createLbs'(e) { let d = this.mxDialog('@./create-lbs-modes', { }, { width: 400 }); }, getIsCheckAll() { let list = this.updater.get('list') || [] let checked = this.updater.get('checked') || [] let isAll = true for (const item of list) { if (!checked.includes(item.crowdId)) { isAll = false break } } return isAll }, //获取人群分组 async getGroups() { try { let models = [{ name: 'api_crowd_group_get' }] let [model] = await this.fetch(models) let data = model.get('data.groups', []) data.unshift({ groupName: '全部营销人群', id: '' }) return data } catch (error) { this.alert('错误提示', error.msg) } }, //获取人群列表 async getCrowds() { let loc = Magix.Router.parse() const params = $.extend(true, {}, loc.params) params.pageSize = params.pageSize || 20 let groups = this.updater.get('groups') || [] let status = this.updater.get('status') || [] let list = this.updater.get('list') || [] let pager = this.updater.get('pager') || {} let checked = this.updater.get('checked') || [] let user = this.updater.get('user') this.updater.digest({ checked, list, pager, groups, status, loading: true }) //合作方人群listType=2 //我的人群listType=1 params.listType = this.updater.get('listType') //LBS线下圈楼里选择人群,固定参数 if (this.updater.get('isSelect')) { params.idType = 1 //筛选非LBS人群 params.status = 3 //有效人群 } // try { // const params = {} // return data // } catch (error) { // console.error(error) // } try { const models = [{ name: 'api_crowd__get', params }] const [model] = await this.fetch(models) const data = model.get('data', {}) //有策略中心权限,并且人群是数据银行的,屏蔽渠道、删除、授权代投按钮等,显示跳转策略中心链接按钮 for (const item of data.list) { if ((item.businessType == 14 || item.businessType == 34) && user.permissions.includes('STRATEGY_CENTER')) { item.isCelue = true } } this.updater.digest({ loading: false }) return data } catch (error) { this.updater.digest({ loading: false }) this.alert('错误提示', error.msg) } }, //获取标签信息,附加到人群里 async getTag(crowd) { let tags = [] let allSet = this.getAllSet(crowd) for (const set of allSet) { if (set.selects[0] && !set.selects[0].tagInfo) { tags.push(set.selects[0]) } } if (tags.length) { try { let models = [] for (const tag of tags) { models.push({ name: 'api_tag_$id_get', pathParams: [tag.tagId] }) } let respModels = await this.fetch(models) respModels.forEach((item, i) => { let tag = item.get('data.tag') tags[i].tagInfo = tag }) } catch (error) { this.alert('错误提示', error.msg) } } }, //修改标签选项 async 'editTag'(e) { const list = this.updater.get('list') let tag = e.params.tag const me = this let crowd = e.params.crowd this.mxDialog('@./tag-select', { tagId: tag.selects[0] && tag.selects[0].tagId, tagSelected: tag, async callback(_tag) { for (const group of _tag.optionGroups) { for (const select of tag.selects) { if (group.id == select.optionGroupId) { select.names = group.selected.names.join(',') select.values = Array.isArray(group.selected.values) ? group.selected.values.join(',') : group.selected.values } } } me.updater.digest({ loading: true }) try { let models = [{ name: 'api_crowd_$id_put', pathParams: [crowd.crowdId], isJson: true, params: crowd }] let [model] = await me.fetch(models) me.render() } catch (error) { me.updater.digest({ loading: false }) me.alert('错误提示', error.msg) } } }, { width: 800, top: 100 }) }, //搜索品牌 async 'showBrands'(e) { // 输入框输入关键词时触发show // 当前输入框输入的值 let keyword = e.keyword; let instance = Magix.Vframe.get(this.id + '_brandSearch'); instance.invoke('showLoading'); let [model] = await this.fetch({ name: 'api_deliver_dongfeng_brand_get', params: { keyword } }) let list = model.get('data', []) this._brands = list instance.invoke('update', [list]); instance.invoke('hideLoading'); }, //选择品牌 'selectBrand'(e) { const channels = this.updater.get('channels') let dongfengChannel for (const channel of channels) { if (channel.id == DONGFENG_ID) { dongfengChannel = channel } } for (const brand of this._brands) { if (brand.id == e.selected) { dongfengChannel.accounts = [] for (const agent of brand.agentList) { dongfengChannel.accounts.push({ targetId: agent.id, nickname: agent.name }) } } } if (!e.selected) { delete dongfengChannel.selected delete dongfengChannel.selectedItem delete dongfengChannel.accounts } this.updater.digest({ channels }) }, //移除标签 async 'removeTag'(e) { let mainSet = e.params.mainSet let excludeSet = e.params.excludeSet let orSet = e.params.orSet let index = e.params.index let crowd = e.params.crowd let setType = e.params.setType const me = this this.confirm({ title: '提示', content: '确定要删除标签吗?', mask: true, async enterCallback() { if (mainSet.length === 1 && excludeSet.length === 0 || excludeSet.length === 1 && mainSet.length === 0) { return me.alert('提示', '至少保留一个标签', null, { mask: true }) } switch (setType) { case 1: mainSet.splice(index, 1) break; case 2: orSet.splice(index, 1) break; case 3: excludeSet.splice(index, 1) break; } me.updater.digest({ loading: true }) try { let models = [{ name: 'api_crowd_$id_put', pathParams: [crowd.crowdId], isJson: true, params: crowd }] let [model] = await me.fetch(models) me.render() } catch (error) { me.updater.digest({ loading: false }) me.alert('错误提示', error.msg) } } } }, async searchAccount(e) { let channel = e.params.channel let channels = this.updater.get('channels') if (!channel._nickname.trim()) { return } channel.selected = channel.selected || [] channel.accounts = [] this.updater.digest({ loadingAccounts: true, channels }) try { let models = [{ name: 'api_user_find_get', params: { nickname: channel._nickname, pageSize: 150 } }] let [model] = await this.fetch(models) let users = model.get('data.users', []) for (const user of users) { user.targetId = user.memberId } channel.accounts = users this.updater.digest({ channels }) } catch (error) { this.alert('错误提示', error.msg || error.message) } this.updater.digest({ loadingAccounts: false }) }, 'searchAccount'(e) { if (e.keyCode === 13) { this.searchAccount(e) } }, 'searchAccount'(e) { this.searchAccount(e) }, async 'batchSync'(e) { let isShowBatchSync = this.updater.get('isShowBatchSync') let checked = this.updater.get('checked') if (!checked || !checked.length) { return this.alert('提示', '请至少选择一个人群', null, { mask: true }) } if (!isShowBatchSync) { this.updater.digest({ isShowBatchSync: true, getChannelsLoading: true }) let channels = await this.getChannels() this.updater.digest({ channels, getChannelsLoading: false }) } else { this.updater.digest({ isShowBatchSync: false }) } }, async getChannels(e) { let crowdId = this.updater.get('checked').join(',') let user = this.updater.get('user') try { let models = [{ name: 'api_deliverapp_deliverapplist_get', params: { crowdId } }] let [model] = await this.fetch(models) let list = model.get('data.list', []) if (!this.updater.get('isXiaoer')) { //商家版 let _models = [] for (const item of list) { _models.push({ name: 'api_crowd_appUser__get', params: { crowdId, appId: item.id, memberId: user.loginUser.userId } }) } let respModels = await this.fetch(_models) respModels.forEach((model, i) => { list[i].accounts = model.get('data.list', []) }) } else { //小二版 for (const channel of list) { if (YOUKU_ADM_IDS.includes(channel.id)) { channel.accounts = [{ nickname: '优酷ADM', targetId: 117810562 }] } } } return list } catch (error) { this.alert('错误提示', error.msg) } }, 'moveTo'(e) { let isShowMove = this.updater.get('isShowMove') this.updater.digest({ isShowMove: !isShowMove }) }, 'cancelMove'(e) { this.updater.digest({ isShowMove: false }) }, 'batchSyncSwitch'(e) { let index = e.params.index this.updater.digest({ batchSyncIndex: index }) }, // api_crowd_multi_app_post async 'confirmMove'(e) { let moveToGroup = this.updater.get('moveToGroup') let checked = this.updater.get('checked') if (moveToGroup === undefined) { return this.alert('提示', '请选择一个人群分组', null, { mask: true }) } if (!checked || !checked.length) { return this.alert('提示', '请至少选择一个人群', null, { mask: true }) } try { let models = [{ name: 'api_crowd_group_$id_put', params: { crowdIds: checked.join(','), groupId: moveToGroup } }] let [model] = await this.fetch(models) this.updater.digest({ isShowMove: false }) this.render() // let data = model.get('data') // return data } catch (error) { this.alert('错误提示', error.msg) } }, async 'confirmSync'(e) { let checked = this.updater.get('checked') let batchSyncAccounts = this.updater.get('batchSyncAccounts') if (!batchSyncAccounts.length) { return this.alert('提示', '请至少勾选一个渠道', null, { mask: true }) } try { let models = [{ name: 'api_crowd_multi_app_post', params: { crowdIds: checked.join(','), apps: JSON.stringify(batchSyncAccounts) } }] let [model] = await this.fetch(models) this.updater.digest({ isShowBatchSync: false }) this.render() // let data = model.get('data') // return data } catch (error) { this.alert('错误提示', error.msg) } }, 'cancelSync'(e) { this.updater.digest({ isShowBatchSync: false }) }, // setSelectedCrowd(crowdId) { let crowds = this.updater.get('list') for (const crowd of crowds) { if (crowd.crowdId == crowdId) { this._selectedCrowd = crowd break } } }, //选择人群 'selectCrowd'(e) { this.setSelectedCrowd(this.updater.get('selectedCrowdId')) }, 'selectAccount'(e) { let { all, checked, batchSyncAccounts } = this.updater.get() let account = e.params.account let channel = e.params.channel if (e.target.checked) { // all.dongfengTargetId //其他渠道 let match batchSyncAccounts.forEach((item, i) => { if (channel.id == item.appId) { match = true //东风渠道特殊处理, if (channel.id == DONGFENG_ID) { item.ext = { "brandId": channel.selectedItem.value, "agentId": account.targetId.toString() } } else { let targets = item.targets.split(',') targets.push(account.targetId) item.targets = targets.join(',') } } }) if (!match) { let _account = { crowdId: checked.join(','), appId: channel.id, targets: '' } if (channel.id == DONGFENG_ID) { _account.targets = all.dongfengTargetId _account.ext = { "brandId": channel.selectedItem.value, "agentId": account.targetId.toString() } } else { _account.targets = [account.targetId].join(',') } batchSyncAccounts.push(_account) } } else { batchSyncAccounts.forEach((item, i) => { if (channel.id == item.appId) { let targets = item.targets.split(',') let matchIndex targets.forEach((target, _i) => { if (target == account.targetId) { matchIndex = _i } }); (matchIndex !== undefined) && targets.splice(matchIndex, 1) if (targets.length === 0) { batchSyncAccounts.splice(i, 1) } } }) } this.updater.digest({ batchSyncAccounts }) }, //同步给小二版 async 'syncx2'(e) { let crowdIds = e.params.id try { let models = [{ name: 'api_crowd_sync_x2_post', params: { crowdIds } }] let [model] = await this.fetch(models) this.alert('提示', '恭喜,人群授权成功', () => { this.render() }, { mask: true }) } catch (error) { this.alert('错误提示', error.msg || error.message || error) } }, //取消同步给小二版 async 'cancelSyncx2'(e) { let crowdIds = e.params.id try { let models = [{ name: 'api_crowd_sync_x2_delete', urlParams: { crowdIds } }] let [model] = await this.fetch(models) this.alert('提示', '人群取消授权成功', () => { this.render() }, { mask: true }) } catch (error) { this.alert('错误提示', error.msg || error.message || error) } }, 'selectOne'(e) { let checked = this.updater.get('checked') || [] if (e.target.checked) { checked.push(e.params.crowdId) } else { checked.forEach((item, i) => { if (item == e.params.crowdId) { checked.splice(i, 1) } }) } this.updater.set({ checked }) this.updater.digest({ isCheckAll: this.getIsCheckAll() }) }, 'selectAll'(e) { let list = this.updater.get('list') let checked = this.updater.get('checked') || [] if (e.target.checked) { for (const item of list) { if (!checked.includes(item.crowdId)) { checked.push(item.crowdId) } } } else { for (const item of list) { let existIndex = checked.indexOf(item.crowdId) if (existIndex > -1) { checked.splice(existIndex, 1) } } } this.updater.set({ checked }) this.updater.digest({ isCheckAll: this.getIsCheckAll() }) }, 'crowdManage'(e) { const me = this let d = this.mxDialog('@./crowd-manage', { id: e.params.id, apps: e.params.apps }, { width: 350, top: 100 }) d.afterClose(() => { me.render() }) }, 'batchManage'(e) { let showSelect = this.updater.get('showSelect') this.updater.digest({ showSelect: !showSelect }) }, // 'addCrowd'(e) { this.options.crowdCallback({ crowdId: e.params.crowdId, crowdName: e.params.crowdName }) }, async 'showSub'(e) { const list = this.updater.get('list') let crowd = e.params.crowd await this.getTag(crowd) this.updater.digest({ list }) }, async 'copy'(e) { const { all, isDmp, isXiaoer, isIsv } = this.updater.get() let businessType = e.params.businessType let id = e.params.id let crowd = e.params.crowd // let defaultPath = (crowd.extra.DMP_PLUS == '1' && isDmp) ? '/crowds-new/create' : tagMarketPath let path = businessTypePathMap[businessType] || tagMarketPath if (crowd.crowdNew == '1' && !isIsv && !isXiaoer) { path = '/crowds-new/create' } //74是人群组合工厂,需要判断下是否超出可创建人群的上限 const combineCrowdBusinessType = 74 if (businessType == combineCrowdBusinessType) { let models = [{ name: 'api_crowd__get', params: { pageSize: 30, businessType: combineCrowdBusinessType } }] let [model] = await this.fetch(models) let crowds = model.get('data.list', []) if (crowds.length >= all.combineCrowdsLimit) { return this.mxDialog('@./combine-crowds-popup', { crowd, isCopy: true, id, crowds }, { top: 100, width: 600 }) } } let routeParams = { id, isCopy: true } if ((isIsv || isXiaoer) && crowd.crowdNew == '1') { routeParams.newGroupType = isXiaoer ? 10 : 7 } Magix.Router.to(path, routeParams) }, 'channel'(e) { const me = this let d = this.mxDialog('@../crowds-new/channels', { id: e.params.id, apps: e.params.apps, coverage: e.params.coverage }, { width: 920, top: 100 }) d.afterClose(() => { me.render() }) }, //批量授权小二版人群 'batchSyncx2'(e) { let checked = this.updater.get('checked') const me = this if (!checked || !checked.length) { return this.alert('提示', '请至少选择一个人群', null, { mask: true }) } this.confirm({ title: '提示', mask: true, content: '确定要批量授权这些人群吗?', async enterCallback() { try { let models = [{ name: 'api_crowd_sync_x2_post', params: { crowdIds: checked.join(',') } }] await me.fetch(models) me.render() } catch (error) { me.alert('错误提示', error.msg) } } }) }, 'batchRemove'(e) { let checked = this.updater.get('checked') const me = this if (!checked || !checked.length) { return this.alert('提示', '请至少选择一个人群', null, { mask: true }) } this.confirm({ title: '提示', mask: true, content: '确定要批量删除吗?', async enterCallback() { try { let models = [{ name: 'api_crowd_crowds__delete', pathParams: [checked.join(',')] }] await me.fetch(models) me.render(new Date().getTime()) } catch (error) { me.alert('错误提示', error.msg) } } }) }, //轮询查询人群是否dump完毕,dump完毕的人群才能计算相似度 async getStatusPolling(crowdId) { const me = this return new Promise(async resolve => { async function polling() { try { let params = { crowdId, bizId: 2 } let models = [{ name: 'api_crowd_accelerate_task_post', params, isJson: true }] let [model] = await me.fetch(models) let status = model.get('data') // status=1,数据还在准备中 // status=2,数据准备完毕 if (me.isSimilarConfirm) { resolve(true) } else if (status == 2) { resolve() } else { setTimeout(async () => { await polling() }, 1000) } } catch (error) { alert(error.msg) resolve(false) } } await polling() }) }, //计算两个人群的相似度 async computeSimilar(checked) { try { let models = [{ name: 'api_analysis_crowd_similarity_post', params: { crowdIds: checked }, isJson: true }] let [model] = await this.fetch(models) let similarity = model.get('data.similarity') return similarity } catch (error) { this.alert('错误提示', error.msg || error.message) } }, //查看两个人群的相似度 async 'similar'(e) { const me = this const Accounting = this.updater.get('Accounting') const checked = this.updater.get('checked') if (checked.length != 2) { return } me.isSimilarConfirm = false const dialog = this.alert('提示', '人群相似度计算中,请稍候...(大约耗时2分钟)', () => { me.isSimilarConfirm = true }, { mask: true }); let [isConfirm1, isConfirm2] = await Promise.all([this.getStatusPolling(checked[0]), this.getStatusPolling(checked[1])]) if (isConfirm1 === false || isConfirm2 === false) { dialog.close() } else if (isConfirm1 === undefined && isConfirm2 === undefined) { let similarCount = await this.computeSimilar(checked) dialog.close() dialog.afterClose(() => { me.alert('提示', `人群相似度计算完毕,相似度为${Accounting.formatNumber(similarCount * 100, 2)}%`, null, { mask: true }) }) } }, async 'edit'(e) { let { isDmp, isXiaoer, isIsv } = this.updater.get() let { businessType, id, apps, crowd } = e.params let { extra } = crowd var me = this; let syncApps = [] //先判断能不能删除 if (!this.updater.get('isXiaoer') && !await this.crowdCanEdit(id)) { return } for (const app of apps) { if (app.status == 1 || app.status == 2) { syncApps.push(app) } } if (syncApps.length) { this.confirm({ mask: true, title: '营销人群修改', content: `该营销人群已被 ${syncApps.map(app => { return app.appName }).join('、')} 这些渠道应用,修改后会对投放渠道造成影响!您确认要修改该营销人群?`, enterCallback() { goto() } }) } else { goto() } function goto() { let path = businessTypePathMap[businessType] || tagMarketPath // crowdNew=1 为新版人群,2为旧版人群 if ((crowd.crowdNew == '1' || extra.DMP_PLUS == '1') && !isXiaoer && !isIsv) { path = '/crowds-new/create' } let routeParams = { id } if ((isXiaoer || isIsv) && crowd.crowdNew == '1') { routeParams.newGroupType = isXiaoer ? 10 : 7 } Magix.Router.to(path, routeParams) } }, //根据接口判断人群能否修改 async crowdCanEdit(crowdId) { try { let models = [{ name: 'api_crowd_$id_edit_check_get', pathParams: [crowdId, 'edit', 'check'] }] let [model] = await this.fetch(models) return true } catch (error) { this.alert('错误提示', error.msg || error.message || error, null, { mask: true }) return false } }, //添加追踪 async 'trace'(e) { try { const all = this.updater.get('all') const user = this.updater.get('user') let params = { crowdIds: e.params.id } // 1:商家版新潜老,2:小二版aipl if (user.loginUser.operType == all.xiaoerOperType) { params.trackType = '2' } let models = [{ name: 'api_crowd_track_put', params }] await this.fetch(models) this.alert('提示', '添加人群追踪成功,请至人群追踪列表查看', () => { this.render() }, { mask: true }) } catch (error) { this.alert('错误提示', error.msg || error.message, null, { mask: true }) } }, //批量追踪 'batchTrace'(e) { let checked = this.updater.get('checked') const me = this if (!checked || !checked.length) { return this.alert('提示', '请至少选择一个人群', null, { mask: true }) } const all = this.updater.get('all') const user = this.updater.get('user') let params = { crowdIds: checked.join(',') } // 1:商家版新潜老,2:小二版aipl if (user.loginUser.operType == all.xiaoerOperType) { params.trackType = '2' } this.confirm({ title: '提示', mask: true, content: '确定要批量追踪这些人群吗?', async enterCallback() { try { let models = [{ name: 'api_crowd_track_put', params }] await me.fetch(models) me.render() } catch (error) { me.alert('错误提示', error.msg) } } }) }, 'deleted'(e) { let id = e.params.id const me = this let apps = e.params.apps let syncApps = [] for (const app of apps) { if (app.status == 1 || app.status == 2) { syncApps.push(app) } } if (syncApps.length) { this.confirm({ mask: true, title: '营销人群删除', content: `该营销人群已被 ${syncApps.map(app => { return app.appName }).join(',')} 这些渠道应用,删除后会对投放渠道造成影响!您确认要删除该营销人群?`, enterCallback() { goto() } }) } else { this.confirm({ mask: true, title: '营销人群删除', content: `确定要删除 『${e.params.crowdName}』 吗?`, enterCallback() { goto() } }) } async function goto() { try { let models = [{ name: 'api_crowd_$id_delete', pathParams: [id] }] let [model] = await me.fetch(models) me.render(new Date().getTime()) } catch (error) { me.alert('不可删除', error.msg) } } }, 'search'(e) { if (e.keyCode === 13) { Magix.Router.to({ crowdName: e.target.value.trim(), currentPage: 1 }) } }, 'changeStatus'(e) { Magix.Router.to({ status: e.value, currentPage: 1 }) }, 'changeVersion'(e) { Magix.Router.to({ crowdNew: e.value, currentPage: 1 }) }, 'changeGroup'(e) { Magix.Router.to({ groupId: e.value, currentPage: 1 }) }, 'changeListType'(e) { Magix.Router.to({ listType: e.value, currentPage: 1 }) }, 'changePager'(e) { Magix.Router.to({ pageSize: e.size, currentPage: e.page }) }, 'showCreateCrowds'(e) { let viewPath = 'dmp-new/views/partials/create' let viewOpitons = {} let dialogOptions = { width: 1100, mask: true, top: 100 } this.mxDialog(viewPath, viewOpitons, dialogOptions) }, check() { const me = this return new Promise((resolve) => { let crowdId = me.updater.get('selectedCrowdId') let ok = !!crowdId resolve({ ok, // true or false,是否校验通过,false的时候不关闭按钮 msg: '请选择一个人群', data: { crowdId, crowdName: this._selectedCrowd && this._selectedCrowd.crowdName } }) }) } })