techAchievementAudit.jsx 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444
  1. import React from 'react';
  2. import { Radio, Icon, Button, Input, Select, Spin, Table, Switch, message, DatePicker, Modal, Upload ,Popconfirm} from 'antd';
  3. import ajax from 'jquery/src/ajax/xhr.js';
  4. import $ from 'jquery/src/ajax';
  5. import moment from 'moment';
  6. import '../techAchievement.less';
  7. import TechAchievementDesc from './auditDesc.jsx';
  8. import { achievementCategoryList, techAuditStatusList } from '../../../dataDic.js';
  9. import { beforeUploadFile, companySearch, getAchievementCategory, getSearchUrl, getTechAuditStatus ,getboutique,gethot} from '../../../tools.js';
  10. const AchievementList = React.createClass({
  11. loadData(pageNo, apiUrl) {
  12. this.state.data = [];
  13. if(this.state.serialNumber&&isNaN(this.state.serialNumber)){
  14. message.warning('请输入正确的编号格式');
  15. return false;
  16. }
  17. this.setState({
  18. loading: true,
  19. ispage:pageNo,
  20. });
  21. $.ajax({
  22. method: "get",
  23. dataType: "json",
  24. crossDomain: false,
  25. url: globalConfig.context + '/api/admin/achievement/orgList',
  26. data: {
  27. pageNo: pageNo || 1,
  28. pageSize: this.state.pagination.pageSize,
  29. serialNumber: this.state.serialNumber, //编号
  30. name: this.state.name,
  31. ownerName: this.state.ownerName,
  32. auditStatus:3,//名称
  33. keyword: this.state.keyword, // 关键词
  34. category: this.state.category, //类型(0--专利, 2--软著, 3--项目, 4--版权, 5--工业设计, 6--配方, 7--非标)
  35. releaseDateStartDate: this.state.releaseDate[0],
  36. releaseDateEndDate: this.state.releaseDate[1],
  37. releaseStatus: this.state.releaseStatus ? Number(this.state.releaseStatus) : undefined, //是否发布(0--未发布,1--已发布)
  38. boutique:this.state.boutique,
  39. hot:this.state.hot,
  40. createDateStartDate: this.state.releaseDateS[0],
  41. createDateEndDate: this.state.releaseDateS[1],
  42. ownerType:this.state.ownerType,
  43. },
  44. success: function (data) {
  45. let theArr = [];
  46. if (!data.data || !data.data.list) {
  47. if (data.error && data.error.length) {
  48. message.warning(data.error[0].message);
  49. };
  50. } else {
  51. for (let i = 0; i < data.data.list.length; i++) {
  52. let thisdata = data.data.list[i];
  53. theArr.push({
  54. key: i,
  55. id: thisdata.id,
  56. serialNumber: thisdata.serialNumber,
  57. dataCategory: thisdata.dataCategory,
  58. name: thisdata.name,
  59. keyword: thisdata.keyword,
  60. theName: thisdata.username || thisdata.ownerName,
  61. category: thisdata.category,
  62. ownerName: thisdata.username ? thisdata.username : thisdata.ownerName,
  63. ownerType: thisdata.ownerType,
  64. ownerMobile: thisdata.ownerMobile,
  65. status: thisdata.status,
  66. releaseDate: thisdata.releaseDate,
  67. releaseDateFormattedDate: thisdata.releaseDateFormattedDate,
  68. auditStatus: thisdata.auditStatus,
  69. boutique: thisdata.boutique,
  70. hot: thisdata.hot,
  71. releaseStatus: thisdata.releaseStatus,
  72. techBrokerId:thisdata.techBrokerId,
  73. createTimeFormattedDate: thisdata.createTimeFormattedDate,
  74. remark:thisdata.remark,
  75. ispage:pageNo,
  76. });
  77. };
  78. this.state.pagination.current = data.data.pageNo;
  79. this.state.pagination.total = data.data.totalCount;
  80. };
  81. this.setState({
  82. dataSource: theArr,
  83. pagination: this.state.pagination
  84. });
  85. }.bind(this),
  86. }).always(function () {
  87. this.setState({
  88. loading: false
  89. });
  90. }.bind(this));
  91. },
  92. getInitialState() {
  93. return {
  94. searchMore: true,
  95. searchType: 0,
  96. validityPeriodDate: [],
  97. releaseDate: [],
  98. releaseDateS: [],
  99. selectedRowKeys: [],
  100. selectedRows: [],
  101. loading: false,
  102. pagination: {
  103. defaultCurrent: 1,
  104. defaultPageSize: 10,
  105. showQuickJumper: true,
  106. pageSize: 10,
  107. onChange: function (page) {
  108. this.loadData(page);
  109. }.bind(this),
  110. showTotal: function (total) {
  111. return '共' + total + '条数据';
  112. }
  113. },
  114. columns: [
  115. {
  116. title: '编号',
  117. dataIndex: 'serialNumber',
  118. key: 'serialNumber',
  119. }, {
  120. title: '名称',
  121. dataIndex: 'name',
  122. key: 'name',
  123. }, {
  124. title: '关键字',
  125. dataIndex: 'keyword',
  126. key: 'keyword',
  127. }, {
  128. title: '类型',
  129. dataIndex: 'category',
  130. key: 'category',
  131. render: text => { return getAchievementCategory(text); }
  132. }, {
  133. title: '录入人',
  134. dataIndex: 'techBrokerId',
  135. key: 'techBrokerId',
  136. },{
  137. title: '审核状态',
  138. dataIndex: 'auditStatus',
  139. key: 'auditStatus',
  140. render: text => { return getTechAuditStatus(text) }
  141. },{
  142. title: '发布状态',
  143. dataIndex: 'releaseStatus',
  144. key: 'releaseStatus',
  145. render: text => { return (text)?'已发布':'未发布' }
  146. },
  147. {
  148. title: '是否精品',
  149. dataIndex: 'boutique',
  150. key: 'boutique',
  151. render: text => { return getboutique(text) }
  152. },
  153. {
  154. title: '发布时间',
  155. dataIndex: 'releaseDateFormattedDate',
  156. key: 'releaseDateFormattedDate',
  157. },{
  158. title: '录入时间',
  159. dataIndex: 'createTimeFormattedDate',
  160. key: 'createTimeFormattedDate',
  161. }, {
  162. title: '发布操作',
  163. dataIndex: 'ee',
  164. key: 'ee',
  165. render: (text, record, index) => {
  166. return <div>
  167. {(!record.releaseStatus)?<Popconfirm title={'请确认发布成果【'+record.name+'】'} onConfirm={(e)=>{this.examineOK(record)}} okText="确认" cancelText="取消">
  168. <Button style={{marginRight:'5px'}} onClick={(e) =>{ e.stopPropagation()}} type="primary">发布</Button>
  169. </Popconfirm>:
  170. <Popconfirm title={'请确认撤销发布成果【'+record.name+'】'} onConfirm={(e)=>{this.examineCancel(record)}} okText="确认" cancelText="取消">
  171. <Button style={{marginRight:'5px'}} onClick={(e) =>{ e.stopPropagation()}} type="danger">撤销发布</Button>
  172. </Popconfirm>}
  173. </div>
  174. }
  175. },
  176. ],
  177. dataSource: [],
  178. searchTime: [,]
  179. };
  180. },
  181. componentWillMount() {
  182. let theArr = [];
  183. achievementCategoryList.map(function (item) {
  184. theArr.push(
  185. <Select.Option value={item.value} key={item.key}>{item.key}</Select.Option>
  186. )
  187. });
  188. let auditArr = [];
  189. techAuditStatusList.map(function (item) {
  190. auditArr.push(
  191. <Select.Option value={item.value} key={item.key}>{item.key}</Select.Option>
  192. )
  193. });
  194. this.state.achievementCategoryOption = theArr;
  195. this.state.auditStatusOption = auditArr;
  196. let data=localStorage.getItem('newData');
  197. if(data!='{}'&&data){
  198. var newData = JSON.parse(data);
  199. this.tableRowClick(newData);
  200. };
  201. this.loadData();
  202. },
  203. tableRowClick(record, index) {
  204. this.state.RowData=record;
  205. this.setState({
  206. showDesc: true
  207. });
  208. localStorage.setItem('newData','{}');
  209. },
  210. //撤销发布
  211. examineCancel(record){
  212. let api=0;
  213. this.examine(api,record);
  214. },
  215. //发布
  216. examineOK(record){
  217. let api=1;
  218. this.examine(api,record);
  219. },
  220. examine(api,record) {
  221. this.setState({
  222. selectedRowKeys: [],
  223. });
  224. $.ajax({
  225. method: "POST",
  226. dataType: "json",
  227. crossDomain: false,
  228. url: globalConfig.context + '/api/admin/achievement/offShelf',
  229. data: {
  230. id:record.id,
  231. releaseStatus:api,
  232. auditStatus:3
  233. }
  234. }).done(function (data) {
  235. if (!data.error.length) {
  236. message.success('操作成功');
  237. this.setState({
  238. loading: false,
  239. });
  240. } else {
  241. message.warning(data.error[0].message);
  242. };
  243. this.loadData(this.state.ispage);
  244. }.bind(this));
  245. },
  246. // delectRow() {
  247. // let deletedIds = [];
  248. // for (let idx = 0; idx < this.state.selectedRows.length; idx++) {
  249. // let rowItem = this.state.selectedRows[idx];
  250. // if (rowItem.id) {
  251. // deletedIds.push(rowItem.id)
  252. // };
  253. // };
  254. // this.setState({
  255. // selectedRowKeys: [],
  256. // loading: deletedIds.length > 0
  257. // });
  258. // $.ajax({
  259. // method: "POST",
  260. // dataType: "json",
  261. // crossDomain: false,
  262. // url: globalConfig.context + "/api/admin/achievement/delete",
  263. // data: {
  264. // ids: deletedIds
  265. // }
  266. // }).done(function (data) {
  267. // if (!data.error.length) {
  268. // message.success('删除成功!');
  269. // this.setState({
  270. // loading: false,
  271. // });
  272. // } else {
  273. // message.warning(data.error[0].message);
  274. // };
  275. // this.loadData(this.state.ispage);
  276. // }.bind(this));
  277. // },
  278. addClick() {
  279. this.state.RowData = {};
  280. this.setState({
  281. showDesc: true
  282. });
  283. },
  284. closeDesc(e, s) {
  285. this.state.showDesc = e;
  286. if (s) {
  287. this.loadData(this.state.ispage);
  288. };
  289. },
  290. search() {
  291. this.loadData();
  292. },
  293. reset() {
  294. this.state.serialNumber = undefined;
  295. this.state.name = undefined;
  296. this.state.ownerName= undefined;
  297. this.state.keyword = undefined;
  298. this.state.category = undefined;
  299. this.state.ownerType = undefined;
  300. this.state.releaseStatus = undefined;
  301. this.state.auditStatus = undefined;
  302. this.state.searchName = undefined;
  303. this.state.releaseDate = [];
  304. this.state.releaseDateS = [];
  305. this.state.boutique = '';
  306. this.state.hot='' ;
  307. this.loadData();
  308. },
  309. searchSwitch() {
  310. this.setState({
  311. searchMore: !this.state.searchMore
  312. });
  313. },
  314. render() {
  315. const rowSelection = {
  316. selectedRowKeys: this.state.selectedRowKeys,
  317. onChange: (selectedRowKeys, selectedRows) => {
  318. this.setState({
  319. selectedRows: selectedRows.slice(-1),
  320. selectedRowKeys: selectedRowKeys.slice(-1)
  321. });
  322. }
  323. };
  324. const hasSelected = this.state.selectedRowKeys.length > 0;
  325. const { RangePicker } = DatePicker;
  326. return (
  327. <div className="user-content" >
  328. <div className="content-title">
  329. <span>科技成果发布</span>
  330. <div className="patent-addNew clearfix">
  331. <Upload
  332. action={globalConfig.context + "/api/admin/achievement/uploadTemplate"}
  333. data={{ 'sign': 'achievement_template' }}
  334. beforeUpload={beforeUploadFile}
  335. showUploadList={false}
  336. onChange={(info) => {
  337. if (info.file.status !== 'uploading') {
  338. }
  339. if (info.file.status === 'done') {
  340. if (!info.file.response.error.length) {
  341. message.success(`${info.file.name} 文件上传成功!`);
  342. } else {
  343. message.warning(info.file.response.error[0].message);
  344. return;
  345. };
  346. } else if (info.file.status === 'error') {
  347. message.error(`${info.file.name} 文件上传失败。`);
  348. };
  349. }} >
  350. <Button style={{"display":"none"}}>上传批量导入模板</Button>
  351. </Upload>
  352. <Button onClick={() => { window.open(globalConfig.context + '/api/admin/achievement/downloadTemplate?sign=achievement_template') }} style={{"display":"none"}}>下载批量导入模板</Button>
  353. <Button type="primary" className="addButton" onClick={this.addClick} style={{"display":"none"}}>发布成果<Icon type="plus" /></Button>
  354. </div>
  355. </div>
  356. <div className="user-search">
  357. <Input placeholder="编号"
  358. value={this.state.serialNumber}
  359. onChange={(e) => { this.setState({ serialNumber: e.target.value }); }} />
  360. <Input placeholder="名称"
  361. value={this.state.name}
  362. onChange={(e) => { this.setState({ name: e.target.value }); }} />
  363. <Input placeholder="关键字"
  364. value={this.state.keyword}
  365. onChange={(e) => { this.setState({ keyword: e.target.value }); }} />
  366. <Input placeholder="成果所有人"
  367. value={this.state.ownerName}
  368. onChange={(e) => { this.setState({ ownerName: e.target.value }); }} />
  369. <Radio.Group value={this.state.searchType} onChange={(e) => {
  370. this.setState({ searchType: e.target.value })
  371. }}>
  372. <Radio value={0}>认证用户</Radio>
  373. <Radio value={1}>非认证用户</Radio>
  374. </Radio.Group>
  375. <Button type="primary" onClick={this.search}>搜索</Button>
  376. <Button onClick={this.reset}>重置</Button>
  377. <span>更多搜索<Switch defaultChecked={false} onChange={this.searchSwitch} /></span>
  378. <div className="search-more" style={this.state.searchMore ? { display: 'none' } : {}}>
  379. <Radio.Group value={this.state.boutique} onChange={(e) => {
  380. this.setState({ boutique: e.target.value })
  381. }}>
  382. <Radio value={1}>精品</Radio>
  383. <Radio value={0}>非精品</Radio>
  384. </Radio.Group>
  385. <Select placeholder="选择类型" style={{ width: 160 }}
  386. value={this.state.category}
  387. onChange={(e) => { this.setState({ category: e }) }}>
  388. {this.state.achievementCategoryOption}
  389. </Select>
  390. <Select placeholder="选择是否发布" style={{ width: 120 }}
  391. value={this.state.releaseStatus}
  392. onChange={(e) => { this.setState({ releaseStatus: e }) }}>
  393. <Select.Option value="0" >未发布</Select.Option>
  394. <Select.Option value="1" >已发布</Select.Option>
  395. </Select>
  396. <Select placeholder="选择所有人类型" style={{ width: 120 }}
  397. value={this.state.ownerType}
  398. onChange={(e) => { this.setState({ ownerType: e }) }}>
  399. <Select.Option value="0" >个人</Select.Option>
  400. <Select.Option value="1" >组织</Select.Option>
  401. </Select>
  402. <div style={{marginTop:'10px'}}>
  403. <span>发布时间 :</span>
  404. <RangePicker
  405. value={[this.state.releaseDate[0] ? moment(this.state.releaseDate[0]) : null,
  406. this.state.releaseDate[1] ? moment(this.state.releaseDate[1]) : null]}
  407. onChange={(data, dataString) => { this.setState({ releaseDate: dataString }); }} />
  408. <span style={{marginLeft:'5px'}}>录入时间 :</span>
  409. <RangePicker
  410. value={[this.state.releaseDateS[0] ? moment(this.state.releaseDateS[0]) : null,
  411. this.state.releaseDateS[1] ? moment(this.state.releaseDateS[1]) : null]}
  412. onChange={(data, dataString) => { this.setState({ releaseDateS: dataString }); }} />
  413. </div>
  414. </div>
  415. </div>
  416. <div className="patent-table">
  417. <Spin spinning={this.state.loading}>
  418. <Table size="middle" columns={this.state.columns}
  419. dataSource={this.state.dataSource}
  420. rowSelection={rowSelection}
  421. pagination={this.state.pagination}
  422. style={{
  423. cursor: 'pointer',
  424. }}
  425. onRowClick={this.tableRowClick} />
  426. </Spin>
  427. </div>
  428. <TechAchievementDesc
  429. data={this.state.RowData}
  430. detailApiUrl={this.props['data-detailApiUrl']}
  431. achievementCategoryOption={this.state.achievementCategoryOption}
  432. showDesc={this.state.showDesc}
  433. closeDesc={this.closeDesc} />
  434. </div >
  435. );
  436. }
  437. });
  438. export default AchievementList;