orgTechCenter.jsx 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516
  1. import React from 'react';
  2. import { Icon, Form, Button, Input, Spin, Table, message, Modal, Upload, DatePicker } from 'antd';
  3. import './techProduct.less';
  4. import { beforeUploadFile, newDownloadFile } 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 CenterListDescFrom = Form.create()(React.createClass({
  9. getInitialState() {
  10. return {
  11. loading: false
  12. };
  13. },
  14. handleSubmit(e) {
  15. e.preventDefault();
  16. this.props.form.validateFields((err, values) => {
  17. if (!err) {
  18. this.props.spinState(true);
  19. $.ajax({
  20. method: "POST",
  21. dataType: "json",
  22. crossDomain: false,
  23. url: globalConfig.context + "/api/user/cognizance/disposeCenterDetail",
  24. data: {
  25. id: this.props.data.id,
  26. projectName: values.projectName,
  27. projectTimeFormattedDate: values.projectTimeFormattedDate.format("YYYY-MM-DD"),
  28. institution: values.institution,
  29. termStartTimeFormattedDate: values.termTimeFormattedDate[0].format("YYYY-MM-DD"),
  30. termEndTimeFormattedDate: values.termTimeFormattedDate[1].format("YYYY-MM-DD"),
  31. protocolUrl: this.state.protocolUrl
  32. }
  33. }).done(function (data) {
  34. if (!data.error.length) {
  35. message.success('保存成功!');
  36. this.props.clickOk();
  37. this.props.spinState(false);
  38. this.props.form.resetFields();
  39. } else {
  40. message.warning(data.error[0].message);
  41. this.props.spinState(false);
  42. }
  43. }.bind(this));
  44. }
  45. });
  46. },
  47. render() {
  48. const FormItem = Form.Item;
  49. const { getFieldDecorator } = this.props.form;
  50. const { RangePicker } = DatePicker;
  51. const theData = this.props.data;
  52. const formItemLayout = {
  53. labelCol: { span: 4 },
  54. wrapperCol: { span: 12 },
  55. };
  56. const _me = this;
  57. return (
  58. <Form onSubmit={this.handleSubmit} className="activityCost-form">
  59. <div className="clearfix">
  60. <FormItem className="half-item"
  61. {...formItemLayout}
  62. label="时间"
  63. >
  64. {getFieldDecorator('projectTimeFormattedDate', {
  65. rules: [{ type: 'object', required: true, message: '此项为必填项!' }],
  66. initialValue: theData.projectTimeFormattedDate ? moment(theData.projectTimeFormattedDate) : null
  67. })(
  68. <DatePicker />
  69. )}
  70. </FormItem>
  71. <FormItem className="half-item"
  72. {...formItemLayout}
  73. label="项目名称"
  74. >
  75. {getFieldDecorator('projectName', {
  76. rules: [{ required: true, message: '此项为必填项!' }],
  77. initialValue: theData.projectName
  78. })(
  79. <Input />
  80. )}
  81. </FormItem>
  82. <FormItem className="half-item"
  83. {...formItemLayout}
  84. label="期限"
  85. >
  86. {getFieldDecorator('termTimeFormattedDate', {
  87. rules: [{ type: 'array', required: true, message: '此项为必填项!' }],
  88. initialValue: theData.termStartTimeFormattedDate && theData.termEndTimeFormattedDate ? [moment(theData.termStartTimeFormattedDate), moment(theData.termEndTimeFormattedDate)] : [null, null]
  89. })(
  90. <RangePicker />
  91. )}
  92. </FormItem>
  93. <FormItem className="half-item"
  94. {...formItemLayout}
  95. label="科研院所"
  96. >
  97. {getFieldDecorator('institution', {
  98. rules: [{ required: true, message: '此项为必填项!' }],
  99. initialValue: theData.institution
  100. })(
  101. <Input />
  102. )}
  103. </FormItem>
  104. </div>
  105. <div className="hrSituation-roster">
  106. <Upload
  107. name="ratepay"
  108. action={globalConfig.context + "/api/user/cognizance/uploadProtocol"}
  109. data={{ 'sign': 'protocol' }}
  110. beforeUpload={beforeUploadFile}
  111. showUploadList={false}
  112. onChange={(info) => {
  113. if (info.file.status !== 'uploading') {
  114. console.log(info.file, info.fileList);
  115. }
  116. if (info.file.status === 'done') {
  117. if (!info.file.response.error.length) {
  118. message.success(`${info.file.name} 文件上传成功!`);
  119. } else {
  120. message.warning(info.file.response.error[0].message);
  121. return;
  122. };
  123. this.state.protocolUrl = info.file.response.data;
  124. } else if (info.file.status === 'error') {
  125. message.error(`${info.file.name} 文件上传失败。`);
  126. }
  127. }}
  128. >
  129. <Button><Icon type="upload" /> 上传研发费用台账 </Button>
  130. </Upload>
  131. <p style={{ marginTop: '10px' }}>{theData.protocolUrl ? <a onClick={newDownloadFile.bind(null, theData.id, 'protocol', '/api/user/cognizance/downloadProtocol')}>{theData.protocolDownloadFileName}</a> : <span><Icon type="exclamation-circle" style={{ color: '#ffbf00', marginRight: '6px' }} />未上传!</span>}</p>
  132. </div>
  133. <FormItem style={{ marginTop: '20px' }}>
  134. <Button className="set-submit" type="primary" htmlType="submit">保存</Button>
  135. <Button type="ghost" style={{ marginLeft: '20px' }} onClick={this.props.closeModal}>取消</Button>
  136. </FormItem>
  137. </Form >
  138. );
  139. },
  140. }));
  141. const CenterListDesc = React.createClass({
  142. getInitialState() {
  143. return {
  144. visible: false,
  145. loading: false
  146. };
  147. },
  148. componentWillReceiveProps(nextProps) {
  149. this.state.visible = nextProps.showDesc
  150. },
  151. showModal() {
  152. this.setState({
  153. visible: true,
  154. });
  155. },
  156. handleOk() {
  157. this.setState({
  158. visible: false,
  159. });
  160. this.props.closeDesc(false, true);
  161. },
  162. handleCancel(e) {
  163. this.setState({
  164. visible: false,
  165. });
  166. this.props.closeDesc(false);
  167. },
  168. spinChange(e) {
  169. this.setState({
  170. loading: e
  171. });
  172. },
  173. render() {
  174. return (
  175. <div className="patent-addNew">
  176. <Spin spinning={this.state.loading} className='spin-box'>
  177. <Modal title="产学研情况详情" visible={this.state.visible}
  178. onOk={this.handleOk} onCancel={this.handleCancel}
  179. width='800px'
  180. footer=''
  181. >
  182. <CenterListDescFrom data={this.props.data}
  183. spinState={this.spinChange} closeModal={this.handleCancel} clickOk={this.handleOk} />
  184. </Modal>
  185. </Spin>
  186. </div>
  187. );
  188. },
  189. });
  190. const CenterList = React.createClass({
  191. loadOrgTechCenterDetail() {
  192. this.setState({
  193. loading: true
  194. });
  195. $.ajax({
  196. method: "get",
  197. dataType: "json",
  198. crossDomain: false,
  199. url: globalConfig.context + "/api/user/cognizance/center",
  200. data: {
  201. }
  202. }).done((data) => {
  203. if (!data.data) {
  204. if (data.error && data.error.length) {
  205. message.warning(data.error[0].message);
  206. this.state.ButtonDisabled = true;
  207. }
  208. return;
  209. };
  210. this.state.cid = data.data.id;
  211. this.state.foundingTime = data.data.foundingTimeFormattedDate;
  212. this.state.principal = data.data.principal;
  213. this.state.systemCatalog = data.data.systemCatalog;
  214. this.state.systemUrl = data.data.systemUrl;
  215. this.state.systemDownloadFileName = data.data.systemDownloadFileName;
  216. this.state.centerName = data.data.centerName;
  217. this.state.comment = data.data.comment;
  218. this.loadData();
  219. }).always(function () {
  220. this.setState({
  221. loading: false
  222. });
  223. }.bind(this));
  224. },
  225. loadData(pageNo) {
  226. this.state.data = [];
  227. this.setState({
  228. loading: true
  229. });
  230. $.ajax({
  231. method: "post",
  232. dataType: "json",
  233. crossDomain: false,
  234. url: globalConfig.context + "/api/user/cognizance/centerDetail",
  235. data: {
  236. pageNo: pageNo || 1,
  237. pageSize: this.state.pagination.pageSize,
  238. cid: this.state.cid
  239. }
  240. }).done((data) => {
  241. if (!data.data || !data.data.list) {
  242. if (data.error.length) {
  243. message.warning(data.error[0].message);
  244. }
  245. return;
  246. };
  247. for (let i = 0; i < data.data.list.length; i++) {
  248. let thisdata = data.data.list[i];
  249. this.state.data.push({
  250. key: i,
  251. id: thisdata.id,
  252. cid: thisdata.cid,
  253. projectTimeFormattedDate: thisdata.projectTimeFormattedDate,
  254. projectName: thisdata.projectName,
  255. protocolDownloadFileName: thisdata.protocolDownloadFileName,
  256. protocolUrl: thisdata.protocolUrl,
  257. protocol: [thisdata.id, thisdata.protocolDownloadFileName],
  258. institution: thisdata.institution,
  259. termTimeFormattedDate: [thisdata.termStartTimeFormattedDate, thisdata.termEndTimeFormattedDate],
  260. termStartTimeFormattedDate: thisdata.termStartTimeFormattedDate,
  261. termEndTimeFormattedDate: thisdata.termEndTimeFormattedDate
  262. });
  263. };
  264. this.state.pagination.current = data.data.pageNo;
  265. this.state.pagination.total = data.data.totalCount;
  266. this.setState({
  267. dataSource: this.state.data,
  268. pagination: this.state.pagination
  269. });
  270. }).always(function () {
  271. this.setState({
  272. loading: false
  273. });
  274. }.bind(this));
  275. },
  276. getInitialState() {
  277. return {
  278. selectedRowKeys: [],
  279. selectedRows: [],
  280. loading: false,
  281. pagination: {
  282. defaultCurrent: 1,
  283. defaultPageSize: 10,
  284. showQuickJumper: true,
  285. pageSize: 10,
  286. onChange: function (page) {
  287. this.loadData(page);
  288. }.bind(this),
  289. showTotal: function (total) {
  290. return '共' + total + '条数据';
  291. }
  292. },
  293. columns: [
  294. {
  295. title: '时间',
  296. dataIndex: 'projectTimeFormattedDate',
  297. key: 'projectTimeFormattedDate'
  298. }, {
  299. title: '项目名称',
  300. dataIndex: 'projectName',
  301. key: 'projectName'
  302. }, {
  303. title: '期限',
  304. dataIndex: 'termTimeFormattedDate',
  305. key: 'termTimeFormattedDate',
  306. render: (text) => {
  307. return text[0] + ' - ' + text[1];
  308. }
  309. }, {
  310. title: '科研院所',
  311. dataIndex: 'institution',
  312. key: 'institution'
  313. }, {
  314. title: '协议附件',
  315. dataIndex: 'protocol',
  316. key: 'protocol',
  317. render: (text) => {
  318. return <a onClick={newDownloadFile.bind(null, text[0], 'protocol', '/api/user/cognizance/downloadProtocol')}>{text[1]}</a>
  319. }
  320. }
  321. ],
  322. dataSource: []
  323. };
  324. },
  325. componentWillMount() {
  326. this.loadOrgTechCenterDetail();
  327. },
  328. tableRowClick(record, index) {
  329. this.state.RowData = record;
  330. this.setState({
  331. showDesc: true
  332. });
  333. },
  334. delectRow() {
  335. let deletedIds = [];
  336. for (let idx = 0; idx < this.state.selectedRows.length; idx++) {
  337. let rowItem = this.state.selectedRows[idx];
  338. if (rowItem.id) {
  339. deletedIds.push(rowItem.id)
  340. }
  341. };
  342. this.setState({
  343. selectedRowKeys: [],
  344. loading: deletedIds.length > 0
  345. });
  346. $.ajax({
  347. method: "POST",
  348. dataType: "json",
  349. crossDomain: false,
  350. url: globalConfig.context + "/api/user/cognizance/deleteOrgTechCenterDetail",
  351. data: {
  352. ids: deletedIds
  353. }
  354. }).done(function (data) {
  355. if (!data.error.length) {
  356. message.success('保存成功!');
  357. this.setState({
  358. loading: false,
  359. });
  360. } else {
  361. message.warning(data.error[0].message);
  362. };
  363. this.loadData();
  364. }.bind(this));
  365. },
  366. closeDesc(e, s) {
  367. this.state.showDesc = e;
  368. if (s) {
  369. this.loadData();
  370. };
  371. },
  372. saveCenterDetail() {
  373. this.setState({
  374. loading: true
  375. });
  376. $.ajax({
  377. method: "post",
  378. dataType: "json",
  379. crossDomain: false,
  380. url: globalConfig.context + "/api/user/cognizance/disposeCenter",
  381. data: {
  382. id: this.state.cid,
  383. principal: this.state.principal,
  384. systemUrl: this.state.systemUrl,
  385. systemCatalog: this.state.systemCatalog,
  386. foundingTimeFormattedDate: this.state.foundingTime,
  387. comment: this.state.comment,
  388. centerName: this.state.centerName
  389. }
  390. }).done((data) => {
  391. if (!data.error.length) {
  392. message.success('保存成功!');
  393. this.loadOrgTechCenterDetail();
  394. this.setState({
  395. loading: false,
  396. });
  397. } else {
  398. message.warning(data.error[0].message);
  399. };
  400. });
  401. },
  402. render() {
  403. const rowSelection = {
  404. selectedRowKeys: this.state.selectedRowKeys,
  405. onChange: (selectedRowKeys, selectedRows) => {
  406. this.setState({
  407. selectedRows: selectedRows,
  408. selectedRowKeys: selectedRowKeys
  409. });
  410. }
  411. };
  412. const hasSelected = this.state.selectedRowKeys.length > 0;
  413. return (
  414. <div className="user-content" >
  415. <div className="content-title">
  416. <span>研发部门</span>
  417. </div>
  418. <div className="clearfix">
  419. <div className="orgTech-item">
  420. <span>研发部门名称: </span>
  421. <Input
  422. value={this.state.centerName}
  423. onChange={(e) => { this.setState({ centerName: e.target.value }); }}
  424. />
  425. <span>成立时间: </span>
  426. <DatePicker
  427. value={moment(this.state.foundingTime)}
  428. allowClear={false}
  429. onChange={(date, dateString) => { this.setState({ foundingTime: dateString }); }}
  430. />
  431. <span>负责人: </span>
  432. <Input
  433. value={this.state.principal}
  434. onChange={(e) => { this.setState({ principal: e.target.value }); }}
  435. />
  436. </div>
  437. <div className="orgTech-item">
  438. <span>制度目录: </span>
  439. <Input type='textarea' rows={6}
  440. value={this.state.systemCatalog}
  441. onChange={(e) => { this.setState({ systemCatalog: e.target.value }); }}
  442. />
  443. </div>
  444. <div className="orgTech-item">
  445. <span>备注: </span>
  446. <Input type='textarea' rows={3}
  447. value={this.state.comment}
  448. onChange={(e) => { this.setState({ comment: e.target.value }); }}
  449. />
  450. </div>
  451. </div>
  452. <div className="half-item">
  453. <p>制度上传: (上传 zip 或者 rar 文件)</p>
  454. <div style={{ margin: '10px 0' }}>
  455. <Upload
  456. name="ratepay"
  457. action={globalConfig.context + "/api/user/cognizance/uploadInstitution"}
  458. data={{ 'sign': 'institution' }}
  459. beforeUpload={beforeUploadFile}
  460. showUploadList={false}
  461. onChange={(info) => {
  462. if (info.file.status !== 'uploading') {
  463. console.log(info.file, info.fileList);
  464. }
  465. if (info.file.status === 'done') {
  466. if (!info.file.response.error.length) {
  467. message.success(`${info.file.name} 文件上传成功!`);
  468. } else {
  469. message.warning(info.file.response.error[0].message);
  470. return;
  471. };
  472. this.state.systemUrl = info.file.response.data;
  473. } else if (info.file.status === 'error') {
  474. message.error(`${info.file.name} 文件上传失败。`);
  475. }
  476. }}
  477. >
  478. <Button disabled={this.state.ButtonDisabled}><Icon type="upload" /> 上传研发部门制度 </Button>
  479. </Upload>
  480. <p style={{ marginTop: '10px' }}>{this.state.systemUrl ? <a onClick={newDownloadFile.bind(null, this.state.cid, 'institution', '/api/user/cognizance/downloadInstitution')}>{this.state.systemDownloadFileName}</a> : <span><Icon type="exclamation-circle" style={{ color: '#ffbf00', marginRight: '6px' }} />未上传!</span>}</p>
  481. </div>
  482. </div>
  483. <Button disabled={this.state.ButtonDisabled} type='primary' onClick={this.saveCenterDetail}>保存</Button>
  484. <div className="content-title" style={{ marginTop: '10px' }}>
  485. <span>产学研情况</span>
  486. </div>
  487. <div className="user-search">
  488. <p>
  489. <Button style={{ background: "#ea0862", border: "none", color: "#fff" }}
  490. disabled={this.state.ButtonDisabled}
  491. onClick={this.tableRowClick}>添加<Icon type="plus" /></Button>
  492. <Button style={{ background: "#3fcf9e", border: "none", color: "#fff" }}
  493. disabled={!hasSelected}
  494. onClick={this.delectRow}>删除<Icon type="minus" /></Button>
  495. </p>
  496. </div>
  497. <div className="patent-table">
  498. <Spin spinning={this.state.loading}>
  499. <Table columns={this.state.columns}
  500. dataSource={this.state.dataSource}
  501. pagination={this.state.pagination}
  502. rowSelection={rowSelection}
  503. onRowClick={this.tableRowClick} />
  504. </Spin>
  505. </div>
  506. <CenterListDesc data={this.state.RowData}
  507. showDesc={this.state.showDesc} closeDesc={this.closeDesc} />
  508. </div >
  509. );
  510. }
  511. });
  512. export default CenterList;