techAchievement.jsx 21 KB

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