forked from nsjcy/frontEnd/nsjcy

liuwh
2020-02-20 6383764128f9f38513df1a55449b230a7b29092a
SunshineIns/src/page/ActiveManage.jsx
@@ -12,6 +12,7 @@
import { Divider, Modal, message, Tooltip, Progress } from 'antd'
import moment from 'moment'
import Fetch from '../fetch';
import { domain } from '../fetch/_fetch';
import TableView from '../view/TableView';
const confirm = Modal.confirm;
function typeOfName(type) {
@@ -28,6 +29,17 @@
            return '已摇号';
    }
}
function typeStatus(type) {
    switch (type) {
        case 'act_1':
            return "南检活动";
        case 'act_2':
            return "法治培训";
        case 'act_3':
            return "普法预约";
    }
}
export default class ActiveManage extends React.Component {
    constructor(props) {
        super(props);
@@ -42,6 +54,9 @@
        this.getData();
    }
    getData = () => {
        // this.setState({
        //     data: []
        // });
        Fetch.activeManage()
            .then(res => {
                for (var i = 0; i < res.length; i++) {
@@ -56,21 +71,25 @@
        this.props.history.push("/activeManageEdit/" + id);
    }
    signIn= (id) => {
        window.open('index.html#/signIn/' + id);
    }
    pulish = (id) => {
        confirm({
            title: '确认要发布这条活动吗?',
            onOk: () => {
                Fetch.publishActive(id)
                  .then(data => {
                    if (data.code == 0) {
                      message.success("发布成功!")
                      this.setState({
                        resetKey: Date.now()
                      }, this.getData);
                    } else {
                      message.error('发布失败,请联系管理员', 2)
                    }
                  })
                    .then(data => {
                        if (data.code == 0) {
                            message.success("发布成功!")
                            this.setState({
                                resetKey: Date.now()
                            }, this.getData);
                        } else {
                            message.error('发布失败,请联系管理员', 2)
                        }
                    })
            }
        });
    }
@@ -97,7 +116,12 @@
            title: '序号',
            dataIndex: 'index',
            key: 'index'
        },{
        }, {
            title: '活动类型',
            dataIndex: 'activityType',
            key: 'activityType',
            render: text => <span>{typeStatus(text)}</span>
        }, {
            title: '活动标题',
            dataIndex: 'title',
            key: 'title'
@@ -124,15 +148,13 @@
            title: '报名人数',
            dataIndex: 'totalNum',
            key: 'totalNum',
            render: (_, { totalNum, applyNum }) => <Progress  percent={applyNum * 100 / totalNum} format={percent => `${applyNum}/${totalNum} `} />,
            render: (_, { totalNum, applyNum }) => <Progress percent={applyNum * 100 / totalNum} format={percent => `${applyNum}/${totalNum} `} />,
        }, {
            title: '操作',
            key: 'action',
            render: (text, record) => (
                (
                    record.status > 0 ? <span>
                        <label className='theme-color' onClick={() => this.showModal(record.id)} style={{ cursor: 'pointer' }}>查看</label></span>
                        :
                    record.status == 0 ?
                        <span>
                            <label className='theme-color' onClick={() => this.showModal(record.id)} style={{ cursor: 'pointer' }}>修改</label>
                            <Divider type="vertical" />
@@ -140,6 +162,15 @@
                            <Divider type="vertical" />
                            <label className='theme-color' onClick={() => this.deleteItems(record.id)} style={{ cursor: 'pointer' }}>删除</label>
                        </span>
                        :
                    record.status == 2 ?
                            <span>
                                <label className='theme-color' onClick={() => this.showModal(record.id)} style={{ cursor: 'pointer' }}>查看</label>
                                <Divider type="vertical" />
                                <label className='theme-color' onClick={() => this.signIn(record.id)} style={{ cursor: 'pointer' }}>签到上墙</label>
                            </span>
                    :
                    <span><label className='theme-color' onClick={() => this.showModal(record.id)} style={{ cursor: 'pointer' }}>查看</label></span>
                )
            ),