myTechAchievement.jsx 21 KB

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