techPolicyAudits.jsx 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634
  1. import React from 'react';
  2. import '../../leftTab.less';
  3. import ReactDom from 'react-dom';
  4. import ajax from 'jquery/src/ajax/xhr.js';
  5. import $ from 'jquery/src/ajax';
  6. import Editors from '../../../richTextEditors'
  7. import '../content.less';
  8. import moment from 'moment';
  9. import { citySelect,provinceList,areaSelect,provinceSelect,addressList} from '../../../NewDicProvinceList';
  10. import { Form,Radio, Icon, Button, Input, Select, Spin, Table, Switch, message, DatePicker, Modal, Upload,Popconfirm,AutoComplete,Tabs,Checkbox,Tree,Cascader} from 'antd';
  11. import {patternOrganization,conditionOrganization,intentionalService,messageType,designatedObjects,socialAttributeS,industry,socialAttribute,industryS,designatedObjectse,auditStatusL} from '../../../dataDic.js';
  12. import {beforeUpload, getBase64,getprovince} from '../../../tools.js';
  13. const TabPane = Tabs.TabPane;
  14. const TreeNodet = Tree.TreeNode;
  15. const CheckboxGroup = Checkbox.Group;
  16. const Avatar = React.createClass({
  17. getInitialState() {
  18. return {
  19. imageUrl: ''
  20. }
  21. },
  22. handleChange(info) {
  23. if (info.file.status === 'done') {
  24. // Get this url from response in real world.
  25. getBase64(info.file.originFileObj, imageUrl => this.setState({ imageUrl }));
  26. this.props.urlData(info.file.response.data);
  27. }
  28. },
  29. componentWillReceiveProps(nextProps) {
  30. if (this.props.visible && !nextProps.visible) {
  31. this.state.imageUrl = null;
  32. };
  33. },
  34. render() {
  35. const imageUrl = this.state.imageUrl;
  36. return (
  37. <Upload
  38. className="avatar-uploader"
  39. name={this.props.name}
  40. showUploadList={false}
  41. action={globalConfig.context + "/api/admin/news/upload"}
  42. data={{ 'sign': 'news_title_picture' }}
  43. beforeUpload={beforeUpload}
  44. onChange={this.handleChange} >
  45. {
  46. (imageUrl || this.props.imageUrl) ?
  47. <img src={imageUrl || this.props.imageUrl} role="presentation" id={this.props.name} /> :
  48. <Icon type="plus" className="avatar-uploader-trigger" />
  49. }
  50. </Upload>
  51. );
  52. }
  53. });
  54. const Inquiry=React.createClass({
  55. loadData(pageNo, theType) {
  56. this.setState({
  57. loading: true,
  58. ispage:pageNo,
  59. });
  60. $.ajax({
  61. method: "get",
  62. dataType: "json",
  63. crossDomain: false,
  64. url: globalConfig.context + '/api/admin/news/list',
  65. data: {
  66. pageNo: pageNo || 1,
  67. pageSize: this.state.pagination.pageSize,
  68. type: theType || 1, //新闻类型
  69. auditStatus:1,//审核状态
  70. title: this.state.searchTitle,
  71. author: this.state.searchAuthor,
  72. startCreateTime: this.state.startDate, //新闻开始时间 yyyy-MM-dd
  73. endCreateTime: this.state.endDate, //新闻结束时间 yyyy-MM-dd
  74. source: this.state.searchSource,
  75. hot: this.state.searchHot, //是否放在首页
  76. },
  77. success: function (data) {
  78. let theArr = [];
  79. if (!data.data || !data.data.list) {
  80. if (data.error && data.error.length) {
  81. message.warning(data.error[0].message);
  82. };
  83. } else {
  84. for (let i = 0; i < data.data.list.length; i++) {
  85. let thisdata = data.data.list[i];
  86. theArr.push({
  87. key: i,
  88. id: thisdata.id ? thisdata.id.toString() : null,
  89. createTime: thisdata.createTime,
  90. editTime: thisdata.editTime,
  91. title: thisdata.title,
  92. titleImg: thisdata.titleImg,
  93. author: thisdata.author,
  94. type: thisdata.type,
  95. hot: thisdata.hot,
  96. source: thisdata.source,
  97. sourceUrl: thisdata.sourceUrl,
  98. summary: thisdata.summary,
  99. content: thisdata.content,
  100. createTimeFormattedDate: thisdata.createTimeFormattedDate,
  101. });
  102. };
  103. this.state.pagination.current = data.data.pageNo;
  104. this.state.pagination.total = data.data.totalCount;
  105. };
  106. this.setState({
  107. tableData: theArr,
  108. pagination: this.state.pagination
  109. });
  110. }.bind(this),
  111. }).always(function () {
  112. this.setState({
  113. loading: false
  114. });
  115. }.bind(this));
  116. },
  117. loadDetailData() {
  118. this.setState({
  119. loading: true
  120. });
  121. $.ajax({
  122. method: "get",
  123. dataType: "json",
  124. crossDomain: false,
  125. url: globalConfig.context + '/api/admin/news/detail',
  126. data: {
  127. id: this.state.RowData.id //新闻主键ID(数字类型,非字符串)
  128. },
  129. success: function (data) {
  130. let theObj = {};
  131. if (!data.data) {
  132. if (data.error && data.error.length) {
  133. message.warning(data.error[0].message);
  134. }
  135. } else {
  136. theObj = data.data;
  137. if(theObj.provinceId==null||theObj.provinceId==''){
  138. theObj.provinceId=11
  139. }
  140. };
  141. this.setState({
  142. RowData: theObj,
  143. });
  144. }.bind(this),
  145. }).always(function () {
  146. this.setState({
  147. loading: false
  148. });
  149. }.bind(this));
  150. },
  151. getInitialState() {
  152. return {
  153. loading: false,
  154. visible: false,
  155. callnub:'1',
  156. selectedRowKeys: [],
  157. selectedRows: [],
  158. keysObj: {},
  159. RowData: {},
  160. pagination: {
  161. defaultCurrent: 1,
  162. defaultPageSize: 10,
  163. showQuickJumper: true,
  164. pageSize: 10,
  165. onChange: function (page) {
  166. this.loadData(page,this.state.callnub);
  167. }.bind(this),
  168. showTotal: function (total) {
  169. return '共' + total + '条数据';
  170. }
  171. },
  172. columns: [
  173. {
  174. title: '标题',
  175. dataIndex: 'title',
  176. key: 'title',
  177. width: '20%'
  178. }, {
  179. title: '发布时间',
  180. dataIndex: 'createTimeFormattedDate',
  181. key: 'createTimeFormattedDate',
  182. }, {
  183. title: '作者',
  184. dataIndex: 'author',
  185. key: 'author',
  186. }, {
  187. title: '来源',
  188. dataIndex: 'source',
  189. key: 'source',
  190. }, {
  191. title: '简介',
  192. dataIndex: 'summary',
  193. key: 'summary',
  194. width: '50%'
  195. }
  196. ],
  197. list:provinceList,
  198. tableData: []
  199. };
  200. },
  201. tableRowClick(record, index) {
  202. this.state.RowData = record;
  203. this.loadDetailData();
  204. this.setState({
  205. visible: true
  206. });
  207. },
  208. componentWillMount() {
  209. this.loadData(1,1);
  210. },
  211. componentWillReceiveProps(nextProps) {
  212. if (this.props.newsType != nextProps.newsType) {
  213. this.state.searchTitle = undefined;
  214. this.state.searchAuthor = undefined;
  215. this.state.startDate = undefined;
  216. this.state.endDate = undefined;
  217. this.state.searchSource = undefined;
  218. this.state.searchHot = undefined;
  219. this.loadData(1, nextProps.newsType);
  220. };
  221. },
  222. callback(e) {
  223. this.setState({
  224. callnub: e,
  225. })
  226. if(e == 1) {
  227. this.loadData(1,1);
  228. this.setState({
  229. })
  230. this.reset();
  231. }
  232. if(e == 2) {
  233. this.loadData(1,2);
  234. this.setState({
  235. })
  236. this.reset();
  237. }
  238. if(e == 3) {
  239. this.loadData(1,3);
  240. this.setState({
  241. })
  242. this.reset();
  243. }
  244. if(e == 4) {
  245. this.loadData(1,4);
  246. this.setState({
  247. })
  248. this.reset();
  249. }
  250. if(e == 5) {
  251. this.loadData(1,5);
  252. this.setState({
  253. })
  254. this.reset();
  255. }
  256. },
  257. submit() {
  258. if (!this.state.RowData.title) {
  259. message.warning('必须填写一个标题!');
  260. return;
  261. };
  262. if (!this.state.RowData.createTimeFormattedDate) {
  263. message.warning('必须选择一个发布时间!');
  264. return;
  265. };
  266. if (!this.state.RowData.author) {
  267. message.warning('必须填写一个作者!');
  268. return;
  269. };
  270. this.setState({
  271. loading: true
  272. });
  273. $.ajax({
  274. method: "post",
  275. dataType: "json",
  276. crossDomain: false,
  277. url: globalConfig.context + (this.state.RowData.id ? '/api/admin/news/update' : '/api/admin/news/add'),
  278. data: {
  279. id: this.state.RowData.id || null, //主键,如果不填主键则为新增记录,填主键则为更新
  280. title: this.state.RowData.title,
  281. titleImg: this.state.RowData.titleImg,
  282. author: this.state.RowData.author,
  283. type: this.state.callnub,
  284. hot: this.state.RowData.hot || 0,
  285. source: this.state.RowData.source,
  286. sourceUrl: this.state.RowData.sourceUrl,
  287. summary: this.state.RowData.summary,
  288. content: this.state.RowData.content,
  289. createTimeFormattedDate: this.state.RowData.createTimeFormattedDate,
  290. provinceId: this.state.RowData.provinceId,
  291. },
  292. success: function (data) {
  293. if (data.error && data.error.length) {
  294. message.warning(data.error[0].message);
  295. } else {
  296. message.success('保存成功!');
  297. this.setState({ visible: false });
  298. this.loadData(this.state.ispage,this.state.callnub);
  299. };
  300. }.bind(this),
  301. }).always(function () {
  302. this.setState({
  303. loading: false
  304. });
  305. }.bind(this));
  306. },
  307. //审核专家通过功能
  308. delectRow() {
  309. let deletedIds;
  310. let rowItem;
  311. for(let idx = 0; idx < this.state.selectedRows.length; idx++) {
  312. rowItem = this.state.selectedRows[idx];
  313. if(rowItem.id) {
  314. deletedIds = rowItem.id;
  315. };
  316. };
  317. this.setState({
  318. selectedRowKeys: [],
  319. });
  320. $.ajax({
  321. method: "post",
  322. dataType: "json",
  323. crossDomain: false,
  324. url: globalConfig.context + "/api/admin/news/update",
  325. data: {
  326. id: deletedIds, //审核通过的ID
  327. auditStatus:2,
  328. title: rowItem.title,
  329. titleImg: rowItem.titleImg,
  330. author: rowItem.author,
  331. type: rowItem.type,
  332. hot: rowItem.hot || 0,
  333. source:rowItem.source,
  334. sourceUrl: rowItem.sourceUrl,
  335. summary: rowItem.summary,
  336. content:rowItem.content,
  337. createTimeFormattedDate: rowItem.createTimeFormattedDate,
  338. provinceId: rowItem.provinceId,
  339. }
  340. }).done(function(data) {
  341. if(!data.error.length) {
  342. message.success('已成功通过审核!');
  343. this.setState({
  344. loading: false,
  345. });
  346. } else {
  347. message.warning(data.error[0].message);
  348. };
  349. this.loadData(this.state.ispage);
  350. }.bind(this));
  351. },
  352. //审核专家不通过功能
  353. delectRows() {
  354. let deletedIds;
  355. let rowItem;
  356. for(let idx = 0; idx < this.state.selectedRows.length; idx++) {
  357. rowItem = this.state.selectedRows[idx];
  358. if(rowItem.id) {
  359. deletedIds = rowItem.id;
  360. };
  361. };
  362. this.setState({
  363. selectedRowKeys: [],
  364. });
  365. $.ajax({
  366. method: "post",
  367. dataType: "json",
  368. crossDomain: false,
  369. url: globalConfig.context + "/api/admin/news/update",
  370. data: {
  371. id: deletedIds, //审核通过的ID
  372. auditStatus:3,
  373. title: rowItem.title,
  374. titleImg: rowItem.titleImg,
  375. author: rowItem.author,
  376. type: rowItem.type,
  377. hot: rowItem.hot || 0,
  378. source:rowItem.source,
  379. sourceUrl: rowItem.sourceUrl,
  380. summary: rowItem.summary,
  381. content:rowItem.content,
  382. createTimeFormattedDate: rowItem.createTimeFormattedDate,
  383. provinceId: rowItem.provinceId,
  384. }
  385. }).done(function(data) {
  386. if(!data.error.length) {
  387. message.success('操作成功!');
  388. this.setState({
  389. loading: false,
  390. });
  391. } else {
  392. message.warning(data.error[0].message);
  393. };
  394. this.loadData(this.state.ispage);
  395. }.bind(this));
  396. },
  397. reset() {
  398. this.state.searchTitle = undefined;
  399. this.state.searchAuthor = undefined;
  400. this.state.startDate = undefined;
  401. this.state.endDate = undefined;
  402. this.state.searchSource = undefined;
  403. this.state.searchHot = undefined;
  404. },
  405. cleanCache(sign) {
  406. this.setState({
  407. loading: true
  408. });
  409. $.ajax({
  410. method: "post",
  411. dataType: "json",
  412. crossDomain: false,
  413. url: globalConfig.context + '/api/admin/news/cleanCache',
  414. data: {
  415. 'cacheKey': sign
  416. },
  417. success: function (data) {
  418. if (data.error && data.error.length) {
  419. message.warning(data.error[0].message);
  420. } else {
  421. message.success('清除缓存成功!');
  422. };
  423. }.bind(this),
  424. }).always(function () {
  425. this.setState({
  426. loading: false
  427. });
  428. }.bind(this));
  429. },
  430. clearCache() {
  431. if (!this.state.searchKey) {
  432. message.warning('必须选择一个位置!');
  433. return;
  434. };
  435. this.setState({
  436. loading: true
  437. });
  438. $.ajax({
  439. method: "get",
  440. dataType: "json",
  441. crossDomain: false,
  442. url: globalConfig.context + '/api/admin/banners/clearCache',
  443. data: {
  444. key: this.state.searchKey // 位置标示,必填
  445. },
  446. success: function (data) {
  447. if (data.error && data.error.length) {
  448. message.warning(data.error[0].message);
  449. } else {
  450. message.success('更新缓存成功!');
  451. };
  452. }.bind(this),
  453. }).always(function () {
  454. this.setState({
  455. loading: false
  456. });
  457. }.bind(this));
  458. },
  459. render(){
  460. const rowSelection = {
  461. selectedRowKeys: this.state.selectedRowKeys,
  462. onChange: (selectedRowKeys, selectedRows) => {
  463. this.setState({
  464. selectedRows: selectedRows.slice(-1),
  465. selectedRowKeys: selectedRowKeys.slice(-1)
  466. });
  467. }
  468. };
  469. const hasSelected = this.state.selectedRowKeys.length > 0;
  470. return(
  471. <div className="admin-content" >
  472. <div className="admin-content-search">
  473. <Input placeholder="标题" style={{ width: 200 ,marginBottom:'10px',marginRight:'10px'}}
  474. value={this.state.searchTitle}
  475. onChange={(e) => { this.setState({ searchTitle: e.target.value }); }} />
  476. <Input placeholder="作者" style={{ width: 100 ,marginRight:'10px'}}
  477. value={this.state.searchAuthor}
  478. onChange={(e) => { this.setState({ searchAuthor: e.target.value }); }} />
  479. <Input placeholder="来源" style={{ width: 100 ,marginRight:'10px'}}
  480. value={this.state.searchSource}
  481. onChange={(e) => { this.setState({ searchSource: e.target.value }); }} />
  482. {this.props.newsType == 2 || this.props.newsType == 3 ? <Select placeholder="显示在首页"
  483. style={{ width: 100,marginRight:'10px' }}
  484. value={this.state.searchHot}
  485. onChange={(e) => { this.setState({ searchHot: e }) }}>
  486. <Select.Option value="0" >不显示</Select.Option>
  487. <Select.Option value="1" >显示</Select.Option>
  488. </Select> : <span></span>}
  489. <span style={{marginRight:'10px'}}>发布时间</span>
  490. <DatePicker style={{ width: 110,marginRight:'10px' }}
  491. format="YYYY-MM-DD"
  492. placeholder="选择开始时间"
  493. value={this.state.startDate ? moment(this.state.startDate, "YYYY-MM-DD") : undefined}
  494. onChange={(t, str) => {
  495. this.setState({ startDate: str });
  496. }} />
  497. <span style={{marginRight:'10px'}}>到</span>
  498. <DatePicker style={{ width: 110 ,marginRight:'10px'}}
  499. format="YYYY-MM-DD"
  500. placeholder="选择结束时间"
  501. value={this.state.endDate ? moment(this.state.endDate, "YYYY-MM-DD") : undefined}
  502. onChange={(t, str) => {
  503. this.setState({ endDate: str });
  504. }} />
  505. <Button type="primary" onClick={() => { this.loadData(1,this.state.callnub) }} style={{marginRight:'10px'}}>搜索</Button>
  506. <Button onClick={this.reset} style={{marginRight:'10px'}}>重置</Button>
  507. <Button type="ghost" onClick={this.clearCache}>清除缓存</Button>
  508. {adminData.isSuperAdmin?<Button type='primary' style={{marginRight:'10px' ,marginLeft:'10px',display:adminData.isSuperAdmin?'inline-block':'none'}}
  509. disabled={!hasSelected}
  510. onClick={this.delectRow}>审核通过</Button>:''}
  511. {adminData.isSuperAdmin?<Button type='primary' style={{marginRight:'10px' ,marginLeft:'10px',display:adminData.isSuperAdmin?'inline-block':'none'}}
  512. disabled={!hasSelected}
  513. onClick={this.delectRows}>审核不通过</Button>:''}
  514. </div>
  515. <div className="clearfix" style={{marginLeft:'20px'}}>
  516. <Tabs onChange={this.callback} type="card" activeKey={this.state.callnub} style={{paddingLeft:'15px',paddingRight:'15px',marginRight:'20px'}}>
  517. <TabPane tab="科技快讯" key="1" ></TabPane>
  518. <TabPane tab="交易问题" key="2"></TabPane>
  519. <TabPane tab="技淘动态" key="3"></TabPane>
  520. <TabPane tab="国家政策" key="4"></TabPane>
  521. <TabPane tab="地方政策" key="5"></TabPane>
  522. </Tabs>
  523. </div>
  524. <Spin spinning={this.state.loading}>
  525. <Table size="middle" className="no-all-select" columns={this.state.columns}
  526. dataSource={this.state.tableData}
  527. pagination={this.state.pagination}
  528. rowSelection={rowSelection}
  529. style={{
  530. cursor: 'pointer',
  531. }}
  532. onRowClick={this.tableRowClick} />
  533. </Spin>
  534. <Modal title="新闻详情" width={1000} className="news-modal"
  535. visible={this.state.visible}
  536. maskClosable={false}
  537. footer={null}
  538. afterClose={() => { this.state.RowData = {}; }}
  539. onCancel={() => { this.setState({ visible: false }) }} >
  540. <Spin spinning={this.state.loading}>
  541. <div className="clearfix">
  542. <div className="modal-box">
  543. <span className="modal-box-title">新闻标题 : </span>
  544. <div className="modal-box-detail">
  545. <span>{this.state.RowData.title}</span>
  546. </div>
  547. </div>
  548. <div className="modal-box">
  549. <span className="modal-box-title">简介 : </span>
  550. <div className="modal-box-detail">
  551. <span>{this.state.RowData.summary}</span>
  552. </div>
  553. </div>
  554. <div className="modal-box">
  555. <span className="modal-box-title">来源:</span>
  556. <div className="modal-box-detail">
  557. <span>{this.state.RowData.source}</span>
  558. </div>
  559. </div>
  560. <div className="modal-box">
  561. <span className="modal-box-title">来源链接 : </span>
  562. <div className="modal-box-detail">
  563. <span>{this.state.RowData.sourceUrl}</span>
  564. </div>
  565. </div>
  566. <div className="modal-box" style={{ position: 'absolute', right: '0', width: '480px' }}>
  567. <span className="modal-box-title">标题图片</span>
  568. <div className="modal-box-detail clearfix" style={{ width: '360px' }}>
  569. <Avatar sign={'news_title_picture'} visible={this.state.visible}
  570. imageUrl={this.state.RowData.titleImg ? (globalConfig.avatarHost + "/upload" + this.state.RowData.titleImg) : null}
  571. urlData={(url) => { this.state.RowData.titleImg = url }} />
  572. </div>
  573. </div>
  574. </div>
  575. <div className="clearfix">
  576. <div className="modal-box news-box">
  577. <span className="modal-box-title">作者 : </span>
  578. <div className="modal-box-detail">
  579. <span>{this.state.RowData.author}</span>
  580. </div>
  581. </div>
  582. <div className="modal-box news-box">
  583. <span className="modal-box-title">发布时间 : </span>
  584. <div className="modal-box-detail">
  585. <span>{this.state.RowData.createTimeFormattedDate}</span>
  586. </div>
  587. </div>
  588. {this.props.newsType == 2 || this.props.newsType == 3 ? <div className="modal-box news-box">
  589. <span className="modal-box-title">发布在首页</span>
  590. <div className="modal-box-detail">
  591. <Radio.Group value={this.state.RowData.hot} onChange={(e) => {
  592. this.state.RowData.hot = e.target.value;
  593. this.setState({ RowData: this.state.RowData });
  594. }} >
  595. <Radio value={0}>否</Radio>
  596. <Radio value={1}>是</Radio>
  597. </Radio.Group>
  598. </div>
  599. </div> : <div></div>}
  600. </div>
  601. <div className="modal-box">
  602. <span className="modal-box-title">选择省份 : </span>
  603. <span>{getprovince(this.state.RowData.provinceId)}</span>
  604. </div>
  605. <Editors textContent={this.state.RowData.content}
  606. uploadUrl={'/api/admin/news/upload'}
  607. uploadSign={'news_content_picture'}
  608. handleRichText={(value) => { this.state.RowData.content = value; }}
  609. visible={this.state.visible} readonly/>
  610. </Spin>
  611. </Modal>
  612. </div>
  613. )
  614. }
  615. })
  616. export default Inquiry;