activity.jsx 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546
  1. import React from 'react';
  2. import { Icon, Button, Upload, Input, Spin, Table, message, Select, Modal, DatePicker, Cascader, Transfer, InputNumber } from 'antd';
  3. import { techFieldList, technicalSourceList } from '../../dataDic.js';
  4. import { getTechField, getTechnicalSource, beforeUploadFile, downloadFile } from '../../tools.js';
  5. import './activity.less';
  6. import moment from 'moment';
  7. import ajax from 'jquery/src/ajax/xhr.js';
  8. import $ from 'jquery/src/ajax';
  9. const ActivityDesc = React.createClass({
  10. getInitialState() {
  11. return {
  12. visible: false,
  13. loading: false,
  14. targetKeys: [],
  15. selectedKeys: []
  16. };
  17. },
  18. handleOk() {
  19. this.setState({
  20. loading: true,
  21. });
  22. $.ajax({
  23. method: "POST",
  24. dataType: "json",
  25. crossDomain: false,
  26. url: globalConfig.context + "/techservice/cognizance/activity",
  27. data: {
  28. id: this.props.data.id,
  29. activityName: this.state.activityName,
  30. activityNumber: this.state.activityNumber,
  31. startDateFormattedDate: this.state.startDateFormattedDate,
  32. endDateFormattedDate: this.state.endDateFormattedDate,
  33. technicalField1: this.state.techField[0],
  34. technicalField2: this.state.techField[1],
  35. technicalField3: this.state.techField[2],
  36. technicalSource: this.state.technicalSource,
  37. intellectualPropertyNumber: this.state.targetKeys.join(","),
  38. budget: this.state.budget,
  39. firstYearExpenditure: this.state.firstYearExpenditure,
  40. secondYearExpenditure: this.state.secondYearExpenditure,
  41. thirdYearExpenditure: this.state.thirdYearExpenditure,
  42. implement: this.state.implement,
  43. technologyInnovation: this.state.technologyInnovation,
  44. achievement: this.state.achievement,
  45. participant: this.state.participant,
  46. proofUrl: this.state.proofUrl,
  47. projectMode: this.state.projectMode
  48. }
  49. }).done(function (data) {
  50. if (!data.error.length) {
  51. message.success('保存成功!');
  52. this.setState({
  53. loading: false,
  54. visible: false
  55. });
  56. this.props.closeDesc(false);
  57. } else {
  58. message.warning(data.error[0].message);
  59. this.setState({
  60. loading: false
  61. });
  62. };
  63. }.bind(this));
  64. },
  65. handleCancel(e) {
  66. this.setState({
  67. visible: false,
  68. });
  69. this.props.closeDesc(false);
  70. },
  71. componentWillReceiveProps(nextProps) {
  72. this.state.visible = nextProps.showDesc;
  73. if (!this.props.showDesc && nextProps.showDesc) {
  74. this.state.activityName = nextProps.data.activityName;
  75. this.state.activityNumber = nextProps.data.activityNumber;
  76. this.state.startDateFormattedDate = nextProps.data.startDateFormattedDate;
  77. this.state.endDateFormattedDate = nextProps.data.endDateFormattedDate;
  78. this.state.techField = nextProps.data.techField;
  79. this.state.technicalSource = nextProps.data.technicalSource;
  80. this.state.targetKeys = nextProps.data.intellectualPropertyNumber || [];
  81. this.state.budget = nextProps.data.budget;
  82. this.state.firstYearExpenditure = nextProps.data.firstYearExpenditure;
  83. this.state.secondYearExpenditure = nextProps.data.secondYearExpenditure;
  84. this.state.thirdYearExpenditure = nextProps.data.thirdYearExpenditure;
  85. this.state.implement = nextProps.data.implement;
  86. this.state.technologyInnovation = nextProps.data.technologyInnovation;
  87. this.state.achievement = nextProps.data.achievement;
  88. this.state.mockData = nextProps.data.mockData;
  89. this.state.projectMode = nextProps.data.projectMode ? String(nextProps.data.projectMode) : undefined;
  90. this.state.proofUrl = nextProps.data.proofUrl;
  91. this.state.proofDownloadFileName = nextProps.data.proofDownloadFileName;
  92. };
  93. },
  94. intellectualChange(nextTargetKeys, direction, moveKeys) {
  95. this.setState({ targetKeys: nextTargetKeys });
  96. },
  97. intellectualSelectChange(sourceSelectedKeys, targetSelectedKeys) {
  98. this.setState({ selectedKeys: [...sourceSelectedKeys, ...targetSelectedKeys] });
  99. },
  100. render() {
  101. if (this.props.data) {
  102. return (
  103. <div className="admin-desc">
  104. <Modal title="企业研究开发活动情况详情" visible={this.state.visible} onCancel={this.handleCancel}
  105. width='800px' footer={[
  106. <Button key="submit" type="primary" size="large" loading={this.state.loading} onClick={this.handleOk}>保存</Button>,
  107. <Button key="back" type="ghost" size="large" onClick={this.handleCancel}>取消</Button>
  108. ]}
  109. className="admin-desc-content">
  110. <div className="clearfix">
  111. <div className="half-div">
  112. <p>研发活动编号:</p>
  113. <Input value={this.state.activityNumber}
  114. onChange={(e) => { this.setState({ activityNumber: e.target.value }); }} />
  115. </div>
  116. <div className="half-div">
  117. <p>研发活动名称:</p>
  118. <Input value={this.state.activityName}
  119. onChange={(e) => { this.setState({ activityName: e.target.value }); }} />
  120. </div>
  121. <div className="half-div">
  122. <p>开始日期:</p>
  123. <DatePicker
  124. value={this.state.startDateFormattedDate ? moment(this.state.startDateFormattedDate) : null}
  125. onChange={(data, dataString) => { this.setState({ startDateFormattedDate: dataString }); }} />
  126. </div>
  127. <div className="half-div">
  128. <p>结束日期:</p>
  129. <DatePicker
  130. value={this.state.endDateFormattedDate ? moment(this.state.endDateFormattedDate) : null}
  131. onChange={(data, dataString) => { this.setState({ endDateFormattedDate: dataString }); }} />
  132. </div>
  133. </div>
  134. <div>
  135. <p>技术领域:</p>
  136. <Cascader
  137. style={{ width: 500 }}
  138. options={techFieldList}
  139. value={this.state.techField}
  140. onChange={(value, selectedOptions) => { this.setState({ techField: value }); console.log(value) }}
  141. placeholder="选择技术领域"
  142. showSearch
  143. />,
  144. </div>
  145. <div className="half-div">
  146. <p>技术来源:</p>
  147. <Select placeholder="选择技术来源" style={{ width: 230 }}
  148. value={this.state.technicalSource}
  149. onChange={(e) => { this.setState({ technicalSource: e }) }}>
  150. {
  151. technicalSourceList.map(function (item, i) {
  152. return <Select.Option key={1000 + i} value={item.value} >{item.key}</Select.Option>
  153. })
  154. }
  155. </Select>
  156. </div>
  157. <div className="half-div">
  158. <p>参与人员:</p>
  159. <InputNumber value={this.state.participant}
  160. onChange={(e) => { this.setState({ participant: e }); }} />
  161. </div>
  162. <div style={{ marginTop: '10px' }}>
  163. <p>知识产权编号:</p>
  164. <Transfer
  165. dataSource={this.props.mockData}
  166. listStyle={{
  167. width: 300,
  168. height: 300,
  169. }}
  170. titles={['未选择', '已选择']}
  171. targetKeys={this.state.targetKeys}
  172. selectedKeys={this.state.selectedKeys}
  173. onChange={this.intellectualChange}
  174. onSelectChange={this.intellectualSelectChange}
  175. render={item => `${item.name}-${item.key}`}
  176. />
  177. </div>
  178. <div>
  179. <p>研发经费总预算(万元):</p>
  180. <InputNumber value={this.state.budget || 0}
  181. onChange={(e) => { this.setState({ budget: e }); }} />
  182. </div>
  183. <div className="clearfix" >
  184. <p>研发经费近三年总支出(万元):</p>
  185. <div className="half-div">
  186. <span>总计(万元):</span>
  187. <InputNumber value={
  188. this.state.firstYearExpenditure + this.state.secondYearExpenditure + this.state.thirdYearExpenditure || 0
  189. } />
  190. </div>
  191. <div className="half-div">
  192. <span>其中(第一年):</span>
  193. <InputNumber value={this.state.firstYearExpenditure}
  194. onChange={(e) => { this.setState({ firstYearExpenditure: e }); }} />
  195. </div>
  196. <div className="half-div">
  197. <span>其中(第二年):</span>
  198. <InputNumber value={this.state.secondYearExpenditure}
  199. onChange={(e) => { this.setState({ secondYearExpenditure: e }); }} />
  200. </div>
  201. <div className="half-div">
  202. <span>其中(第三年):</span>
  203. <InputNumber value={this.state.thirdYearExpenditure}
  204. onChange={(e) => { this.setState({ thirdYearExpenditure: e }); }} />
  205. </div>
  206. </div>
  207. <div className="clearfix">
  208. <div className="half-div">
  209. <p>目的及组织实施方式(限400字):</p>
  210. <Input type="textarea" rows={6}
  211. value={this.state.implement}
  212. onChange={(e) => {
  213. if (e.target.value.length > 400) {
  214. return;
  215. }
  216. this.setState({ implement: e.target.value });
  217. }} />
  218. </div>
  219. <div className="half-div">
  220. <p>核心技术及创新点(限400字):</p>
  221. <Input type="textarea" rows={6}
  222. value={this.state.technologyInnovation}
  223. onChange={(e) => {
  224. if (e.target.value.length > 400) {
  225. return;
  226. }
  227. this.setState({ technologyInnovation: e.target.value });
  228. }} />
  229. </div>
  230. <div className="half-div">
  231. <p>取得的阶段性成果(限400字):</p>
  232. <Input type="textarea" rows={6}
  233. value={this.state.achievement}
  234. onChange={(e) => {
  235. if (e.target.value.length > 400) {
  236. return;
  237. }
  238. this.setState({ achievement: e.target.value });
  239. }} />
  240. </div>
  241. </div>
  242. <Select style={{ width: 120 }}
  243. placeholder='请选择立项类型'
  244. value={this.state.projectMode}
  245. onChange={(e) => { this.setState({ projectMode: e }); }}>
  246. <Select.Option value='1'>内部立项</Select.Option>
  247. <Select.Option value='2'>外部立项</Select.Option>
  248. </Select>
  249. <div style={{ width: '50%' }}>
  250. <Upload
  251. name="ratepay"
  252. action={globalConfig.context + "/techservice/cognizance/upload"}
  253. data={{ 'sign': 'proof' }}
  254. beforeUpload={beforeUploadFile}
  255. showUploadList={false}
  256. onChange={(info) => {
  257. if (info.file.status !== 'uploading') {
  258. console.log(info.file, info.fileList);
  259. }
  260. if (info.file.status === 'done') {
  261. if (!info.file.response.error.length) {
  262. message.success(`${info.file.name} 文件上传成功!`);
  263. } else {
  264. message.warning(info.file.response.error[0].message);
  265. return;
  266. };
  267. this.state.proofUrl = info.file.response.data;
  268. } else if (info.file.status === 'error') {
  269. message.error(`${info.file.name} 文件上传失败。`);
  270. }
  271. }}
  272. >
  273. <Button><Icon type="upload" /> 上传立项证明材料 </Button>
  274. </Upload>
  275. <p>{this.state.proofUrl ? <a onClick={downloadFile.bind(null, this.state.proofUrl, this.state.proofDownloadFileName)}>{this.state.proofDownloadFileName}</a> : <span>未上传!</span>}</p>
  276. </div>
  277. </Modal>
  278. </div>
  279. );
  280. } else {
  281. return <div></div>
  282. }
  283. },
  284. });
  285. const Activity = React.createClass({
  286. loadData(pageNo) {
  287. this.state.data = [];
  288. this.setState({
  289. loading: true
  290. });
  291. $.when($.ajax({
  292. method: "post",
  293. dataType: "json",
  294. crossDomain: false,
  295. url: globalConfig.context + "/techservice/cognizance/activityList",
  296. data: {
  297. pageNo: pageNo || 1,
  298. pageSize: this.state.pagination.pageSize,
  299. activityNumber: this.state.activityNumber,
  300. activityName: this.state.activityName,
  301. startDate: this.state.startDate,
  302. endDate: this.state.endDate
  303. }
  304. }), $.ajax({
  305. method: "get",
  306. dataType: "json",
  307. crossDomain: false,
  308. url: globalConfig.context + "/techservice/cognizance/intellectualList",
  309. data: {
  310. pageNo: pageNo || 1,
  311. pageSize: 99,
  312. }
  313. })).done((data1, data2) => {
  314. let data = data1[0];
  315. let intellectualList = data2[0];
  316. if (data.error.length || !data.data || !data.data.list) {
  317. message.warning(data.error[0].message);
  318. return;
  319. };
  320. if (intellectualList.error.length || !intellectualList.data || !intellectualList.data.list) {
  321. message.warning(intellectualList.error[0].message);
  322. return;
  323. };
  324. let theArr = [];
  325. for (let i = 0; i < intellectualList.data.list.length; i++) {
  326. theArr.push({
  327. key: intellectualList.data.list[i].intellectualPropertyNumber,
  328. name: intellectualList.data.list[i].intellectualPropertyName
  329. });
  330. };
  331. this.state.mockData = theArr;
  332. for (let i = 0; i < data.data.list.length; i++) {
  333. let thisdata = data.data.list[i];
  334. this.state.data.push({
  335. key: i,
  336. id: thisdata.id,
  337. uid: thisdata.uid,
  338. activityNumber: thisdata.activityNumber,
  339. activityName: thisdata.activityName,
  340. startDate: thisdata.startDate,
  341. endDate: thisdata.endDate,
  342. mockData: this.state.mockData,
  343. techField: [Number(thisdata.technicalField1), Number(thisdata.technicalField2), Number(thisdata.technicalField3)],
  344. technicalField: getTechField(thisdata.technicalField1, thisdata.technicalField2, thisdata.technicalField3),
  345. technicalField1: thisdata.technicalField1,
  346. technicalField2: thisdata.technicalField2,
  347. technicalField3: thisdata.technicalField3,
  348. technicalSource: String(thisdata.technicalSource),
  349. intellectualPropertyNumber: thisdata.intellectualPropertyNumber ? thisdata.intellectualPropertyNumber.split(",") : [],
  350. budget: thisdata.budget,
  351. firstYearExpenditure: thisdata.firstYearExpenditure,
  352. secondYearExpenditure: thisdata.secondYearExpenditure,
  353. thirdYearExpenditure: thisdata.thirdYearExpenditure,
  354. implement: thisdata.implement,
  355. technologyInnovation: thisdata.technologyInnovation,
  356. achievement: thisdata.achievement,
  357. internalLaborCost: thisdata.internalLaborCost,
  358. internalDirectCost: thisdata.internalDirectCost,
  359. internalDepreciationCost: thisdata.internalDepreciationCost,
  360. internalAmortizationCost: thisdata.internalAmortizationCost,
  361. internalDesignCost: thisdata.internalDesignCost,
  362. internalEquipmentCost: thisdata.internalEquipmentCost,
  363. internalOtherCost: thisdata.internalOtherCost,
  364. externalTotalCost: thisdata.externalTotalCost,
  365. externalAbroadCost: thisdata.externalAbroadCost,
  366. enterpriseFiller: thisdata.enterpriseFiller,
  367. signDate: thisdata.signDate,
  368. sortNumber: thisdata.sortNumber,
  369. startDateFormattedDate: thisdata.startDateFormattedDate,
  370. endDateFormattedDate: thisdata.endDateFormattedDate,
  371. projectMode: thisdata.projectMode,
  372. proofUrl: thisdata.proofUrl,
  373. proofDownloadFileName: thisdata.proofDownloadFileName
  374. });
  375. };
  376. this.state.pagination.current = data.data.pageNo;
  377. this.state.pagination.total = data.data.totalCount;
  378. this.setState({
  379. dataSource: this.state.data,
  380. pagination: this.state.pagination
  381. });
  382. }).always(function () {
  383. this.setState({
  384. loading: false
  385. });
  386. }.bind(this));
  387. },
  388. getInitialState() {
  389. return {
  390. mockData: [],
  391. selectedRowKeys: [],
  392. selectedRows: [],
  393. loading: false,
  394. pagination: {
  395. defaultCurrent: 1,
  396. defaultPageSize: 10,
  397. showQuickJumper: true,
  398. pageSize: 10,
  399. onChange: function (page) {
  400. this.loadData(page);
  401. }.bind(this),
  402. showTotal: function (total) {
  403. return '共' + total + '条数据';
  404. }
  405. },
  406. columns: [
  407. {
  408. title: '研发活动编号',
  409. dataIndex: 'activityNumber',
  410. key: 'activityNumber'
  411. }, {
  412. title: '研发活动名称',
  413. dataIndex: 'activityName',
  414. key: 'activityName'
  415. }, {
  416. title: '技术领域',
  417. dataIndex: 'technicalField',
  418. key: 'technicalField'
  419. }, {
  420. title: '技术来源',
  421. dataIndex: 'technicalSource',
  422. key: 'technicalSource',
  423. render: (text) => { return getTechnicalSource(text) }
  424. }, {
  425. title: '知识产权编号',
  426. dataIndex: 'intellectualPropertyNumber',
  427. key: 'intellectualPropertyNumber'
  428. }, {
  429. title: '开始时间',
  430. dataIndex: 'startDateFormattedDate',
  431. key: 'startDateFormattedDate'
  432. }, {
  433. title: '结束时间',
  434. dataIndex: 'endDateFormattedDate',
  435. key: 'endDateFormattedDate'
  436. }
  437. ],
  438. dataSource: []
  439. };
  440. },
  441. componentWillMount() {
  442. this.loadData();
  443. },
  444. tableRowClick(record, index) {
  445. this.state.RowData = record;
  446. this.setState({
  447. showDesc: true
  448. });
  449. },
  450. delectRow() {
  451. let deletedIds = [];
  452. for (let idx = 0; idx < this.state.selectedRows.length; idx++) {
  453. let rowItem = this.state.selectedRows[idx];
  454. if (rowItem.id) {
  455. deletedIds.push(rowItem.id)
  456. }
  457. }
  458. this.setState({
  459. selectedRowKeys: [],
  460. loading: deletedIds.length > 0
  461. });
  462. $.ajax({
  463. method: "POST",
  464. dataType: "json",
  465. crossDomain: false,
  466. url: globalConfig.context + "/techservice/cognizance/deleteActivity",
  467. data: {
  468. ids: deletedIds
  469. }
  470. }).done(function (data) {
  471. if (!data.error.length) {
  472. message.success('保存成功!');
  473. this.setState({
  474. loading: false,
  475. });
  476. } else {
  477. message.warning(data.error[0].message);
  478. };
  479. this.loadData();
  480. }.bind(this));
  481. },
  482. closeDesc(e) {
  483. this.state.showDesc = e;
  484. this.loadData();
  485. },
  486. search() {
  487. this.loadData();
  488. },
  489. reset() {
  490. this.state.activityName = undefined;
  491. this.state.activityNumber = undefined;
  492. this.loadData();
  493. },
  494. render() {
  495. const rowSelection = {
  496. selectedRowKeys: this.state.selectedRowKeys,
  497. onChange: (selectedRowKeys, selectedRows) => {
  498. this.setState({
  499. selectedRows: selectedRows,
  500. selectedRowKeys: selectedRowKeys
  501. });
  502. }
  503. };
  504. const hasSelected = this.state.selectedRowKeys.length > 0;
  505. return (
  506. <div className="user-content" >
  507. <div className="content-title">
  508. <span>企业研究开发活动情况表</span>
  509. </div>
  510. <div className="user-search">
  511. <Input placeholder="研发活动名称" value={this.state.activityName}
  512. onChange={(e) => { this.setState({ activityName: e.target.value }); }} />
  513. <Input placeholder="研发活动编号" value={this.state.activityNumber}
  514. onChange={(e) => { this.setState({ activityNumber: e.target.value }); }} />
  515. <Button type="primary" onClick={this.search}>搜索</Button>
  516. <Button onClick={this.reset}>重置</Button>
  517. <p>
  518. <Button style={{ background: "#ea0862", border: "none", color: "#fff" }}
  519. onClick={this.tableRowClick}>添加<Icon type="plus" /></Button>
  520. <Button style={{ background: "#3fcf9e", border: "none", color: "#fff" }}
  521. disabled={!hasSelected}
  522. onClick={this.delectRow}>删除<Icon type="minus" /></Button>
  523. </p>
  524. </div>
  525. <div className="patent-table">
  526. <Spin spinning={this.state.loading}>
  527. <Table columns={this.state.columns}
  528. dataSource={this.state.dataSource}
  529. pagination={this.state.pagination}
  530. rowSelection={rowSelection}
  531. onRowClick={this.tableRowClick} />
  532. </Spin>
  533. </div>
  534. <ActivityDesc data={this.state.RowData}
  535. mockData={this.state.mockData}
  536. showDesc={this.state.showDesc} closeDesc={this.closeDesc} />
  537. </div >
  538. );
  539. }
  540. });
  541. export default Activity;