activity.jsx 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747
  1. import React from 'react';
  2. import { Icon, Button, Upload, Input, Spin, Table, message, Select, Modal, DatePicker, Cascader, Transfer, InputNumber, Switch, Form } from 'antd';
  3. import { technicalSourceList } from '../../../../dataDic.js';
  4. import { techFieldList, getTechField } from '../../../../DicTechFieldList.js';
  5. import { getTechnicalSource, beforeUploadFile, newDownloadFile, getProportion, saveProportion, getPreview } from '../../../../tools.js';
  6. import moment from 'moment';
  7. import ajax from 'jquery/src/ajax/xhr.js';
  8. import $ from 'jquery/src/ajax';
  9. if (!Array.prototype.includes) {
  10. Object.defineProperty(Array.prototype, 'includes', {
  11. value: function (searchElement, fromIndex) {
  12. // 1. Let O be ? ToObject(this value).
  13. if (this == null) {
  14. throw new TypeError('"this" is null or not defined');
  15. }
  16. var o = Object(this);
  17. // 2. Let len be ? ToLength(? Get(O, "length")).
  18. var len = o.length >>> 0;
  19. // 3. If len is 0, return false.
  20. if (len === 0) {
  21. return false;
  22. }
  23. // 4. Let n be ? ToInteger(fromIndex).
  24. // (If fromIndex is undefined, this step produces the value 0.)
  25. var n = fromIndex | 0;
  26. // 5. If n ≥ 0, then
  27. // a. Let k be n.
  28. // 6. Else n < 0,
  29. // a. Let k be len + n.
  30. // b. If k < 0, let k be 0.
  31. var k = Math.max(n >= 0 ? n : len - Math.abs(n), 0);
  32. // 7. Repeat, while k < len
  33. while (k < len) {
  34. // a. Let elementK be the result of ? Get(O, ! ToString(k)).
  35. // b. If SameValueZero(searchElement, elementK) is true, return true.
  36. // c. Increase k by 1.
  37. // NOTE: === provides the correct "SameValueZero" comparison needed here.
  38. if (o[k] === searchElement) {
  39. return true;
  40. }
  41. k++;
  42. }
  43. // 8. Return false
  44. return false;
  45. }
  46. });
  47. }
  48. const ActivityForm = Form.create()(React.createClass({
  49. getInitialState() {
  50. return {
  51. loading: false,
  52. targetKeys: [],
  53. selectedKeys: []
  54. };
  55. },
  56. loadData(id) {
  57. this.setState({ loading: true });
  58. $.ajax({
  59. method: "get",
  60. dataType: "json",
  61. crossDomain: false,
  62. url: globalConfig.context + "/api/admin/activityDetail",
  63. data: {
  64. id: id || this.props.data.id
  65. }
  66. }).done(function (data) {
  67. if (!data.data) {
  68. if (data.error && data.error.length) {
  69. message.warning(data.error[0].message);
  70. };
  71. };
  72. this.setState({
  73. data: data.data,
  74. targetKeys: data.data.intellectualPropertyNumber ? data.data.intellectualPropertyNumber.split(",") : [],
  75. techField: [data.data.technicalField1, data.data.technicalField2, data.data.technicalField3]
  76. });
  77. }.bind(this)).always(function (data) {
  78. this.setState({ loading: false });
  79. }.bind(this));
  80. },
  81. handleSubmit(e) {
  82. e.preventDefault();
  83. this.props.form.validateFields((err, values) => {
  84. if (!err) {
  85. this.setState({ loading: true });
  86. $.ajax({
  87. method: "POST",
  88. dataType: "json",
  89. crossDomain: false,
  90. url: globalConfig.context + "/api/admin/activity",
  91. data: {
  92. id: this.props.data.id,
  93. uid: this.props.uid,
  94. activityName: values.activityName,
  95. activityNumber: values.activityNumber,
  96. projectMode: values.projectMode,
  97. startDateFormattedDate: values.startDate ? values.startDate.format("YYYY-MM-DD") : null,
  98. endDateFormattedDate: values.endDate ? values.endDate.format("YYYY-MM-DD") : null,
  99. technicalField1: values.techField[0],
  100. technicalField2: values.techField[1],
  101. technicalField3: values.techField[2],
  102. technicalSource: values.technicalSource,
  103. intellectualPropertyNumber: this.state.targetKeys.join(","),
  104. budget: values.budget,
  105. implement: values.implement,
  106. technologyInnovation: values.technologyInnovation,
  107. achievement: values.achievement,
  108. proofUrl: this.state.proofUrl
  109. }
  110. }).done(function (data) {
  111. if (!data.error.length) {
  112. message.success('保存成功!');
  113. this.props.closeModal(true);
  114. } else {
  115. message.warning(data.error[0].message);
  116. };
  117. this.setState({ loading: false });
  118. }.bind(this));
  119. }
  120. });
  121. },
  122. componentWillMount() {
  123. if (this.props.data.id) {
  124. this.loadData();
  125. } else {
  126. this.state.data = {};
  127. this.state.targetKeys = [];
  128. this.state.techField = undefined;
  129. };
  130. },
  131. componentWillReceiveProps(nextProps) {
  132. if (!this.props.visible && nextProps.visible) {
  133. this.state.mockData = nextProps.data.mockData;
  134. this.props.form.resetFields();
  135. this.state.fileList = [];
  136. this.state.proofUrl = undefined;
  137. if (nextProps.data.id) {
  138. this.loadData(nextProps.data.id);
  139. } else {
  140. this.state.data = {};
  141. this.state.targetKeys = [];
  142. this.state.techField = undefined;
  143. };
  144. };
  145. },
  146. intellectualChange(nextTargetKeys, direction, moveKeys) {
  147. //debugger
  148. this.setState({ targetKeys: nextTargetKeys });
  149. },
  150. intellectualSelectChange(sourceSelectedKeys, targetSelectedKeys) {
  151. this.setState({ selectedKeys: [...sourceSelectedKeys, ...targetSelectedKeys] });
  152. },
  153. render() {
  154. const FormItem = Form.Item;
  155. const { getFieldDecorator } = this.props.form;
  156. const theData = this.state.data;
  157. const formItemLayout = {
  158. labelCol: { span: 6 },
  159. wrapperCol: { span: 12 },
  160. };
  161. if (theData) {
  162. return (
  163. <Spin spinning={this.state.loading} className='spin-box'>
  164. <Form onSubmit={this.handleSubmit} id="admin-desc-content">
  165. <div className="clearfix">
  166. <FormItem className="half-item"
  167. {...formItemLayout}
  168. label="研发活动编号"
  169. >
  170. {getFieldDecorator('activityNumber', {
  171. initialValue: theData.activityNumber
  172. })(
  173. <Input />
  174. )}
  175. </FormItem>
  176. <FormItem className="half-item"
  177. {...formItemLayout}
  178. label="研发活动名称"
  179. >
  180. {getFieldDecorator('activityName', {
  181. initialValue: theData.activityName
  182. })(
  183. <Input />
  184. )}
  185. </FormItem>
  186. <FormItem className="half-item"
  187. {...formItemLayout}
  188. label="开始日期"
  189. >
  190. {getFieldDecorator('startDate', {
  191. initialValue: theData.startDateFormattedDate ? moment(theData.startDateFormattedDate) : null
  192. })(
  193. <DatePicker />
  194. )}
  195. </FormItem>
  196. <FormItem className="half-item"
  197. {...formItemLayout}
  198. label="结束日期"
  199. >
  200. {getFieldDecorator('endDate', {
  201. initialValue: theData.endDateFormattedDate ? moment(theData.endDateFormattedDate) : null
  202. })(
  203. <DatePicker />
  204. )}
  205. </FormItem>
  206. </div>
  207. <div className="clearfix">
  208. <FormItem className="half-item"
  209. {...formItemLayout}
  210. label="技术领域"
  211. >
  212. {getFieldDecorator('techField', {
  213. initialValue: this.state.techField || []
  214. })(
  215. <Cascader
  216. style={{ width: 500 }}
  217. options={techFieldList}
  218. placeholder="选择技术领域"
  219. showSearch
  220. />
  221. )}
  222. </FormItem>
  223. </div>
  224. <div className="clearfix">
  225. <FormItem className="half-item"
  226. {...formItemLayout}
  227. label="技术来源"
  228. >
  229. {getFieldDecorator('technicalSource', {
  230. initialValue: theData.technicalSource ? String(theData.technicalSource) : undefined,
  231. })(
  232. <Select placeholder="选择技术来源" style={{ width: 230 }}>
  233. {
  234. technicalSourceList.map(function (item, i) {
  235. return <Select.Option key={1000 + i} value={item.value} >{item.key}</Select.Option>
  236. })
  237. }
  238. </Select>
  239. )}
  240. </FormItem>
  241. <FormItem className="half-item"
  242. {...formItemLayout}
  243. label="立项类型"
  244. >
  245. {getFieldDecorator('projectMode', {
  246. initialValue: theData.projectMode
  247. })(
  248. <Select style={{ width: 120 }}>
  249. <Select.Option value='0'>内部立项</Select.Option>
  250. <Select.Option value='1'>外部立项</Select.Option>
  251. </Select>
  252. )}
  253. </FormItem>
  254. </div>
  255. <div style={{ marginBottom: '20px' }}>
  256. <p>知识产权编号:</p>
  257. <Transfer
  258. dataSource={this.props.mockData}
  259. listStyle={{
  260. width: 300,
  261. height: 300,
  262. }}
  263. titles={['未选择', '已选择']}
  264. targetKeys={this.state.targetKeys || []}
  265. selectedKeys={this.state.selectedKeys || []}
  266. onChange={this.intellectualChange}
  267. onSelectChange={this.intellectualSelectChange}
  268. render={item => `${item.name}-${item.number}`}
  269. />
  270. </div>
  271. <FormItem className="half-div"
  272. labelCol={{ span: 8 }}
  273. wrapperCol={{ span: 12 }}
  274. label="研发经费总预算"
  275. >
  276. {getFieldDecorator('budget', {
  277. initialValue: theData.budget
  278. })(
  279. <InputNumber min={0} max={999999} step={0.01} />
  280. )}
  281. <span>万元</span>
  282. </FormItem>
  283. <div className="clearfix" >
  284. <p>研发经费近三年总支出:</p>
  285. <FormItem className="half-item"
  286. labelCol={{ span: 8 }}
  287. wrapperCol={{ span: 12 }}
  288. label="总计"
  289. >
  290. <span>{
  291. (theData.firstYearExpenditure || 0) +
  292. (theData.secondYearExpenditure || 0) +
  293. (theData.thirdYearExpenditure || 0)
  294. }</span>
  295. <span>万元</span>
  296. </FormItem>
  297. <FormItem className="half-item"
  298. labelCol={{ span: 8 }}
  299. wrapperCol={{ span: 12 }}
  300. label="其中(前一年)"
  301. >
  302. <span>{theData.firstYearExpenditure}</span>
  303. <span>万元</span>
  304. </FormItem>
  305. <FormItem className="half-item"
  306. labelCol={{ span: 8 }}
  307. wrapperCol={{ span: 12 }}
  308. label="其中(前二年)"
  309. >
  310. <span>{theData.secondYearExpenditure}</span>
  311. <span>万元</span>
  312. </FormItem>
  313. <FormItem className="half-item"
  314. labelCol={{ span: 8 }}
  315. wrapperCol={{ span: 12 }}
  316. label="其中(前三年)"
  317. >
  318. <span>{theData.thirdYearExpenditure}</span>
  319. <span>万元</span>
  320. </FormItem>
  321. </div>
  322. <div className="clearfix">
  323. <div className="half-div">
  324. <p>目的及组织实施方式(限400字):</p>
  325. {getFieldDecorator('implement', {
  326. initialValue: theData.implement
  327. })(
  328. <Input type="textarea" rows={6} />
  329. )}
  330. </div>
  331. <div className="half-div">
  332. <p>核心技术及创新点(限400字):</p>
  333. {getFieldDecorator('technologyInnovation', {
  334. initialValue: theData.technologyInnovation
  335. })(
  336. <Input type="textarea" rows={6} />
  337. )}
  338. </div>
  339. <div className="half-div">
  340. <p>取得的阶段性成果(限400字):</p>
  341. {getFieldDecorator('achievement', {
  342. initialValue: theData.achievement
  343. })(
  344. <Input type="textarea" rows={6} />
  345. )}
  346. </div>
  347. </div>
  348. <div style={{ width: '50%' }}>
  349. <Upload
  350. name="ratepay"
  351. action={globalConfig.context + "/api/admin/uploadProof"}
  352. data={{ 'sign': 'proof', 'uid': this.props.uid }}
  353. beforeUpload={beforeUploadFile}
  354. fileList={this.state.fileList}
  355. onChange={(info) => {
  356. if (info.file.status !== 'uploading') {
  357. // console.log(info.file, info.fileList);
  358. }
  359. if (info.file.status === 'done') {
  360. if (!info.file.response.error.length) {
  361. message.success(`${info.file.name} 文件上传成功!`);
  362. } else {
  363. message.warning(info.file.response.error[0].message);
  364. return;
  365. };
  366. this.state.proofUrl = info.file.response.data;
  367. } else if (info.file.status === 'error') {
  368. message.error(`${info.file.name} 文件上传失败。`);
  369. };
  370. this.setState({ fileList: info.fileList.slice(-1) });
  371. }}
  372. >
  373. <Button><Icon type="upload" /> 上传立项证明材料 </Button>
  374. </Upload>
  375. <p>{theData.proofUrl ?
  376. <span className="download-file">
  377. <a onClick={newDownloadFile.bind(null, theData.id, 'proof', '/api/admin/downloadProof')}>{theData.proofDownloadFileName}</a>
  378. <a onClick={() => {
  379. var newTab = window.open('about:blank'); getPreview(theData.id, 'activity', 'proof', function (data) { newTab.location.href = data; });
  380. }}><Icon style={{ fontSize: '16px' }} type="eye-o" /></a>
  381. </span>
  382. : <span><Icon type="exclamation-circle" style={{ color: '#ffbf00', marginRight: '6px' }} />未上传!</span>}</p>
  383. </div>
  384. <FormItem style={{ marginTop: '20px' }}>
  385. <Button className="set-submit" type="primary" htmlType="submit">保存</Button>
  386. <Button type="ghost" style={{ marginLeft: '20px' }} onClick={this.props.closeModal}>取消</Button>
  387. </FormItem>
  388. </Form >
  389. </Spin >
  390. )
  391. } else {
  392. return (<div></div>)
  393. };
  394. }
  395. }));
  396. const ActivityDesc = React.createClass({
  397. getInitialState() {
  398. return {
  399. visible: false,
  400. loading: false
  401. };
  402. },
  403. handleCancel(e) {
  404. this.setState({
  405. visible: false,
  406. });
  407. if (e) {
  408. this.props.closeDesc(true);
  409. };
  410. },
  411. componentWillReceiveProps(nextProps) {
  412. this.state.visible = nextProps.showDesc;
  413. },
  414. render() {
  415. return (
  416. <div className="admin-desc">
  417. <Modal maskClosable={false} title="企业研究开发活动情况详情"
  418. visible={this.state.visible}
  419. onCancel={this.handleCancel}
  420. width='800px'
  421. footer=''
  422. className="admin-desc-content">
  423. <ActivityForm
  424. visible={this.state.visible}
  425. data={this.props.data}
  426. uid={this.props.uid}
  427. mockData={this.props.mockData}
  428. spinState={this.spinChange}
  429. closeModal={this.handleCancel} />
  430. </Modal>
  431. </div>
  432. );
  433. },
  434. });
  435. const Activity = React.createClass({
  436. loadData(pageNo) {
  437. this.state.data = [];
  438. this.setState({
  439. loading: true
  440. });
  441. $.when($.ajax({
  442. method: "post",
  443. dataType: "json",
  444. crossDomain: false,
  445. url: globalConfig.context + "/api/admin/activityList",
  446. data: {
  447. pageNo: pageNo || 1,
  448. pageSize: this.state.pagination.pageSize,
  449. uid: this.props.data.uid,
  450. activityNumber: this.state.activityNumber,
  451. activityName: this.state.activityName,
  452. startDateFormattedDate: this.state.startDateFormattedDate,
  453. endDateFormattedDate: this.state.endDateFormattedDate
  454. }
  455. }), $.ajax({
  456. method: "post",
  457. dataType: "json",
  458. crossDomain: false,
  459. url: globalConfig.context + "/api/admin/intellectualList",
  460. data: {
  461. uid: this.props.data.uid,
  462. pageNo: pageNo || 1,
  463. pageSize: 99,
  464. }
  465. })).done((data1, data2) => {
  466. let data = data1[0];
  467. let intellectualList = data2[0];
  468. let theArr = [], theObj = {};
  469. if (data.error.length || !data.data || !data.data.list) {
  470. message.warning(data.error[0].message);
  471. } else {
  472. for (let i = 0; i < data.data.list.length; i++) {
  473. let thisdata = data.data.list[i];
  474. this.state.data.push({
  475. key: i,
  476. id: thisdata.id,
  477. uid: thisdata.uid,
  478. activityNumber: thisdata.activityNumber,
  479. activityName: thisdata.activityName,
  480. startDate: thisdata.startDate,
  481. endDate: thisdata.endDate,
  482. mockData: this.state.mockData,
  483. techField: [thisdata.technicalField1, thisdata.technicalField2, thisdata.technicalField3],
  484. technicalField: getTechField(thisdata.technicalField1, thisdata.technicalField2, thisdata.technicalField3),
  485. technicalField1: thisdata.technicalField1,
  486. technicalField2: thisdata.technicalField2,
  487. technicalField3: thisdata.technicalField3,
  488. technicalSource: thisdata.technicalSource ? String(thisdata.technicalSource) : undefined,
  489. intellectualPropertyNumber: thisdata.intellectualPropertyNumber ? thisdata.intellectualPropertyNumber.split(",") : [],
  490. intellectualPropertyNumberText: thisdata.intellectualPropertyNumber,
  491. budget: thisdata.budget,
  492. firstYearExpenditure: thisdata.firstYearExpenditure,
  493. secondYearExpenditure: thisdata.secondYearExpenditure,
  494. thirdYearExpenditure: thisdata.thirdYearExpenditure,
  495. implement: thisdata.implement,
  496. technologyInnovation: thisdata.technologyInnovation,
  497. achievement: thisdata.achievement,
  498. internalLaborCost: thisdata.internalLaborCost,
  499. internalDirectCost: thisdata.internalDirectCost,
  500. internalDepreciationCost: thisdata.internalDepreciationCost,
  501. internalAmortizationCost: thisdata.internalAmortizationCost,
  502. internalDesignCost: thisdata.internalDesignCost,
  503. internalEquipmentCost: thisdata.internalEquipmentCost,
  504. internalOtherCost: thisdata.internalOtherCost,
  505. externalTotalCost: thisdata.externalTotalCost,
  506. externalAbroadCost: thisdata.externalAbroadCost,
  507. enterpriseFiller: thisdata.enterpriseFiller,
  508. signDate: thisdata.signDate,
  509. sortNumber: thisdata.sortNumber,
  510. startDateFormattedDate: thisdata.startDateFormattedDate,
  511. endDateFormattedDate: thisdata.endDateFormattedDate,
  512. projectMode: thisdata.projectMode,
  513. proofUrl: thisdata.proofUrl,
  514. proofDownloadFileName: thisdata.proofDownloadFileName
  515. });
  516. };
  517. this.state.pagination.current = data.data.pageNo;
  518. this.state.pagination.total = data.data.totalCount;
  519. };
  520. if (intellectualList.error.length || !intellectualList.data || !intellectualList.data.list) {
  521. message.warning(intellectualList.error[0].message);
  522. } else {
  523. for (let i = 0; i < intellectualList.data.list.length; i++) {
  524. theArr.push({
  525. key: intellectualList.data.list[i].id,
  526. number: intellectualList.data.list[i].intellectualPropertyNumber,
  527. name: intellectualList.data.list[i].intellectualPropertyName
  528. });
  529. theObj[intellectualList.data.list[i].id] = intellectualList.data.list[i].intellectualPropertyNumber;
  530. };
  531. };
  532. this.setState({
  533. dataSource: this.state.data,
  534. pagination: this.state.pagination,
  535. mockData: theArr,
  536. mockDataObj: theObj
  537. });
  538. }).always(function () {
  539. this.setState({
  540. loading: false
  541. });
  542. }.bind(this));
  543. let _me = this;
  544. getProportion(this.props.data.uid, function (data) { _me.setState({ proportion: data }); });
  545. },
  546. getInitialState() {
  547. return {
  548. mockData: [],
  549. mockDataObj: {},
  550. selectedRowKeys: [],
  551. selectedRows: [],
  552. loading: false,
  553. pagination: {
  554. defaultCurrent: 1,
  555. defaultPageSize: 10,
  556. showQuickJumper: true,
  557. pageSize: 10,
  558. onChange: function (page) {
  559. this.loadData(page);
  560. }.bind(this),
  561. showTotal: function (total) {
  562. return '共' + total + '条数据';
  563. }
  564. },
  565. columns: [
  566. {
  567. title: '研发活动编号',
  568. dataIndex: 'activityNumber',
  569. key: 'activityNumber'
  570. }, {
  571. title: '研发活动名称',
  572. dataIndex: 'activityName',
  573. key: 'activityName'
  574. }, {
  575. title: '技术领域',
  576. dataIndex: 'technicalField',
  577. key: 'technicalField'
  578. }, {
  579. title: '技术来源',
  580. dataIndex: 'technicalSource',
  581. key: 'technicalSource',
  582. render: (text) => { return getTechnicalSource(text) }
  583. }, {
  584. title: '知识产权编号',
  585. dataIndex: 'intellectualPropertyNumberText',
  586. key: 'intellectualPropertyNumberText',
  587. render: (text) => {
  588. let arr = [], _me = this;
  589. if (text && text.split(',').length) {
  590. text.split(',').map((item) => {
  591. arr.push(_me.state.mockDataObj[item]);
  592. });
  593. };
  594. return arr.join(',');
  595. }
  596. }, {
  597. title: '开始时间',
  598. dataIndex: 'startDateFormattedDate',
  599. key: 'startDateFormattedDate'
  600. }, {
  601. title: '结束时间',
  602. dataIndex: 'endDateFormattedDate',
  603. key: 'endDateFormattedDate'
  604. }
  605. ],
  606. dataSource: []
  607. };
  608. },
  609. componentWillMount() {
  610. this.loadData();
  611. },
  612. tableRowClick(record, index) {
  613. this.state.RowData = record;
  614. this.setState({
  615. showDesc: true
  616. });
  617. },
  618. delectRow() {
  619. let deletedIds = [];
  620. for (let idx = 0; idx < this.state.selectedRows.length; idx++) {
  621. let rowItem = this.state.selectedRows[idx];
  622. if (rowItem.id) {
  623. deletedIds.push(rowItem.id)
  624. }
  625. }
  626. this.setState({
  627. selectedRowKeys: [],
  628. loading: deletedIds.length > 0
  629. });
  630. $.ajax({
  631. method: "post",
  632. dataType: "json",
  633. crossDomain: false,
  634. url: globalConfig.context + "/api/admin/deleteActivity",
  635. data: {
  636. ids: deletedIds
  637. }
  638. }).done(function (data) {
  639. if (!data.error.length) {
  640. message.success('删除成功!');
  641. this.setState({
  642. loading: false,
  643. });
  644. } else {
  645. message.warning(data.error[0].message);
  646. };
  647. this.loadData();
  648. }.bind(this));
  649. },
  650. closeDesc(e) {
  651. this.state.showDesc = false;
  652. if (e) {
  653. this.loadData();
  654. };
  655. },
  656. search() {
  657. this.loadData();
  658. },
  659. reset() {
  660. this.state.activityName = undefined;
  661. this.state.activityNumber = undefined;
  662. this.state.startDateFormattedDate = undefined;
  663. this.state.endDateFormattedDate = undefined;
  664. this.loadData();
  665. },
  666. render() {
  667. const rowSelection = {
  668. selectedRowKeys: this.state.selectedRowKeys,
  669. onChange: (selectedRowKeys, selectedRows) => {
  670. this.setState({
  671. selectedRows: selectedRows,
  672. selectedRowKeys: selectedRowKeys
  673. });
  674. }
  675. };
  676. const hasSelected = this.state.selectedRowKeys.length > 0;
  677. return (
  678. <div className="user-content" >
  679. <div className="content-title">
  680. <span>企业研究开发活动情况表</span>
  681. <span className="proportion"> 是否已完成:</span>
  682. <Switch
  683. checked={this.state.proportion && this.state.proportion.activity == 1 ? true : false}
  684. checkedChildren={'已完成'}
  685. unCheckedChildren={'未完成'}
  686. onChange={(e) => {
  687. e ? this.state.proportion.activity = 1 : this.state.proportion.activity = 0;
  688. saveProportion(this.state.proportion.id, this.props.data.uid, 'activity', this.state.proportion.activity);
  689. this.setState({ proportion: this.state.proportion });
  690. }} />
  691. </div>
  692. <div className="user-search">
  693. <Input placeholder="研发活动名称" value={this.state.activityName}
  694. onChange={(e) => { this.setState({ activityName: e.target.value }); }} />
  695. <Input placeholder="研发活动编号" value={this.state.activityNumber}
  696. onChange={(e) => { this.setState({ activityNumber: e.target.value }); }} />
  697. <span>开始日期:</span>
  698. <DatePicker
  699. value={this.state.startDateFormattedDate ? moment(this.state.startDateFormattedDate) : null}
  700. onChange={(data, dataString) => { this.setState({ startDateFormattedDate: dataString }); }} />
  701. <span>结束日期:</span>
  702. <DatePicker
  703. value={this.state.endDateFormattedDate ? moment(this.state.endDateFormattedDate) : null}
  704. onChange={(data, dataString) => { this.setState({ endDateFormattedDate: dataString }); }} />
  705. <Button type="primary" onClick={this.search}>搜索</Button>
  706. <Button onClick={this.reset}>重置</Button>
  707. <p>
  708. <Button style={{ background: "#ea0862", border: "none", color: "#fff" }}
  709. onClick={this.tableRowClick}>添加<Icon type="plus" /></Button>
  710. <Button style={{ background: "#3fcf9e", border: "none", color: "#fff" }}
  711. disabled={!hasSelected}
  712. onClick={this.delectRow}>删除<Icon type="minus" /></Button>
  713. </p>
  714. </div>
  715. <div className="patent-table" >
  716. <Spin spinning={this.state.loading}>
  717. <Table columns={this.state.columns}
  718. dataSource={this.state.dataSource}
  719. pagination={this.state.pagination}
  720. rowSelection={rowSelection}
  721. onRowClick={this.tableRowClick} />
  722. </Spin>
  723. </div>
  724. <ActivityDesc data={this.state.RowData}
  725. uid={this.props.data.uid}
  726. mockData={this.state.mockData}
  727. showDesc={this.state.showDesc} closeDesc={this.closeDesc} />
  728. </div >
  729. );
  730. }
  731. });
  732. export default Activity;