activity.jsx 27 KB

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