activity.jsx 23 KB

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