| | |
| | | import HeadView from '../view/HeadView'; |
| | | import TableBtnView from '../view/TableBtnView'; |
| | | import CommonSearchForm from '../view/CommonSearchForm'; |
| | | import { Divider, Modal, message, Button, Progress } from 'antd' |
| | | import { Divider, Modal, message, Button, Row, Col, Progress, Input, Upload, Icon } from 'antd' |
| | | import moment from 'moment' |
| | | import Fetch from '../fetch'; |
| | | import { domain } from '../fetch/_fetch'; |
| | | import TableView from '../view/TableView'; |
| | | const confirm = Modal.confirm; |
| | | const { TextArea } = Input; |
| | | function typeOfName(type) { |
| | | switch (type) { |
| | | case 0: |
| | |
| | | this.state = { |
| | | data: [], |
| | | resetKey: Date.now(), |
| | | loading:false, |
| | | loading: false, |
| | | confirmLoading: false, |
| | | modal: false, |
| | | closeKey: Date.now(), |
| | | formData: { |
| | | __key: Date.now(), |
| | | activityType: '', |
| | | activityStatus: '', |
| | | startTime: '', |
| | | endTime: '', |
| | | } |
| | | }, |
| | | savedate: {}, |
| | | fileList: [], |
| | | previewVisible: false, |
| | | previewImage: '', |
| | | }; |
| | | } |
| | | |
| | | componentDidMount() { |
| | | document.title = '活动管理'; |
| | | document.title = '法治活动'; |
| | | this.getData(); |
| | | } |
| | | |
| | |
| | | }); |
| | | } |
| | | |
| | | handlePreview = (file) => { |
| | | this.setState({ |
| | | previewImage: file.url || file.thumbUrl, |
| | | previewVisible: true, |
| | | }); |
| | | } |
| | | |
| | | handleOk = () => { |
| | | console.log('success') |
| | | this.setState({ confirmLoading: true }); |
| | | const { savedate } = this.state; |
| | | console.log(savedate) |
| | | |
| | | if (!savedate.result) { |
| | | return message.warning("培训结果不能为空"); |
| | | } |
| | | Fetch.addResult({ ...savedate }) |
| | | .then(res => { |
| | | console.log(res) |
| | | if (res.code === 0) { |
| | | this.setState({ |
| | | confirmLoading: false, |
| | | modal: false, |
| | | closeKey: Date.now() |
| | | }, this.getData); |
| | | message.success("提交成功!") |
| | | } else { |
| | | message.error('保存失败,请联系管理员', 2) |
| | | } |
| | | }); |
| | | } |
| | | |
| | | handleCancel = () => { |
| | | this.setState({ |
| | | closeKey: Date.now(), |
| | | modal: false |
| | | }); |
| | | } |
| | | |
| | | searchonClick = data => { |
| | | console.log('form', data); |
| | | this.setState({ |
| | | formData: data, |
| | | }); |
| | | this.getData(); |
| | | } |
| | | |
| | | getData = () => { |
| | | // this.setState({ |
| | | // data: [] |
| | | // }); |
| | | this.setState({loading:true}) |
| | | this.setState({ loading: true }) |
| | | Fetch.activeManage({ ...this.state.formData }) |
| | | .then(res => { |
| | | for (var i = 0; i < res.length; i++) { |
| | |
| | | } |
| | | this.setState({ |
| | | data: res, |
| | | loading:false |
| | | loading: false |
| | | }); |
| | | }); |
| | | } |
| | | |
| | | saveInputChange = ({ target: { value, name } }) => { |
| | | this.setState(({ savedate }) => ({ |
| | | savedate: { |
| | | ...savedate, |
| | | [name]: value |
| | | } |
| | | })) |
| | | } |
| | | |
| | | getData = () => { |
| | | // 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, |
| | | loading: false |
| | | }); |
| | | }); |
| | | } |
| | |
| | | |
| | | signIn = (id) => { |
| | | window.open('index.html#/signIn/' + id); |
| | | } |
| | | |
| | | addResult = (id) => { |
| | | this.setState(({ savedate }) => ({ |
| | | savedate: { |
| | | ...savedate, |
| | | id: id |
| | | }, |
| | | modal: true |
| | | })) |
| | | } |
| | | |
| | | pulish = (id) => { |
| | |
| | | <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> |
| | | record.status == 3 ? |
| | | <span> |
| | | <label className='theme-color' onClick={() => this.showModal(record.id)} style={{ cursor: 'pointer' }}>查看</label> |
| | | {!record.result && |
| | | <React.Fragment> |
| | | <Divider type="vertical" /> |
| | | <label className='theme-color' onClick={() => this.addResult(record.id)} style={{ cursor: 'pointer' }}>添加结果</label> |
| | | </React.Fragment> |
| | | } |
| | | </span> |
| | | : |
| | | <span><label className='theme-color' onClick={() => this.showModal(record.id)} style={{ cursor: 'pointer' }}>查看</label></span> |
| | | |
| | | ) |
| | | ), |
| | | }]; |
| | | const { data, resetKey, formData, loading } = this.state; |
| | | const { data, previewImage, formData, loading, modal, fileList, previewVisible, confirmLoading, closeKey, savedate } = this.state; |
| | | const props = { |
| | | action: domain + 'api/v1/attachment/materials?associateTypeId=1020&entityId=' + savedate.id, |
| | | onChange: ({ file, fileList }) => { |
| | | this.setState({ fileList }); |
| | | }, |
| | | fileList: fileList, |
| | | onRemove: (file) => { |
| | | Fetch.deleteAttachment(file.uid) |
| | | .then(res => { |
| | | message.success("移除成功!"); |
| | | }); |
| | | this.setState(({ fileList }) => { |
| | | const index = fileList.indexOf(file); |
| | | const newFileList = fileList.slice(); |
| | | newFileList.splice(index, 1); |
| | | return { |
| | | fileList: newFileList, |
| | | }; |
| | | }); |
| | | } |
| | | }; |
| | | return ( |
| | | <div className="app-page" > |
| | | <HeadView history={this.props.history} /> |
| | |
| | | ]} /> |
| | | <TableView columns={columns} data={data} pageSize='10' size='default' loading={loading} /> |
| | | </div> |
| | | <Modal |
| | | key={closeKey} |
| | | confirmLoading={confirmLoading} |
| | | visible={modal} |
| | | width={'50%'} |
| | | title="添加结果" |
| | | onOk={this.handleOk} |
| | | onCancel={this.handleCancel} |
| | | > |
| | | <Row type="flex" align='middle' style={{ margin: '12px 0' }} justify="space-around"> |
| | | <Col span={6} pull={0} style={{ textAlign: 'center' }}><span>培训结果</span></Col> |
| | | <Col span={18} push={0} ><TextArea rows={4} placeholder="请输入培训结果" value={savedate.result || ""} onChange={this.saveInputChange} name='result' /></Col> |
| | | </Row> |
| | | <Row type="flex" align='middle' justify="space-around"> |
| | | <Col span={6} pull={0} style={{ textAlign: 'center' }}><span>培训材料</span></Col> |
| | | <Col span={18} push={0} > |
| | | <Upload listType="picture-card" onPreview={this.handlePreview} {...props}> |
| | | <div> |
| | | <Icon type="plus" /> |
| | | <div className="ant-upload-text">上传图片</div> |
| | | </div> |
| | | </Upload> |
| | | <Modal visible={previewVisible} footer={null} onCancel={this.handleCancel}> |
| | | <img alt="example" style={{ width: '100%' }} src={previewImage} /> |
| | | </Modal> |
| | | </Col> |
| | | </Row> |
| | | </Modal> |
| | | </div> |
| | | ); |
| | | } |