orgTechCenter.jsx 21 KB

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