orgTechCenter.jsx 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506
  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 + "/techservice/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.closeModal();
  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 + "/techservice/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>未上传!</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);
  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} />
  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 + "/techservice/cognizance/center",
  198. data: {
  199. }
  200. }).done((data) => {
  201. if (!data.data) {
  202. if(data.error.length) {
  203. message.warning(data.error[0].message);
  204. }
  205. return;
  206. };
  207. this.state.cid = data.data.id;
  208. this.state.foundingTime = data.data.foundingTimeFormattedDate;
  209. this.state.principal = data.data.principal;
  210. this.state.systemCatalog = data.data.systemCatalog;
  211. this.state.systemUrl = data.data.systemUrl;
  212. this.state.systemDownloadFileName = data.data.systemDownloadFileName;
  213. this.state.centerName = data.data.centerName;
  214. this.state.comment = data.data.comment;
  215. this.loadData();
  216. }).always(function () {
  217. this.setState({
  218. loading: false
  219. });
  220. }.bind(this));
  221. },
  222. loadData(pageNo) {
  223. this.state.data = [];
  224. this.setState({
  225. loading: true
  226. });
  227. $.ajax({
  228. method: "post",
  229. dataType: "json",
  230. crossDomain: false,
  231. url: globalConfig.context + "/techservice/cognizance/centerDetail",
  232. data: {
  233. pageNo: pageNo || 1,
  234. pageSize: this.state.pagination.pageSize,
  235. cid: this.state.cid
  236. }
  237. }).done((data) => {
  238. if (!data.data || !data.data.list) {
  239. if(data.error.length) {
  240. message.warning(data.error[0].message);
  241. }
  242. return;
  243. };
  244. for (let i = 0; i < data.data.list.length; i++) {
  245. let thisdata = data.data.list[i];
  246. this.state.data.push({
  247. key: i,
  248. id: thisdata.id,
  249. cid: thisdata.cid,
  250. projectTimeFormattedDate: thisdata.projectTimeFormattedDate,
  251. projectName: thisdata.projectName,
  252. protocolDownloadFileName: thisdata.protocolDownloadFileName,
  253. protocolUrl: thisdata.protocolUrl,
  254. protocol: [thisdata.protocolUrl, thisdata.protocolDownloadFileName],
  255. institution: thisdata.institution,
  256. termTimeFormattedDate: thisdata.termTimeFormattedDate
  257. });
  258. };
  259. this.state.pagination.current = data.data.pageNo;
  260. this.state.pagination.total = data.data.totalCount;
  261. this.setState({
  262. dataSource: this.state.data,
  263. pagination: this.state.pagination
  264. });
  265. }).always(function () {
  266. this.setState({
  267. loading: false
  268. });
  269. }.bind(this));
  270. },
  271. getInitialState() {
  272. return {
  273. selectedRowKeys: [],
  274. selectedRows: [],
  275. loading: false,
  276. pagination: {
  277. defaultCurrent: 1,
  278. defaultPageSize: 10,
  279. showQuickJumper: true,
  280. pageSize: 10,
  281. onChange: function (page) {
  282. this.loadData(page);
  283. }.bind(this),
  284. showTotal: function (total) {
  285. return '共' + total + '条数据';
  286. }
  287. },
  288. columns: [
  289. {
  290. title: '时间',
  291. dataIndex: 'projectTimeFormattedDate',
  292. key: 'projectTimeFormattedDate'
  293. }, {
  294. title: '名称',
  295. dataIndex: 'projectName',
  296. key: 'projectName'
  297. }, {
  298. title: '期限',
  299. dataIndex: 'termTimeFormattedDate',
  300. key: 'termTimeFormattedDate'
  301. }, {
  302. title: '大学机构',
  303. dataIndex: 'institution',
  304. key: 'institution'
  305. }, {
  306. title: '协议附件',
  307. dataIndex: 'protocol',
  308. key: 'protocol',
  309. render: (text) => {
  310. return <a onClick={downloadFile.bind(null, text[0], text[1])}>{text[1]}</a>
  311. }
  312. }
  313. ],
  314. dataSource: []
  315. };
  316. },
  317. componentWillMount() {
  318. this.loadOrgTechCenterDetail();
  319. },
  320. tableRowClick(record, index) {
  321. this.state.RowData = record;
  322. this.setState({
  323. showDesc: true
  324. });
  325. },
  326. delectRow() {
  327. let deletedIds = [];
  328. for (let idx = 0; idx < this.state.selectedRows.length; idx++) {
  329. let rowItem = this.state.selectedRows[idx];
  330. if (rowItem.id) {
  331. deletedIds.push(rowItem.id)
  332. }
  333. };
  334. this.setState({
  335. selectedRowKeys: [],
  336. loading: deletedIds.length > 0
  337. });
  338. $.ajax({
  339. method: "POST",
  340. dataType: "json",
  341. crossDomain: false,
  342. url: globalConfig.context + "/techservice/cognizance/deleteOrgTechCenterDetail",
  343. data: {
  344. ids: deletedIds
  345. }
  346. }).done(function (data) {
  347. if (!data.error.length) {
  348. message.success('保存成功!');
  349. this.setState({
  350. loading: false,
  351. });
  352. } else {
  353. message.warning(data.error[0].message);
  354. };
  355. this.loadData();
  356. }.bind(this));
  357. },
  358. closeDesc(e) {
  359. this.state.showDesc = e;
  360. this.loadData();
  361. },
  362. saveCenterDetail() {
  363. this.setState({
  364. loading: true
  365. });
  366. $.ajax({
  367. method: "post",
  368. dataType: "json",
  369. crossDomain: false,
  370. url: globalConfig.context + "/techservice/cognizance/disposeCenter",
  371. data: {
  372. id: this.state.cid,
  373. principal: this.state.principal,
  374. systemUrl: this.state.systemUrl,
  375. systemCatalog: this.state.systemCatalog,
  376. foundingTimeFormattedDate: this.state.foundingTime,
  377. comment: this.state.comment,
  378. centerName: this.state.centerName
  379. }
  380. }).done((data) => {
  381. if (!data.error.length) {
  382. message.success('保存成功!');
  383. this.loadOrgTechCenterDetail();
  384. this.setState({
  385. loading: false,
  386. });
  387. } else {
  388. message.warning(data.error[0].message);
  389. };
  390. });
  391. },
  392. render() {
  393. const rowSelection = {
  394. selectedRowKeys: this.state.selectedRowKeys,
  395. onChange: (selectedRowKeys, selectedRows) => {
  396. this.setState({
  397. selectedRows: selectedRows,
  398. selectedRowKeys: selectedRowKeys
  399. });
  400. }
  401. };
  402. const hasSelected = this.state.selectedRowKeys.length > 0;
  403. return (
  404. <div className="user-content" >
  405. <div className="content-title">
  406. <span>研发部门</span>
  407. </div>
  408. <div className="clearfix">
  409. <div className="orgTech-item">
  410. <span>研发部门名称: </span>
  411. <Input
  412. value={this.state.centerName}
  413. onChange={(e) => { this.setState({ centerName: e.target.value }); }}
  414. />
  415. <span>成立时间: </span>
  416. <DatePicker
  417. value={moment(this.state.foundingTime)}
  418. allowClear={false}
  419. onChange={(date, dateString) => { this.setState({ foundingTime: dateString }); }}
  420. />
  421. <span>负责人: </span>
  422. <Input
  423. value={this.state.principal}
  424. onChange={(e) => { this.setState({ principal: e.target.value }); }}
  425. />
  426. </div>
  427. <div className="orgTech-item">
  428. <span>制度目录: </span>
  429. <Input type='textarea' rows={6}
  430. value={this.state.systemCatalog}
  431. onChange={(e) => { this.setState({ systemCatalog: e.target.value }); }}
  432. />
  433. </div>
  434. <div className="orgTech-item">
  435. <span>备注: </span>
  436. <Input type='textarea' rows={3}
  437. value={this.state.comment}
  438. onChange={(e) => { this.setState({ comment: e.target.value }); }}
  439. />
  440. </div>
  441. </div>
  442. <div className="half-item">
  443. <p>制度上传: (上传 zip 或者 rar 文件)</p>
  444. <div style={{ margin: '10px 0' }}>
  445. <Upload
  446. name="ratepay"
  447. action={globalConfig.context + "/techservice/cognizance/upload"}
  448. data={{ 'sign': 'institution' }}
  449. beforeUpload={beforeUploadFile}
  450. showUploadList={false}
  451. onChange={(info) => {
  452. if (info.file.status !== 'uploading') {
  453. console.log(info.file, info.fileList);
  454. }
  455. if (info.file.status === 'done') {
  456. if (!info.file.response.error.length) {
  457. message.success(`${info.file.name} 文件上传成功!`);
  458. } else {
  459. message.warning(info.file.response.error[0].message);
  460. return;
  461. };
  462. this.state.systemUrl = info.file.response.data;
  463. } else if (info.file.status === 'error') {
  464. message.error(`${info.file.name} 文件上传失败。`);
  465. }
  466. }}
  467. >
  468. <Button><Icon type="upload" /> 上传研发费用台账 </Button>
  469. </Upload>
  470. <p style={{ marginTop: '10px' }}>{this.state.systemUrl ? <a onClick={downloadFile.bind(null, this.state.systemUrl, this.state.systemDownloadFileName)}>{this.state.systemDownloadFileName}</a> : <span>未上传!</span>}</p>
  471. </div>
  472. </div>
  473. <Button type='primary' onClick={this.saveCenterDetail}>保存</Button>
  474. <div className="content-title">
  475. <span>产学研情况</span>
  476. </div>
  477. <div className="user-search">
  478. <p>
  479. <Button style={{ background: "#ea0862", border: "none", color: "#fff" }}
  480. onClick={this.tableRowClick}>添加<Icon type="plus" /></Button>
  481. <Button style={{ background: "#3fcf9e", border: "none", color: "#fff" }}
  482. disabled={!hasSelected}
  483. onClick={this.delectRow}>删除<Icon type="minus" /></Button>
  484. </p>
  485. </div>
  486. <div className="patent-table">
  487. <Spin spinning={this.state.loading}>
  488. <Table columns={this.state.columns}
  489. dataSource={this.state.dataSource}
  490. pagination={this.state.pagination}
  491. rowSelection={rowSelection}
  492. onRowClick={this.tableRowClick} />
  493. </Spin>
  494. </div>
  495. <CenterListDesc data={this.state.RowData}
  496. showDesc={this.state.showDesc} closeDesc={this.closeDesc} />
  497. </div >
  498. );
  499. }
  500. });
  501. export default CenterList;