import React from 'react'; import { Icon, Button, Spin, message, Table, Cascader, Input, Modal, DatePicker, Upload, Checkbox } from 'antd'; import { techFieldList, getTechField } from '../../../DicTechFieldList'; import { beforeUpload, getBase64 } from '../../../tools'; import moment from 'moment'; import ajax from 'jquery/src/ajax/xhr.js'; import $ from 'jquery/src/ajax'; const Avatar = React.createClass({ getInitialState() { return { imageUrl: '' } }, handleChange(info) { if (info.file.status === 'done') { // Get this url from response in real world. getBase64(info.file.originFileObj, imageUrl => this.setState({ imageUrl })); this.props.urlData(info.file.response.data); } }, componentWillReceiveProps(nextProps) { if (this.props.uid != nextProps.uid) { this.state.imageUrl = null; }; }, render() { const imageUrl = this.state.imageUrl; return ( { (imageUrl || this.props.imageUrl) ? : } ); } }); const Lecture = React.createClass({ loadLectureData(pageNo) { this.setState({ loading: true }); $.ajax({ method: "get", dataType: "json", crossDomain: false, url: globalConfig.context + '/api/admin/lecture/list', data: { pageNo: pageNo || 1, pageSize: this.state.lecturePagination.pageSize, username: this.state.searchLectureUser, //用户名称 name: this.state.searchLectureName, //讲座名称 startLectureTime: this.state.startLectureTime, endLectureTime: this.state.endLectureTime }, success: function (data) { let theArr = []; if (!data.data || !data.data.list) { if (data.error && data.error.length) { message.warning(data.error[0].message); }; } else { for (let i = 0; i < data.data.list.length; i++) { let thisdata = data.data.list[i]; theArr.push({ key: i, id: thisdata.id, uid: thisdata.uid, lectureTime: thisdata.lectureTime, lecturer: thisdata.lecturer, endTime: thisdata.endTime, name: thisdata.name, summary: thisdata.summary, username: thisdata.username, lectureUrl: thisdata.lectureUrl, lectureTimeFormattedDate: thisdata.lectureTimeFormattedDate, endTimeFormattedDate: thisdata.endTimeFormattedDate, hot: thisdata.hot, dynamic: thisdata.dynamic }); }; this.state.lecturePagination.current = data.data.pageNo; this.state.lecturePagination.total = data.data.totalCount; }; this.setState({ lectureTableData: theArr, lecturePagination: this.state.lecturePagination }); }.bind(this), }).always(function () { this.setState({ loading: false }); }.bind(this)); }, loadHotData() { this.setState({ loading: true }); $.ajax({ method: "get", dataType: "json", crossDomain: false, url: globalConfig.context + '/api/admin/lecture/hotList', success: function (data) { let theArr = []; if (!data.data) { if (data.error && data.error.length) { message.warning(data.error[0].message); }; } else { for (let i = 0; i < data.data.length; i++) { let thisdata = data.data[i]; theArr.push({ key: i, id: thisdata.id, uid: thisdata.uid, lectureTime: thisdata.lectureTime, lecturer: thisdata.lecturer, endTime: thisdata.endTime, name: thisdata.name, summary: thisdata.summary, username: thisdata.username, lectureUrl: thisdata.lectureUrl, lectureTimeFormattedDate: thisdata.lectureTimeFormattedDate, endTimeFormattedDate: thisdata.endTimeFormattedDate, hot: thisdata.hot, dynamic: thisdata.dynamic }); }; }; this.setState({ hotTableData: theArr }); }.bind(this), }).always(function () { this.setState({ loading: false }); }.bind(this)); }, loadDynamicData() { this.setState({ loading: true }); $.ajax({ method: "get", dataType: "json", crossDomain: false, url: globalConfig.context + '/api/admin/lecture/dynamic', success: function (data) { let theArr = []; if (!data.data) { if (data.error && data.error.length) { message.warning(data.error[0].message); }; } else { for (let i = 0; i < data.data.length; i++) { let thisdata = data.data[i]; theArr.push({ key: i, id: thisdata.id, uid: thisdata.uid, lectureTime: thisdata.lectureTime, lecturer: thisdata.lecturer, endTime: thisdata.endTime, name: thisdata.name, summary: thisdata.summary, username: thisdata.username, lectureUrl: thisdata.lectureUrl, lectureTimeFormattedDate: thisdata.lectureTimeFormattedDate, endTimeFormattedDate: thisdata.endTimeFormattedDate, hot: thisdata.hot, dynamic: thisdata.dynamic }); }; }; this.setState({ dynamicTableData: theArr }); }.bind(this), }).always(function () { this.setState({ loading: false }); }.bind(this)); }, loadData() { this.loadLectureData(); this.loadHotData(); this.loadDynamicData(); }, getInitialState() { return { loading: false, addVisible: false, addModal: {}, selectedRowKeys: [], selectedRows: [], lecturePagination: { defaultCurrent: 1, defaultPageSize: 10, showQuickJumper: true, pageSize: 10, onChange: function (page) { this.loadLectureData(page); }.bind(this), showTotal: function (total) { return '共' + total + '条数据'; } }, lectureColumns: [ { title: '讲堂名称', dataIndex: 'name', key: 'name', }, { title: '开讲人姓名', dataIndex: 'lecturer', key: 'lecturer', }, { title: '描述', dataIndex: 'summary', key: 'summary', width: '50%' }, { title: '开始时间', dataIndex: 'lectureTimeFormattedDate', key: 'lectureTimeFormattedDate', }, { title: '结束时间', dataIndex: 'endTimeFormattedDate', key: 'endTimeFormattedDate', }, { title: '展示图', dataIndex: 'lectureUrl', key: 'lectureUrl', render: text => { if (text) { return '已上传' } else { return '未上传' }; } } ], userTableData: [], lectureTableData: [], hotTableData: [], dynamicTableData: [] }; }, delectRow() { let deletedIds = []; for (let idx = 0; idx < this.state.selectedRows.length; idx++) { let rowItem = this.state.selectedRows[idx]; if (rowItem.id) { deletedIds.push(rowItem.id) }; }; this.setState({ selectedRowKeys: [], loading: deletedIds.length > 0 }); $.ajax({ method: "POST", dataType: "json", crossDomain: false, url: globalConfig.context + "/api/admin/lecture/delete", data: { ids: deletedIds } }).done(function (data) { if (data.error && data.error.length) { message.warning(data.error[0].message); } else { message.success('删除成功!'); this.loadData(); }; this.setState({ loading: false, }); }.bind(this)); }, componentWillMount() { this.loadData(); }, submit() { this.setState({ loading: true }); $.ajax({ method: "post", dataType: "json", crossDomain: false, url: globalConfig.context + (this.state.addModal.id ? '/api/admin/lecture/update' : '/api/admin/lecture/add'), data: { 'id': this.state.addModal.id, "uid": this.state.addModal.uid, "lecturer": this.state.addModal.lecturer, "name": this.state.addModal.name, "summary": this.state.addModal.summary, "lectureUrl": this.state.addModal.lectureUrl, "lectureTimeFormattedDate": this.state.addModal.lectureTimeFormattedDate, "endTimeFormattedDate": this.state.addModal.endTimeFormattedDate, "hot": this.state.addModal.showBig ? 1 : 0, "dynamic": this.state.addModal.showStar ? 1 : 0 }, success: function (data) { if (data.error && data.error.length) { message.warning(data.error[0].message); } else { message.success('保存成功!'); this.setState({ addVisible: false }); this.loadData(); }; }.bind(this), }).always(function () { this.setState({ loading: false }); }.bind(this)); }, cleanCache(sign) { this.setState({ loading: true }); $.ajax({ method: "post", dataType: "json", crossDomain: false, url: globalConfig.context + '/api/admin/lecture/cleanCache', data: { 'cacheKey': sign }, success: function (data) { if (data.error && data.error.length) { message.warning(data.error[0].message); } else { message.success('清除缓存成功!'); }; }.bind(this), }).always(function () { this.setState({ loading: false }); }.bind(this)); }, // resetUser() { // this.state.searchUserNumber = undefined; // this.state.searchUserName = undefined; // this.state.searchField = undefined; // this.state.searchPfs = undefined; // this.state.searchUnit = undefined; // this.loadUserData(); // }, resetList() { this.state.searchLectureUser = undefined; this.state.searchLectureName = undefined; this.state.startLectureTime = undefined; this.state.endLectureTime = undefined; this.loadLectureData(); }, addClick() { this.setState({ addVisible: true }); }, listTableRowClick(record, index) { this.state.addModal = record; this.state.addModal.showBig = record.hot ? true : false; this.state.addModal.showStar = record.dynamic ? true : false; this.setState({ addVisible: true }); }, render() { const rowSelection = { selectedRowKeys: this.state.selectedRowKeys, onChange: (selectedRowKeys, selectedRows) => { this.setState({ selectedRows: selectedRows, selectedRowKeys: selectedRowKeys }); } }; const hasSelected = this.state.selectedRowKeys.length > 0; return (
科技讲堂管理
讲堂列表
{ this.setState({ searchLectureUser: e.target.value }); }} /> { this.setState({ searchLectureName: e.target.value }); }} /> 开始时间 { this.setState({ startLectureTime: str }); }} /> { this.setState({ endLectureTime: str }); }} />
大咖页列表
明星动态列表
{ this.state.addModal = {} }} onCancel={() => { this.setState({ addVisible: false }) }} >
开讲人
{ this.state.addModal.lecturer = e.target.value; this.setState({ addModal: this.state.addModal }); }} />
讲堂标题
{ this.state.addModal.name = e.target.value; this.setState({ addModal: this.state.addModal }); }} />
讲堂描述
{ this.state.addModal.summary = e.target.value; this.setState({ addModal: this.state.addModal }); }} />
开讲时间
{ this.state.addModal.lectureTimeFormattedDate = str; this.setState({ addModal: this.state.addModal }); }} /> { this.state.addModal.endTimeFormattedDate = str; this.setState({ addModal: this.state.addModal }); }} />
讲堂图片
{ this.state.addModal.lectureUrl = url }} />
其他选项
{ this.state.addModal.showBig = e.target.checked; this.setState({ addModal: this.state.addModal }); }}>显示到大咖说 { this.state.addModal.showStar = e.target.checked; this.setState({ addModal: this.state.addModal }); }}>显示到明星动态
); } }); export default Lecture; // loadUserData(pageNo) { // this.setState({ // loading: true // }); // $.ajax({ // method: "get", // dataType: "json", // crossDomain: false, // url: globalConfig.context + '/api/admin/lecture/starAndExpertList', // data: { // pageNo: pageNo || 1, // pageSize: this.state.userPagination.pageSize, // number: this.state.searchUserNumber, //编号 // username: this.state.searchUserName, //名称 // engagedField: this.state.searchField ? this.state.searchField.join(',') : undefined, // professionalTitle: this.state.searchPfs, // workUnit: this.state.searchUnit // }, // success: function (data) { // let theArr = []; // if (!data.data || !data.data.list) { // if (data.error && data.error.length) { // message.warning(data.error[0].message); // }; // } else { // for (let i = 0; i < data.data.list.length; i++) { // let thisdata = data.data.list[i]; // theArr.push({ // key: i, // uid: thisdata.uid, // engagedField: thisdata.engagedField ? thisdata.engagedField.split(',') : [], // username: thisdata.username, // professionalTitle: thisdata.professionalTitle, // workUnit: thisdata.workUnit, // number: thisdata.number, // achievementNums: thisdata.achievementNums, // }); // }; // this.state.userPagination.current = data.data.pageNo; // this.state.userPagination.total = data.data.totalCount; // }; // this.setState({ // userTableData: theArr, // userPagination: this.state.userPagination // }); // }.bind(this), // }).always(function () { // this.setState({ // loading: false // }); // }.bind(this)); // }, //
//
专家明星列表
//
// { this.setState({ searchUserNumber: e.target.value }); }} /> // { this.setState({ searchUserName: e.target.value }); }} /> // { this.setState({ searchField: e }) }} /> // { this.setState({ searchPfs: e.target.value }); }} /> // { this.setState({ searchUnit: e.target.value }); }} /> // // //
// //
// //