From 2bcd556961208b80af1cb157633c594faab1eca2 Mon Sep 17 00:00:00 2001
From: liuwh <liuwh@hugeinfo.com.cn>
Date: Mon, 24 Feb 2020 00:11:18 +0800
Subject: [PATCH] 小程序代码

---
 SunshineIns/src/page/ActiveManage.jsx |  172 +++++++++++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 142 insertions(+), 30 deletions(-)

diff --git a/SunshineIns/src/page/ActiveManage.jsx b/SunshineIns/src/page/ActiveManage.jsx
index 2d1d66e..bc789c1 100644
--- a/SunshineIns/src/page/ActiveManage.jsx
+++ b/SunshineIns/src/page/ActiveManage.jsx
@@ -1,17 +1,13 @@
-/**
- * 徐祥健<xuxj@hugeinfo.com.cn>
- * 2018年8月28日 10:41
- *
- */
-
 
 import React from 'react';
 
 import HeadView from '../view/HeadView';
 import TableBtnView from '../view/TableBtnView';
-import { Divider, Modal, message, Tooltip, Progress } from 'antd'
+import CommonSearchForm from '../view/CommonSearchForm';
+import { Divider, Modal, message, Button, 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,12 +24,59 @@
             return '已摇号';
     }
 }
+
+function typeStatus(type) {
+    switch (type) {
+        case 'act_1':
+            return "南检活动";
+        case 'act_2':
+            return "法治培训";
+        case 'act_3':
+            return "普法预约";
+    }
+}
+
+const taskNodeIds = {
+    'act_1': '南检活动',
+    'act_2': '法治培训',
+    'act_3': '普法预约',
+}
+
+const activityTypeList = [
+    'act_1',
+    'act_2',
+    'act_3',
+]
+
+const activityStatusIds = {
+    0: '未发布',
+    1: '报名中',
+    2: '活动中',
+    3: '已结束',
+    100: '已摇号',
+}
+
+const activityStatusList = [
+    0,
+    1,
+    2,
+    3,
+    100,
+]
 export default class ActiveManage extends React.Component {
     constructor(props) {
         super(props);
         this.state = {
             data: [],
-            resetKey: Date.now()
+            resetKey: Date.now(),
+            loading:false,
+            formData: {
+                __key: Date.now(),
+                activityType: '',
+                activityStatus: '',
+                startTime: '',
+                endTime: '',
+            }
         };
     }
 
@@ -41,14 +84,35 @@
         document.title = '活动管理';
         this.getData();
     }
+
+    setFormData = data => {
+        console.log('form', data);
+        this.setState({
+            formData: data,
+        });
+    }
+
+    searchonClick = data => {
+        console.log('form', data);
+        this.setState({
+            formData: data,
+        });
+        this.getData();
+    }
+
     getData = () => {
-        Fetch.activeManage()
+        // this.setState({
+        //     data: []
+        // });
+        this.setState({loading:true})
+        Fetch.activeManage({ ...this.state.formData })
             .then(res => {
                 for (var i = 0; i < res.length; i++) {
                     res[i]['index'] = i + 1;
                 }
                 this.setState({
-                    data: res
+                    data: res,
+                    loading:false
                 });
             });
     }
@@ -56,21 +120,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 +165,12 @@
             title: '序号',
             dataIndex: 'index',
             key: 'index'
-        },{
+        }, {
+            title: '活动类型',
+            dataIndex: 'activityType',
+            key: 'activityType',
+            render: text => <span>{typeStatus(text)}</span>
+        }, {
             title: '活动标题',
             dataIndex: 'title',
             key: 'title'
@@ -124,15 +197,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,17 +211,58 @@
                             <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>
 
                 )
             ),
         }];
-        const { data, resetKey } = this.state;
+        const { data, resetKey, formData, loading } = this.state;
         return (
-            <div className="app-page">
+            <div className="app-page" >
                 <HeadView history={this.props.history} />
-                <TableBtnView key={-resetKey} type="infoManage" name='活动一览' btnName='活动发布' onClick={() => this.showModal('new')}>
-                </TableBtnView>
-                <TableView columns={columns} data={data} pageSize='10' size='default' />
+                <div style={{ marginLeft: '90%', marginBottom: '20px', marginTop: '20px' }}>
+                    <Button type="primary" size='large' onClick={() => this.showModal('new')}>活动发布</Button>
+                </div>
+                {/* <TableBtnView key={-resetKey} type="infoManage" name='活动一览' btnName='活动发布' onClick={() => this.showModal('new')}>
+                </TableBtnView> */}
+                <div style={{ background: '#fff', margin: 20 }}>
+                    <CommonSearchForm
+                        {...this.props}
+                        formData={formData}
+                        setFormData={this.setFormData}
+                        searchonClick={this.searchonClick}
+                        pathName={this.props.location.pathname}
+                        data={[
+                            {
+                                type: 'select', name: '活动类型', label: '活动类型', key: 'activityType', list: activityTypeList.map(key => ({
+                                    id: key,
+                                    name: taskNodeIds[key]
+                                })),
+                            },
+                            {
+                                type: 'select', name: '活动状态', label: '活动状态', key: 'activityStatus', list: activityStatusList.map(key => ({
+                                    id: key,
+                                    name: activityStatusIds[key]
+                                })),
+                            },
+                            {
+                                type: 'rangePicker',
+                                label: '任务生成时间',
+                                name: JSON.stringify(['开始时间', '结束时间']),
+                                key: JSON.stringify(['startTime', 'endTime']),
+                                keylistName: 'rangeTimelist',
+                            },
+                        ]} />
+                    <TableView columns={columns} data={data} pageSize='10' size='default' loading={loading} />
+                </div>
             </div>
         );
     }

--
Gitblit v1.8.0