activity.jsx 25 KB

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