import React from 'react'; import '../../leftTab.less'; import ReactDom from 'react-dom'; import ajax from 'jquery/src/ajax/xhr.js'; import $ from 'jquery/src/ajax'; import Editors from '../../../richTextEditors' import '../content.less'; import moment from 'moment'; import { citySelect,provinceList,areaSelect,provinceSelect,addressList} from '../../../NewDicProvinceList'; import { Form,Radio, Icon, Button, Input, Select, Spin, Table, Switch, message, DatePicker, Modal, Upload,Popconfirm,AutoComplete,Tabs,Checkbox,Tree,Cascader} from 'antd'; import {patternOrganization,conditionOrganization,intentionalService,messageType,designatedObjects,socialAttributeS,industry,socialAttribute,industryS,designatedObjectse,auditStatusL} from '../../../dataDic.js'; import { beforeUpload, getBase64, getprovince, getauditStatus, ShowModal } from "../../../tools.js"; const TabPane = Tabs.TabPane; const TreeNodet = Tree.TreeNode; const CheckboxGroup = Checkbox.Group; import ShowModalDiv from "@/showModal.jsx"; 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.visible && !nextProps.visible) { this.state.imageUrl = null; }; }, render() { const imageUrl = this.state.imageUrl; return ( { (imageUrl || this.props.imageUrl) ? : } ); } }); const Inquiry=React.createClass({ loadData(pageNo, theType) { this.setState({ loading: true, ispage:pageNo, }); $.ajax({ method: "get", dataType: "json", crossDomain: false, url: globalConfig.context + '/api/admin/news/list', data: { pageNo: pageNo || 1, pageSize: this.state.pagination.pageSize, type: theType || 1, //新闻类型 title: this.state.searchTitle, author: this.state.searchAuthor, startCreateTime: this.state.startDate, //新闻开始时间 yyyy-MM-dd endCreateTime: this.state.endDate, //新闻结束时间 yyyy-MM-dd source: this.state.searchSource, hot: this.state.searchHot, //是否放在首页 }, success: function (data) { ShowModal(this); 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 ? thisdata.id.toString() : null, createTime: thisdata.createTime, editTime: thisdata.editTime, title: thisdata.title, titleImg: thisdata.titleImg, author: thisdata.author, type: thisdata.type, hot: thisdata.hot, source: thisdata.source, sourceUrl: thisdata.sourceUrl, summary: thisdata.summary, content: thisdata.content, createTimeFormattedDate: thisdata.createTimeFormattedDate, auditStatus:thisdata.auditStatus, }); }; this.state.pagination.current = data.data.pageNo; this.state.pagination.total = data.data.totalCount; }; this.setState({ tableData: theArr, pagination: this.state.pagination }); }.bind(this), }).always(function () { this.setState({ loading: false }); }.bind(this)); }, loadDetailData() { this.setState({ loading: true }); $.ajax({ method: "get", dataType: "json", crossDomain: false, url: globalConfig.context + '/api/admin/news/detail', data: { id: this.state.RowData.id //新闻主键ID(数字类型,非字符串) }, success: function (data) { let theObj = {}; if (!data.data) { if (data.error && data.error.length) { message.warning(data.error[0].message); } } else { theObj = data.data; if(theObj.provinceId==null||theObj.provinceId==''){ theObj.provinceId=11 } }; this.setState({ RowData: theObj, }); }.bind(this), }).always(function () { this.setState({ loading: false }); }.bind(this)); }, getInitialState() { return { loading: false, visible: false, callnub:'1', selectedRowKeys: [], selectedRows: [], keysObj: {}, RowData: {}, pagination: { defaultCurrent: 1, defaultPageSize: 10, showQuickJumper: true, pageSize: 10, onChange: function (page) { this.loadData(page,this.state.callnub); }.bind(this), showTotal: function (total) { return '共' + total + '条数据'; } }, columns: [ { title: '标题', dataIndex: 'title', key: 'title', width: '20%' }, { title: '发布时间', dataIndex: 'createTimeFormattedDate', key: 'createTimeFormattedDate', }, { title: '作者', dataIndex: 'author', key: 'author', }, { title: '审核状态', dataIndex: 'auditStatus', key: 'auditStatus', render: text => { return getauditStatus(text) } }, { title: '来源', dataIndex: 'source', key: 'source', }, { title: '简介', dataIndex: 'summary', key: 'summary', width: '50%' } ], list:provinceList, tableData: [] }; }, tableRowClick(record, index) { this.state.RowData = record; this.loadDetailData(); this.setState({ visible: true }); }, componentWillMount() { this.loadData(1,1); }, componentWillReceiveProps(nextProps) { if (this.props.newsType != nextProps.newsType) { this.state.searchTitle = undefined; this.state.searchAuthor = undefined; this.state.startDate = undefined; this.state.endDate = undefined; this.state.searchSource = undefined; this.state.searchHot = undefined; this.loadData(1, nextProps.newsType); }; }, callback(e) { this.setState({ callnub: e, }) if(e == 1) { this.setState({ }) this.reset(); this.loadData(1,1); } if(e == 2) { this.setState({ }) this.reset(); this.loadData(1,2); } if(e == 3) { this.setState({ }) this.reset(); this.loadData(1,3); } if(e == 4) { this.setState({ }) this.reset(); this.loadData(1,4); } if(e == 5) { this.setState({ }) this.reset(); this.loadData(1,5); } }, submit() { if (!this.state.RowData.title) { message.warning('必须填写一个标题!'); return; }; if (!this.state.RowData.createTimeFormattedDate) { message.warning('必须选择一个发布时间!'); return; }; if (!this.state.RowData.author) { message.warning('必须填写一个作者!'); return; }; this.setState({ loading: true }); $.ajax({ method: "post", dataType: "json", crossDomain: false, url: globalConfig.context + (this.state.RowData.id ? '/api/admin/news/update' : '/api/admin/news/add'), data: { id: this.state.RowData.id || null, //主键,如果不填主键则为新增记录,填主键则为更新 title: this.state.RowData.title, titleImg: this.state.RowData.titleImg, author: this.state.RowData.author, type: this.state.callnub, hot: this.state.RowData.hot || 0, source: this.state.RowData.source, sourceUrl: this.state.RowData.sourceUrl, summary: this.state.RowData.summary, content: this.state.RowData.content, createTimeFormattedDate: this.state.RowData.createTimeFormattedDate, provinceId: this.state.RowData.provinceId, }, success: function (data) { if (data.error && data.error.length) { message.warning(data.error[0].message); } else { message.success('保存成功!'); this.setState({ visible: false }); this.loadData(this.state.ispage,this.state.callnub); }; }.bind(this), }).always(function () { this.setState({ loading: false }); }.bind(this)); }, 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/news/delete", data: { ids: deletedIds } }).done(function (data) { if (data.error && data.error.length) { message.warning(data.error[0].message); } else { message.success('删除成功!'); }; this.setState({ loading: false, }); this.loadData(this.state.ispage,this.state.callnub); }.bind(this)); }, reset() { this.state.searchTitle = undefined; this.state.searchAuthor = undefined; this.state.startDate = undefined; this.state.endDate = undefined; this.state.searchSource = undefined; this.state.searchHot = undefined; }, cleanCache(sign) { this.setState({ loading: true }); $.ajax({ method: "post", dataType: "json", crossDomain: false, url: globalConfig.context + '/api/admin/news/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)); }, clearCache() { if (!this.state.searchKey) { message.warning('必须选择一个位置!'); return; }; this.setState({ loading: true }); $.ajax({ method: "get", dataType: "json", crossDomain: false, url: globalConfig.context + '/api/admin/banners/clearCache', data: { key: this.state.searchKey // 位置标示,必填 }, 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)); }, render(){ const rowSelection = { selectedRowKeys: this.state.selectedRowKeys, onChange: (selectedRowKeys, selectedRows) => { this.setState({ selectedRows: selectedRows.slice(-1), selectedRowKeys: selectedRowKeys.slice(-1) }); } }; const hasSelected = this.state.selectedRowKeys.length > 0; return (
{ this.setState({ showModal: false }) }} />
{ this.setState({ searchTitle: e.target.value }); }} /> { this.setState({ searchAuthor: e.target.value }); }} /> { this.setState({ searchSource: e.target.value }); }} /> {this.props.newsType == 2 || this.props.newsType == 3 ? ( ) : ( )} 发布时间 { this.setState({ startDate: str }); }} /> { this.setState({ endDate: str }); }} />
{ this.state.RowData = {}; }} onCancel={() => { this.setState({ visible: false }); }} >
新闻标题 :
{this.state.RowData.title}
简介 :
{this.state.RowData.summary}
来源:
{this.state.RowData.source}
来源链接 :
{this.state.RowData.sourceUrl}
标题图片
{ this.state.RowData.titleImg = url; }} />
作者 :
{this.state.RowData.author}
发布时间 :
{this.state.RowData.createTimeFormattedDate}
{this.props.newsType == 2 || this.props.newsType == 3 ? (
发布在首页
{ this.state.RowData.hot = e.target.value; this.setState({ RowData: this.state.RowData }); }} >
) : (
)}
选择省份 : {getprovince(this.state.RowData.provinceId)}
{ this.state.RowData.content = value; }} visible={this.state.visible} readonly />
); } }) export default Inquiry;