import Magix from 'magix' import * as View from '../../../view' Magix.applyStyle('@./show-project.less') export default View.extend({ tmpl: '@show-project.html', init (options) { this.options = options }, async render () { const list = await this.getList() this.updater.digest({ list, total: 20 }) }, async getList () { try { const params = { pageSize: 100 } const models = [{ name: 'api_analysis_plan_get', params }] const [model] = await this.fetch(models) const data = model.get('data.list', []) return data } catch (error) { this.alert('错误提示', error.msg || error.message || error, null, { mask: true }) } }, 'show' (e) { const { id } = e.params this.options.dialog.afterClose(() => { Magix.Router.to({ insightId: id }) }) this.options.dialog.close() }, async 'copy' (e) { const { index } = e.params const { list } = this.updater.get() const viewPath = '@./create-project' const viewOptions = { config: this.options.config, projectInfo: list[index], callback: () => { this.render() } } const dialogOptions = { top: 100 } this.mxDialog(viewPath, viewOptions, dialogOptions) }, async 'delete' (e) { const { id, index } = e.params const { list } = this.updater.get() this.confirm({ title: '提示', content: '方案删除后将不能恢复,确认删除吗?', enterCallback: async () => { try { const models = [{ name: 'api_analysis_plan_$id_delete', pathParams: [id] }] const [model] = await this.fetch(models) // let data = model.get('data') // return data list.splice(index, 1) this.updater.digest({ list }) } catch (error) { this.alert('错误提示', error.msg || error.message || error, null, { mask: true }) } } }) } })