| | |
| | | import React, {Component} from 'react' |
| | | import PropTypes from 'prop-types' |
| | | import { is, fromJS } from 'immutable' |
| | | import { Spin, notification } from 'antd' |
| | | import { Spin, notification, Modal } from 'antd' |
| | | |
| | | import Api from '@/api' |
| | | import UtilsDM from '@/utils/utils-datamanage.js' |
| | |
| | | sync: false, // 是否统一请求数据 |
| | | data: [], // 数据 |
| | | html: '', |
| | | result: {} |
| | | } |
| | | |
| | | loaded = false |
| | |
| | | }, 10) |
| | | } |
| | | |
| | | let _result = {...result} |
| | | delete _result.data |
| | | |
| | | this.setState({ |
| | | data: _data, |
| | | result: _result, |
| | | loading: false |
| | | }) |
| | | |
| | | if (result.message) { |
| | | if (result.ErrCode === 'Y') { |
| | | Modal.success({ |
| | | title: result.message |
| | | }) |
| | | } else if (result.ErrCode === 'S') { |
| | | notification.success({ |
| | | top: 92, |
| | | message: result.message, |
| | | duration: 2 |
| | | }) |
| | | } |
| | | } |
| | | } else { |
| | | this.setState({ |
| | | loading: false |
| | | }) |
| | | notification.error({ |
| | | top: 92, |
| | | message: result.message, |
| | | duration: 10 |
| | | }) |
| | | |
| | | if (!result.message) return |
| | | if (result.ErrCode === 'N') { |
| | | Modal.error({ |
| | | title: result.message |
| | | }) |
| | | } else if (result.ErrCode !== '-2') { |
| | | notification.error({ |
| | | top: 92, |
| | | message: result.message, |
| | | duration: 10 |
| | | }) |
| | | } |
| | | } |
| | | } |
| | | |
| | | renderView = () => { |
| | | const { data } = this.state |
| | | const { data, result } = this.state |
| | | const { html, js, wrap, columns } = this.state.config |
| | | |
| | | let _html = html |
| | |
| | | if (js) { |
| | | try { |
| | | // eslint-disable-next-line |
| | | let evalfunc = eval('(true && function (data) {' + js + '})') |
| | | evalfunc(data) |
| | | // if (wrap.compileMode !== 'custom') { |
| | | // // eslint-disable-next-line no-eval |
| | | // eval(js) |
| | | // } else { |
| | | // // eslint-disable-next-line |
| | | // let evalfunc = eval('(true && function (data) {' + js + '})') |
| | | // evalfunc(data) |
| | | // } |
| | | let evalfunc = eval('(true && function (data, result) {' + js + '})') |
| | | evalfunc(data, result) |
| | | } catch (e) { |
| | | console.warn(e) |
| | | } |