activity.jsx 26 KB

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