activity.jsx 26 KB

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