activity.jsx 28 KB

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