| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354 |
- /**
- * Created by FANGlh on 2018/11/6 15:47.
- */
- import React, {Component} from 'react';
- import nextArrowimg from '../../../style/imgs/next_arrow.png';
- import './SendMeet.css';
- import 'antd/dist/antd.css';
- import {Select, TreeSelect, Icon, Button} from 'antd';
- import moment from 'moment';
- import add_newimg from '../../../style/imgs/add_new.png';
- import {fetchPost, fetchGet, fetchGetNoSession} from '../../../utils/fetchRequest';
- import {API} from '../../../configs/api.config';
- import {Toast, Picker, List, DatePicker} from 'antd-mobile';
- import {getIntValue, getStrValue, isObjEmpty} from "../../../utils/common";
- import TargetSelect from '../../../components/TargetSelect';
- import {connect} from 'react-redux';
- import {clearListState} from "../../../redux/actions/listState";
- const Option = Select.Option;
- class SendMeet extends Component {
- componentWillMount() {
- document.title = '发起会议'
- }
- componentDidMount() {
- this.getOrganization()
- }
- componentWillUnmount() {
- Toast.hide()
- clearTimeout(this.backTask)
- }
- getOrganization = () => {
- Toast.loading('', 0)
- fetchGet(API.getAllTeacher, {
- schoolId: this.props.userInfo.user.schoolId,
- }).then(response => {
- Toast.hide()
- const {targetData} = this.state
- targetData.length = 0
- if (response && response.data) {
- // const schoolArray = response.data.schools
- const teacherArray = response.data
- if (!isObjEmpty(teacherArray)) {
- const teacherData = []
- teacherArray.forEach((teacherObj, index) => {
- if (teacherObj) {
- teacherData.push({
- title: getStrValue(teacherObj, 'teacherName'),
- userId: getIntValue(teacherObj, 'teacherId'),
- userPhone: getStrValue(teacherObj, 'userPhone'),
- value: getStrValue(teacherObj, 'teacherName') + `-0-${index}`,
- key: `1-${index}`,
- })
- }
- })
- targetData.push({
- title: `全体老师`,
- value: `0`,
- key: `0`,
- selectable: false,
- children: teacherData,
- })
- }
- }
- console.log('targetData', targetData)
- this.setState({
- targetData,
- })
- }).catch(error => {
- Toast.hide()
- if (typeof error === 'string') {
- Toast.fail(error, 2)
- } else {
- Toast.fail('请求异常', 2)
- }
- })
- }
- constructor() {
- super();
- this.state = {
- targetList: [],
- targetCount: 0,
- targetData: [],
- startValue: null,
- endValue: null,
- endOpen: false,
- titleValue: null,
- contentValue: null,
- earlyTime: null,
- meetPerson: [],
- meetAddress: null,
- noticeType: [{
- label: '创建即提醒',
- value: '0'
- }, {
- label: '会前5分钟',
- value: 5
- }, {
- label: '会前15分钟',
- value: 15
- }, {
- label: '会前25分钟',
- value: 25
- }, {
- label: '会前35分钟',
- value: 35
- }]
- };
- }
- render() {
- const targetProps = {
- targetData: this.state.targetData,
- targetValues: this.state.targetList,
- title: '与会人',
- targetCount: this.state.targetCount,
- onTargetChange: this.onTargetChange.bind(this),
- onTargetFocus: this.onTargetFocus.bind(this)
- }
- const defaultTargetProps = {
- targetData: [],
- targetValues: this.state.targetList,
- title: '与会人',
- targetCount: this.state.targetCount,
- onTargetChange: this.onTargetChange.bind(this),
- onTargetFocus: this.onTargetFocus.bind(this)
- }
- return (
- <div onChange={this.handelValueCom} style={{fontFamily: "PingFangSC-Regular", letterSpacing: 2.5}}
- className='common-column-layout'>
- {/*<p>{new Date().getTime()}</p>*/}
- <textarea autoFocus="autoFocus" ref='meetTitle' className="form-control textarea_sty" rows="2"
- placeholder="请填写会议主题…" maxLength={20}></textarea>
- <textarea ref='meetAddress' className="form-control textarea_sty" rows="3"
- placeholder="请填写会议地址…" maxLength={50}></textarea>
- <div className="comhline_sty"></div>
- <div className="common-column-layout" style={{fontSize: 15}}>
- <DatePicker
- value={this.state.startValue}
- locale={{
- okText: '确定',
- dismissText: '取消'
- }}
- onChange={date => this.setState({startValue: date})}>
- <List.Item arrow="horizontal">会议开始时间</List.Item>
- </DatePicker>
- <div className="comhline_sty1"></div>
- <DatePicker
- value={this.state.endValue}
- locale={{
- okText: '确定',
- dismissText: '取消'
- }}
- onChange={date => this.setState({endValue: date})}>
- <List.Item arrow="horizontal">会议结束时间</List.Item>
- </DatePicker>
- <div className="comhline_sty1"></div>
- <Picker
- data={this.state.noticeType} title='提醒时间' extra='请选择'
- value={this.state.earlyTime}
- onChange={this.handleSelectChange}
- onOk={this.handleSelectChange} cols={1}>
- <List.Item arrow="horizontal">提醒时间</List.Item>
- </Picker>
- </div>
- <div className="comhline_sty1"></div>
- {this.state.targetData.length > 0 ? <TargetSelect {...targetProps}/>
- : <TargetSelect {...defaultTargetProps}/>}
- {/*<center><Button type="button" className="btn btn-primary comBtn_sty"*/}
- {/*onClick={this.doSaveClick}>创建</Button></center>*/}
- <Button className='commonButton' type='primary' style={{margin: '35px'}}
- onClick={this.doSaveClick}>创建</Button>
- </div>
- )
- }
- doSaveClick = (event) => {
- if (this.isRequesting == true) {
- return
- }
- console.log('state', this.state)
- if (this.state.titleValue == null || this.state.titleValue.trim().length == 0) {
- Toast.fail('请填写会议主题...')
- return
- }
- if (this.state.meetAddress == null || this.state.meetAddress.trim().length == 0) {
- Toast.fail('请填写会议地址...')
- return
- }
- if (this.state.startValue == null) {
- Toast.fail('请选择开始时间...')
- return
- }
- if (this.state.endValue == null) {
- Toast.fail('请选择结束时间...')
- return
- }
- if (this.state.earlyTime == null) {
- Toast.fail('请选择提醒时间...')
- return
- }
- if (this.state.targetList.length == 0) {
- Toast.fail('请选择与会人...')
- return
- }
- const userList = []
- if (!isObjEmpty(this.checkNodes)) {
- this.checkNodes.forEach((node, index) => {
- userList.push(node.userId)
- })
- if (!isObjEmpty(this.props.userInfo.user.userFunId) && userList.indexOf(this.props.userInfo.user.userFunId) === -1) {
- userList.push(this.props.userInfo.user.userFunId)
- }
- }
- var nowT = new Date().getTime()
- var startT = new Date(this.state.startValue).getTime()
- var endT = new Date(this.state.endValue).getTime()
- console.log('startT', startT)
- if (nowT > startT) {
- Toast.show('开始时间不可小于当前时间', 1)
- return
- }
- if (startT > endT) {
- Toast.show('结束时间不可小于开始时间', 1)
- return
- }
- if (!isObjEmpty(this.checkNodes)) {
- this.checkNodes.forEach((node, index) => {
- this.state.meetPerson.push(node.userId)
- })
- }
- var noticeT = startT - this.state.earlyTime * 1000 * 60
- console.log('noticeT', noticeT)
- console.log('noticeT', new Date(noticeT))
- let params = {
- meetingCreator: this.props.userInfo.user.userFunId,
- meetingStatus: 1,
- meetingName: this.state.titleValue,
- meetingAddress: this.state.meetAddress,
- startDate: moment(this.state.startValue).format('YYYY-MM-DD HH:mm:ss'),
- endDate: moment(this.state.endValue).format('YYYY-MM-DD HH:mm:ss'),
- reminderDate: moment(new Date(noticeT)).format('YYYY-MM-DD HH:mm:ss'),
- meetingNotifier: JSON.stringify(userList),
- meetingRemarks: "会议备注",
- meetingFiles: "[]",
- meetingDetails: "一定要参加",
- }
- console.log('params', params)
- Toast.loading("会议创建中...", 0)
- this.isRequesting = true
- fetchPost(API.createMeeting, {
- jsonMeeting: JSON.stringify(params)
- }, {})
- .then((response) => {
- this.isRequesting = false
- Toast.hide()
- console.log('response', response)
- if (response.success) {
- this.isRequesting = true
- clearListState()()
- Toast.show('创建成功', 1)
- this.backTask = setTimeout(() => {
- this.props.history.goBack()
- }, 1000)
- }
- })
- .catch((error) => {
- this.isRequesting = false
- Toast.hide()
- console.log('error', error)
- console.log('error', error)
- if (typeof error === 'string') {
- Toast.fail(error, 2)
- } else {
- if (typeof error === 'string') {
- Toast.fail(error, 2)
- } else {
- Toast.fail('请求异常', 2)
- }
- }
- })
- }
- onTargetFocus = (e) => {
- if (isObjEmpty(this.state.targetData)) {
- this.getOrganization()
- }
- }
- onTargetChange = (value, label, checkNodes, count) => {
- this.checkNodes = checkNodes
- this.setState({
- targetList: value,
- targetCount: count
- });
- }
- selectPersononChange = (value) => {
- console.log('selectPersononChange ', value);
- this.setState({meetPerson: value});
- }
- disabledStartDate = (startValue) => {
- const endValue = this.state.endValue;
- if (!startValue || !endValue) {
- return false;
- }
- return startValue.valueOf() > endValue.valueOf();
- }
- handleSelectChange = (value) => {
- console.log(`selected ${value}`);
- this.setState({
- earlyTime: value
- })
- }
- handelValueCom = (event) => {
- //获取用户名的值
- let meetTitle = this.refs.meetTitle.value;
- //获得内容的值
- let meetAddress = this.refs.meetAddress.value;
- this.setState({
- titleValue: meetTitle,
- meetAddress: meetAddress
- })
- }
- }
- let mapStateToProps = (state) => ({
- userInfo: {...state.redUserInfo}
- })
- let mapDispatchToProps = (dispatch) => ({})
- export default connect(mapStateToProps, mapDispatchToProps)(SendMeet)
|