activity.jsx 27 KB

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